Archive for August, 2013

Monitor battery discharge in Linux

25 August 2013

I wondered how long the battery of my Acer Aspire One A110-BW would make me ‘socket-less’. Monitoring by hand is not very practical, so I started to bash around and did some low level coding.

The result is a simple script that monitors the discharging of a laptop battery. It starts with reporting basic info on the condition of the battery. Every 60 seconds the power status is written to the same file. The file and its lines have detailed date and time stamps to compare subsequent reports.

The bash script needs acpi installed, it should be in the repo of any Linux distro. You can run it as a regular user. Needless to say that the laptop should run on battery power…

[user@mybox ~]$ ( date && acpi -V | grep Battery ) > `date +%y%m%d_%Hh%M`_batterylog.txt; sleep 60; while x=0; do (( date && acpi -V | grep Discharging) ; sleep 60 ); done >> `date +%y%m%d_%Hh%M`_batterylog.txt

[changed the %H:M to %Hh%M in the output filenameĀ as the colon ‘:’ frustrates filemanagers and other CLI handling]

Bash spreads the output of two subsequent commands (here <date && acpi>) over two lines. I tried <echo -n> to make one line every minute but with no succes yet–it’s something I have to work on. I set monitoring pace to one minute (60 secs) to get detailed reports.

Use this script if you like. If you make interesting improvements I’d like to hear from you!


Rooting my Droid

2 August 2013

Last May I defenately decided to root my Samsung Galaxy 4.2 WiFi. The good news is that it is running flawlessly since! Since buying the device rooting had my interest, but there was no real need to go on this journey. What if it didn’t work and I brick my favorite pocket computer? Could I go back do default? And for rooting: can I find the right images and instructions for rooting a not so much used Android?

After failing to update TalkBack I was definately determined to root my tool. “TalkBack is an Accessibility Service that helps blind and vision-impaired users interact with their devices more easily.” reading the GOOG playstore. It comes pre installed on the Galaxy and I never used it, I have excellent eyevision. But the update required deleting the previous version first before installing the fresh version. Some apps do, no problem. In the case of TalkBack however delete failed because as a Dumb End User of my Droid I had no permissions to delete system apps. For the least this permissions-policy would annoy me with Please-Update-TalkBack messages until the end of time.

On a more fundamental level IMHO Freedom of Choice is a right for all of us. I like to choose the tools I like in the way that suits me best, likewise on my Android. So away with GOOG restrictions on my privately owned pocked device.

How-To in a Human perspective

The technical How-To’s are provided in the links

But how to proceed? After all the Galaxy WiFi is not a very popular model and skilled coders let it be for a long time for the understandable reasons. Last May however I discovered that there were some posts on the xda-developers forum for the Samsung Galaxy Player 4.2. YESSS! I also looked for CyanogenMod for even more freedom, but with no succes on my Galaxy WiFi. Replicant is a parallel initiative.

Meanwhile I convinced myself that rooting my Droid was no different from trying and full use of Linux. Back in 2009 I discovered Linux but it took a while to convince myself that changing or modifying an operating system is quite safe. After all many people did it before and explore new worlds. I don’t say it always is easy, but in fact there are hardly any risks. Development is all about doing things a different way, otherwise you’ll stick up with the old (and often annoying) results. Reading all the right stuff, downloading the proper software and images and backup all your stuff you want to keep.

First I had do find out what version of the Galaxy I had on the table. Strangely enough I don’t own an International version but a North American one. Don’t ask me why these are regulary sold in the Netherlands. I only know some political reasons my country seems to be the 51st State ;-) International and North American devices have different ROM. The XDA forum provides both as well as the stock factoryfs ROM. So in case I didn’t like the result I was able to go back to ‘normal mode’.

Given Enough Eyeballs, Every Problem is Superficial

The International ‘rooting page’ on XDA has a well written how-to providing all neccesary steps. If you like to root your Droid be sute to read and double read these instructions until you know what you’re going to do!

To do the job I had to install ADB to connect and send commands to the Android from my Linux computer. Luckily I discovered a page that instructed only to install specific parts and not the entire set of Android Developer Tools ADT. Lots of this stuff you don’t need when only rooting your Droid. Now ADB told me to install Oracle Java instead of OpenJDK I use in Fedora. Freeing your Droid from GOOG only with the aid of proprietary software? IMHO both companies are kind’o crooky… Besides Java is and ongoing security risk. For the very same Java & Security reasons I use VirtualBox (you’re right, again Oracle) with Linux Mint. This provided an excellent platform to do all the neccesary ‘java-stuff’ in a relatively safe environment–which sands for: not affecting my main Fedora system.

Final part in rooting is flashing the ROM on my Samsung Galaxy. Where Odin is used in Windows environments to do the job, Heimdall is a cross platform alternative for Linux. In past years I more and more learned to appreciate command line operations, but Heimdall also has a graphical shell (which didn’t work for me so I gained full control with CLI). Heimdall was in the Fedora repository. The basic use for flashing with Odin or Heimdall are quite the same.

So far so good, I managed quite well to put the de-googelized ROM on my Droid. Final touch was restoring the WiFi files. It is a common problem that WiFi only works with the original files put back in place.

Up and running!

Now back to where all this fuzz started–to get rid of pre installed software. Although GOOG doesn’t provide us with default root access as common on proper operating systems, the playstore has plenty of apps to manage root functionality. Again this took some late night surfing to decide between the good, bad and ugly. Do I like this app? Why on earth does it want to control networks and camera–the usual suspicious questions. Rootappdelete made the difference for me. I found well written explanations of the working of this app. Great suggestion and feature of this app was first to freeze unwanted apps and see how your Droids performs. Freezing puts the app completely out of work, it only doesn’t delete it in case of trouble or regret. Rootappdelete also colorizes its advice wether it’s safe to put things away and when such can cause nasty problems.

For two and a half months I run my rooted Droid without any trouble. Most of the pre installed and adviced ‘safe to remove’ apps are taken out of order (some Samsung Smart View bluntly refuses). Thanks to the exellent work of hard(er) core coders I was able to change things the way that suits me best and regain my Digital Freedom. This really is something great: people sharing their knowledge, just because they can help others with it. Many Thanks!

There are noticabe less reminders to update things I don’t use and no more of the TalkBack-like issues. One of these days I will permanently delete the apps I put in the freezer to free some memory, also one of the big advantages of rooting. My rooted Droid now has the possibilities to connect to other computers in my home network. Fun–just because it is possible :-) Soon I’ll get this ssh-thing working to out of pocket (literally) and remotely kill these huge and bandwidth consuming media streams of my youngsters. Indeed, a rooted Android is all about getting back control ;-)