diff options
author | 2009-10-08 12:58:48 -0400 | |
---|---|---|
committer | 2009-10-08 12:58:48 -0400 | |
commit | bd324c9bd32a3c86634c1cc1ab8525f46a56b694 (patch) | |
tree | 8a66b7b3a4f9e5c822578fe10ac4b29d3ca5d9ad | |
parent | e9296876140ba055d311f3f11af25beae652e6d8 (diff) | |
parent | 080b61ba17014b8c93914f642ccbe05c76dc611d (diff) |
Merge change I50a321c9 into eclair
* 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 f6a1be73328f..c8fa4c39ad03 100644 --- a/services/java/com/android/server/LocationManagerService.java +++ b/services/java/com/android/server/LocationManagerService.java @@ -382,7 +382,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 @@ -921,6 +926,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 |