|
|
|
@ -91,6 +91,7 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
private static final String ACTION_HEARTBEAT = "ACT_HB";
|
|
|
|
|
private static final String ACTION_TAKE_PHOTO = "ACT_TP";
|
|
|
|
|
private static final String ACTION_TAKE_PHOTO_MANUALLY = "ACT_TP_M";
|
|
|
|
|
private static final String ACTION_HEARTBEAT_MANUALLY = "ACT_HB_M";
|
|
|
|
|
private static final String ACTION_TIMEOUT = "ACT_TIMEOUT";
|
|
|
|
|
private static final String EXTRA_PARAM_CHANNEL = "Channel";
|
|
|
|
|
private static final String EXTRA_PARAM_PRESET = "Preset";
|
|
|
|
@ -158,6 +159,7 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
intentFilter.addAction(ACTION_TAKE_PHOTO);
|
|
|
|
|
intentFilter.addAction(ACTION_TIMEOUT);
|
|
|
|
|
intentFilter.addAction(ACTION_TAKE_PHOTO_MANUALLY);
|
|
|
|
|
intentFilter.addAction(ACTION_HEARTBEAT_MANUALLY);
|
|
|
|
|
intentFilter.addAction(ACTION_MSG_BROADCAST);
|
|
|
|
|
registerReceiver(mAlarmReceiver, intentFilter);
|
|
|
|
|
|
|
|
|
@ -295,6 +297,9 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
long baseTime = nowTs - startTime;
|
|
|
|
|
|
|
|
|
|
mService.registerCaptureSchedule(startTime, baseTime);
|
|
|
|
|
}if (TextUtils.equals(ACTION_HEARTBEAT_MANUALLY, action)) {
|
|
|
|
|
Log.i(TAG, "HB Timer Fired ACTION=" + action);
|
|
|
|
|
mService.sendHeartbeat(mService.mNativeHandle);
|
|
|
|
|
} else if (TextUtils.equals(ACTION_TAKE_PHOTO_MANUALLY, action)) {
|
|
|
|
|
int channel = intent.getIntExtra(EXTRA_PARAM_CHANNEL, 0);
|
|
|
|
|
int preset = intent.getIntExtra(EXTRA_PARAM_PRESET, 0);
|
|
|
|
@ -536,6 +541,16 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
registerPhotoTimer(context, channel, preset, 0, 0, schedules);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void sendHeartbeat(Context context) {
|
|
|
|
|
|
|
|
|
|
Intent alarmIntent = new Intent();
|
|
|
|
|
alarmIntent.setAction(ACTION_HEARTBEAT_MANUALLY);
|
|
|
|
|
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, 0);
|
|
|
|
|
|
|
|
|
|
AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE);
|
|
|
|
|
alarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), pendingIntent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
|
|
|
|
|
|
|
|
|