• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.Flags
22 import com.android.systemui.dagger.SysUISingleton
23 import com.android.systemui.flags.FeatureFlagsClassic
24 import com.android.systemui.flags.Flags as FlagsClassic
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         return StatusBarManager.useMediaSessionActionsForApp(packageName, user)
34     }
35 
36     /** Check whether media control actions should be derived from Media3 controller */
areMedia3ActionsEnablednull37     fun areMedia3ActionsEnabled(packageName: String, user: UserHandle): Boolean {
38         val compatFlag = StatusBarManager.useMedia3ControllerForApp(packageName, user)
39         val featureFlag = Flags.mediaControlsButtonMedia3()
40         return featureFlag && compatFlag
41     }
42 
43     /**
44      * If true, keep active media controls for the lifetime of the MediaSession, regardless of
45      * whether the underlying notification was dismissed
46      */
isRetainingPlayersEnablednull47     fun isRetainingPlayersEnabled() = featureFlags.isEnabled(FlagsClassic.MEDIA_RETAIN_SESSIONS)
48 }
49