Merge "Send AOD auth interrupt only after display state is ON" into sc-dev am: 7ed65c1d49

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14984537

Change-Id: Ib5853c5ed44ef597d7b4896afafcf0026dd6c39e
This commit is contained in:
Beverly Tai
2021-06-17 19:41:37 +00:00
committed by Automerger Merge Worker
2 changed files with 40 additions and 7 deletions

View File

@@ -38,6 +38,7 @@ import com.android.systemui.biometrics.AuthController;
import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dock.DockManager; import com.android.systemui.dock.DockManager;
import com.android.systemui.doze.DozeMachine.State;
import com.android.systemui.doze.dagger.DozeScope; import com.android.systemui.doze.dagger.DozeScope;
import com.android.systemui.statusbar.phone.DozeParameters; import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.util.Assert; import com.android.systemui.util.Assert;
@@ -96,6 +97,7 @@ public class DozeTriggers implements DozeMachine.Part {
private long mNotificationPulseTime; private long mNotificationPulseTime;
private boolean mPulsePending; private boolean mPulsePending;
private Runnable mAodInterruptRunnable;
/** see {@link #onProximityFar} prox for callback */ /** see {@link #onProximityFar} prox for callback */
private boolean mWantProxSensor; private boolean mWantProxSensor;
@@ -303,11 +305,16 @@ public class DozeTriggers implements DozeMachine.Part {
} else if (isPickup) { } else if (isPickup) {
gentleWakeUp(pulseReason); gentleWakeUp(pulseReason);
} else if (isUdfpsLongPress) { } else if (isUdfpsLongPress) {
final State state = mMachine.getState();
if (state == State.DOZE_AOD || state == State.DOZE) {
// Since the gesture won't be received by the UDFPS view, we need to
// manually inject an event once the display is ON
mAodInterruptRunnable = () ->
mAuthController.onAodInterrupt((int) screenX, (int) screenY,
rawValues[3] /* major */, rawValues[4] /* minor */);
}
requestPulse(DozeLog.REASON_SENSOR_UDFPS_LONG_PRESS, true, null); requestPulse(DozeLog.REASON_SENSOR_UDFPS_LONG_PRESS, true, null);
// Since the gesture won't be received by the UDFPS view, manually inject an
// event.
mAuthController.onAodInterrupt((int) screenX, (int) screenY,
rawValues[3] /* major */, rawValues[4] /* minor */);
} else { } else {
mDozeHost.extendPulse(pulseReason); mDozeHost.extendPulse(pulseReason);
} }
@@ -439,6 +446,7 @@ public class DozeTriggers implements DozeMachine.Part {
public void transitionTo(DozeMachine.State oldState, DozeMachine.State newState) { public void transitionTo(DozeMachine.State oldState, DozeMachine.State newState) {
switch (newState) { switch (newState) {
case INITIALIZED: case INITIALIZED:
mAodInterruptRunnable = null;
sWakeDisplaySensorState = true; sWakeDisplaySensorState = true;
mBroadcastReceiver.register(mBroadcastDispatcher); mBroadcastReceiver.register(mBroadcastDispatcher);
mDozeHost.addCallback(mHostCallback); mDozeHost.addCallback(mHostCallback);
@@ -448,6 +456,7 @@ public class DozeTriggers implements DozeMachine.Part {
break; break;
case DOZE: case DOZE:
case DOZE_AOD: case DOZE_AOD:
mAodInterruptRunnable = null;
mWantProxSensor = newState != DozeMachine.State.DOZE; mWantProxSensor = newState != DozeMachine.State.DOZE;
mWantSensors = true; mWantSensors = true;
mWantTouchScreenSensors = true; mWantTouchScreenSensors = true;
@@ -494,6 +503,11 @@ public class DozeTriggers implements DozeMachine.Part {
|| state == Display.STATE_DOZE_SUSPEND || state == Display.STATE_OFF; || state == Display.STATE_DOZE_SUSPEND || state == Display.STATE_OFF;
mDozeSensors.setProxListening(mWantProxSensor && lowPowerStateOrOff); mDozeSensors.setProxListening(mWantProxSensor && lowPowerStateOrOff);
mDozeSensors.setListening(mWantSensors, mWantTouchScreenSensors, lowPowerStateOrOff); mDozeSensors.setListening(mWantSensors, mWantTouchScreenSensors, lowPowerStateOrOff);
if (mAodInterruptRunnable != null && state == Display.STATE_ON) {
mAodInterruptRunnable.run();
mAodInterruptRunnable = null;
}
} }
/** /**
@@ -576,6 +590,8 @@ public class DozeTriggers implements DozeMachine.Part {
@Override @Override
public void dump(PrintWriter pw) { public void dump(PrintWriter pw) {
pw.println(" mAodInterruptRunnable=" + mAodInterruptRunnable);
pw.print(" notificationPulseTime="); pw.print(" notificationPulseTime=");
pw.println(Formatter.formatShortElapsedTime(mContext, mNotificationPulseTime)); pw.println(Formatter.formatShortElapsedTime(mContext, mNotificationPulseTime));

View File

@@ -16,7 +16,10 @@
package com.android.systemui.doze; package com.android.systemui.doze;
import static com.android.systemui.doze.DozeMachine.State.DOZE_AOD;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.clearInvocations;
@@ -161,7 +164,7 @@ public class DozeTriggersTest extends SysuiTestCase {
clearInvocations(mSensors); clearInvocations(mSensors);
mTriggers.transitionTo(DozeMachine.State.DOZE_PULSING, DozeMachine.State.DOZE_PULSE_DONE); mTriggers.transitionTo(DozeMachine.State.DOZE_PULSING, DozeMachine.State.DOZE_PULSE_DONE);
mTriggers.transitionTo(DozeMachine.State.DOZE_PULSE_DONE, DozeMachine.State.DOZE_AOD); mTriggers.transitionTo(DozeMachine.State.DOZE_PULSE_DONE, DOZE_AOD);
waitForSensorManager(); waitForSensorManager();
verify(mSensors).requestTriggerSensor(any(), eq(mTapSensor)); verify(mSensors).requestTriggerSensor(any(), eq(mTapSensor));
} }
@@ -207,7 +210,7 @@ public class DozeTriggersTest extends SysuiTestCase {
mTriggers.onSensor(DozeLog.REASON_SENSOR_QUICK_PICKUP, 100, 100, null); mTriggers.onSensor(DozeLog.REASON_SENSOR_QUICK_PICKUP, 100, 100, null);
// THEN device goes into aod (shows clock with black background) // THEN device goes into aod (shows clock with black background)
verify(mMachine).requestState(DozeMachine.State.DOZE_AOD); verify(mMachine).requestState(DOZE_AOD);
// THEN a log is taken that quick pick up was triggered // THEN a log is taken that quick pick up was triggered
verify(mUiEventLogger).log(DozingUpdateUiEvent.DOZING_UPDATE_QUICK_PICKUP); verify(mUiEventLogger).log(DozingUpdateUiEvent.DOZING_UPDATE_QUICK_PICKUP);
@@ -218,7 +221,7 @@ public class DozeTriggersTest extends SysuiTestCase {
// GIVEN quick pickup is triggered when device is in DOZE // GIVEN quick pickup is triggered when device is in DOZE
when(mMachine.getState()).thenReturn(DozeMachine.State.DOZE); when(mMachine.getState()).thenReturn(DozeMachine.State.DOZE);
mTriggers.onSensor(DozeLog.REASON_SENSOR_QUICK_PICKUP, 100, 100, null); mTriggers.onSensor(DozeLog.REASON_SENSOR_QUICK_PICKUP, 100, 100, null);
verify(mMachine).requestState(DozeMachine.State.DOZE_AOD); verify(mMachine).requestState(DOZE_AOD);
verify(mMachine, never()).requestState(DozeMachine.State.DOZE); verify(mMachine, never()).requestState(DozeMachine.State.DOZE);
// WHEN next executable is run // WHEN next executable is run
@@ -234,6 +237,8 @@ public class DozeTriggersTest extends SysuiTestCase {
@Test @Test
public void testOnSensor_Fingerprint() { public void testOnSensor_Fingerprint() {
// GIVEN dozing state
when(mMachine.getState()).thenReturn(DOZE_AOD);
final int screenX = 100; final int screenX = 100;
final int screenY = 100; final int screenY = 100;
final float misc = -1; final float misc = -1;
@@ -241,8 +246,20 @@ public class DozeTriggersTest extends SysuiTestCase {
final float major = 3f; final float major = 3f;
final int reason = DozeLog.REASON_SENSOR_UDFPS_LONG_PRESS; final int reason = DozeLog.REASON_SENSOR_UDFPS_LONG_PRESS;
float[] rawValues = new float[]{screenX, screenY, misc, major, minor}; float[] rawValues = new float[]{screenX, screenY, misc, major, minor};
// WHEN longpress gesture is triggered
mTriggers.onSensor(reason, screenX, screenY, rawValues); mTriggers.onSensor(reason, screenX, screenY, rawValues);
// THEN
// * don't immediately send interrupt
// * immediately extend pulse
verify(mAuthController, never()).onAodInterrupt(anyInt(), anyInt(), anyFloat(), anyFloat());
verify(mHost).extendPulse(reason); verify(mHost).extendPulse(reason);
// WHEN display state changes to ON
mTriggers.onScreenState(Display.STATE_ON);
// THEN send interrupt
verify(mAuthController).onAodInterrupt(eq(screenX), eq(screenY), eq(major), eq(minor)); verify(mAuthController).onAodInterrupt(eq(screenX), eq(screenY), eq(major), eq(minor));
} }