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

Commit b096310e authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

[flexiglass] Fixes issues that prevented falsing session from starting

See comments on the attached bug for details. TL;DR:
- FalsingCoreStartable which is responsible for initializing
  FalsingCollector doesn't initialize the real FalsingCollector when
  Flexiglass is on, leading to a disabled collector
- SceneContainerStartable's logic to report screen on/off was not
  running when AOD was available. There's no reason to condition that
  logic's running on the availability of AOD, the production logic
  doesn't do that

Fix: 365877972
Test: manually verified that, after a fresh device reboot, bringing up
the bouncer and tapping outside any PIN button a couple of times
correctly handles the false touch by force-navigating back to the
lockscreen scene
Test: unit tests updated
Flag: com.android.systemui.scene_container

Change-Id: Ib1d452c2ef0a42d49fdb5130a9da373697f8724e
parent 218fb8f2
Loading
Loading
Loading
Loading
+1 −50
Original line number Diff line number Diff line
@@ -1508,10 +1508,8 @@ class SceneContainerStartableTest : SysuiTestCase() {
        }

    @Test
    fun collectFalsingSignals_screenOnAndOff_aodUnavailable() =
    fun collectFalsingSignals_screenOnAndOff() =
        testScope.runTest {
            kosmos.fakeKeyguardRepository.setAodAvailable(false)
            runCurrent()
            prepareState(
                initialSceneKey = Scenes.Lockscreen,
                authenticationMethod = AuthenticationMethodModel.Pin,
@@ -1555,53 +1553,6 @@ class SceneContainerStartableTest : SysuiTestCase() {
            verify(falsingCollector, times(3)).onScreenOff()
        }

    @Test
    fun collectFalsingSignals_screenOnAndOff_aodAvailable() =
        testScope.runTest {
            kosmos.fakeKeyguardRepository.setAodAvailable(true)
            runCurrent()
            prepareState(
                initialSceneKey = Scenes.Lockscreen,
                authenticationMethod = AuthenticationMethodModel.Pin,
                isDeviceUnlocked = false,
            )
            underTest.start()
            runCurrent()
            verify(falsingCollector, never()).onScreenTurningOn()
            verify(falsingCollector, never()).onScreenOnFromTouch()
            verify(falsingCollector, never()).onScreenOff()

            powerInteractor.setAwakeForTest(reason = PowerManager.WAKE_REASON_POWER_BUTTON)
            runCurrent()
            verify(falsingCollector, never()).onScreenTurningOn()
            verify(falsingCollector, never()).onScreenOnFromTouch()
            verify(falsingCollector, never()).onScreenOff()

            powerInteractor.setAsleepForTest()
            runCurrent()
            verify(falsingCollector, never()).onScreenTurningOn()
            verify(falsingCollector, never()).onScreenOnFromTouch()
            verify(falsingCollector, never()).onScreenOff()

            powerInteractor.setAwakeForTest(reason = PowerManager.WAKE_REASON_TAP)
            runCurrent()
            verify(falsingCollector, never()).onScreenTurningOn()
            verify(falsingCollector, never()).onScreenOnFromTouch()
            verify(falsingCollector, never()).onScreenOff()

            powerInteractor.setAsleepForTest()
            runCurrent()
            verify(falsingCollector, never()).onScreenTurningOn()
            verify(falsingCollector, never()).onScreenOnFromTouch()
            verify(falsingCollector, never()).onScreenOff()

            powerInteractor.setAwakeForTest(reason = PowerManager.WAKE_REASON_POWER_BUTTON)
            runCurrent()
            verify(falsingCollector, never()).onScreenTurningOn()
            verify(falsingCollector, never()).onScreenOnFromTouch()
            verify(falsingCollector, never()).onScreenOff()
        }

    @Test
    fun collectFalsingSignals_bouncerVisibility() =
        testScope.runTest {
+3 −2
Original line number Diff line number Diff line
@@ -21,8 +21,9 @@ import javax.inject.Inject

/** Initializes classes related to falsing. */
@SysUISingleton
class FalsingCoreStartable @Inject constructor(val falsingCollector: FalsingCollector) :
    CoreStartable {
class FalsingCoreStartable
@Inject
constructor(@FalsingCollectorActual val falsingCollector: FalsingCollector) : CoreStartable {
    override fun start() {
        falsingCollector.init()
    }
+1 −9
Original line number Diff line number Diff line
@@ -94,7 +94,6 @@ import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.distinctUntilChangedBy
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterIsInstance
import kotlinx.coroutines.flow.filterNot
@@ -717,14 +716,7 @@ constructor(
        }

        applicationScope.launch {
            keyguardInteractor.isAodAvailable
                .flatMapLatest { isAodAvailable ->
                    if (!isAodAvailable) {
            powerInteractor.detailedWakefulness
                    } else {
                        emptyFlow()
                    }
                }
                .distinctUntilChangedBy { it.isAwake() }
                .collect { wakefulness ->
                    when {