Loading packages/SystemUI/src/com/android/systemui/flags/Flags.kt +3 −19 Original line number Diff line number Diff line Loading @@ -545,28 +545,12 @@ object Flags { unreleasedFlag("clipboard_shared_transitions", teamfood = true) /** * Whether the scene container (Flexiglass) is enabled. Note that [SCENE_CONTAINER] should be * checked and toggled together with [SCENE_CONTAINER_ENABLED] so that ProGuard can remove * unused code from our APK at compile time. * Whether the scene container (Flexiglass) is enabled. Note that SceneContainerFlags#isEnabled * should be checked and toggled together with [SCENE_CONTAINER_ENABLED] so that ProGuard can * remove unused code from our APK at compile time. */ // TODO(b/283300105): Tracking Bug @JvmField val SCENE_CONTAINER_ENABLED = false @Deprecated( message = """ Do not use this flag directly. Please use [com.android.systemui.scene.shared.flag.SceneContainerFlags#isEnabled]. (Not really deprecated but using this as a simple way to bring attention to the above). """, replaceWith = ReplaceWith( "com.android.systemui.scene.shared.flag.SceneContainerFlags#isEnabled", ), level = DeprecationLevel.WARNING, ) @JvmField val SCENE_CONTAINER = resourceBooleanFlag( R.bool.config_sceneContainerFrameworkEnabled, "scene_container", ) // 1900 @JvmField val NOTE_TASKS = releasedFlag("keycode_flag") Loading packages/SystemUI/src/com/android/systemui/scene/shared/flag/SceneContainerFlags.kt +17 −1 Original line number Diff line number Diff line Loading @@ -16,12 +16,14 @@ package com.android.systemui.scene.shared.flag import android.content.Context import androidx.annotation.VisibleForTesting import com.android.systemui.Flags as AConfigFlags import com.android.systemui.Flags.keyguardBottomAreaRefactor import com.android.systemui.Flags.sceneContainer import com.android.systemui.compose.ComposeFacade import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.flags.FeatureFlagsClassic import com.android.systemui.flags.Flag import com.android.systemui.flags.Flags Loading @@ -29,6 +31,7 @@ import com.android.systemui.flags.ReleasedFlag import com.android.systemui.flags.ResourceBooleanFlag import com.android.systemui.flags.UnreleasedFlag import com.android.systemui.keyguard.shared.KeyguardShadeMigrationNssl import com.android.systemui.res.R import dagger.Module import dagger.Provides import dagger.assisted.Assisted Loading @@ -51,6 +54,7 @@ interface SceneContainerFlags { class SceneContainerFlagsImpl @AssistedInject constructor( @Application private val context: Context, private val featureFlagsClassic: FeatureFlagsClassic, @Assisted private val isComposeAvailable: Boolean, ) : SceneContainerFlags { Loading Loading @@ -80,7 +84,11 @@ constructor( ), ) + classicFlagTokens.map { flagToken -> FlagMustBeEnabled(flagToken) } + listOf(ComposeMustBeAvailable(), CompileTimeFlagMustBeEnabled()) listOf( ComposeMustBeAvailable(), CompileTimeFlagMustBeEnabled(), ResourceConfigMustBeEnabled() ) override fun isEnabled(): Boolean { // SCENE_CONTAINER_ENABLED is an explicit static flag check that helps with downstream Loading Loading @@ -146,6 +154,14 @@ constructor( } } private inner class ResourceConfigMustBeEnabled : Requirement { override val name: String = "R.bool.config_sceneContainerFrameworkEnabled must be true" override fun isMet(): Boolean { return context.resources.getBoolean(R.bool.config_sceneContainerFrameworkEnabled) } } @AssistedFactory interface Factory { fun create(isComposeAvailable: Boolean): SceneContainerFlagsImpl Loading packages/SystemUI/tests/src/com/android/systemui/scene/shared/flag/SceneContainerFlagsTest.kt +16 −8 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import com.android.systemui.flags.ReleasedFlag import com.android.systemui.flags.ResourceBooleanFlag import com.android.systemui.flags.UnreleasedFlag import com.android.systemui.keyguard.shared.KeyguardShadeMigrationNssl import com.android.systemui.res.R import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Rule Loading Loading @@ -74,10 +75,15 @@ internal class SceneContainerFlagsTest( .forEach { flagToken -> setFlagsRule.enableFlags(flagToken) aconfigFlags.setFlag(flagToken, testCase.areAllFlagsSet) overrideResource( R.bool.config_sceneContainerFrameworkEnabled, testCase.isResourceConfigEnabled ) } underTest = SceneContainerFlagsImpl( context = context, featureFlagsClassic = featureFlags, isComposeAvailable = testCase.isComposeAvailable, ) Loading @@ -91,13 +97,12 @@ internal class SceneContainerFlagsTest( internal data class TestCase( val isComposeAvailable: Boolean, val areAllFlagsSet: Boolean, val isResourceConfigEnabled: Boolean, val expectedEnabled: Boolean, ) { override fun toString(): String { return """ (compose=$isComposeAvailable + flags=$areAllFlagsSet) -> expected=$expectedEnabled """ .trimIndent() return "(compose=$isComposeAvailable + flags=$areAllFlagsSet) + XML" + " config=$isResourceConfigEnabled -> expected=$expectedEnabled" } } Loading @@ -105,17 +110,20 @@ internal class SceneContainerFlagsTest( @Parameterized.Parameters(name = "{0}") @JvmStatic fun testCases() = buildList { repeat(4) { combination -> val isComposeAvailable = combination and 0b10 != 0 val areAllFlagsSet = combination and 0b01 != 0 repeat(8) { combination -> val isComposeAvailable = combination and 0b100 != 0 val areAllFlagsSet = combination and 0b010 != 0 val isResourceConfigEnabled = combination and 0b001 != 0 val expectedEnabled = isComposeAvailable && areAllFlagsSet val expectedEnabled = isComposeAvailable && areAllFlagsSet && isResourceConfigEnabled add( TestCase( isComposeAvailable = isComposeAvailable, areAllFlagsSet = areAllFlagsSet, expectedEnabled = expectedEnabled, isResourceConfigEnabled = isResourceConfigEnabled, ) ) } Loading Loading
packages/SystemUI/src/com/android/systemui/flags/Flags.kt +3 −19 Original line number Diff line number Diff line Loading @@ -545,28 +545,12 @@ object Flags { unreleasedFlag("clipboard_shared_transitions", teamfood = true) /** * Whether the scene container (Flexiglass) is enabled. Note that [SCENE_CONTAINER] should be * checked and toggled together with [SCENE_CONTAINER_ENABLED] so that ProGuard can remove * unused code from our APK at compile time. * Whether the scene container (Flexiglass) is enabled. Note that SceneContainerFlags#isEnabled * should be checked and toggled together with [SCENE_CONTAINER_ENABLED] so that ProGuard can * remove unused code from our APK at compile time. */ // TODO(b/283300105): Tracking Bug @JvmField val SCENE_CONTAINER_ENABLED = false @Deprecated( message = """ Do not use this flag directly. Please use [com.android.systemui.scene.shared.flag.SceneContainerFlags#isEnabled]. (Not really deprecated but using this as a simple way to bring attention to the above). """, replaceWith = ReplaceWith( "com.android.systemui.scene.shared.flag.SceneContainerFlags#isEnabled", ), level = DeprecationLevel.WARNING, ) @JvmField val SCENE_CONTAINER = resourceBooleanFlag( R.bool.config_sceneContainerFrameworkEnabled, "scene_container", ) // 1900 @JvmField val NOTE_TASKS = releasedFlag("keycode_flag") Loading
packages/SystemUI/src/com/android/systemui/scene/shared/flag/SceneContainerFlags.kt +17 −1 Original line number Diff line number Diff line Loading @@ -16,12 +16,14 @@ package com.android.systemui.scene.shared.flag import android.content.Context import androidx.annotation.VisibleForTesting import com.android.systemui.Flags as AConfigFlags import com.android.systemui.Flags.keyguardBottomAreaRefactor import com.android.systemui.Flags.sceneContainer import com.android.systemui.compose.ComposeFacade import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.flags.FeatureFlagsClassic import com.android.systemui.flags.Flag import com.android.systemui.flags.Flags Loading @@ -29,6 +31,7 @@ import com.android.systemui.flags.ReleasedFlag import com.android.systemui.flags.ResourceBooleanFlag import com.android.systemui.flags.UnreleasedFlag import com.android.systemui.keyguard.shared.KeyguardShadeMigrationNssl import com.android.systemui.res.R import dagger.Module import dagger.Provides import dagger.assisted.Assisted Loading @@ -51,6 +54,7 @@ interface SceneContainerFlags { class SceneContainerFlagsImpl @AssistedInject constructor( @Application private val context: Context, private val featureFlagsClassic: FeatureFlagsClassic, @Assisted private val isComposeAvailable: Boolean, ) : SceneContainerFlags { Loading Loading @@ -80,7 +84,11 @@ constructor( ), ) + classicFlagTokens.map { flagToken -> FlagMustBeEnabled(flagToken) } + listOf(ComposeMustBeAvailable(), CompileTimeFlagMustBeEnabled()) listOf( ComposeMustBeAvailable(), CompileTimeFlagMustBeEnabled(), ResourceConfigMustBeEnabled() ) override fun isEnabled(): Boolean { // SCENE_CONTAINER_ENABLED is an explicit static flag check that helps with downstream Loading Loading @@ -146,6 +154,14 @@ constructor( } } private inner class ResourceConfigMustBeEnabled : Requirement { override val name: String = "R.bool.config_sceneContainerFrameworkEnabled must be true" override fun isMet(): Boolean { return context.resources.getBoolean(R.bool.config_sceneContainerFrameworkEnabled) } } @AssistedFactory interface Factory { fun create(isComposeAvailable: Boolean): SceneContainerFlagsImpl Loading
packages/SystemUI/tests/src/com/android/systemui/scene/shared/flag/SceneContainerFlagsTest.kt +16 −8 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import com.android.systemui.flags.ReleasedFlag import com.android.systemui.flags.ResourceBooleanFlag import com.android.systemui.flags.UnreleasedFlag import com.android.systemui.keyguard.shared.KeyguardShadeMigrationNssl import com.android.systemui.res.R import com.google.common.truth.Truth.assertThat import org.junit.Before import org.junit.Rule Loading Loading @@ -74,10 +75,15 @@ internal class SceneContainerFlagsTest( .forEach { flagToken -> setFlagsRule.enableFlags(flagToken) aconfigFlags.setFlag(flagToken, testCase.areAllFlagsSet) overrideResource( R.bool.config_sceneContainerFrameworkEnabled, testCase.isResourceConfigEnabled ) } underTest = SceneContainerFlagsImpl( context = context, featureFlagsClassic = featureFlags, isComposeAvailable = testCase.isComposeAvailable, ) Loading @@ -91,13 +97,12 @@ internal class SceneContainerFlagsTest( internal data class TestCase( val isComposeAvailable: Boolean, val areAllFlagsSet: Boolean, val isResourceConfigEnabled: Boolean, val expectedEnabled: Boolean, ) { override fun toString(): String { return """ (compose=$isComposeAvailable + flags=$areAllFlagsSet) -> expected=$expectedEnabled """ .trimIndent() return "(compose=$isComposeAvailable + flags=$areAllFlagsSet) + XML" + " config=$isResourceConfigEnabled -> expected=$expectedEnabled" } } Loading @@ -105,17 +110,20 @@ internal class SceneContainerFlagsTest( @Parameterized.Parameters(name = "{0}") @JvmStatic fun testCases() = buildList { repeat(4) { combination -> val isComposeAvailable = combination and 0b10 != 0 val areAllFlagsSet = combination and 0b01 != 0 repeat(8) { combination -> val isComposeAvailable = combination and 0b100 != 0 val areAllFlagsSet = combination and 0b010 != 0 val isResourceConfigEnabled = combination and 0b001 != 0 val expectedEnabled = isComposeAvailable && areAllFlagsSet val expectedEnabled = isComposeAvailable && areAllFlagsSet && isResourceConfigEnabled add( TestCase( isComposeAvailable = isComposeAvailable, areAllFlagsSet = areAllFlagsSet, expectedEnabled = expectedEnabled, isResourceConfigEnabled = isResourceConfigEnabled, ) ) } Loading