Is this caused by flashing two partitions to what would normally be the single system partition, alike to what flashing with fastboot does?
Or does the android recovery zip use the system partition as an android ROM would?
Is this caused by flashing two partitions to what would normally be the single system partition, alike to what flashing with fastboot does?
That sounds plausible. I could not find the location in the code of TWRP that does the check though, only where it gets displayed in the gui code.
Or does the android recovery zip use the system partition as an android ROM would?
No, it still generates two partitions (it's possible to use full disk encryption with the recovery zip method as well, and that needs the two partitions).
@Dees-Troy, @mdmower, @that1, @enh, @bigbiff: GitHub stats says that you are the top contributors for the TWRP repository. So if you have minute you could possibly help us out here.
We built a recovery installer that works with TWRP, but it says that no OS is installed (although the installation worked and it's possible to boot afterwards). After installation, instead of flashing the rootfs as one filesystem to the system partition, we put a partition table and two "subpartitions" to the system partition. (See also: partition layout)
How does TWRP check if a OS is installed, and do you have an idea how we could make it detect our installation? (ideally without changing the TWRP code, so it works with all existing TWRP versions that people may already have flashed)
After a zip install, TWRP runs some functions to update partition details to determine how much space is in use on each partition including the system partition. If the system partition can't be mounted or if there is less than 50MB of files, then TWRP assumes that no OS is installed.
Thanks for the quick answer! So it seems we can't make a solution that is compatible with existing TWRP versions, as we really need to have these two partitions inside of one.
Would TWRP accept a PR that adds code to detect postmarketOS installations, and if so, could you point us to where in the code the current condition is?
Hi @ollieparanoid,
In case you decide to start digging into the reboot OS check yourself, here's a starting point:
gui/theme/common/portrait.xml (there's also landscape.xml and watch.xml):
The reboot screen is in <page name="reboot">. When one of the buttons (e.g. System) is pressed, variables text1 and text2 are set with warning text (which is not shown yet). For System, this occurs via the intermediate page navigation reboot_system_routine and for the other buttons (e.g. Power Off) this occurs as one of the button press actions.
All buttons lead to <page name="rebootcheck">. Two actions are conditionally run on that page: tw_backup_system_size > tw_min_system and tw_backup_system_size < tw_min_system. The first is to check for and offer to install the TWRP app, the latter is to make sure /system is mountable and has more than 50MB of files (configured by TW_MIN_SYSTEM_SIZE in variables.h). You're seeing the warning text when the latter condition is satisfied and you navigate to <page name="confirm_action">, which shows the warning text.
The quick and dirty hack would be to remove both the conditional actions in <page name="rebootcheck">. The far more extensive solution would be to update TWRP's partition manager partitionmanager.cpp to recognize and be able to mount your custom system partition.
Best of luck in your venture! Sorry, I can't say whether or not TWRP would accept your commits, as I was just an outside contributor when I still tinkered with Android. They use gerrit for code review, though, instead of merging pull requests: https://gerrit.omnirom.org/#/q/status:open+project:android_bootable_recovery,n,z
Amazing write up @mdmower! Personally I will most likely not have time to look into this the next weeks, but it's great to know where it would need to be implemented. Maybe someone in the pmOS community wants to give it a shot in the meantime. Thank you very much!
I think the simplest solution for now would be to make a custom TWRP theme for pmOS users that disables the OS check during reboot. I am not sure if we will want to add custom code for pmOS at this point.