Loading packages/SystemUI/src/com/android/systemui/util/sensors/ProximitySensor.java +30 −23 Original line number Diff line number Diff line Loading @@ -21,8 +21,8 @@ import android.util.Log; import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.util.Assert; import com.android.systemui.util.concurrency.DelayableExecutor; import com.android.systemui.util.concurrency.Execution; import java.util.ArrayList; import java.util.List; Loading Loading @@ -62,6 +62,7 @@ public class ProximitySensor implements ThresholdSensor { private final ThresholdSensor mPrimaryThresholdSensor; private final ThresholdSensor mSecondaryThresholdSensor; private final DelayableExecutor mDelayableExecutor; private final Execution mExecution; private final List<ThresholdSensor.Listener> mListeners = new ArrayList<>(); private String mTag = null; @VisibleForTesting protected boolean mPaused; Loading @@ -74,14 +75,10 @@ public class ProximitySensor implements ThresholdSensor { private boolean mInitializedListeners = false; private boolean mSecondarySafe = false; private ThresholdSensor.Listener mPrimaryEventListener = new ThresholdSensor.Listener() { @Override public void onThresholdCrossed(ThresholdSensorEvent event) { onPrimarySensorEvent(event); } }; private final ThresholdSensor.Listener mPrimaryEventListener = this::onPrimarySensorEvent; private ThresholdSensor.Listener mSecondaryEventListener = new ThresholdSensor.Listener() { private final ThresholdSensor.Listener mSecondaryEventListener = new ThresholdSensor.Listener() { @Override public void onThresholdCrossed(ThresholdSensorEvent event) { // If we no longer have a "below" signal and the secondary sensor is not Loading Loading @@ -110,12 +107,15 @@ public class ProximitySensor implements ThresholdSensor { }; @Inject public ProximitySensor(@PrimaryProxSensor ThresholdSensor primary, public ProximitySensor( @PrimaryProxSensor ThresholdSensor primary, @SecondaryProxSensor ThresholdSensor secondary, @Main DelayableExecutor delayableExecutor) { @Main DelayableExecutor delayableExecutor, Execution execution) { mPrimaryThresholdSensor = primary; mSecondaryThresholdSensor = secondary; mDelayableExecutor = delayableExecutor; mExecution = execution; } @Override Loading @@ -127,7 +127,7 @@ public class ProximitySensor implements ThresholdSensor { @Override public void setDelay(int delay) { Assert.isMainThread(); mExecution.assertIsMainThread(); mPrimaryThresholdSensor.setDelay(delay); mSecondaryThresholdSensor.setDelay(delay); } Loading @@ -137,7 +137,7 @@ public class ProximitySensor implements ThresholdSensor { */ @Override public void pause() { Assert.isMainThread(); mExecution.assertIsMainThread(); mPaused = true; unregisterInternal(); } Loading @@ -147,18 +147,23 @@ public class ProximitySensor implements ThresholdSensor { */ @Override public void resume() { Assert.isMainThread(); mExecution.assertIsMainThread(); mPaused = false; registerInternal(); } /** * Sets that it is safe to leave the secondary sensor on indefinitely. * * The secondary sensor will be turned on if there are any registered listeners, regardless * of what is reported by the primary sensor. */ public void setSecondarySafe(boolean safe) { mSecondarySafe = safe; if (!mSecondarySafe) { mSecondaryThresholdSensor.pause(); } else { mSecondaryThresholdSensor.resume(); } } Loading @@ -185,7 +190,7 @@ public class ProximitySensor implements ThresholdSensor { */ @Override public void register(ThresholdSensor.Listener listener) { Assert.isMainThread(); mExecution.assertIsMainThread(); if (!isLoaded()) { return; } Loading @@ -199,13 +204,15 @@ public class ProximitySensor implements ThresholdSensor { } protected void registerInternal() { Assert.isMainThread(); mExecution.assertIsMainThread(); if (mRegistered || mPaused || mListeners.isEmpty()) { return; } if (!mInitializedListeners) { mPrimaryThresholdSensor.register(mPrimaryEventListener); if (!mSecondarySafe) { mSecondaryThresholdSensor.pause(); } mSecondaryThresholdSensor.register(mSecondaryEventListener); mInitializedListeners = true; } Loading @@ -222,7 +229,7 @@ public class ProximitySensor implements ThresholdSensor { */ @Override public void unregister(ThresholdSensor.Listener listener) { Assert.isMainThread(); mExecution.assertIsMainThread(); mListeners.remove(listener); if (mListeners.size() == 0) { unregisterInternal(); Loading @@ -230,7 +237,7 @@ public class ProximitySensor implements ThresholdSensor { } protected void unregisterInternal() { Assert.isMainThread(); mExecution.assertIsMainThread(); if (!mRegistered) { return; } Loading @@ -252,7 +259,7 @@ public class ProximitySensor implements ThresholdSensor { /** Update all listeners with the last value this class received from the sensor. */ public void alertListeners() { Assert.isMainThread(); mExecution.assertIsMainThread(); if (mAlerting.getAndSet(true)) { return; } Loading @@ -267,7 +274,7 @@ public class ProximitySensor implements ThresholdSensor { } private void onPrimarySensorEvent(ThresholdSensorEvent event) { Assert.isMainThread(); mExecution.assertIsMainThread(); if (mLastPrimaryEvent != null && event.getBelow() == mLastPrimaryEvent.getBelow()) { return; } Loading @@ -290,7 +297,7 @@ public class ProximitySensor implements ThresholdSensor { } private void onSensorEvent(ThresholdSensorEvent event) { Assert.isMainThread(); mExecution.assertIsMainThread(); if (mLastEvent != null && event.getBelow() == mLastEvent.getBelow()) { return; } Loading @@ -306,9 +313,9 @@ public class ProximitySensor implements ThresholdSensor { @Override public String toString() { return String.format("{registered=%s, paused=%s, near=%s, primarySensor=%s, " + "secondarySensor=%s}", + "secondarySensor=%s secondarySafe=%s}", isRegistered(), mPaused, isNear(), mPrimaryThresholdSensor, mSecondaryThresholdSensor); mSecondaryThresholdSensor, mSecondarySafe); } /** Loading packages/SystemUI/src/com/android/systemui/util/sensors/ThresholdSensorImpl.java +17 −12 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import android.util.Log; import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.util.Assert; import com.android.systemui.util.concurrency.Execution; import java.util.ArrayList; import java.util.List; Loading @@ -37,6 +37,7 @@ class ThresholdSensorImpl implements ThresholdSensor { private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private final AsyncSensorManager mSensorManager; private final Execution mExecution; private final Sensor mSensor; private final float mThreshold; private boolean mRegistered; Loading @@ -61,9 +62,10 @@ class ThresholdSensorImpl implements ThresholdSensor { } }; private ThresholdSensorImpl(AsyncSensorManager sensorManager, Sensor sensor, float threshold, float thresholdLatch, int sensorDelay) { private ThresholdSensorImpl(AsyncSensorManager sensorManager, Sensor sensor, Execution execution, float threshold, float thresholdLatch, int sensorDelay) { mSensorManager = sensorManager; mExecution = execution; mSensor = sensor; mThreshold = threshold; mThresholdLatch = thresholdLatch; Loading Loading @@ -107,7 +109,7 @@ class ThresholdSensorImpl implements ThresholdSensor { */ @Override public void register(Listener listener) { Assert.isMainThread(); mExecution.assertIsMainThread(); if (!mListeners.contains(listener)) { mListeners.add(listener); } Loading @@ -116,7 +118,7 @@ class ThresholdSensorImpl implements ThresholdSensor { @Override public void unregister(Listener listener) { Assert.isMainThread(); mExecution.assertIsMainThread(); mListeners.remove(listener); unregisterInternal(); } Loading @@ -126,7 +128,7 @@ class ThresholdSensorImpl implements ThresholdSensor { */ @Override public void pause() { Assert.isMainThread(); mExecution.assertIsMainThread(); mPaused = true; unregisterInternal(); } Loading @@ -136,7 +138,7 @@ class ThresholdSensorImpl implements ThresholdSensor { */ @Override public void resume() { Assert.isMainThread(); mExecution.assertIsMainThread(); mPaused = false; registerInternal(); } Loading @@ -148,7 +150,7 @@ class ThresholdSensorImpl implements ThresholdSensor { } private void registerInternal() { Assert.isMainThread(); mExecution.assertIsMainThread(); if (mRegistered || mPaused || mListeners.isEmpty()) { return; } Loading @@ -158,7 +160,7 @@ class ThresholdSensorImpl implements ThresholdSensor { } private void unregisterInternal() { Assert.isMainThread(); mExecution.assertIsMainThread(); if (!mRegistered) { return; } Loading @@ -177,7 +179,7 @@ class ThresholdSensorImpl implements ThresholdSensor { * still appears entirely binary. */ private void onSensorEvent(boolean belowThreshold, boolean aboveThreshold, long timestampNs) { Assert.isMainThread(); mExecution.assertIsMainThread(); if (!mRegistered) { return; } Loading Loading @@ -212,6 +214,7 @@ class ThresholdSensorImpl implements ThresholdSensor { static class Builder { private final Resources mResources; private final AsyncSensorManager mSensorManager; private final Execution mExecution; private int mSensorDelay = SensorManager.SENSOR_DELAY_NORMAL;; private float mThresholdValue; private float mThresholdLatchValue; Loading @@ -221,9 +224,10 @@ class ThresholdSensorImpl implements ThresholdSensor { private boolean mThresholdLatchValueSet; @Inject Builder(@Main Resources resources, AsyncSensorManager sensorManager) { Builder(@Main Resources resources, AsyncSensorManager sensorManager, Execution execution) { mResources = resources; mSensorManager = sensorManager; mExecution = execution; } Loading Loading @@ -302,7 +306,8 @@ class ThresholdSensorImpl implements ThresholdSensor { } return new ThresholdSensorImpl( mSensorManager, mSensor, mThresholdValue, mThresholdLatchValue, mSensorDelay); mSensorManager, mSensor, mExecution, mThresholdValue, mThresholdLatchValue, mSensorDelay); } private Sensor findSensorByType(String sensorType) { Loading packages/SystemUI/tests/src/com/android/systemui/util/sensors/FakeProximitySensor.java +2 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.util.sensors; import com.android.systemui.util.concurrency.DelayableExecutor; import com.android.systemui.util.concurrency.FakeExecution; public class FakeProximitySensor extends ProximitySensor { private boolean mAvailable; Loading @@ -25,7 +26,7 @@ public class FakeProximitySensor extends ProximitySensor { public FakeProximitySensor(ThresholdSensor primary, ThresholdSensor secondary, DelayableExecutor delayableExecutor) { super(primary, secondary == null ? new FakeThresholdSensor() : secondary, delayableExecutor); delayableExecutor, new FakeExecution()); mAvailable = true; } Loading packages/SystemUI/tests/src/com/android/systemui/util/sensors/ProximitySensorDualTest.java +5 −2 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.testing.TestableLooper; import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; import com.android.systemui.util.concurrency.FakeExecution; import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.time.FakeSystemClock; Loading Loading @@ -54,7 +55,8 @@ public class ProximitySensorDualTest extends SysuiTestCase { mThresholdSensorSecondary.setLoaded(true); mProximitySensor = new ProximitySensor( mThresholdSensorPrimary, mThresholdSensorSecondary, mFakeExecutor); mThresholdSensorPrimary, mThresholdSensorSecondary, mFakeExecutor, new FakeExecution()); } @Test Loading Loading @@ -324,9 +326,10 @@ public class ProximitySensorDualTest extends SysuiTestCase { TestableListener listener = new TestableListener(); // WE immediately register the secondary sensor. mProximitySensor.register(listener); assertFalse(mThresholdSensorPrimary.isPaused()); assertTrue(mThresholdSensorSecondary.isPaused()); assertFalse(mThresholdSensorSecondary.isPaused()); assertNull(listener.mLastEvent); assertEquals(0, listener.mCallCount); Loading packages/SystemUI/tests/src/com/android/systemui/util/sensors/ProximitySensorSingleTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.testing.TestableLooper; import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; import com.android.systemui.util.concurrency.FakeExecution; import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.time.FakeSystemClock; Loading Loading @@ -54,7 +55,7 @@ public class ProximitySensorSingleTest extends SysuiTestCase { mThresholdSensor.setLoaded(true); mProximitySensor = new ProximitySensor( mThresholdSensor, new FakeThresholdSensor(), mFakeExecutor); mThresholdSensor, new FakeThresholdSensor(), mFakeExecutor, new FakeExecution()); } @Test Loading Loading
packages/SystemUI/src/com/android/systemui/util/sensors/ProximitySensor.java +30 −23 Original line number Diff line number Diff line Loading @@ -21,8 +21,8 @@ import android.util.Log; import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.util.Assert; import com.android.systemui.util.concurrency.DelayableExecutor; import com.android.systemui.util.concurrency.Execution; import java.util.ArrayList; import java.util.List; Loading Loading @@ -62,6 +62,7 @@ public class ProximitySensor implements ThresholdSensor { private final ThresholdSensor mPrimaryThresholdSensor; private final ThresholdSensor mSecondaryThresholdSensor; private final DelayableExecutor mDelayableExecutor; private final Execution mExecution; private final List<ThresholdSensor.Listener> mListeners = new ArrayList<>(); private String mTag = null; @VisibleForTesting protected boolean mPaused; Loading @@ -74,14 +75,10 @@ public class ProximitySensor implements ThresholdSensor { private boolean mInitializedListeners = false; private boolean mSecondarySafe = false; private ThresholdSensor.Listener mPrimaryEventListener = new ThresholdSensor.Listener() { @Override public void onThresholdCrossed(ThresholdSensorEvent event) { onPrimarySensorEvent(event); } }; private final ThresholdSensor.Listener mPrimaryEventListener = this::onPrimarySensorEvent; private ThresholdSensor.Listener mSecondaryEventListener = new ThresholdSensor.Listener() { private final ThresholdSensor.Listener mSecondaryEventListener = new ThresholdSensor.Listener() { @Override public void onThresholdCrossed(ThresholdSensorEvent event) { // If we no longer have a "below" signal and the secondary sensor is not Loading Loading @@ -110,12 +107,15 @@ public class ProximitySensor implements ThresholdSensor { }; @Inject public ProximitySensor(@PrimaryProxSensor ThresholdSensor primary, public ProximitySensor( @PrimaryProxSensor ThresholdSensor primary, @SecondaryProxSensor ThresholdSensor secondary, @Main DelayableExecutor delayableExecutor) { @Main DelayableExecutor delayableExecutor, Execution execution) { mPrimaryThresholdSensor = primary; mSecondaryThresholdSensor = secondary; mDelayableExecutor = delayableExecutor; mExecution = execution; } @Override Loading @@ -127,7 +127,7 @@ public class ProximitySensor implements ThresholdSensor { @Override public void setDelay(int delay) { Assert.isMainThread(); mExecution.assertIsMainThread(); mPrimaryThresholdSensor.setDelay(delay); mSecondaryThresholdSensor.setDelay(delay); } Loading @@ -137,7 +137,7 @@ public class ProximitySensor implements ThresholdSensor { */ @Override public void pause() { Assert.isMainThread(); mExecution.assertIsMainThread(); mPaused = true; unregisterInternal(); } Loading @@ -147,18 +147,23 @@ public class ProximitySensor implements ThresholdSensor { */ @Override public void resume() { Assert.isMainThread(); mExecution.assertIsMainThread(); mPaused = false; registerInternal(); } /** * Sets that it is safe to leave the secondary sensor on indefinitely. * * The secondary sensor will be turned on if there are any registered listeners, regardless * of what is reported by the primary sensor. */ public void setSecondarySafe(boolean safe) { mSecondarySafe = safe; if (!mSecondarySafe) { mSecondaryThresholdSensor.pause(); } else { mSecondaryThresholdSensor.resume(); } } Loading @@ -185,7 +190,7 @@ public class ProximitySensor implements ThresholdSensor { */ @Override public void register(ThresholdSensor.Listener listener) { Assert.isMainThread(); mExecution.assertIsMainThread(); if (!isLoaded()) { return; } Loading @@ -199,13 +204,15 @@ public class ProximitySensor implements ThresholdSensor { } protected void registerInternal() { Assert.isMainThread(); mExecution.assertIsMainThread(); if (mRegistered || mPaused || mListeners.isEmpty()) { return; } if (!mInitializedListeners) { mPrimaryThresholdSensor.register(mPrimaryEventListener); if (!mSecondarySafe) { mSecondaryThresholdSensor.pause(); } mSecondaryThresholdSensor.register(mSecondaryEventListener); mInitializedListeners = true; } Loading @@ -222,7 +229,7 @@ public class ProximitySensor implements ThresholdSensor { */ @Override public void unregister(ThresholdSensor.Listener listener) { Assert.isMainThread(); mExecution.assertIsMainThread(); mListeners.remove(listener); if (mListeners.size() == 0) { unregisterInternal(); Loading @@ -230,7 +237,7 @@ public class ProximitySensor implements ThresholdSensor { } protected void unregisterInternal() { Assert.isMainThread(); mExecution.assertIsMainThread(); if (!mRegistered) { return; } Loading @@ -252,7 +259,7 @@ public class ProximitySensor implements ThresholdSensor { /** Update all listeners with the last value this class received from the sensor. */ public void alertListeners() { Assert.isMainThread(); mExecution.assertIsMainThread(); if (mAlerting.getAndSet(true)) { return; } Loading @@ -267,7 +274,7 @@ public class ProximitySensor implements ThresholdSensor { } private void onPrimarySensorEvent(ThresholdSensorEvent event) { Assert.isMainThread(); mExecution.assertIsMainThread(); if (mLastPrimaryEvent != null && event.getBelow() == mLastPrimaryEvent.getBelow()) { return; } Loading @@ -290,7 +297,7 @@ public class ProximitySensor implements ThresholdSensor { } private void onSensorEvent(ThresholdSensorEvent event) { Assert.isMainThread(); mExecution.assertIsMainThread(); if (mLastEvent != null && event.getBelow() == mLastEvent.getBelow()) { return; } Loading @@ -306,9 +313,9 @@ public class ProximitySensor implements ThresholdSensor { @Override public String toString() { return String.format("{registered=%s, paused=%s, near=%s, primarySensor=%s, " + "secondarySensor=%s}", + "secondarySensor=%s secondarySafe=%s}", isRegistered(), mPaused, isNear(), mPrimaryThresholdSensor, mSecondaryThresholdSensor); mSecondaryThresholdSensor, mSecondarySafe); } /** Loading
packages/SystemUI/src/com/android/systemui/util/sensors/ThresholdSensorImpl.java +17 −12 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ import android.util.Log; import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.util.Assert; import com.android.systemui.util.concurrency.Execution; import java.util.ArrayList; import java.util.List; Loading @@ -37,6 +37,7 @@ class ThresholdSensorImpl implements ThresholdSensor { private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private final AsyncSensorManager mSensorManager; private final Execution mExecution; private final Sensor mSensor; private final float mThreshold; private boolean mRegistered; Loading @@ -61,9 +62,10 @@ class ThresholdSensorImpl implements ThresholdSensor { } }; private ThresholdSensorImpl(AsyncSensorManager sensorManager, Sensor sensor, float threshold, float thresholdLatch, int sensorDelay) { private ThresholdSensorImpl(AsyncSensorManager sensorManager, Sensor sensor, Execution execution, float threshold, float thresholdLatch, int sensorDelay) { mSensorManager = sensorManager; mExecution = execution; mSensor = sensor; mThreshold = threshold; mThresholdLatch = thresholdLatch; Loading Loading @@ -107,7 +109,7 @@ class ThresholdSensorImpl implements ThresholdSensor { */ @Override public void register(Listener listener) { Assert.isMainThread(); mExecution.assertIsMainThread(); if (!mListeners.contains(listener)) { mListeners.add(listener); } Loading @@ -116,7 +118,7 @@ class ThresholdSensorImpl implements ThresholdSensor { @Override public void unregister(Listener listener) { Assert.isMainThread(); mExecution.assertIsMainThread(); mListeners.remove(listener); unregisterInternal(); } Loading @@ -126,7 +128,7 @@ class ThresholdSensorImpl implements ThresholdSensor { */ @Override public void pause() { Assert.isMainThread(); mExecution.assertIsMainThread(); mPaused = true; unregisterInternal(); } Loading @@ -136,7 +138,7 @@ class ThresholdSensorImpl implements ThresholdSensor { */ @Override public void resume() { Assert.isMainThread(); mExecution.assertIsMainThread(); mPaused = false; registerInternal(); } Loading @@ -148,7 +150,7 @@ class ThresholdSensorImpl implements ThresholdSensor { } private void registerInternal() { Assert.isMainThread(); mExecution.assertIsMainThread(); if (mRegistered || mPaused || mListeners.isEmpty()) { return; } Loading @@ -158,7 +160,7 @@ class ThresholdSensorImpl implements ThresholdSensor { } private void unregisterInternal() { Assert.isMainThread(); mExecution.assertIsMainThread(); if (!mRegistered) { return; } Loading @@ -177,7 +179,7 @@ class ThresholdSensorImpl implements ThresholdSensor { * still appears entirely binary. */ private void onSensorEvent(boolean belowThreshold, boolean aboveThreshold, long timestampNs) { Assert.isMainThread(); mExecution.assertIsMainThread(); if (!mRegistered) { return; } Loading Loading @@ -212,6 +214,7 @@ class ThresholdSensorImpl implements ThresholdSensor { static class Builder { private final Resources mResources; private final AsyncSensorManager mSensorManager; private final Execution mExecution; private int mSensorDelay = SensorManager.SENSOR_DELAY_NORMAL;; private float mThresholdValue; private float mThresholdLatchValue; Loading @@ -221,9 +224,10 @@ class ThresholdSensorImpl implements ThresholdSensor { private boolean mThresholdLatchValueSet; @Inject Builder(@Main Resources resources, AsyncSensorManager sensorManager) { Builder(@Main Resources resources, AsyncSensorManager sensorManager, Execution execution) { mResources = resources; mSensorManager = sensorManager; mExecution = execution; } Loading Loading @@ -302,7 +306,8 @@ class ThresholdSensorImpl implements ThresholdSensor { } return new ThresholdSensorImpl( mSensorManager, mSensor, mThresholdValue, mThresholdLatchValue, mSensorDelay); mSensorManager, mSensor, mExecution, mThresholdValue, mThresholdLatchValue, mSensorDelay); } private Sensor findSensorByType(String sensorType) { Loading
packages/SystemUI/tests/src/com/android/systemui/util/sensors/FakeProximitySensor.java +2 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.util.sensors; import com.android.systemui.util.concurrency.DelayableExecutor; import com.android.systemui.util.concurrency.FakeExecution; public class FakeProximitySensor extends ProximitySensor { private boolean mAvailable; Loading @@ -25,7 +26,7 @@ public class FakeProximitySensor extends ProximitySensor { public FakeProximitySensor(ThresholdSensor primary, ThresholdSensor secondary, DelayableExecutor delayableExecutor) { super(primary, secondary == null ? new FakeThresholdSensor() : secondary, delayableExecutor); delayableExecutor, new FakeExecution()); mAvailable = true; } Loading
packages/SystemUI/tests/src/com/android/systemui/util/sensors/ProximitySensorDualTest.java +5 −2 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.testing.TestableLooper; import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; import com.android.systemui.util.concurrency.FakeExecution; import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.time.FakeSystemClock; Loading Loading @@ -54,7 +55,8 @@ public class ProximitySensorDualTest extends SysuiTestCase { mThresholdSensorSecondary.setLoaded(true); mProximitySensor = new ProximitySensor( mThresholdSensorPrimary, mThresholdSensorSecondary, mFakeExecutor); mThresholdSensorPrimary, mThresholdSensorSecondary, mFakeExecutor, new FakeExecution()); } @Test Loading Loading @@ -324,9 +326,10 @@ public class ProximitySensorDualTest extends SysuiTestCase { TestableListener listener = new TestableListener(); // WE immediately register the secondary sensor. mProximitySensor.register(listener); assertFalse(mThresholdSensorPrimary.isPaused()); assertTrue(mThresholdSensorSecondary.isPaused()); assertFalse(mThresholdSensorSecondary.isPaused()); assertNull(listener.mLastEvent); assertEquals(0, listener.mCallCount); Loading
packages/SystemUI/tests/src/com/android/systemui/util/sensors/ProximitySensorSingleTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.testing.TestableLooper; import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; import com.android.systemui.util.concurrency.FakeExecution; import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.time.FakeSystemClock; Loading Loading @@ -54,7 +55,7 @@ public class ProximitySensorSingleTest extends SysuiTestCase { mThresholdSensor.setLoaded(true); mProximitySensor = new ProximitySensor( mThresholdSensor, new FakeThresholdSensor(), mFakeExecutor); mThresholdSensor, new FakeThresholdSensor(), mFakeExecutor, new FakeExecution()); } @Test Loading