1 /*
2  * Copyright 2018 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 android.media.update;
18 
19 import android.app.PendingIntent;
20 import android.media.AudioFocusRequest;
21 import android.media.MediaItem2;
22 import android.media.MediaMetadata2;
23 import android.media.MediaPlayerBase;
24 import android.media.MediaPlaylistAgent;
25 import android.media.MediaSession2;
26 import android.media.SessionCommand2;
27 import android.media.MediaSession2.CommandButton;
28 import android.media.MediaSession2.CommandButton.Builder;
29 import android.media.SessionCommandGroup2;
30 import android.media.MediaSession2.ControllerInfo;
31 import android.media.MediaSession2.OnDataSourceMissingHelper;
32 import android.media.MediaSession2.SessionCallback;
33 import android.media.SessionToken2;
34 import android.media.VolumeProvider2;
35 import android.os.Bundle;
36 import android.os.ResultReceiver;
37 
38 import java.util.List;
39 import java.util.Set;
40 import java.util.concurrent.Executor;
41 
42 /**
43  * @hide
44  */
45 public interface MediaSession2Provider extends TransportControlProvider {
close_impl()46     void close_impl();
updatePlayer_impl(MediaPlayerBase player, MediaPlaylistAgent playlistAgent, VolumeProvider2 volumeProvider)47     void updatePlayer_impl(MediaPlayerBase player, MediaPlaylistAgent playlistAgent,
48             VolumeProvider2 volumeProvider);
getPlayer_impl()49     MediaPlayerBase getPlayer_impl();
getPlaylistMetadata_impl()50     MediaMetadata2 getPlaylistMetadata_impl();
updatePlaylistMetadata_impl(MediaMetadata2 metadata)51     void updatePlaylistMetadata_impl(MediaMetadata2 metadata);
getPlaylistAgent_impl()52     MediaPlaylistAgent getPlaylistAgent_impl();
getVolumeProvider_impl()53     VolumeProvider2 getVolumeProvider_impl();
getToken_impl()54     SessionToken2 getToken_impl();
getConnectedControllers_impl()55     List<ControllerInfo> getConnectedControllers_impl();
setCustomLayout_impl(ControllerInfo controller, List<CommandButton> layout)56     void setCustomLayout_impl(ControllerInfo controller, List<CommandButton> layout);
setAudioFocusRequest_impl(AudioFocusRequest afr)57     void setAudioFocusRequest_impl(AudioFocusRequest afr);
setAllowedCommands_impl(ControllerInfo controller, SessionCommandGroup2 commands)58     void setAllowedCommands_impl(ControllerInfo controller, SessionCommandGroup2 commands);
sendCustomCommand_impl(ControllerInfo controller, SessionCommand2 command, Bundle args, ResultReceiver receiver)59     void sendCustomCommand_impl(ControllerInfo controller, SessionCommand2 command, Bundle args,
60             ResultReceiver receiver);
sendCustomCommand_impl(SessionCommand2 command, Bundle args)61     void sendCustomCommand_impl(SessionCommand2 command, Bundle args);
addPlaylistItem_impl(int index, MediaItem2 item)62     void addPlaylistItem_impl(int index, MediaItem2 item);
removePlaylistItem_impl(MediaItem2 item)63     void removePlaylistItem_impl(MediaItem2 item);
replacePlaylistItem_impl(int index, MediaItem2 item)64     void replacePlaylistItem_impl(int index, MediaItem2 item);
getPlaylist_impl()65     List<MediaItem2> getPlaylist_impl();
setPlaylist_impl(List<MediaItem2> list, MediaMetadata2 metadata)66     void setPlaylist_impl(List<MediaItem2> list, MediaMetadata2 metadata);
getCurrentPlaylistItem_impl()67     MediaItem2 getCurrentPlaylistItem_impl();
notifyError_impl(int errorCode, Bundle extras)68     void notifyError_impl(int errorCode, Bundle extras);
getPlayerState_impl()69     int getPlayerState_impl();
getCurrentPosition_impl()70     long getCurrentPosition_impl();
getBufferedPosition_impl()71     long getBufferedPosition_impl();
setOnDataSourceMissingHelper_impl(OnDataSourceMissingHelper helper)72     void setOnDataSourceMissingHelper_impl(OnDataSourceMissingHelper helper);
clearOnDataSourceMissingHelper_impl()73     void clearOnDataSourceMissingHelper_impl();
74 
75     // TODO(jaewan): Rename and move provider
76     interface CommandProvider {
getCommandCode_impl()77         int getCommandCode_impl();
getCustomCommand_impl()78         String getCustomCommand_impl();
getExtras_impl()79         Bundle getExtras_impl();
toBundle_impl()80         Bundle toBundle_impl();
81 
equals_impl(Object ob)82         boolean equals_impl(Object ob);
hashCode_impl()83         int hashCode_impl();
84     }
85 
86     // TODO(jaewan): Rename and move provider
87     interface CommandGroupProvider {
addCommand_impl(SessionCommand2 command)88         void addCommand_impl(SessionCommand2 command);
addAllPredefinedCommands_impl()89         void addAllPredefinedCommands_impl();
removeCommand_impl(SessionCommand2 command)90         void removeCommand_impl(SessionCommand2 command);
hasCommand_impl(SessionCommand2 command)91         boolean hasCommand_impl(SessionCommand2 command);
hasCommand_impl(int code)92         boolean hasCommand_impl(int code);
getCommands_impl()93         Set<SessionCommand2> getCommands_impl();
toBundle_impl()94         Bundle toBundle_impl();
95     }
96 
97     interface CommandButtonProvider {
getCommand_impl()98         SessionCommand2 getCommand_impl();
getIconResId_impl()99         int getIconResId_impl();
getDisplayName_impl()100         String getDisplayName_impl();
getExtras_impl()101         Bundle getExtras_impl();
isEnabled_impl()102         boolean isEnabled_impl();
103 
104         interface BuilderProvider {
setCommand_impl(SessionCommand2 command)105             Builder setCommand_impl(SessionCommand2 command);
setIconResId_impl(int resId)106             Builder setIconResId_impl(int resId);
setDisplayName_impl(String displayName)107             Builder setDisplayName_impl(String displayName);
setEnabled_impl(boolean enabled)108             Builder setEnabled_impl(boolean enabled);
setExtras_impl(Bundle extras)109             Builder setExtras_impl(Bundle extras);
build_impl()110             CommandButton build_impl();
111         }
112     }
113 
114     interface ControllerInfoProvider {
getPackageName_impl()115         String getPackageName_impl();
getUid_impl()116         int getUid_impl();
isTrusted_impl()117         boolean isTrusted_impl();
hashCode_impl()118         int hashCode_impl();
equals_impl(Object obj)119         boolean equals_impl(Object obj);
toString_impl()120         String toString_impl();
121     }
122 
123     interface BuilderBaseProvider<T extends MediaSession2, C extends SessionCallback> {
setPlayer_impl(MediaPlayerBase player)124         void setPlayer_impl(MediaPlayerBase player);
setPlaylistAgent_impl(MediaPlaylistAgent playlistAgent)125         void setPlaylistAgent_impl(MediaPlaylistAgent playlistAgent);
setVolumeProvider_impl(VolumeProvider2 volumeProvider)126         void setVolumeProvider_impl(VolumeProvider2 volumeProvider);
setSessionActivity_impl(PendingIntent pi)127         void setSessionActivity_impl(PendingIntent pi);
setId_impl(String id)128         void setId_impl(String id);
setSessionCallback_impl(Executor executor, C callback)129         void setSessionCallback_impl(Executor executor, C callback);
build_impl()130         T build_impl();
131     }
132 }
133