https://forum.freaktab.com/forum/dev...cks-by-finless
But most of the posts are very old, dating back to 2014 with most discussion regarding s8xx chip, and I didn't get much details as I wish.
With the declining of development activities for newer processors (see the whooping decline of number of posts across S905x, S905x2, and S905x3, screenshot image attached), plus Android partitioning is getting a lot more complicated since Android 9 (Pie), not to mention that some of our elite gurus (like ricky divjakovski and Xannytech ) decided to retire from rom modding or tool creation to focus on their real life, I think we better have a place to gather detailed, in-depth descriptions of how to modify a rom/firmware, so that someones with boxes that have little to no supports from rom modding community can modify the stock firmware to their will.
I'm asking you, the elite rom developers, tool makers, and senior nerds, to share your knowledge of modding a rom in a single thread.
Xannytech, ALVATECH, superceleron, Guest, ricky divjakovski , minixfreak, bumerc , soldiaz , trebor, Sasvlad, ath156, mo123, hannah
Please help me refer to other known developers as well.
This thread is written with Amlogic TV boxes in mind but, in theory, should work with other Android-based TV boxes as well (Rockchip, Allwinner, etc...). I divide this post into several sections and try to be as discrete as possible, with reference links wherever I can find. Once I receive feedback, I'll update this first post accordingly. Most of the modifications are not app-related, but rather subtle tweaks that help fix common bugs and improve performance. There is a separate section for app categorization and suggestion at the end to explain why some specific app is preferred to others, as well as serving as a list to be removed if a modder feels they are redundant. And this is not about building a ROM from scratch, but rather extracting the .img, making modifications, and then repacking it.
Mod, please move this thread to an appropriate place, but please do not remove it. I'm sure people with intermediate knowledge of modding and tweaking will find this thread useful, sooner or later.
[ROM/Firmware Modding Tools]
1. Android 9 (Pie) and above:
Android 9 Partition repack tool (credit: bumerc). It's actually a tool to both unpack and repack android 9.0 images (currently support android 10 Q). Only works in Linux (Tested on Ubuntu, possibly supported in Virtual Machine (VMBox)). It now works with multiple-dtb roms, and can resize partitions as well!
For some reason, using this tool to unpack and then repack a stock firmware for H96 max x2 box would disable supersu. Possibly because it's encrypted.
https://forum.freaktab.com/forum/tv-...on-repack-tool
Note: if you are using Ubuntu 20.04.1 LTS or higher, make sure to install gawk. Also, follow apt suggestion when you can't install android-tools-fsutils.
2. Android 8 (Oreo) and below:
AMlogic Tools 7.1.0 (credit: ricky divjakovski). This is an all-in-one modding tools for adding/removing apks, changing boot animation, adding TWRP recovery, and (if supported) modifying kernel. Unbelievably free useful toolkit. Runs on Windows, but you DO need to disable Windows Defender or any antivirus software.
If you try to unpack android 9 img with this toolkit, repacking may yield an error, or worse, the repacked image can cause a boot loop after flashing (or error during flashing).
https://forum.xda-developers.com/t/0...lable.3786991/
[Non-app-related tweaks and tricks]
1. Keyboard "Enter" key fix and other game controller supports: In some stock roms, when you connect a physical keyboard and press the middle ender (not the one in the numpad), it may redirect to "q" key. To fix this, modify system/usr/keylayout/Generic.kl with a text editor and change "key28" to "ENTER" (by default, it's "DPAD_CENTER").
https://droidboxforums.com/threads/e...ard-fix.15397/
An easier way is to download any of the recent XTMOD roms (credit: Xannytech) or ALVATECH roms (credit: ALVATECH), extract it, then copy and replace all files /system/usr/keylayout/ to your firmware. This will also add supports for many game controllers as well
(though, maybe not the latest PS5 dualsense controller - google 1controller magisk module. If you don't have magisk, extract that module and get Vendor_054c_Product_0ce6.kl, then copy to your /system/usr/keylayout/).
Example:
https://forum.xda-developers.com/t/r...d-etc.3887379/
As always, just make sure to appreciate the modder whose rom you copied the keylayout files from!
By the way, you may need to change the Generic.kl in /vendor/usr/keylayout and /product/usr/keylayout as well. For example, the Generic.kl was fixed in /system and /product for SlimBox roms, but not in /vendor.
2. Just a side request, but related to keylayout: I'm not sure if we can directly use /system/etc/remote.conf from Android and plug it to ~/.storage/config of Coreelec or Libreelec. Some people have trouble doing that:
https://forum.libreelec.tv/thread/35...-from-scratch/
You might be able to make your remote work with coreelec/libreelec if you have the your android remote.conf file and start making one for coreelect/libreelec from scratch.
3. Deodexing and zipaligning: To me, it's not very important since I install my own apps afterward, from a cleaned, stripped rom, but you can find a lot of google references on this topic. I'm not even sure if it's relevant from Android 9 and above...
Xannytech: A lot of your roms are de-odexed and zip-aligned. What tools did you use to deodex and zipalign the apps?
4. init.d support: if you are familiar with init.d from older android versions, you'll appreciate what it does. It's like a task scheduler to be run when the box start up, specifically for some terminal command.
I'm not sure how Xannytech can make built-in support for init.d, but I have been using an apk alternative (root required):
Slimbox support USER-SPACE init.d as well! The user-space init.d of slimbox is located directly under /sdcard/ (internal storage). It includes some of the important script like the wake-lock script below.
5. Prevent tv box from sleeping (i.e. in case you wonder why you can't wake the TV box with a wireless remote like G10/G20 but have to use the TV box's original IR remote). This is buried pretty deep in the internet.
In short, you need to type this (of course, with root permission) in a terminal:
echo nosleep > /sys/power/wake_lock
#!/system/bin/sh echo nosleep > /sys/power/wake_lock
6. Enabling top bar and navigation bar (navbar): After several posts withsuperceleron and ath156, I think we need to decompile and modify systemUI.apk and framework-res, as indicated in this site:
https://www.semicolonworld.com/quest...oid-status-bar
I did not have a chance to try that method (because all the roms I'm using is AOSP rom, and I do like the bars). Let me know how it works for you.
7. Double click on home button to bring recent apps: Also a very handy feature that I have no idea how to enable. ALVATECH, Xannytech, superceleron how did you guys do that?
SlimBox AOSP roms seem to have this feature by default. If you haven't noticed yet, when you press the "menu" button (the three dash icon button) on your remote, or the "Select" button on your controller WHILE being in the recent-app window, it will kill off all the apps. To kill a specific app, simply move up/down/left/right after being in recent-app window to select it, then hit the DEL button (<x|) or the X button on a gamepad (square button on a PS controller).
If you desperately need a button to invoke recent apps (without using Taskbar - mentioned as a launcher app recommendation below), you can try an app called "Button mapper: Remap your keys" by flar2. Simply map an unused button on your remote (like double clicking the menu button, for example) to open recent app. Root is only required if you want to invoke some action when the box is sleeping.
8. Performance optimization: The whole point of installing a custom rom. A lot of custom roms boast "performance optimization", but no exact detail. ALVATECH, Xannytech, superceleron, ath156 156: is it related to CPU clock speed tweak? Memory boosting? Like those tweaks in LSpeed apk? Something else? Or is it just simply because you removed and replaced a bunch of bloatware apks from stock rom?
9. DTB modification: the purpose is to shrink system, cache, instaboot partitions in order to expand data partition as much as possible. This can significantly enlarge data partition on budget-tight devices (with 8GB internal storage or less). Confirmed working in Android 6 roms, but also confirmed NOT working in android 8 (oreo) roms (probably this is why Xannytech did NOT resize his system partition in XTMOD rom for u211 devices).
Search for "partition" and then "system" in a decrypted (flattened) DTB file (it's actually called a DTS file, but if you google DTS, you'll end up with something else...). Example:
system { pname = "system"; size = <0x00 0x74000000>; mask = <0x01>; linux,phandle = <0x65>; phandle = <0x65>; };
Or you can use Ricky's AMlogic tools for Android 8 and below. The toolkit allow you to directly modify partition sizes. All sizes are in BYTES
Update: bumerc tool can now resize android 9 (and 10 Q?) image partitions, with a single command.
Also, DTB file can be used to fix a weird usb error when running Coreelec from sdcard: when I'm on my stock rom, booting coreelec from sd card would result in one USB port not working. However, if XTMOD rom is in the box and I start coreelec from sd card, that USB port is working correctly! This is because the stock rom has bad DTB configuration for a usb port. I have to search "usb" in the DTB file and compare every section containing "usb" between my stock rom and XTMOD DTB to find out a single mismatch value, and fix my stock rom's DTB!
Another example of DTB modification is to fix no-ethernet issue in Tanix TX3 S905X3 box for armbian, mentioned here by hannah:
https://forum.armbian.com/topic/1669...etooth-module/
https://forum.armbian.com/topic/1298...comment-108204
[In case you think you BRICKED your device...]
Don't panic! Unless you physically destroyed the hardware of your android box, either by smashing it or pouring water on it, it's almost guaranteed to be revivable. Simply google your box name, model, and the key word "NAND mask" or "NAND short" or "Chip mask". Hopefully somebody have already figured the box's NAND short location, and you simply need to short it after powering the box on before being able to use tools like USB burn tool or restore firmware through micro SD card. If not, take high-resolution pictures of the front and back of your box's motherboard, and open a new thread here in Freaktab to ask for help.
Example: here is the NAND short location for H96 MAX X2 2GB/16GB box:
https://www.google.com/url?sa=i&url=...AAAAAdAAAAABAD
hannah: If you have the location of NAND chip mask for the TANIX TX3 box, please share it with us. Thanks!
[Apps categorizations and suggestions]
1. Youtube:
Smart Tube Next: Latest No-ad youtube.designed for Android TV. Works with remotes AND gamepads!!! Voice search works with google framework, so don't freeze or uninstall google framework if you want to use voice search. You can safely disable the google play services and google play store app and still be able to do voice search in Smart Tube Next.
Update: Some searches like "paw patrol" or "dora the explorer" suddenly works again in Smart Tube Next for no reason. It didn't work several weeks ago. You can thank Google for that! So right now, Smart Tube Next is the KING.
Smart Youtube TV: Older but more stable no-ad youtube, designed for Android TV, and works intuitively with remotes (i.e. left button = rewind, right button = fast forward, etc...). Does yield results for "paw patrol", if you wonder. Doesn't work with gamepad/controller up/down/left/right axes. Without google search and voice recognition, the voice search function won't work: when you press the voice search button on your fancy air remote, a recording icon will appear and "splash" out, but actually does nothing. No background music playback either.
Alternative: Youtube Vanced + microG: no-ad, designed for phones and tablet, background music playback enabled by default. However, remote buttons don't work. You have to have a mouse or airmouse. It also works without google service framework, and voice search works regardless of the presence of google framework.
2. Video Player:
MX Player. Simply the best video player for 1080p resolution and below. Also act as a de-facto music player if needed. I knew it since the time I still have my Nexus 7 1st gen, and even with such ancient hardware, it was able to play 1080p@30fps video without a hiccup. It's also intuitive to use with a remote. The free version comes with ads and limited features, so I suggest googling for MX Player Pro.
For some reason, Xannytech includes MX Player Codec armv7 apk in his rom (XTMOD). I'm not sure what exactly that is for, but I never have a problem without MX Player Codec apk. Xannytech: any insight?
Update: Nova Video Player. I got this from Slimbox rom. looks sleek and very TV remote friendly. It's just a bit less smooth than MX Player.
KODI. The most well-known piracy-prone video streaming app. Just kidding :v It's simply a media player app with many extra features, each can be installed as an addon. By itself, it can be an operating system (google CoreElec (Amlogic) or LibreElec (non-Amlogic) for more detail), including video player, audio player, picture slideshow (YES! while playing music in the background - KODI is just so perfect fot this purpose), and retro game emulators!
In some of Xannytech XTMOD rom (like the one for the S905X Mini M8S II), I saw that he was including SPMC instead, which was supposed to be a KODI-for-android version. However, a lot has changed since then, and if you google it, SPMC is no longer maintained, and KODI was officially supporting Android for a while now. Xannytech: any thoughts? Your XTMOD roms indicated that you optimized KODI and SPMC. How?
3. Droid Settings:
It's a setting app specifically for android TV (such as changing screen resolutions, HDMI CEC, Power button options, Dolby Audio, etc...). If you find a rom with this apk and it has the same type (ATV or non-ATV) and android version with your firmware, you can extract the Droid Settings apk and put it in your rom. I prefer it to be a stand-alone apk, but in some roms (like Xannytech's XTMOD roms), it's integrated to Square Home launcher and is not accessible in an App Drawer.
4. Screen mirroring:
AirScreen. I've seen this apk in a hell lot of roms (including XTMODs). It seems to be in conjunction with DLNA and media server apks. Xannytech: can you give some more detail? I didn't use this app much, only for testing purpose. To me, this is still not the way wireless display should work. My vision of screen mirroring is at least 60FPS without performance compromisation. Right now, even chromecast or any miracast is still limited to 30FPS.
5. Web browsing:
Don't use Chrome, please. Seriously. Use Brave instead if you love chrome. It's ad-free and anti-tracking. You can debate whether Brave is better than Firefox + Adblock Plus. On phones and tablets, Brave seems to be faster than Firefox. In contrast, on Desktop, Brave is slightly slower than Firefox.
6. Terminal app:
Android Terminal Emulator, Termux, etc... (bundled in all Xannytech's XTMOD roms). However, some rom may not work with Android Terminal Emulator for some reason (like the XTMOD for u211 devices rom). My alternative is JuiceSSH. It's designed as a ssh client, but it can open a local terminal as well. It's very intuitive to use on phones and tablets, and for android TV without a physical keyboard. Google it to download the latest version.
7. Adblocker (root required):
Adaway. Need no introduction for a system-wide adblocker if you use a rooted android phone
8. Firewall (root required): the purpose is to prevent specific apks from connecting to the internet, so that it won't display ads or won't ask for update constantly.
AFWall+. I never saw any modder include this app in their rom. It can allow/deny specific app to connect to any network. Google AFWall+ Donate apk if you don't like the free version.
9. Reboot app:
Simple Reboot (required root), included in all Xannytech's XTMOD roms. So that you don't have to unplug and plug the power cord to reset your box.
10. File Browser:
Total Commander is included in all Xannytech's XTMOD roms. It's free and good.
Update: Xplorer: included in SlimBox roms.
My preference is Root Explorer. It's not free, but sleek.
11. Launcher:
Update: Launcher3 (or Laucher<3), come with SlimBox AOSP rom. Simply light-weight, just-work launcher that is the default for AOSP vanilla roms, with app-switch icon by default for easy TV navigation.
SquareHome3 (included in many modded roms like XTMOD, ALVATECH, etc...).
However, since I'm coming from phones and tablets, I suggest Nova launcher, a simple, butter-fluid launcher for any kind of hardware. It works with remotes, too. Google the paid version, of course. However, if you cannot add app to the home screen in Nova Launcher, search for Lineage OS's Trebuchet launcher for your android version (i.e. Trebuchet Oreo, Trebuchet Pie, etc...). It's a bit more laggy than Nova Launcher but it did the job and it's free. Works with remotes too.
Recommended by ath156: Taskbar. It's designed to mimic Windows' task bar, but it can actually be used as a launcher. However, you cannot navigate using remote/controller buttons. A mouse/air-mouse is a must.
N. List of google apks (to be removed if you don't want google stuff - it's also a good performance boost if google stuff is removed, especially for older boxes with S8xx or even S905x with less than 2GB of memory):
Note: on Android 9 (Pie) and above, some of the google apps may be located in Vendor or Product partition, so I only list the name of those apps here. This is NOT an exhaustive list.
For android 8 (oreo) and above, do NOT attempt to remove google apps while modding the rom's img. It will cause bootloop. You better use some kind of system app remover like Titanium backup to remove google system apks after you boot the box the first time. I learned this the hard way...
- Katniss: the google search app for Android TV (hidden, but required for voice controll)
- Velvet: the google search app
- Youtube (or Youtube TV): the youtube app
- Chrome: you know what it is
- GoogleTTS: text-to-speech
- Phonesky: Google Playstore app (com.google.vending for older android)
- GoogleCalendarSyncAdapter
- GoogleContactSyncAdapter
- PrebuiltDeskClockGoogle (actually, it works without google framework, as a nice simple widget)
- PrebuiltExchange3Google
- GmsCoreSetupPrebuilt
- GoogleBackupTransport
- GoogleExtServices
- GoogleFeedback
- GoogleLoginService
- GoogleOneTimeInitializer
- GooglePackageInstaller
- GooglePartnerSetup
- GoogleServiceFramework (yes, this is the core)
Comment