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

Commit c761b5a0 authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Fix GONE => AOD AodPromotedNotif sensitivity flicker

Check hasTrust instead of isKeyguardDismissible.
isKeyguardDismissible doesn't get updated to false
until the GONE => AOD transition is finished since
it relies on isKeyguardShowing. hasTrust does not
rely on the keyguardShowing state, so it avoids
the flicker of showing the unredacted notification
on transition to AOD.

Test: atest AODPromotedNotificationsInteractorTest
Bug: 421115996
Flag: EXEMPT bugfix
Change-Id: Iae5c2b8100f7f28ccf060b1d5b8f62eea802b94b
parent bd4ec4cb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -152,7 +152,7 @@ class AODPromotedNotificationsInteractorTest : SysuiTestCase() {
        }

    private fun Kosmos.setKeyguardLocked(locked: Boolean) {
        fakeKeyguardRepository.setKeyguardDismissible(!locked)
        fakeKeyguardRepository.setHasTrust(!locked)
    }

    private fun Kosmos.setScreenSharingProtectionActive(active: Boolean) {
+10 −0
Original line number Diff line number Diff line
@@ -102,6 +102,12 @@ interface KeyguardRepository {
     */
    val isKeyguardDismissible: StateFlow<Boolean>

    /**
     * Whether device entry believes the device is trusted. This can be true or false when keyguard
     * has been dismissed depending on biometric and trust states.
     */
    val hasTrust: StateFlow<Boolean>

    /**
     * Observable for the signal that keyguard is about to go away.
     *
@@ -381,6 +387,9 @@ constructor(
    override val isKeyguardDismissible: MutableStateFlow<Boolean> =
        MutableStateFlow(keyguardStateController.isUnlocked)

    override val hasTrust: MutableStateFlow<Boolean> =
        MutableStateFlow(keyguardStateController.canDismissLockScreen())

    @SuppressLint("SharedFlowCreation")
    override val isKeyguardGoingAway: MutableSharedFlow<Boolean> =
        MutableSharedFlow<Boolean>(
@@ -588,6 +597,7 @@ constructor(
                }

                override fun onUnlockedChanged() {
                    hasTrust.value = keyguardStateController.canDismissLockScreen()
                    isKeyguardDismissible.value = keyguardStateController.isUnlocked
                }
            }
+10 −1
Original line number Diff line number Diff line
@@ -232,9 +232,18 @@ constructor(
    @Deprecated("Use KeyguardTransitionInteractor + KeyguardState")
    val isKeyguardShowing: StateFlow<Boolean> = repository.isKeyguardShowing

    /** Whether the keyguard is dismissible or not. */
    /**
     * Whether the keyguard is unlocked or not. This is always true when keyguard has been dismissed
     * or can be dismissed by a swipe.
     */
    val isKeyguardDismissible: StateFlow<Boolean> = repository.isKeyguardDismissible

    /**
     * Whether device entry believes the device is trusted. This can be true or false when keyguard
     * has been dismissed depending on biometric and trust states.
     */
    val hasTrust: StateFlow<Boolean> = repository.hasTrust

    /** Whether the keyguard is occluded (covered by an activity). */
    @Deprecated("Use KeyguardTransitionInteractor + KeyguardState.OCCLUDED")
    val isKeyguardOccluded: StateFlow<Boolean> = repository.isKeyguardOccluded
+3 −3
Original line number Diff line number Diff line
@@ -47,11 +47,11 @@ constructor(
     */
    private val canShowPrivateNotificationContent: Flow<Boolean> =
        combine(
            keyguardInteractor.isKeyguardDismissible,
            keyguardInteractor.hasTrust,
            sensitiveNotificationProtectionInteractor.isSensitiveStateActive,
            biometricUnlockInteractor.unlockState,
        ) { isKeyguardDismissible, isSensitive, biometricUnlockState ->
            isKeyguardDismissible &&
        ) { hasTrust, isSensitive, biometricUnlockState ->
            hasTrust &&
                !isSensitive &&
                !BiometricUnlockMode.dismissesKeyguard(biometricUnlockState.mode)
        }
+7 −0
Original line number Diff line number Diff line
@@ -59,6 +59,9 @@ class FakeKeyguardRepository @Inject constructor() : KeyguardRepository {
    private val _isKeyguardUnlocked = MutableStateFlow(false)
    override val isKeyguardDismissible: StateFlow<Boolean> = _isKeyguardUnlocked.asStateFlow()

    private val _hasTrust = MutableStateFlow(false)
    override val hasTrust: StateFlow<Boolean> = _hasTrust.asStateFlow()

    private val _isKeyguardOccluded = MutableStateFlow(false)
    override val isKeyguardOccluded: StateFlow<Boolean> = _isKeyguardOccluded

@@ -167,6 +170,10 @@ class FakeKeyguardRepository @Inject constructor() : KeyguardRepository {
        _isKeyguardUnlocked.value = isUnlocked
    }

    fun setHasTrust(hasTrust: Boolean) {
        _hasTrust.value = hasTrust
    }

    override fun setIsDozing(isDozing: Boolean) {
        _isDozing.value = isDozing
    }