Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ace83d3a authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[flexiglass] Simplifies SceneContainerFlag" into main

parents a623355e 8b049096
Loading
Loading
Loading
Loading
+0 −14
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.platform.test.flag.junit.FlagsParameterization
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags.FLAG_EXAMPLE_FLAG
import com.android.systemui.Flags.FLAG_NOTIFICATION_AVALANCHE_THROTTLE_HUN
import com.android.systemui.Flags.FLAG_SCENE_CONTAINER
import com.android.systemui.SysuiTestCase
import com.android.systemui.flags.andSceneContainer
@@ -64,17 +63,4 @@ internal class SceneContainerFlagParameterizationTest : SysuiTestCase() {
        Truth.assertThat(result[3].mOverrides[unrelatedFlag]).isTrue()
        Truth.assertThat(result[3].mOverrides[FLAG_SCENE_CONTAINER]).isTrue()
    }

    @Test
    fun oneDependencyAndSceneContainer() {
        val dependentFlag = FLAG_NOTIFICATION_AVALANCHE_THROTTLE_HUN
        val result = FlagsParameterization.allCombinationsOf(dependentFlag).andSceneContainer()
        Truth.assertThat(result).hasSize(3)
        Truth.assertThat(result[0].mOverrides[dependentFlag]).isFalse()
        Truth.assertThat(result[0].mOverrides[FLAG_SCENE_CONTAINER]).isFalse()
        Truth.assertThat(result[1].mOverrides[dependentFlag]).isTrue()
        Truth.assertThat(result[1].mOverrides[FLAG_SCENE_CONTAINER]).isFalse()
        Truth.assertThat(result[2].mOverrides[dependentFlag]).isTrue()
        Truth.assertThat(result[2].mOverrides[FLAG_SCENE_CONTAINER]).isTrue()
    }
}
+0 −4
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import com.android.server.notification.Flags.vibrateWhileUnlocked
import com.android.systemui.Flags.FLAG_COMMUNAL_HUB
import com.android.systemui.Flags.communalHub
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.statusbar.notification.interruption.VisualInterruptionRefactor
import com.android.systemui.statusbar.notification.shared.NotificationAvalancheSuppression
import com.android.systemui.statusbar.notification.shared.NotificationMinimalism
@@ -44,9 +43,6 @@ class FlagDependencies @Inject constructor(featureFlags: FeatureFlagsClassic, ha
        // Internal notification frontend dependencies
        NotificationAvalancheSuppression.token dependsOn VisualInterruptionRefactor.token
        NotificationMinimalism.token dependsOn NotificationThrottleHun.token

        // SceneContainer dependencies
        SceneContainerFlag.getFlagDependencies().forEach { (alpha, beta) -> alpha dependsOn beta }
    }

    private inline val politeNotifications
+0 −33
Original line number Diff line number Diff line
@@ -38,27 +38,6 @@ object QsDetailedView {
            Flags.qsTileDetailedView() && // mainAconfigFlag
                SceneContainerFlag.isEnabled

    // NOTE: Changes should also be made in getSecondaryFlags

    /** The main aconfig flag. */
    inline fun getMainAconfigFlag() = FlagToken(FLAG_NAME, Flags.qsTileDetailedView())

    /** The set of secondary flags which must be enabled for qs detailed view to work properly */
    inline fun getSecondaryFlags(): Sequence<FlagToken> =
        // NOTE: Changes should also be made in isEnabled
        SceneContainerFlag.getAllRequirements()

    /** The full set of requirements for QsDetailedView */
    inline fun getAllRequirements(): Sequence<FlagToken> {
        return sequenceOf(getMainAconfigFlag()) + getSecondaryFlags()
    }

    /** Return all dependencies of this flag in pairs where [Pair.first] depends on [Pair.second] */
    inline fun getFlagDependencies(): Sequence<Pair<FlagToken, FlagToken>> {
        val mainAconfigFlag = getMainAconfigFlag()
        return getSecondaryFlags().map { mainAconfigFlag to it }
    }

    /**
     * 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
@@ -84,16 +63,4 @@ object QsDetailedView {
    @Deprecated("Avoid crashing.", ReplaceWith("if (this.isUnexpectedlyInLegacyMode()) return"))
    inline fun unsafeAssertInNewMode() =
        RefactorFlagUtils.unsafeAssertInNewMode(isEnabled, FLAG_NAME)

    /** Returns a developer-readable string that describes the current requirement list. */
    @JvmStatic
    fun requirementDescription(): String {
        return buildString {
            getAllRequirements().forEach { requirement ->
                append('\n')
                append(if (requirement.isEnabled) "    [MET]" else "[NOT MET]")
                append(" ${requirement.name}")
            }
        }
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -29,8 +29,7 @@ object QsInCompose {
     * This is not a real flag name, but a representation of the allowed flag names. Should not be
     * used with test annotations.
     */
    private val flagName =
        "${QSComposeFragment.FLAG_NAME}|${SceneContainerFlag.getMainAconfigFlag().name}"
    private val flagName = "${QSComposeFragment.FLAG_NAME}|${SceneContainerFlag.DESCRIPTION}"

    @JvmStatic
    inline val isEnabled: Boolean
+1 −5
Original line number Diff line number Diff line
@@ -189,10 +189,7 @@ constructor(
            hydrateActivityTransitionAnimationState()
            lockWhenDeviceBecomesUntrusted()
        } else {
            sceneLogger.logFrameworkEnabled(
                isEnabled = false,
                reason = SceneContainerFlag.requirementDescription(),
            )
            sceneLogger.logFrameworkEnabled(isEnabled = false)
        }
    }

@@ -201,7 +198,6 @@ constructor(
            printSection("SceneContainerFlag") {
                printSection("Framework availability") {
                    println("isEnabled", SceneContainerFlag.isEnabled)
                    println(SceneContainerFlag.requirementDescription())
                }

                if (!SceneContainerFlag.isEnabled) {
Loading