Search This Blog

Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

Configuring zRAM on the Sony Xperia Play with FreeXperia Zeus

If you have unlocked your Xperia Play and installed FreeXperia (+CyanogenMod  9.1) then you will quickly discover that enabling zRAM via the Performance settings has no effect whatsoever.





















I have reported this as a bug but the project team seem more interested in burying their head in the sand so you won't get any help at all from them. I even asked for help on the +FreeXperia +Google+ page but I gave up on asking for any help from anyone there a long time ago.

The provided Linux kernel definitely does have zRAM enabled.

# ll /dev/block/zram*
brw-------    1 root         root          253,   0 Sep 10 13:10 /dev/block/zram0

The problem lies within the UI to configure it. No scripts seem to be created or executed so either the option is a stub or it is simply broken.

Initially I decided to use SetXperia which, again, proves that the kernel part is fine, but SetXperia remains in RAM all the time, and even in the notification area. I just don't see the point in that.

It can't be that difficult to enable zRAM, right?

Using the Ubuntu zram-config package it was fairly easy to work out what was needed and hence create a script.

#!/system/bin/sh

SWAPPINESS="35"
TAG="zram-config"

log -p i -t $TAG "Setting vm.swappiness to $SWAPPINESS"
logwrapper sysctl -w vm.swappiness=$SWAPPINESS
log -p i -t $TAG "Done."

log -p i -t $TAG "Setting up zram"
echo 75497472 > /sys/block/zram0/disksize
logwrapper mkswap /dev/block/zram0
logwrapper swapon /dev/block/zram0
log -p i -t $TAG "Done."

log -p i -t $TAG "All done."

I dropped this script into /data/local/userinit.d/zram-config (remember to set +x on the script).

All the log and logwrapper stuff is obviously to send details to the log. It probably doesn't work as the script is run before Android is loaded. Indeed, I've never seen anything using logcat unless it's run manually. They are not needed for the script to work.

vm.swappiness is set to 60 by default. You shouldn't change that unless you know what you're doing. In my case sysctl -w vm.swappiness=35 does this. I could not find a config file for sysctl (such as /etc/sysctl.conf) as is the case for most Linux distributions.

The Ubuntu script sets up the amount of zRAM based on the amount of RAM and creates separate devices based on the number of cores, which makes sense because it's a generic script to be used on a vast array of machines including, recently, mobile platforms. There's no real need to do that unless you plan on dropping the script on a variety of different devices. You should decide for yourself how much zRAM you want to configure.

echo 75497472 > /sys/block/zram0/disksize sets my zRAM device to 75 MB.

mkswap /dev/block/zram0 sets up the device as a swap device, as you would with any normal swap.

swapon /dev/block/zram0 enables the swap.

This can, of course, be used with any device that has zRAM enabled in the kernel.

# uname -a
Linux localhost 2.6.32.9-FXP #1 PREEMPT Fri Apr 19 17:37:58 EEST 2013 armv7l GNU/Linux

I recommend installing ZRAM Status from the Play Store so that you can see that your zRAM is being used, along with some interesting, nerdy statistics.




Remember that you will need to reboot your device (or run the script manually) to enable zRAM the first time.

Start the Android media scanner from the command line

If you're like me, and let's hope for your sake that you're not, you find it much easier to run an SSH server on your Android device than using something like adb or USB Mass Storage or any of the other crap out there.

With SSH I can simply and easily check logcat, netstat, issue commands, copy files and generally bugger about.

Sometimes you have moved quite a lot of files around and you need your media scanner to launch to update its database. This can be done via the CLI.

.nomedia is recursive on Android devices

Just a small note but I thought I best mention it as not everyone realises this.

Your /sdcard can often have a lot of garbage in it that you do not necessarily want to appear in your Media Album.

A solution to this is to add .nomedia (a zero byte file) to the directories that you do not want the Media Scanner to scan. What you need to be aware of is that the Media Scanner will skip this whole directory and will not recurse into subfolders. The result being if you drop the file /sdcard/.nomedia then nothing on the SD card will be scanned nor added to the Media Library.

