diff options
| author | 2024-01-30 13:22:41 -0800 | |
|---|---|---|
| committer | 2024-01-31 13:03:03 -0800 | |
| commit | e51a5d3146acd71cd128f60706d97a350d46ed66 (patch) | |
| tree | b557342aaa161499afb4c156f7a5a5cc99f97dcb | |
| parent | 09f0199735db2cbfda387fbfa1a353d22f89dfa7 (diff) | |
Rename ACONFIG flag and add flag wrapper
Rename enable_keyguard_compose to compose_lockscreen.
Also add a flag wrapper which enables flag dependencies.
Test: Ensure that code compiles. Try different flag combinations.
Bug: 301968149
Flag: ACONFIG com.android.systemui.compose_lockscreen DEVELOPMENT
Change-Id: I18aeb62f5e16bd4b656179fe91e8e370c1d1232d
3 files changed, 66 insertions, 2 deletions
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig index 3db99f284e4c..0b244426b69e 100644 --- a/packages/SystemUI/aconfig/systemui.aconfig +++ b/packages/SystemUI/aconfig/systemui.aconfig @@ -365,9 +365,9 @@ flag { } flag { - name: "enable_keyguard_compose" + name: "compose_lockscreen" namespace: "systemui" - description: "Enables the compose version of keyguard." + description: "Enables the compose version of lockscreen that runs standalone, outside of Flexiglass." bug: "301968149" } diff --git a/packages/SystemUI/src/com/android/systemui/flags/FlagDependencies.kt b/packages/SystemUI/src/com/android/systemui/flags/FlagDependencies.kt index df0566e246a8..41ce3fd11e8a 100644 --- a/packages/SystemUI/src/com/android/systemui/flags/FlagDependencies.kt +++ b/packages/SystemUI/src/com/android/systemui/flags/FlagDependencies.kt @@ -23,9 +23,12 @@ import com.android.server.notification.Flags.crossAppPoliteNotifications import com.android.server.notification.Flags.politeNotifications import com.android.server.notification.Flags.vibrateWhileUnlocked import com.android.systemui.Flags.FLAG_KEYGUARD_BOTTOM_AREA_REFACTOR +import com.android.systemui.Flags.FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT import com.android.systemui.Flags.keyguardBottomAreaRefactor +import com.android.systemui.Flags.migrateClocksToBlueprint import com.android.systemui.dagger.SysUISingleton import com.android.systemui.flags.Flags.MIGRATE_KEYGUARD_STATUS_BAR_VIEW +import com.android.systemui.keyguard.shared.ComposeLockscreen import com.android.systemui.keyguard.shared.KeyguardShadeMigrationNssl import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.statusbar.notification.footer.shared.FooterViewRefactor @@ -55,6 +58,11 @@ class FlagDependencies @Inject constructor(featureFlags: FeatureFlagsClassic, ha // SceneContainer dependencies SceneContainerFlag.getFlagDependencies().forEach { (alpha, beta) -> alpha dependsOn beta } SceneContainerFlag.getMainStaticFlag() dependsOn MIGRATE_KEYGUARD_STATUS_BAR_VIEW + + // ComposeLockscreen dependencies + ComposeLockscreen.token dependsOn KeyguardShadeMigrationNssl.token + ComposeLockscreen.token dependsOn keyguardBottomAreaRefactor + ComposeLockscreen.token dependsOn migrateClocksToBlueprint } private inline val politeNotifications @@ -65,4 +73,6 @@ class FlagDependencies @Inject constructor(featureFlags: FeatureFlagsClassic, ha get() = FlagToken(FLAG_VIBRATE_WHILE_UNLOCKED, vibrateWhileUnlocked()) private inline val keyguardBottomAreaRefactor get() = FlagToken(FLAG_KEYGUARD_BOTTOM_AREA_REFACTOR, keyguardBottomAreaRefactor()) + private inline val migrateClocksToBlueprint + get() = FlagToken(FLAG_MIGRATE_CLOCKS_TO_BLUEPRINT, migrateClocksToBlueprint()) } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/shared/ComposeLockscreen.kt b/packages/SystemUI/src/com/android/systemui/keyguard/shared/ComposeLockscreen.kt new file mode 100644 index 000000000000..7f0b483919b3 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/keyguard/shared/ComposeLockscreen.kt @@ -0,0 +1,54 @@ +/* + * 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.keyguard.shared + +import com.android.systemui.Flags +import com.android.systemui.compose.ComposeFacade +import com.android.systemui.flags.FlagToken +import com.android.systemui.flags.RefactorFlagUtils + +/** Helper for reading or using the compose lockscreen flag state. */ +@Suppress("NOTHING_TO_INLINE") +object ComposeLockscreen { + /** The aconfig flag name */ + const val FLAG_NAME = Flags.FLAG_COMPOSE_LOCKSCREEN + + /** A token used for dependency declaration */ + val token: FlagToken + get() = FlagToken(FLAG_NAME, isEnabled) + + /** Is the refactor enabled */ + @JvmStatic + inline val isEnabled + get() = Flags.composeLockscreen() && ComposeFacade.isComposeAvailable() + + /** + * Called to ensure code is only run when the flag is enabled. This protects users from the + * unintended behaviors caused by accidentally running new logic, while also crashing on an eng + * build to ensure that the refactor author catches issues in testing. + */ + @JvmStatic + inline fun isUnexpectedlyInLegacyMode() = + RefactorFlagUtils.isUnexpectedlyInLegacyMode(isEnabled, FLAG_NAME) + + /** + * Called to ensure code is only run when the flag is disabled. This will throw an exception if + * the flag is enabled to ensure that the refactor author catches issues in testing. + */ + @JvmStatic + inline fun assertInLegacyMode() = RefactorFlagUtils.assertInLegacyMode(isEnabled, FLAG_NAME) +} |