LineageOS – Open Source Android

Summary

Android is essentially a Linux distro. It is a mobile device oriented UI / desktop running on a version of Linux. However, it’s not really open source. Every phone manufacturer writes binary drivers to get it to run on their hardware, and they don’t contribute those to the community. And mobile carriers pile their own add-ons on top of this. So by the time the Android phone gets into the hands of the user, it is loaded with proprietary software and bloat-ware.

For example Samsung modifies Android with “TouchWiz” which significantly changes the UI. And Motorola pre-installs the Facebook app – users can “uninstall” it, but it reinstalls itself every time the phone boots. Some people might like these changes, but I think most, like me, would prefer the pure unadulterated open source Android without bloat-ware or crapplets to burn down the battery and hog the storage.

Another issue with Android is that most manufacturers only support a given model of phone for a year or two. After that, no more updates, which means the phone is condemned to planned obsolescence.

In some cases we can avoid these issues, keep our phones for years while running the latest version of open source Android without bloat-ware. If that sounds interesting, read on.

Unlocking or Jailbreaking

The term “unlocked” has 3 different meanings:

  • Carrier unlocked: you can use the phone on any carrier’s network, so long as you have the right SIM card, and the phone’s modem & radio supports the right frequencies & protocols (GSM vs. CDMA). Many phones are carrier locked when new. When buying a new phone, when it says “unlocked” it means carrier unlocked.
  • Bootloader unlocked: just about all phones are shipped with a locked bootloader. This means you cannot replace the operating system. You can only install factory supported updates using the phone’s settings menu.
  • Rooted: the phone allows the user and apps to take on “superuser” or admin privileges. This means the phone can be used as a little computer without any restrictions – direct access to the filesystem etc.

“Jailbreaking” refers to rooting Apple phones while “unlocking” is a more general term.

Carrier: Every carrier is required by law to give mobile phone users a code to carrier-unlock their phone, so long as the phone is fully paid for. Most make this process as difficult as they can in order to discourage users from doing it. But, the process is accessible to non-technical users. Essentially, they send you a long code that you enter into one of the phone’s settings menus.

Bootloader: There is no law that I know of requiring manufacturers to allow users to unlock their phone’s bootloader. Some (like Motorola) officially support this, others (like Samsung) support it only unofficially, and others do not support it at all. In the latter case, hackers often (but not always) figure out how to crack it. When you unlock the phone’s bootloader, the warranty becomes void. Of course, that’s a nothing sandwich if the phone is already out of warranty.

Rooting: This enables you to use the phone for things you can’t do otherwise. For example, direct access to the full filesystem, even system partitions, enables full backups just like a computer, and makes possible amazing customizations. However, some security apps (for example banking and 2FA) detect whether a phone is rooted and refuse to run. So don’t root unless you really need to, and take measures to handle these cases.

Booting to Recovery

Recovery is disk partition on the phone that has a mini-OS that runs as root and enables you do make changes that aren’t possible when it’s booted normally. This includes changing the partition table, wiping the system partition, loading the operating system, etc. The two most common ways to boot to recovery are:

  • A button chord: power off the phone, then power it on while holding down other buttons. Exactly which buttons varies by manufacturer. For example, with Motorola press and hold the volume down button while powering on.
  • Android tools: Android, being open source, has a full set of developer tools that are freely available to everyone. Install the Android toolkit on your computer (Linux, PC or Mac), connect your phone via USB, and control it from the computer using tools like adb and fastboot.

Every phone comes with a factory supplied recovery, but it is not intended to load custom operating systems. Two of the most popular custom recoveries are TWRP (on Samsung) and boot.img (on Motorola).

Partition Table

The partition table determines how much disk space is allocated for recovery, for the operating system, and left over for user storage. Running a newer version Android or different recovery sometimes requires more space, which means changing the partition table.

Google Apps

Google Apps includes the Google Play App Store, Contacts, Calendar and several other apps that are not part of the Android operating system, but run with special privileges other apps don’t have. These apps cannot be installed from the Play Store but are installed while booted to recovery, just after installing the operating system.

These apps are not strictly required to use the device, but without them you won’t have the Google Play store or other important functions. They are required if you want your device to work like the normal Android that everyone is familiar with.

Compiled ready to install packages of these free open source versions of Google Apps are published in two popular places: OpenGapps and MindTheGapps.

The Process

So, how does one actually do this?

  1. Find out exactly what kind of device you have, including the specific model number. For example, not just a Motorola G7 Power but model XT1955-5, because there are several different versions having different processors, radios and modems.
  2. Ensure your device is fully functional with the OEM ROM, go to settings and install all updates to ensure it has the most recent version.
  3. Ensure to actually use the features from the OEM ROM, to ensure your device is properly registered on the carrier network. For example, on T-Mobile make phone calls & texts over WiFi.
  4. Back up any data on your device that you want to keep, because the install will wipe the entire device.
  5. Find a ROM that is supported on your device. You can get an officially supported ROM, like those at lineageos. Or you can find an unofficial ROM at places like xdaforums, where individual developers create and support them. An unofficial ROM could be LineageOS or many other versions of Android.
  6. Unlock the bootloader on your device. How to do this will vary from one device to another so you’ll have to do some homework.
  7. Follow the ROM installation instructions. This typically includes these steps:
    1. Boot to the OEM recovery
    2. Flash a new recovery
    3. Boot to the new recovery
    4. Update the partition table
    5. Install the new ROM
    6. Install Google Apps
  8. Boot the device into LineageOS.