Fix deadlock for system location clients
Bug: 158637743 Test: manual Change-Id: I0fd2f2ac8cc4c81014e67d1115a2343b95b7cecf
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user