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

Commit aa92df8b authored by Ale Nijamkin's avatar Ale Nijamkin Committed by Android (Google) Code Review
Browse files

Merge changes Ib1d452c2,Ia10503da into main

* changes:
  [flexiglass] Fixes issues that prevented falsing session from starting
  [flexiglass] Call avoidGesture in falsing from PIN bouncer
parents 82e41d22 b096310e
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 {
+5 −7
Original line number Diff line number Diff line
@@ -29,11 +29,11 @@ import android.view.KeyEvent.isConfirmKey
import android.view.View
import androidx.compose.ui.input.key.KeyEvent
import androidx.compose.ui.input.key.KeyEventType
import com.android.app.tracing.coroutines.launchTraced as launch
import com.android.keyguard.PinShapeAdapter
import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
import com.android.systemui.bouncer.domain.interactor.BouncerInteractor
import com.android.systemui.bouncer.domain.interactor.SimBouncerInteractor
import com.android.systemui.bouncer.shared.flag.ComposeBouncerFlags
import com.android.systemui.bouncer.ui.helper.BouncerHapticPlayer
import com.android.systemui.res.R
import dagger.assisted.Assisted
@@ -50,7 +50,6 @@ import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.receiveAsFlow
import com.android.app.tracing.coroutines.launchTraced as launch

/** Holds UI state and handles user input for the PIN code bouncer UI. */
class PinBouncerViewModel
@@ -289,11 +288,10 @@ constructor(
     * feedback on the view.
     */
    fun onDigitButtonDown(view: View?) {
        if (ComposeBouncerFlags.isOnlyComposeBouncerEnabled()) {
            // Current PIN bouncer informs FalsingInteractor#avoidGesture() upon every Pin button
            // touch.
        // This ends up calling FalsingInteractor#avoidGesture() each time a PIN button is touched.
        // It helps make sure that legitimate touch in the PIN bouncer isn't treated as false touch.
        super.onDown()
        }

        if (bouncerHapticPlayer?.isEnabled == true) {
            bouncerHapticPlayer.playNumpadKeyFeedback()
        } else {
+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 {