1 /*
2  * Copyright (C) 2007 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;
18 
19 import android.bluetooth.BluetoothDevice;
20 import android.media.AudioAttributes;
21 import android.media.AudioFocusInfo;
22 import android.media.AudioPlaybackConfiguration;
23 import android.media.AudioRecordingConfiguration;
24 import android.media.AudioRoutesInfo;
25 import android.media.IAudioFocusDispatcher;
26 import android.media.IAudioRoutesObserver;
27 import android.media.IAudioServerStateDispatcher;
28 import android.media.IPlaybackConfigDispatcher;
29 import android.media.IRecordingConfigDispatcher;
30 import android.media.IRingtonePlayer;
31 import android.media.IVolumeController;
32 import android.media.IVolumeController;
33 import android.media.PlayerBase;
34 import android.media.VolumePolicy;
35 import android.media.audiopolicy.AudioPolicyConfig;
36 import android.media.audiopolicy.IAudioPolicyCallback;
37 
38 /**
39  * {@hide}
40  */
41 interface IAudioService {
42     // C++ and Java methods below.
43 
44     // WARNING: When methods are inserted or deleted in this section, the transaction IDs in
45     // frameworks/native/include/audiomanager/IAudioManager.h must be updated to match the order
46     // in this file.
47     //
48     // When a method's argument list is changed, BpAudioManager's corresponding serialization code
49     // (if any) in frameworks/native/services/audiomanager/IAudioManager.cpp must be updated.
50 
trackPlayer(in PlayerBase.PlayerIdCard pic)51     int trackPlayer(in PlayerBase.PlayerIdCard pic);
52 
playerAttributes(in int piid, in AudioAttributes attr)53     oneway void playerAttributes(in int piid, in AudioAttributes attr);
54 
playerEvent(in int piid, in int event)55     oneway void playerEvent(in int piid, in int event);
56 
releasePlayer(in int piid)57     oneway void releasePlayer(in int piid);
58 
59     // Java-only methods below.
60 
adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags, String callingPackage, String caller)61     oneway void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags,
62             String callingPackage, String caller);
63 
adjustStreamVolume(int streamType, int direction, int flags, String callingPackage)64     void adjustStreamVolume(int streamType, int direction, int flags, String callingPackage);
65 
setStreamVolume(int streamType, int index, int flags, String callingPackage)66     void setStreamVolume(int streamType, int index, int flags, String callingPackage);
67 
isStreamMute(int streamType)68     boolean isStreamMute(int streamType);
69 
forceRemoteSubmixFullVolume(boolean startForcing, IBinder cb)70     void forceRemoteSubmixFullVolume(boolean startForcing, IBinder cb);
71 
isMasterMute()72     boolean isMasterMute();
73 
setMasterMute(boolean mute, int flags, String callingPackage, int userId)74     void setMasterMute(boolean mute, int flags, String callingPackage, int userId);
75 
getStreamVolume(int streamType)76     int getStreamVolume(int streamType);
77 
getStreamMinVolume(int streamType)78     int getStreamMinVolume(int streamType);
79 
getStreamMaxVolume(int streamType)80     int getStreamMaxVolume(int streamType);
81 
getLastAudibleStreamVolume(int streamType)82     int getLastAudibleStreamVolume(int streamType);
83 
setMicrophoneMute(boolean on, String callingPackage, int userId)84     void setMicrophoneMute(boolean on, String callingPackage, int userId);
85 
setRingerModeExternal(int ringerMode, String caller)86     void setRingerModeExternal(int ringerMode, String caller);
87 
setRingerModeInternal(int ringerMode, String caller)88     void setRingerModeInternal(int ringerMode, String caller);
89 
getRingerModeExternal()90     int getRingerModeExternal();
91 
getRingerModeInternal()92     int getRingerModeInternal();
93 
isValidRingerMode(int ringerMode)94     boolean isValidRingerMode(int ringerMode);
95 
setVibrateSetting(int vibrateType, int vibrateSetting)96     void setVibrateSetting(int vibrateType, int vibrateSetting);
97 
getVibrateSetting(int vibrateType)98     int getVibrateSetting(int vibrateType);
99 
shouldVibrate(int vibrateType)100     boolean shouldVibrate(int vibrateType);
101 
setMode(int mode, IBinder cb, String callingPackage)102     void setMode(int mode, IBinder cb, String callingPackage);
103 
getMode()104     int getMode();
105 
playSoundEffect(int effectType)106     oneway void playSoundEffect(int effectType);
107 
playSoundEffectVolume(int effectType, float volume)108     oneway void playSoundEffectVolume(int effectType, float volume);
109 
loadSoundEffects()110     boolean loadSoundEffects();
111 
unloadSoundEffects()112     oneway void unloadSoundEffects();
113 
reloadAudioSettings()114     oneway void reloadAudioSettings();
115 
avrcpSupportsAbsoluteVolume(String address, boolean support)116     oneway void avrcpSupportsAbsoluteVolume(String address, boolean support);
117 
setSpeakerphoneOn(boolean on)118     void setSpeakerphoneOn(boolean on);
119 
isSpeakerphoneOn()120     boolean isSpeakerphoneOn();
121 
setBluetoothScoOn(boolean on)122     void setBluetoothScoOn(boolean on);
123 
isBluetoothScoOn()124     boolean isBluetoothScoOn();
125 
setBluetoothA2dpOn(boolean on)126     void setBluetoothA2dpOn(boolean on);
127 
isBluetoothA2dpOn()128     boolean isBluetoothA2dpOn();
129 
requestAudioFocus(in AudioAttributes aa, int durationHint, IBinder cb, IAudioFocusDispatcher fd, String clientId, String callingPackageName, int flags, IAudioPolicyCallback pcb, int sdk)130     int requestAudioFocus(in AudioAttributes aa, int durationHint, IBinder cb,
131             IAudioFocusDispatcher fd, String clientId, String callingPackageName, int flags,
132             IAudioPolicyCallback pcb, int sdk);
133 
abandonAudioFocus(IAudioFocusDispatcher fd, String clientId, in AudioAttributes aa, in String callingPackageName)134     int abandonAudioFocus(IAudioFocusDispatcher fd, String clientId, in AudioAttributes aa,
135             in String callingPackageName);
136 
unregisterAudioFocusClient(String clientId)137     void unregisterAudioFocusClient(String clientId);
138 
getCurrentAudioFocus()139     int getCurrentAudioFocus();
140 
startBluetoothSco(IBinder cb, int targetSdkVersion)141     void startBluetoothSco(IBinder cb, int targetSdkVersion);
startBluetoothScoVirtualCall(IBinder cb)142     void startBluetoothScoVirtualCall(IBinder cb);
stopBluetoothSco(IBinder cb)143     void stopBluetoothSco(IBinder cb);
144 
forceVolumeControlStream(int streamType, IBinder cb)145     void forceVolumeControlStream(int streamType, IBinder cb);
146 
setRingtonePlayer(IRingtonePlayer player)147     void setRingtonePlayer(IRingtonePlayer player);
getRingtonePlayer()148     IRingtonePlayer getRingtonePlayer();
getUiSoundsStreamType()149     int getUiSoundsStreamType();
150 
setWiredDeviceConnectionState(int type, int state, String address, String name, String caller)151     void setWiredDeviceConnectionState(int type, int state, String address, String name,
152             String caller);
153 
setHearingAidDeviceConnectionState(in BluetoothDevice device, int state)154     void setHearingAidDeviceConnectionState(in BluetoothDevice device, int state);
155 
setBluetoothA2dpDeviceConnectionState(in BluetoothDevice device, int state, int profile)156     int setBluetoothA2dpDeviceConnectionState(in BluetoothDevice device, int state, int profile);
157 
handleBluetoothA2dpDeviceConfigChange(in BluetoothDevice device)158     void handleBluetoothA2dpDeviceConfigChange(in BluetoothDevice device);
159 
startWatchingRoutes(in IAudioRoutesObserver observer)160     AudioRoutesInfo startWatchingRoutes(in IAudioRoutesObserver observer);
161 
isCameraSoundForced()162     boolean isCameraSoundForced();
163 
setVolumeController(in IVolumeController controller)164     void setVolumeController(in IVolumeController controller);
165 
notifyVolumeControllerVisible(in IVolumeController controller, boolean visible)166     void notifyVolumeControllerVisible(in IVolumeController controller, boolean visible);
167 
isStreamAffectedByRingerMode(int streamType)168     boolean isStreamAffectedByRingerMode(int streamType);
169 
isStreamAffectedByMute(int streamType)170     boolean isStreamAffectedByMute(int streamType);
171 
disableSafeMediaVolume(String callingPackage)172     void disableSafeMediaVolume(String callingPackage);
173 
setHdmiSystemAudioSupported(boolean on)174     int setHdmiSystemAudioSupported(boolean on);
175 
isHdmiSystemAudioSupported()176     boolean isHdmiSystemAudioSupported();
177 
registerAudioPolicy(in AudioPolicyConfig policyConfig, in IAudioPolicyCallback pcb, boolean hasFocusListener, boolean isFocusPolicy, boolean isVolumeController)178     String registerAudioPolicy(in AudioPolicyConfig policyConfig,
179             in IAudioPolicyCallback pcb, boolean hasFocusListener, boolean isFocusPolicy,
180             boolean isVolumeController);
181 
unregisterAudioPolicyAsync(in IAudioPolicyCallback pcb)182     oneway void unregisterAudioPolicyAsync(in IAudioPolicyCallback pcb);
183 
addMixForPolicy(in AudioPolicyConfig policyConfig, in IAudioPolicyCallback pcb)184     int addMixForPolicy(in AudioPolicyConfig policyConfig, in IAudioPolicyCallback pcb);
185 
removeMixForPolicy(in AudioPolicyConfig policyConfig, in IAudioPolicyCallback pcb)186     int removeMixForPolicy(in AudioPolicyConfig policyConfig, in IAudioPolicyCallback pcb);
187 
setFocusPropertiesForPolicy(int duckingBehavior, in IAudioPolicyCallback pcb)188     int setFocusPropertiesForPolicy(int duckingBehavior, in IAudioPolicyCallback pcb);
189 
setVolumePolicy(in VolumePolicy policy)190     void setVolumePolicy(in VolumePolicy policy);
191 
registerRecordingCallback(in IRecordingConfigDispatcher rcdb)192     void registerRecordingCallback(in IRecordingConfigDispatcher rcdb);
193 
unregisterRecordingCallback(in IRecordingConfigDispatcher rcdb)194     oneway void unregisterRecordingCallback(in IRecordingConfigDispatcher rcdb);
195 
getActiveRecordingConfigurations()196     List<AudioRecordingConfiguration> getActiveRecordingConfigurations();
197 
registerPlaybackCallback(in IPlaybackConfigDispatcher pcdb)198     void registerPlaybackCallback(in IPlaybackConfigDispatcher pcdb);
199 
unregisterPlaybackCallback(in IPlaybackConfigDispatcher pcdb)200     oneway void unregisterPlaybackCallback(in IPlaybackConfigDispatcher pcdb);
201 
getActivePlaybackConfigurations()202     List<AudioPlaybackConfiguration> getActivePlaybackConfigurations();
203 
disableRingtoneSync(in int userId)204     void disableRingtoneSync(in int userId);
205 
getFocusRampTimeMs(in int focusGain, in AudioAttributes attr)206     int getFocusRampTimeMs(in int focusGain, in AudioAttributes attr);
207 
dispatchFocusChange(in AudioFocusInfo afi, in int focusChange, in IAudioPolicyCallback pcb)208     int dispatchFocusChange(in AudioFocusInfo afi, in int focusChange,
209             in IAudioPolicyCallback pcb);
210 
playerHasOpPlayAudio(in int piid, in boolean hasOpPlayAudio)211     oneway void playerHasOpPlayAudio(in int piid, in boolean hasOpPlayAudio);
212 
setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(in BluetoothDevice device, int state, int profile, boolean suppressNoisyIntent, int a2dpVolume)213     int setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent(in BluetoothDevice device,
214             int state, int profile, boolean suppressNoisyIntent, int a2dpVolume);
215 
setFocusRequestResultFromExtPolicy(in AudioFocusInfo afi, int requestResult, in IAudioPolicyCallback pcb)216     oneway void setFocusRequestResultFromExtPolicy(in AudioFocusInfo afi, int requestResult,
217             in IAudioPolicyCallback pcb);
218 
registerAudioServerStateDispatcher(IAudioServerStateDispatcher asd)219     void registerAudioServerStateDispatcher(IAudioServerStateDispatcher asd);
220 
unregisterAudioServerStateDispatcher(IAudioServerStateDispatcher asd)221     oneway void unregisterAudioServerStateDispatcher(IAudioServerStateDispatcher asd);
222 
isAudioServerRunning()223     boolean isAudioServerRunning();
224 
225     // WARNING: read warning at top of file, new methods that need to be used by native
226     // code via IAudioManager.h need to be added to the top section.
227 }
228