Merge "Revert changes to StationaryThrottlingLocationProvider" into sc-qpr1-dev

This commit is contained in:
TreeHugger Robot
2021-10-08 16:26:41 +00:00
committed by Android (Google) Code Review

View File

@@ -105,15 +105,20 @@ public final class StationaryThrottlingLocationProvider extends DelegateLocation
synchronized (mLock) {
mDeviceIdleHelper.addListener(this);
onDeviceIdleChanged(mDeviceIdleHelper.isDeviceIdle());
mDeviceIdle = mDeviceIdleHelper.isDeviceIdle();
mDeviceStationaryHelper.addListener(this);
mDeviceStationary = false;
mDeviceStationaryRealtimeMs = Long.MIN_VALUE;
onThrottlingChangedLocked(false);
}
}
@Override
protected void onStop() {
synchronized (mLock) {
mDeviceStationaryHelper.removeListener(this);
mDeviceIdleHelper.removeListener(this);
onDeviceIdleChanged(false);
mIncomingRequest = ProviderRequest.EMPTY_REQUEST;
mOutgoingRequest = ProviderRequest.EMPTY_REQUEST;
@@ -146,27 +151,13 @@ public final class StationaryThrottlingLocationProvider extends DelegateLocation
}
mDeviceIdle = deviceIdle;
if (deviceIdle) {
// device stationary helper will deliver an immediate listener update
mDeviceStationaryHelper.addListener(this);
} else {
mDeviceStationaryHelper.removeListener(this);
mDeviceStationary = false;
mDeviceStationaryRealtimeMs = Long.MIN_VALUE;
onThrottlingChangedLocked(false);
}
onThrottlingChangedLocked(false);
}
}
@Override
public void onDeviceStationaryChanged(boolean deviceStationary) {
synchronized (mLock) {
if (!mDeviceIdle) {
// stationary detection is only registered while idle - ignore late notifications
return;
}
if (mDeviceStationary == deviceStationary) {
return;
}