Kitaab

The Story of How Reviving An Ancient Smartphone Nearly Broke Me

dev blog

published 2020-05-06 14:21

updated 2023-06-04 00:49

My second smartphone ever was the HTC One M8) and it has served me very well. The first thing I always do when I get any sort of consumer device is attempt to ▓▛▚▓ it. In fact, I will specifically pick devices I know to have a good developer community so that I can ▓▛▚▓ them. The only device I own that hasn't been ▓▛▚▓ed is my Switch, mostly because doing so would result in me being unable to purchase games legitimately, and I do wish to support the indie artists whose games I invariably gravitate towards. As proof of my good ▓▛▚▓er taste™, the HTC One M8 still has somewhat of an active developer scene and has recieved the latest LineageOS update officially. Truly incredible that with a little effort a phone from 2014 can still run the latest version of Android. Planned obsolescence? Never heard of it.

Anyways at some point between when I stopped using it and now, it broke. Entered a bootloop. I decieded to fix it so that I could use certain surveillance apparatus (namely freakin' dating applications because apparently I thought they could be a cure to the lonliness I faced during pandemic) without turning my daily driver into a wire-tap. No big deal I figured, I'd done this a hundred times before. Oh boy, how wrong I was.

Since I had already rooted this phone, the first step was to get into a working recovery image. This is the part of your phone that sits between the bootloader and the operating system, and most people never see it and don't know it exists. Stock recovery images that come with your phone probably aren't accessible to you anyway, so this is hardly a surprise. This step didn't turn out to be too difficult. Download TWRP, install adb on my computer, boot the phone into the bootloader, flash the recovery, and we're off to the races. Excellent.

With a working recovery image, the next step was to choose a ROM. I don't particularly want to trust random strangers on the internet who put together blazing fast ROM that doesn't support Wi-fi over the weekend and so the default choice in this space is LineageOS. Get the image, wipe the phone, install it through the recovery image. I try to flash it and everything seemed to have gone well, except when I try to boot the phone I'm still stuck in a bootloop. Huh, maybe there was an error I didn't notice? I try again and no I didn't miss anything, and no it didn't boot. Hmm, I guess I'll pull up a guide to installation. I read through it and it seems like I'm doing everything right, and now I'm beginning to get a little frustrated. I try again, same results. Ugh! I re-read the guide carefully and of course there was a thing I missed... I was pressing 'yes' to TWRP's helpful suggestion to install the application (which would show up once you booted into the operating system). Turns out, that breaks LineageOS. Classic case of PEBCAK. Great, now that I managed to get this installed and booted properly, this shouldn't take me more than a few hours at worst.

And this is the point in the story where I am driven to the brink of insanity.

Basically every Android phone in existence comes pre-installed with Google Play Services. In the mind of most consumers these two are intrinsically tied. Android == Google. But as it turns out, Android is technically an open source project named AOSP (Android Open Source Project) wrapped up with Google's proprietary tentacles Google Play Services. If you want access to the Google Play Services as a device manufacturer, you have to agree to some of Google's terms. For most phone software/hardware manufacturers this isn't a problem, or at least, not a big enough problem for them to forgo GApps. Afterall most of the value of building an Android phone is access to the Google Play Store. LineageOS's whole pitch is basically "Android without the Google". Obviously it doesn't come bundled with GApps.

Installing Google Play Services on LineageOS requires downloading them as another file you can flash from the custom recovery. Since it requires heavy tie in from the system, there are various requirements about how and when it is flashed. You can't just willy-nilly take your non-GApps phone and add GApps, just like you can't take a GApps phone and make it free from the largest surveillance company in existence. There have been times I have used GApps, and installing it wasn't a problem then, and so I figured it should be fine.

So off to OpenGApps, the only provider for GApps for Android Q. Download the smallest package they distribute (pico) and put it on my phone. I try to flash it and come across "Error 70: Not enough storage on /system". Fuck. Okay, time for some googling.

Turns out the LineageOS 15.0 image for my phone has decided that the /system partition (the part of your phone you don't have access to generally) will be of size 1GB. This is normally not a big deal, there's even some space left over for other things you may wish to put in this partition (23MB to be exact). Because GApps is required to be installed on this partition so it can't be fucked with, with it's ballooning size (the smallest package from openGapps is now over 150MB) this did indeed turn out to be a problem for me. A very big problem. One that would nearly move me to tears of frustration.

There's plenty of people online who have come across the same error message. None of their solutions worked for me. Some suggest using the smallest version of OpenGapps, which I was already doing. Others suggest trying to resize the partition in TWRP, through the provided GUI. It does nothing for me. I even watched a video tutorial (🤮) on how to click the right buttons on the screen in TWRP to perfrom the black magic sorcery which would grow the partition from 1GB to 4GB. I'm not sure what I was doing wrong, but it certainly didn't do anything for me.

Alright, well, time to put on my ▓▛▚▓er cap™ and repartition the Android internal storage myself. Afterall Android is technically a Linux distribution, and I have heaps of experience with those. I was even an Arch Linux user for a while. (For the uninitiated, it's installation process looks like this, it constantly breaks if you blindly decide to upgrade it, and is a meme/badge of honour in nerdy groups). How hard could it be?

*stares into camera*

After some googling and reading through many, many XDA threads and some reddit and stackexchange threads (a whopping total of 50+ tabs in my browser), I had a strategy. I decided the best course of action would be to take the script written in one of the XDA threads and adapt it to my phone. All I had to do was change the partition number to be the same as what my phone uses.

Alright, this is something I do know how to do:

adb shell 
# df -h /

Turns out my system partition is partition number 45, instead of 25 like it is on the Nexus 5. Change the script, flash it, reboot to recovery and... nothing. No change. Fuck. Not even in adb shell. Okay, let's do it by hand and see what happens. Running the commands by hand was painful, but it did seem to actually change the partition size. That's good. I got a bunch of warnings that I shouldn't do anything with these partitions until I reboot. Okay, let's reboot then. Aaaand, it's gone. Like I didn't actually do anything. Fucking hell.

There's a famous quote about insanity. "Insanity is doing the same thing over and over again, and expecting different results". Determined not to be driven insane by this ludicrious endeavor to install fucking DATING apps, I employed every permutation I could think of. The order of commands (to the degree it made sense), rebooting/flashing at different stages, using the previous trick of resizing the file system mentioned above once I resized the partition. Fucking nothing.

At this point I'm totally going insane. Banging my head against this 5 inch contraption of silicon, aluminium and glass was not good for my mental health. It became less about actually using the dating apps and into all out war. I was determined not to be defeated by a piece of obsolete technology. So back to the drawing board I went.

I thought maybe I could get a different ROM installed, since it was LineageOS that determined the size of the /system partition. Well, after much waiting and downloading various different shady ROMs from XDA (carefully choosing those that had at least been updated in 2018), I still got nowhere. Each of them presented their own failures. Various indecipherable error messages I no longer had the heart to fix. I tried at least 6 different ROMs. I was getting to the end of my rope here.

In one of the threads about /system partition woes somebody passingly mentioned Systemless GApps through Magisk. Magisk is a true marvel of ▓▛▚▓ing. It allows you to install various modifications to your phone without actually changing the /system partition. My interest piquied I decided to do some digging. Of course, this too was fruitless. The prolific ▓▛▚▓er that maintains the Systemless Gapps, VR25 had moved on to other projects. Since then, Magisk had changed the way it operates leaving it totally broken. But wait. There was a different package, that appeared to be working! It was even designed for the exact issue I'm facing!! My heart starts racing. Is this the answer to all the troubles I've been having?! I excitedly reflash regular old LineageOS, Magisk, boot up my phone. I try to install the Magisk module, and you know where this goes. Nothing. Nada. No error message, module installed successfully, but no google play services. No indication that the package had even been installed. UGH.

At this point I'm ready to throw in the towel. Scrolling hopelessly through the HTC XDA forum for anything at all. Then I see it. A possible solution. The simplest solution. The Google Play Edition. Google Play Edition (since cancelled, big surprise there lol) was an edition of your phone that came without all the manufacturer's bloatware. Stock Android in all it's goodness for those that didn't want the trouble of ▓▛▚▓ing their device. What the hell I figure, I've tried all the other options and at this stage just wanted to win. Anything would do, and this device was intended to be a wire-tap anyway, so what did it matter. It didn't even require flashing the OpenGapps, they came preinstalled! So I tried flashing it. Seems like it flashed okay, time to boot. 10 minutes of loading had passed, and I was doing lots of praying. I was just about to give up, when... SUCCESS! The phone boots! It has Google Play Services!

I cannot tell you the relief that washed over me when the phone finally booted and had the Play Store on screen. This hopelessly out of date ROM (It's running Android 6.0) made me so fucking happy, holy shit. I wasn't defeated! Now I could be judged by strangers I didn't know and would probably never meet! To think I put myself through such strain for the sake of dating apps makes me a little uneasy, but I want it to be known that I didn't quit. That I found a way to do what I wanted and revive this phone.

I downloaded and installed various dating applications, when they finally prompted me to create a profile is when I realized I don't actually have any good photos of myself from recent history... Perhaps a project for another time.