diff options
| author | 2020-06-11 21:49:06 +0000 | |
|---|---|---|
| committer | 2020-06-11 21:49:06 +0000 | |
| commit | b297119cdb750d82fb8361b04d9a30e84d3341f8 (patch) | |
| tree | b8feae66c5200cc27ac296e533c2c53a3f3f9dc6 | |
| parent | 4e10d57e3486050f719ae853d0d22e95e759b145 (diff) | |
| parent | 8bd4db2620d090c414954d135b2486ce515f1dc4 (diff) | |
Merge "Fix deadlock for system location clients" into rvc-dev
| -rw-r--r-- | location/java/android/location/LocationManager.java | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/location/java/android/location/LocationManager.java b/location/java/android/location/LocationManager.java index a112bdd0ce03..7d15bbd46697 100644 --- a/location/java/android/location/LocationManager.java +++ b/location/java/android/location/LocationManager.java @@ -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,16 +2671,10 @@ 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); } - - consumer.accept(location); } } |