Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eeff412d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix bug unregistering stationary listener" into sc-qpr1-dev

parents 4cb5412d 08f91a61
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -154,6 +154,7 @@ public final class StationaryThrottlingLocationProvider extends DelegateLocation
                mDeviceStationaryHelper.removeListener(this);
                mDeviceStationary = false;
                mDeviceStationaryRealtimeMs = Long.MIN_VALUE;
                onThrottlingChangedLocked(false);
            }
        }
    }
+24 −1
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ public class StationaryThrottlingLocationProviderTest {
    }

    @Test
    public void testThrottle() {
    public void testThrottle_stationaryExit() {
        ProviderRequest request = new ProviderRequest.Builder().setIntervalMillis(50).build();

        mProvider.getController().setRequest(request);
@@ -112,6 +112,29 @@ public class StationaryThrottlingLocationProviderTest {
        verify(mListener, after(75).times(3)).onReportLocation(any(LocationResult.class));
    }

    @Test
    public void testThrottle_idleExit() {
        ProviderRequest request = new ProviderRequest.Builder().setIntervalMillis(50).build();

        mProvider.getController().setRequest(request);
        verify(mDelegate).onSetRequest(request);

        mDelegateProvider.reportLocation(createLocationResult("test_provider", mRandom));
        verify(mListener, times(1)).onReportLocation(any(LocationResult.class));

        mInjector.getDeviceIdleHelper().setIdle(true);
        verify(mDelegate, never()).onSetRequest(ProviderRequest.EMPTY_REQUEST);

        mInjector.getDeviceStationaryHelper().setStationary(true);
        verify(mDelegate).onSetRequest(ProviderRequest.EMPTY_REQUEST);
        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(75).times(3)).onReportLocation(any(LocationResult.class));
    }

    @Test
    public void testThrottle_NoInitialLocation() {
        ProviderRequest request = new ProviderRequest.Builder().setIntervalMillis(50).build();