2 * Copyright (C) 2007 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.media;
19 import android.app.PendingIntent;
20 import android.bluetooth.BluetoothDevice;
21 import android.content.ComponentName;
22 import android.media.AudioRoutesInfo;
23 import android.media.IAudioFocusDispatcher;
24 import android.media.IAudioRoutesObserver;
25 import android.media.IRemoteControlClient;
26 import android.media.IRemoteControlDisplay;
27 import android.media.IRemoteVolumeObserver;
28 import android.media.IRingtonePlayer;
29 import android.media.IVolumeController;
30 import android.media.Rating;
31 import android.media.audiopolicy.AudioPolicyConfig;
32 import android.net.Uri;
33 import android.view.KeyEvent;
38 interface IAudioService {
40 void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags,
41 String callingPackage);
43 void adjustStreamVolume(int streamType, int direction, int flags, String callingPackage);
45 void adjustMasterVolume(int direction, int flags, String callingPackage);
47 void setStreamVolume(int streamType, int index, int flags, String callingPackage);
49 oneway void setRemoteStreamVolume(int index);
51 void setMasterVolume(int index, int flags, String callingPackage);
53 void setStreamSolo(int streamType, boolean state, IBinder cb);
55 void setStreamMute(int streamType, boolean state, IBinder cb);
57 boolean isStreamMute(int streamType);
59 void setMasterMute(boolean state, int flags, String callingPackage, IBinder cb);
61 boolean isMasterMute();
63 int getStreamVolume(int streamType);
65 int getMasterVolume();
67 int getStreamMaxVolume(int streamType);
69 int getMasterMaxVolume();
71 int getLastAudibleStreamVolume(int streamType);
73 int getLastAudibleMasterVolume();
75 void setMicrophoneMute(boolean on, String callingPackage);
77 void setRingerMode(int ringerMode);
81 void setVibrateSetting(int vibrateType, int vibrateSetting);
83 int getVibrateSetting(int vibrateType);
85 boolean shouldVibrate(int vibrateType);
87 void setMode(int mode, IBinder cb);
91 oneway void playSoundEffect(int effectType);
93 oneway void playSoundEffectVolume(int effectType, float volume);
95 boolean loadSoundEffects();
97 oneway void unloadSoundEffects();
99 oneway void reloadAudioSettings();
101 oneway void avrcpSupportsAbsoluteVolume(String address, boolean support);
103 void setSpeakerphoneOn(boolean on);
105 boolean isSpeakerphoneOn();
107 void setBluetoothScoOn(boolean on);
109 boolean isBluetoothScoOn();
111 void setBluetoothA2dpOn(boolean on);
113 boolean isBluetoothA2dpOn();
115 int requestAudioFocus(int mainStreamType, int durationHint, IBinder cb,
116 IAudioFocusDispatcher fd, String clientId, String callingPackageName);
118 int abandonAudioFocus(IAudioFocusDispatcher fd, String clientId);
120 void unregisterAudioFocusClient(String clientId);
122 int getCurrentAudioFocus();
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.
136 boolean registerRemoteControlDisplay(in IRemoteControlDisplay rcd, int w, int h);
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
144 boolean registerRemoteController(in IRemoteControlDisplay rcd, int w, int h,
145 in ComponentName listenerComp);
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.
152 oneway void unregisterRemoteControlDisplay(in IRemoteControlDisplay rcd);
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.
161 oneway void remoteControlDisplayUsesBitmapSize(in IRemoteControlDisplay rcd, int w, int h);
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
174 oneway void remoteControlDisplayWantsPlaybackPositionSync(in IRemoteControlDisplay rcd,
177 void startBluetoothSco(IBinder cb, int targetSdkVersion);
178 void startBluetoothScoVirtualCall(IBinder cb);
179 void stopBluetoothSco(IBinder cb);
181 void forceVolumeControlStream(int streamType, IBinder cb);
183 void setRingtonePlayer(IRingtonePlayer player);
184 IRingtonePlayer getRingtonePlayer();
185 int getMasterStreamType();
187 void setWiredDeviceConnectionState(int device, int state, String name);
188 int setBluetoothA2dpDeviceConnectionState(in BluetoothDevice device, int state, int profile);
190 AudioRoutesInfo startWatchingRoutes(in IAudioRoutesObserver observer);
192 boolean isCameraSoundForced();
194 void setVolumeController(in IVolumeController controller);
196 void notifyVolumeControllerVisible(in IVolumeController controller, boolean visible);
198 boolean isStreamAffectedByRingerMode(int streamType);
200 void disableSafeMediaVolume();
202 int setHdmiSystemAudioSupported(boolean on);
204 boolean isHdmiSystemAudioSupported();
206 boolean registerAudioPolicy(in AudioPolicyConfig policyConfig, IBinder cb);
207 oneway void unregisterAudioPolicyAsync(in IBinder cb);