Saturday 29 June 2024

Root an Android Phone

Rationale

Rooting is a technique for circumventing the security on a phone / tablet giving more capabilities / permissions to access the Operating System and hardware.


For a long while I have been intrigued as to whether it would be worthwhile to "root" an old phone.
Improved backups, fonts and display customization, file recovery, improved battery life, removing bloatware appear to be common reasons for rooting.  None of them particularly appeal to me.

I have an old phone, an HTC One M8 which I intend to root.  It is a particularly good choice as HTC support(ed) the rooting process rather than trying to prevent it.  As it is an old phone rooting may allow me to install software which has subsequently become unavailable in the app store.
I hope to find other advantages as I proceed.

Overview

Clearly mobile phone vendors dont want just anybody to be able to modify OS software on their phones.  When the phone is powered on a program called "bootloader" copies the Android OS into memory and starts it running.  By default you are not allowed to change the program which bootloader runs so it should always start Android.

HTC provide instructions to "unlock" the bootloader.  You obtain an "identification" key from your phone, send it to HTC and they provide you with an unlock code.  After you flash this code to your phone your bootloader is unlocked.

Next you need to use a "custom recovery program" which will allow you to modify OS files.  As the bootloader is unlocked you can flash TWRP (TeamWin Recovery Program) to the HTC and call it  "recovery.img".  You can then start recovery.

The final step is telling the recovery program to execute a zip file SuperSU.zip.  This is the actual "rooting" step which will update Android files so that you can be a  "root" superuser whenever you need to.

After completing this process you boot the phone normally then, when necessary you use the SuperSU app to provide extra permissions.

The rooting process relies on the skills of the community to provide a recovery program and Android superuser modifications.

Installation : Unlock the bootloader

I found an excellent video by Sakitech which goes through the unlocking / rooting process in detail.  The phone is at least ten years old and the video was uploaded in May 2013 so I was apprehensive about whether the process would work.

The first tool you need is the "Android Debug Bridge" (ADB) which allows the PC to communicate with the phone via a USB cable.  You download the Android SDK and find it is located in the platform-tools folder.  You can delete the rest of the SDK if you want.

On the HTC you enable the developer options (see left for details) and you can then set the "USB debugging" option on.

Next you boot the phone in fastboot mode by holding the "volume down" button and pressing "power".   The fastboot menu shown on the right is displayed.  You should have the HTC attached to the PC with a USB cable.
Now the HTC is ready to communicate and you run the ADB fastboot program on the PC.  Initially the fastboot program wouldn't talk to the HTC, until I installed  the ADB driver for my HTC android device.

Using the fastboot program I was able to obtain the "identifier code" and send it to HTC who returned the unlock code.  HTC provide excellent clear instructions to help you do this. 



You then flash Unlock_code.bin to HTC and the bootloader is unlocked.  The phone resets itself to factory defaults, all data is erased and it reboots.  It takes a few minutes to do this.
If you reboot in fastboot mode you can see that the phone says it is "unlocked".



Installation : Custom recovery and Superuser


The bootloader is unlocked now so we can find some more programs to help us.

The first is TWRP (Team Win Recovery Program) which is a program you can boot from the HTC flash to carry out various recovery functions.  The video instructions recommended a program called clockworkmod but this was discontinued in about 2015 and TWRP seems to be a popular replacement.

The second is a package called  SuperSU which modifies appropriate Android files to allow you to be a superuser / admin / root / su.
We download SuperSU.zip from the SuperSU website to the root folder of the phone using the HTC normally booted.

We download the TWRP image to the PC and then use fastboot to copy it to HTC flash with the name recovery.img.  Now, in the bootloader menu, we select RECOVERY and boot the TWRP recovery.img file.

We then use RECOVERY to install SuperSU.zip.  This patches the OS image so that we can have root access.  Next time we boot HTC we have a new "SuperSU icon.  We can look at the settings to check that the phone is successfully rooted.


Success! We have rooted our HTC One M8.
Next I need to find out what the point of this exercise was.  What can I now do that I couldn't do before that is useful?

No comments:

Post a Comment