Merge "Fix deadlock for system location clients" into rvc-dev am: b297119cdb am: 243af9e9cf am: 27ec4f69b8

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

Change-Id: I32d2e74b75bd9bbf16f272ce40b15a78ebefe162
This commit is contained in:
TreeHugger Robot
2020-06-11 22:22:15 +00:00
committed by Automerger Merge Worker

View File

@@ -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);
}
}