Why?

I kind of like new technologies, and I am well-equiped: smartphone, computers, etc. They’re pretty useful. In particular, I use my smartphone for communication, I listen to podcasts, I record my running activities, and many more. Hence a huge part of my private life passes through this small object, and the information goes actually all over the world:

  • if you are using GMail (whether it’s on your phone, the web interface or IMAP), Google is probably reading your emails
  • WhatsApp saves the conversations on Google Drive
  • have you ever received a notification from Google Maps telling you to take a picture of a restaurant, just because you happen to be close to it and this place needs reviews? That is pretty disturbing.
  • many more things that are probably not aiming at you personally, but are still taking bits of your private life (that should remain private).

It is difficult (impossible?) to keep your life completely private, if you’re using online services. However, I think the more efforts I do towards keeping my life private, the better.

And recently, I went one step forward, by removing the semi-proprietary Android OS on my phone to a fully-open OS. Plus, I did not install the Google Apps (GAPPS), which are unfortunately needed for many apps and services (such as some notifications… How the f*ck an app does need Goole to send a notifcation?!).

You’ll easily find the way to do the same, but here is how I did.

How?

1. Backup

Because the operation will erase all the data on your phone, you need (if you want to) to save some data, including, for example:

  • contacts
  • texts
  • pictures
  • files
  • your podcast subscriptions

Copying everything to a computer can work, but since I have a personal Nextcloud server, I am syncing most of my data in real-time.

2. Downloads and tools setup

To connect your phone to your computer, you need :

  • enable the phone’s debugging mode, by tapping several times the Build version in the About section of the phone’s settings
  • have adb (Android Debug Bridge) working on your computer

And of course, you’ll need:

  • the OS itself (I recommend LineageOS, select the image for your phone, and you better read their instructions instead of mines :P)
  • a recovery image, such as TWRP. As I understood it, this is a software that run as the recovery mode of your phone, and mainly allows you to install OSes and apps from downloaded zip files.
  • I also recommend NanoMod, which is a package that bundles microG (to replace GAPPS) among other useful free apps (the F-Droid open-source app repository, Zelda ringtones…)

3. Unlock the bootloader

This is do be done only once per phone. This wipes your phone out (no data anymore), and it is done using adb. From the LineageOS wiki (in my case, for the OnePlus3T):

  • Enable OEM unlock in the Developper options under device Settings
  • Connect the device to your PC via USB
  • On the computer terminal, type: adb reboot bootloader. This will reboot the phone on the bootloader (does this sentence make sense? I wonder…). You can also press the Volume Up and Power buttons together, after having powered the phone down.
  • Check your PC finds the device: fastboot devices or sudo fastboot devices
  • This part will wipe our your phone! Once the phone is in fastboot mode, type: fastboot oem unlock or sudo fastboot oem unlock.

Now your phone should restart (if not: help it) totally unlocked. And you’ll need to re-enable the USB debugging thing to continue.

4. Install a custom recovery using fastboot

Continuing on the LineageOS wiki:

  • Download a custom recovery, specific to your phone (in my case, TWRP for OnePlus3)
  • Connect your device to your PC via USB
  • On the computer, type adb reboot bootloader
  • Check that the device is recognized: fastboot devices or sudo fastboot devices
  • Flash the recovery into the device (this means copy-paste-and-install to the device): fastboot flash recovery twrp-x.x.x.x-oneplus3.img (use sudo if needed, and change the file accordingly)
  • Congratulation, you have installed a custom recovery, it will allow you to install the rest!

5. Push the needed files to your phone

Now you’ll push the needed/wanted files to your phone. These include the OS of course, and if you want NanoMod (the Stable archive). In order to use NanoMod, you’ll need to install it before the OS itself. But first, let’s push the files to the phone:

  • use the command adb push filename.zip /sdcard/, replacing filename.zip by the OS’s and/or NanoMod’s zip file.

6. Install everything from the recovery

  • If your aren’t already in recovery, reboot into recovery.
  • Select Wipe and then Advanced Wipe
  • Select Cache, System and Dat partitions to be swiped, and then swipe to wipe
  • Go back to the main menu, and select Install
  • Navigate to /sdcard, select (first, if you want it) NanoMod and LineageOS zip packages
  • Follow the on-screen prompts to install the package

Tadaaa! Your phone should reboot into your brand new Google-free OS!

7. (Optional) Configure microG

From the NanoMod readme:

Signature Spoofing Support

For microG to work, your ROM needs to have signature spoofing enabled (or a deodexed ROM to patch yourself).

If your ROM does not have signature spoofing support, you can manually patch it either

  • flashing the on-device Patcher zip
  • it also installs an addon.d script that auto re-patches the ROM upon update
  • running the framework-patcher script
  • use from your PC or laptop while your device is in TWRP. This shell script for GNU Bash (and compatible shells) works on unixoid operating systems like GNU/Linux, BSD or MacOS. It automizes the process of downloading Haystack > GitHub, pulling files from phone, patching and installing the modified services.jar on the device.

Both patchers support installing the patched services.jar into the following locations:

  • NanoMod Magisk Module
  • NanoMod-microG Magisk Module
  • directly into /system

So you can use them regardless whether you’re using NanoMod or not.

microG Setup

Once your ROM supports signature spoofing, you need to setup microG like this

  • go into microG settings and set up everything like:
    • check results in Self-Check, grant missing permissions (by tapping on them)
      • especially the Battery Optimization item
    • enable Google device registration
    • enable Google Cloud Messaging (only if you want to receive push messages from your applications)
    • enable Google SafetyNet (required for applications that utilize SafetyNet, for example Pokémon GO, …)
      • ’…’ menu > set to use the Official Server
    • in UnifiedNlp Settings choose
      • Mozilla Location Backend as Geolocation backend
      • Nominatim as Address lockup backend
    • after everything is done, reboot
    • go to Play Store, setup account and install your apps

My current configuration

Just for the inspiration, here is what I am using:

  • OS: LineageOS, with NanoMod and microG
  • App store: F-Droid
  • Email client: K9-mail
  • Browser: Firefox and Firefox Focus
  • Camera: Open Camera
  • File synchronisation: Nextcloud
  • Text synchronisation: Nextcloud SMS
  • Calendar and Contacts synchronisation: DavDroid
  • Map and navigation: OsmAnd

And other apps, including proprietary ones, I must confess. But my phone is Google-free now!

Hope this helps!


Sources: