<!-- Doze: duration to avoid false pickup gestures triggered by notification vibrations -->
<integer name="doze_pickup_vibration_threshold">2000</integer>
- <!-- Doze: can we assume the pickup sensor includes a proximity check? -->
- <bool name="doze_pickup_performs_proximity_check">false</bool>
-
<!-- Type of a sensor that provides a low-power estimate of the desired display
brightness, suitable to listen to while the device is asleep (e.g. during
always-on display) -->
config.dozePickupSensorAvailable(),
DozeLog.REASON_SENSOR_PICKUP, false /* touchCoords */,
false /* touchscreen */,
- false /* ignoresSetting */,
- mDozeParameters.getPickupPerformsProxCheck()),
+ false /* ignoresSetting */),
new TriggerSensor(
findSensorWithType(config.doubleTapSensorType()),
Settings.Secure.DOZE_DOUBLE_TAP_GESTURE,
public void updateListening() {
boolean anyListening = false;
for (TriggerSensor s : mSensors) {
- // We don't want to be listening while we're PAUSED (prox sensor is covered)
- // except when the sensor is already gated by prox.
- boolean listen = mListening && (!mPaused || s.performsProxCheck());
- s.setListening(listen);
- if (listen) {
+ s.setListening(mListening);
+ if (mListening) {
anyListening = true;
}
}
private final boolean mReportsTouchCoordinates;
private final boolean mSettingDefault;
private final boolean mRequiresTouchscreen;
- private final boolean mSensorPerformsProxCheck;
protected boolean mRequested;
protected boolean mRegistered;
boolean configured, int pulseReason, boolean reportsTouchCoordinates,
boolean requiresTouchscreen) {
this(sensor, setting, settingDef, configured, pulseReason, reportsTouchCoordinates,
- requiresTouchscreen, false /* ignoresSetting */,
- false /* sensorPerformsProxCheck */);
+ requiresTouchscreen, false /* ignoresSetting */);
}
private TriggerSensor(Sensor sensor, String setting, boolean settingDef,
boolean configured, int pulseReason, boolean reportsTouchCoordinates,
- boolean requiresTouchscreen, boolean ignoresSetting,
- boolean sensorPerformsProxCheck) {
+ boolean requiresTouchscreen, boolean ignoresSetting) {
mSensor = sensor;
mSetting = setting;
mSettingDefault = settingDef;
mReportsTouchCoordinates = reportsTouchCoordinates;
mRequiresTouchscreen = requiresTouchscreen;
mIgnoresSetting = ignoresSetting;
- mSensorPerformsProxCheck = sensorPerformsProxCheck;
}
public void setListening(boolean listen) {
screenX = event.values[0];
screenY = event.values[1];
}
- mCallback.onSensorPulse(mPulseReason, mSensorPerformsProxCheck, screenX, screenY,
- event.values);
+ mCallback.onSensorPulse(mPulseReason, screenX, screenY, event.values);
if (!mRegistered) {
updateListening(); // reregister, this sensor only fires once
}
}));
}
- /**
- * If the sensor itself performs proximity checks, to avoid pocket dialing.
- * Gated sensors don't need to be stopped when the {@link DozeMachine} is
- * {@link DozeMachine.State#DOZE_AOD_PAUSED}.
- */
- public boolean performsProxCheck() {
- return mSensorPerformsProxCheck;
- }
-
public void registerSettingsObserver(ContentObserver settingsObserver) {
if (mConfigured && !TextUtils.isEmpty(mSetting)) {
mResolver.registerContentObserver(
return;
}
if (DEBUG) Log.d(TAG, "onSensorEvent: " + triggerEventToString(event));
- mCallback.onSensorPulse(mPulseReason, true /* sensorPerformsProxCheck */, -1, -1,
- event.getValues());
+ mCallback.onSensorPulse(mPulseReason, -1, -1, event.getValues());
}));
}
}
/**
* Called when a sensor requests a pulse
* @param pulseReason Requesting sensor, e.g. {@link DozeLog#REASON_SENSOR_PICKUP}
- * @param sensorPerformedProxCheck true if the sensor already checked for FAR proximity.
* @param screenX the location on the screen where the sensor fired or -1
- * if the sensor doesn't support reporting screen locations.
+ * if the sensor doesn't support reporting screen locations.
* @param screenY the location on the screen where the sensor fired or -1
* @param rawValues raw values array from the event.
*/
- void onSensorPulse(int pulseReason, boolean sensorPerformedProxCheck,
- float screenX, float screenY, float[] rawValues);
+ void onSensorPulse(int pulseReason, float screenX, float screenY, float[] rawValues);
}
}
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.internal.util.Preconditions;
import com.android.systemui.Dependency;
+import com.android.systemui.R;
import com.android.systemui.dock.DockManager;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.util.Assert;
}
@VisibleForTesting
- void onSensor(int pulseReason, boolean sensorPerformedProxCheck,
- float screenX, float screenY, float[] rawValues) {
+ void onSensor(int pulseReason, float screenX, float screenY, float[] rawValues) {
boolean isDoubleTap = pulseReason == DozeLog.REASON_SENSOR_DOUBLE_TAP;
boolean isTap = pulseReason == DozeLog.REASON_SENSOR_TAP;
boolean isPickup = pulseReason == DozeLog.REASON_SENSOR_PICKUP;
if (isWakeDisplay) {
onWakeScreen(wakeEvent, mMachine.isExecutingTransition() ? null : mMachine.getState());
} else if (isLongPress) {
- requestPulse(pulseReason, sensorPerformedProxCheck, null /* onPulseSupressedListener */);
+ requestPulse(pulseReason, true /* alreadyPerformedProxCheck */,
+ null /* onPulseSupressedListener */);
} else if (isWakeLockScreen) {
if (wakeEvent) {
- requestPulse(pulseReason, sensorPerformedProxCheck,
+ requestPulse(pulseReason, true /* alreadyPerformedProxCheck */,
null /* onPulseSupressedListener */);
}
} else {
} else {
mDozeHost.extendPulse(pulseReason);
}
- }, sensorPerformedProxCheck
- || (mDockManager != null && mDockManager.isDocked()), pulseReason);
+ }, true /* alreadyPerformedProxCheck */, pulseReason);
}
if (isPickup) {
.setType(MetricsEvent.TYPE_OPEN)
.setSubtype(DozeLog.REASON_SENSOR_WAKE_UP));
}
- }, false /* alreadyPerformedProxCheck */, DozeLog.REASON_SENSOR_WAKE_UP);
+ }, true /* alreadyPerformedProxCheck */, DozeLog.REASON_SENSOR_WAKE_UP);
} else {
boolean paused = (state == DozeMachine.State.DOZE_AOD_PAUSED);
boolean pausing = (state == DozeMachine.State.DOZE_AOD_PAUSING);
public void check() {
Preconditions.checkState(!mFinished && !mRegistered);
- final Sensor sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
+ Sensor sensor = DozeSensors.findSensorWithType(mSensorManager,
+ mContext.getString(R.string.doze_brightness_sensor_type));
+ if (sensor == null) {
+ sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
+ }
if (sensor == null) {
if (DozeMachine.DEBUG) Log.d(TAG, "ProxCheck: No sensor found");
finishWithResult(RESULT_UNKNOWN);
return SystemProperties.get(propName, mContext.getString(resId));
}
- public boolean getPickupPerformsProxCheck() {
- return mContext.getResources().getBoolean(R.bool.doze_pickup_performs_proximity_check);
- }
-
public int getPulseVisibleDurationExtended() {
return 2 * getPulseVisibleDuration();
}
when(params.getPulseOnSigMotion()).thenReturn(false);
when(params.getPickupVibrationThreshold()).thenReturn(0);
when(params.getProxCheckBeforePulse()).thenReturn(true);
- when(params.getPickupPerformsProxCheck()).thenReturn(true);
when(params.getPolicy()).thenReturn(mock(AlwaysOnDisplayPolicy.class));
when(params.doubleTapReportsTouchCoordinates()).thenReturn(false);
when(params.getDisplayNeedsBlanking()).thenReturn(false);
import static com.android.systemui.plugins.SensorManagerPlugin.Sensor.TYPE_WAKE_LOCK_SCREEN;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
private AlwaysOnDisplayPolicy mAlwaysOnDisplayPolicy;
@Mock
private TriggerSensor mTriggerSensor;
- @Mock
- private TriggerSensor mProxGatedTriggerSensor;
private SensorManagerPlugin.SensorEventListener mWakeLockScreenListener;
private TestableLooper mTestableLooper;
private DozeSensors mDozeSensors;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
- when(mProxGatedTriggerSensor.performsProxCheck()).thenReturn(true);
mTestableLooper = TestableLooper.get(this);
when(mAmbientDisplayConfiguration.getWakeLockScreenDebounce()).thenReturn(5000L);
when(mAmbientDisplayConfiguration.alwaysOnEnabled(anyInt())).thenReturn(true);
mWakeLockScreenListener.onSensorChanged(mock(SensorManagerPlugin.SensorEvent.class));
mTestableLooper.processAllMessages();
verify(mCallback).onSensorPulse(eq(DozeLog.PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN),
- anyBoolean(), anyFloat(), anyFloat(), eq(null));
+ anyFloat(), anyFloat(), eq(null));
mDozeSensors.requestTemporaryDisable();
reset(mCallback);
mWakeLockScreenListener.onSensorChanged(mock(SensorManagerPlugin.SensorEvent.class));
mTestableLooper.processAllMessages();
verify(mCallback, never()).onSensorPulse(eq(DozeLog.PULSE_REASON_SENSOR_WAKE_LOCK_SCREEN),
- anyBoolean(), anyFloat(), anyFloat(), eq(null));
+ anyFloat(), anyFloat(), eq(null));
}
@Test
}
@Test
- public void testSetPaused_onlyPausesNonGatedSensors() {
+ public void testSetPaused_doesntPause_sensors() {
mDozeSensors.setListening(true);
verify(mTriggerSensor).setListening(eq(true));
- verify(mProxGatedTriggerSensor).setListening(eq(true));
- clearInvocations(mTriggerSensor, mProxGatedTriggerSensor);
+ clearInvocations(mTriggerSensor);
mDozeSensors.setPaused(true);
- verify(mTriggerSensor).setListening(eq(false));
- verify(mProxGatedTriggerSensor).setListening(eq(true));
-
- clearInvocations(mTriggerSensor, mProxGatedTriggerSensor);
- mDozeSensors.setPaused(false);
verify(mTriggerSensor).setListening(eq(true));
- verify(mProxGatedTriggerSensor).setListening(eq(true));
+
+ clearInvocations(mTriggerSensor);
+ mDozeSensors.setListening(false);
+ verify(mTriggerSensor).setListening(eq(false));
}
private class TestableDozeSensors extends DozeSensors {
mWakeLockScreenListener = (PluginSensor) sensor;
}
}
- mSensors = new TriggerSensor[] {mTriggerSensor, mProxGatedTriggerSensor};
+ mSensors = new TriggerSensor[] {mTriggerSensor};
}
}
}
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.clearInvocations;
-import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
mTriggers.transitionTo(DozeMachine.State.DOZE, DozeMachine.State.FINISH);
verify(mDockManagerFake).removeListener(any());
}
-
- @Test
- public void testOnSensor_whenUndockedWithNearAndDoubleTapScreen_shouldNotWakeUp() {
- mSensors.getMockProximitySensor().sendProximityResult(false /* far */);
-
- mTriggers.onSensor(DozeLog.REASON_SENSOR_DOUBLE_TAP,
- false /* sensorPerformedProxCheck */, 50 /* screenX */, 50 /* screenY */,
- null /* rawValues */);
- verify(mMachine, never()).wakeUp();
- }
-
- @Test
- public void testOnSensor_whenDockedWithNearAndDoubleTapScreen_shouldWakeUp() {
- doReturn(true).when(mDockManagerFake).isDocked();
- doReturn(true).when(mParameters).getDisplayNeedsBlanking();
- mSensors.getMockProximitySensor().sendProximityResult(false /* far */);
-
- mTriggers.onSensor(DozeLog.REASON_SENSOR_DOUBLE_TAP,
- false /* sensorPerformedProxCheck */, 50 /* screenX */, 50 /* screenY */,
- null /* rawValues */);
-
- verify(mHost).setAodDimmingScrim(eq(1f));
- verify(mMachine).wakeUp();
- }
}