From 4fab68b5324e1f9b6765cdc33e66d1f074623dc2 Mon Sep 17 00:00:00 2001 From: Victoria Lease Date: Thu, 13 Sep 2012 13:20:59 -0700 Subject: Require ACCESS_FINE_LOCATION for Geofence use. Bug: 7153226 Change-Id: I49236379e739fcda66bbc9a31cfdca9a87122aec --- .../java/com/android/server/LocationManagerService.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'services/java/com/android/server/LocationManagerService.java') 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); -- cgit v1.1