|
|
@ -78,11 +78,9 @@ public class MpMasterService extends Service {
|
|
|
|
private static final String ACTION_HEARTBEAT = "com.xypower.mpmaster.ACT_HB";
|
|
|
|
private static final String ACTION_HEARTBEAT = "com.xypower.mpmaster.ACT_HB";
|
|
|
|
private static final String ACTION_TAKE_PHOTO = "com.xypower.mpapp.ACT_TP";
|
|
|
|
private static final String ACTION_TAKE_PHOTO = "com.xypower.mpapp.ACT_TP";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static final String ACTION_MP_RESTART = "com.xypower.mpapp.ACT_START";
|
|
|
|
public static final String ACTION_IMP_PUBKRY = "com.xypower.mpapp.ACT_IMP_PUBKEY";
|
|
|
|
public static final String ACTION_IMP_PUBKRY = "com.xypower.mpapp.ACT_IMP_PUBKEY";
|
|
|
|
|
|
|
|
|
|
|
|
private static final String EXTRA_PARAM_SCHEDULES = "Schedules";
|
|
|
|
|
|
|
|
private static final String EXTRA_PARAM_SCHEDULE = "Schedule_";
|
|
|
|
|
|
|
|
private static final String EXTRA_PARAM_TIME = "Time";
|
|
|
|
|
|
|
|
private static final String FOREGROUND_CHANNEL_ID = "foreground_channel_id";
|
|
|
|
private static final String FOREGROUND_CHANNEL_ID = "foreground_channel_id";
|
|
|
|
private SmsSendReceiver mSmsSnedReceiver;
|
|
|
|
private SmsSendReceiver mSmsSnedReceiver;
|
|
|
|
|
|
|
|
|
|
|
@ -514,7 +512,7 @@ public class MpMasterService extends Service {
|
|
|
|
int restart = intent.getIntExtra("restart", 0);
|
|
|
|
int restart = intent.getIntExtra("restart", 0);
|
|
|
|
mService.logger.info("Update Config Fired ACTION=" + action + " restart=" + restart);
|
|
|
|
mService.logger.info("Update Config Fired ACTION=" + action + " restart=" + restart);
|
|
|
|
if (restart != 0) {
|
|
|
|
if (restart != 0) {
|
|
|
|
mService.restartApp(context, context.getPackageName());
|
|
|
|
MicroPhotoContext.restartApp(context, context.getPackageName());
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
mService.loadConfig();
|
|
|
|
mService.loadConfig();
|
|
|
|
mService.registerHeartbeatTimer();
|
|
|
|
mService.registerHeartbeatTimer();
|
|
|
@ -897,7 +895,7 @@ public class MpMasterService extends Service {
|
|
|
|
if (rebootType == 0) {
|
|
|
|
if (rebootType == 0) {
|
|
|
|
logger.warning("Recv REBOOT MpMst APP cmd");
|
|
|
|
logger.warning("Recv REBOOT MpMst APP cmd");
|
|
|
|
Context context = MpMasterService.this.getApplicationContext();
|
|
|
|
Context context = MpMasterService.this.getApplicationContext();
|
|
|
|
restartApp(context, context.getPackageName());
|
|
|
|
MicroPhotoContext.restartApp(context, context.getPackageName());
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
logger.warning("Recv RESET cmd");
|
|
|
|
logger.warning("Recv RESET cmd");
|
|
|
@ -908,26 +906,6 @@ public class MpMasterService extends Service {
|
|
|
|
mHander.postDelayed(runnable, 1000);
|
|
|
|
mHander.postDelayed(runnable, 1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void restartApp(Context context, String packageName) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
Context context = MicroPhotoService.this.getApplicationContext();
|
|
|
|
|
|
|
|
Intent intent = getPackageManager().getLaunchIntentForPackage(context.getPackageName());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int noDelay = 1;
|
|
|
|
|
|
|
|
intent.putExtra("noDelay", noDelay);
|
|
|
|
|
|
|
|
PendingIntent restartIntent = PendingIntent.getActivity(context, 0, intent, 0);
|
|
|
|
|
|
|
|
AlarmManager mgr = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
|
|
|
|
|
|
|
|
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, restartIntent); // 1秒钟后重启应用
|
|
|
|
|
|
|
|
System.exit(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Intent LaunchIntent = context.getPackageManager().getLaunchIntentForPackage(packageName);
|
|
|
|
|
|
|
|
LaunchIntent.putExtra("noDelay", 1);
|
|
|
|
|
|
|
|
LaunchIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
|
|
|
|
|
|
context.startActivity(LaunchIntent);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int getActiveSlotIndex() {
|
|
|
|
public int getActiveSlotIndex() {
|
|
|
|
Context context = getApplicationContext();
|
|
|
|
Context context = getApplicationContext();
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
|
|