If you're one of those people who drops everything on /sdcard then you need to tidy it up a bit. /sdcard/downloads for example is nearly always the best place to drop your downloads, and you rarely want that stuff scanned. If you do then create new directories:

/sdcard/Music
/sdcard/Movies
/sdcard/Porn

for example.

This way you can simply touch /sdcard/Porn/.nomedia so that it doesn't appear in your Media Album.

BT SmartTalk

I have previously written about how impressed I am by BT's roll out of their 21CN network. I never thought for a second they could impress me even further but they have! I do believe this now makes me a BT fanboi, but I'm cool with that because I'll be an adult soon.

Whilst messing around on the Internet and checking my telephone usage I stumbled across BT SmartTalk. SmartTalk is not new technology. It is basically a VoIP service operated by BT where your calls are routed over the Internet and you are billed to your BT bill. This means you can bill your landline at landline rates, and not have to pay the ridiculous charges mobile operators get away with (such as charging for 0800, higher charges for 0844, 0845, etc.) and even call back to the UK at UK standard call rates so long as you have an Internet connection. And it's free!

In Australia and want to call home? Got a plan that gives you free calls to landlines? It won't cost a penny!

Dropbear SSH server on Android

It's safe to say that if you're reading this then you know why one would want an SSH server running on your Android device. Personally I have SSH running on all my Linux boxes because it makes life so much easier, and I'm sure I do not need to explain why. Having an SSH server start on boot is simply a lot more convenient!

There are a number of apps on the Android market but most of them are utterly useless with one exception: SSHDroid.

If you are likely to use SSH once in a while then it may be easier for you to just install SSHDroid on your device and start it when needed, and I have been happy with it for a while.

However:
  1. It's an ugly app that sits in your notification tray once it has been started and uses up RAM and CPU. I want a background app.
  2. SSHDroid refuses to run if it cannot access adverts unless you pay for it. I block all adverts because they get on my nerves.
  3. All it does is drop a copy of Dropbear anyway, so you may as well do that yourself.
  4. Dropbear will happily run in the background and uses tiny amounts of CPU when active, so you can imagine how little it does when idle.
  5. If you can compile Dropbear yourself you can choose the options that you want.
As I'm sure you are aware there is no package delivery system for this kind of application in Android, but Android runs on a modified Linux kernel - this makes things so much easier! The result being that the following process is ridiculously easy assuming that your OS has:
  • su or sudo (root)
  • init.d support (or another way to run scripts at startup)
The only problem, really, is that the filesystem and methods used in Android aren't exactly standard compared to other *nix systems, but its not massively different. The result being that there are a number of ways that you can get things to work, so I'll simply show you what I have done. If I was doing this to a number of devices or in a corporate environment then I would use a bit more planning.

YouTube is utterly broken

Google have recently made a whole bunch of changes across most of their platforms to, apparently, integrate more easily with Google+. One of the platforms affected is YouTube. But YouTube also decided to introduce a new video format at the same time, namely 140p (around 32kbps, presumably for dial-up users).

At the exact same time my ISP, O2, sold their broadband network to Sky, more's the pity. I have been informed that there should have been no changes to my ISP in any way... yet.

If that is the case then YouTube is definitely broken.

Nuisance 1
Connection: Ethernet --> ADSL2+

The first problem which became apparent was that the Wii client couldn't play videos any more, or not for more than a few seconds anyway. When it did play it would randomly stop to buffer only a few seconds at a time, and sometimes give up altogether and exit the video. I am not alone:
YouTube on Wii keeps buffering. It won't load more than 30 seconds of video.

Nuisance 2
Connection: Any

The second problem was on the trusty browser. In my case Chromium on Ubuntu 12.04.

I seem to have been volunteered to join the HTML5 trial, which I really didn't mind except that it doesn't bloody work.



The video above is Big Buck Bunny downloaded in H264 format at 1080p. It refuses to play in the HTML5 player. To be fair this has only been uploaded a few hours ago and may need time to prepare/transcode/whatever, but as a general rule the HTML5 player fails on videos a LOT.

