WIPE DALVIK CACHE AND CACHE 14 TIMES WHILE DANCING IN A CIRCLE AROUND A FIRE SINGING DAVID HASSELHOFF'S LATEST SINGLE BEFORE FLASHING NEW VERSION!!!- XDA user
Wait... isn't Android already FOSS?
Erm... kind of. The base android operating system, AOSP (Android Open Source Project) is free software, but almost every single part you use and interact with everyday is completely proprietary, and Google further tightens their grasp on android by introducing concepts like requiring messaging apps to use their proprietary push messaging services in order to function the way they should. A lot of FOSS apps which used to be included by default on android (for example, the launcher, the calendar and the email client) have been abandoned and replaced by Google's own proprietary solutions (think Google Now Launcher, Google Calender, GMail etc). Imagine running Linux but having every single program you interact with be proprietary; it kind of defeats the purpose of having a FOSS operating system. Here I'm going to talk about how to make your android device as FOSS as possible while still maintaining your device's practicality. There are several ways to do this: attain root access and delete all the proprietary applications, install a custom ROM without google play services, disable all proprietary applications and so on. Here I am going to go the custom ROM route as this is the method I prefer and root access is generally not a good thing to have all the time.
Before we can begin to FOSSify our android device, we need to unlock the bootloader. The bootloader is a program which loads the rest of the Android OS for you. On an android device, it does a few more things like verifying whether the OS being booted is genuine (i.e, what was originally put by the manufacturer) or not. As the custom ROM is not what is trusted by the locked bootloader, we'll need to unlock it. On most devices, this should be possible, and a quick google duckduckgo search (for example "unlock bootloader moto g5 plus") would tell you how to do so. However, if your device doesn't have an unlocked bootloader, you're kind of stuck here. You could attain root access by exploiting a few flaws in the OS, but this varies from device to device and isn't very straightforward.
Achtung! Unlocking the bootloader will most probably void your warranty.
A recovery is like a tiny OS which helps you do things like flashing/updating a ROM, making backups, and flashing/updating the recovery itself. You can boot your phone into the recovery using a specific key combination while booting (usually something like power button + volume down). While you can probably flash a ROM without a custom recovery, it is highly recommended that you use one as it makes your life much easier. Unfortunately, there is only one actively developed recovery nowadays, TWRP. On the bright side, it's open source! If your phone has an unlockable bootloader, it most probably has a TWRP port too, either an official or an unofficial one. Again, the internet is your friend, and you'll probably find an official port or an unofficial one in the XDA forums.
Achtung! If your port is unofficial, make sure that the porters are good with releasing the source code and that the recovery is in a good, working state by browsing the XDA thread for that port.
Sometimes, booting into stock android after flashing the recovery rewrites the recovery, resulting in you having to flash it again. To save yourself from this hassle, it might be better to boot directly into the recovery after installing it, and then flashing the custom ROM right away.
We're almost there! Now that you have a custom recovery installed, it's now time to install a custom ROM. The two "big" custom ROMs, in my opinion, are LineageOS and OmniROM, with LineageOS supporting more devices and being more popular among the custom ROM community. Again, there'll probably be an official port or an unofficial one on XDA. Most of the time, you'll have to wipe your phone's memory, download a .zip file, copy it onto your phone, and flash it through the recovery. The steps may vary from device to device (here's the steps for how to install it on the OnePlus One, for example), but they will usually follow this pattern. Refer to the install instructions from the device page on the LineageOS or OmniROM website (or an XDA thread for unoffically supported devices, or sometimes even an official XDA thread), depending on which one you choose. If in doubt, choose LineageOS as it's more popular and there will be more people to help you if you're stuck.
With some perseverance and luck, after following all the steps detailed above, you should have a working device with a custom ROM installed! Now, time to get into the important part: the FOSS apps which I said are your saving grace from Google. First off, you won't have access to the play store, or any other Google goodies like Google Assistant, Maps, Voice recognition etc. Also, you would have noticed that a lot of the old, open source AOSP apps like the calendar, email, and gallery have appeared, slightly updated by the ROM maintainers to keep up with modern android. In the FOSS android world, you will be downloading most of your apps from F-Droid, the free software alternative to the play store. So open the default browser on your device, go to the F-Droid website and install the app and you're set. Here are a few open source alternatives to popular proprietary apps on android, all available on F-Droid:
Great! You now have a mostly FOSS android phone, with some obvious exceptions. The drivers for 3d acceleration, WiFi, the Modem, and basically every other driver is probably still a binary blob. There is not much you can do about this, unless you have a phone which has support for Replicant, a fully free android distribution. Even in that case, you'll still need binary blobs for some (subjectively) important features like WiFi. This is probably the most you can go while still having a functional "smart" android phone. Sadly, the state of AOSP for FOSS Purists is not very good and it certainly doesn't look like Google is going to help improve this situation in any way. XDA Forums, the hub of custom ROM development, is a complete mess and incredibly annoying to go through. This is why I am eagerly awaiting the Purism Librem 5, a Linux-running smartphone which will hopefully not contain any proprietary blobs. But no matter what the current situation is, run FOSS and support the great people behind custom ROMs, F-Droid and all the open source apps out there!