From db71562964d5e5862ee08274bf3d2e0dca58a6fb Mon Sep 17 00:00:00 2001 From: Soonil Nagarkar Date: Fri, 17 Dec 2021 05:09:28 +0000 Subject: [PATCH] DO NOT MERGE: Revert "DO NOT MERGE: Lower bound throttling interval" This reverts commit 943c8287f887ad757b904f55bb7da442857ce093. Reason for revert: Possible root cause for b/210934408 Change-Id: I1ad30012d062342f21752fcc763e7973d1d1a118 --- .../StationaryThrottlingLocationProvider.java | 5 +-- ...tionaryThrottlingLocationProviderTest.java | 31 ++++++------------- 2 files changed, 11 insertions(+), 25 deletions(-) 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 5e38bca78a7c2..22a675ad39ab6 100644 --- a/services/core/java/com/android/server/location/provider/StationaryThrottlingLocationProvider.java +++ b/services/core/java/com/android/server/location/provider/StationaryThrottlingLocationProvider.java @@ -23,8 +23,6 @@ import static com.android.server.location.LocationManagerService.D; import static com.android.server.location.LocationManagerService.TAG; import static com.android.server.location.eventlog.LocationEventLog.EVENT_LOG; -import static java.lang.Math.max; - import android.annotation.Nullable; import android.location.Location; import android.location.LocationResult; @@ -55,7 +53,6 @@ public final class StationaryThrottlingLocationProvider extends DelegateLocation implements DeviceIdleHelper.DeviceIdleListener, DeviceIdleInternal.StationaryListener { private static final long MAX_STATIONARY_LOCATION_AGE_MS = 30000; - private static final long MIN_INTERVAL_MS = 1000; final Object mLock = new Object(); @@ -182,7 +179,7 @@ public final class StationaryThrottlingLocationProvider extends DelegateLocation && mLastLocation != null && mLastLocation.getElapsedRealtimeAgeMillis(mDeviceStationaryRealtimeMs) <= MAX_STATIONARY_LOCATION_AGE_MS) { - throttlingIntervalMs = max(mIncomingRequest.getIntervalMillis(), MIN_INTERVAL_MS); + throttlingIntervalMs = mIncomingRequest.getIntervalMillis(); } ProviderRequest newRequest; diff --git a/services/tests/mockingservicestests/src/com/android/server/location/provider/StationaryThrottlingLocationProviderTest.java b/services/tests/mockingservicestests/src/com/android/server/location/provider/StationaryThrottlingLocationProviderTest.java index 4eba21934a4e6..4d6f49e5d2231 100644 --- a/services/tests/mockingservicestests/src/com/android/server/location/provider/StationaryThrottlingLocationProviderTest.java +++ b/services/tests/mockingservicestests/src/com/android/server/location/provider/StationaryThrottlingLocationProviderTest.java @@ -89,19 +89,6 @@ public class StationaryThrottlingLocationProviderTest { mProvider.getController().stop(); } - @Test - public void testThrottle_lowInterval() { - ProviderRequest request = new ProviderRequest.Builder().setIntervalMillis(0).build(); - - mProvider.getController().setRequest(request); - mDelegateProvider.reportLocation(createLocationResult("test_provider", mRandom)); - verify(mListener, times(1)).onReportLocation(any(LocationResult.class)); - - mInjector.getDeviceStationaryHelper().setStationary(true); - mInjector.getDeviceIdleHelper().setIdle(true); - verify(mListener, after(1500).times(2)).onReportLocation(any(LocationResult.class)); - } - @Test public void testThrottle_stationaryExit() { ProviderRequest request = new ProviderRequest.Builder().setIntervalMillis(50).build(); @@ -117,16 +104,17 @@ public class StationaryThrottlingLocationProviderTest { mInjector.getDeviceIdleHelper().setIdle(true); verify(mDelegate).onSetRequest(ProviderRequest.EMPTY_REQUEST); - verify(mListener, timeout(1100).times(2)).onReportLocation(any(LocationResult.class)); + verify(mListener, timeout(75).times(2)).onReportLocation(any(LocationResult.class)); + verify(mListener, timeout(75).times(3)).onReportLocation(any(LocationResult.class)); mInjector.getDeviceStationaryHelper().setStationary(false); verify(mDelegate, times(2)).onSetRequest(request); - verify(mListener, after(1000).times(2)).onReportLocation(any(LocationResult.class)); + verify(mListener, after(75).times(3)).onReportLocation(any(LocationResult.class)); } @Test public void testThrottle_idleExit() { - ProviderRequest request = new ProviderRequest.Builder().setIntervalMillis(1000).build(); + ProviderRequest request = new ProviderRequest.Builder().setIntervalMillis(50).build(); mProvider.getController().setRequest(request); verify(mDelegate).onSetRequest(request); @@ -139,16 +127,17 @@ public class StationaryThrottlingLocationProviderTest { mInjector.getDeviceStationaryHelper().setStationary(true); verify(mDelegate).onSetRequest(ProviderRequest.EMPTY_REQUEST); - verify(mListener, timeout(1100).times(2)).onReportLocation(any(LocationResult.class)); + verify(mListener, timeout(75).times(2)).onReportLocation(any(LocationResult.class)); + verify(mListener, timeout(75).times(3)).onReportLocation(any(LocationResult.class)); mInjector.getDeviceIdleHelper().setIdle(false); verify(mDelegate, times(2)).onSetRequest(request); - verify(mListener, after(1000).times(2)).onReportLocation(any(LocationResult.class)); + verify(mListener, after(75).times(3)).onReportLocation(any(LocationResult.class)); } @Test public void testThrottle_NoInitialLocation() { - ProviderRequest request = new ProviderRequest.Builder().setIntervalMillis(1000).build(); + ProviderRequest request = new ProviderRequest.Builder().setIntervalMillis(50).build(); mProvider.getController().setRequest(request); verify(mDelegate).onSetRequest(request); @@ -160,11 +149,11 @@ public class StationaryThrottlingLocationProviderTest { mDelegateProvider.reportLocation(createLocationResult("test_provider", mRandom)); verify(mListener, times(1)).onReportLocation(any(LocationResult.class)); verify(mDelegate, times(1)).onSetRequest(ProviderRequest.EMPTY_REQUEST); - verify(mListener, timeout(1100).times(2)).onReportLocation(any(LocationResult.class)); + verify(mListener, timeout(75).times(2)).onReportLocation(any(LocationResult.class)); mInjector.getDeviceStationaryHelper().setStationary(false); verify(mDelegate, times(2)).onSetRequest(request); - verify(mListener, after(1000).times(2)).onReportLocation(any(LocationResult.class)); + verify(mListener, after(75).times(2)).onReportLocation(any(LocationResult.class)); } @Test