0

I've a OnePlus One with unlocked bootloader, modified TWRP v2.8.6, unofficial MultiROM v32k, MultiROM Manager v1.186, Cyanogen OS 12 as primary and several Android 5.1 secondary ROMs. I don't have any non-Android secondary ROM.

I created a Android backup script in my PC which requires me to boot into a particular ROM of mine for backup to take place. This is not an XY problem and hence I need not to discuss anything about the flexibility of backup. I must boot into a particular secondary ROM (say S1).

At present, I'm using , Tasker precisely, which using time trigger launches MultiROM and uses combination of input tap commands to navigate to S1's entry and taps it to boot into it. As you may have guessed, this approach is mundane and is bound to fail should the user deliberately or inadvertently touches any soft/hard button or interacts with UI of the active app during which the series of input commands are in use.

I'm absolutely aware about AutoInput, Xposed Additions Pro apps and screen pinning of an app, where the former two allows independently disabling soft/hard keys for an active app. AutoInput can even simulate recorded touches. However, none of them can disable input from touchscreen, with touch input being the biggest cause of failure with current solution.

Being unable to find out a way to block touch input on-the-fly, I decided to figure how MultiROM Manager app causes a device to boot into a particular ROM. It was a hopeless journey to begin with, given that the keywords viz. command, multirom, adb, boot, secondary, primary ROM, are found wherever MultiROM is mentioned. Since even advanced web search didn't benefit me, I decided to peek into the output of and see whether it gives me something useful. Once again, nothing of any good use.

I found myself left with the choice to contact Vojtech Bocek (Tassadar, the original developer of MultiROM) for the solution or peek into the source code of the app. Deciding to go with the latter choice, during my exploration I stumbled upon these lines in MultiROM.java

public void bootRom(Rom rom) {
    String name = (rom.type == Rom.ROM_PRIMARY) ? INTERNAL_ROM : rom.name;
    Shell.SU.run("%smultirom --boot-rom='%s'", m_path, name);
}

Being through with libsuperuser already, I took an educated guess that Shell.SU.run("%s/multirom --boot-rom='%s'", m_path, name) most likely corresponds to the command run in a shell with superuser privilege.

And, this is the end of the story since I've checked all the locations under $PATH and none of them contains the binary named multirom.

So, how do I boot into a particular ROM now?

1
  • Now that I think about it, I realized that I can use Tasker's scene in overlay blocking mode over the screen except at places where input tap would be performed.
    – Firelord
    Commented Dec 30, 2015 at 0:12

2 Answers 2

0

I later realized that the major inconvenience in my solution, the touch input, can be stopped if I use Tasker's scenes in overlay blocking mode.

(Click image to enlarge)

IMG: IMG: IMG:

I created several blank scenes and configured task to display them in such a way, that only a small fraction of screen can send touch input to app (fraction is allowed because I need to do input tap). The Manage ROMs window works well with DPAD key events so I used Task → Input → Dpad to reach my preferred ROMs entry and tap it.

To disable input from navigational keys, I used Xposed Additions Pro. Here are the relevant instructions. (Follow instructions there up to step 10.)

I also successfully tested AutoInput as an alternative for Xposed Additions. In a task, its relevant usage is:

Plugin → AutoInput → Modes:

  1. Configuration:

    1. Key Suppress: Enable
    2. Keys: your navigation key
  2. Timeout (Seconds): None

Make sure to enable its accessibility service in Settings → Accessibility.

This solution is not convenient as much as my other solution is, but it gets the job done.

0

I searched for the string multirom --boot-rom and came across an interesting paste (copy) posted by an untitled guest, with these relevant lines:

<alvinmobile> How do you autoboot other rom in a secondary rom?

<alvinmobile> I mean where do you store the info?

<Tassadar> it runs "multirom --boot-rom=nameoftherom" in su shell, and MultiROM takes care of that - it loads ROM list as usual and either directly kexecs the required kernel or sets force-autoboot into rom X (which saves into multirom.ini) and reboots

I was on the right track as it seems. I suddenly realized that multirom installer zip may be the final piece of the puzzle. And it was, since it contains the multirom binary and uses extract_multirom.sh script to place the binary et al into /data/media/0/multirom (accessible with root access only).

As for finding the name of a ROM, it is what you see in the ROM list in the app or the name of the top-level directories under /data/media/0/multirom/roms.

Boot into the ROM

(Prefix adb shell in commands if you want to use adb to test them.)

The command is very simple:

su -c /data/media/0/multirom/multirom --boot-rom=ROM_NAME

Replace ROM_NAME with the name of the ROM to which you want the device to boot into. It is case-sensitive so Internal works but internal doesn't to boot into primary ROM.

I've not tested passing a ROM's name consisting of special characters but whitespace can be escaped using '' and \. E.g., the name Xenon HD can be passed as 'Xenon\ HD' and the whole command would be

su -c /data/media/0/multirom/multirom --boot-rom='Xenon\ HD'

You can create a symlink for convenience.

Trial and Error

With a bit of testing, I reached the conclusion that the ROM can be switched by editing the multirom.ini file alone, followed by an ordinary reboot instruction. Among other lines in that file, these are the most useful ones:

current_rom=COS12
auto_boot_seconds=5
auto_boot_rom=Internal
auto_boot_type=0

Here,

  • current_rom - contains the name of the currently active ROM or the last active ROM if the device powers off without an instruction to be switched into an another ROM
  • auto_boot_seconds - timeout to boot into default ROM
  • auto_boot_rom - the ROM that should be booted into after timeout
  • auto_boot_type - governs whether there should be a direct switch between ROMs or should the UI for ROM selection be shown during boot

(There are no sources to support the claims. I've reached the conclusion based on my experiment only.)

Let's assume that your active ROM is named COS12, internal ROM is named Internal and you want to switch to Xenon HD. Switch it this way:

(Requires Busybox)

su -c cp /data/media/0/multirom/multirom.ini /data/media/0/multirom/multirom.ini.orig       # one time command and optional, but it is safe to make backup always
su -c sed -i 's/current_rom.*/current_rom\=ROM_NAME/g' /data/media/0/multirom/multirom.ini  # for Xenon HD, ROM_NAME would be Xenon\ HD
su -c sed -i 's/auto_boot_type.*/auto_boot_type\=2/g' /data/media/0/multirom/multirom.ini   # changing to `2` causes MultiROM to directly boot into the ROM mentioned in `current_rom`. The setting would later be reverted to 0 after successful boot
su -c reboot

Commands are optional here. You can use a file editor app, such as QuickEdit to edit the file.

Note: During reboot:

  • If auto_boot_type is found 1, the ROM selection UI would be shown after boot logo and it overrides auto_boot_rom which means after timeout the device would boot into whatsoever the current_rom has, automatically.

  • If auto_boot_type is found 3, device would boot straight into whatsoever the current_rom has, but, auto_boot_rom would also now be found same as the current_rom. auto_boot_type later reverts to 1 after successful boot.

    I cannot comment on whether this is a bug or a desired behavior, but this is how it is.

Further note that I wouldn't be surprised if methods mentioned in this answer fails for a non-Android ROM.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .