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

Commit 622c4fe2 authored by Beth Thibodeau's avatar Beth Thibodeau
Browse files

Create aconfig flag for media in scene container

Bug: 296122467
Test: make
Flag: ACONFIG com.android.systemui.media_in_scene_container DEVELOPMENT
Change-Id: Idc8e69b9da152ee8054d4ef9366b8110f627fd92
parent b354181a
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -141,3 +141,10 @@ flag {
    description: "Move LightRevealScrim to recommended architecture"
    bug: "281655028"
}

flag {
   name: "media_in_scene_container"
   namespace: "systemui"
   description: "Enable media in the scene container framework"
   bug: "296122467"
}
+12 −2
Original line number Diff line number Diff line
@@ -19,12 +19,18 @@ package com.android.systemui.media.controls.util
import android.app.StatusBarManager
import android.os.UserHandle
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.FeatureFlagsClassic
import com.android.systemui.flags.Flags
import com.android.systemui.scene.shared.flag.SceneContainerFlags
import javax.inject.Inject

@SysUISingleton
class MediaFlags @Inject constructor(private val featureFlags: FeatureFlags) {
class MediaFlags
@Inject
constructor(
    private val featureFlags: FeatureFlagsClassic,
    private val sceneContainerFlags: SceneContainerFlags
) {
    /**
     * Check whether media control actions should be based on PlaybackState instead of notification
     */
@@ -48,4 +54,8 @@ class MediaFlags @Inject constructor(private val featureFlags: FeatureFlags) {

    /** Check whether we allow remote media to generate resume controls */
    fun isRemoteResumeAllowed() = featureFlags.isEnabled(Flags.MEDIA_REMOTE_RESUME)

    /** Check whether to use flexiglass layout */
    fun isFlexiglassEnabled() =
        sceneContainerFlags.isEnabled() && MediaInSceneContainerFlag.isEnabled
}
+48 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.media.controls.util

import com.android.systemui.Flags
import com.android.systemui.flags.RefactorFlagUtils

/** Helper for reading or using the media_in_scene_container flag state. */
@Suppress("NOTHING_TO_INLINE")
object MediaInSceneContainerFlag {
    /** The aconfig flag name */
    const val FLAG_NAME = Flags.FLAG_MEDIA_IN_SCENE_CONTAINER

    /** Is the flag enabled? */
    @JvmStatic
    inline val isEnabled
        get() = Flags.mediaInSceneContainer()

    /**
     * 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)
}