调试获取电压和mpapp自启

nx2024
liuguijing 3 months ago
parent d2ba139c20
commit a5f1697856

@ -1344,15 +1344,24 @@ public class MicroPhotoService extends Service {
public static void restartApp(Context context, String packageName, String reason) {
Intent intent = new Intent(context, MainActivity.class);
int noDelay = 1;
intent.putExtra("noDelay", noDelay);
if (!TextUtils.isEmpty(reason)) {
intent.putExtra("reason", reason);
}
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
context.startActivity(intent);
// Intent intent = new Intent(context, MainActivity.class);
// int noDelay = 1;
// intent.putExtra("noDelay", noDelay);
// if (!TextUtils.isEmpty(reason)) {
// intent.putExtra("reason", reason);
// }
//
// intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
// context.startActivity(intent);
// System.exit(0);
Intent restartIntent = new Intent();
restartIntent.putExtra("cmd", "forceLaunch");
restartIntent.putExtra("pkname", packageName);
restartIntent.setAction("com.xy.xsetting.action");
restartIntent.setPackage("com.android.systemui");
context.sendBroadcast(restartIntent);
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);

@ -427,7 +427,7 @@ public class MpMasterService extends Service {
if (!isMpAppRunning) {
// Restart MpApp
MpMasterService.restartMpApp(context,"MpMST Keep Alive Detection: NO Lock");
MpMasterService.restartMpApp(context, "MpMST Keep Alive Detection: NO Lock");
logger.warning("Restart MpAPP as There is NO Lock");
mTimeToStartMpApp = ts;
return;
@ -443,7 +443,7 @@ public class MpMasterService extends Service {
// MpApp is not running
if (ts - mTimeToStartMpApp >= 1800000) { // 30 minutes 30 * 60 * 1000
if (false) {
MpMasterService.restartMpApp(context.getApplicationContext(),"MpMST Keep Alive Detection");
MpMasterService.restartMpApp(context.getApplicationContext(), "MpMST Keep Alive Detection");
}
logger.warning("Restart MpAPP as it is NOT Running Prev MPAPP HB=" +
@ -694,7 +694,7 @@ public class MpMasterService extends Service {
int restart = intent.getIntExtra("restart", 0);
mService.logger.info("Update Config Fired ACTION=" + action + " restart=" + restart);
if (restart != 0) {
MpMasterService.restartMpMasterApp(context,"Config Updated");
MpMasterService.restartMpMasterApp(context, "Config Updated");
} else {
mService.loadConfig();
mService.registerHeartbeatTimer();
@ -1087,9 +1087,12 @@ public class MpMasterService extends Service {
}
private void buildChargingBatteryVoltage(long ts) {
logger.info("电压测试开始");
int val = 0;
for (int idx = 0; idx < 3; idx++) {
logger.info("电压测试第" + idx + "次开始读取");
val = MpMasterService.getInt(112);
logger.info("电压测试第" + idx + "次读取结束 " + val);
if (val > 0) {
break;
}
@ -1163,7 +1166,7 @@ public class MpMasterService extends Service {
if (rebootType == 0) {
logger.warning("Recv REBOOT MpMst APP cmd");
Context context = MpMasterService.this.getApplicationContext();
MpMasterService.restartMpMasterApp(context,reason);
MpMasterService.restartMpMasterApp(context, reason);
} else {
logger.warning("Recv RESET cmd");
SysApi.reboot(MpMasterService.this.getApplicationContext());
@ -1256,8 +1259,8 @@ public class MpMasterService extends Service {
return 0;
}
//重启运维应用
public static void restartMpMasterApp(Context context,String reason) {
//重启运维应用
public static void restartMpMasterApp(Context context, String reason) {
Intent intent = new Intent(context, MainActivity.class);
if (intent != null) {
if (!TextUtils.isEmpty(reason)) {
@ -1270,7 +1273,7 @@ public class MpMasterService extends Service {
System.exit(0);
}
//重启MpApp应用
//重启MpApp应用
public static void restartMpApp(Context context, String reason) {
SysApi.forceStopApp(context, MicroPhotoContext.PACKAGE_NAME_MPAPP);
@ -1295,8 +1298,8 @@ public class MpMasterService extends Service {
}
}
//根据包名重启应用
public static void restartAppByPackage(Context context,String packagename, String reason) {
//根据包名重启应用
public static void restartAppByPackage(Context context, String packagename, String reason) {
SysApi.forceStopApp(context, packagename);
try {
@ -1390,7 +1393,7 @@ public class MpMasterService extends Service {
}
}
copyAssetsDir(context, "mpapp/data", tmpDestPath.getAbsolutePath());
MpMasterService.restartMpApp(context.getApplicationContext(),"FIRST Config Init");
MpMasterService.restartMpApp(context.getApplicationContext(), "FIRST Config Init");
}
};

Loading…
Cancel
Save