优化代码

serial
Matthew 1 year ago
parent 247d2817ee
commit c4a5c365af

@ -79,17 +79,11 @@ public class MicroPhotoService extends Service {
public static final int MSG_WHAT_LOG = 10;
public final static int MSG_WHAT_NETWORK_CHANGE = 20;
public final static int MSG_WHAT_SERVICE_STATUS_CHANGE = 30;
public final static int MSG_WHAT_SENDING_HB = 40;
public final static int MSG_WHAT_MAX = 1000;
private static final String ALARM_EVENT = "com.xinyingpower.mp.MicroPhotoService.AlarmReceiver";
public static final int NOTIFICATION_ID_FOREGROUND_SERVICE = 8466503;
// public static final int NOTIFICATION_ID_FOREGROUND_SERVICE = 0;
public static final String ACTION_MSG_BROADCAST = "ACT_MSG_BROADCAST";
public static final String ACTION_START = "com.xypower.mpapp.ACT_START";
@ -97,6 +91,7 @@ public class MicroPhotoService extends Service {
public static final String ACTION_MAIN = "com.xypower.mpapp.ACT_MAIN";
private static final String ACTION_HEARTBEAT = MicroPhotoContext.ACTION_HEARTBEAT_MP;
private static final String ACTION_TAKE_PHOTO = "com.xypower.mpapp.ACT_TP";
private static final String ACTION_GPS_TIMEOUT = "com.xypower.mpapp.GPS_TIMEOUT";
private static final String ACTION_IMP_PUBKRY = "com.xypower.mpapp.ACT_IMP_PUBKEY";
@ -111,12 +106,10 @@ public class MicroPhotoService extends Service {
private static final String EXTRA_PARAM_SCHEDULE = "Schedule_";
private static final String EXTRA_PARAM_TAKING_TIME = "TakingTime";
private static final String EXTRA_PARAM_TIME = "Time";
// private static String EXTRA_PARAM_FILENAME = "FileName";
private static final String EXTRA_PARAM_TIMER_UID = "TimerUid";
// private static String EXTRA_PARAM_TIMER_TYPE = "TimerType";
private static final String EXTRA_PARAM_TIMEOUT = "Timeout";
private static final String EXTRA_PARAM_TIMES = "Times";
private static final String EXTRA_PARAM_ELASPED_TIMES = "ElapsedTimes";
// private static final String EXTRA_PARAM_TIMER_UID = "TimerUid";
// private static final String EXTRA_PARAM_TIMEOUT = "Timeout";
// private static final String EXTRA_PARAM_TIMES = "Times";
// private static final String EXTRA_PARAM_ELASPED_TIMES = "ElapsedTimes";
private static final String FOREGROUND_CHANNEL_ID = "foreground_channel_id";
public static class STATE_SERVICE {
public static final int CONNECTED = 10;
@ -128,10 +121,9 @@ public class MicroPhotoService extends Service {
private NotificationManager mNotificationManager;
private final Map<String, PowerManager.WakeLock> mWakeLocks = new HashMap<>();
private int mHeartbeatDuration = 0; // MUST BE 0!!!
private long mNextHeartbeatTime = 0;
// private long mNextHeartbeatTime = 0;
private PositionManager mPositionManager = null;
private final Map<Long, PendingIntent> mTimers = new HashMap<>();
// private final Map<Long, PendingIntent> mTimers = new HashMap<>();
protected long mNativeHandle = 0;
private AlarmReceiver mAlarmReceiver = null;
@ -139,6 +131,8 @@ public class MicroPhotoService extends Service {
private ScreenActionReceiver mScreenaAtionReceiver = null;
private NetworkChangedReceiver mNetworkChangedReceiver = null;
private PendingIntent mPreviousGpsTimer = null;
private ServiceHandler mHander = null;
private Messenger mMessenger = null;
@ -182,6 +176,7 @@ public class MicroPhotoService extends Service {
intentFilter.addAction(ACTION_UPDATE_CONFIGS);
intentFilter.addAction(ACTION_IMP_PUBKRY);
intentFilter.addAction(ACTION_TAKE_PHOTO_MANUALLY);
intentFilter.addAction(ACTION_GPS_TIMEOUT);
// intentFilter.addAction(ACTION_HEARTBEAT_MANUALLY);
// intentFilter.addAction(ACTION_MSG_BROADCAST);
// intentFilter.addAction(ACTION_VIDEO_FINISHED);
@ -376,6 +371,10 @@ public class MicroPhotoService extends Service {
} else if (TextUtils.equals(ACTION_IMP_PUBKRY, action)) {
String path = intent.getStringExtra("path");
String md5 = intent.getStringExtra("md5");
} else if (TextUtils.equals(ACTION_GPS_TIMEOUT, action)) {
mService.mPreviousGpsTimer = null;
mService.mLocationManager.removeUpdates(mService.mLocationListener);
mService.enableGps(false);
}
}
}
@ -414,7 +413,7 @@ public class MicroPhotoService extends Service {
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + mHeartbeatDuration, pendingIntent);
mNextHeartbeatTime = System.currentTimeMillis() + mHeartbeatDuration;
// mNextHeartbeatTime = System.currentTimeMillis() + mHeartbeatDuration;
// alarmManager.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + timeout, pendingIntent);
}
@ -1111,6 +1110,7 @@ cellSignalStrengthGsm.getDbm();
@Override
public void onLocationChanged(Location location) {
if (mNativeHandle != 0) {
updatePosition(mNativeHandle, location.getLongitude(), location.getLatitude(), location.getAccuracy(), location.getTime() / 1000);

Loading…
Cancel
Save