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

main
Matthew 5 days ago
parent a9ac0743f7
commit a38e3801ae

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

Loading…
Cancel
Save