From 16ea810a84163ad2ece46c76050fb1601f6a6258 Mon Sep 17 00:00:00 2001 From: mar-v-in Date: Mon, 26 Jan 2015 03:27:36 +0100 Subject: [PATCH] Disable multi-process (causes preferences mismatch), close backends if provider is disabled --- .gitignore | 11 ++++++++--- AndroidManifest.xml | 3 --- UnifiedNlpApi | 2 +- src/org/microg/nlp/location/BackendFuser.java | 6 ++++-- .../microg/nlp/location/LocationProviderV1.java | 3 +++ .../microg/nlp/location/LocationProviderV2.java | 14 +++++--------- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index df0fcc8..f9c9bfe 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,10 @@ *.iml -gen -bin -build +gen/ +bin/ +build/ user.gradle +.gradle/ +gradle/ +gradlew +local.properties +.idea/ diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 78746d0..f93a553 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -46,7 +46,6 @@ @@ -64,7 +63,6 @@ @@ -82,7 +80,6 @@ diff --git a/UnifiedNlpApi b/UnifiedNlpApi index 2f713c5..54d4988 160000 --- a/UnifiedNlpApi +++ b/UnifiedNlpApi @@ -1 +1 @@ -Subproject commit 2f713c50a824d7e5e2e01f815c85d67f1c4d077d +Subproject commit 54d49883059adb100a8a3d901d4fbeaf4a0f5353 diff --git a/src/org/microg/nlp/location/BackendFuser.java b/src/org/microg/nlp/location/BackendFuser.java index dbd326b..679e299 100644 --- a/src/org/microg/nlp/location/BackendFuser.java +++ b/src/org/microg/nlp/location/BackendFuser.java @@ -30,7 +30,9 @@ import java.util.Collections; import java.util.Comparator; 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 { private static final String TAG = "NlpLocationBackendFuser"; @@ -150,7 +152,7 @@ class BackendFuser { public static class LocationComparator implements Comparator { 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} diff --git a/src/org/microg/nlp/location/LocationProviderV1.java b/src/org/microg/nlp/location/LocationProviderV1.java index 2e3dcb3..9c53162 100644 --- a/src/org/microg/nlp/location/LocationProviderV1.java +++ b/src/org/microg/nlp/location/LocationProviderV1.java @@ -40,6 +40,8 @@ public class LocationProviderV1 extends com.android.location.provider.LocationPr @Override public void onDisable() { + Log.d(TAG, "onDisable"); + helper.disable(); } @Override @@ -54,6 +56,7 @@ public class LocationProviderV1 extends com.android.location.provider.LocationPr @Override public void onEnable() { + Log.d(TAG, "onEnable"); } @Override diff --git a/src/org/microg/nlp/location/LocationProviderV2.java b/src/org/microg/nlp/location/LocationProviderV2.java index 05769ea..617bb0a 100644 --- a/src/org/microg/nlp/location/LocationProviderV2.java +++ b/src/org/microg/nlp/location/LocationProviderV2.java @@ -50,6 +50,8 @@ class LocationProviderV2 extends LocationProviderBase implements LocationProvide @Override public void onDisable() { + Log.d(TAG, "onDisable"); + helper.disable(); } @Override @@ -69,6 +71,7 @@ class LocationProviderV2 extends LocationProviderBase implements LocationProvide @Override public void onEnable() { + Log.d(TAG, "onEnable"); } @Override @@ -85,15 +88,8 @@ class LocationProviderV2 extends LocationProviderBase implements LocationProvide public void onSetRequest(ProviderRequestUnbundled requests, WorkSource source) { Log.v(TAG, "onSetRequest: " + requests + " by " + source); - long autoTime = Long.MAX_VALUE; - boolean autoUpdate = false; - for (LocationRequestUnbundled request : requests.getLocationRequests()) { - Log.v(TAG, "onSetRequest: request: " + request); - if (autoTime > request.getInterval()) { - autoTime = request.getInterval(); - } - autoUpdate = true; - } + long autoTime = requests.getInterval(); + boolean autoUpdate = requests.getReportLocation(); if (autoTime < 1500) { // Limit to 1.5s