Loading packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt +14 −2 Original line number Diff line number Diff line Loading @@ -57,14 +57,18 @@ import com.android.systemui.concurrency.fakeExecutor import com.android.systemui.haptics.msdl.msdlPlayer import com.android.systemui.haptics.vibratorHelper import com.android.systemui.jank.interactionJankMonitor import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.wakefulnessLifecycle import com.android.systemui.kosmos.runCurrent import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope import com.android.systemui.lifecycle.activateIn import com.android.systemui.res.R import com.android.systemui.shade.data.repository.fakeShadeRepository import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.After import org.junit.Before import org.junit.Ignore Loading Loading @@ -102,7 +106,6 @@ open class AuthContainerViewTest : SysuiTestCase() { private val testScope = kosmos.testScope private val fakeExecutor = kosmos.fakeExecutor private val fakeShadeRepository = kosmos.fakeShadeRepository private val defaultLogoIcon = context.getDrawable(R.drawable.ic_android) Loading Loading @@ -633,6 +636,15 @@ open class AuthContainerViewTest : SysuiTestCase() { ): TestAuthContainerView { authContainer = view kosmos.runTest { // Ensure lockscreen is not showing kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.LOCKSCREEN, to = KeyguardState.UNDEFINED, testScope, ) } if (addToView) { authContainer!!.addToView() } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/AuthControllerTest.java +18 −1 Original line number Diff line number Diff line Loading @@ -99,6 +99,8 @@ import com.android.systemui.biometrics.ui.viewmodel.PromptFallbackViewModel; import com.android.systemui.biometrics.ui.viewmodel.PromptViewModel; import com.android.systemui.display.data.repository.FocusedDisplayRepository; import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor; import com.android.systemui.keyguard.shared.model.KeyguardState; import com.android.systemui.kosmos.KosmosJavaAdapter; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.VibratorHelper; Loading Loading @@ -186,6 +188,8 @@ public class AuthControllerTest extends SysuiTestCase { @Mock private PromptSelectorInteractor mPromptSelectionInteractor; @Mock private KeyguardTransitionInteractor mKeyguardTransitionInteractor; @Mock private CredentialViewModel mCredentialViewModel; @Mock private PromptViewModel mPromptViewModel; Loading Loading @@ -251,6 +255,8 @@ public class AuthControllerTest extends SysuiTestCase { when(mFingerprintManager.isHardwareDetected()).thenReturn(true); when(mFaceManager.isHardwareDetected()).thenReturn(true); when(mKeyguardTransitionInteractor.getCurrentState()).thenReturn(KeyguardState.UNDEFINED); final List<ComponentInfoInternal> fpComponentInfo = List.of( new ComponentInfoInternal("faceSensor" /* componentId */, "vendor/model/revision" /* hardwareVersion */, "1.01" /* firmwareVersion */, Loading Loading @@ -1021,6 +1027,17 @@ public class AuthControllerTest extends SysuiTestCase { eq(null) /* credentialAttestation */); } @Test public void testShowAuthenticationDialog_whenKeyguardIsShowing_dismisses() throws RemoteException { when(mKeyguardTransitionInteractor.getCurrentState()).thenReturn(KeyguardState.LOCKSCREEN); mAuthController.showAuthenticationDialog( new PromptInfo(), mReceiver, new int[0], false, false, 0, 0, "", 0); verify(mReceiver).onDialogDismissed( BiometricPrompt.DISMISSED_REASON_USER_CANCEL, null /* credentialAttestation */); } @Test public void testShowDialog_whenOwnerNotInForegroundAndNotVisible() { final PromptInfo promptInfo = createTestPromptInfo(); Loading Loading @@ -1277,7 +1294,7 @@ public class AuthControllerTest extends SysuiTestCase { () -> mCredentialViewModel, () -> mPromptViewModel, mInteractionJankMonitor, mHandler, mBackgroundExecutor, mUdfpsUtils, mVibratorHelper, mKeyguardManager, mMSDLPlayer, mWindowManagerProvider, mFallbackViewModelFactory, mFocusedDisplayRepository); mFocusedDisplayRepository, () -> mKeyguardTransitionInteractor); } @Override Loading packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/ui/viewmodel/CredentialViewModelTest.kt +2 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ import com.android.systemui.biometrics.promptInfo import com.android.systemui.biometrics.shared.model.BiometricModalities import com.android.systemui.biometrics.shared.model.PromptKind import com.android.systemui.haptics.msdl.msdlPlayer import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor import com.android.systemui.kosmos.testScope import com.android.systemui.shade.domain.interactor.shadeInteractor import com.android.systemui.testKosmos Loading Loading @@ -52,6 +53,7 @@ class CredentialViewModelTest : SysuiTestCase() { kosmos.shadeInteractor, kosmos.promptSelectorInteractor, kosmos.msdlPlayer, kosmos.keyguardTransitionInteractor, ) kosmos.testScope.runCurrent() Loading packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java +17 −3 Original line number Diff line number Diff line Loading @@ -91,6 +91,8 @@ import com.android.systemui.display.data.repository.FocusedDisplayRepository; import com.android.systemui.doze.DozeReceiver; import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.keyguard.data.repository.BiometricType; import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor; import com.android.systemui.keyguard.shared.model.KeyguardState; import com.android.systemui.log.core.LogLevel; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.VibratorHelper; Loading Loading @@ -158,6 +160,7 @@ public class AuthController implements @NonNull private final Provider<CredentialViewModel> mCredentialViewModelProvider; @NonNull private final Provider<PromptViewModel> mPromptViewModelProvider; @NonNull private final Lazy<LogContextInteractor> mLogContextInteractor; @NonNull private final Lazy<KeyguardTransitionInteractor> mKeyguardTransitionInteractor; private final Display mDisplay; private float mScaleFactor = 1f; Loading Loading @@ -741,7 +744,8 @@ public class AuthController implements @NonNull MSDLPlayer msdlPlayer, WindowManagerProvider windowManagerProvider, @NonNull PromptFallbackViewModel.Factory promptFallbackViewModelFactory, @NonNull FocusedDisplayRepository focusedDisplayRepository) { @NonNull FocusedDisplayRepository focusedDisplayRepository, @NonNull Lazy<KeyguardTransitionInteractor> keyguardTransitionInteractor) { mContext = context; mExecution = execution; mUserManager = userManager; Loading @@ -766,6 +770,7 @@ public class AuthController implements mVibratorHelper = vibratorHelper; mMSDLPlayer = msdlPlayer; mPromptFallbackViewModelFactory = promptFallbackViewModelFactory; mKeyguardTransitionInteractor = keyguardTransitionInteractor; mLogContextInteractor = logContextInteractor; mPromptSelectorInteractor = promptSelectorInteractorProvider; Loading Loading @@ -1312,10 +1317,19 @@ public class AuthController implements } mCurrentDialog = newDialog; // Dismiss if the keyguard is showing and not occluded. isOwnerInBackground() handles the // check to ensure the occluding app is the bp caller final KeyguardState keyguardState = mKeyguardTransitionInteractor.get().getCurrentState(); final boolean isKeyguardShowingAndNotOccluded = keyguardState != KeyguardState.GONE && keyguardState != KeyguardState.UNDEFINED && keyguardState != KeyguardState.OCCLUDED; if (!promptInfo.isAllowBackgroundAuthentication() && isOwnerInBackground()) { // TODO(b/353597496): We should check whether |allowBackgroundAuthentication| should be // removed. if (!promptInfo.isAllowBackgroundAuthentication() && isOwnerInBackground()) { cancelIfOwnerIsNotInForeground(); } else if (isKeyguardShowingAndNotOccluded) { closeDialog("keyguard showing"); } else { WindowManager wm = getWindowManagerForUser(userId); if (wm != null) { Loading packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt +2 −2 Original line number Diff line number Diff line Loading @@ -311,8 +311,8 @@ object BiometricViewBinder { } launch { viewModel.isShadeInteracted.collect { isShadeInteracted -> if (isShadeInteracted) { viewModel.shouldDismiss.collect { shouldDismiss -> if (shouldDismiss) { legacyCallback.onUserCanceled() } } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt +14 −2 Original line number Diff line number Diff line Loading @@ -57,14 +57,18 @@ import com.android.systemui.concurrency.fakeExecutor import com.android.systemui.haptics.msdl.msdlPlayer import com.android.systemui.haptics.vibratorHelper import com.android.systemui.jank.interactionJankMonitor import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.wakefulnessLifecycle import com.android.systemui.kosmos.runCurrent import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.testScope import com.android.systemui.lifecycle.activateIn import com.android.systemui.res.R import com.android.systemui.shade.data.repository.fakeShadeRepository import com.android.systemui.testKosmos import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest import org.junit.After import org.junit.Before import org.junit.Ignore Loading Loading @@ -102,7 +106,6 @@ open class AuthContainerViewTest : SysuiTestCase() { private val testScope = kosmos.testScope private val fakeExecutor = kosmos.fakeExecutor private val fakeShadeRepository = kosmos.fakeShadeRepository private val defaultLogoIcon = context.getDrawable(R.drawable.ic_android) Loading Loading @@ -633,6 +636,15 @@ open class AuthContainerViewTest : SysuiTestCase() { ): TestAuthContainerView { authContainer = view kosmos.runTest { // Ensure lockscreen is not showing kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps( from = KeyguardState.LOCKSCREEN, to = KeyguardState.UNDEFINED, testScope, ) } if (addToView) { authContainer!!.addToView() } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/AuthControllerTest.java +18 −1 Original line number Diff line number Diff line Loading @@ -99,6 +99,8 @@ import com.android.systemui.biometrics.ui.viewmodel.PromptFallbackViewModel; import com.android.systemui.biometrics.ui.viewmodel.PromptViewModel; import com.android.systemui.display.data.repository.FocusedDisplayRepository; import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor; import com.android.systemui.keyguard.shared.model.KeyguardState; import com.android.systemui.kosmos.KosmosJavaAdapter; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.VibratorHelper; Loading Loading @@ -186,6 +188,8 @@ public class AuthControllerTest extends SysuiTestCase { @Mock private PromptSelectorInteractor mPromptSelectionInteractor; @Mock private KeyguardTransitionInteractor mKeyguardTransitionInteractor; @Mock private CredentialViewModel mCredentialViewModel; @Mock private PromptViewModel mPromptViewModel; Loading Loading @@ -251,6 +255,8 @@ public class AuthControllerTest extends SysuiTestCase { when(mFingerprintManager.isHardwareDetected()).thenReturn(true); when(mFaceManager.isHardwareDetected()).thenReturn(true); when(mKeyguardTransitionInteractor.getCurrentState()).thenReturn(KeyguardState.UNDEFINED); final List<ComponentInfoInternal> fpComponentInfo = List.of( new ComponentInfoInternal("faceSensor" /* componentId */, "vendor/model/revision" /* hardwareVersion */, "1.01" /* firmwareVersion */, Loading Loading @@ -1021,6 +1027,17 @@ public class AuthControllerTest extends SysuiTestCase { eq(null) /* credentialAttestation */); } @Test public void testShowAuthenticationDialog_whenKeyguardIsShowing_dismisses() throws RemoteException { when(mKeyguardTransitionInteractor.getCurrentState()).thenReturn(KeyguardState.LOCKSCREEN); mAuthController.showAuthenticationDialog( new PromptInfo(), mReceiver, new int[0], false, false, 0, 0, "", 0); verify(mReceiver).onDialogDismissed( BiometricPrompt.DISMISSED_REASON_USER_CANCEL, null /* credentialAttestation */); } @Test public void testShowDialog_whenOwnerNotInForegroundAndNotVisible() { final PromptInfo promptInfo = createTestPromptInfo(); Loading Loading @@ -1277,7 +1294,7 @@ public class AuthControllerTest extends SysuiTestCase { () -> mCredentialViewModel, () -> mPromptViewModel, mInteractionJankMonitor, mHandler, mBackgroundExecutor, mUdfpsUtils, mVibratorHelper, mKeyguardManager, mMSDLPlayer, mWindowManagerProvider, mFallbackViewModelFactory, mFocusedDisplayRepository); mFocusedDisplayRepository, () -> mKeyguardTransitionInteractor); } @Override Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/ui/viewmodel/CredentialViewModelTest.kt +2 −0 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ import com.android.systemui.biometrics.promptInfo import com.android.systemui.biometrics.shared.model.BiometricModalities import com.android.systemui.biometrics.shared.model.PromptKind import com.android.systemui.haptics.msdl.msdlPlayer import com.android.systemui.keyguard.domain.interactor.keyguardTransitionInteractor import com.android.systemui.kosmos.testScope import com.android.systemui.shade.domain.interactor.shadeInteractor import com.android.systemui.testKosmos Loading Loading @@ -52,6 +53,7 @@ class CredentialViewModelTest : SysuiTestCase() { kosmos.shadeInteractor, kosmos.promptSelectorInteractor, kosmos.msdlPlayer, kosmos.keyguardTransitionInteractor, ) kosmos.testScope.runCurrent() Loading
packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java +17 −3 Original line number Diff line number Diff line Loading @@ -91,6 +91,8 @@ import com.android.systemui.display.data.repository.FocusedDisplayRepository; import com.android.systemui.doze.DozeReceiver; import com.android.systemui.keyguard.WakefulnessLifecycle; import com.android.systemui.keyguard.data.repository.BiometricType; import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor; import com.android.systemui.keyguard.shared.model.KeyguardState; import com.android.systemui.log.core.LogLevel; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.VibratorHelper; Loading Loading @@ -158,6 +160,7 @@ public class AuthController implements @NonNull private final Provider<CredentialViewModel> mCredentialViewModelProvider; @NonNull private final Provider<PromptViewModel> mPromptViewModelProvider; @NonNull private final Lazy<LogContextInteractor> mLogContextInteractor; @NonNull private final Lazy<KeyguardTransitionInteractor> mKeyguardTransitionInteractor; private final Display mDisplay; private float mScaleFactor = 1f; Loading Loading @@ -741,7 +744,8 @@ public class AuthController implements @NonNull MSDLPlayer msdlPlayer, WindowManagerProvider windowManagerProvider, @NonNull PromptFallbackViewModel.Factory promptFallbackViewModelFactory, @NonNull FocusedDisplayRepository focusedDisplayRepository) { @NonNull FocusedDisplayRepository focusedDisplayRepository, @NonNull Lazy<KeyguardTransitionInteractor> keyguardTransitionInteractor) { mContext = context; mExecution = execution; mUserManager = userManager; Loading @@ -766,6 +770,7 @@ public class AuthController implements mVibratorHelper = vibratorHelper; mMSDLPlayer = msdlPlayer; mPromptFallbackViewModelFactory = promptFallbackViewModelFactory; mKeyguardTransitionInteractor = keyguardTransitionInteractor; mLogContextInteractor = logContextInteractor; mPromptSelectorInteractor = promptSelectorInteractorProvider; Loading Loading @@ -1312,10 +1317,19 @@ public class AuthController implements } mCurrentDialog = newDialog; // Dismiss if the keyguard is showing and not occluded. isOwnerInBackground() handles the // check to ensure the occluding app is the bp caller final KeyguardState keyguardState = mKeyguardTransitionInteractor.get().getCurrentState(); final boolean isKeyguardShowingAndNotOccluded = keyguardState != KeyguardState.GONE && keyguardState != KeyguardState.UNDEFINED && keyguardState != KeyguardState.OCCLUDED; if (!promptInfo.isAllowBackgroundAuthentication() && isOwnerInBackground()) { // TODO(b/353597496): We should check whether |allowBackgroundAuthentication| should be // removed. if (!promptInfo.isAllowBackgroundAuthentication() && isOwnerInBackground()) { cancelIfOwnerIsNotInForeground(); } else if (isKeyguardShowingAndNotOccluded) { closeDialog("keyguard showing"); } else { WindowManager wm = getWindowManagerForUser(userId); if (wm != null) { Loading
packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt +2 −2 Original line number Diff line number Diff line Loading @@ -311,8 +311,8 @@ object BiometricViewBinder { } launch { viewModel.isShadeInteracted.collect { isShadeInteracted -> if (isShadeInteracted) { viewModel.shouldDismiss.collect { shouldDismiss -> if (shouldDismiss) { legacyCallback.onUserCanceled() } } Loading