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.AudioRoutesInfo;
23import android.media.IAudioFocusDispatcher;
24import android.media.IAudioRoutesObserver;
25import android.media.IRemoteControlClient;
26import android.media.IRemoteControlDisplay;
27import android.media.IRemoteVolumeObserver;
28import android.media.IRingtonePlayer;
29import android.media.Rating;
30import android.net.Uri;
31import android.view.KeyEvent;
32
33/**
34 * {@hide}
35 */
36interface IAudioService {
37
38    void adjustVolume(int direction, int flags, String callingPackage);
39
40    boolean isLocalOrRemoteMusicActive();
41
42    oneway void adjustLocalOrRemoteStreamVolume(int streamType, int direction,
43            String callingPackage);
44
45    void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags,
46            String callingPackage);
47
48    void adjustStreamVolume(int streamType, int direction, int flags, String callingPackage);
49
50    void adjustMasterVolume(int direction, int flags, String callingPackage);
51
52    void setStreamVolume(int streamType, int index, int flags, String callingPackage);
53
54    oneway void setRemoteStreamVolume(int index);
55
56    void setMasterVolume(int index, int flags, String callingPackage);
57
58    void setStreamSolo(int streamType, boolean state, IBinder cb);
59
60    void setStreamMute(int streamType, boolean state, IBinder cb);
61
62    boolean isStreamMute(int streamType);
63
64    void setMasterMute(boolean state, int flags, IBinder cb);
65
66    boolean isMasterMute();
67
68    int getStreamVolume(int streamType);
69
70    int getMasterVolume();
71
72    int getStreamMaxVolume(int streamType);
73
74    int getMasterMaxVolume();
75
76    int getLastAudibleStreamVolume(int streamType);
77
78    int getLastAudibleMasterVolume();
79
80    void setRingerMode(int ringerMode);
81
82    int getRingerMode();
83
84    void setVibrateSetting(int vibrateType, int vibrateSetting);
85
86    int getVibrateSetting(int vibrateType);
87
88    boolean shouldVibrate(int vibrateType);
89
90    void setMode(int mode, IBinder cb);
91
92    int getMode();
93
94    oneway void playSoundEffect(int effectType);
95
96    oneway void playSoundEffectVolume(int effectType, float volume);
97
98    boolean loadSoundEffects();
99
100    oneway void unloadSoundEffects();
101
102    oneway void reloadAudioSettings();
103
104    oneway void avrcpSupportsAbsoluteVolume(String address, boolean support);
105
106    void setSpeakerphoneOn(boolean on);
107
108    boolean isSpeakerphoneOn();
109
110    void setBluetoothScoOn(boolean on);
111
112    boolean isBluetoothScoOn();
113
114    void setBluetoothA2dpOn(boolean on);
115
116    boolean isBluetoothA2dpOn();
117
118    int requestAudioFocus(int mainStreamType, int durationHint, IBinder cb,
119            IAudioFocusDispatcher fd, String clientId, String callingPackageName);
120
121    int abandonAudioFocus(IAudioFocusDispatcher fd, String clientId);
122
123    void unregisterAudioFocusClient(String clientId);
124
125    int getCurrentAudioFocus();
126
127    oneway void dispatchMediaKeyEvent(in KeyEvent keyEvent);
128    void dispatchMediaKeyEventUnderWakelock(in KeyEvent keyEvent);
129
130           void registerMediaButtonIntent(in PendingIntent pi, in ComponentName c, IBinder token);
131    oneway void unregisterMediaButtonIntent(in PendingIntent pi);
132
133    oneway void registerMediaButtonEventReceiverForCalls(in ComponentName c);
134    oneway void unregisterMediaButtonEventReceiverForCalls();
135
136    /**
137     * Register an IRemoteControlDisplay.
138     * Success of registration is subject to a check on
139     *   the android.Manifest.permission.MEDIA_CONTENT_CONTROL permission.
140     * Notify all IRemoteControlClient of the new display and cause the RemoteControlClient
141     * at the top of the stack to update the new display with its information.
142     * @param rcd the IRemoteControlDisplay to register. No effect if null.
143     * @param w the maximum width of the expected bitmap. Negative or zero values indicate this
144     *   display doesn't need to receive artwork.
145     * @param h the maximum height of the expected bitmap. Negative or zero values indicate this
146     *   display doesn't need to receive artwork.
147     */
148    boolean registerRemoteControlDisplay(in IRemoteControlDisplay rcd, int w, int h);
149
150    /**
151     * Like registerRemoteControlDisplay, but with success being subject to a check on
152     *   the android.Manifest.permission.MEDIA_CONTENT_CONTROL permission, and if it fails,
153     *   success is subject to listenerComp being one of the ENABLED_NOTIFICATION_LISTENERS
154     *   components.
155     */
156    boolean registerRemoteController(in IRemoteControlDisplay rcd, int w, int h,
157            in ComponentName listenerComp);
158
159    /**
160     * Unregister an IRemoteControlDisplay.
161     * No effect if the IRemoteControlDisplay hasn't been successfully registered.
162     * @param rcd the IRemoteControlDisplay to unregister. No effect if null.
163     */
164    oneway void unregisterRemoteControlDisplay(in IRemoteControlDisplay rcd);
165    /**
166     * Update the size of the artwork used by an IRemoteControlDisplay.
167     * @param rcd the IRemoteControlDisplay with the new artwork size requirement
168     * @param w the maximum width of the expected bitmap. Negative or zero values indicate this
169     *   display doesn't need to receive artwork.
170     * @param h the maximum height of the expected bitmap. Negative or zero values indicate this
171     *   display doesn't need to receive artwork.
172     */
173    oneway void remoteControlDisplayUsesBitmapSize(in IRemoteControlDisplay rcd, int w, int h);
174    /**
175     * Controls whether a remote control display needs periodic checks of the RemoteControlClient
176     * playback position to verify that the estimated position has not drifted from the actual
177     * position. By default the check is not performed.
178     * The IRemoteControlDisplay must have been previously registered for this to have any effect.
179     * @param rcd the IRemoteControlDisplay for which the anti-drift mechanism will be enabled
180     *     or disabled. Not null.
181     * @param wantsSync if true, RemoteControlClient instances which expose their playback position
182     *     to the framework will regularly compare the estimated playback position with the actual
183     *     position, and will update the IRemoteControlDisplay implementation whenever a drift is
184     *     detected.
185     */
186    oneway void remoteControlDisplayWantsPlaybackPositionSync(in IRemoteControlDisplay rcd,
187            boolean wantsSync);
188    /**
189     * Request the user of a RemoteControlClient to seek to the given playback position.
190     * @param generationId the RemoteControlClient generation counter for which this request is
191     *         issued. Requests for an older generation than current one will be ignored.
192     * @param timeMs the time in ms to seek to, must be positive.
193     */
194     void setRemoteControlClientPlaybackPosition(int generationId, long timeMs);
195     /**
196      * Notify the user of a RemoteControlClient that it should update its metadata with the
197      * new value for the given key.
198      * @param generationId the RemoteControlClient generation counter for which this request is
199      *         issued. Requests for an older generation than current one will be ignored.
200      * @param key the metadata key for which a new value exists
201      * @param value the new metadata value
202      */
203     void updateRemoteControlClientMetadata(int generationId, int key, in Rating value);
204
205    /**
206     * Do not use directly, use instead
207     *     {@link android.media.AudioManager#registerRemoteControlClient(RemoteControlClient)}
208     */
209    int registerRemoteControlClient(in PendingIntent mediaIntent,
210            in IRemoteControlClient rcClient, in String callingPackageName);
211    /**
212     * Do not use directly, use instead
213     *     {@link android.media.AudioManager#unregisterRemoteControlClient(RemoteControlClient)}
214     */
215    oneway void unregisterRemoteControlClient(in PendingIntent mediaIntent,
216            in IRemoteControlClient rcClient);
217
218    oneway void setPlaybackInfoForRcc(int rccId, int what, int value);
219    void setPlaybackStateForRcc(int rccId, int state, long timeMs, float speed);
220           int  getRemoteStreamMaxVolume();
221           int  getRemoteStreamVolume();
222    oneway void registerRemoteVolumeObserverForRcc(int rccId, in IRemoteVolumeObserver rvo);
223
224    void startBluetoothSco(IBinder cb, int targetSdkVersion);
225    void stopBluetoothSco(IBinder cb);
226
227    void forceVolumeControlStream(int streamType, IBinder cb);
228
229    void setRingtonePlayer(IRingtonePlayer player);
230    IRingtonePlayer getRingtonePlayer();
231    int getMasterStreamType();
232
233    void setWiredDeviceConnectionState(int device, int state, String name);
234    int setBluetoothA2dpDeviceConnectionState(in BluetoothDevice device, int state);
235
236    AudioRoutesInfo startWatchingRoutes(in IAudioRoutesObserver observer);
237
238    boolean isCameraSoundForced();
239}
240