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
This commit is contained in:
Soonil Nagarkar
2019-02-27 13:00:56 -08:00
parent 6cde03853b
commit 8c4655e091

View File

@@ -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,
}
// 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);
}
// 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,
callerHasLocationHardwarePermission);
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);
}
uid, packageName);
} finally {
Binder.restoreCallingIdentity(identity);
}
}