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