Android without Google

There are a number of posts on the Internet about freeing your phone, ditching the mothershipdivorcing Google, and Android without Google. All promote reducing or eliminating the ties between Google and your Android phone.

Reasons for removing Google from the phone.

I have followed along that path. I suppose everyone has their own reasons but a couple of mine that I haven’t seen elsewhere come to mind. My own usage patterns are probably far different than most but I found that I was only really relying on two of Google’s many apps and services:

  1. Play Store for free apps.
  2. Calendar

I was already using K-9 for mail and Firefox for browsing. I used the address book but went through a number of hoops to make sure that I never had my contacts synced with Google. So I was not highly dependent on Google.

My current phone is a Google Galaxy Nexus (Maguro GSM) which has no SD card and I can’t even fit my whole music library into the phone. So things that use storage that I don’t use and can’t remove annoy me. They annoy me even more when they incessantly nag me to be updated. Google Play this, Google Play that, Google Wallet, Google+ and all the other apps in the suite were always asking to be updated. If updated, they always expanded the amount of storage they needed. Very, very annoying.

And, finally, it became apparent that Google was not going to release KitKat for that model phone.

As long as I was going to root the phone to remove the offending apps, I might as well install something that came from a place that had KitKat for my phone on its product plan. So I went with CyanogenMod.

Installing CyanogenMod

There is a quick and easy way to install CyanogenMod with links from their main page. But it did not work for me on my Mac. In retrospect it was probably something with my hosts file which redirects a huge number of ad servers to nowhere land. That was probably blocking one or more of the servers CyanogenMod was using as part of their content delivery system. So I had to find and use the procedure that was common prior to the fancy new installer.

Missing Pieces

A common suggestion is to use F-droid for installing apps if you don’t want to use Google’s Play Store. K-9 mail and Firefox are available there. But I was sorely missing apps that only seemed to be available from Google’s store. Things like TitanTV, IMDb, Netflix, NPR News, etc.

If you do a search for “apk downloader” you can find ways around having the old Google Market or current Google Play Store on your phone. But you end up having to trust another third party not to modify the apks.

And once you get those apps/apks installed you find that some don’t work. For example, TitanTV wants to know your location. Which is reasonable as it needs to know roughly where you are to give you the viewing options in your area. It uses an API that is not on the phone unless some of the libraries that come packaged with Google apps are available.

Eventually I stumbled on to the ”nogapps” or “microG” project which publishes its code so you can review it and provides some of the missing pieces:

  • “BlankStore”, a replacement for Google Play Store which happens to use the old Market API but seems to work fine.
  • “NetworkLocation”, a library to provide network (cell and WiFi) based locations which allows programs like TitanTV to run.
  • “Maps API”, a library providing mapping hooks for apps so things like CalTrans QuickMap app work.

Installing microG

Installing each of these is a bit fiddly. A person who is up to rooting their phone and installing, via adb, a new operating system can do it. But I would not suggest that everyone can. And if you install each of them individually as I first did you end up repeating a number of steps. Finally, each month the CyanogenMod team releases a new snapshot. If you accept the new release then a system without microG is installed and you have to install microG all over again. Obviously a script is needed to make this less painful. Here is mine. It has some local customizations that you won’t need like installing my root CA so my personal servers are trusted by my phone. So you will have to edit the script for your own needs.

#! /bin/bash
#
# Install the parts of microG (a.k.a. nogapps) that make the phone
# really useful.
#

#
# Remount the system as read/write so we can add things
#

adb root
adb remount

#
# Install NetworkLocation and BlankStore
#

adb push NetworkLocation-gms.apk /system/priv-app/
adb push BlankStore.apk /system/priv-app/

#
# Install cell tower database for NetworkLocation
#

adb push lacells.db /sdcard/.nogapps/

#
# Install our own organization's CA cert
#

adb push 00475224.0 /system/etc/security/cacerts/

#
# Maps API needs to be flashed. Copy to SD card and reboot
#

