Revert changes to StationaryThrottlingLocationProvider
For unknown reasons these changes are causing a memory usage increase
affecting Go devices. This reverts commit
6eecc3ce91432db9ee4f3ede0b4efd45f70885f0.
Bug: 201306859
Test: presubmits
Change-Id: Ifd820ead3099c61abf7403442219f3d1172b8505
diff --git a/services/core/java/com/android/server/location/provider/StationaryThrottlingLocationProvider.java b/services/core/java/com/android/server/location/provider/StationaryThrottlingLocationProvider.java
index cc51cea..22a675a 100644
--- a/services/core/java/com/android/server/location/provider/StationaryThrottlingLocationProvider.java
+++ b/services/core/java/com/android/server/location/provider/StationaryThrottlingLocationProvider.java
@@ -105,15 +105,20 @@
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 @@
}
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;
}