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

Commit b696b536 authored by Chandru S's avatar Chandru S Committed by Android (Google) Code Review
Browse files

Merge "Handle bouncer show requests when bouncer is already unlocked" into main

parents b2d72d12 00d8bb88
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ import com.android.systemui.authentication.shared.model.AuthenticationMethodMode
import com.android.systemui.bouncer.data.repository.fakeKeyguardBouncerRepository
import com.android.systemui.bouncer.domain.interactor.alternateBouncerInteractor
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor
import com.android.systemui.deviceentry.domain.interactor.deviceUnlockedInteractor
import com.android.systemui.flags.EnableSceneContainer
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
import com.android.systemui.keyguard.shared.model.DismissAction
@@ -79,12 +79,11 @@ class KeyguardDismissActionInteractorTest : SysuiTestCase() {
                dismissInteractor = dismissInteractor,
                applicationScope = testScope.backgroundScope,
                sceneInteractor = { kosmos.sceneInteractor },
                deviceEntryInteractor = { kosmos.deviceEntryInteractor },
                deviceUnlockedInteractor = { kosmos.deviceUnlockedInteractor },
                quickSettingsSceneFamilyResolver = { kosmos.quickSettingsSceneFamilyResolver },
                notifShadeSceneFamilyResolver = { kosmos.notifShadeSceneFamilyResolver },
                powerInteractor = kosmos.powerInteractor,
                alternateBouncerInteractor = kosmos.alternateBouncerInteractor,
                keyguardInteractor = { kosmos.keyguardInteractor },
                shadeInteractor = { kosmos.shadeInteractor },
            )
    }
