diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index 6046af09..95fb9da9 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -199,7 +199,7 @@ CPhoneDevice::CPhoneDevice(JavaVM* vm, jobject service, const std::string& appPa mGetSystemInfoMid = env->GetMethodID(classService, "getSystemInfo", "()Ljava/lang/String;"); mInstallAppMid = env->GetMethodID(classService, "installApp", "(Ljava/lang/String;J)Z"); - mRebootMid = env->GetMethodID(classService, "reboot", "(I)V"); + mRebootMid = env->GetMethodID(classService, "reboot", "(IJ)V"); mEnableGpsMid = env->GetMethodID(classService, "enableGps", "(Z)V"); mRequestPositionMid = env->GetMethodID(classService, "requestPosition", "()Z"); @@ -765,6 +765,14 @@ bool CPhoneDevice::Reboot(int resetType) return true; } + long timeout = 1000; + RestartApp(resetType, timeout); + + return true; +} + +void CPhoneDevice::RestartApp(int resetType, long timeout) +{ JNIEnv* env = NULL; bool didAttachThread = false; bool res = GetJniEnv(m_vm, &env, didAttachThread); @@ -772,13 +780,11 @@ bool CPhoneDevice::Reboot(int resetType) { ALOGE("Failed to get JNI Env"); } - env->CallVoidMethod(m_javaService, mRebootMid, resetType); + env->CallVoidMethod(m_javaService, mRebootMid, resetType, timeout); if (didAttachThread) { m_vm->DetachCurrentThread(); } - - return true; } bool CPhoneDevice::EnableGPS(bool enabled) @@ -918,7 +924,7 @@ void CPhoneDevice::handleRebootTimer(union sigval v) CPhoneDevice* pDevice = (CPhoneDevice*)(v.sival_ptr); // Reboot APP XYLOG(XYLOG_SEVERITY_ERROR, "Camera Close Thread is DEAD, will RESTART app"); - pDevice->Reboot(0); + pDevice->RestartApp(0, 2000); } // void CPhoneDevice::handleRebootTimerImpl() diff --git a/app/src/main/cpp/PhoneDevice.h b/app/src/main/cpp/PhoneDevice.h index bf8114a7..abcf6436 100644 --- a/app/src/main/cpp/PhoneDevice.h +++ b/app/src/main/cpp/PhoneDevice.h @@ -263,6 +263,7 @@ protected: void handleTimerImpl(TIMER_CONTEXT* context); void static handleRebootTimer(union sigval v); // void handleRebootTimerImpl(); + void RestartApp(int rebootType, long timeout); int QueryBatteryVoltage(int retries); diff --git a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java index 1f89b02e..bc8f089a 100644 --- a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java +++ b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java @@ -1037,7 +1037,7 @@ public class MicroPhotoService extends Service { return true; } - public void reboot(final int rebootType) { + public void reboot(final int rebootType, final long timeout) { Runnable runnable = new Runnable() { @Override @@ -1052,7 +1052,7 @@ public class MicroPhotoService extends Service { } } }; - mHander.postDelayed(runnable, 1000); + mHander.postDelayed(runnable, timeout > 0 ? timeout : 1000); } public static void restartApp(Context context, String packageName) {