summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Soonil Nagarkar <sooniln@google.com> 2019-02-27 13:00:56 -0800
committer Soonil Nagarkar <sooniln@google.com> 2019-02-27 13:00:56 -0800
commit8c4655e09141902618c1e649afa2f2e004a4eedf (patch)
treebe0c7b063789c312aa0c9610bb694a4344dde91e
parent6cde03853b57500926acc9aaa03376d324138f44 (diff)
Fix deadlock in GeofenceManager
GeofenceManager has threading bugs, but it's much easier to relax the guarantees in LMS than to actually fix GeofenceManager. Bug: 124648800 Test: manually Change-Id: I429b7c60d545c7f9503178c9a5be0d0bcd2f33b0
-rw-r--r--services/core/java/com/android/server/LocationManagerService.java50
1 files changed, 25 insertions, 25 deletions
diff --git a/services/core/java/com/android/server/LocationManagerService.java b/services/core/java/com/android/server/LocationManagerService.java
index d8b96e43114a..4b8ba1056c85 100644
--- a/services/core/java/com/android/server/LocationManagerService.java
+++ b/services/core/java/com/android/server/LocationManagerService.java
@@ -2643,33 +2643,33 @@ public class LocationManagerService extends ILocationManager.Stub {
synchronized (mLock) {
checkResolutionLevelIsSufficientForProviderUseLocked(allowedResolutionLevel,
request.getProvider());
- // Require that caller can manage given document
- boolean callerHasLocationHardwarePermission =
- mContext.checkCallingPermission(android.Manifest.permission.LOCATION_HARDWARE)
- == PERMISSION_GRANTED;
- LocationRequest sanitizedRequest = createSanitizedRequest(request,
- allowedResolutionLevel,
- callerHasLocationHardwarePermission);
+ }
+ // Require that caller can manage given document
+ boolean callerHasLocationHardwarePermission =
+ mContext.checkCallingPermission(android.Manifest.permission.LOCATION_HARDWARE)
+ == PERMISSION_GRANTED;
+ LocationRequest sanitizedRequest = createSanitizedRequest(request,
+ allowedResolutionLevel,
+ callerHasLocationHardwarePermission);
- if (D) {
- Log.d(TAG, "requestGeofence: " + sanitizedRequest + " " + geofence + " " + intent);
- }
+ if (D) {
+ Log.d(TAG, "requestGeofence: " + sanitizedRequest + " " + geofence + " " + intent);
+ }
- // geo-fence manager uses the public location API, need to clear identity
- int uid = Binder.getCallingUid();
- if (UserHandle.getUserId(uid) != UserHandle.USER_SYSTEM) {
- // temporary measure until geofences work for secondary users
- Log.w(TAG, "proximity alerts are currently available only to the primary user");
- return;
- }
- long identity = Binder.clearCallingIdentity();
- try {
- mGeofenceManager.addFence(sanitizedRequest, geofence, intent,
- allowedResolutionLevel,
- uid, packageName);
- } finally {
- Binder.restoreCallingIdentity(identity);
- }
+ // geo-fence manager uses the public location API, need to clear identity
+ int uid = Binder.getCallingUid();
+ if (UserHandle.getUserId(uid) != UserHandle.USER_SYSTEM) {
+ // temporary measure until geofences work for secondary users
+ Log.w(TAG, "proximity alerts are currently available only to the primary user");
+ return;
+ }
+ long identity = Binder.clearCallingIdentity();
+ try {
+ mGeofenceManager.addFence(sanitizedRequest, geofence, intent,
+ allowedResolutionLevel,
+ uid, packageName);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
}
}