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

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

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

View File

@@ -2448,9 +2448,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) {
@@ -2470,6 +2476,8 @@ public class LocationManager {
// ignore
}
}
return consumer;
}
public void fail() {
@@ -2528,16 +2536,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);
}
}