summaryrefslogtreecommitdiffstats
path: root/core/java/android/provider
diff options
context:
space:
mode:
authorTom O'Neill <tomo@google.com>2014-10-09 11:30:49 -0700
committerTom O'Neill <tomo@google.com>2014-10-09 11:30:49 -0700
commit7731a99807728298cd4bbfdc8b577183199bc47e (patch)
treef36862c012d7a907eb78be36454a4b5753e4ed16 /core/java/android/provider
parentc1f4c0fefebfb296846e88324c1bb7dee6b5c876 (diff)
downloadframeworks_base-7731a99807728298cd4bbfdc8b577183199bc47e.zip
frameworks_base-7731a99807728298cd4bbfdc8b577183199bc47e.tar.gz
frameworks_base-7731a99807728298cd4bbfdc8b577183199bc47e.tar.bz2
Fix a race where NLP consent dialog can be shown unnecessarily
- Bug: 17908111 Change-Id: If94570861f38b922478d490599ab02cfb86adea6
Diffstat (limited to 'core/java/android/provider')
-rw-r--r--core/java/android/provider/Settings.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index e40c88f..821e0a8 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -5013,10 +5013,19 @@ public final class Settings {
default:
throw new IllegalArgumentException("Invalid location mode: " + mode);
}
- boolean gpsSuccess = Settings.Secure.setLocationProviderEnabledForUser(
- cr, LocationManager.GPS_PROVIDER, gps, userId);
+ // Note it's important that we set the NLP mode first. The Google implementation
+ // of NLP clears its NLP consent setting any time it receives a
+ // LocationManager.PROVIDERS_CHANGED_ACTION broadcast and NLP is disabled. Also,
+ // it shows an NLP consent dialog any time it receives the broadcast, NLP is
+ // enabled, and the NLP consent is not set. If 1) we were to enable GPS first,
+ // 2) a setup wizard has its own NLP consent UI that sets the NLP consent setting,
+ // and 3) the receiver happened to complete before we enabled NLP, then the Google
+ // NLP would detect the attempt to enable NLP and show a redundant NLP consent
+ // dialog. Then the people who wrote the setup wizard would be sad.
boolean nlpSuccess = Settings.Secure.setLocationProviderEnabledForUser(
cr, LocationManager.NETWORK_PROVIDER, network, userId);
+ boolean gpsSuccess = Settings.Secure.setLocationProviderEnabledForUser(
+ cr, LocationManager.GPS_PROVIDER, gps, userId);
return gpsSuccess && nlpSuccess;
}
}