Allow face auth to run even when secure camera is launched if primary bouncer is also visible am: 0c852330af

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

Change-Id: I589d600fb4cd25947a3e2eca093e18c05a98a595
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Chandru S
2023-06-27 08:37:10 +00:00
committed by Automerger Merge Worker
2 changed files with 35 additions and 7 deletions

View File

@@ -317,13 +317,14 @@ constructor(
tableLogBuffer
),
logAndObserve(
combine(
keyguardInteractor.isSecureCameraActive,
alternateBouncerInteractor.isVisible
) { a, b ->
!a || b
},
"secureCameraNotActiveOrAltBouncerIsShowing",
keyguardInteractor.isSecureCameraActive
.isFalse()
.or(
alternateBouncerInteractor.isVisible.or(
keyguardInteractor.primaryBouncerShowing
)
),
"secureCameraNotActiveOrAnyBouncerIsShowing",
tableLogBuffer
),
logAndObserve(
@@ -640,6 +641,10 @@ constructor(
private fun and(flow: Flow<Boolean>, anotherFlow: Flow<Boolean>) =
flow.combine(anotherFlow) { a, b -> a && b }
/** Combine two boolean flows by or-ing both of them */
private fun Flow<Boolean>.or(anotherFlow: Flow<Boolean>) =
this.combine(anotherFlow) { a, b -> a || b }
/** "Not" the given flow. The return [Flow] will be true when [this] flow is false. */
private fun Flow<Boolean>.isFalse(): Flow<Boolean> {
return this.map { !it }

View File

@@ -572,6 +572,29 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
}
}
@Test
fun authenticateRunsWhenSecureCameraIsActiveIfBouncerIsShowing() =
testScope.runTest {
initCollectors()
allPreconditionsToRunFaceAuthAreTrue()
bouncerRepository.setAlternateVisible(false)
bouncerRepository.setPrimaryShow(false)
assertThat(canFaceAuthRun()).isTrue()
// launch secure camera
fakeCommandQueue.doForEachCallback {
it.onCameraLaunchGestureDetected(CAMERA_LAUNCH_SOURCE_POWER_DOUBLE_TAP)
}
keyguardRepository.setKeyguardOccluded(true)
runCurrent()
assertThat(canFaceAuthRun()).isFalse()
// but bouncer is shown after that.
bouncerRepository.setPrimaryShow(true)
assertThat(canFaceAuthRun()).isTrue()
}
@Test
fun authenticateDoesNotRunOnUnsupportedPosture() =
testScope.runTest {