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

Test: atest DeviceEntryFaceAuthRepositoryTest
Fixes: 285521712
Change-Id: I1af59924054ed3f01a43774cf306b39b300ab8df
This commit is contained in:
Chandru S
2023-06-23 11:52:45 -07:00
parent f2d674bc4a
commit 0c852330af
2 changed files with 35 additions and 7 deletions

View File

@@ -317,13 +317,14 @@ constructor(
tableLogBuffer tableLogBuffer
), ),
logAndObserve( logAndObserve(
combine( keyguardInteractor.isSecureCameraActive
keyguardInteractor.isSecureCameraActive, .isFalse()
alternateBouncerInteractor.isVisible .or(
) { a, b -> alternateBouncerInteractor.isVisible.or(
!a || b keyguardInteractor.primaryBouncerShowing
}, )
"secureCameraNotActiveOrAltBouncerIsShowing", ),
"secureCameraNotActiveOrAnyBouncerIsShowing",
tableLogBuffer tableLogBuffer
), ),
logAndObserve( logAndObserve(
@@ -640,6 +641,10 @@ constructor(
private fun and(flow: Flow<Boolean>, anotherFlow: Flow<Boolean>) = private fun and(flow: Flow<Boolean>, anotherFlow: Flow<Boolean>) =
flow.combine(anotherFlow) { a, b -> a && b } 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. */ /** "Not" the given flow. The return [Flow] will be true when [this] flow is false. */
private fun Flow<Boolean>.isFalse(): Flow<Boolean> { private fun Flow<Boolean>.isFalse(): Flow<Boolean> {
return this.map { !it } 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 @Test
fun authenticateDoesNotRunOnUnsupportedPosture() = fun authenticateDoesNotRunOnUnsupportedPosture() =
testScope.runTest { testScope.runTest {