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