1 /* 2 * Copyright (C) 2020 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 18 19 import android.app.PendingIntent 20 import android.graphics.drawable.Drawable 21 import android.graphics.drawable.Icon 22 import android.media.session.MediaSession 23 24 /** State of a media view. */ 25 data class MediaData( 26 val userId: Int, 27 val initialized: Boolean = false, 28 val backgroundColor: Int, 29 /** 30 * App name that will be displayed on the player. 31 */ 32 val app: String?, 33 /** 34 * App icon shown on player. 35 */ 36 val appIcon: Icon?, 37 /** 38 * Artist name. 39 */ 40 val artist: CharSequence?, 41 /** 42 * Song name. 43 */ 44 val song: CharSequence?, 45 /** 46 * Album artwork. 47 */ 48 val artwork: Icon?, 49 /** 50 * List of actions that can be performed on the player: prev, next, play, pause, etc. 51 */ 52 val actions: List<MediaAction>, 53 /** 54 * Same as above, but shown on smaller versions of the player, like in QQS or keyguard. 55 */ 56 val actionsToShowInCompact: List<Int>, 57 /** 58 * Package name of the app that's posting the media. 59 */ 60 val packageName: String, 61 /** 62 * Unique media session identifier. 63 */ 64 val token: MediaSession.Token?, 65 /** 66 * Action to perform when the player is tapped. 67 * This is unrelated to {@link #actions}. 68 */ 69 val clickIntent: PendingIntent?, 70 /** 71 * Where the media is playing: phone, headphones, ear buds, remote session. 72 */ 73 val device: MediaDeviceData?, 74 /** 75 * When active, a player will be displayed on keyguard and quick-quick settings. 76 * This is unrelated to the stream being playing or not, a player will not be active if 77 * timed out, or in resumption mode. 78 */ 79 var active: Boolean, 80 /** 81 * Action that should be performed to restart a non active session. 82 */ 83 var resumeAction: Runnable?, 84 /** 85 * Local or remote playback 86 */ 87 var isLocalSession: Boolean = true, 88 /** 89 * Indicates that this player is a resumption player (ie. It only shows a play actions which 90 * will start the app and start playing). 91 */ 92 var resumption: Boolean = false, 93 /** 94 * Notification key for cancelling a media player after a timeout (when not using resumption.) 95 */ 96 val notificationKey: String? = null, 97 var hasCheckedForResume: Boolean = false, 98 99 /** 100 * If apps do not report PlaybackState, set as null to imply 'undetermined' 101 */ 102 val isPlaying: Boolean? = null, 103 104 /** 105 * Set from the notification and used as fallback when PlaybackState cannot be determined 106 */ 107 val isClearable: Boolean = true, 108 109 /** 110 * Timestamp when this player was last active. 111 */ 112 var lastActive: Long = 0L 113 ) 114 115 /** State of a media action. */ 116 data class MediaAction( 117 val icon: Icon?, 118 val action: Runnable?, 119 val contentDescription: CharSequence? 120 ) 121 122 /** State of the media device. */ 123 data class MediaDeviceData( 124 val enabled: Boolean, 125 val icon: Drawable?, 126 val name: String? 127 ) 128