Switching back to Flash for affected videos can still give the same message, but continually hitting refresh tends to get the damned thing working.

Nuisance 3
Connection: Any

Another problem is that the video will play for a few seconds, usually the magic number of 19 seconds, and then stop, never to continue. Hitting refresh a number of times is required for this to start working too. See the video in Nuisance 4 for an example of this.

Nuisance 4
Connection: Wi-Fi --> ADSL2+

With my 3Mbps down connection I have been able to play 720p YouTube videos for quite a while. If someone else is on the network then it would happily drop down to 480p and play nicely. Not any more!

For reasons unknown the quality jumps up and down, preferentially towards the new 144p format. This is simply ridiculous! At 144p some videos are nothing more than a jumble of pixels. I have deliberately chosen a picture slideshow to show this as quality should be easy to maintain (very little motion). The video is 1080p.



This video shows a typical example of what happens (approximate times):

0:00 "An error occurred, please try again".
0:27 480p
0:37 Video stops altogether as the download stream fails and there is not enough video buffered.
0:45 144p
0:55 480p
1:13 240p
1:45 360p
2:20 144p

Perhaps the ISP or the connection to the router is the problem? Well, I tested this by downloading Big Buck Bunny. This was over Wi-Fi. Caution: this is a very dull video.



tldw; The video basically shows a number of drops in download speed. If I was sensible I would compare this to a wired connection but I don't feel there is any point: the drop-outs are minimal and very short lived. The download (of Big Buck Bunny) is not affected. I also have no other problems with connection on this computer ever. I feel fairly safe to conclude that the signal is not the problem and given that YouTube is supposed to buffer to avoid these problems, that this is not the cause. Uploading is a very similar story. In this instance it's an upload to YouTube of Big Buck Bunny. An equally dull video.

Reported.

Nuisance 5
Connection: Wi-Fi --> Any

On mobile, the video usually plays quite well, but recently has decided to simply pause for no reason. Hitting play will start it up again but... Nuisance 6.

Not tested over a mobile network yet but I cannot imagine it makes a difference.

Reported.

Nuisance 6
Connection: Any

On both mobile and web the video should buffer. It doesn't really matter if it does, however. Once paused, either intentionally or because the mobile just felt like it, the video continues to buffer. When clicking play the entire buffer is lost and the video starts downloading again. What the Hell is the point in the video buffering if it's just going to dump the buffer anyway? A wonderful waste of bandwidth.

Pausing used to be useful if I wanted to buffer a whole video in 1080p and watch it in this higher quality. Now it is simply impossible!

The Android app has a solution: pre-loading. Add the video to "Watch later" and it will download the whole video. Annoyingly if you don't watch every video you have pre-loaded immediately then there is a notification on the phone "reminding" you that you have pre-loading enabled and you're not watching the videos. P.I.T.A.

Nuisance 7
Connection: Ethernet --> Powerline --> Ethernet --> ADSL2+

This has never worked. I have a Philips Blu-ray player which comes with a YouTube app (probably Java).

The problem being that the bloody stupid thing makes no attempt to discover the maximum download speed. This means that it will play at the highest quality, no matter what it is. At 3 Mbps my connection cannot handle 1080p (or in some cases 720p) and so continually stops, buffers a BIT (pausing is no use) and then goes through the process again. There is no solution. Even using the Android app the quality cannot be amended.



I thought this app may be maintained by Philips, but it has the same layout as other T.V. apps for YouTube so I don't know who maintains the code. Either way it's cack.

Reported.

Nuisance 8
Connection: Ethernet --> Powerline --> Ethernet --> ADSL2+

Same equipment as above. The Wii works fine using the Android app as a remote control. On the Blu-ray player it often does whatever the Hell it likes. It nearly always starts the video twice, sometimes three times, and often randomly switches the video. Sometimes it plays a video I played a while ago because it seems to have created a play list and decides to play that from the beginning. The whole thing is just garbage! The responsiveness is generally poor on the YouTube app on this Blu-ray player anyway. The Blu-ray player itself seems underpowered but it plays all kinds of HD files without any problem.

