diff options
| author | 2024-08-28 22:22:11 +0000 | |
|---|---|---|
| committer | 2024-08-29 05:52:50 +0000 | |
| commit | 3b2c905b6845ede3306d61b6abb70f6b4b18a6d4 (patch) | |
| tree | 12e2fc4b8d10fe32b562170a248fd197516627f2 | |
| parent | 86d29dfd6498cf74c1c2a559c45c05ae88635c35 (diff) | |
Change ComposeBouncerFlags to an object instead of an interface + impl
This makes it easier to use the flag in a new class.
Bug: 310005730
Flag: com.android.systemui.compose_bouncer
Test: everything builds
Change-Id: Ie954186877c1a6b585c4918be0c4e3b2fae7ff9b
11 files changed, 12 insertions, 99 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/viewmodel/BouncerMessageViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/viewmodel/BouncerMessageViewModelTest.kt index c1615253804c..8c8faee99139 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/viewmodel/BouncerMessageViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/viewmodel/BouncerMessageViewModelTest.kt @@ -19,9 +19,11 @@ package com.android.systemui.bouncer.ui.viewmodel import android.content.pm.UserInfo import android.hardware.biometrics.BiometricFaceConstants import android.hardware.fingerprint.FingerprintManager +import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.internal.widget.LockPatternUtils +import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.authentication.data.repository.FakeAuthenticationRepository import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository @@ -35,7 +37,6 @@ import com.android.systemui.biometrics.data.repository.fakeFacePropertyRepositor import com.android.systemui.biometrics.data.repository.fakeFingerprintPropertyRepository import com.android.systemui.biometrics.shared.model.SensorStrength import com.android.systemui.bouncer.domain.interactor.bouncerInteractor -import com.android.systemui.bouncer.shared.flag.fakeComposeBouncerFlags import com.android.systemui.coroutines.collectLastValue import com.android.systemui.deviceentry.domain.interactor.DeviceUnlockedInteractor import com.android.systemui.deviceentry.shared.model.ErrorFaceAuthenticationStatus @@ -71,6 +72,7 @@ import org.junit.runner.RunWith @OptIn(ExperimentalCoroutinesApi::class) @SmallTest @RunWith(AndroidJUnit4::class) +@EnableFlags(Flags.FLAG_COMPOSE_BOUNCER) class BouncerMessageViewModelTest : SysuiTestCase() { private val kosmos = testKosmos() private val testScope = kosmos.testScope @@ -82,7 +84,6 @@ class BouncerMessageViewModelTest : SysuiTestCase() { @Before fun setUp() { kosmos.fakeUserRepository.setUserInfos(listOf(PRIMARY_USER)) - kosmos.fakeComposeBouncerFlags.composeBouncerEnabled = true overrideResource( R.array.config_face_acquire_device_entry_ignorelist, intArrayOf(ignoreHelpMessageId) diff --git a/packages/SystemUI/src/com/android/systemui/authentication/data/repository/AuthenticationRepository.kt b/packages/SystemUI/src/com/android/systemui/authentication/data/repository/AuthenticationRepository.kt index 468737d9372f..732a90d2c01d 100644 --- a/packages/SystemUI/src/com/android/systemui/authentication/data/repository/AuthenticationRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/authentication/data/repository/AuthenticationRepository.kt @@ -32,11 +32,11 @@ import com.android.systemui.authentication.shared.model.AuthenticationMethodMode import com.android.systemui.authentication.shared.model.AuthenticationMethodModel.Pin import com.android.systemui.authentication.shared.model.AuthenticationMethodModel.Sim import com.android.systemui.authentication.shared.model.AuthenticationResultModel +import com.android.systemui.bouncer.shared.flag.ComposeBouncerFlags import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background -import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.statusbar.pipeline.mobile.data.repository.MobileConnectionsRepository import com.android.systemui.user.data.repository.UserRepository import com.android.systemui.util.kotlin.onSubscriberAdded @@ -254,7 +254,7 @@ constructor( override val hasLockoutOccurred: StateFlow<Boolean> = _hasLockoutOccurred.asStateFlow() init { - if (SceneContainerFlag.isEnabled) { + if (ComposeBouncerFlags.isComposeBouncerOrSceneContainerEnabled()) { // Hydrate failedAuthenticationAttempts initially and whenever the selected user // changes. applicationScope.launch { diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/shared/flag/ComposeBouncerFlags.kt b/packages/SystemUI/src/com/android/systemui/bouncer/shared/flag/ComposeBouncerFlags.kt index 62ef365345b7..a1111f68f1ee 100644 --- a/packages/SystemUI/src/com/android/systemui/bouncer/shared/flag/ComposeBouncerFlags.kt +++ b/packages/SystemUI/src/com/android/systemui/bouncer/shared/flag/ComposeBouncerFlags.kt @@ -17,18 +17,17 @@ 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.SceneContainerFlag -import dagger.Module -import dagger.Provides -interface ComposeBouncerFlags { +object ComposeBouncerFlags { /** * Returns `true` if the Compose bouncer is enabled or if the scene container framework is * enabled; `false` otherwise. */ - fun isComposeBouncerOrSceneContainerEnabled(): Boolean + fun isComposeBouncerOrSceneContainerEnabled(): Boolean { + return SceneContainerFlag.isEnabled || Flags.composeBouncer() + } /** * Returns `true` if only compose bouncer is enabled and scene container framework is not @@ -39,30 +38,7 @@ interface ComposeBouncerFlags { "that includes compose bouncer in legacy keyguard.", replaceWith = ReplaceWith("isComposeBouncerOrSceneContainerEnabled()") ) - fun isOnlyComposeBouncerEnabled(): Boolean -} - -class ComposeBouncerFlagsImpl() : ComposeBouncerFlags { - - override fun isComposeBouncerOrSceneContainerEnabled(): Boolean { - return SceneContainerFlag.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 { + fun isOnlyComposeBouncerEnabled(): Boolean { return !SceneContainerFlag.isEnabled && Flags.composeBouncer() } } - -@Module -object ComposeBouncerFlagsModule { - @Provides - @SysUISingleton - fun impl(): ComposeBouncerFlags { - return ComposeBouncerFlagsImpl() - } -} diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/ui/binder/BouncerViewBinder.kt b/packages/SystemUI/src/com/android/systemui/bouncer/ui/binder/BouncerViewBinder.kt index ad93a25f39a5..cc8dce7938aa 100644 --- a/packages/SystemUI/src/com/android/systemui/bouncer/ui/binder/BouncerViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/bouncer/ui/binder/BouncerViewBinder.kt @@ -55,12 +55,11 @@ constructor( class BouncerViewBinder @Inject constructor( - private val composeBouncerFlags: ComposeBouncerFlags, private val legacyBouncerDependencies: Lazy<LegacyBouncerDependencies>, private val composeBouncerDependencies: Lazy<ComposeBouncerDependencies>, ) { fun bind(view: ViewGroup) { - if (composeBouncerFlags.isOnlyComposeBouncerEnabled()) { + if (ComposeBouncerFlags.isOnlyComposeBouncerEnabled()) { val deps = composeBouncerDependencies.get() ComposeBouncerViewBinder.bind( view, diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerMessageViewModel.kt b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerMessageViewModel.kt index 05b46564c5ba..73325f5e012f 100644 --- a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerMessageViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerMessageViewModel.kt @@ -78,7 +78,6 @@ constructor( private val faceAuthInteractor: DeviceEntryFaceAuthInteractor, private val deviceUnlockedInteractor: DeviceUnlockedInteractor, private val deviceEntryBiometricsAllowedInteractor: DeviceEntryBiometricsAllowedInteractor, - private val flags: ComposeBouncerFlags, ) : ExclusiveActivatable() { /** * A message shown when the user has attempted the wrong credential too many times and now must @@ -96,7 +95,7 @@ constructor( val message: MutableStateFlow<MessageViewModel?> = MutableStateFlow(null) override suspend fun onActivated(): Nothing { - if (!flags.isComposeBouncerOrSceneContainerEnabled()) { + if (!ComposeBouncerFlags.isComposeBouncerOrSceneContainerEnabled()) { return awaitCancellation() } diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerSceneContentViewModel.kt b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerSceneContentViewModel.kt index b985fc4efece..c34297e6026a 100644 --- a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerSceneContentViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerSceneContentViewModel.kt @@ -29,7 +29,6 @@ import com.android.systemui.authentication.shared.model.AuthenticationMethodMode 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.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 @@ -57,7 +56,6 @@ constructor( private val authenticationInteractor: AuthenticationInteractor, private val devicePolicyManager: DevicePolicyManager, private val bouncerMessageViewModelFactory: BouncerMessageViewModel.Factory, - private val flags: ComposeBouncerFlags, private val userSwitcher: UserSwitcherViewModel, private val actionButtonInteractor: BouncerActionButtonInteractor, private val pinViewModelFactory: PinBouncerViewModel.Factory, diff --git a/packages/SystemUI/src/com/android/systemui/scene/SceneContainerFrameworkModule.kt b/packages/SystemUI/src/com/android/systemui/scene/SceneContainerFrameworkModule.kt index 7d63b4ce0044..e854a6989687 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/SceneContainerFrameworkModule.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/SceneContainerFrameworkModule.kt @@ -17,7 +17,6 @@ package com.android.systemui.scene import com.android.systemui.CoreStartable -import com.android.systemui.bouncer.shared.flag.ComposeBouncerFlagsModule import com.android.systemui.notifications.ui.composable.NotificationsShadeSessionModule import com.android.systemui.scene.domain.SceneDomainModule import com.android.systemui.scene.domain.interactor.WindowRootViewVisibilityInteractor @@ -43,7 +42,6 @@ import dagger.multibindings.IntoMap [ BouncerSceneModule::class, CommunalSceneModule::class, - ComposeBouncerFlagsModule::class, EmptySceneModule::class, GoneSceneModule::class, LockscreenSceneModule::class, diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/bouncer/shared/flag/ComposeBouncerFlagsKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/bouncer/shared/flag/ComposeBouncerFlagsKosmos.kt deleted file mode 100644 index 60d97d1b1437..000000000000 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/bouncer/shared/flag/ComposeBouncerFlagsKosmos.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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 - -var Kosmos.fakeComposeBouncerFlags by Kosmos.Fixture { FakeComposeBouncerFlags() } -val Kosmos.composeBouncerFlags by Kosmos.Fixture<ComposeBouncerFlags> { fakeComposeBouncerFlags } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/bouncer/shared/flag/FakeComposeBouncerFlags.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/bouncer/shared/flag/FakeComposeBouncerFlags.kt deleted file mode 100644 index 7482c0feb56a..000000000000 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/bouncer/shared/flag/FakeComposeBouncerFlags.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.SceneContainerFlag - -class FakeComposeBouncerFlags(var composeBouncerEnabled: Boolean = false) : ComposeBouncerFlags { - override fun isComposeBouncerOrSceneContainerEnabled(): Boolean { - return SceneContainerFlag.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 -} diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/bouncer/ui/viewmodel/BouncerMessageViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/bouncer/ui/viewmodel/BouncerMessageViewModelKosmos.kt index e8612d084b14..5c5969d359c3 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/bouncer/ui/viewmodel/BouncerMessageViewModelKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/bouncer/ui/viewmodel/BouncerMessageViewModelKosmos.kt @@ -22,7 +22,6 @@ import android.content.applicationContext import com.android.systemui.authentication.domain.interactor.authenticationInteractor 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.deviceentry.domain.interactor.biometricMessageInteractor import com.android.systemui.deviceentry.domain.interactor.deviceEntryBiometricsAllowedInteractor import com.android.systemui.deviceentry.domain.interactor.deviceEntryFaceAuthInteractor @@ -45,7 +44,6 @@ val Kosmos.bouncerMessageViewModel by Fixture { faceAuthInteractor = deviceEntryFaceAuthInteractor, deviceUnlockedInteractor = deviceUnlockedInteractor, deviceEntryBiometricsAllowedInteractor = deviceEntryBiometricsAllowedInteractor, - flags = composeBouncerFlags, ) } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModelKosmos.kt index e405d17166b9..171be97bf964 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModelKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModelKosmos.kt @@ -25,7 +25,6 @@ import com.android.systemui.authentication.shared.model.AuthenticationMethodMode 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 @@ -55,7 +54,6 @@ val Kosmos.bouncerSceneContentViewModel by Fixture { authenticationInteractor = authenticationInteractor, devicePolicyManager = devicePolicyManager, bouncerMessageViewModelFactory = bouncerMessageViewModelFactory, - flags = composeBouncerFlags, userSwitcher = userSwitcherViewModel, actionButtonInteractor = bouncerActionButtonInteractor, pinViewModelFactory = pinBouncerViewModelFactory, |