blob: 182a7f52a85f5eb6ec59ce6447063ed27d72cccb [file] [log] [blame]
Sailesh Nepalab5d2822014-03-08 18:01:06 -08001/*
2 * Copyright (C) 2013 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
Tyler Gunnef9f6f92014-09-12 22:16:17 -070017package android.telecom;
Sailesh Nepalab5d2822014-03-08 18:01:06 -080018
Tyler Gunn2ac40102014-08-18 16:23:10 -070019import android.annotation.SdkConstant;
Santos Cordona2492812015-04-15 11:05:16 -070020import android.annotation.SystemApi;
Santos Cordon2f42b112014-07-19 13:19:37 -070021import android.app.Service;
22import android.content.Intent;
Yorke Lee32f24732015-05-12 16:18:03 -070023import android.net.Uri;
Sailesh Nepalab5d2822014-03-08 18:01:06 -080024import android.os.Handler;
25import android.os.IBinder;
26import android.os.Looper;
27import android.os.Message;
Andrew Lee50aca232014-07-22 16:41:54 -070028import android.view.Surface;
Sailesh Nepalab5d2822014-03-08 18:01:06 -080029
Ihab Awad2f236642014-03-10 15:33:45 -070030import com.android.internal.os.SomeArgs;
Tyler Gunnef9f6f92014-09-12 22:16:17 -070031import com.android.internal.telecom.IInCallAdapter;
32import com.android.internal.telecom.IInCallService;
Sailesh Nepalab5d2822014-03-08 18:01:06 -080033
Andrew Lee50aca232014-07-22 16:41:54 -070034import java.lang.String;
Santos Cordona2492812015-04-15 11:05:16 -070035import java.util.Collections;
36import java.util.List;
Andrew Lee50aca232014-07-22 16:41:54 -070037
Sailesh Nepalab5d2822014-03-08 18:01:06 -080038/**
39 * This service is implemented by any app that wishes to provide the user-interface for managing
Tyler Gunnef9f6f92014-09-12 22:16:17 -070040 * phone calls. Telecom binds to this service while there exists a live (active or incoming) call,
Santos Cordon2f42b112014-07-19 13:19:37 -070041 * and uses it to notify the in-call app of any live and and recently disconnected calls.
Sailesh Nepalab5d2822014-03-08 18:01:06 -080042 */
Santos Cordon2f42b112014-07-19 13:19:37 -070043public abstract class InCallService extends Service {
Tyler Gunn2ac40102014-08-18 16:23:10 -070044
45 /**
46 * The {@link Intent} that must be declared as handled by the service.
47 */
48 @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
Tyler Gunnef9f6f92014-09-12 22:16:17 -070049 public static final String SERVICE_INTERFACE = "android.telecom.InCallService";
Tyler Gunn2ac40102014-08-18 16:23:10 -070050
Sailesh Nepalab5d2822014-03-08 18:01:06 -080051 private static final int MSG_SET_IN_CALL_ADAPTER = 1;
52 private static final int MSG_ADD_CALL = 2;
Sailesh Nepal60437932014-04-05 16:44:55 -070053 private static final int MSG_UPDATE_CALL = 3;
Ihab Awad5d0410f2014-07-30 10:07:40 -070054 private static final int MSG_SET_POST_DIAL_WAIT = 4;
55 private static final int MSG_ON_AUDIO_STATE_CHANGED = 5;
56 private static final int MSG_BRING_TO_FOREGROUND = 6;
Santos Cordon6c912b72014-11-07 16:05:09 -080057 private static final int MSG_ON_CAN_ADD_CALL_CHANGED = 7;
Sailesh Nepalab5d2822014-03-08 18:01:06 -080058
59 /** Default Handler used to consolidate binder method calls onto a single thread. */
60 private final Handler mHandler = new Handler(Looper.getMainLooper()) {
61 @Override
62 public void handleMessage(Message msg) {
Jay Shrauner5e6162d2014-09-22 20:47:45 -070063 if (mPhone == null && msg.what != MSG_SET_IN_CALL_ADAPTER) {
64 return;
65 }
66
Sailesh Nepalab5d2822014-03-08 18:01:06 -080067 switch (msg.what) {
68 case MSG_SET_IN_CALL_ADAPTER:
Ihab Awade63fadb2014-07-09 21:52:04 -070069 mPhone = new Phone(new InCallAdapter((IInCallAdapter) msg.obj));
Santos Cordona2492812015-04-15 11:05:16 -070070 mPhone.addListener(mPhoneListener);
Ihab Awade63fadb2014-07-09 21:52:04 -070071 onPhoneCreated(mPhone);
Sailesh Nepalab5d2822014-03-08 18:01:06 -080072 break;
73 case MSG_ADD_CALL:
Santos Cordon88b771d2014-07-19 13:10:40 -070074 mPhone.internalAddCall((ParcelableCall) msg.obj);
Sailesh Nepalab5d2822014-03-08 18:01:06 -080075 break;
Sailesh Nepal60437932014-04-05 16:44:55 -070076 case MSG_UPDATE_CALL:
Santos Cordon88b771d2014-07-19 13:10:40 -070077 mPhone.internalUpdateCall((ParcelableCall) msg.obj);
Ihab Awad2f236642014-03-10 15:33:45 -070078 break;
Ihab Awad2f236642014-03-10 15:33:45 -070079 case MSG_SET_POST_DIAL_WAIT: {
80 SomeArgs args = (SomeArgs) msg.obj;
81 try {
82 String callId = (String) args.arg1;
83 String remaining = (String) args.arg2;
Ihab Awade63fadb2014-07-09 21:52:04 -070084 mPhone.internalSetPostDialWait(callId, remaining);
Ihab Awad2f236642014-03-10 15:33:45 -070085 } finally {
86 args.recycle();
87 }
88 break;
89 }
Sailesh Nepal4cff3922014-03-19 10:15:37 -070090 case MSG_ON_AUDIO_STATE_CHANGED:
Ihab Awadb19a0bc2014-08-07 19:46:01 -070091 mPhone.internalAudioStateChanged((AudioState) msg.obj);
Sailesh Nepalb632e5b2014-04-03 12:54:33 -070092 break;
Santos Cordon3534ede2014-05-29 13:07:10 -070093 case MSG_BRING_TO_FOREGROUND:
Ihab Awade63fadb2014-07-09 21:52:04 -070094 mPhone.internalBringToForeground(msg.arg1 == 1);
Santos Cordon3534ede2014-05-29 13:07:10 -070095 break;
Santos Cordon6c912b72014-11-07 16:05:09 -080096 case MSG_ON_CAN_ADD_CALL_CHANGED:
97 mPhone.internalSetCanAddCall(msg.arg1 == 1);
98 break;
Sailesh Nepalab5d2822014-03-08 18:01:06 -080099 default:
100 break;
101 }
102 }
103 };
104
105 /** Manages the binder calls so that the implementor does not need to deal with it. */
106 private final class InCallServiceBinder extends IInCallService.Stub {
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800107 @Override
108 public void setInCallAdapter(IInCallAdapter inCallAdapter) {
109 mHandler.obtainMessage(MSG_SET_IN_CALL_ADAPTER, inCallAdapter).sendToTarget();
110 }
111
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800112 @Override
Santos Cordon88b771d2014-07-19 13:10:40 -0700113 public void addCall(ParcelableCall call) {
Sailesh Nepal60437932014-04-05 16:44:55 -0700114 mHandler.obtainMessage(MSG_ADD_CALL, call).sendToTarget();
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800115 }
116
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800117 @Override
Santos Cordon88b771d2014-07-19 13:10:40 -0700118 public void updateCall(ParcelableCall call) {
Sailesh Nepal60437932014-04-05 16:44:55 -0700119 mHandler.obtainMessage(MSG_UPDATE_CALL, call).sendToTarget();
Ihab Awad2f236642014-03-10 15:33:45 -0700120 }
121
122 @Override
123 public void setPostDial(String callId, String remaining) {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700124 // TODO: Unused
Ihab Awad2f236642014-03-10 15:33:45 -0700125 }
126
127 @Override
128 public void setPostDialWait(String callId, String remaining) {
129 SomeArgs args = SomeArgs.obtain();
130 args.arg1 = callId;
131 args.arg2 = remaining;
132 mHandler.obtainMessage(MSG_SET_POST_DIAL_WAIT, args).sendToTarget();
133 }
Sailesh Nepalb632e5b2014-04-03 12:54:33 -0700134
135 @Override
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700136 public void onAudioStateChanged(AudioState audioState) {
Sailesh Nepal60437932014-04-05 16:44:55 -0700137 mHandler.obtainMessage(MSG_ON_AUDIO_STATE_CHANGED, audioState).sendToTarget();
Sailesh Nepalb632e5b2014-04-03 12:54:33 -0700138 }
Santos Cordon3534ede2014-05-29 13:07:10 -0700139
Santos Cordon3534ede2014-05-29 13:07:10 -0700140 @Override
141 public void bringToForeground(boolean showDialpad) {
142 mHandler.obtainMessage(MSG_BRING_TO_FOREGROUND, showDialpad ? 1 : 0, 0).sendToTarget();
143 }
Santos Cordon6c912b72014-11-07 16:05:09 -0800144
145 @Override
146 public void onCanAddCallChanged(boolean canAddCall) {
147 mHandler.obtainMessage(MSG_ON_CAN_ADD_CALL_CHANGED, canAddCall ? 1 : 0, 0)
148 .sendToTarget();
149 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800150 }
151
Santos Cordona2492812015-04-15 11:05:16 -0700152 private Phone.Listener mPhoneListener = new Phone.Listener() {
153 /** ${inheritDoc} */
154 @Override
155 public void onAudioStateChanged(Phone phone, AudioState audioState) {
156 InCallService.this.onAudioStateChanged(audioState);
157 }
158
159 /** ${inheritDoc} */
160 @Override
161 public void onBringToForeground(Phone phone, boolean showDialpad) {
162 InCallService.this.onBringToForeground(showDialpad);
163 }
164
165 /** ${inheritDoc} */
166 @Override
167 public void onCallAdded(Phone phone, Call call) {
168 InCallService.this.onCallAdded(call);
169 }
170
171 /** ${inheritDoc} */
172 @Override
173 public void onCallRemoved(Phone phone, Call call) {
174 InCallService.this.onCallRemoved(call);
175 }
176
177 /** ${inheritDoc} */
178 @Override
179 public void onCanAddCallChanged(Phone phone, boolean canAddCall) {
180 InCallService.this.onCanAddCallChanged(canAddCall);
181 }
182
183 };
184
Ihab Awade63fadb2014-07-09 21:52:04 -0700185 private Phone mPhone;
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800186
Santos Cordon2f42b112014-07-19 13:19:37 -0700187 public InCallService() {
188 }
Evan Charlton924748f2014-04-03 08:36:38 -0700189
Santos Cordon2f42b112014-07-19 13:19:37 -0700190 @Override
191 public IBinder onBind(Intent intent) {
Ihab Awade63fadb2014-07-09 21:52:04 -0700192 return new InCallServiceBinder();
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800193 }
194
Santos Cordonf30d7e92014-08-26 09:54:33 -0700195 @Override
196 public boolean onUnbind(Intent intent) {
Santos Cordon619b3c02014-09-02 17:13:45 -0700197 if (mPhone != null) {
198 Phone oldPhone = mPhone;
199 mPhone = null;
Santos Cordonf30d7e92014-08-26 09:54:33 -0700200
Santos Cordon619b3c02014-09-02 17:13:45 -0700201 oldPhone.destroy();
Santos Cordona2492812015-04-15 11:05:16 -0700202 // destroy sets all the calls to disconnected if any live ones still exist. Therefore,
203 // it is important to remove the Listener *after* the call to destroy so that
204 // InCallService.on* callbacks are appropriately called.
205 oldPhone.removeListener(mPhoneListener);
206
Santos Cordon619b3c02014-09-02 17:13:45 -0700207 onPhoneDestroyed(oldPhone);
208 }
Santos Cordona2492812015-04-15 11:05:16 -0700209
Santos Cordonf30d7e92014-08-26 09:54:33 -0700210 return false;
211 }
212
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800213 /**
Ihab Awade63fadb2014-07-09 21:52:04 -0700214 * Obtain the {@code Phone} associated with this {@code InCallService}.
215 *
216 * @return The {@code Phone} object associated with this {@code InCallService}, or {@code null}
Santos Cordon2f42b112014-07-19 13:19:37 -0700217 * if the {@code InCallService} is not in a state where it has an associated
218 * {@code Phone}.
Santos Cordona2492812015-04-15 11:05:16 -0700219 * @hide
Santos Cordon29886d82015-04-16 15:34:07 -0700220 * @deprecated Use direct methods on InCallService instead of {@link Phone}.
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800221 */
Santos Cordona2492812015-04-15 11:05:16 -0700222 @SystemApi
Santos Cordon29886d82015-04-16 15:34:07 -0700223 @Deprecated
224 public Phone getPhone() {
Ihab Awade63fadb2014-07-09 21:52:04 -0700225 return mPhone;
Evan Charlton924748f2014-04-03 08:36:38 -0700226 }
227
228 /**
Santos Cordona2492812015-04-15 11:05:16 -0700229 * Obtains the current list of {@code Call}s to be displayed by this in-call experience.
230 *
231 * @return A list of the relevant {@code Call}s.
232 */
233 public final List<Call> getCalls() {
234 return mPhone == null ? Collections.<Call>emptyList() : mPhone.getCalls();
235 }
236
237 /**
238 * Returns if the device can support additional calls.
239 *
240 * @return Whether the phone supports adding more calls.
241 */
242 public final boolean canAddCall() {
243 return mPhone == null ? false : mPhone.canAddCall();
244 }
245
246 /**
247 * Obtains the current phone call audio state.
248 *
249 * @return An object encapsulating the audio state. Returns null if the service is not
250 * fully initialized.
251 */
252 public final AudioState getAudioState() {
253 return mPhone == null ? null : mPhone.getAudioState();
254 }
255
256 /**
257 * Sets the microphone mute state. When this request is honored, there will be change to
258 * the {@link #getAudioState()}.
259 *
260 * @param state {@code true} if the microphone should be muted; {@code false} otherwise.
261 */
262 public final void setMuted(boolean state) {
263 if (mPhone != null) {
264 mPhone.setMuted(state);
265 }
266 }
267
268 /**
269 * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will
270 * be change to the {@link #getAudioState()}.
271 *
272 * @param route The audio route to use.
273 */
274 public final void setAudioRoute(int route) {
275 if (mPhone != null) {
276 mPhone.setAudioRoute(route);
277 }
278 }
279
280 /**
Ihab Awade63fadb2014-07-09 21:52:04 -0700281 * Invoked when the {@code Phone} has been created. This is a signal to the in-call experience
282 * to start displaying in-call information to the user. Each instance of {@code InCallService}
Santos Cordon2f42b112014-07-19 13:19:37 -0700283 * will have only one {@code Phone}, and this method will be called exactly once in the lifetime
284 * of the {@code InCallService}.
Evan Charlton924748f2014-04-03 08:36:38 -0700285 *
Ihab Awade63fadb2014-07-09 21:52:04 -0700286 * @param phone The {@code Phone} object associated with this {@code InCallService}.
Santos Cordona2492812015-04-15 11:05:16 -0700287 * @hide
Santos Cordon29886d82015-04-16 15:34:07 -0700288 * @deprecated Use direct methods on InCallService instead of {@link Phone}.
Evan Charlton924748f2014-04-03 08:36:38 -0700289 */
Santos Cordona2492812015-04-15 11:05:16 -0700290 @SystemApi
Santos Cordon29886d82015-04-16 15:34:07 -0700291 @Deprecated
Santos Cordon2f42b112014-07-19 13:19:37 -0700292 public void onPhoneCreated(Phone phone) {
293 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800294
295 /**
Ihab Awade63fadb2014-07-09 21:52:04 -0700296 * Invoked when a {@code Phone} has been destroyed. This is a signal to the in-call experience
297 * to stop displaying in-call information to the user. This method will be called exactly once
298 * in the lifetime of the {@code InCallService}, and it will always be called after a previous
299 * call to {@link #onPhoneCreated(Phone)}.
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800300 *
Ihab Awade63fadb2014-07-09 21:52:04 -0700301 * @param phone The {@code Phone} object associated with this {@code InCallService}.
Santos Cordona2492812015-04-15 11:05:16 -0700302 * @hide
Santos Cordon29886d82015-04-16 15:34:07 -0700303 * @deprecated Use direct methods on InCallService instead of {@link Phone}.
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800304 */
Santos Cordona2492812015-04-15 11:05:16 -0700305 @SystemApi
Santos Cordon29886d82015-04-16 15:34:07 -0700306 @Deprecated
Santos Cordon2f42b112014-07-19 13:19:37 -0700307 public void onPhoneDestroyed(Phone phone) {
308 }
Andrew Lee50aca232014-07-22 16:41:54 -0700309
310 /**
Santos Cordona2492812015-04-15 11:05:16 -0700311 * Called when the audio state changes.
312 *
313 * @param audioState The new {@link AudioState}.
314 */
315 public void onAudioStateChanged(AudioState audioState) {
316 }
317
318 /**
319 * Called to bring the in-call screen to the foreground. The in-call experience should
320 * respond immediately by coming to the foreground to inform the user of the state of
321 * ongoing {@code Call}s.
322 *
323 * @param showDialpad If true, put up the dialpad when the screen is shown.
324 */
325 public void onBringToForeground(boolean showDialpad) {
326 }
327
328 /**
329 * Called when a {@code Call} has been added to this in-call session. The in-call user
330 * experience should add necessary state listeners to the specified {@code Call} and
331 * immediately start to show the user information about the existence
332 * and nature of this {@code Call}. Subsequent invocations of {@link #getCalls()} will
333 * include this {@code Call}.
334 *
335 * @param call A newly added {@code Call}.
336 */
337 public void onCallAdded(Call call) {
338 }
339
340 /**
341 * Called when a {@code Call} has been removed from this in-call session. The in-call user
342 * experience should remove any state listeners from the specified {@code Call} and
343 * immediately stop displaying any information about this {@code Call}.
344 * Subsequent invocations of {@link #getCalls()} will no longer include this {@code Call}.
345 *
346 * @param call A newly removed {@code Call}.
347 */
348 public void onCallRemoved(Call call) {
349 }
350
351 /**
352 * Called when the ability to add more calls changes. If the phone cannot
353 * support more calls then {@code canAddCall} is set to {@code false}. If it can, then it
354 * is set to {@code true}. This can be used to control the visibility of UI to add more calls.
355 *
356 * @param canAddCall Indicates whether an additional call can be added.
357 */
358 public void onCanAddCallChanged(boolean canAddCall) {
359 }
360
361 /**
Andrew Lee50aca232014-07-22 16:41:54 -0700362 * Class to invoke functionality related to video calls.
363 */
364 public static abstract class VideoCall {
365
Andrew Lee011728f2015-04-23 15:47:06 -0700366 /** @hide */
367 public abstract void destroy();
368
Andrew Lee50aca232014-07-22 16:41:54 -0700369 /**
Andrew Lee7c9ee2b2015-04-16 15:26:08 -0700370 * Registers a callback to receive commands and state changes for video calls.
Andrew Lee50aca232014-07-22 16:41:54 -0700371 *
Andrew Lee7c9ee2b2015-04-16 15:26:08 -0700372 * @param callback The video call callback.
Andrew Lee50aca232014-07-22 16:41:54 -0700373 */
Andrew Leeda80c872015-04-15 14:09:50 -0700374 public abstract void registerCallback(VideoCall.Callback callback);
375
376 /**
Andrew Lee011728f2015-04-23 15:47:06 -0700377 * Registers a callback to receive commands and state changes for video calls.
378 *
379 * @param callback The video call callback.
380 * @param handler A handler which commands and status changes will be delivered to.
381 */
382 public abstract void registerCallback(VideoCall.Callback callback, Handler handler);
383
384 /**
Etan Cohen912270e2015-04-24 18:43:41 -0700385 * Clears the video call listener set via {@link #registerCallback}.
Tyler Gunn75958422015-04-15 14:23:42 -0700386 */
Andrew Lee011728f2015-04-23 15:47:06 -0700387 public abstract void unregisterCallback(VideoCall.Callback callback);
Tyler Gunn75958422015-04-15 14:23:42 -0700388
389 /**
Andrew Lee50aca232014-07-22 16:41:54 -0700390 * Sets the camera to be used for video recording in a video call.
391 *
392 * @param cameraId The id of the camera.
393 */
394 public abstract void setCamera(String cameraId);
395
396 /**
397 * Sets the surface to be used for displaying a preview of what the user's camera is
398 * currently capturing. When video transmission is enabled, this is the video signal which
399 * is sent to the remote device.
400 *
401 * @param surface The surface.
402 */
403 public abstract void setPreviewSurface(Surface surface);
404
405 /**
406 * Sets the surface to be used for displaying the video received from the remote device.
407 *
408 * @param surface The surface.
409 */
410 public abstract void setDisplaySurface(Surface surface);
411
412 /**
413 * Sets the device orientation, in degrees. Assumes that a standard portrait orientation of
414 * the device is 0 degrees.
415 *
416 * @param rotation The device orientation, in degrees.
417 */
418 public abstract void setDeviceOrientation(int rotation);
419
420 /**
421 * Sets camera zoom ratio.
422 *
423 * @param value The camera zoom ratio.
424 */
425 public abstract void setZoom(float value);
426
427 /**
428 * Issues a request to modify the properties of the current session. The request is sent to
429 * the remote device where it it handled by
Andrew Leeda80c872015-04-15 14:09:50 -0700430 * {@link VideoCall.Callback#onSessionModifyRequestReceived}.
Andrew Lee50aca232014-07-22 16:41:54 -0700431 * Some examples of session modification requests: upgrade call from audio to video,
432 * downgrade call from video to audio, pause video.
433 *
434 * @param requestProfile The requested call video properties.
435 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700436 public abstract void sendSessionModifyRequest(VideoProfile requestProfile);
Andrew Lee50aca232014-07-22 16:41:54 -0700437
438 /**
439 * Provides a response to a request to change the current call session video
440 * properties.
441 * This is in response to a request the InCall UI has received via
Andrew Leeda80c872015-04-15 14:09:50 -0700442 * {@link VideoCall.Callback#onSessionModifyRequestReceived}.
Andrew Lee50aca232014-07-22 16:41:54 -0700443 * The response is handled on the remove device by
Andrew Leeda80c872015-04-15 14:09:50 -0700444 * {@link VideoCall.Callback#onSessionModifyResponseReceived}.
Andrew Lee50aca232014-07-22 16:41:54 -0700445 *
446 * @param responseProfile The response call video properties.
447 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700448 public abstract void sendSessionModifyResponse(VideoProfile responseProfile);
Andrew Lee50aca232014-07-22 16:41:54 -0700449
450 /**
451 * Issues a request to the video provider to retrieve the camera capabilities.
452 * Camera capabilities are reported back to the caller via
Andrew Leeda80c872015-04-15 14:09:50 -0700453 * {@link VideoCall.Callback#onCameraCapabilitiesChanged(CameraCapabilities)}.
Andrew Lee50aca232014-07-22 16:41:54 -0700454 */
455 public abstract void requestCameraCapabilities();
456
457 /**
458 * Issues a request to the video telephony framework to retrieve the cumulative data usage for
459 * the current call. Data usage is reported back to the caller via
Andrew Leeda80c872015-04-15 14:09:50 -0700460 * {@link VideoCall.Callback#onCallDataUsageChanged}.
Andrew Lee50aca232014-07-22 16:41:54 -0700461 */
462 public abstract void requestCallDataUsage();
463
464 /**
465 * Provides the video telephony framework with the URI of an image to be displayed to remote
466 * devices when the video signal is paused.
467 *
468 * @param uri URI of image to display.
469 */
Yorke Lee32f24732015-05-12 16:18:03 -0700470 public abstract void setPauseImage(Uri uri);
Andrew Lee50aca232014-07-22 16:41:54 -0700471
472 /**
Andrew Leeda80c872015-04-15 14:09:50 -0700473 * Callback class which invokes callbacks after video call actions occur.
Andrew Lee50aca232014-07-22 16:41:54 -0700474 */
Andrew Leeda80c872015-04-15 14:09:50 -0700475 public static abstract class Callback {
Andrew Lee50aca232014-07-22 16:41:54 -0700476 /**
477 * Called when a session modification request is received from the remote device.
Andrew Lee14185762014-07-25 09:41:56 -0700478 * The remote request is sent via
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700479 * {@link Connection.VideoProvider#onSendSessionModifyRequest}. The InCall UI
Andrew Lee14185762014-07-25 09:41:56 -0700480 * is responsible for potentially prompting the user whether they wish to accept the new
481 * call profile (e.g. prompt user if they wish to accept an upgrade from an audio to a
482 * video call) and should call
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700483 * {@link Connection.VideoProvider#onSendSessionModifyResponse} to indicate
Andrew Lee14185762014-07-25 09:41:56 -0700484 * the video settings the user has agreed to.
Andrew Lee50aca232014-07-22 16:41:54 -0700485 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700486 * @param videoProfile The requested video call profile.
Andrew Lee50aca232014-07-22 16:41:54 -0700487 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700488 public abstract void onSessionModifyRequestReceived(VideoProfile videoProfile);
Andrew Lee50aca232014-07-22 16:41:54 -0700489
490 /**
491 * Called when a response to a session modification request is received from the remote
492 * device. The remote InCall UI sends the response using
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700493 * {@link Connection.VideoProvider#onSendSessionModifyResponse}.
Andrew Lee50aca232014-07-22 16:41:54 -0700494 *
495 * @param status Status of the session modify request. Valid values are
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700496 * {@link Connection.VideoProvider#SESSION_MODIFY_REQUEST_SUCCESS},
497 * {@link Connection.VideoProvider#SESSION_MODIFY_REQUEST_FAIL},
498 * {@link Connection.VideoProvider#SESSION_MODIFY_REQUEST_INVALID}
Andrew Lee50aca232014-07-22 16:41:54 -0700499 * @param requestedProfile The original request which was sent to the remote device.
500 * @param responseProfile The actual profile changes made by the remote device.
501 */
502 public abstract void onSessionModifyResponseReceived(int status,
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700503 VideoProfile requestedProfile, VideoProfile responseProfile);
Andrew Lee50aca232014-07-22 16:41:54 -0700504
505 /**
506 * Handles events related to the current session which the client may wish to handle.
507 * These are separate from requested changes to the session due to the underlying
508 * protocol or connection.
509 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700510 * Valid values are:
511 * {@link Connection.VideoProvider#SESSION_EVENT_RX_PAUSE},
512 * {@link Connection.VideoProvider#SESSION_EVENT_RX_RESUME},
513 * {@link Connection.VideoProvider#SESSION_EVENT_TX_START},
514 * {@link Connection.VideoProvider#SESSION_EVENT_TX_STOP},
515 * {@link Connection.VideoProvider#SESSION_EVENT_CAMERA_FAILURE},
516 * {@link Connection.VideoProvider#SESSION_EVENT_CAMERA_READY}
Andrew Lee50aca232014-07-22 16:41:54 -0700517 *
518 * @param event The event.
519 */
520 public abstract void onCallSessionEvent(int event);
521
522 /**
523 * Handles a change to the video dimensions from the remote caller (peer). This could
524 * happen if, for example, the peer changes orientation of their device.
525 *
526 * @param width The updated peer video width.
527 * @param height The updated peer video height.
528 */
529 public abstract void onPeerDimensionsChanged(int width, int height);
530
531 /**
Rekha Kumar07366812015-03-24 16:42:31 -0700532 * Handles a change to the video quality.
533 *
534 * @param videoQuality The updated peer video quality.
535 */
536 public abstract void onVideoQualityChanged(int videoQuality);
537
538 /**
Andrew Lee50aca232014-07-22 16:41:54 -0700539 * Handles an update to the total data used for the current session.
540 *
541 * @param dataUsage The updated data usage.
542 */
Rekha Kumar07366812015-03-24 16:42:31 -0700543 public abstract void onCallDataUsageChanged(long dataUsage);
Andrew Lee50aca232014-07-22 16:41:54 -0700544
545 /**
546 * Handles a change in camera capabilities.
547 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700548 * @param cameraCapabilities The changed camera capabilities.
Andrew Lee50aca232014-07-22 16:41:54 -0700549 */
Yorke Lee400470f2015-05-12 13:31:25 -0700550 public abstract void onCameraCapabilitiesChanged(
551 VideoProfile.CameraCapabilities cameraCapabilities);
Andrew Lee50aca232014-07-22 16:41:54 -0700552 }
553 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800554}