(The Picasa app cannot handle video at all, but makes no attempt to filter them.)

I'm sure there are more but I think I've said enough for now.

YouTube is utterly broken!

TVCatchup for Android - don't bother

I have this problem when trying to stream the TVCatchup RTSP stream on my Android phone.

I was informed that an Android app is currently under development, so I thought I would give it a go, see if it makes any difference.

I did explain what the problem was, but the "developer" failed to tell me that it would make no difference, but I had to find that out for myself.

The first thing I noticed once installed on my phone was that it consumed a ridiculous amount of internal storage, despite the fact it was installed on my SD card.

For reasons unknown, by neither the development team nor I, the data used was over 2MB and the cache another 2MB. My internal storage reduced by 7MB and I still have no idea why, and neither do they.

The result? Well, I had to uninstall it as the internal memory is very restricted on my phone.

The uninstaller immediately crashed and caused my phone to reboot. On boot it was obvious that the phone believed that the app had been removed but only 4MB of internal storage had been recovered, and this was probably because I had the good sense to clear the stored data and cache.

I reported this on the feedback forum with a clear explanation of what had happened. In fact, the explanation above should be adequate, so it would be impossible for anyone with any knowledge of computing to be puzzled as to how I have come to the conclusion that the fault is with their software.

The first reply was from TVC_Colwal who copy-and-pasted some nonsense from a Wiki site about installing apps onto an SD card, despite the fact I had already explained what I had done. I had to repeat myself.

The second reply was from legoUK who told me that I was wrong, because the app is only around 1MB in size. I could not believe the stupidity of these people. This was the second time my original post had been ignored. I made it very clear in my reply that this person clearly doesn't know anything about .apk files nor the Android system.

The third reply was TVC_Colwal telling me that legoUK was the developer, I was rude, and that they were trying to help me. There are three things wrong with that statement.
  1. Neither of these clowns bothered reading my original post, or understood what I was saying.
  2. I was providing THEM with feedback, and at no point did they try to understand or discover what was causing the runaway waste of storage due to THEIR application. I was helping them and they have the cheek to claim the reverse is true!
  3. I consider it rude to completely ignore what you've been told, or just fob someone off with some Wiki rubbish that they clearly don't understand.
The solution? There wasn't one. I wasn't going to get any help from Dumpty and Numpty so I had to go out hunting myself. I found this very useful page about what can and can't be cleaned up, and from there I figured out how to remove all the shite that came bundled with my latest firmware update, saving a significant amount of space. Unfortunately I never found out what damage had been done by the awful TVCatchup software. I'm guessing fsck didn't find anything either as the space was never freed.

As for the app itself?

Well, on web pages TVCatchup.com first plays an advertisement before showing you the channel. On mobile RTSP though, they did not do this. It is possible, both through RTSP and on the mobile web page, but I doubt they have any idea how to do this.

The first improvement I noticed was that there was a brief TV guide included, to show you what's on Now and Next. Very handy, although I would recommend this app from TVGuide.co.uk.

This was the only improvement, things got worse from this point on.

The video, when it starts playing over RTSP (yes, there is no point in this app at all), is intentionally orientated incorrectly so that a banner can be continually shown. So, not only does the video not fit the screen, they can now show you even more advertisements continually. Ever wished you had more advertising on TV? Well now you can!

And that is it. Literally. The app is clearly a way for TVCatchup so show more adverts, and serves no other purpose. There is this but... well, just look at it.

Advantages:
  • A Now and Next TV guide, although there is much better out there.

Disadvantages:
  • The app will bugger your internal storage.
  • The developers have no idea what they're doing.
  • The screen is not watchable.
  • There are more advertisements.

Don't bother.

[Update]

In response to this post, their Twitter twit, who types like a teenage girl, responded:









This shows exactly what kind of people work there, lol.
My profile on StackExchange