Merge "Quick fix for possible deadlock in LMS" into rvc-dev am: 45b8146ae8 am: 98c1646443

Change-Id: I8378aa26a2c6edf6f2b3b72d39b370e7aac0d38c
This commit is contained in:
Automerger Merge Worker
2020-03-03 03:21:45 +00:00

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