adb push adb push mapsapi.flashable.zip /sdcard/
adb reboot recovery

echo "In recovery:"
echo " 1. Select install from ZIP and select mapsapi.flashable.zip"
echo " 2. Select clean dalvik-cache from under advanced"
echo " 3. Select system reboot"
echo ""
echo "Once rebooted, in settings under accounts and sync, add the Google"
echo "Play account information."

The current version of NetworkLocation has two internal providers. One uses a on phone database of cell tower locations from OpenCellID and the other uses an Apple API to query the location of WiFi networks. The database is available from OpenCellID but they recently changed the access to require you to log in (have an API key) and only allow one download per day. The following script will take the comma separated value file from OpenCellID and turn it into a database for the NetworkLocation software. You will probably also want to change the country code from 310 to the one for your country and/or change the logic to keep the data for several countries:

#! /bin/bash
#
# Quick and dirty script to build and install a new
# cell tower database on phone for microg/nogapps
# network location.
#
API_KEY='my-opencellid-api-key-string'

# Delete and/or backup older data files
if [ -e cell_towers.csv.gz ] ; then
 rm cell_towers.csv.gz
fi
if [ -e cell_towers.csv ] ; then
 mv -f cell_towers.csv cell_towers.csv.bak
fi

#
# Get latest cell tower data from opencellid
#
wget --output-document=cell_towers.csv.gz "http://opencellid.org/downloads/?apiKey=${API_KEY}&filename=cell_towers.csv.gz"
gunzip cell_towers.csv.gz

#
# Backup previous database and build new one
#
# Could use:
# DELETE FROM cells WHERE mcc != 310 OR mnc != 260;
#
# Instead of:
# DELETE FROM cells WHERE mcc != 310;
#
# To make database even smaller but it isn't all that big
# covering the whole US instead of just T-Mobile.
#
if [ -e lacells.db ] ; then
 mv -f lacells.db lacells.db.bak
fi
sqlite3 lacells.db <<!
CREATE TABLE cells_new(mcc INTEGER, mnc INTEGER, lac INTEGER, cellId INTEGER, long REAL, lat REAL, samples INTEGER, changeable BOOL, created INTEGER, updated INTEGER, averageSignalStrength INTEGER);
.mode csv
.import cell_towers.csv cells_new
DELETE FROM cells_new WHERE samples < 2;
CREATE TABLE cells(mcc INTEGER, mnc INTEGER, lac INTEGER, cid INTEGER, longitude REAL, latitude REAL, altitude REAL, accuracy REAL);
INSERT INTO cells SELECT mcc, mnc, lac, cellid, long, lat, -1, max(100000/samples, 5000) FROM cells_new;
DROP TABLE cells_new;
DELETE FROM cells WHERE mcc != 310;
VACUUM;
.quit
!

#
# Push the new database to the phone. Reboot may not
# be required but probably won't hurt.
#
adb push lacells.db /sdcard/.nogapps/lacells.db
adb reboot

There are a number of apps that can collect information about cell towers and upload it to the OpenCellID project. I picked Tower Collector as a simple one that does what it says and little more.

Expected Issues

If you need or want access to services like gmail, or YouTube going with microG won’t work for you. YouTube might in the future if the microG project gets a Play Store API working. But Google blocks mobile access to gmail if made from mobile mail clients other than what they expect. I found this out the hard way on a trip when I turned on data and tethering and attempted to check a gmail account from my laptop. I had to add VPN access to my configuration for that so the IP address I came from was not one assigned by my mobile phone provider.

Unexpected Benefits

One nice unexpected benefit of using the microG NetworkLocation software is that my GPS locks much faster. Since I leave data turned off almost all the time, the phone did not have a guess on current location to help the GPS to acquire. Now, with a cell tower database in the phone, it does. So in areas that cell towers are reasonably known to OpenCellID, my phone can generally guess its location to within 500 meters even without a data connection. That allows the GPS to lock much, much faster.

Edited 31-Jul-2014 with more recent scripts shown.

1 comment

Leave a comment