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.FeatureFlags 23 import com.android.systemui.flags.Flags 24 import javax.inject.Inject 25 26 @SysUISingleton 27 class MediaFlags @Inject constructor(private val featureFlags: FeatureFlags) { 28 /** 29 * Check whether media control actions should be based on PlaybackState instead of notification 30 */ areMediaSessionActionsEnablednull31 fun areMediaSessionActionsEnabled(packageName: String, user: UserHandle): Boolean { 32 val enabled = StatusBarManager.useMediaSessionActionsForApp(packageName, user) 33 // Allow global override with flag 34 return enabled || featureFlags.isEnabled(Flags.MEDIA_SESSION_ACTIONS) 35 } 36 37 /** Check whether we support displaying information about mute await connections. */ areMuteAwaitConnectionsEnablednull38 fun areMuteAwaitConnectionsEnabled() = featureFlags.isEnabled(Flags.MEDIA_MUTE_AWAIT) 39 40 /** 41 * Check whether we enable support for nearby media devices. See 42 * [android.app.StatusBarManager.registerNearbyMediaDevicesProvider] for more information. 43 */ 44 fun areNearbyMediaDevicesEnabled() = featureFlags.isEnabled(Flags.MEDIA_NEARBY_DEVICES) 45 46 /** Check whether we show explicit indicator on UMO */ 47 fun isExplicitIndicatorEnabled() = featureFlags.isEnabled(Flags.MEDIA_EXPLICIT_INDICATOR) 48 49 /** 50 * If true, keep active media controls for the lifetime of the MediaSession, regardless of 51 * whether the underlying notification was dismissed 52 */ 53 fun isRetainingPlayersEnabled() = featureFlags.isEnabled(Flags.MEDIA_RETAIN_SESSIONS) 54 55 /** Check whether we show the updated recommendation card. */ 56 fun isRecommendationCardUpdateEnabled() = 57 featureFlags.isEnabled(Flags.MEDIA_RECOMMENDATION_CARD_UPDATE) 58 59 /** Check whether to get progress information for resume players */ 60 fun isResumeProgressEnabled() = featureFlags.isEnabled(Flags.MEDIA_RESUME_PROGRESS) 61 62 /** If true, do not automatically dismiss the recommendation card */ 63 fun isPersistentSsCardEnabled() = featureFlags.isEnabled(Flags.MEDIA_RETAIN_RECOMMENDATIONS) 64 65 /** Check whether we allow remote media to generate resume controls */ 66 fun isRemoteResumeAllowed() = featureFlags.isEnabled(Flags.MEDIA_REMOTE_RESUME) 67 } 68