Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19335046 authored by Android Code Review's avatar Android Code Review
Browse files

Merge change I9ff67a5f

* changes:
  LocationManagerService: Fix race when removing LocationListener
parents 0b95a572 9ff67a5f
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -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