Merge "ActiveUnlock: run wake_unfolded logic on OPENED" into tm-qpr-dev

This commit is contained in:
Beverly Tai
2023-03-20 16:54:52 +00:00
committed by Android (Google) Code Review
3 changed files with 94 additions and 17 deletions

View File

@@ -68,6 +68,7 @@ import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_STARTED_WAK
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_STRONG_AUTH_CHANGED;
import static com.android.keyguard.FaceAuthUiEvent.FACE_AUTH_UPDATED_USER_SWITCHING;
import static com.android.systemui.DejankUtils.whitelistIpcs;
import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_OPENED;
import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_UNKNOWN;
import android.annotation.AnyThread;
@@ -1862,6 +1863,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
updateFaceListeningState(BIOMETRIC_ACTION_STOP,
FACE_AUTH_UPDATED_POSTURE_CHANGED);
}
if (mPostureState == DEVICE_POSTURE_OPENED) {
mLogger.d("Posture changed to open - attempting to request active unlock");
requestActiveUnlockFromWakeReason(PowerManager.WAKE_REASON_UNFOLD_DEVICE,
false);
}
}
};
@@ -1988,26 +1994,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
FACE_AUTH_UPDATED_STARTED_WAKING_UP.setExtraInfo(pmWakeReason);
updateFaceListeningState(BIOMETRIC_ACTION_UPDATE,
FACE_AUTH_UPDATED_STARTED_WAKING_UP);
final ActiveUnlockConfig.ActiveUnlockRequestOrigin requestOrigin =
mActiveUnlockConfig.isWakeupConsideredUnlockIntent(pmWakeReason)
? ActiveUnlockConfig.ActiveUnlockRequestOrigin.UNLOCK_INTENT
: ActiveUnlockConfig.ActiveUnlockRequestOrigin.WAKE;
final String reason = "wakingUp - " + PowerManager.wakeReasonToString(pmWakeReason);
if (mActiveUnlockConfig.shouldWakeupForceDismissKeyguard(pmWakeReason)) {
requestActiveUnlockDismissKeyguard(
requestOrigin,
reason
);
} else {
requestActiveUnlock(
requestOrigin,
reason
);
}
} else {
mLogger.logSkipUpdateFaceListeningOnWakeup(pmWakeReason);
}
requestActiveUnlockFromWakeReason(pmWakeReason, true);
for (int i = 0; i < mCallbacks.size(); i++) {
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
@@ -2640,6 +2630,32 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
}
}
private void requestActiveUnlockFromWakeReason(@PowerManager.WakeReason int wakeReason,
boolean powerManagerWakeup) {
if (!mFaceWakeUpTriggersConfig.shouldTriggerFaceAuthOnWakeUpFrom(wakeReason)) {
mLogger.logActiveUnlockRequestSkippedForWakeReasonDueToFaceConfig(wakeReason);
return;
}
final ActiveUnlockConfig.ActiveUnlockRequestOrigin requestOrigin =
mActiveUnlockConfig.isWakeupConsideredUnlockIntent(wakeReason)
? ActiveUnlockConfig.ActiveUnlockRequestOrigin.UNLOCK_INTENT
: ActiveUnlockConfig.ActiveUnlockRequestOrigin.WAKE;
final String reason = "wakingUp - " + PowerManager.wakeReasonToString(wakeReason)
+ " powerManagerWakeup=" + powerManagerWakeup;
if (mActiveUnlockConfig.shouldWakeupForceDismissKeyguard(wakeReason)) {
requestActiveUnlockDismissKeyguard(
requestOrigin,
reason
);
} else {
requestActiveUnlock(
requestOrigin,
reason
);
}
}
/**
* Attempts to trigger active unlock from trust agent.
*/

View File

@@ -62,6 +62,16 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
)
}
fun logActiveUnlockRequestSkippedForWakeReasonDueToFaceConfig(wakeReason: Int) {
logBuffer.log(
"ActiveUnlock",
DEBUG,
{ int1 = wakeReason },
{ "Skip requesting active unlock from wake reason that doesn't trigger face auth" +
" reason=${PowerManager.wakeReasonToString(int1)}" }
)
}
fun logAuthInterruptDetected(active: Boolean) {
logBuffer.log(TAG, DEBUG, { bool1 = active }, { "onAuthInterruptDetected($bool1)" })
}

View File

@@ -2432,6 +2432,57 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
eq(false));
}
@Test
public void unfoldFromPostureChange_requestActiveUnlock_forceDismissKeyguard()
throws RemoteException {
// GIVEN shouldTriggerActiveUnlock
keyguardIsVisible();
when(mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser())).thenReturn(true);
// GIVEN active unlock triggers on wakeup
when(mActiveUnlockConfig.shouldAllowActiveUnlockFromOrigin(
ActiveUnlockConfig.ActiveUnlockRequestOrigin.WAKE))
.thenReturn(true);
// GIVEN an unfold should force dismiss the keyguard
when(mActiveUnlockConfig.shouldWakeupForceDismissKeyguard(
PowerManager.WAKE_REASON_UNFOLD_DEVICE)).thenReturn(true);
// WHEN device posture changes to unfold
deviceInPostureStateOpened();
mTestableLooper.processAllMessages();
// THEN request unlock with a keyguard dismissal
verify(mTrustManager).reportUserRequestedUnlock(eq(KeyguardUpdateMonitor.getCurrentUser()),
eq(true));
}
@Test
public void unfoldFromPostureChange_requestActiveUnlock_noDismissKeyguard()
throws RemoteException {
// GIVEN shouldTriggerActiveUnlock on wake from UNFOLD_DEVICE
keyguardIsVisible();
when(mLockPatternUtils.isSecure(KeyguardUpdateMonitor.getCurrentUser())).thenReturn(true);
// GIVEN active unlock triggers on wakeup
when(mActiveUnlockConfig.shouldAllowActiveUnlockFromOrigin(
ActiveUnlockConfig.ActiveUnlockRequestOrigin.WAKE))
.thenReturn(true);
// GIVEN an unfold should NOT force dismiss the keyguard
when(mActiveUnlockConfig.shouldWakeupForceDismissKeyguard(
PowerManager.WAKE_REASON_UNFOLD_DEVICE)).thenReturn(false);
// WHEN device posture changes to unfold
deviceInPostureStateOpened();
mTestableLooper.processAllMessages();
// THEN request unlock WITHOUT a keyguard dismissal
verify(mTrustManager).reportUserRequestedUnlock(eq(KeyguardUpdateMonitor.getCurrentUser()),
eq(false));
}
@Test
public void detectFingerprint_onTemporaryLockoutReset_authenticateFingerprint() {
ArgumentCaptor<FingerprintManager.LockoutResetCallback> fpLockoutResetCallbackCaptor =