延迟重启MpAPP

避免打断拍照
MQTTtest
Matthew 9 months ago
parent fd16115e3e
commit fa176e8877

@ -121,6 +121,7 @@ public class MpMasterService extends Service {
private boolean mSeparateNetwork = false; private boolean mSeparateNetwork = false;
private long mDelayedRestartMpTime = 60000;
private PendingIntent mPreviousHB = null; private PendingIntent mPreviousHB = null;
private long mPreviousHeartbeatTime = 0; private long mPreviousHeartbeatTime = 0;
@ -366,7 +367,7 @@ public class MpMasterService extends Service {
final String appPath = MicroPhotoContext.buildMpAppDir(context); final String appPath = MicroPhotoContext.buildMpAppDir(context);
final long ts = System.currentTimeMillis(); final long ts = System.currentTimeMillis();
if (ts - mTimeToStartMpApp < 30000) { if (ts - mTimeToStartMpApp < 30000) {
logger.warning("MpAPP is STILL Running"); logger.warning("MpAPP has restarted in 30s");
return; return;
} }
@ -387,7 +388,7 @@ public class MpMasterService extends Service {
MicroPhotoContext.restartMpApp(context); MicroPhotoContext.restartMpApp(context);
mTimeToStartMpApp = System.currentTimeMillis(); mTimeToStartMpApp = System.currentTimeMillis();
} }
}, 60000); }, mDelayedRestartMpTime);
} }
} catch (Exception ex) { } catch (Exception ex) {
@ -521,7 +522,7 @@ public class MpMasterService extends Service {
mService.mMpHeartbeatDuration = intent.getIntExtra("HeartbeatDuration", 600000); mService.mMpHeartbeatDuration = intent.getIntExtra("HeartbeatDuration", 600000);
} }
mService.logger.info("Heartbeat Timer Fired By MpAPP ACTION=" + action); mService.logger.info("Heartbeat Timer Fired By MpAPP ACTION=" + action + " MpHB=" + Long.toString(mService.mMpHeartbeatDuration));
mService.registerHeartbeatTimer(); mService.registerHeartbeatTimer();
@ -645,6 +646,7 @@ public class MpMasterService extends Service {
registerHeartbeatTimer(zeroPoint + closestTime * 1000, keepAlive); registerHeartbeatTimer(zeroPoint + closestTime * 1000, keepAlive);
} }
} else { } else {
// mUsingAbsHbTime: false
if ((mPreviousHeartbeatTime != 0) && (mPreviousHeartbeatTime - currentTimeMs < mHeartbeatDuration * 1000)) { if ((mPreviousHeartbeatTime != 0) && (mPreviousHeartbeatTime - currentTimeMs < mHeartbeatDuration * 1000)) {
registerHeartbeatTimer(mPreviousHeartbeatTime + mHeartbeatDuration * 1000, keepAlive); registerHeartbeatTimer(mPreviousHeartbeatTime + mHeartbeatDuration * 1000, keepAlive);
} else { } else {

Loading…
Cancel
Save