1 /* Copyright (C) 2014 The Android Open Source Project 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 package android.media.session; 17 18 import android.content.ComponentName; 19 import android.content.pm.ParceledListSlice; 20 import android.media.IRemoteSessionCallback; 21 import android.media.Session2Token; 22 import android.media.session.IActiveSessionsListener; 23 import android.media.session.IOnMediaKeyEventDispatchedListener; 24 import android.media.session.IOnMediaKeyEventSessionChangedListener; 25 import android.media.session.IOnMediaKeyListener; 26 import android.media.session.IOnVolumeKeyLongPressListener; 27 import android.media.session.ISession; 28 import android.media.session.ISessionCallback; 29 import android.media.session.ISession2TokensListener; 30 import android.media.session.MediaSession; 31 import android.os.Bundle; 32 import android.view.KeyEvent; 33 34 /** 35 * Interface to the MediaSessionManagerService 36 * @hide 37 */ 38 interface ISessionManager { createSession(String packageName, in ISessionCallback sessionCb, String tag, in Bundle sessionInfo, int userId)39 ISession createSession(String packageName, in ISessionCallback sessionCb, String tag, 40 in Bundle sessionInfo, int userId); getSessions(in ComponentName compName, int userId)41 List<MediaSession.Token> getSessions(in ComponentName compName, int userId); getMediaKeyEventSession()42 MediaSession.Token getMediaKeyEventSession(); getMediaKeyEventSessionPackageName()43 String getMediaKeyEventSessionPackageName(); dispatchMediaKeyEvent(String packageName, boolean asSystemService, in KeyEvent keyEvent, boolean needWakeLock)44 void dispatchMediaKeyEvent(String packageName, boolean asSystemService, in KeyEvent keyEvent, 45 boolean needWakeLock); dispatchMediaKeyEventToSessionAsSystemService(String packageName, in KeyEvent keyEvent, in MediaSession.Token sessionToken)46 boolean dispatchMediaKeyEventToSessionAsSystemService(String packageName, 47 in KeyEvent keyEvent, in MediaSession.Token sessionToken); dispatchVolumeKeyEvent(String packageName, String opPackageName, boolean asSystemService, in KeyEvent keyEvent, int stream, boolean musicOnly)48 void dispatchVolumeKeyEvent(String packageName, String opPackageName, boolean asSystemService, 49 in KeyEvent keyEvent, int stream, boolean musicOnly); dispatchVolumeKeyEventToSessionAsSystemService(String packageName, String opPackageName, in KeyEvent keyEvent, in MediaSession.Token sessionToken)50 void dispatchVolumeKeyEventToSessionAsSystemService(String packageName, String opPackageName, 51 in KeyEvent keyEvent, in MediaSession.Token sessionToken); dispatchAdjustVolume(String packageName, String opPackageName, int suggestedStream, int delta, int flags)52 void dispatchAdjustVolume(String packageName, String opPackageName, int suggestedStream, 53 int delta, int flags); addSessionsListener(in IActiveSessionsListener listener, in ComponentName compName, int userId)54 void addSessionsListener(in IActiveSessionsListener listener, in ComponentName compName, 55 int userId); removeSessionsListener(in IActiveSessionsListener listener)56 void removeSessionsListener(in IActiveSessionsListener listener); addSession2TokensListener(in ISession2TokensListener listener, int userId)57 void addSession2TokensListener(in ISession2TokensListener listener, int userId); removeSession2TokensListener(in ISession2TokensListener listener)58 void removeSession2TokensListener(in ISession2TokensListener listener); 59 registerRemoteSessionCallback(in IRemoteSessionCallback rvc)60 void registerRemoteSessionCallback(in IRemoteSessionCallback rvc); unregisterRemoteSessionCallback(in IRemoteSessionCallback rvc)61 void unregisterRemoteSessionCallback(in IRemoteSessionCallback rvc); 62 63 // For PhoneWindowManager to precheck media keys isGlobalPriorityActive()64 boolean isGlobalPriorityActive(); 65 addOnMediaKeyEventDispatchedListener(in IOnMediaKeyEventDispatchedListener listener)66 void addOnMediaKeyEventDispatchedListener(in IOnMediaKeyEventDispatchedListener listener); removeOnMediaKeyEventDispatchedListener(in IOnMediaKeyEventDispatchedListener listener)67 void removeOnMediaKeyEventDispatchedListener(in IOnMediaKeyEventDispatchedListener listener); addOnMediaKeyEventSessionChangedListener( in IOnMediaKeyEventSessionChangedListener listener)68 void addOnMediaKeyEventSessionChangedListener( 69 in IOnMediaKeyEventSessionChangedListener listener); removeOnMediaKeyEventSessionChangedListener( in IOnMediaKeyEventSessionChangedListener listener)70 void removeOnMediaKeyEventSessionChangedListener( 71 in IOnMediaKeyEventSessionChangedListener listener); setOnVolumeKeyLongPressListener(in IOnVolumeKeyLongPressListener listener)72 void setOnVolumeKeyLongPressListener(in IOnVolumeKeyLongPressListener listener); setOnMediaKeyListener(in IOnMediaKeyListener listener)73 void setOnMediaKeyListener(in IOnMediaKeyListener listener); 74 isTrusted(String controllerPackageName, int controllerPid, int controllerUid)75 boolean isTrusted(String controllerPackageName, int controllerPid, int controllerUid); setCustomMediaKeyDispatcher(String name)76 void setCustomMediaKeyDispatcher(String name); setCustomMediaSessionPolicyProvider(String name)77 void setCustomMediaSessionPolicyProvider(String name); hasCustomMediaKeyDispatcher(String componentName)78 boolean hasCustomMediaKeyDispatcher(String componentName); hasCustomMediaSessionPolicyProvider(String componentName)79 boolean hasCustomMediaSessionPolicyProvider(String componentName); getSessionPolicies(in MediaSession.Token token)80 int getSessionPolicies(in MediaSession.Token token); setSessionPolicies(in MediaSession.Token token, int policies)81 void setSessionPolicies(in MediaSession.Token token, int policies); 82 } 83