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