From d23116aa57730e422848a74a63f4949238606799 Mon Sep 17 00:00:00 2001 From: Matthew Date: Tue, 22 Apr 2025 12:52:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=95=BF=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=97=A0=E5=BF=83=E8=B7=B3=E9=87=8D=E5=90=AFapp=E7=9A=84?= =?UTF-8?q?=E6=9C=BA=E5=88=B6=EF=BC=8C=E5=B9=B6=E4=BC=98=E5=8C=96=E8=BF=90?= =?UTF-8?q?=E7=BB=B4=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xypower/mpmaster/MpMasterService.java | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) 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 {