am 1db0cce0: Merge "Fix a race where NLP consent dialog can be shown unnecessarily" into lmp-mr1-dev
* commit '1db0cce028c22fe04b129c8d1f627ac30da84558': Fix a race where NLP consent dialog can be shown unnecessarily
This commit is contained in:
@@ -5013,10 +5013,19 @@ public final class Settings {
|
|||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Invalid location mode: " + mode);
|
throw new IllegalArgumentException("Invalid location mode: " + mode);
|
||||||
}
|
}
|
||||||
boolean gpsSuccess = Settings.Secure.setLocationProviderEnabledForUser(
|
// Note it's important that we set the NLP mode first. The Google implementation
|
||||||
cr, LocationManager.GPS_PROVIDER, gps, userId);
|
// 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(
|
boolean nlpSuccess = Settings.Secure.setLocationProviderEnabledForUser(
|
||||||
cr, LocationManager.NETWORK_PROVIDER, network, userId);
|
cr, LocationManager.NETWORK_PROVIDER, network, userId);
|
||||||
|
boolean gpsSuccess = Settings.Secure.setLocationProviderEnabledForUser(
|
||||||
|
cr, LocationManager.GPS_PROVIDER, gps, userId);
|
||||||
return gpsSuccess && nlpSuccess;
|
return gpsSuccess && nlpSuccess;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user