优化重启APP的等待时间

hdrplus
Matthew 1 year ago
parent 2b38a768c7
commit 71bca1aca4

@ -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()

@ -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);

@ -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) {

Loading…
Cancel
Save