Merge "Fix deadlock for system location clients" into rvc-dev am: b297119cdb
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11839901 Change-Id: I1bc8d42ca758b6e94e4be79e7157dfbe4aa02327
This commit is contained in:
@@ -2583,9 +2583,15 @@ public class LocationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
|
remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Consumer<Location> remove() {
|
||||||
|
Consumer<Location> consumer;
|
||||||
ICancellationSignal cancellationSignal;
|
ICancellationSignal cancellationSignal;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
mExecutor = null;
|
mExecutor = null;
|
||||||
|
consumer = mConsumer;
|
||||||
mConsumer = null;
|
mConsumer = null;
|
||||||
|
|
||||||
if (mAlarmManager != null) {
|
if (mAlarmManager != null) {
|
||||||
@@ -2605,6 +2611,8 @@ public class LocationManager {
|
|||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return consumer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fail() {
|
public void fail() {
|
||||||
@@ -2663,16 +2671,10 @@ public class LocationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void acceptResult(Location location) {
|
private void acceptResult(Location location) {
|
||||||
Consumer<Location> consumer;
|
Consumer<Location> consumer = remove();
|
||||||
synchronized (this) {
|
if (consumer != null) {
|
||||||
if (mConsumer == null) {
|
consumer.accept(location);
|
||||||
return;
|
|
||||||
}
|
|
||||||
consumer = mConsumer;
|
|
||||||
cancel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
consumer.accept(location);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user