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      * Icon shown on player, close to app name.
35      */
36     val appIcon: Drawable?,
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      * Indicates that this player is a resumption player (ie. It only shows a play actions which
86      * will start the app and start playing).
87      */
88     var resumption: Boolean = false,
89     /**
90      * Notification key for cancelling a media player after a timeout (when not using resumption.)
91      */
92     val notificationKey: String? = null,
93     var hasCheckedForResume: Boolean = false
94 )
95 
96 /** State of a media action. */
97 data class MediaAction(
98     val drawable: Drawable?,
99     val action: Runnable?,
100     val contentDescription: CharSequence?
101 )
102 
103 /** State of the media device. */
104 data class MediaDeviceData(
105     val enabled: Boolean,
106     val icon: Drawable?,
107     val name: String?
108 )
109