+3 −1
Original line number Diff line number Diff line
@@ -294,7 +294,9 @@ constructor(

    /** Tell the bouncer that bouncer is requested when device is already authenticated */
    fun notifyUserRequestedBouncerWhenAlreadyAuthenticated(userId: Int) {
        applicationScope.launch { repository.setKeyguardAuthenticatedPrimaryAuth(userId) }
        applicationScope.launch {
            repository.setUserRequestedBouncerWhenAlreadyAuthenticated(userId)
        }
    }

    /** Tell the bouncer that keyguard is authenticated with biometrics. */
+16 −2
Original line number Diff line number Diff line
@@ -17,12 +17,14 @@
package com.android.systemui.bouncer.ui.viewmodel

import androidx.compose.runtime.getValue
import com.android.keyguard.ViewMediatorCallback
import com.android.systemui.authentication.domain.interactor.AuthenticationInteractor
import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor
import com.android.systemui.deviceentry.domain.interactor.DeviceUnlockedInteractor
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.lifecycle.Hydrator
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import com.android.systemui.util.kotlin.Utils.Companion.sample
import com.android.systemui.util.kotlin.sample
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import kotlinx.coroutines.coroutineScope
@@ -34,7 +36,7 @@ constructor(
    private val legacyInteractor: PrimaryBouncerInteractor,
    private val authenticationInteractor: AuthenticationInteractor,
    private val selectedUserInteractor: SelectedUserInteractor,
    private val viewMediatorCallback: ViewMediatorCallback?,
    private val deviceUnlockedInteractor: DeviceUnlockedInteractor,
) : ExclusiveActivatable() {

    private val hydrator = Hydrator("BouncerContainerViewModel")
@@ -44,6 +46,18 @@ constructor(

    override suspend fun onActivated(): Nothing {
        coroutineScope {
            launch {
                legacyInteractor.isShowing
                    .sample(deviceUnlockedInteractor.deviceUnlockStatus, ::Pair)
                    .collect { (isShowing, unlockStatus) ->
                        if (isShowing && unlockStatus.isUnlocked) {
                            legacyInteractor.notifyUserRequestedBouncerWhenAlreadyAuthenticated(
                                selectedUserInteractor.getSelectedUserId()
                            )
                        }
                    }
            }

            launch {
                authenticationInteractor.onAuthenticationResult.collect { authenticationSucceeded ->
                    if (authenticationSucceeded) {
+15 −14
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor
import com.android.systemui.bouncer.shared.flag.ComposeBouncerFlags
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor
import com.android.systemui.deviceentry.domain.interactor.DeviceUnlockedInteractor
import com.android.systemui.keyguard.data.repository.KeyguardRepository
import com.android.systemui.keyguard.shared.model.DismissAction
import com.android.systemui.keyguard.shared.model.KeyguardDone
@@ -36,6 +36,7 @@ import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.util.kotlin.Utils.Companion.sampleFilter
import com.android.systemui.util.kotlin.sample
import dagger.Lazy
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -61,14 +62,13 @@ constructor(
    transitionInteractor: KeyguardTransitionInteractor,
    val dismissInteractor: KeyguardDismissInteractor,
    @Application private val applicationScope: CoroutineScope,
    sceneInteractor: dagger.Lazy<SceneInteractor>,
    deviceEntryInteractor: dagger.Lazy<DeviceEntryInteractor>,
    quickSettingsSceneFamilyResolver: dagger.Lazy<QuickSettingsSceneFamilyResolver>,
    notifShadeSceneFamilyResolver: dagger.Lazy<NotifShadeSceneFamilyResolver>,
    sceneInteractor: Lazy<SceneInteractor>,
    deviceUnlockedInteractor: Lazy<DeviceUnlockedInteractor>,
    quickSettingsSceneFamilyResolver: Lazy<QuickSettingsSceneFamilyResolver>,
    notifShadeSceneFamilyResolver: Lazy<NotifShadeSceneFamilyResolver>,
    powerInteractor: PowerInteractor,
    alternateBouncerInteractor: AlternateBouncerInteractor,
    keyguardInteractor: dagger.Lazy<KeyguardInteractor>,
    shadeInteractor: dagger.Lazy<ShadeInteractor>,
    shadeInteractor: Lazy<ShadeInteractor>,
) {
    val dismissAction: Flow<DismissAction> = repository.dismissAction

@@ -106,18 +106,19 @@ constructor(
        if (SceneContainerFlag.isEnabled) {
            combine(
                    sceneInteractor.get().currentScene,
                    deviceEntryInteractor.get().isUnlocked,
                ) { scene, isUnlocked ->
                    isUnlocked &&
                    deviceUnlockedInteractor.get().deviceUnlockStatus,
                ) { scene, unlockStatus ->
                    unlockStatus.isUnlocked &&
                        (quickSettingsSceneFamilyResolver.get().includesScene(scene) ||
                            notifShadeSceneFamilyResolver.get().includesScene(scene))
                }
                .distinctUntilChanged()
        } else if (ComposeBouncerFlags.isOnlyComposeBouncerEnabled()) {
            shadeInteractor.get().isAnyExpanded.sample(
                keyguardInteractor.get().isKeyguardDismissible
            ) { isAnyExpanded, isKeyguardDismissible ->
                isAnyExpanded && isKeyguardDismissible
            combine(
                shadeInteractor.get().isAnyExpanded,
                deviceUnlockedInteractor.get().deviceUnlockStatus,
            ) { isAnyExpanded, deviceUnlockStatus ->
                isAnyExpanded && deviceUnlockStatus.isUnlocked
            }
        } else {
            flow {
+2 −3
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
package com.android.systemui.keyguard.domain.interactor

import com.android.systemui.bouncer.domain.interactor.alternateBouncerInteractor
import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor
import com.android.systemui.deviceentry.domain.interactor.deviceUnlockedInteractor
import com.android.systemui.keyguard.data.repository.keyguardRepository
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testScope
@@ -37,12 +37,11 @@ val Kosmos.keyguardDismissActionInteractor by
            dismissInteractor = keyguardDismissInteractor,
            applicationScope = testScope.backgroundScope,
            sceneInteractor = { sceneInteractor },
            deviceEntryInteractor = { deviceEntryInteractor },
            deviceUnlockedInteractor = { deviceUnlockedInteractor },
            quickSettingsSceneFamilyResolver = { quickSettingsSceneFamilyResolver },
            notifShadeSceneFamilyResolver = { notifShadeSceneFamilyResolver },
            powerInteractor = powerInteractor,
            alternateBouncerInteractor = alternateBouncerInteractor,
            keyguardInteractor = { keyguardInteractor },
            shadeInteractor = { shadeInteractor },
        )
    }