|
|
|
@ -137,6 +137,7 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
|
|
|
|
|
private long mGpsTimeout = 60000; // 1 minute
|
|
|
|
|
private PendingIntent mPreviousGpsTimer = null;
|
|
|
|
|
private long mLastLocationRequested = 0;
|
|
|
|
|
|
|
|
|
|
private ServiceHandler mHander = null;
|
|
|
|
|
private Messenger mMessenger = null;
|
|
|
|
@ -318,6 +319,9 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
mService.registerHeartbeatTimer(mService.mHeartbeatDuration);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
mService.detectGpsStatus();
|
|
|
|
|
|
|
|
|
|
ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
|
|
|
|
if (connectivityManager != null) {
|
|
|
|
|
if (!connectivityManager.isDefaultNetworkActive()) {
|
|
|
|
@ -1072,6 +1076,8 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
// Set Listener
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
enableGps(true);
|
|
|
|
|
mLastLocationRequested = System.currentTimeMillis();
|
|
|
|
|
mLocationManager.requestLocationUpdates(mLocateType, 30000, 1, mLocationListener, Looper.getMainLooper());
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
@ -1090,6 +1096,13 @@ public class MicroPhotoService extends Service {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void detectGpsStatus() {
|
|
|
|
|
if (System.currentTimeMillis() - mLastLocationRequested > 10 * 60000) {
|
|
|
|
|
// 10minutes close it
|
|
|
|
|
enableGps(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void downloadAndInstall(final String url) {
|
|
|
|
|
|
|
|
|
|
final Context context = getApplicationContext();
|
|
|
|
|