对于旧版本,直接注册重启设备的延迟广播来保活

main
Matthew 4 days ago
parent a9ac0743f7
commit a38e3801ae

@ -872,7 +872,12 @@ public class MpMasterService extends Service {
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, triggerTime, pendingIntent);
Intent relaunchIntent = new Intent();
relaunchIntent.putExtra("cmd", "forceLaunch");
if (Build.TIME < 1744905600000L) {
relaunchIntent.putExtra("cmd", "reboot");
} else {
relaunchIntent.putExtra("cmd", "forceLaunch");
}
relaunchIntent.putExtra("pkname", MicroPhotoContext.PACKAGE_NAME_MPMASTER);
relaunchIntent.setAction("com.xy.xsetting.action");
relaunchIntent.setPackage("com.android.systemui");
@ -882,8 +887,11 @@ public class MpMasterService extends Service {
PendingIntent sysKAPendingIntent = PendingIntent.getBroadcast(this, BROADCAST_REQUEST_CODE_SYS_KEEPALIVE, relaunchIntent, PendingIntent.FLAG_UPDATE_CURRENT);
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, launchTs, sysKAPendingIntent);
logger.info(String.format("Register KeepAlive Launch Clock: " + format.format(new Date(launchTs))));
if (Build.TIME < 1744905600000L) {
logger.info(String.format("Register KeepAlive Reboot Clock: " + format.format(new Date(launchTs))));
} else {
logger.info(String.format("Register KeepAlive Launch Clock: " + format.format(new Date(launchTs))));
}
}
@Override
@ -892,6 +900,7 @@ public class MpMasterService extends Service {
Log.d(TAG, "MpMasterService::onStartCommand");
if (intent == null) {
Log.d(TAG, "MpMasterService::onStartCommand intent is null. Stop self");
stopForeground(true);
stopSelf(startId);
return START_NOT_STICKY;
@ -938,7 +947,7 @@ public class MpMasterService extends Service {
stopSelf();
}
return START_REDELIVER_INTENT;
return START_STICKY;
}
private void connect() {
@ -1278,6 +1287,7 @@ public class MpMasterService extends Service {
private static void forceStopMpApp(Context context) {
if (Build.TIME < 1744905600000L) {
// 2025-04-18
SysApi.forceStopApp(context, MicroPhotoContext.PACKAGE_NAME_MPAPP);
} else {
int pid = MicroPhotoContext.getProcessIdOfService(context, MicroPhotoContext.PACKAGE_NAME_MPAPP, MicroPhotoContext.SERVICE_NAME_MPSERVICE);

Loading…
Cancel
Save