Disable multi-process (causes preferences mismatch), close backends if provider is disabled

This commit is contained in:
mar-v-in 2015-01-26 03:27:36 +01:00
parent e4485d14b1
commit 16ea810a84
6 changed files with 21 additions and 18 deletions

11
.gitignore vendored
View file

@ -1,5 +1,10 @@
*.iml *.iml
gen gen/
bin bin/
build build/
user.gradle user.gradle
.gradle/
gradle/
gradlew
local.properties
.idea/

View file

@ -46,7 +46,6 @@
<service <service
android:name="org.microg.nlp.location.LocationServiceV1" android:name="org.microg.nlp.location.LocationServiceV1"
android:permission="android.permission.ACCESS_COARSE_LOCATION" android:permission="android.permission.ACCESS_COARSE_LOCATION"
android:process=":nlp_loc_service"
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>
<action android:name="com.google.android.location.NetworkLocationProvider" /> <action android:name="com.google.android.location.NetworkLocationProvider" />
@ -64,7 +63,6 @@
<service <service
android:name="org.microg.nlp.location.LocationServiceV2" android:name="org.microg.nlp.location.LocationServiceV2"
android:permission="android.permission.ACCESS_COARSE_LOCATION" android:permission="android.permission.ACCESS_COARSE_LOCATION"
android:process=":nlp_loc_service"
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>
<!-- KitKat changed the action name but nothing else, hence we handle it the same --> <!-- KitKat changed the action name but nothing else, hence we handle it the same -->
@ -82,7 +80,6 @@
<service <service
android:name="org.microg.nlp.geocode.GeocodeServiceV1" android:name="org.microg.nlp.geocode.GeocodeServiceV1"
android:process=":nlp_geo_service"
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>
<!-- Jelly Bean changed the action name but nothing else, hence we handle it the same --> <!-- Jelly Bean changed the action name but nothing else, hence we handle it the same -->

@ -1 +1 @@
Subproject commit 2f713c50a824d7e5e2e01f815c85d67f1c4d077d Subproject commit 54d49883059adb100a8a3d901d4fbeaf4a0f5353

View file

@ -30,7 +30,9 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import static org.microg.nlp.api.Constants.*; import static org.microg.nlp.api.Constants.ACTION_LOCATION_BACKEND;
import static org.microg.nlp.api.Constants.LOCATION_EXTRA_BACKEND_PROVIDER;
import static org.microg.nlp.api.Constants.LOCATION_EXTRA_OTHER_BACKENDS;
class BackendFuser { class BackendFuser {
private static final String TAG = "NlpLocationBackendFuser"; private static final String TAG = "NlpLocationBackendFuser";
@ -150,7 +152,7 @@ class BackendFuser {
public static class LocationComparator implements Comparator<Location> { public static class LocationComparator implements Comparator<Location> {
public static final LocationComparator INSTANCE = new LocationComparator(); public static final LocationComparator INSTANCE = new LocationComparator();
public static final long SWITCH_ON_FRESHNESS_CLIFF_MS = 30000; // 30 seconds TODO: make it a setting public static final long SWITCH_ON_FRESHNESS_CLIFF_MS = 30000; // 30 seconds
/** /**
* @return whether {@param lhs} is better than {@param rhs} * @return whether {@param lhs} is better than {@param rhs}

View file

@ -40,6 +40,8 @@ public class LocationProviderV1 extends com.android.location.provider.LocationPr
@Override @Override
public void onDisable() { public void onDisable() {
Log.d(TAG, "onDisable");
helper.disable();
} }
@Override @Override
@ -54,6 +56,7 @@ public class LocationProviderV1 extends com.android.location.provider.LocationPr
@Override @Override
public void onEnable() { public void onEnable() {
Log.d(TAG, "onEnable");
} }
@Override @Override

View file

@ -50,6 +50,8 @@ class LocationProviderV2 extends LocationProviderBase implements LocationProvide
@Override @Override
public void onDisable() { public void onDisable() {
Log.d(TAG, "onDisable");
helper.disable();
} }
@Override @Override
@ -69,6 +71,7 @@ class LocationProviderV2 extends LocationProviderBase implements LocationProvide
@Override @Override
public void onEnable() { public void onEnable() {
Log.d(TAG, "onEnable");
} }
@Override @Override
@ -85,15 +88,8 @@ class LocationProviderV2 extends LocationProviderBase implements LocationProvide
public void onSetRequest(ProviderRequestUnbundled requests, WorkSource source) { public void onSetRequest(ProviderRequestUnbundled requests, WorkSource source) {
Log.v(TAG, "onSetRequest: " + requests + " by " + source); Log.v(TAG, "onSetRequest: " + requests + " by " + source);
long autoTime = Long.MAX_VALUE; long autoTime = requests.getInterval();
boolean autoUpdate = false; boolean autoUpdate = requests.getReportLocation();
for (LocationRequestUnbundled request : requests.getLocationRequests()) {
Log.v(TAG, "onSetRequest: request: " + request);
if (autoTime > request.getInterval()) {
autoTime = request.getInterval();
}
autoUpdate = true;
}
if (autoTime < 1500) { if (autoTime < 1500) {
// Limit to 1.5s // Limit to 1.5s