Alert ProxCheck listeners directly when timing out.

Before this change, we were relying on the ProximitySensor class
to circle back and tell the ProximityCheck class about null results.
When the ProximitySensor class changed, this broke ProxCheck. The
ProxCheck class now directly alerts its listeners when it times out.

A test has been added to cover this case now.

Fixes: 162205584
Test: atest SystemUiTests && Manual
Change-Id: Ie48589a54daae3e29defde9ed2300f3c7e2b88ae
This commit is contained in:
Dave Mankoff
2020-08-03 16:02:08 -04:00
parent afab5784ea
commit 06d38cabf6
2 changed files with 7 additions and 1 deletions

View File

@@ -338,7 +338,7 @@ public class ProximitySensor implements ThresholdSensor {
@Override
public void run() {
unregister();
mSensor.alertListeners();
onProximityEvent(null);
}
/**

View File

@@ -16,6 +16,7 @@
package com.android.systemui.util.sensors;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -80,6 +81,8 @@ public class ProximityCheckTest extends SysuiTestCase {
mFakeExecutor.runAllReady();
assertFalse(mFakeProximitySensor.isRegistered());
assertEquals(1, mTestableCallback.mNumCalls);
assertNull(mTestableCallback.mLastResult);
}
@Test
@@ -110,9 +113,12 @@ public class ProximityCheckTest extends SysuiTestCase {
private static class TestableCallback implements Consumer<Boolean> {
Boolean mLastResult;
int mNumCalls = 0;
@Override
public void accept(Boolean result) {
mLastResult = result;
mNumCalls++;
}
}
}