From d8136da9a14a76730a5282a99581942411abae74 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 6 May 2024 15:35:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E9=87=8D=E5=A4=8D=E7=9A=84?= =?UTF-8?q?=E8=BF=90=E7=BB=B4=E8=AF=B7=E6=B1=82=EF=BC=8C=E5=B9=B6=E9=92=88?= =?UTF-8?q?=E5=AF=B9=E4=B8=8D=E5=90=8C=E7=9A=84=E8=BF=90=E7=BB=B4=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E6=B7=BB=E5=8A=A0=E4=B8=8D=E5=90=8C=E7=9A=84=E6=A0=87?= =?UTF-8?q?=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/xypower/mpmaster/AppMaster.java | 11 ++++++++++- .../java/com/xypower/mpmaster/MpMasterService.java | 12 ++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/mpmaster/src/main/java/com/xypower/mpmaster/AppMaster.java b/mpmaster/src/main/java/com/xypower/mpmaster/AppMaster.java index 00f58efe..539568df 100644 --- a/mpmaster/src/main/java/com/xypower/mpmaster/AppMaster.java +++ b/mpmaster/src/main/java/com/xypower/mpmaster/AppMaster.java @@ -50,6 +50,7 @@ public class AppMaster { private MpMasterService mService; private String mMasterUrl; private String mCmdid; + private boolean mBundleWithMpApp; private PowerManager.WakeLock mWakelock; public static final String CMD_REBOOT_APP = "cmd_reboot_app"; @@ -70,13 +71,18 @@ public class AppMaster { public static final String CMD_IMPORT_PUB_KEY = "imp_pub_key"; - public AppMaster(MpMasterService service, String masterUrl, String cmdid) { + public AppMaster(MpMasterService service, String masterUrl, String cmdid, boolean bundleWithMpApp) { mService = service; mMasterUrl = masterUrl; mCmdid = cmdid; + mBundleWithMpApp = bundleWithMpApp; mWakelock = null; + if (!mBundleWithMpApp) { + int aa = 0; + } + try { PowerManager powerManager = (PowerManager) service.getSystemService(Context.POWER_SERVICE); mWakelock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "com.xypower.mpmaster:MpMaster"); @@ -204,6 +210,9 @@ public class AppMaster { List> postParams = new ArrayList<>(); postParams.add(new Pair("id", mCmdid)); postParams.add(new Pair("XyDev", "1")); + if (mBundleWithMpApp) { + postParams.add(new Pair("bundled", "1")); + } postParams.add(new Pair("bootTime", Long.toString(getBootTime()))); postParams.add(new Pair("i1Version", mService.getMpAppVersion())); postParams.add(new Pair("oid", mService.getSerialNo())); diff --git a/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java b/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java index b2ee237d..5c494dbe 100644 --- a/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java +++ b/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java @@ -225,7 +225,7 @@ public class MpMasterService extends Service { // AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); - startMaster(); + // startMaster(false); startMpApp(); registerHeartbeatTimer(); @@ -416,7 +416,7 @@ public class MpMasterService extends Service { } } - private void startMaster() { + private void startMaster(boolean bundleWithMpApp) { String masterUrl = MicroPhotoContext.DEFAULT_MASTER_URL; MicroPhotoContext.MasterConfig masterConfig = MicroPhotoContext.getMasterConfig(getApplicationContext()); @@ -429,7 +429,7 @@ public class MpMasterService extends Service { logger.warning("Start Mntn report:" + masterUrl); - AppMaster appMaster = new AppMaster(this, masterUrl, appConfig.cmdid); + AppMaster appMaster = new AppMaster(this, masterUrl, appConfig.cmdid, bundleWithMpApp); appMaster.start(); } @@ -448,7 +448,7 @@ public class MpMasterService extends Service { mService.registerHeartbeatTimer(); - mService.startMaster(); + mService.startMaster(false); mService.startMpApp(); } else if (TextUtils.equals(MicroPhotoContext.ACTION_HEARTBEAT_MP, action)) { @@ -457,7 +457,7 @@ public class MpMasterService extends Service { mService.registerHeartbeatTimer(mService.mPreviousHeartbeatTime + mService.mHeartbeatDuration * 1000); - mService.startMaster(); + mService.startMaster(true); mService.startMpApp(); } } else if (TextUtils.equals(ACTION_UPDATE_CONFIGS, action)) { @@ -533,7 +533,7 @@ public class MpMasterService extends Service { registerHeartbeatTimer(); - startMaster(); + startMaster(false); break; case ACTION_STOP: