Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit acc021b2 authored by Chandru S's avatar Chandru S Committed by Automerger Merge Worker
Browse files

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

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

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



Change-Id: Ib5c8b268c17e631d55daf18ae1b21820faf9e7a9
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 8b8bc874 5d894cae
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -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 }
+23 −0
Original line number Diff line number Diff line
@@ -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 {