Building a custom Android ROM
Something I haven’t yet covered on this blog is my interest in Android. Since ~2011 I’ve been modifying and tweaking my phones to make them more unique to my needs. This began with rooting my Sony Xperia SP using TowelRoot, an incredibly easy way to grant elevated privileges on Sony phones from that time period. In case you’ve never heard the term ‘root’ or ‘jailbreak’ before, here’s the basics.
An operating system, like Android or Windows, has a certain directory structure that must always be kept the same. On Windows, this structure originates from your local disk (C: partition). This is where everything is stored on the computer unless you have multiple internal drives. Within this main disk is C:\, which is the first directory inside the drive. All of the other folders in the OS originate from here. For instance, the Downloads folder in my PC is located at C:\Users\copey\Downloads\. All operating systems will store their data in a similar way.
In Android, the Downloads folder is located at /storage/emulated/0/Download/ (the /0/ means the folder is for User 0). In native Android, like you find on any Android device, the only directory accessible by the user is /storage/emulated/0/, meaning that anything in a higher directory than /0/ is impossible to get to. Whilst this makes Android a lot harder to mess up (you cannot delete system files) it also means the user cannot perform any functions that require access to a higher-level folder. Rooting an Android phone means that the user is free to access any location on the internal storage of the device, including the root directory (/) where all other subdirectories stem from. This increases the user's privileges, giving them full reign over the system.
For instance, a rooted Android device is capable of completely removing system apps, changing the way apps function or look, creating full backups of app data, editing the hosts file to block adverts system-wide, to be used as a mini cyber penetration testing tool for MitM (Man in the Middle) attacks and even giving the user the ability to under/overclock their CPU. Most of these things won’t matter to regular users, but for enthusiasts the pros of having complete control over their system usually outweigh the negatives of warranty voiding and the potential for more powerful malware to take control, though that issue can easily be avoided through common sense.
On my next phone, the LG G3, I took things a step further, installing a custom recovery in the form of TWRP (Team Win Recovery Project). This is similar to a PC’s UEFI firmware settings screen in that it allows the user to wipe partitions on the device as well as to flash custom files to said partitions. Therefore it can be used to load custom firmware, or ROMs, onto an Android powered device (if it has an unlocked bootloader to install the custom recovery). With this new power I was able to experiment with many different takes on Android by hobbyist developers on XDA. Now my G3 is on Android 8.1, which is the very latest version of the OS -- pretty good if you ask me, as far as third-party development goes.
My latest phone, the S8, was one I thought I would keep factory for a good amount of time. I still haven’t done anything to void the warranty yet, but I've been strongly considering changing that out of a desire to make it my own. In an attempt to further my knowledge of Android as an operating system, I decided to try to build my own custom ROM for the S8. Although I could have easily done the same for the G3, the ROMs available for that device are already how I would configure them, so building one for the S8 presents a more interesting challenge and one which isn't as redundant.
My goals for this new ROM were to keep the Samsung applications that I personally use and to completely remove what I don’t.
The first step was to download the latest Samsung firmware build for my SM-G950F on Updato, which at the time of posting is CRB7, the latest stable Oreo release from Samsung. I don’t have the skill to manually edit the operating system’s files directly, so using a ROM kitchen such as Super R’s simplifies the whole process. The firmware file from Updato comes ready to flash with Odin/as an OTA update, but in the wrong format to edit and repackage. Luckily, Super R is able to unpack Samsung firmware files, so it was straightfoward to start editing.
The first modification I made was to change the system’s kernel. The kernel is what directly interfaces with the device’s hardware, so changing it can give the system better performance and battery life due to the way it can control when apps can wake in the background, what can be kept in memory and so on. I went with NX (Nox) kernel, as I have previously used Xceed on my G3 and wanted to try something different.
Next, I added Magisk to the ROM. Magisk is a root manager, which has a bunch of great features that set it apart from the previous standard in the community, SuperSU. One of these is the ability to install modules. I’m not sure if my method of installing them actually worked, as I have not yet flashed the finished ROM on my phone, but the ones I added are: the Single-User module as I don’t have multiple users on my device; the Magic-Charging-Switch to aid with battery health and the Magisk-Blobmoji module as the stock Samsung set, although better in Oreo, is terrible.
I then changed my focus to natively remapping the Bixby button without using an app as I could then remove all Bixby services from the device. I used this tutorial on XDA to modify the generic.kl file, assigning the button to open and close quick settings.
Although I recognise the value of advertising on the internet, I decided to add the MoaAB hosts file in order to block adverts without the need for an app such as AdAway. This prevents the IP addresses of >20,000 ad servers from connecting to the device, eliminating ads from being shown in any app.
Next up was debloating. I used Super R to de-Knox the firmware which is useless after the device is rooted -- an e-fuse is irreversibly tripped after modifications are made to the system. Afterwards, I incorporated the Project Deep Clean zip file in the ROM by adding the appropriate lines to the updater-script file in META-INF for when the ROM is flashed. This completely removes everything that is not needed for the phone to function normally. This takes it too far for my liking, which lead me to remove the files in updater-script I wanted to keep from being deleted. Whilst this method is imperfect, as it means the final zip file contains all of Samsung's extra additions which are immediately delted upon flashing, it does mean the user is able to choose what they want deleted from the ROM. In the future, I would like to give the user the option of what to uninstall through the recovery, instead of by modifying the code line-by-line.
To add to the idea that this is not stock firmware, I used another tutorial on XDA to add my own boot animation as Samsung uses .qmg files for their animations, not .zip like every other manufacturer. I changed the file to a dark version of the Pixel's boot animation.
Lastly, I modified the build name of the firmware to AltitudeCRB7, so the phone would display that as the firmware's name.
Then it was time to repack the ROM using Super R.
And it was done!
Like I said, I'll probably flash this to my phone soon, and if it's a success I might consider maintaining it on XDA for the rest of the community to use.
To keep up-to-date on this and future projects, join the mailing list by pressing the “Subscribe” button at the top of the page.
| The contents of my C:\ drive |
For instance, a rooted Android device is capable of completely removing system apps, changing the way apps function or look, creating full backups of app data, editing the hosts file to block adverts system-wide, to be used as a mini cyber penetration testing tool for MitM (Man in the Middle) attacks and even giving the user the ability to under/overclock their CPU. Most of these things won’t matter to regular users, but for enthusiasts the pros of having complete control over their system usually outweigh the negatives of warranty voiding and the potential for more powerful malware to take control, though that issue can easily be avoided through common sense.
On my next phone, the LG G3, I took things a step further, installing a custom recovery in the form of TWRP (Team Win Recovery Project). This is similar to a PC’s UEFI firmware settings screen in that it allows the user to wipe partitions on the device as well as to flash custom files to said partitions. Therefore it can be used to load custom firmware, or ROMs, onto an Android powered device (if it has an unlocked bootloader to install the custom recovery). With this new power I was able to experiment with many different takes on Android by hobbyist developers on XDA. Now my G3 is on Android 8.1, which is the very latest version of the OS -- pretty good if you ask me, as far as third-party development goes.
My latest phone, the S8, was one I thought I would keep factory for a good amount of time. I still haven’t done anything to void the warranty yet, but I've been strongly considering changing that out of a desire to make it my own. In an attempt to further my knowledge of Android as an operating system, I decided to try to build my own custom ROM for the S8. Although I could have easily done the same for the G3, the ROMs available for that device are already how I would configure them, so building one for the S8 presents a more interesting challenge and one which isn't as redundant.
The first step was to download the latest Samsung firmware build for my SM-G950F on Updato, which at the time of posting is CRB7, the latest stable Oreo release from Samsung. I don’t have the skill to manually edit the operating system’s files directly, so using a ROM kitchen such as Super R’s simplifies the whole process. The firmware file from Updato comes ready to flash with Odin/as an OTA update, but in the wrong format to edit and repackage. Luckily, Super R is able to unpack Samsung firmware files, so it was straightfoward to start editing.
The first modification I made was to change the system’s kernel. The kernel is what directly interfaces with the device’s hardware, so changing it can give the system better performance and battery life due to the way it can control when apps can wake in the background, what can be kept in memory and so on. I went with NX (Nox) kernel, as I have previously used Xceed on my G3 and wanted to try something different.
![]() |
| The contents of an Android device's /system/ directory |
I then changed my focus to natively remapping the Bixby button without using an app as I could then remove all Bixby services from the device. I used this tutorial on XDA to modify the generic.kl file, assigning the button to open and close quick settings.
Although I recognise the value of advertising on the internet, I decided to add the MoaAB hosts file in order to block adverts without the need for an app such as AdAway. This prevents the IP addresses of >20,000 ad servers from connecting to the device, eliminating ads from being shown in any app.
Next up was debloating. I used Super R to de-Knox the firmware which is useless after the device is rooted -- an e-fuse is irreversibly tripped after modifications are made to the system. Afterwards, I incorporated the Project Deep Clean zip file in the ROM by adding the appropriate lines to the updater-script file in META-INF for when the ROM is flashed. This completely removes everything that is not needed for the phone to function normally. This takes it too far for my liking, which lead me to remove the files in updater-script I wanted to keep from being deleted. Whilst this method is imperfect, as it means the final zip file contains all of Samsung's extra additions which are immediately delted upon flashing, it does mean the user is able to choose what they want deleted from the ROM. In the future, I would like to give the user the option of what to uninstall through the recovery, instead of by modifying the code line-by-line.
To add to the idea that this is not stock firmware, I used another tutorial on XDA to add my own boot animation as Samsung uses .qmg files for their animations, not .zip like every other manufacturer. I changed the file to a dark version of the Pixel's boot animation.
Lastly, I modified the build name of the firmware to AltitudeCRB7, so the phone would display that as the firmware's name.
Then it was time to repack the ROM using Super R.
And it was done!
Like I said, I'll probably flash this to my phone soon, and if it's a success I might consider maintaining it on XDA for the rest of the community to use.
To keep up-to-date on this and future projects, join the mailing list by pressing the “Subscribe” button at the top of the page.






Comments
Post a Comment