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.app.PendingIntent; 20 import android.bluetooth.BluetoothDevice; 21 import android.content.ComponentName; 22 import android.media.AudioAttributes; 23 import android.media.AudioRoutesInfo; 24 import android.media.IAudioFocusDispatcher; 25 import android.media.IAudioRoutesObserver; 26 import android.media.IRemoteControlClient; 27 import android.media.IRemoteControlDisplay; 28 import android.media.IRemoteVolumeObserver; 29 import android.media.IRingtonePlayer; 30 import android.media.IVolumeController; 31 import android.media.Rating; 32 import android.media.VolumePolicy; 33 import android.media.audiopolicy.AudioPolicyConfig; 34 import android.media.audiopolicy.IAudioPolicyCallback; 35 import android.net.Uri; 36 import android.view.KeyEvent; 37 38 /** 39 * {@hide} 40 */ 41 interface IAudioService { 42 adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags, String callingPackage, String caller)43 oneway void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags, 44 String callingPackage, String caller); 45 adjustStreamVolume(int streamType, int direction, int flags, String callingPackage)46 void adjustStreamVolume(int streamType, int direction, int flags, String callingPackage); 47 setStreamVolume(int streamType, int index, int flags, String callingPackage)48 void setStreamVolume(int streamType, int index, int flags, String callingPackage); 49 setRemoteStreamVolume(int index)50 oneway void setRemoteStreamVolume(int index); 51 isStreamMute(int streamType)52 boolean isStreamMute(int streamType); 53 forceRemoteSubmixFullVolume(boolean startForcing, IBinder cb)54 void forceRemoteSubmixFullVolume(boolean startForcing, IBinder cb); 55 isMasterMute()56 boolean isMasterMute(); 57 setMasterMute(boolean mute, int flags, String callingPackage, int userId)58 void setMasterMute(boolean mute, int flags, String callingPackage, int userId); 59 getStreamVolume(int streamType)60 int getStreamVolume(int streamType); 61 getStreamMinVolume(int streamType)62 int getStreamMinVolume(int streamType); 63 getStreamMaxVolume(int streamType)64 int getStreamMaxVolume(int streamType); 65 getLastAudibleStreamVolume(int streamType)66 int getLastAudibleStreamVolume(int streamType); 67 setMicrophoneMute(boolean on, String callingPackage, int userId)68 void setMicrophoneMute(boolean on, String callingPackage, int userId); 69 setRingerModeExternal(int ringerMode, String caller)70 void setRingerModeExternal(int ringerMode, String caller); 71 setRingerModeInternal(int ringerMode, String caller)72 void setRingerModeInternal(int ringerMode, String caller); 73 getRingerModeExternal()74 int getRingerModeExternal(); 75 getRingerModeInternal()76 int getRingerModeInternal(); 77 isValidRingerMode(int ringerMode)78 boolean isValidRingerMode(int ringerMode); 79 setVibrateSetting(int vibrateType, int vibrateSetting)80 void setVibrateSetting(int vibrateType, int vibrateSetting); 81 getVibrateSetting(int vibrateType)82 int getVibrateSetting(int vibrateType); 83 shouldVibrate(int vibrateType)84 boolean shouldVibrate(int vibrateType); 85 setMode(int mode, IBinder cb, String callingPackage)86 void setMode(int mode, IBinder cb, String callingPackage); 87 getMode()88 int getMode(); 89 playSoundEffect(int effectType)90 oneway void playSoundEffect(int effectType); 91 playSoundEffectVolume(int effectType, float volume)92 oneway void playSoundEffectVolume(int effectType, float volume); 93 loadSoundEffects()94 boolean loadSoundEffects(); 95 unloadSoundEffects()96 oneway void unloadSoundEffects(); 97 reloadAudioSettings()98 oneway void reloadAudioSettings(); 99 avrcpSupportsAbsoluteVolume(String address, boolean support)100 oneway void avrcpSupportsAbsoluteVolume(String address, boolean support); 101 setSpeakerphoneOn(boolean on)102 void setSpeakerphoneOn(boolean on); 103 isSpeakerphoneOn()104 boolean isSpeakerphoneOn(); 105 setBluetoothScoOn(boolean on)106 void setBluetoothScoOn(boolean on); 107 isBluetoothScoOn()108 boolean isBluetoothScoOn(); 109 setBluetoothA2dpOn(boolean on)110 void setBluetoothA2dpOn(boolean on); 111 isBluetoothA2dpOn()112 boolean isBluetoothA2dpOn(); 113 requestAudioFocus(in AudioAttributes aa, int durationHint, IBinder cb, IAudioFocusDispatcher fd, String clientId, String callingPackageName, int flags, IAudioPolicyCallback pcb)114 int requestAudioFocus(in AudioAttributes aa, int durationHint, IBinder cb, 115 IAudioFocusDispatcher fd, String clientId, String callingPackageName, int flags, 116 IAudioPolicyCallback pcb); 117 abandonAudioFocus(IAudioFocusDispatcher fd, String clientId, in AudioAttributes aa)118 int abandonAudioFocus(IAudioFocusDispatcher fd, String clientId, in AudioAttributes aa); 119 unregisterAudioFocusClient(String clientId)120 void unregisterAudioFocusClient(String clientId); 121 getCurrentAudioFocus()122 int getCurrentAudioFocus(); 123 124 /** 125 * Register an IRemoteControlDisplay. 126 * Success of registration is subject to a check on 127 * the android.Manifest.permission.MEDIA_CONTENT_CONTROL permission. 128 * Notify all IRemoteControlClient of the new display and cause the RemoteControlClient 129 * at the top of the stack to update the new display with its information. 130 * @param rcd the IRemoteControlDisplay to register. No effect if null. 131 * @param w the maximum width of the expected bitmap. Negative or zero values indicate this 132 * display doesn't need to receive artwork. 133 * @param h the maximum height of the expected bitmap. Negative or zero values indicate this 134 * display doesn't need to receive artwork. 135 */ registerRemoteControlDisplay(in IRemoteControlDisplay rcd, int w, int h)136 boolean registerRemoteControlDisplay(in IRemoteControlDisplay rcd, int w, int h); 137 138 /** 139 * Like registerRemoteControlDisplay, but with success being subject to a check on 140 * the android.Manifest.permission.MEDIA_CONTENT_CONTROL permission, and if it fails, 141 * success is subject to listenerComp being one of the ENABLED_NOTIFICATION_LISTENERS 142 * components. 143 */ registerRemoteController(in IRemoteControlDisplay rcd, int w, int h, in ComponentName listenerComp)144 boolean registerRemoteController(in IRemoteControlDisplay rcd, int w, int h, 145 in ComponentName listenerComp); 146 147 /** 148 * Unregister an IRemoteControlDisplay. 149 * No effect if the IRemoteControlDisplay hasn't been successfully registered. 150 * @param rcd the IRemoteControlDisplay to unregister. No effect if null. 151 */ unregisterRemoteControlDisplay(in IRemoteControlDisplay rcd)152 oneway void unregisterRemoteControlDisplay(in IRemoteControlDisplay rcd); 153 /** 154 * Update the size of the artwork used by an IRemoteControlDisplay. 155 * @param rcd the IRemoteControlDisplay with the new artwork size requirement 156 * @param w the maximum width of the expected bitmap. Negative or zero values indicate this 157 * display doesn't need to receive artwork. 158 * @param h the maximum height of the expected bitmap. Negative or zero values indicate this 159 * display doesn't need to receive artwork. 160 */ remoteControlDisplayUsesBitmapSize(in IRemoteControlDisplay rcd, int w, int h)161 oneway void remoteControlDisplayUsesBitmapSize(in IRemoteControlDisplay rcd, int w, int h); 162 /** 163 * Controls whether a remote control display needs periodic checks of the RemoteControlClient 164 * playback position to verify that the estimated position has not drifted from the actual 165 * position. By default the check is not performed. 166 * The IRemoteControlDisplay must have been previously registered for this to have any effect. 167 * @param rcd the IRemoteControlDisplay for which the anti-drift mechanism will be enabled 168 * or disabled. Not null. 169 * @param wantsSync if true, RemoteControlClient instances which expose their playback position 170 * to the framework will regularly compare the estimated playback position with the actual 171 * position, and will update the IRemoteControlDisplay implementation whenever a drift is 172 * detected. 173 */ remoteControlDisplayWantsPlaybackPositionSync(in IRemoteControlDisplay rcd, boolean wantsSync)174 oneway void remoteControlDisplayWantsPlaybackPositionSync(in IRemoteControlDisplay rcd, 175 boolean wantsSync); 176 startBluetoothSco(IBinder cb, int targetSdkVersion)177 void startBluetoothSco(IBinder cb, int targetSdkVersion); startBluetoothScoVirtualCall(IBinder cb)178 void startBluetoothScoVirtualCall(IBinder cb); stopBluetoothSco(IBinder cb)179 void stopBluetoothSco(IBinder cb); 180 forceVolumeControlStream(int streamType, IBinder cb)181 void forceVolumeControlStream(int streamType, IBinder cb); 182 setRingtonePlayer(IRingtonePlayer player)183 void setRingtonePlayer(IRingtonePlayer player); getRingtonePlayer()184 IRingtonePlayer getRingtonePlayer(); getUiSoundsStreamType()185 int getUiSoundsStreamType(); 186 setWiredDeviceConnectionState(int type, int state, String address, String name, String caller)187 void setWiredDeviceConnectionState(int type, int state, String address, String name, 188 String caller); 189 setBluetoothA2dpDeviceConnectionState(in BluetoothDevice device, int state, int profile)190 int setBluetoothA2dpDeviceConnectionState(in BluetoothDevice device, int state, int profile); 191 startWatchingRoutes(in IAudioRoutesObserver observer)192 AudioRoutesInfo startWatchingRoutes(in IAudioRoutesObserver observer); 193 isCameraSoundForced()194 boolean isCameraSoundForced(); 195 setVolumeController(in IVolumeController controller)196 void setVolumeController(in IVolumeController controller); 197 notifyVolumeControllerVisible(in IVolumeController controller, boolean visible)198 void notifyVolumeControllerVisible(in IVolumeController controller, boolean visible); 199 isStreamAffectedByRingerMode(int streamType)200 boolean isStreamAffectedByRingerMode(int streamType); 201 isStreamAffectedByMute(int streamType)202 boolean isStreamAffectedByMute(int streamType); 203 disableSafeMediaVolume(String callingPackage)204 void disableSafeMediaVolume(String callingPackage); 205 setHdmiSystemAudioSupported(boolean on)206 int setHdmiSystemAudioSupported(boolean on); 207 isHdmiSystemAudioSupported()208 boolean isHdmiSystemAudioSupported(); 209 registerAudioPolicy(in AudioPolicyConfig policyConfig, in IAudioPolicyCallback pcb, boolean hasFocusListener)210 String registerAudioPolicy(in AudioPolicyConfig policyConfig, 211 in IAudioPolicyCallback pcb, boolean hasFocusListener); 212 unregisterAudioPolicyAsync(in IAudioPolicyCallback pcb)213 oneway void unregisterAudioPolicyAsync(in IAudioPolicyCallback pcb); 214 setFocusPropertiesForPolicy(int duckingBehavior, in IAudioPolicyCallback pcb)215 int setFocusPropertiesForPolicy(int duckingBehavior, in IAudioPolicyCallback pcb); 216 setVolumePolicy(in VolumePolicy policy)217 void setVolumePolicy(in VolumePolicy policy); 218 } 219