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 17package android.media; 18 19import android.app.PendingIntent; 20import android.bluetooth.BluetoothDevice; 21import android.content.ComponentName; 22import android.media.AudioAttributes; 23import android.media.AudioRoutesInfo; 24import android.media.IAudioFocusDispatcher; 25import android.media.IAudioRoutesObserver; 26import android.media.IRemoteControlClient; 27import android.media.IRemoteControlDisplay; 28import android.media.IRemoteVolumeObserver; 29import android.media.IRingtonePlayer; 30import android.media.IVolumeController; 31import android.media.Rating; 32import android.media.VolumePolicy; 33import android.media.audiopolicy.AudioPolicyConfig; 34import android.media.audiopolicy.IAudioPolicyCallback; 35import android.net.Uri; 36import android.view.KeyEvent; 37 38/** 39 * {@hide} 40 */ 41interface IAudioService { 42 43 oneway void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags, 44 String callingPackage, String caller); 45 46 void adjustStreamVolume(int streamType, int direction, int flags, String callingPackage); 47 48 void setStreamVolume(int streamType, int index, int flags, String callingPackage); 49 50 oneway void setRemoteStreamVolume(int index); 51 52 boolean isStreamMute(int streamType); 53 54 void forceRemoteSubmixFullVolume(boolean startForcing, IBinder cb); 55 56 boolean isMasterMute(); 57 58 void setMasterMute(boolean mute, int flags, String callingPackage, int userId); 59 60 int getStreamVolume(int streamType); 61 62 int getStreamMinVolume(int streamType); 63 64 int getStreamMaxVolume(int streamType); 65 66 int getLastAudibleStreamVolume(int streamType); 67 68 void setMicrophoneMute(boolean on, String callingPackage, int userId); 69 70 void setRingerModeExternal(int ringerMode, String caller); 71 72 void setRingerModeInternal(int ringerMode, String caller); 73 74 int getRingerModeExternal(); 75 76 int getRingerModeInternal(); 77 78 boolean isValidRingerMode(int ringerMode); 79 80 void setVibrateSetting(int vibrateType, int vibrateSetting); 81 82 int getVibrateSetting(int vibrateType); 83 84 boolean shouldVibrate(int vibrateType); 85 86 void setMode(int mode, IBinder cb, String callingPackage); 87 88 int getMode(); 89 90 oneway void playSoundEffect(int effectType); 91 92 oneway void playSoundEffectVolume(int effectType, float volume); 93 94 boolean loadSoundEffects(); 95 96 oneway void unloadSoundEffects(); 97 98 oneway void reloadAudioSettings(); 99 100 oneway void avrcpSupportsAbsoluteVolume(String address, boolean support); 101 102 void setSpeakerphoneOn(boolean on); 103 104 boolean isSpeakerphoneOn(); 105 106 void setBluetoothScoOn(boolean on); 107 108 boolean isBluetoothScoOn(); 109 110 void setBluetoothA2dpOn(boolean on); 111 112 boolean isBluetoothA2dpOn(); 113 114 int requestAudioFocus(in AudioAttributes aa, int durationHint, IBinder cb, 115 IAudioFocusDispatcher fd, String clientId, String callingPackageName, int flags, 116 IAudioPolicyCallback pcb); 117 118 int abandonAudioFocus(IAudioFocusDispatcher fd, String clientId, in AudioAttributes aa); 119 120 void unregisterAudioFocusClient(String clientId); 121 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 */ 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 */ 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 */ 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 */ 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 */ 174 oneway void remoteControlDisplayWantsPlaybackPositionSync(in IRemoteControlDisplay rcd, 175 boolean wantsSync); 176 177 void startBluetoothSco(IBinder cb, int targetSdkVersion); 178 void startBluetoothScoVirtualCall(IBinder cb); 179 void stopBluetoothSco(IBinder cb); 180 181 void forceVolumeControlStream(int streamType, IBinder cb); 182 183 void setRingtonePlayer(IRingtonePlayer player); 184 IRingtonePlayer getRingtonePlayer(); 185 int getUiSoundsStreamType(); 186 187 void setWiredDeviceConnectionState(int type, int state, String address, String name, 188 String caller); 189 190 int setBluetoothA2dpDeviceConnectionState(in BluetoothDevice device, int state, int profile); 191 192 AudioRoutesInfo startWatchingRoutes(in IAudioRoutesObserver observer); 193 194 boolean isCameraSoundForced(); 195 196 void setVolumeController(in IVolumeController controller); 197 198 void notifyVolumeControllerVisible(in IVolumeController controller, boolean visible); 199 200 boolean isStreamAffectedByRingerMode(int streamType); 201 202 boolean isStreamAffectedByMute(int streamType); 203 204 void disableSafeMediaVolume(String callingPackage); 205 206 int setHdmiSystemAudioSupported(boolean on); 207 208 boolean isHdmiSystemAudioSupported(); 209 210 String registerAudioPolicy(in AudioPolicyConfig policyConfig, 211 in IAudioPolicyCallback pcb, boolean hasFocusListener); 212 213 oneway void unregisterAudioPolicyAsync(in IAudioPolicyCallback pcb); 214 215 int setFocusPropertiesForPolicy(int duckingBehavior, in IAudioPolicyCallback pcb); 216 217 void setVolumePolicy(in VolumePolicy policy); 218} 219