diff options
Diffstat (limited to 'services/java')
| -rw-r--r-- | services/java/com/android/server/LocationManagerService.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java index c26448f..197f6ab 100644 --- a/services/java/com/android/server/LocationManagerService.java +++ b/services/java/com/android/server/LocationManagerService.java @@ -588,7 +588,17 @@ public class LocationManagerService extends ILocationManager.Stub implements Run } throw new SecurityException("Location requires either ACCESS_COARSE_LOCATION or" + - "ACCESS_FINE_LOCATION permission"); + " ACCESS_FINE_LOCATION permission"); + } + + /** + * Throw SecurityException if caller lacks permission to use Geofences. + */ + private void checkGeofencePermission() { + if (mContext.checkCallingOrSelfPermission(ACCESS_FINE_LOCATION) != + PackageManager.PERMISSION_GRANTED) { + throw new SecurityException("Geofence usage requires ACCESS_FINE_LOCATION permission"); + } } /** @@ -1096,6 +1106,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run public void requestGeofence(LocationRequest request, Geofence geofence, PendingIntent intent, String packageName) { if (request == null) request = DEFAULT_LOCATION_REQUEST; + checkGeofencePermission(); checkPermissionAndRequest(request); checkPendingIntent(intent); checkPackageName(packageName); @@ -1114,7 +1125,7 @@ public class LocationManagerService extends ILocationManager.Stub implements Run @Override public void removeGeofence(Geofence geofence, PendingIntent intent, String packageName) { - checkPermission(); + checkGeofencePermission(); checkPendingIntent(intent); checkPackageName(packageName); |
