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.IRemoteVolumeController;
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);
notifySession2Created(in Session2Token sessionToken)41     void notifySession2Created(in Session2Token sessionToken);
getSessions(in ComponentName compName, int userId)42     List<MediaSession.Token> getSessions(in ComponentName compName, int userId);
getSession2Tokens(int userId)43     ParceledListSlice getSession2Tokens(int userId);
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 MediaSession.Token sessionToken, in KeyEvent keyEvent)46     boolean dispatchMediaKeyEventToSessionAsSystemService(String packageName,
47             in MediaSession.Token sessionToken, in KeyEvent keyEvent);
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 MediaSession.Token sessionToken, in KeyEvent keyEvent)50     void dispatchVolumeKeyEventToSessionAsSystemService(String packageName, String opPackageName,
51             in MediaSession.Token sessionToken, in KeyEvent keyEvent);
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 
registerRemoteVolumeController(in IRemoteVolumeController rvc)60     void registerRemoteVolumeController(in IRemoteVolumeController rvc);
unregisterRemoteVolumeController(in IRemoteVolumeController rvc)61     void unregisterRemoteVolumeController(in IRemoteVolumeController 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);
76 }
77