更改配置后实时刷新

serial
BlueMatthew 1 year ago
parent f6f57d2445
commit 1492f05c39

@ -638,6 +638,20 @@ Java_com_xypower_mpapp_MicroPhotoService_recordingFinished(
}
extern "C" JNIEXPORT void JNICALL
Java_com_xypower_mpapp_MicroPhotoService_updateConfigs(
JNIEnv* env,
jobject pThis, jlong handler) {
CTerminal* pTerminal = reinterpret_cast<CTerminal *>(handler);
if (pTerminal == NULL)
{
return;
}
pTerminal->LoadAppConfigs();
}
extern "C" JNIEXPORT void JNICALL
Java_com_xypower_mpapp_MicroPhotoService_setOtgState(
JNIEnv* env,

@ -66,6 +66,7 @@ public class ChannelActivity extends AppCompatActivity {
public void onClick(View v) {
int channel = binding.channels.getSelectedItemPosition() + 1;
saveChannelParams(channel);
MicroPhotoService.updateConfigs(ChannelActivity.this.getApplicationContext());
}
});

@ -245,6 +245,7 @@ public class MainActivity extends AppCompatActivity {
public void onClick(View view) {
retrieveAndSaveAppConfig();
MicroPhotoService.updateConfigs(MainActivity.this.getApplicationContext());
}
});

@ -98,8 +98,10 @@ public class MicroPhotoService extends Service {
public static final String ACTION_MAIN = "com.xypower.mpapp.ACT_MAIN";
private static final String ACTION_HEARTBEAT = "com.xypower.mpapp.ACT_HB";
private static final String ACTION_TAKE_PHOTO = "com.xypower.mpapp.ACT_TP";
private static final String ACTION_TAKE_PHOTO_MANUALLY = "com.xypower.mpapp.ACT_TP_M";
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";
@ -191,6 +193,7 @@ public class MicroPhotoService extends Service {
intentFilter.addAction(ACTION_MSG_BROADCAST);
intentFilter.addAction(ACTION_VIDEO_FINISHED);
intentFilter.addAction(ACTION_STOP);
intentFilter.addAction(ACTION_UPDATE_CONFIGS);
LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver (mLocalMsgReceiver, intentFilter);
}
@ -394,6 +397,11 @@ public class MicroPhotoService extends Service {
if (what == MSG_WHAT_SENDING_HB) {
mService.sendHeartbeat(mService.mNativeHandle, mService.getSignalLevel());
}
} else if (TextUtils.equals(ACTION_UPDATE_CONFIGS, action)) {
Log.i(TAG, "UPD CFG Fired ACTION=" + action);
if (mService.mNativeHandle != 0) {
mService.updateConfigs(mService.mNativeHandle);
}
} else if (TextUtils.equals(ACTION_VIDEO_FINISHED, action)) {
boolean result = intent.getBooleanExtra("result", false);
String path = intent.getStringExtra("path");
@ -539,6 +547,14 @@ public class MicroPhotoService extends Service {
localBroadcastManager.sendBroadcast(intent);
}
public static void updateConfigs(Context context) {
Intent intent = new Intent();
intent.setAction(ACTION_UPDATE_CONFIGS);
// PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
localBroadcastManager.sendBroadcast(intent);
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
@ -1068,6 +1084,7 @@ cellSignalStrengthGsm.getDbm();
// protected native long[] getNextScheduleItem(long handler);
protected native boolean notifyToTakePhoto(long handler, int channel, int preset, long scheduleTime, boolean photoOrVideo);
protected native boolean sendHeartbeat(long handler, int signalLevel);
protected native boolean updateConfigs(long handler);
protected native void updatePosition(long handler, double lon, double lat, long ts);
protected native boolean uninit(long handler);
protected native void recordingFinished(long handler, boolean result, String path, long videoId);

Loading…
Cancel
Save