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

Commit 6c821dab authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Prevent paused ThresholdSensorImpl event delivery." into rvc-d1-dev am: d688f8ba

Change-Id: I506b2c2dd98e5c8b7dc89796969c21e9c67ca401
parents 7cb811aa d688f8ba
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ class ThresholdSensorImpl implements ThresholdSensor {

    private void onSensorEvent(boolean below, long timestampNs) {
        Assert.isMainThread();
        if (mLastBelow != null && mLastBelow == below) {
        if (!mRegistered || mLastBelow != null && mLastBelow == below) {
            return;
        }
        mLastBelow = below;
+17 −0
Original line number Diff line number Diff line
@@ -226,6 +226,23 @@ public class ThresholdSensorImplTest extends SysuiTestCase {
        waitForSensorManager();
    }

    @Test
    public void testAlertAfterPause() {
        TestableListener listener = new TestableListener();

        mThresholdSensor.register(listener);
        waitForSensorManager();
        mFakeProximitySensor.sendProximityResult(false);
        assertTrue(listener.mBelow);
        assertEquals(1, listener.mCallCount);

        mThresholdSensor.pause();

        mFakeProximitySensor.sendProximityResult(false);
        assertTrue(listener.mBelow);
        assertEquals(1, listener.mCallCount);
    }

    static class TestableListener implements ThresholdSensor.Listener {
        boolean mBelow;
        long mTimestampNs;