通过命令行的方式重启系统

lowmem
Matthew 1 month ago
parent f433903745
commit 0f54876da8

@ -1204,19 +1204,6 @@ bool CPhoneDevice::Reboot(int resetType, bool manually, const std::string& reaso
GpioControl::reboot();
#else
RestartApp(resetType, timeout, reason);
std::thread t([timeout, fileName]()
{
// Double Calls
std::this_thread::sleep_for(std::chrono::milliseconds(timeout + 5000));
GpioControl::reboot();
writeFile(fileName + ".new", NULL, 0);
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
GpioControl::reboot2();
});
t.detach();
#endif
}
}

@ -1563,6 +1563,23 @@ public class MicroPhotoService extends Service {
} else {
Log.w(TAG, "Recv REBOOT command");
SysApi.reboot(MicroPhotoService.this.getApplicationContext());
new Thread(new Runnable() {
@Override
public void run() {
sleep(5000);
try {
Process process = Runtime.getRuntime().exec("/system/xbin/su root");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("/system/bin/reboot\n");
os.writeBytes("exit\n"); // 重要退出su shell
os.flush();
int exitValue = process.waitFor();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}).start();
}
}
};

Loading…
Cancel
Save