diff options
| author | 2009-11-05 11:36:48 -0800 | |
|---|---|---|
| committer | 2009-11-05 11:36:48 -0800 | |
| commit | 193350461621a26cd27c24c5a2ea5eeb4ab66e46 (patch) | |
| tree | 4a41632817463972fcfaffd3fe2f16162007e297 | |
| parent | 0b95a572a04073ba85dd860caf8fe724d807358d (diff) | |
| parent | 9ff67a5f9b0bca15ad6933eac90a65b11b29eb2e (diff) | |
Merge change I9ff67a5f
* changes:
LocationManagerService: Fix race when removing LocationListener
| -rw-r--r-- | services/java/com/android/server/LocationManagerService.java | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/services/java/com/android/server/LocationManagerService.java b/services/java/com/android/server/LocationManagerService.java index 9866ccea8732..4a4d5abb3371 100644 --- a/services/java/com/android/server/LocationManagerService.java +++ b/services/java/com/android/server/LocationManagerService.java @@ -394,7 +394,12 @@ public class LocationManagerService extends ILocationManager.Stub implements Run } public void locationCallbackFinished(ILocationListener listener) { - Receiver receiver = getReceiver(listener); + //Do not use getReceiver here as that will add the ILocationListener to + //the receiver list if it is not found. If it is not found then the + //LocationListener was removed when it had a pending broadcast and should + //not be added back. + IBinder binder = listener.asBinder(); + Receiver receiver = mReceivers.get(binder); if (receiver != null) { synchronized (receiver) { // so wakelock calls will succeed @@ -1030,6 +1035,12 @@ public class LocationManagerService extends ILocationManager.Stub implements Run try { if (mReceivers.remove(receiver.mKey) != null && receiver.isListener()) { receiver.getListener().asBinder().unlinkToDeath(receiver, 0); + synchronized(receiver) { + if(receiver.mPendingBroadcasts > 0) { + decrementPendingBroadcasts(); + receiver.mPendingBroadcasts = 0; + } + } } // Record which providers were associated with this listener |