A few days ago the screen on my Sony Xperia Z2 Compact broke, after a long line of other problems with it (both charging ports breaking, broken TRS jack, broken camera, port covers coming loose etc). I tried to triage the screen cracking with superglue, but all that accomplished was make the phone look awful:
I decided it was time for something else, preferably something that gives me more control than the non-rooted Xperia. I ended up trading a friend of mine a few beers for his old Samsung Galaxy S5, partly to have something while shopping around for a used Fairphone or waiting for the Librem 5. The S5 is quite rootable though, and LineageOS supports it, so I decided to go for it instead. This also has the upside of saving money and saving the S5 from becoming e-waste.
For the most part I followed this guide on lineageos.org. It might help knowing my device (SM-G900F) is known as klte in TWRP and Lineage circles. First up was making sure Heimdall worked correctly by issuing the print-pit command:
$ heimdall print-pit Heimdall v1.4.1 Copyright (c) 2010-2014 Benjamin Dobell, Glass Echidna http://www.glassechidna.com.au/ This software is provided free of charge. Copying and redistribution is encouraged. If you appreciate this software and you would like to support future development please consider donating: http://www.glassechidna.com.au/donate/ Initialising connection... Detecting device... Claiming interface... Setting up interface... Initialising protocol... Protocol initialisation successful. Beginning session... Some devices may take up to 2 minutes to respond. Please be patient! Session begun. Downloading device's PIT file... ERROR: Failed to send request to end PIT file transfer! ERROR: Failed to download PIT file! Ending session... ERROR: Failed to send end session packet! Releasing device interface...
To build Heimdall a number of dependencies had to be installed. For various reasons I was unable to install Qt5's build deps, so I only installed the dependencies needed to build the Heimdall CLI:
# apt install build-essential cmake zlib1g-dev libusb-1.0-0-dev
Next I configured Heimdall with -DCMAKE_BUILD_TYPE=Release and -DDISABLE_FRONTEND=ON, leading to a successful compile and a binary under build/bin/heimdall which could successfully perform print-pit:
$ ./heimdall version v1.4.2 $ ./heimdall print-pit Heimdall v1.4.2 Copyright (c) 2010-2017 Benjamin Dobell, Glass Echidna http://www.glassechidna.com.au/ This software is provided free of charge. Copying and redistribution is encouraged. If you appreciate this software and you would like to support future development please consider donating: http://www.glassechidna.com.au/donate/ Initialising connection... Detecting device... Claiming interface... Setting up interface... Initialising protocol... Protocol initialisation successful. Beginning session... Some devices may take up to 2 minutes to respond. Please be patient! Session begun. Downloading device's PIT file... PIT file download successful. Entry Count: 30 [snip] Ending session... Rebooting device... Releasing device interface...
The time was ripe for flashing twrp-3.2.3-0-klte.img (sha256sum ce7e30871a101f53835d46dc296eb92c2a586e8034f41235b1dfe264eab62326):
$ ./heimdall flash --RECOVERY twrp-x.x.x-x-klte.img --no-reboot
This worked fine, but the phone didn't reboot after flashing like the guide said it would. I waited a while and rebooted it manually, which worked fine. Holding Volume Up + Home + Power got me into TWRP to continue the process. I followed the instructions to wipe and format the device, or as TWRP says: ~swipe to wipe~
Next I pushed the LineageOS install ZIP and the addonsu ZIP:
$ adb push lineage-15.1-20180820-nightly-klte-signed.zip /sdcard/ [100%] /sdcard/lineage-15.1-20180820-nightly-klte-signed.zip $ adb push addonsu-15.1-arm-signed.zip /sdcard/ [100%] /sdcard/addonsu-15.1-arm-signed.zip
TWRP was not able to verify the signature on the Lineage ZIP, so I skipped the verification step on both files. After doing that the installation went fine, and I was able to successfully boot into Lineage. Woo!
After this I wanted to install F-Droid,
which is like an app store for libre programs.
Android 8 Oreo has made installing unofficial apps a bit more difficult,
so I went with downloading the F-Droid APK via ADB.
To do this I had to enable developer mode and USB debugging on the phone.
After that it was merely a matter of running
adb install with a USB cable plugged in:
$ adb install FDroid.apk Success
Funnily enough, F-Droid wanted to update even though I grabbed the latest version of it off its website. Oh well. Here's the final result of all this:
I also had to fiddle with importing my contacts and calendar. All in all I'd say this was much less painful than I expected. Having the increased control this setup gives me is great, and the lack of apps on F-Droid that try to harvest and sell my data and display ads makes me wonder why I didn't do this sooner...
In the future I might fiddle with ways of sandboxing Android apps if I ever need to run any. Perhaps I can make do with my old broken phone for that - it's probably a good idea to force myself to use the OTG cable, wireless mouse and keyboad before stooping to using proprietary software!