Skip to content

Commit 86568d7

Browse files
Brad LarsonJean-Baptiste Queru
authored andcommitted
Use isLocationProviderEnabled to test for enabled providers
LocationManagerService was just checking if the string of (comma-separated) Location Providers contained the provider we were interested in. This works fine in normal cases, but breaks if we add a provider such as test_network. Enabling test_network causes LocationManagerService to think that the network provider is also enabled. The code in Settings.Secure.isLocationProviderEnabled() checks for the commas in the string as well, to make sure that a provider name which is a substring of another provider name won't cause problems. It also centralizes the code which reads the string. Signed-off-by: Brad Larson <brad.larson@garmin.com> Change-Id: I00dfe7c2b09739ed4c8ed07c6167e409b0bf7d13
1 parent af7c978 commit 86568d7

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

services/java/com/android/server/LocationManagerService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,8 @@ private boolean isAllowedBySettingsLocked(String provider) {
552552
}
553553
// Use system settings
554554
ContentResolver resolver = mContext.getContentResolver();
555-
String allowedProviders = Settings.Secure.getString(resolver,
556-
Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
557555

558-
return ((allowedProviders != null) && (allowedProviders.contains(provider)));
556+
return Settings.Secure.isLocationProviderEnabled(resolver, provider);
559557
}
560558

561559
private void checkPermissionsSafe(String provider) {

0 commit comments

Comments
 (0)