Android, Open Source and a self-induced hackathon

Posted on Apr 11, 2013 in All Articles, Featured Articles, Linux and Open Source, Technology, Writing

tl;dr Android as a whole -from Google’s code repository to cheap Chinese tablets- is open source to a certain extent but, although this acts as a cushion for poor product releases, it isn’t an excuse.

Some weeks ago I had to spend more time than usual to get my Android devices do my binding; more time as in four (4) days!

When it comes to Android, I am an advanced user, having rooted and flashed some ROMs on my devices. Also, due to my Linux knowledge, Android’s lower levels don’t feel that strange to me.

That said, without any specific knowledge, in 4 days I got to resolve a hardware (software related though) issue, write a really basic Android application, submitted it to Play store and create a custom ROM image by using a ready made ROM as base (some orders of magnitude easier than compiling cyanogenmod).

For any Linux user, Android has a low entry hacking barrier.

Day 1: hardware hacking on Samsung’s Galaxy R i9103 phone

I like photography. Since the 1st day, one and a half year ago, being on Android GB 2.3, my Samsung Galaxy R didn’t permit for exposure compensation (and consequently HDR) from any 3rd party app. This was unacceptable. I emailed various app developers about this, but it was a device specific problem they could not solve. The trend continued even when Samsung released Android ICS 4.0.1 for my model.

Since I upgraded to a custom, almost alpha, version of CM 10.1, I thought it was about time to solve it myself. I downloaded kernel sources, CM sources, did some online search, did some grepping and found possible places of failure. Although in the end I could describe perfectly the problem, like which Android framework’s call were failing to provide accurate data, I couldn’t tell where exactly the failure happened. The kernel driver returned correct information, yet Android framework reported them wrong (or probably reported some default Android values).

Samsung had fixed this in their camera apk. Yeap, they knew the problem and instead of fixing it properly, they opt to fix it only for their built-in camera app, breaking any 3rd party app from Google Play. Kudos Samsung for being a douchebag.

I would report the problem to the CM developer but I wanted an easy fix (and proof of concept) for myself. I decided that the easiest way for me, would be to hardcode my device’s capabilities inside Android’s framework. But again, compiling CM from source, isn’t the easiest path possible. So, hello Dalvik assembly. I downloaded an Android jar/apk disassembler, took framework.jar from my phone, disassemble it, hardcoded my device’s data, reassemble it and I was ready. I could now both describe the problem and provide a proof-of-concept fix, since many people didn’t want to aknowledge that their device had a problem.

Suffice it to say, for the next few days, I only took HDR photos. :D

For the technical oriented, you could see my post over XDA which explains the problem:

So, day 1 ended. I learned a bit about Android kernel, CM/Android sources, CM development model, Android’s framework, Android’s Dalvik assembly.

Day 2: hacking on Android Jelly Bean, releasing an app

Day 1 was Monday. On Tuesday I received a chinese Android tablet I had ordered a month before. I spent the best part of this day shooting HDR and playing with the tablet. Day 2 was Wednesday.

I sincerely think that Android can be used for some work, though this may require a hardware keyboard. I connected a usb keyboard to my tablet and was delighted to find that Android JB 4.1 has proper support for hardware keyboards. Unfortunately though, it didn’t support Greek. Thankfully, language layouts could be added via 3rd party apps, but none was available for Greek.

There was one paid app in Play, that supported Greek via a hardware keyboard by implementing a software keyboard. That may be needed for older Android versions but not for Jelly Bean which lets you use any software keyboard (and its correction/prediction methods) with your physical keyboard. Also its cost was about €2.5, which I think is a bit too much for anyone who just want to write in his mother tongue.

Open source wins again and after some search, I found an open source project which added an English variant layout to Jelly Bean. This was a good start.

I downloaded it and tried to compile it since I had Android SDK installed because I needed adb. It couldn’t compile because I had an older Android SDK and also the downloaded project included some configuration files that I should create myself.

After a quick course in Android’s build system and an update to the SDK, I could compile it myself. It took me some trials to understand the format Android uses to describe keyboard layouts. Google’s documentation is good but I think in this case, it could be a little better. When I understood the format,  it took me a couple of hours, at most, to transfer the Greek layout and get something that worked.

