|
|
@ -38,6 +38,7 @@ import android.os.SystemClock;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.core.app.NotificationCompat;
|
|
|
|
import androidx.core.app.NotificationCompat;
|
|
|
|
import androidx.core.content.FileProvider;
|
|
|
|
import androidx.core.content.FileProvider;
|
|
|
|
|
|
|
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|
|
|
|
|
|
|
|
|
|
|
import android.telephony.SignalStrength;
|
|
|
|
import android.telephony.SignalStrength;
|
|
|
|
import android.telephony.SubscriptionManager;
|
|
|
|
import android.telephony.SubscriptionManager;
|
|
|
@ -113,11 +114,10 @@ public class MicroPhotoService extends Service {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private static int mStateService = STATE_SERVICE.NOT_CONNECTED;
|
|
|
|
private static int mStateService = STATE_SERVICE.NOT_CONNECTED;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String mCmdid = "";
|
|
|
|
private String mCmdid = "";
|
|
|
|
private NotificationManager mNotificationManager;
|
|
|
|
private NotificationManager mNotificationManager;
|
|
|
|
private final Map<String, PowerManager.WakeLock> mWakeLocks = new HashMap<>();
|
|
|
|
private final Map<String, PowerManager.WakeLock> mWakeLocks = new HashMap<>();
|
|
|
|
private int mHeartbeatDuration = 60000; // Default 10m: 10 * 60 * 1000
|
|
|
|
private int mHeartbeatDuration = 0; // Default 1m: 10 * 60 * 1000 from NDK
|
|
|
|
private long mNextHeartbeatTime = 0;
|
|
|
|
private long mNextHeartbeatTime = 0;
|
|
|
|
|
|
|
|
|
|
|
|
private PositionManager mPositionManager = null;
|
|
|
|
private PositionManager mPositionManager = null;
|
|
|
@ -163,7 +163,7 @@ public class MicroPhotoService extends Service {
|
|
|
|
intentFilter.addAction(ACTION_HEARTBEAT_MANUALLY);
|
|
|
|
intentFilter.addAction(ACTION_HEARTBEAT_MANUALLY);
|
|
|
|
intentFilter.addAction(ACTION_MSG_BROADCAST);
|
|
|
|
intentFilter.addAction(ACTION_MSG_BROADCAST);
|
|
|
|
intentFilter.addAction(ACTION_VIDEO_FINISHED);
|
|
|
|
intentFilter.addAction(ACTION_VIDEO_FINISHED);
|
|
|
|
registerReceiver(mAlarmReceiver, intentFilter);
|
|
|
|
getApplicationContext().registerReceiver(mAlarmReceiver, intentFilter);
|
|
|
|
|
|
|
|
|
|
|
|
// IntentFilter intentFilter2 = new IntentFilter(ACTION_MSG_BROADCAST);
|
|
|
|
// IntentFilter intentFilter2 = new IntentFilter(ACTION_MSG_BROADCAST);
|
|
|
|
// registerReceiver(mAlarmReceiver, intentFilter2);
|
|
|
|
// registerReceiver(mAlarmReceiver, intentFilter2);
|
|
|
@ -211,7 +211,7 @@ public class MicroPhotoService extends Service {
|
|
|
|
uninit(mNativeHandle);
|
|
|
|
uninit(mNativeHandle);
|
|
|
|
mNativeHandle = 0;
|
|
|
|
mNativeHandle = 0;
|
|
|
|
|
|
|
|
|
|
|
|
unregisterReceiver(mAlarmReceiver);
|
|
|
|
getApplicationContext().unregisterReceiver(mAlarmReceiver);
|
|
|
|
unregisterReceiver(mScreenaAtionReceiver);
|
|
|
|
unregisterReceiver(mScreenaAtionReceiver);
|
|
|
|
unregisterReceiver(mNetworkChangedReceiver);
|
|
|
|
unregisterReceiver(mNetworkChangedReceiver);
|
|
|
|
|
|
|
|
|
|
|
@ -300,7 +300,7 @@ public class MicroPhotoService extends Service {
|
|
|
|
long baseTime = nowTs - startTime;
|
|
|
|
long baseTime = nowTs - startTime;
|
|
|
|
|
|
|
|
|
|
|
|
mService.registerCaptureSchedule(startTime, baseTime);
|
|
|
|
mService.registerCaptureSchedule(startTime, baseTime);
|
|
|
|
}if (TextUtils.equals(ACTION_HEARTBEAT_MANUALLY, action)) {
|
|
|
|
} else if (TextUtils.equals(ACTION_HEARTBEAT_MANUALLY, action)) {
|
|
|
|
Log.i(TAG, "HB Timer Fired ACTION=" + action);
|
|
|
|
Log.i(TAG, "HB Timer Fired ACTION=" + action);
|
|
|
|
mService.sendHeartbeat(mService.mNativeHandle);
|
|
|
|
mService.sendHeartbeat(mService.mNativeHandle);
|
|
|
|
} else if (TextUtils.equals(ACTION_TAKE_PHOTO_MANUALLY, action)) {
|
|
|
|
} else if (TextUtils.equals(ACTION_TAKE_PHOTO_MANUALLY, action)) {
|
|
|
@ -570,11 +570,19 @@ public class MicroPhotoService extends Service {
|
|
|
|
public static void sendHeartbeat(Context context) {
|
|
|
|
public static void sendHeartbeat(Context context) {
|
|
|
|
|
|
|
|
|
|
|
|
Intent alarmIntent = new Intent();
|
|
|
|
Intent alarmIntent = new Intent();
|
|
|
|
|
|
|
|
// if(Build.VERSION.SDK_INT >= 26) {
|
|
|
|
|
|
|
|
// alarmIntent.addFlags(0x01000000);
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
alarmIntent.setPackage(context.getPackageName());
|
|
|
|
alarmIntent.setAction(ACTION_HEARTBEAT_MANUALLY);
|
|
|
|
alarmIntent.setAction(ACTION_HEARTBEAT_MANUALLY);
|
|
|
|
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, 0);
|
|
|
|
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, alarmIntent, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// context.sendBroadcast(alarmIntent);
|
|
|
|
|
|
|
|
// LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
|
|
|
|
|
|
|
|
// localBroadcastManager.sendBroadcast(alarmIntent);
|
|
|
|
|
|
|
|
|
|
|
|
AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE);
|
|
|
|
AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE);
|
|
|
|
alarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 1000, pendingIntent);
|
|
|
|
alarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 100, pendingIntent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|