From 55c3776ac8a9f64c4b6148778c38d53d1c35c81e Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 24 Apr 2025 15:47:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=BF=87=E9=99=84=E4=BB=B6=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E6=97=B6=E9=97=B4=E6=9D=A5=E9=80=89=E6=8B=A9=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E7=9A=84=E5=88=A4=E6=96=AD=E8=BF=90=E7=BB=B4=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E6=98=AF=E5=90=A6=E8=BF=90=E8=A1=8C=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xypower/mpapp/MicroPhotoService.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java index a3fa32ee..852ebb03 100644 --- a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java +++ b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java @@ -435,7 +435,22 @@ public class MicroPhotoService extends Service { System.exit(0); } - private void ProcessReceivedAction(Context context, Intent intent) { + private boolean isMpMasterAlive(Context context) { + if (Build.TIME < 1744905600000L) { + // 2025-04-18 old firmware + // Check Log file time + File file = new File(MicroPhotoContext.buildMasterAppDir(context) + "logs/mlog.txt"); + if (file.exists()) { + return ((System.currentTimeMillis() - file.lastModified()) < 1800000); + } else { + return false; + } + } + + return MicroPhotoContext.isAppAlive(context, MicroPhotoContext.PACKAGE_NAME_MPMASTER, MicroPhotoContext.SERVICE_NAME_MPMASTER); + } + + private void ProcessReceivedAction(final Context context, final Intent intent) { String action = intent.getAction(); if (TextUtils.equals(ACTION_HEARTBEAT, action)) { long ts = System.currentTimeMillis(); @@ -461,18 +476,20 @@ public class MicroPhotoService extends Service { mService.detectGpsStatus(); + /* ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivityManager != null) { if (!connectivityManager.isDefaultNetworkActive()) { infoLog("DefaultNetwork is NOT Active"); } } + */ } catch (Exception ex) { ex.printStackTrace(); } try { - boolean mpmstAlive = MicroPhotoContext.isAppAlive(context, MicroPhotoContext.PACKAGE_NAME_MPMASTER, MicroPhotoContext.SERVICE_NAME_MPMASTER); + boolean mpmstAlive = isMpMasterAlive(context); if (!mpmstAlive) { Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(MicroPhotoContext.PACKAGE_NAME_MPMASTER); // launchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);