From 0f54876da83e40f2380086b6ea9fd93185e36dab Mon Sep 17 00:00:00 2001 From: Matthew Date: Tue, 13 May 2025 19:22:26 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=BF=87=E5=91=BD=E4=BB=A4=E8=A1=8C?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E5=BC=8F=E9=87=8D=E5=90=AF=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/PhoneDevice.cpp | 13 ------------- .../com/xypower/mpapp/MicroPhotoService.java | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index d01497f8..1f8585f7 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -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 } } diff --git a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java index d4d69dcb..718fbeea 100644 --- a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java +++ b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java @@ -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(); } } };