Skip to content

Commit 2b7a0d0

Browse files
author
Nick Pelly
committed
Fix addGeofence() and addProximityAlert().
Need to clear the callers identity before calling into geofence manager because it in turn calls fused location API's. Change-Id: I7993b0b8b2a947ff93c37a7c9d29ca0e7c95f9a8
1 parent 4035f5a commit 2b7a0d0

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ public void requestLocationUpdates(LocationRequest request, ILocationListener li
968968
final int uid = Binder.getCallingUid();
969969
Receiver recevier = checkListenerOrIntent(listener, intent, pid, uid, packageName);
970970

971-
// so wakelock calls will succeed (not totally sure this is still needed)
971+
// providers may use public location API's, need to clear identity
972972
long identity = Binder.clearCallingIdentity();
973973
try {
974974
synchronized (mLock) {
@@ -1018,7 +1018,7 @@ public void removeUpdates(ILocationListener listener, PendingIntent intent,
10181018
final int uid = Binder.getCallingUid();
10191019
Receiver receiver = checkListenerOrIntent(listener, intent, pid, uid, packageName);
10201020

1021-
// so wakelock calls will succeed (not totally sure this is still needed)
1021+
// providers may use public location API's, need to clear identity
10221022
long identity = Binder.clearCallingIdentity();
10231023
try {
10241024
synchronized (mLock) {
@@ -1107,7 +1107,14 @@ public void requestGeofence(LocationRequest request, Geofence geofence, PendingI
11071107

11081108
if (D) Log.d(TAG, "requestGeofence: " + request + " " + geofence + " " + intent);
11091109

1110-
mGeofenceManager.addFence(request, geofence, intent, Binder.getCallingUid(), packageName);
1110+
// geo-fence manager uses the public location API, need to clear identity
1111+
int uid = Binder.getCallingUid();
1112+
long identity = Binder.clearCallingIdentity();
1113+
try {
1114+
mGeofenceManager.addFence(request, geofence, intent, uid, packageName);
1115+
} finally {
1116+
Binder.restoreCallingIdentity(identity);
1117+
}
11111118
}
11121119

11131120
@Override
@@ -1118,7 +1125,13 @@ public void removeGeofence(Geofence geofence, PendingIntent intent, String packa
11181125

11191126
if (D) Log.d(TAG, "removeGeofence: " + geofence + " " + intent);
11201127

1121-
mGeofenceManager.removeFence(geofence, intent);
1128+
// geo-fence manager uses the public location API, need to clear identity
1129+
long identity = Binder.clearCallingIdentity();
1130+
try {
1131+
mGeofenceManager.removeFence(geofence, intent);
1132+
} finally {
1133+
Binder.restoreCallingIdentity(identity);
1134+
}
11221135
}
11231136

11241137

0 commit comments

Comments
 (0)