But I couldn’t stop there. I wanted to be easy for all people to write in Greek, so I decided to uploaded it to Google Play.

I got myself a Google developer account and paid the $25 fee, a tad ironic since earlier I refused to buy the €2.5 app, but this was different. Then I learned that in order to upload an app to Google Play, I have to add icons to my application, to write descriptions, to add screenshots etc.

All these took about as much time, as the development process. I had to learn about android resources (how to add icons to an app for various resolutions), I had to create an icon, to stage some screenshots from the mobile phone because the tablet had a non standard screen resolution which Google wouldn’t accept, write an accurate description and translate it to Greek.

For the icon, I couldn’t find a decent icon of a keyboard button with a permissive enough license, so I resorted to my camera and used a photo of my keyboard. I am not very happy with the result, but it was the best I could get. We should introduce more artists to free software.

Last, I wrote about my app in a couple of forums that I am a regular, respecting each forum’s rules (aka I didn’t spam).

So, day 2 ended. I learned a bit about Android’s build system, Android’s SDK, Android Programming, Google Play. In the morning I knew nothing about developing an app. In the evening my app was published (and visible) in Google Play. I don’t think Google can lower this barrier any further.

Oh, of course my app’s source code is available. Head over to github to check it out:

Day 3 and 4: ROM/hardware/software hacking over Pipo S2 tablet

This wasn’t as exciting. The chinese tablet (a Pipo Max S2) had a decent ROM but with some shortcomings, like the absence of root and an easy way to root, as well as some built in apps I didn’t need to use my resources.

No one had released an acceptable -for me- ROM for the tablet. There was one ROM available at the time but it was very obtrusive for my taste, masquerading the tablet as a Samsung Galaxy S2 phone and tampering with framework.jar in unknown to me ways. So I thought I should release a ROM (a first for me) for all to enjoy.

I started by learning a bit about the tools you need to flash a RK3066 device. After that it was a matter of mounting an image and using my Android and linux knowledge to do some changes. It took me enough time though, because I would never risk to release a firmware less than perfect. So every step needed much testing.

I wanted to add nfs and smb support, so I downloaded some kernel sources and tried to built them. I couldn’t get working modules, so I used some that I found ready on the net. I needed to run some commands at startup, so I learned a bit about Android’s init. I wanted to add support for usb devices (disabled on Android’s level due to being flakky) so I learned a bit about Android permissions. I found that performance was IO bounded, so I tried to enhance it a bit. The default notification ringtone could cause a heart attack, so I changed it.

It was fun, like hacking around a distribution, but not that great of a learning experience. I posted it to a couple of forums, got some feedback, adjusted some issues and issued an update.

So, days 3 and 4 ended. I learned a bit about Android’s OS level workings, I learned a bit about cross compiling, I learned a bit about proprietary embedded boards.


I am awesome! :p

No, seriously. Open source is awesome. Android is mostly awesome. Android devices are nice but not always awesome.

Should Samsung get away by the fact that they sold me a handset they knew to be broken? They programmed their own app to work around the problem, so they can’t deny that they had knowledge of it. They sold me a smartphone that couldn’t run 3rd party apps properly, so should we still consider it a smartphone?

Should Google get away by the fact that they didn’t include a Greek layout for physical keyboards in Android 4.1 nor in Android 4.2? They do have limited resources, but all it would take for them, would be 2 hours at most for one of their Greek speaking employees to do a completely mechanical task.

As for the Chinese vendor, they are illegal. They do not provide kernel sources as they should (the compiling I mentioned, was for sources provided by other vendors). Due to Android, they are able to sell and make profit of a decent tablet for a low price (below €100) which, because of Android being based on the open source Linux kernel, I was able to tamper with at a (super)user level and adapt partially to my needs. On the other hand, the lack of GPL compliance, means there aren’t serious community efforts to develop a ROM from scratch, or a way to use a more recent Android version, or for someone to try to improve the flakky usb support. We are at the vendor’s mercy to get updates and fixes.

Android shows the way. But we can do better.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>