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

Commit 243af9e9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix deadlock for system location clients" into rvc-dev am: b297119c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11839901

Change-Id: I1bc8d42ca758b6e94e4be79e7157dfbe4aa02327
parents fc31ef0d b297119c
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 {