Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70c9a07469 | ||
|
|
32d97e9c78 | ||
|
|
9ac137b9f7 | ||
|
|
204c1b3e7a | ||
|
|
4a13f36971 | ||
|
|
e1022fb785 | ||
|
|
35785b719c |
@@ -27,7 +27,7 @@ android {
|
||||
applicationId "com.maptology.android.app"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 28
|
||||
versionCode 6
|
||||
versionCode 8
|
||||
versionName "${version}"
|
||||
buildConfigField "long", "BUILD_TIME", System.currentTimeMillis() + "L"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -66,7 +66,7 @@ public class LocationService extends Service {
|
||||
/**
|
||||
* The minimum time between two localization attempts.
|
||||
*/
|
||||
private static final long LOCALIZATION_TIMEOUT = 60000;
|
||||
private static final long LOCALIZATION_TIMEOUT = 55000;
|
||||
|
||||
/**
|
||||
* The time to wait for wifi scans.
|
||||
@@ -196,6 +196,17 @@ public class LocationService extends Service {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A broadcast receiver to receive timer ticks in the background.
|
||||
*/
|
||||
private BroadcastReceiver timeTickReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.d(TAG, "Tick received.");
|
||||
onStartCommand(null, 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A location listener that simply forwards its locations to
|
||||
* the service.
|
||||
@@ -282,6 +293,7 @@ public class LocationService extends Service {
|
||||
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, WAKELOCK_TAG);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1)
|
||||
registerReceiver(idleModeReceiver, new IntentFilter(PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED));
|
||||
registerReceiver(timeTickReceiver, new IntentFilter(Intent.ACTION_TIME_TICK));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -303,6 +315,7 @@ public class LocationService extends Service {
|
||||
app.getRepository().uploadingLocations.removeValueListener(uploadListener);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1)
|
||||
unregisterReceiver(idleModeReceiver);
|
||||
unregisterReceiver(timeTickReceiver);
|
||||
Log.d(TAG, "Releasing wake lock.");
|
||||
if (wakeLock.isHeld()) wakeLock.release();
|
||||
stopForeground(true);
|
||||
@@ -614,7 +627,7 @@ public class LocationService extends Service {
|
||||
// otherwise create idle update
|
||||
ReleasedLocation update = createLocation();
|
||||
update.setAvailability(ReleasedLocation.AvailabilityEnum.IDLE);
|
||||
update.setTimestamp(localizationTime);
|
||||
update.setTimestamp(System.currentTimeMillis());
|
||||
update.setAccuracy(previous.getAccuracy());
|
||||
update.setCoordinate(previous.getCoordinate());
|
||||
update.setProvider(previous.getProvider());
|
||||
@@ -942,17 +955,17 @@ public class LocationService extends Service {
|
||||
* @param context The context used to schedule this.
|
||||
*/
|
||||
private static void scheduleExecution(Context context, long lastTime) {
|
||||
PendingIntent pending = createIntent(context);
|
||||
AlarmManager manager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
|
||||
long now = SystemClock.elapsedRealtime();
|
||||
long next = Math.max(0, (lastTime + LOCALIZATION_TIMEOUT) - now);
|
||||
long next = Math.max(5000, (lastTime + LOCALIZATION_TIMEOUT) - now);
|
||||
Log.d(TAG, "Updating alarm to execute in " + next + " ms.");
|
||||
// this is too imprecise on Android 9
|
||||
//manager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + next, LOCALIZATION_TIMEOUT, pending);
|
||||
PendingIntent pending = createIntent(context);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
manager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + next, pending);
|
||||
} else {
|
||||
manager.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + next, 10000, pending);
|
||||
manager.setWindow(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + next, LOCALIZATION_TIMEOUT / 2, pending);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -262,8 +262,8 @@ public class MainActivity extends AppCompatActivity implements
|
||||
* Method to request location permission for the app.
|
||||
*/
|
||||
private void checkPermissions() {
|
||||
boolean permissionGranted = PermissionChecker.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED &&
|
||||
PermissionChecker.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
|
||||
boolean permissionGranted = PermissionChecker.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) == PermissionChecker.PERMISSION_GRANTED &&
|
||||
PermissionChecker.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) == PermissionChecker.PERMISSION_GRANTED;
|
||||
if (!permissionGranted) {
|
||||
Log.d(TAG, "Requesting permissions.");
|
||||
ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION}, CODE_REQUEST_PERMISSIONS);
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.4.2'
|
||||
classpath 'com.android.tools.build:gradle:3.5.0'
|
||||
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.8.1'
|
||||
classpath 'com.google.android.gms:oss-licenses-plugin:0.9.5'
|
||||
classpath files('gradle/gradle-android-eclipse-1.1.jar')
|
||||
@@ -25,7 +25,7 @@ buildscript {
|
||||
allprojects {
|
||||
// set version for our project
|
||||
group = 'com.maptology'
|
||||
version = '1.0.2'
|
||||
version = '1.0.3'
|
||||
|
||||
// set versions for our libraries
|
||||
ext {
|
||||
|
||||
@@ -71,11 +71,12 @@ public class GeocoderBuilder {
|
||||
*
|
||||
* @return The geo coder service.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public IGeocoderService build() {
|
||||
ResteasyClientBuilder builder = new ResteasyClientBuilder();
|
||||
builder.httpEngine(new URLConnectionEngine());
|
||||
if (socketTimeout != null) builder.readTimeout(socketTimeout, TimeUnit.SECONDS);
|
||||
if (connectionTimeout != null) builder.connectTimeout(connectionTimeout, TimeUnit.SECONDS);
|
||||
if (socketTimeout != null) builder.socketTimeout(socketTimeout,TimeUnit.SECONDS);
|
||||
if (connectionTimeout != null) builder.establishConnectionTimeout(connectionTimeout, TimeUnit.SECONDS);
|
||||
ResteasyClient client = builder.build();
|
||||
return client.target(GEOCODER_URL).proxy(IGeocoderService.class);
|
||||
}
|
||||
|
||||
Generated
Reference in New Issue
Block a user