LineageOS on Xperia Z5 Compact
If one assumes the tendency of the rate of profit to fall (see TRPF), the rise of software as a service (SaaS) can be interpreted in terms of TRPF. The main IT players try to keep their profit margins from falling by switching to a more profitable niche - such as services - as their core businesses are saturating - not giving astonishing growth figures any more. When you cannot sell more and more computers, phones, office products, ad space, and so on, you need to expand to new markets to stay profitable and all directions nowadays lead to services. Sell services! All you need to do is to force the existing users of your platforms to rely more and more on your services: the more users of your services you gather, the happier your stockholders are, and consequently, the higher the executive compensation you get.
"Old software" is not making as much money as before, thus companies are "open-sourcing" their software (even Microsoft, before the arch enemy of FLOSS), but at the same time, that open-sourced software is more and more dependent on their services. Without them, it is practically useless. Everybody open-sources only clients of proprietary platforms, while the platforms are kept as walled gardens.
I wrote the previous introduction to briefly argue that Google's Android OS will become more and more tied to their services for which Google will introduce new limitations for free users. That is the way to continue the growth. Also, phone vendors cannot resist the temptation to add some "great" services from their own kitchen to the products they offer. Carriers give their own contribution too! The current situation has already reached the point where one cannot use his/her phone without being constantly disturbed by "great" services, offers, promotions and shiny new products. Even though you buy an expensive product, the product becomes a trojan horse in your pocket which is trying to empty your wallet even further.
To confront this madness, we are forced to clean up our devices, and luckily, for Android, this (still) can be done, under certain circumstances, by putting custom Android ROMs. Custom ROMs usually provide root access which is an indispensable feature for power users. Before buying a new device check if the bootloader of the device can be unlocked (you should avoid carrier's phones which usually come with the locked bootloader).
First, a few words about the warranty and risks involving unlocking bootloaders and putting custom ROMs. Of course, a vendor will try to discourage you from removing an official ROM. For example, Sony on its page for unlocking bootloaders says (emphasis mine):
If you unlock the bootloader, you may void the warranty of your device and/or any warranty from your operator. (...) Additionally, due to the modified device software, Sony’s repair network will likely have to replace key components before it can properly test, repair and verify your device using our repair tools and software. Consequently, if Sony performs a warranty repair, Sony will likely charge you a significant service fee for the additional costs caused by your modification of the software.
Please be aware that Sony cannot guarantee the full functionality, and will not be responsible, for any unsigned custom ROM being flashed to your device after the bootloader is unlocked. An unsigned custom ROM may not have gone through the thorough tests that we run for each device and software version that we release.
Also, a custom ROM might not work properly on your device, and certain functions and offerings may cease to work. The performance of the device might also be affected, and you may damage your device permanently. In worst case, unlocking the bootloader will cause physical injuries or material damage, for example, due to the device overheating.
Certain pre-loaded content on your device may also be inaccessible due to the removal of DRM security keys. For devices running recent software versions, for instance Xperia Z3, the removal of DRM security keys may affect advanced camera functionality. For example, noise reduction algorithms might be removed, and performance when taking photos in low-light conditions might be affected. The secure user data partition may also become inaccessible, and you will not be able to get any more official software upgrades if you unlock the bootloader.
After reading this, one could think that the procedure is the only way to void the warranty but if you would read the general terms and conditions and understand its context you would notice that there are so many cases which are not covered by the warranty that the manufacturer could always find a reason to void the warranty - that is why I emphasised "may".
Of course, if you value more their proprietary features over anti-features and freedom, you should not proceed. Regarding the voiding of the warranty, it is unlikely that new software can cause physical, hardware failure of the phone, but the risk, however, does exist, especially if the phone will be overclocked beyond some default settings. Do it at your own risk, although I cannot recall of breaking any phone by flashing it with custom ROMs and I have been doing that for years. Finally, the action can be fully reverted by putting the stock ROM back, thus restoring the warranty.
Here I will briefly sketch how to do it on Sony's Xperia Z5 Compact which bootloader can be unlocked.
Back up important/personal data from your phone since the phone's data will be erased. Even the content from an SD card can be lost if it is encrypted and keys are not backed up. If you want to revert the phone to the original state at some point, back up the TA partition where DRM keys are kept (unfortunately, for this you have to root the device while still being in the official ROM).
Prepare IMEI of the phone which can be obtained from the service menu (#*#7378423#*#) and obtain the code to unlock the bootloader by following the official guide.
Enable USB debugging and then use fastboot to unlock the bootloader (fastboot is usually available in repositories of a Linux distribution) again by following the official guide.
Flash TWRP to a recovery partition as described on the XDA forum.
Install LineageOS through the TWRP recovery following the official tutorial and add root access by installing su.
That's it. The next step would be to install F-Droid to securely install and update apps without enabling "unknown sources".