Merge "Only register stationary detector while idle" into sc-qpr1-dev am: 65f1d1a5e1 am: 307c549046

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15639364

Change-Id: I9065c9554dc8445e9fc0951dab6182cf5c1daffc
This commit is contained in:
TreeHugger Robot
2021-09-23 05:34:40 +00:00
committed by Automerger Merge Worker

View File

@@ -105,20 +105,15 @@ public final class StationaryThrottlingLocationProvider extends DelegateLocation
synchronized (mLock) {
mDeviceIdleHelper.addListener(this);
mDeviceIdle = mDeviceIdleHelper.isDeviceIdle();
mDeviceStationaryHelper.addListener(this);
mDeviceStationary = false;
mDeviceStationaryRealtimeMs = Long.MIN_VALUE;
onThrottlingChangedLocked(false);
onDeviceIdleChanged(mDeviceIdleHelper.isDeviceIdle());
}
}
@Override
protected void onStop() {
synchronized (mLock) {
mDeviceStationaryHelper.removeListener(this);
mDeviceIdleHelper.removeListener(this);
onDeviceIdleChanged(false);
mIncomingRequest = ProviderRequest.EMPTY_REQUEST;
mOutgoingRequest = ProviderRequest.EMPTY_REQUEST;
@@ -151,13 +146,26 @@ public final class StationaryThrottlingLocationProvider extends DelegateLocation
}
mDeviceIdle = deviceIdle;
onThrottlingChangedLocked(false);
if (deviceIdle) {
// device stationary helper will deliver an immediate listener update
mDeviceStationaryHelper.addListener(this);
} else {
mDeviceStationaryHelper.removeListener(this);
mDeviceStationary = false;
mDeviceStationaryRealtimeMs = Long.MIN_VALUE;
}
}
}
@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;
}