Merge "Quick fix for possible deadlock in LMS" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-03-03 02:59:15 +00:00
committed by Android (Google) Code Review

View File

@@ -2562,7 +2562,9 @@ public class LocationManager {
mRemoteCancellationSignal = remoteCancellationSignal; mRemoteCancellationSignal = remoteCancellationSignal;
} }
public synchronized void cancel() { public void cancel() {
ICancellationSignal cancellationSignal;
synchronized (this) {
mExecutor = null; mExecutor = null;
mConsumer = null; mConsumer = null;
@@ -2571,13 +2573,17 @@ public class LocationManager {
mAlarmManager = null; mAlarmManager = null;
} }
if (mRemoteCancellationSignal != null) { // ensure only one cancel event will go through
cancellationSignal = mRemoteCancellationSignal;
mRemoteCancellationSignal = null;
}
if (cancellationSignal != null) {
try { try {
mRemoteCancellationSignal.cancel(); cancellationSignal.cancel();
} catch (RemoteException e) { } catch (RemoteException e) {
// ignore // ignore
} }
mRemoteCancellationSignal = null;
} }
} }