Search code examples
androidflashrecoveryrom

How to flash ROM from app?


I am trying to make updater for custom rom. I can get to recovery from my app by:

Process p = Runtime.getRuntime().exec("su");
OutputStream os = p.getOutputStream();
os.write("mkdir -p /cache/recovery/\n".getBytes());
os.write("echo 'boot-recovery' >/cache/recovery/command\n".getBytes());
os.write("reboot recovery\n".getBytes());
os.flush();

If I add next lines, device will load to recovery, clear cache and boot to system.

os.write("echo '--whipe-cache' >>/cache/recovery/command\n".getBytes());
os.write("echo 'reboot' >> /cache/recovery/command\n".getBytes());

Is there command to execute flashing?


Solution

  • You can add this line:

    os.write("echo '--update_package=/sdcard/update.zip' >>/cache/recovery/command\n".getBytes());
    

    before

     os.write("reboot recovery\n".getBytes());
     os.flush();