通过附件编译时间来选择不同的判断运维程序是否运行的方法

lowmem
Matthew 2 months ago
parent 126c1f5e1b
commit 55c3776ac8

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

Loading…
Cancel
Save