Yep, a brand new Fairphone! One of the probably most notable differences of the “Fairphone OS” to any stock Android is, that it does not include, by default, all these little Google thingies like the Play Store, GMail, the Location Service etc.! On the other hand, Fairphone did provide a way to install that crap by downloading an approximately 100 MB sized file from some “secured source”. Fair enough.
Two things to check here. First, where does this download come from and second: how can I control what’s being installed, e.g. to install the Play Store and it’s bare essential dependencies, and nothing else; maybe to exchange some of the frameworks by the great replacements from the NOGAPPS project?
By the way, there’s a really great thread about the Fairphone and it’s Hard- & Software on the XDA-Developers Forum.
Where does this come from?
First of all, I wanted to know where the files get downloaded. A quick search didn’t give satisfactory results. But, there’s a Firmware recovery image available for download. Looking at the APKs residing in /system/apps of that image (which saves quite some time compared to pulling that from the actual device) it is easily discoverable that this “Install Google Apps” widget belongs to FairPhoneHome.apk. The two great tools APKTool and SMALI ease up the digging a lot, and in the end there’s the App’s string-resource XML-File that reveals the download location of the first step:
<string name="gapps_installer_download_url">http://www.fairphone.com/externalcontent/fp_ga.zip</string> <string name="gapps_installer_config_file">fairphonegapps</string> <string name="gapps_installer_zip">.zip</string> <string name="gapps_installer_cfg">.cfg</string>
fp_ga.zip contains two files, fairphonegapps.cfg and fairphonegapps.sig. fairphonegapps.sig seams to be the signature signed with the private key that belongs to the public key in FairPhoneHome.apk’s resources. Being no crypto expert, it’s not easy to tell whether this approach is secure, but a short look at the disassembly and some testing did not reveal any easy way to replace fairphonegapps.cfg.
This file however, contains the link to the “real” GApps archive, together with it’s MD5-Hash.
Well, let’s download that and have a look.
How to change the apps being installed?
The Archive contains the usual set of object files and bundles etc. needed to install the Google Apps. Is copied to the /system volume, the phone will “install” them on the next reboot. The installer contains some hardcoded filenames and desinations, it’s automatically issue the needed remount-command to make /system writable and does all the copying for us. As it’s inconvenient to try to replace the file being downloaded, let’s just install everything we want our own.
The Android-SDK contains a nifty tool called “adb” that allows to connect to the underlying linux-shell of any android phone, given USB-Debugging is active and USB is set up correctly. On Windows, the right drivers will have to be installed (you might want to change “My HTC” in the driver to “Fairphone” for device id 0x0C03 if you don’t mind installing unsigned drivers). On Linux, you’ll need to modify the udev rules to include HTCs vendor ID, 0xBB4.
Then it’s quite easy to modify the apps installed. I removed everything except the Google Play Services, it’s dependencies (Text to Speech) and the initialization app. All these have to be copied to the internal storage “SDCard”, for example into the folder “apps-install”. After that, start the terminal by issuing “adb shell”, then become root and copy the files over. This of course only works if the /system filesystem has been re-mounted writable:
mount -o remount,rw /system cp -r /mnt/sdcard/apps-install/* /system/ chmod 755 /system/addon.d/70-gapps.sh mount -o remount,ro /system
When installing the face recognition service, 71-gapps-faceunlock.sh also needs to be chmodded.
After copying, reboot the phone – Android will “optimize” your applications, and that’s it. As far as I know, one cannot use the Play Store without Google Account Services and all it’s downsides (like advertising, google only provides the setting to “ask” applications not to track users). So, if possible, use the APKDownloader extension or alternate sources like F-Droid. Unfortunately, only few developers sell their apps directly.
(first version, changes pending)