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

Commit 8bd4db26 authored by Soonil Nagarkar's avatar Soonil Nagarkar
Browse files

Fix deadlock for system location clients

Bug: 158637743
Test: manual
Change-Id: I0fd2f2ac8cc4c81014e67d1115a2343b95b7cecf
parent d4952538
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -2583,9 +2583,15 @@ public class LocationManager {
        }

        public void cancel() {
            remove();
        }

        private Consumer<Location> remove() {
            Consumer<Location> consumer;
            ICancellationSignal cancellationSignal;
            synchronized (this) {
                mExecutor = null;
                consumer = mConsumer;
                mConsumer = null;

                if (mAlarmManager != null) {
@@ -2605,6 +2611,8 @@ public class LocationManager {
                    // ignore
                }
            }

            return consumer;
        }

        public void fail() {
@@ -2663,18 +2671,12 @@ public class LocationManager {
        }

        private void acceptResult(Location location) {
            Consumer<Location> consumer;
            synchronized (this) {
                if (mConsumer == null) {
                    return;
                }
                consumer = mConsumer;
                cancel();
            }

            Consumer<Location> consumer = remove();
            if (consumer != null) {
                consumer.accept(location);
            }
        }
    }

    private class LocationListenerTransport extends ILocationListener.Stub {