1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.media.controls.util 18 19 import android.app.StatusBarManager 20 import android.os.UserHandle 21 import com.android.systemui.dagger.SysUISingleton 22 import com.android.systemui.flags.FeatureFlagsClassic 23 import com.android.systemui.flags.Flags 24 import com.android.systemui.scene.shared.flag.SceneContainerFlag 25 import javax.inject.Inject 26 27 @SysUISingleton 28 class MediaFlags @Inject constructor(private val featureFlags: FeatureFlagsClassic) { 29 /** 30 * Check whether media control actions should be based on PlaybackState instead of notification 31 */ areMediaSessionActionsEnablednull32 fun areMediaSessionActionsEnabled(packageName: String, user: UserHandle): Boolean { 33 val enabled = StatusBarManager.useMediaSessionActionsForApp(packageName, user) 34 // Allow global override with flag 35 return enabled || featureFlags.isEnabled(Flags.MEDIA_SESSION_ACTIONS) 36 } 37 38 /** 39 * If true, keep active media controls for the lifetime of the MediaSession, regardless of 40 * whether the underlying notification was dismissed 41 */ isRetainingPlayersEnablednull42 fun isRetainingPlayersEnabled() = featureFlags.isEnabled(Flags.MEDIA_RETAIN_SESSIONS) 43 44 /** Check whether to get progress information for resume players */ 45 fun isResumeProgressEnabled() = featureFlags.isEnabled(Flags.MEDIA_RESUME_PROGRESS) 46 47 /** If true, do not automatically dismiss the recommendation card */ 48 fun isPersistentSsCardEnabled() = featureFlags.isEnabled(Flags.MEDIA_RETAIN_RECOMMENDATIONS) 49 50 /** Check whether we allow remote media to generate resume controls */ 51 fun isRemoteResumeAllowed() = featureFlags.isEnabled(Flags.MEDIA_REMOTE_RESUME) 52 53 /** Check whether to use scene framework */ 54 fun isSceneContainerEnabled() = SceneContainerFlag.isEnabled 55 } 56