Stop face auth when we transition to unsupported posture, no-op otherwise on posture change.

Fixes: 262492399
Test: atest KeyguardUpdateMonitorTest
Test: manually,
  1. enroll face auth
  2. Go to an face auth unsupported posture for the device
  3. Go to a face auth supported posture for the device
  4. Check the logs to make sure face auth wasn't triggered momentarily.
Change-Id: Ic96ddde93d1f45c1bf667d6b32193e754a79bf06
This commit is contained in:
Chandru S
2023-03-02 02:18:37 -08:00
parent 91bae30e7b
commit 98769357a3
3 changed files with 46 additions and 8 deletions

View File

@@ -40,7 +40,7 @@ data class KeyguardFaceListenModel(
var keyguardGoingAway: Boolean = false, var keyguardGoingAway: Boolean = false,
var listeningForFaceAssistant: Boolean = false, var listeningForFaceAssistant: Boolean = false,
var occludingAppRequestingFaceAuth: Boolean = false, var occludingAppRequestingFaceAuth: Boolean = false,
val postureAllowsListening: Boolean = false, var postureAllowsListening: Boolean = false,
var primaryUser: Boolean = false, var primaryUser: Boolean = false,
var secureCameraLaunched: Boolean = false, var secureCameraLaunched: Boolean = false,
var supportsDetect: Boolean = false, var supportsDetect: Boolean = false,
@@ -70,6 +70,7 @@ data class KeyguardFaceListenModel(
listeningForFaceAssistant.toString(), listeningForFaceAssistant.toString(),
occludingAppRequestingFaceAuth.toString(), occludingAppRequestingFaceAuth.toString(),
primaryUser.toString(), primaryUser.toString(),
postureAllowsListening.toString(),
secureCameraLaunched.toString(), secureCameraLaunched.toString(),
supportsDetect.toString(), supportsDetect.toString(),
switchingUser.toString(), switchingUser.toString(),
@@ -109,6 +110,7 @@ data class KeyguardFaceListenModel(
listeningForFaceAssistant = model.listeningForFaceAssistant listeningForFaceAssistant = model.listeningForFaceAssistant
occludingAppRequestingFaceAuth = model.occludingAppRequestingFaceAuth occludingAppRequestingFaceAuth = model.occludingAppRequestingFaceAuth
primaryUser = model.primaryUser primaryUser = model.primaryUser
postureAllowsListening = model.postureAllowsListening
secureCameraLaunched = model.secureCameraLaunched secureCameraLaunched = model.secureCameraLaunched
supportsDetect = model.supportsDetect supportsDetect = model.supportsDetect
switchingUser = model.switchingUser switchingUser = model.switchingUser
@@ -152,6 +154,7 @@ data class KeyguardFaceListenModel(
"listeningForFaceAssistant", "listeningForFaceAssistant",
"occludingAppRequestingFaceAuth", "occludingAppRequestingFaceAuth",
"primaryUser", "primaryUser",
"postureAllowsListening",
"secureCameraLaunched", "secureCameraLaunched",
"supportsDetect", "supportsDetect",
"switchingUser", "switchingUser",

View File

@@ -160,6 +160,7 @@ import com.android.systemui.shared.system.TaskStackChangeListeners;
import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.policy.DevicePostureController; import com.android.systemui.statusbar.policy.DevicePostureController;
import com.android.systemui.statusbar.policy.DevicePostureController.DevicePostureInt;
import com.android.systemui.telephony.TelephonyListenerManager; import com.android.systemui.telephony.TelephonyListenerManager;
import com.android.systemui.util.Assert; import com.android.systemui.util.Assert;
import com.android.systemui.util.settings.SecureSettings; import com.android.systemui.util.settings.SecureSettings;
@@ -368,7 +369,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
private final FaceManager mFaceManager; private final FaceManager mFaceManager;
private final LockPatternUtils mLockPatternUtils; private final LockPatternUtils mLockPatternUtils;
@VisibleForTesting @VisibleForTesting
@DevicePostureController.DevicePostureInt @DevicePostureInt
protected int mConfigFaceAuthSupportedPosture; protected int mConfigFaceAuthSupportedPosture;
private KeyguardBypassController mKeyguardBypassController; private KeyguardBypassController mKeyguardBypassController;
@@ -1862,11 +1863,16 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
final DevicePostureController.Callback mPostureCallback = final DevicePostureController.Callback mPostureCallback =
new DevicePostureController.Callback() { new DevicePostureController.Callback() {
@Override @Override
public void onPostureChanged(int posture) { public void onPostureChanged(@DevicePostureInt int posture) {
boolean currentPostureAllowsFaceAuth = doesPostureAllowFaceAuth(mPostureState);
boolean newPostureAllowsFaceAuth = doesPostureAllowFaceAuth(posture);
mPostureState = posture; mPostureState = posture;
updateFaceListeningState(BIOMETRIC_ACTION_UPDATE, if (currentPostureAllowsFaceAuth && !newPostureAllowsFaceAuth) {
mLogger.d("New posture does not allow face auth, stopping it");
updateFaceListeningState(BIOMETRIC_ACTION_STOP,
FACE_AUTH_UPDATED_POSTURE_CHANGED); FACE_AUTH_UPDATED_POSTURE_CHANGED);
} }
}
}; };
@VisibleForTesting @VisibleForTesting
@@ -2901,9 +2907,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
final boolean biometricEnabledForUser = mBiometricEnabledForUser.get(user); final boolean biometricEnabledForUser = mBiometricEnabledForUser.get(user);
final boolean shouldListenForFaceAssistant = shouldListenForFaceAssistant(); final boolean shouldListenForFaceAssistant = shouldListenForFaceAssistant();
final boolean isUdfpsFingerDown = mAuthController.isUdfpsFingerDown(); final boolean isUdfpsFingerDown = mAuthController.isUdfpsFingerDown();
final boolean isPostureAllowedForFaceAuth = final boolean isPostureAllowedForFaceAuth = doesPostureAllowFaceAuth(mPostureState);
mConfigFaceAuthSupportedPosture == 0 /* DEVICE_POSTURE_UNKNOWN */ ? true
: (mPostureState == mConfigFaceAuthSupportedPosture);
// Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an // Only listen if this KeyguardUpdateMonitor belongs to the primary user. There is an
// instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware. // instance of KeyguardUpdateMonitor for each user but KeyguardUpdateMonitor is user-aware.
final boolean shouldListen = final boolean shouldListen =
@@ -2952,6 +2956,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
return shouldListen; return shouldListen;
} }
private boolean doesPostureAllowFaceAuth(@DevicePostureInt int posture) {
return mConfigFaceAuthSupportedPosture == DEVICE_POSTURE_UNKNOWN
|| (posture == mConfigFaceAuthSupportedPosture);
}
private void logListenerModelData(@NonNull KeyguardListenModel model) { private void logListenerModelData(@NonNull KeyguardListenModel model) {
mLogger.logKeyguardListenerModel(model); mLogger.logKeyguardListenerModel(model);
if (model instanceof KeyguardFingerprintListenModel) { if (model instanceof KeyguardFingerprintListenModel) {

View File

@@ -2209,6 +2209,32 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
eq(false), eq(BiometricSourceType.FACE)); eq(false), eq(BiometricSourceType.FACE));
} }
@Test
public void testPostureChangeToUnsupported_stopsFaceListeningState() {
// GIVEN device is listening for face
mKeyguardUpdateMonitor.mConfigFaceAuthSupportedPosture = DEVICE_POSTURE_CLOSED;
deviceInPostureStateClosed();
mKeyguardUpdateMonitor.dispatchStartedWakingUp(PowerManager.WAKE_REASON_POWER_BUTTON);
mTestableLooper.processAllMessages();
keyguardIsVisible();
verifyFaceAuthenticateCall();
final CancellationSignal faceCancel = spy(mKeyguardUpdateMonitor.mFaceCancelSignal);
mKeyguardUpdateMonitor.mFaceCancelSignal = faceCancel;
KeyguardUpdateMonitorCallback callback = mock(KeyguardUpdateMonitorCallback.class);
mKeyguardUpdateMonitor.registerCallback(callback);
// WHEN device is opened
deviceInPostureStateOpened();
mTestableLooper.processAllMessages();
// THEN face listening is stopped.
verify(faceCancel).cancel();
verify(callback).onBiometricRunningStateChanged(
eq(false), eq(BiometricSourceType.FACE));
}
@Test @Test
public void testShouldListenForFace_withLockedDown_returnsFalse() public void testShouldListenForFace_withLockedDown_returnsFalse()
throws RemoteException { throws RemoteException {