From 3f7388a4cfba9667ac500d3a09461bb5dbb98052 Mon Sep 17 00:00:00 2001 From: Matthew Date: Thu, 17 Apr 2025 18:46:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=B6=E9=97=B4=E5=8F=91?= =?UTF-8?q?=E7=94=9F=E5=8F=98=E5=8C=96=E5=90=8E=E7=9A=84=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 7 ++++++- app/src/main/cpp/MicroPhoto.cpp | 19 ++++++++++++++++++- .../com/xypower/mpapp/MicroPhotoService.java | 16 ++++++++++------ 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 0f614729..08ac2a18 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -86,6 +86,10 @@ + + + + + android:exported="true" > + (handle); + if (pTerminal == NULL) + { + return; + } + + std::thread t([pTerminal]() + { + pTerminal->OnTimeUpdated(); + }); + t.detach(); +} diff --git a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java index 0faea91d..f87f0370 100644 --- a/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java +++ b/app/src/main/java/com/xypower/mpapp/MicroPhotoService.java @@ -119,6 +119,7 @@ public class MicroPhotoService extends Service { private static final String ACTION_HEARTBEAT_MANUALLY = "com.xypower.mpapp.ACT_HB_M"; private static final String ACTION_UPDATE_CONFIGS = "com.xypower.mpapp.ACT_UPD_CFG"; public static final String ACTION_VIDEO_FINISHED = "com.xypower.mpapp.ACT_V_FINISHED"; + private static final String EXTRA_PARAM_CHANNEL = "Channel"; private static final String EXTRA_PARAM_PRESET = "Preset"; private static final String EXTRA_PARAM_PHOTO_OR_VIDEO = "PhotoOrVideo"; @@ -272,11 +273,7 @@ public class MicroPhotoService extends Service { intentFilter.addAction(ACTION_HEARTBEAT_MANUALLY); intentFilter.addAction(ACTION_GPS_TIMEOUT); intentFilter.addAction(ACTION_RESTART); - // intentFilter.addAction(ACTION_HEARTBEAT_MANUALLY); - // intentFilter.addAction(ACTION_MSG_BROADCAST); - // intentFilter.addAction(ACTION_VIDEO_FINISHED); - // intentFilter.addAction(ACTION_STOP); - // intentFilter.addCategory(Intent.CATEGORY_DEFAULT); + intentFilter.addAction(Intent.ACTION_TIME_CHANGED); getApplicationContext().registerReceiver(mAlarmReceiver, intentFilter, Context.RECEIVER_EXPORTED | Context.RECEIVER_VISIBLE_TO_INSTANT_APPS); // IntentFilter intentFilter2 = new IntentFilter(ACTION_MSG_BROADCAST); @@ -622,7 +619,12 @@ public class MicroPhotoService extends Service { } catch (Exception ex) { ex.printStackTrace(); } - MicroPhotoService.restartApp(context.getApplicationContext(), MicroPhotoContext.PACKAGE_NAME_MPAPP, "Restart Cmd"); + restartSelfImpl(context, reason); + } else if (TextUtils.equals(Intent.ACTION_TIME_CHANGED, action)) { + mService.notifyTimeUpdated(mService.mNativeHandle); + Date date = new Date(); + long startTime = (date.getTime() + 999) / 1000; + mService.updateCaptureSchedule(startTime); } } } @@ -1496,6 +1498,8 @@ cellSignalStrengthGsm.getDbm(); // protected native long[] getNextScheduleItem(long handler); protected native boolean notifyToTakePhoto(long handler, int channel, int preset, long scheduleTime, boolean photoOrVideo); + protected native void notifyTimeUpdated(long handler); + protected native boolean sendHeartbeat(long handler, int signalLevel); protected native boolean reloadConfigs(long handler); protected native void updatePosition(long handler, double lon, double lat, double radius, long ts);