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

Commit e51a5d31 authored by Aaron Liu's avatar Aaron Liu
Browse files

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
parent 09f01997
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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"
}

+10 −0
Original line number Diff line number Diff line
@@ -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())
}
+54 −0
Original line number Diff line number Diff line
/*
 * 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)
}