Skip to content

Commit f429921

Browse files
author
Victoria Lease
committed
throw SecurityException in isProviderEnabled()
In MR0, we did not allow applications to query enabled status of location providers they did not have permission to use. Some applications counted on this behavior, using the thrown SecurityException to determine whether or not they have permission to use the specified provider. Reverting to this behavior fixes the regressions seen in those applications. Bug: 7251459 Change-Id: I8b0cfd5862c80f0c831a4ab544c3fa7408bc84a0
1 parent 0f9deb3 commit f429921

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,8 +1293,13 @@ public ProviderProperties getProviderProperties(String provider) {
12931293

12941294
@Override
12951295
public boolean isProviderEnabled(String provider) {
1296-
checkPermission();
1296+
String perms = checkPermission();
12971297
if (LocationManager.FUSED_PROVIDER.equals(provider)) return false;
1298+
if (ACCESS_COARSE_LOCATION.equals(perms) &&
1299+
!isProviderAllowedByCoarsePermission(provider)) {
1300+
throw new SecurityException("The \"" + provider +
1301+
"\" provider requires ACCESS_FINE_LOCATION permission");
1302+
}
12981303

12991304
synchronized (mLock) {
13001305
LocationProviderInterface p = mProvidersByName.get(provider);

0 commit comments

Comments
 (0)