2
我正在尝试构建一个应用程序,该应用程序将自动重新启动恢复并从我的SD卡上刷新一个zip文件。 此应用可以使用系统应用权限,因为我打算将其用作系统应用, 我该怎么做?我怎样才能从应用程序中以编程方式闪光邮编android
我想这个代码
File zip = new File("/sdcard/test.zip");
if(zip.exists()) {
Toast.makeText(context,"ZIP EXIST!",Toast.LENGTH_LONG).show();
Process p = Runtime.getRuntime().exec("sh");
OutputStream os = p.getOutputStream();
os.write("mkdir -p /cache/recovery/\n".getBytes());
os.write("echo 'boot-recovery' >/cache/recovery/command\n".getBytes());
String cmd = "echo '--update_package=/sdcard/test.zip' >> /cache/recovery/command\n";
os.write(cmd.getBytes());
os.flush();
// Trigger the reboot
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
powerManager.reboot("recovery");
}
else{
Toast.makeText(context,"ZIP NOT EXIST!",Toast.LENGTH_LONG).show();
}
我也试过这个代码:
Process p = Runtime.getRuntime().exec("/system/bin/sh");
OutputStream os = p.getOutputStream();
os.write("echo 'boot-recovery ' > /cache/recovery/command".getBytes());
os.write("echo '--update_package=/sdcard/test.zip' >> /cache/recovery/command".getBytes());
os.write("echo '--wipe_cache' >> /cache/recovery/command".getBytes());
os.write("echo 'reboot' >> /cache/recovery/command".getBytes());
os.write("reboot recovery".getBytes());
os.flush();
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
powerManager.reboot("recovery");
但它所做的只是重新启动恢复,它不闪我的拉链。 请帮忙。
PS
我使用的是Android L移动在Nexus 5 TWRP恢复