diff --git a/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java b/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java index 8c67350f..b9b1e0ef 100644 --- a/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java +++ b/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java @@ -444,18 +444,29 @@ public class MpMasterService extends Service { } long tempduration = mMpHeartbeatDuration; - if (mMpHeartbeatDuration < 600000) - tempduration = 290000; - if (mPreviousMpHbTime <= ts && ts - mPreviousMpHbTime > tempduration * 2) { + if (mMpHeartbeatDuration < 600000) { + tempduration = 600000; + } + if (mPreviousMpHbTime <= ts && (ts - mPreviousMpHbTime) > tempduration * 3) { // MpApp is not running if (ts - mTimeToStartMpApp >= 1800000) { // 30 minutes 30 * 60 * 1000 - if (false) { - MpMasterService.restartMpApp(context.getApplicationContext(), "MpMST Keep Alive Detection"); - } + MpMasterService.restartMpApp(context.getApplicationContext(), "MpMST Keep Alive Detection"); + + String prevMpHBTime = ""; + String prevRestartTime = ""; + try { + SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm:ss"); + Date date = new Date(mPreviousMpHbTime); + prevMpHBTime = format.format(date); + Date date2 = new Date(mTimeToStartMpApp); + prevRestartTime = format.format(date2); + } catch (Exception ex) { + ex.printStackTrace(); + } logger.warning("Restart MpAPP as it is NOT Running Prev MPAPP HB=" + - Long.toString((ts - mPreviousMpHbTime) / 1000) + " MPAPP HBDuration=" + Long.toString(mMpHeartbeatDuration) - + " Prev MpRestart Time=" + Long.toString(mTimeToStartMpApp) + " last MPAPPHB =" + (mPreviousMpHbTime / 1000)); + Long.toString((ts - mPreviousMpHbTime) / 1000) + " MPAPP HBDuration=" + Long.toString(tempduration) + + " Prev MpRestart Time=" + prevRestartTime + " last MPAPPHB =" + prevMpHBTime); mTimeToStartMpApp = ts; } else {