Merge "DO NOT MERGE Local timeout should cancel remote work" into rvc-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
bfd3ac4d58
@@ -732,7 +732,7 @@ public class LocationManager {
|
||||
mContext.getAttributionTag(), transport.getListenerId());
|
||||
if (cancelRemote != null) {
|
||||
transport.register(mContext.getSystemService(AlarmManager.class),
|
||||
cancellationSignal);
|
||||
cancellationSignal, cancelRemote);
|
||||
if (cancellationSignal != null) {
|
||||
cancellationSignal.setRemote(cancelRemote);
|
||||
}
|
||||
@@ -2571,7 +2571,8 @@ public class LocationManager {
|
||||
}
|
||||
|
||||
public synchronized void register(AlarmManager alarmManager,
|
||||
CancellationSignal cancellationSignal) {
|
||||
CancellationSignal cancellationSignal,
|
||||
ICancellationSignal remoteCancellationSignal) {
|
||||
if (mConsumer == null) {
|
||||
return;
|
||||
}
|
||||
@@ -2587,15 +2588,21 @@ public class LocationManager {
|
||||
if (cancellationSignal != null) {
|
||||
cancellationSignal.setOnCancelListener(this);
|
||||
}
|
||||
|
||||
mRemoteCancellationSignal = remoteCancellationSignal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
synchronized (this) {
|
||||
mRemoteCancellationSignal = null;
|
||||
}
|
||||
remove();
|
||||
}
|
||||
|
||||
private Consumer<Location> remove() {
|
||||
Consumer<Location> consumer;
|
||||
ICancellationSignal cancellationSignal;
|
||||
synchronized (this) {
|
||||
mExecutor = null;
|
||||
consumer = mConsumer;
|
||||
@@ -2605,6 +2612,18 @@ public class LocationManager {
|
||||
mAlarmManager.cancel(this);
|
||||
mAlarmManager = null;
|
||||
}
|
||||
|
||||
// ensure only one cancel event will go through
|
||||
cancellationSignal = mRemoteCancellationSignal;
|
||||
mRemoteCancellationSignal = null;
|
||||
}
|
||||
|
||||
if (cancellationSignal != null) {
|
||||
try {
|
||||
cancellationSignal.cancel();
|
||||
} catch (RemoteException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
return consumer;
|
||||
|
||||
Reference in New Issue
Block a user