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 com.android.media; 18 19 import android.os.Bundle; 20 import android.os.ResultReceiver; 21 import android.net.Uri; 22 23 import com.android.media.IMediaController2; 24 25 /** 26 * Interface from MediaController2 to MediaSession2. 27 * <p> 28 * Keep this interface oneway. Otherwise a malicious app may implement fake version of this, 29 * and holds calls from session to make session owner(s) frozen. 30 */ 31 // TODO(jaewan): (Post P) Handle when the playlist becomes too huge. 32 // Note that ParcelledSliceList isn't a good idea for the purpose. (see: b/37493677) 33 oneway interface IMediaSession2 { 34 // TODO(jaewan): add onCommand() to send private command 35 36 // TODO(jaewan): (Post P) We may consider to add another binder just for the connection 37 // not to expose other methods to the controller whose connection wasn't accepted. 38 // But this would be enough for now because it's the same as existing 39 // MediaBrowser and MediaBrowserService. connect(IMediaController2 caller, String callingPackage)40 void connect(IMediaController2 caller, String callingPackage); release(IMediaController2 caller)41 void release(IMediaController2 caller); 42 setVolumeTo(IMediaController2 caller, int value, int flags)43 void setVolumeTo(IMediaController2 caller, int value, int flags); adjustVolume(IMediaController2 caller, int direction, int flags)44 void adjustVolume(IMediaController2 caller, int direction, int flags); 45 46 ////////////////////////////////////////////////////////////////////////////////////////////// 47 // send command 48 ////////////////////////////////////////////////////////////////////////////////////////////// sendTransportControlCommand(IMediaController2 caller, int commandCode, in Bundle args)49 void sendTransportControlCommand(IMediaController2 caller, 50 int commandCode, in Bundle args); sendCustomCommand(IMediaController2 caller, in Bundle command, in Bundle args, in ResultReceiver receiver)51 void sendCustomCommand(IMediaController2 caller, in Bundle command, in Bundle args, 52 in ResultReceiver receiver); 53 prepareFromUri(IMediaController2 caller, in Uri uri, in Bundle extras)54 void prepareFromUri(IMediaController2 caller, in Uri uri, in Bundle extras); prepareFromSearch(IMediaController2 caller, String query, in Bundle extras)55 void prepareFromSearch(IMediaController2 caller, String query, in Bundle extras); prepareFromMediaId(IMediaController2 caller, String mediaId, in Bundle extras)56 void prepareFromMediaId(IMediaController2 caller, String mediaId, in Bundle extras); playFromUri(IMediaController2 caller, in Uri uri, in Bundle extras)57 void playFromUri(IMediaController2 caller, in Uri uri, in Bundle extras); playFromSearch(IMediaController2 caller, String query, in Bundle extras)58 void playFromSearch(IMediaController2 caller, String query, in Bundle extras); playFromMediaId(IMediaController2 caller, String mediaId, in Bundle extras)59 void playFromMediaId(IMediaController2 caller, String mediaId, in Bundle extras); setRating(IMediaController2 caller, String mediaId, in Bundle rating)60 void setRating(IMediaController2 caller, String mediaId, in Bundle rating); 61 setPlaylist(IMediaController2 caller, in List<Bundle> playlist, in Bundle metadata)62 void setPlaylist(IMediaController2 caller, in List<Bundle> playlist, in Bundle metadata); updatePlaylistMetadata(IMediaController2 caller, in Bundle metadata)63 void updatePlaylistMetadata(IMediaController2 caller, in Bundle metadata); addPlaylistItem(IMediaController2 caller, int index, in Bundle mediaItem)64 void addPlaylistItem(IMediaController2 caller, int index, in Bundle mediaItem); removePlaylistItem(IMediaController2 caller, in Bundle mediaItem)65 void removePlaylistItem(IMediaController2 caller, in Bundle mediaItem); replacePlaylistItem(IMediaController2 caller, int index, in Bundle mediaItem)66 void replacePlaylistItem(IMediaController2 caller, int index, in Bundle mediaItem); skipToPlaylistItem(IMediaController2 caller, in Bundle mediaItem)67 void skipToPlaylistItem(IMediaController2 caller, in Bundle mediaItem); skipToPreviousItem(IMediaController2 caller)68 void skipToPreviousItem(IMediaController2 caller); skipToNextItem(IMediaController2 caller)69 void skipToNextItem(IMediaController2 caller); setRepeatMode(IMediaController2 caller, int repeatMode)70 void setRepeatMode(IMediaController2 caller, int repeatMode); setShuffleMode(IMediaController2 caller, int shuffleMode)71 void setShuffleMode(IMediaController2 caller, int shuffleMode); 72 73 ////////////////////////////////////////////////////////////////////////////////////////////// 74 // library service specific 75 ////////////////////////////////////////////////////////////////////////////////////////////// getLibraryRoot(IMediaController2 caller, in Bundle rootHints)76 void getLibraryRoot(IMediaController2 caller, in Bundle rootHints); getItem(IMediaController2 caller, String mediaId)77 void getItem(IMediaController2 caller, String mediaId); getChildren(IMediaController2 caller, String parentId, int page, int pageSize, in Bundle extras)78 void getChildren(IMediaController2 caller, String parentId, int page, int pageSize, 79 in Bundle extras); search(IMediaController2 caller, String query, in Bundle extras)80 void search(IMediaController2 caller, String query, in Bundle extras); getSearchResult(IMediaController2 caller, String query, int page, int pageSize, in Bundle extras)81 void getSearchResult(IMediaController2 caller, String query, int page, int pageSize, 82 in Bundle extras); subscribe(IMediaController2 caller, String parentId, in Bundle extras)83 void subscribe(IMediaController2 caller, String parentId, in Bundle extras); unsubscribe(IMediaController2 caller, String parentId)84 void unsubscribe(IMediaController2 caller, String parentId); 85 } 86