Skip to content
Snippets Groups Projects
Commit af64c7cf authored by Danny Burakov's avatar Danny Burakov Committed by Android (Google) Code Review
Browse files

Merge "Change usages of flags within bouncer to consider both compose bouncer...

Merge "Change usages of flags within bouncer to consider both compose bouncer and scene container framework flags" into main
parents 49de7371 37011184
No related branches found
No related tags found
No related merge requests found
/*
* 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)
}
}
......@@ -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
......@@ -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(
......
......@@ -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
......@@ -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
......@@ -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>>,
......@@ -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 {
......@@ -478,7 +478,7 @@ object BouncerViewModelModule {
actionButtonInteractor: BouncerActionButtonInteractor,
authenticationInteractor: AuthenticationInteractor,
selectedUserInteractor: SelectedUserInteractor,
flags: SceneContainerFlags,
flags: ComposeBouncerFlags,
userSwitcherViewModel: UserSwitcherViewModel,
clock: SystemClock,
devicePolicyManager: DevicePolicyManager,
......
......@@ -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
......@@ -34,6 +35,7 @@ import dagger.multibindings.IntoMap
[
BouncerSceneModule::class,
CommunalSceneModule::class,
ComposeBouncerFlagsModule::class,
EmptySceneModule::class,
GoneSceneModule::class,
LockscreenSceneModule::class,
......
/*
* 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 }
/*
* 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.scene.shared.flag.SceneContainerFlags
class FakeComposeBouncerFlags(
private val sceneContainerFlags: SceneContainerFlags,
var composeBouncerEnabled: Boolean = false
) : ComposeBouncerFlags {
override fun isComposeBouncerOrSceneContainerEnabled(): Boolean {
return sceneContainerFlags.isEnabled() || composeBouncerEnabled
}
@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 = composeBouncerEnabled
}
......@@ -21,12 +21,12 @@ import com.android.systemui.authentication.domain.interactor.authenticationInter
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.inputmethod.domain.interactor.inputMethodInteractor
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.kosmos.testScope
import com.android.systemui.scene.shared.flag.sceneContainerFlags
import com.android.systemui.user.domain.interactor.selectedUserInteractor
import com.android.systemui.user.ui.viewmodel.userSwitcherViewModel
import com.android.systemui.util.mockito.mock
......@@ -42,7 +42,7 @@ val Kosmos.bouncerViewModel by Fixture {
simBouncerInteractor = simBouncerInteractor,
authenticationInteractor = authenticationInteractor,
selectedUserInteractor = selectedUserInteractor,
flags = sceneContainerFlags,
flags = composeBouncerFlags,
selectedUser = userSwitcherViewModel.selectedUser,
users = userSwitcherViewModel.users,
userSwitcherMenu = userSwitcherViewModel.menu,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment