Loading packages/SystemUI/src/com/android/systemui/bouncer/shared/flag/ComposeBouncerFlags.kt 0 → 100644 +69 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.bouncer.shared.flag import com.android.systemui.Flags import com.android.systemui.dagger.SysUISingleton import com.android.systemui.scene.shared.flag.SceneContainerFlags import dagger.Module import dagger.Provides interface ComposeBouncerFlags { /** * Returns `true` if the Compose bouncer is enabled or if the scene container framework is * enabled; `false` otherwise. */ fun isComposeBouncerOrSceneContainerEnabled(): Boolean /** * Returns `true` if only compose bouncer is enabled and scene container framework is not * enabled. */ @Deprecated( "Avoid using this, this is meant to be used only by the glue code " + "that includes compose bouncer in legacy keyguard.", replaceWith = ReplaceWith("isComposeBouncerOrSceneContainerEnabled()") ) fun isOnlyComposeBouncerEnabled(): Boolean } class ComposeBouncerFlagsImpl(private val sceneContainerFlags: SceneContainerFlags) : ComposeBouncerFlags { override fun isComposeBouncerOrSceneContainerEnabled(): Boolean { return sceneContainerFlags.isEnabled() || Flags.composeBouncer() } @Deprecated( "Avoid using this, this is meant to be used only by the glue code " + "that includes compose bouncer in legacy keyguard.", replaceWith = ReplaceWith("isComposeBouncerOrSceneContainerEnabled()") ) override fun isOnlyComposeBouncerEnabled(): Boolean { return !sceneContainerFlags.isEnabled() && Flags.composeBouncer() } } @Module object ComposeBouncerFlagsModule { @Provides @SysUISingleton fun impl(sceneContainerFlags: SceneContainerFlags): ComposeBouncerFlags { return ComposeBouncerFlagsImpl(sceneContainerFlags) } } packages/SystemUI/src/com/android/systemui/bouncer/ui/binder/BouncerViewBinder.kt +5 −2 Original line number Diff line number Diff line Loading @@ -4,10 +4,10 @@ import android.view.ViewGroup import com.android.keyguard.KeyguardMessageAreaController import com.android.keyguard.ViewMediatorCallback import com.android.keyguard.dagger.KeyguardBouncerComponent import com.android.systemui.Flags import com.android.systemui.authentication.domain.interactor.AuthenticationInteractor import com.android.systemui.bouncer.domain.interactor.BouncerMessageInteractor import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor import com.android.systemui.bouncer.shared.flag.ComposeBouncerFlags import com.android.systemui.bouncer.ui.BouncerDialogFactory import com.android.systemui.bouncer.ui.viewmodel.BouncerViewModel import com.android.systemui.bouncer.ui.viewmodel.KeyguardBouncerViewModel Loading Loading @@ -55,12 +55,15 @@ constructor( class BouncerViewBinder @Inject constructor( private val composeBouncerFlags: ComposeBouncerFlags, private val legacyBouncerDependencies: Lazy<LegacyBouncerDependencies>, private val composeBouncerDependencies: Lazy<ComposeBouncerDependencies>, ) { fun bind(view: ViewGroup) { if ( ComposeFacade.isComposeAvailable() && Flags.composeBouncer() && COMPOSE_BOUNCER_ENABLED COMPOSE_BOUNCER_ENABLED && composeBouncerFlags.isOnlyComposeBouncerEnabled() && ComposeFacade.isComposeAvailable() ) { val deps = composeBouncerDependencies.get() ComposeBouncerViewBinder.bind( Loading packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModel.kt +4 −4 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import com.android.systemui.authentication.shared.model.AuthenticationWipeModel import com.android.systemui.bouncer.domain.interactor.BouncerActionButtonInteractor 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.shared.model.BouncerActionButtonModel import com.android.systemui.common.shared.model.Icon import com.android.systemui.common.shared.model.Text Loading @@ -35,7 +36,6 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.inputmethod.domain.interactor.InputMethodInteractor import com.android.systemui.scene.shared.flag.SceneContainerFlags import com.android.systemui.user.domain.interactor.SelectedUserInteractor import com.android.systemui.user.ui.viewmodel.UserActionViewModel import com.android.systemui.user.ui.viewmodel.UserSwitcherViewModel Loading Loading @@ -72,7 +72,7 @@ class BouncerViewModel( private val simBouncerInteractor: SimBouncerInteractor, private val authenticationInteractor: AuthenticationInteractor, private val selectedUserInteractor: SelectedUserInteractor, flags: SceneContainerFlags, flags: ComposeBouncerFlags, selectedUser: Flow<UserViewModel>, users: Flow<List<UserViewModel>>, userSwitcherMenu: Flow<List<UserActionViewModel>>, Loading Loading @@ -233,7 +233,7 @@ class BouncerViewModel( private var lockoutCountdownJob: Job? = null init { if (flags.isEnabled()) { if (flags.isComposeBouncerOrSceneContainerEnabled()) { // Keeps the lockout dialog up-to-date. applicationScope.launch { bouncerInteractor.onLockoutStarted.collect { Loading Loading @@ -478,7 +478,7 @@ object BouncerViewModelModule { actionButtonInteractor: BouncerActionButtonInteractor, authenticationInteractor: AuthenticationInteractor, selectedUserInteractor: SelectedUserInteractor, flags: SceneContainerFlags, flags: ComposeBouncerFlags, userSwitcherViewModel: UserSwitcherViewModel, clock: SystemClock, devicePolicyManager: DevicePolicyManager, Loading packages/SystemUI/src/com/android/systemui/scene/SceneContainerFrameworkModule.kt +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.scene import com.android.systemui.CoreStartable import com.android.systemui.bouncer.shared.flag.ComposeBouncerFlagsModule import com.android.systemui.scene.domain.interactor.WindowRootViewVisibilityInteractor import com.android.systemui.scene.domain.startable.SceneContainerStartable import com.android.systemui.scene.shared.flag.SceneContainerFlagsModule Loading @@ -34,6 +35,7 @@ import dagger.multibindings.IntoMap [ BouncerSceneModule::class, CommunalSceneModule::class, ComposeBouncerFlagsModule::class, EmptySceneModule::class, GoneSceneModule::class, LockscreenSceneModule::class, Loading packages/SystemUI/tests/utils/src/com/android/systemui/bouncer/shared/flag/ComposeBouncerFlagsKosmos.kt 0 → 100644 +24 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.bouncer.shared.flag import com.android.systemui.kosmos.Kosmos import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags var Kosmos.fakeComposeBouncerFlags by Kosmos.Fixture { FakeComposeBouncerFlags(fakeSceneContainerFlags) } val Kosmos.composeBouncerFlags by Kosmos.Fixture<ComposeBouncerFlags> { fakeComposeBouncerFlags } Loading
packages/SystemUI/src/com/android/systemui/bouncer/shared/flag/ComposeBouncerFlags.kt 0 → 100644 +69 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.bouncer.shared.flag import com.android.systemui.Flags import com.android.systemui.dagger.SysUISingleton import com.android.systemui.scene.shared.flag.SceneContainerFlags import dagger.Module import dagger.Provides interface ComposeBouncerFlags { /** * Returns `true` if the Compose bouncer is enabled or if the scene container framework is * enabled; `false` otherwise. */ fun isComposeBouncerOrSceneContainerEnabled(): Boolean /** * Returns `true` if only compose bouncer is enabled and scene container framework is not * enabled. */ @Deprecated( "Avoid using this, this is meant to be used only by the glue code " + "that includes compose bouncer in legacy keyguard.", replaceWith = ReplaceWith("isComposeBouncerOrSceneContainerEnabled()") ) fun isOnlyComposeBouncerEnabled(): Boolean } class ComposeBouncerFlagsImpl(private val sceneContainerFlags: SceneContainerFlags) : ComposeBouncerFlags { override fun isComposeBouncerOrSceneContainerEnabled(): Boolean { return sceneContainerFlags.isEnabled() || Flags.composeBouncer() } @Deprecated( "Avoid using this, this is meant to be used only by the glue code " + "that includes compose bouncer in legacy keyguard.", replaceWith = ReplaceWith("isComposeBouncerOrSceneContainerEnabled()") ) override fun isOnlyComposeBouncerEnabled(): Boolean { return !sceneContainerFlags.isEnabled() && Flags.composeBouncer() } } @Module object ComposeBouncerFlagsModule { @Provides @SysUISingleton fun impl(sceneContainerFlags: SceneContainerFlags): ComposeBouncerFlags { return ComposeBouncerFlagsImpl(sceneContainerFlags) } }
packages/SystemUI/src/com/android/systemui/bouncer/ui/binder/BouncerViewBinder.kt +5 −2 Original line number Diff line number Diff line Loading @@ -4,10 +4,10 @@ import android.view.ViewGroup import com.android.keyguard.KeyguardMessageAreaController import com.android.keyguard.ViewMediatorCallback import com.android.keyguard.dagger.KeyguardBouncerComponent import com.android.systemui.Flags import com.android.systemui.authentication.domain.interactor.AuthenticationInteractor import com.android.systemui.bouncer.domain.interactor.BouncerMessageInteractor import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor import com.android.systemui.bouncer.shared.flag.ComposeBouncerFlags import com.android.systemui.bouncer.ui.BouncerDialogFactory import com.android.systemui.bouncer.ui.viewmodel.BouncerViewModel import com.android.systemui.bouncer.ui.viewmodel.KeyguardBouncerViewModel Loading Loading @@ -55,12 +55,15 @@ constructor( class BouncerViewBinder @Inject constructor( private val composeBouncerFlags: ComposeBouncerFlags, private val legacyBouncerDependencies: Lazy<LegacyBouncerDependencies>, private val composeBouncerDependencies: Lazy<ComposeBouncerDependencies>, ) { fun bind(view: ViewGroup) { if ( ComposeFacade.isComposeAvailable() && Flags.composeBouncer() && COMPOSE_BOUNCER_ENABLED COMPOSE_BOUNCER_ENABLED && composeBouncerFlags.isOnlyComposeBouncerEnabled() && ComposeFacade.isComposeAvailable() ) { val deps = composeBouncerDependencies.get() ComposeBouncerViewBinder.bind( Loading
packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModel.kt +4 −4 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import com.android.systemui.authentication.shared.model.AuthenticationWipeModel import com.android.systemui.bouncer.domain.interactor.BouncerActionButtonInteractor 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.shared.model.BouncerActionButtonModel import com.android.systemui.common.shared.model.Icon import com.android.systemui.common.shared.model.Text Loading @@ -35,7 +36,6 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.inputmethod.domain.interactor.InputMethodInteractor import com.android.systemui.scene.shared.flag.SceneContainerFlags import com.android.systemui.user.domain.interactor.SelectedUserInteractor import com.android.systemui.user.ui.viewmodel.UserActionViewModel import com.android.systemui.user.ui.viewmodel.UserSwitcherViewModel Loading Loading @@ -72,7 +72,7 @@ class BouncerViewModel( private val simBouncerInteractor: SimBouncerInteractor, private val authenticationInteractor: AuthenticationInteractor, private val selectedUserInteractor: SelectedUserInteractor, flags: SceneContainerFlags, flags: ComposeBouncerFlags, selectedUser: Flow<UserViewModel>, users: Flow<List<UserViewModel>>, userSwitcherMenu: Flow<List<UserActionViewModel>>, Loading Loading @@ -233,7 +233,7 @@ class BouncerViewModel( private var lockoutCountdownJob: Job? = null init { if (flags.isEnabled()) { if (flags.isComposeBouncerOrSceneContainerEnabled()) { // Keeps the lockout dialog up-to-date. applicationScope.launch { bouncerInteractor.onLockoutStarted.collect { Loading Loading @@ -478,7 +478,7 @@ object BouncerViewModelModule { actionButtonInteractor: BouncerActionButtonInteractor, authenticationInteractor: AuthenticationInteractor, selectedUserInteractor: SelectedUserInteractor, flags: SceneContainerFlags, flags: ComposeBouncerFlags, userSwitcherViewModel: UserSwitcherViewModel, clock: SystemClock, devicePolicyManager: DevicePolicyManager, Loading
packages/SystemUI/src/com/android/systemui/scene/SceneContainerFrameworkModule.kt +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.scene import com.android.systemui.CoreStartable import com.android.systemui.bouncer.shared.flag.ComposeBouncerFlagsModule import com.android.systemui.scene.domain.interactor.WindowRootViewVisibilityInteractor import com.android.systemui.scene.domain.startable.SceneContainerStartable import com.android.systemui.scene.shared.flag.SceneContainerFlagsModule Loading @@ -34,6 +35,7 @@ import dagger.multibindings.IntoMap [ BouncerSceneModule::class, CommunalSceneModule::class, ComposeBouncerFlagsModule::class, EmptySceneModule::class, GoneSceneModule::class, LockscreenSceneModule::class, Loading
packages/SystemUI/tests/utils/src/com/android/systemui/bouncer/shared/flag/ComposeBouncerFlagsKosmos.kt 0 → 100644 +24 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.bouncer.shared.flag import com.android.systemui.kosmos.Kosmos import com.android.systemui.scene.shared.flag.fakeSceneContainerFlags var Kosmos.fakeComposeBouncerFlags by Kosmos.Fixture { FakeComposeBouncerFlags(fakeSceneContainerFlags) } val Kosmos.composeBouncerFlags by Kosmos.Fixture<ComposeBouncerFlags> { fakeComposeBouncerFlags }