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.app.PendingIntent; 20 import android.os.Bundle; 21 import android.os.ResultReceiver; 22 23 import com.android.media.IMediaSession2; 24 25 /** 26 * Interface from MediaSession2 to MediaController2. 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 IMediaController2 { onPlayerStateChanged(int state)34 void onPlayerStateChanged(int state); onPositionChanged(long eventTimeMs, long positionMs)35 void onPositionChanged(long eventTimeMs, long positionMs); onPlaybackSpeedChanged(float speed)36 void onPlaybackSpeedChanged(float speed); onBufferedPositionChanged(long bufferedPositionMs)37 void onBufferedPositionChanged(long bufferedPositionMs); onPlaylistChanged(in List<Bundle> playlist, in Bundle metadata)38 void onPlaylistChanged(in List<Bundle> playlist, in Bundle metadata); onPlaylistMetadataChanged(in Bundle metadata)39 void onPlaylistMetadataChanged(in Bundle metadata); onPlaybackInfoChanged(in Bundle playbackInfo)40 void onPlaybackInfoChanged(in Bundle playbackInfo); onRepeatModeChanged(int repeatMode)41 void onRepeatModeChanged(int repeatMode); onShuffleModeChanged(int shuffleMode)42 void onShuffleModeChanged(int shuffleMode); onError(int errorCode, in Bundle extras)43 void onError(int errorCode, in Bundle extras); 44 onConnected(IMediaSession2 sessionBinder, in Bundle commandGroup, int playerState, long positionEventTimeMs, long positionMs, float playbackSpeed, long bufferedPositionMs, in Bundle playbackInfo, int repeatMode, int shuffleMode, in List<Bundle> playlist, in PendingIntent sessionActivity)45 void onConnected(IMediaSession2 sessionBinder, in Bundle commandGroup, 46 int playerState, long positionEventTimeMs, long positionMs, float playbackSpeed, 47 long bufferedPositionMs, in Bundle playbackInfo, int repeatMode, int shuffleMode, 48 in List<Bundle> playlist, in PendingIntent sessionActivity); onDisconnected()49 void onDisconnected(); 50 onCustomLayoutChanged(in List<Bundle> commandButtonlist)51 void onCustomLayoutChanged(in List<Bundle> commandButtonlist); onAllowedCommandsChanged(in Bundle commands)52 void onAllowedCommandsChanged(in Bundle commands); 53 onCustomCommand(in Bundle command, in Bundle args, in ResultReceiver receiver)54 void onCustomCommand(in Bundle command, in Bundle args, in ResultReceiver receiver); 55 56 ////////////////////////////////////////////////////////////////////////////////////////////// 57 // Browser sepcific 58 ////////////////////////////////////////////////////////////////////////////////////////////// onGetLibraryRootDone(in Bundle rootHints, String rootMediaId, in Bundle rootExtra)59 void onGetLibraryRootDone(in Bundle rootHints, String rootMediaId, in Bundle rootExtra); onGetItemDone(String mediaId, in Bundle result)60 void onGetItemDone(String mediaId, in Bundle result); onChildrenChanged(String rootMediaId, int itemCount, in Bundle extras)61 void onChildrenChanged(String rootMediaId, int itemCount, in Bundle extras); onGetChildrenDone(String parentId, int page, int pageSize, in List<Bundle> result, in Bundle extras)62 void onGetChildrenDone(String parentId, int page, int pageSize, in List<Bundle> result, 63 in Bundle extras); onSearchResultChanged(String query, int itemCount, in Bundle extras)64 void onSearchResultChanged(String query, int itemCount, in Bundle extras); onGetSearchResultDone(String query, int page, int pageSize, in List<Bundle> result, in Bundle extras)65 void onGetSearchResultDone(String query, int page, int pageSize, in List<Bundle> result, 66 in Bundle extras); 67 } 68