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

Commit b297119c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents 4e10d57e 8bd4db26
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 {