From 38fe69d93bbed68df00597a5dc9f3986eec26f8d Mon Sep 17 00:00:00 2001 From: Matthew Date: Tue, 6 May 2025 14:33:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E6=8B=8D=E7=85=A7?= =?UTF-8?q?=E9=97=B9=E9=92=9F=E7=9A=84=E5=A4=84=E7=90=86=EF=BC=88=E5=85=B6?= =?UTF-8?q?=E4=B8=AD=E5=8C=85=E5=90=AB=E5=BF=83=E8=B7=B3=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xypower/mpmaster/MpMasterService.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java b/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java index b1702c0a..feb74576 100644 --- a/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java +++ b/mpmaster/src/main/java/com/xypower/mpmaster/MpMasterService.java @@ -256,6 +256,7 @@ public class MpMasterService extends Service { intentFilter.addAction(ACTION_UNINSTALL_RESULT); intentFilter.addAction(ACTION_REQ_RESTART_APP); intentFilter.addAction(MicroPhotoContext.ACTION_HEARTBEAT_MP); + intentFilter.addAction(MicroPhotoContext.ACTION_TAKEPHOTO_MP); registerReceiver(mAlarmReceiver, intentFilter); } @@ -645,7 +646,17 @@ public class MpMasterService extends Service { mService = service; } - public void onReceive(Context context, Intent intent) { + public void onReceive(final Context context, final Intent intent) { + mService.mHander.postDelayed(new Runnable() { + @Override + public void run() { + processAction(context, intent); + } + }, 0); + + } + + public void processAction(final Context context, final Intent intent) { String action = intent.getAction(); if (TextUtils.equals(ACTION_HEARTBEAT, action)) { boolean keepAlive = intent.getBooleanExtra("keepAlive", false); @@ -681,6 +692,22 @@ public class MpMasterService extends Service { mService.startMaster(true); } mService.detectMpAppAlive(); + } else if (TextUtils.equals(MicroPhotoContext.ACTION_TAKEPHOTO_MP, action)) { + if (intent.hasExtra("HeartbeatDuration")) { + int hbDuration = intent.getIntExtra("HeartbeatDuration", 600000); + mService.mMpHeartbeatDuration = hbDuration > 0 ? hbDuration : 600000; + + mService.mPreviousMpHbTime = intent.getLongExtra("HeartbeatTime", System.currentTimeMillis()); + mService.logger.info("Heartbeat Timer Fired By MpAPP ACTION=" + action + " MpHB=" + Long.toString(mService.mMpHeartbeatDuration) + " HBTime =" + mService.mPreviousMpHbTime); + + mService.registerHeartbeatTimer(); + + mService.buildChargingBatteryVoltage(System.currentTimeMillis()); + if (!mService.mSeparateNetwork && (!mService.mMntnMode)) { + mService.startMaster(true); + } + mService.detectMpAppAlive(); + } } else if (TextUtils.equals(ACTION_UPDATE_CONFIGS, action)) { int restart = intent.getIntExtra("restart", 0); mService.logger.info("Update Config Fired ACTION=" + action + " restart=" + restart);