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