blob: 1aeeca73c0b9c595647e92f4c22f19ee6f378fff [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
Hall Liua98f58b52017-11-07 17:59:28 -080019import android.annotation.NonNull;
Tyler Gunn2ac40102014-08-18 16:23:10 -070020import android.annotation.SdkConstant;
Santos Cordona2492812015-04-15 11:05:16 -070021import android.annotation.SystemApi;
Santos Cordon2f42b112014-07-19 13:19:37 -070022import android.app.Service;
Hall Liua98f58b52017-11-07 17:59:28 -080023import android.bluetooth.BluetoothDevice;
Santos Cordon2f42b112014-07-19 13:19:37 -070024import android.content.Intent;
Tyler Gunnb702ef82015-05-29 11:51:53 -070025import android.hardware.camera2.CameraManager;
Yorke Lee32f24732015-05-12 16:18:03 -070026import android.net.Uri;
Tyler Gunn876dbfb2016-03-14 15:18:07 -070027import android.os.Bundle;
Sailesh Nepalab5d2822014-03-08 18:01:06 -080028import android.os.Handler;
29import android.os.IBinder;
30import android.os.Looper;
31import android.os.Message;
Andrew Lee50aca232014-07-22 16:41:54 -070032import android.view.Surface;
Sailesh Nepalab5d2822014-03-08 18:01:06 -080033
Ihab Awad2f236642014-03-10 15:33:45 -070034import com.android.internal.os.SomeArgs;
Tyler Gunnef9f6f92014-09-12 22:16:17 -070035import com.android.internal.telecom.IInCallAdapter;
36import com.android.internal.telecom.IInCallService;
Sailesh Nepalab5d2822014-03-08 18:01:06 -080037
Andrew Lee50aca232014-07-22 16:41:54 -070038import java.lang.String;
Santos Cordona2492812015-04-15 11:05:16 -070039import java.util.Collections;
40import java.util.List;
Andrew Lee50aca232014-07-22 16:41:54 -070041
Sailesh Nepalab5d2822014-03-08 18:01:06 -080042/**
43 * This service is implemented by any app that wishes to provide the user-interface for managing
Tyler Gunnef9f6f92014-09-12 22:16:17 -070044 * phone calls. Telecom binds to this service while there exists a live (active or incoming) call,
Santos Cordonf2600eb2015-06-22 15:02:20 -070045 * and uses it to notify the in-call app of any live and recently disconnected calls. An app must
46 * first be set as the default phone app (See {@link TelecomManager#getDefaultDialerPackage()})
47 * before the telecom service will bind to its {@code InCallService} implementation.
48 * <p>
49 * Below is an example manifest registration for an {@code InCallService}. The meta-data
Tyler Gunndc6e6c42018-07-03 16:08:17 -070050 * {@link TelecomManager#METADATA_IN_CALL_SERVICE_UI} indicates that this particular
Santos Cordonf2600eb2015-06-22 15:02:20 -070051 * {@code InCallService} implementation intends to replace the built-in in-call UI.
Tyler Gunndc6e6c42018-07-03 16:08:17 -070052 * The meta-data {@link TelecomManager#METADATA_IN_CALL_SERVICE_RINGING} indicates that this
53 * {@link InCallService} will play the ringtone for incoming calls. See
54 * <a href="#incomingCallNotification">below</a> for more information on showing the incoming call
55 * UI and playing the ringtone in your app.
Santos Cordonf2600eb2015-06-22 15:02:20 -070056 * <pre>
57 * {@code
Neil Fuller71fbb812015-11-30 09:51:33 +000058 * <service android:name="your.package.YourInCallServiceImplementation"
Sailesh Nepal78f3ba62015-12-28 16:20:56 -080059 * android:permission="android.permission.BIND_INCALL_SERVICE">
Neil Fuller71fbb812015-11-30 09:51:33 +000060 * <meta-data android:name="android.telecom.IN_CALL_SERVICE_UI" android:value="true" />
Tyler Gunndc6e6c42018-07-03 16:08:17 -070061 * <meta-data android:name="android.telecom.IN_CALL_SERVICE_RINGING"
62 * android:value="true" />
Neil Fuller71fbb812015-11-30 09:51:33 +000063 * <intent-filter>
64 * <action android:name="android.telecom.InCallService"/>
65 * </intent-filter>
66 * </service>
Santos Cordonf2600eb2015-06-22 15:02:20 -070067 * }
68 * </pre>
Tyler Gunnfe39efa2018-02-02 13:18:02 -080069 * <p>
70 * In addition to implementing the {@link InCallService} API, you must also declare an activity in
71 * your manifest which handles the {@link Intent#ACTION_DIAL} intent. The example below illustrates
72 * how this is done:
73 * <pre>
74 * {@code
75 * <activity android:name="your.package.YourDialerActivity"
76 * android:label="@string/yourDialerActivityLabel">
77 * <intent-filter>
78 * <action android:name="android.intent.action.DIAL" />
79 * <category android:name="android.intent.category.DEFAULT" />
80 * </intent-filter>
81 * </activity>
82 * }
83 * </pre>
84 * <p>
85 * When a user installs your application and runs it for the first time, you should prompt the user
86 * to see if they would like your application to be the new default phone app. See the
87 * {@link TelecomManager#ACTION_CHANGE_DEFAULT_DIALER} intent documentation for more information on
88 * how to do this.
Tyler Gunndc6e6c42018-07-03 16:08:17 -070089 * <p id="incomingCallNotification">
90 * <h2>Showing the Incoming Call Notification</h2>
91 * When your app receives a new incoming call via {@link InCallService#onCallAdded(Call)}, it is
92 * responsible for displaying an incoming call UI for the incoming call. It should do this using
93 * {@link android.app.NotificationManager} APIs to post a new incoming call notification.
94 * <p>
95 * Where your app declares the meta-data {@link TelecomManager#METADATA_IN_CALL_SERVICE_RINGING}, it
96 * is responsible for playing the ringtone for incoming calls. Your app should create a
97 * {@link android.app.NotificationChannel} which specifies the desired ringtone. For example:
98 * <pre><code>
99 * NotificationChannel channel = new NotificationChannel(YOUR_CHANNEL_ID, "Incoming Calls",
100 * NotificationManager.IMPORTANCE_MAX);
101 * // other channel setup stuff goes here.
102 *
103 * // We'll use the default system ringtone for our incoming call notification channel. You can
104 * // use your own audio resource here.
105 * Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
106 * channel.setSound(ringtoneUri, new AudioAttributes.Builder()
107 * // Setting the AudioAttributes is important as it identifies the purpose of your
108 * // notification sound.
109 * .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
110 * .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
111 * .build());
112 *
113 * NotificationManager mgr = getSystemService(NotificationManager.class);
114 * mgr.createNotificationChannel(channel);
115 * </code></pre>
116 * <p>
117 * When your app receives a new incoming call, it creates a {@link android.app.Notification} for the
118 * incoming call and associates it with your incoming call notification channel. You can specify a
119 * {@link android.app.PendingIntent} on the notification which will launch your full screen
120 * incoming call UI. The notification manager framework will display your notification as a
121 * heads-up notification if the user is actively using the phone. When the user is not using the
122 * phone, your full-screen incoming call UI is used instead.
123 * For example:
124 * <pre><code>
125 * // Create an intent which triggers your fullscreen incoming call user interface.
126 * Intent intent = new Intent(Intent.ACTION_MAIN, null);
127 * intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_ACTIVITY_NEW_TASK);
128 * intent.setClass(context, YourIncomingCallActivity.class);
129 * PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, 0);
130 *
131 * // Build the notification as an ongoing high priority item; this ensures it will show as
132 * // a heads up notification which slides down over top of the current content.
133 * final Notification.Builder builder = new Notification.Builder(context);
134 * builder.setOngoing(true);
135 * builder.setPriority(Notification.PRIORITY_HIGH);
136 *
137 * // Set notification content intent to take user to the fullscreen UI if user taps on the
138 * // notification body.
139 * builder.setContentIntent(pendingIntent);
140 * // Set full screen intent to trigger display of the fullscreen UI when the notification
141 * // manager deems it appropriate.
142 * builder.setFullScreenIntent(pendingIntent, true);
143 *
144 * // Setup notification content.
145 * builder.setSmallIcon( yourIconResourceId );
146 * builder.setContentTitle("Your notification title");
147 * builder.setContentText("Your notification content.");
148 *
149 * // Use builder.addAction(..) to add buttons to answer or reject the call.
150 *
151 * NotificationManager notificationManager = mContext.getSystemService(
152 * NotificationManager.class);
153 * notificationManager.notify(YOUR_CHANNEL_ID, YOUR_TAG, YOUR_ID, builder.build());
154 * </code></pre>
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800155 */
Santos Cordon2f42b112014-07-19 13:19:37 -0700156public abstract class InCallService extends Service {
Tyler Gunn2ac40102014-08-18 16:23:10 -0700157
158 /**
159 * The {@link Intent} that must be declared as handled by the service.
160 */
161 @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION)
Tyler Gunnef9f6f92014-09-12 22:16:17 -0700162 public static final String SERVICE_INTERFACE = "android.telecom.InCallService";
Tyler Gunn2ac40102014-08-18 16:23:10 -0700163
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800164 private static final int MSG_SET_IN_CALL_ADAPTER = 1;
165 private static final int MSG_ADD_CALL = 2;
Sailesh Nepal60437932014-04-05 16:44:55 -0700166 private static final int MSG_UPDATE_CALL = 3;
Ihab Awad5d0410f2014-07-30 10:07:40 -0700167 private static final int MSG_SET_POST_DIAL_WAIT = 4;
Yorke Lee4af59352015-05-13 14:14:54 -0700168 private static final int MSG_ON_CALL_AUDIO_STATE_CHANGED = 5;
Ihab Awad5d0410f2014-07-30 10:07:40 -0700169 private static final int MSG_BRING_TO_FOREGROUND = 6;
Santos Cordon6c912b72014-11-07 16:05:09 -0800170 private static final int MSG_ON_CAN_ADD_CALL_CHANGED = 7;
Sailesh Nepal9c2618b2016-01-23 16:28:22 -0800171 private static final int MSG_SILENCE_RINGER = 8;
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700172 private static final int MSG_ON_CONNECTION_EVENT = 9;
Hall Liu95d55872017-01-25 17:12:49 -0800173 private static final int MSG_ON_RTT_UPGRADE_REQUEST = 10;
Hall Liu57006aa2017-02-06 10:49:48 -0800174 private static final int MSG_ON_RTT_INITIATION_FAILURE = 11;
Sanket Padawe85291f62017-12-01 13:59:27 -0800175 private static final int MSG_ON_HANDOVER_FAILED = 12;
Tyler Gunn858bfaf2018-01-22 15:17:54 -0800176 private static final int MSG_ON_HANDOVER_COMPLETE = 13;
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800177
178 /** Default Handler used to consolidate binder method calls onto a single thread. */
179 private final Handler mHandler = new Handler(Looper.getMainLooper()) {
180 @Override
181 public void handleMessage(Message msg) {
Jay Shrauner5e6162d2014-09-22 20:47:45 -0700182 if (mPhone == null && msg.what != MSG_SET_IN_CALL_ADAPTER) {
183 return;
184 }
185
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800186 switch (msg.what) {
187 case MSG_SET_IN_CALL_ADAPTER:
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -0800188 String callingPackage = getApplicationContext().getOpPackageName();
Tyler Gunn159f35c2017-03-02 09:28:37 -0800189 mPhone = new Phone(new InCallAdapter((IInCallAdapter) msg.obj), callingPackage,
190 getApplicationContext().getApplicationInfo().targetSdkVersion);
Santos Cordona2492812015-04-15 11:05:16 -0700191 mPhone.addListener(mPhoneListener);
Ihab Awade63fadb2014-07-09 21:52:04 -0700192 onPhoneCreated(mPhone);
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800193 break;
194 case MSG_ADD_CALL:
Santos Cordon88b771d2014-07-19 13:10:40 -0700195 mPhone.internalAddCall((ParcelableCall) msg.obj);
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800196 break;
Sailesh Nepal60437932014-04-05 16:44:55 -0700197 case MSG_UPDATE_CALL:
Santos Cordon88b771d2014-07-19 13:10:40 -0700198 mPhone.internalUpdateCall((ParcelableCall) msg.obj);
Ihab Awad2f236642014-03-10 15:33:45 -0700199 break;
Ihab Awad2f236642014-03-10 15:33:45 -0700200 case MSG_SET_POST_DIAL_WAIT: {
201 SomeArgs args = (SomeArgs) msg.obj;
202 try {
203 String callId = (String) args.arg1;
204 String remaining = (String) args.arg2;
Ihab Awade63fadb2014-07-09 21:52:04 -0700205 mPhone.internalSetPostDialWait(callId, remaining);
Ihab Awad2f236642014-03-10 15:33:45 -0700206 } finally {
207 args.recycle();
208 }
209 break;
210 }
Yorke Lee4af59352015-05-13 14:14:54 -0700211 case MSG_ON_CALL_AUDIO_STATE_CHANGED:
212 mPhone.internalCallAudioStateChanged((CallAudioState) msg.obj);
Sailesh Nepalb632e5b2014-04-03 12:54:33 -0700213 break;
Santos Cordon3534ede2014-05-29 13:07:10 -0700214 case MSG_BRING_TO_FOREGROUND:
Ihab Awade63fadb2014-07-09 21:52:04 -0700215 mPhone.internalBringToForeground(msg.arg1 == 1);
Santos Cordon3534ede2014-05-29 13:07:10 -0700216 break;
Santos Cordon6c912b72014-11-07 16:05:09 -0800217 case MSG_ON_CAN_ADD_CALL_CHANGED:
218 mPhone.internalSetCanAddCall(msg.arg1 == 1);
219 break;
Sailesh Nepal9c2618b2016-01-23 16:28:22 -0800220 case MSG_SILENCE_RINGER:
221 mPhone.internalSilenceRinger();
222 break;
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700223 case MSG_ON_CONNECTION_EVENT: {
224 SomeArgs args = (SomeArgs) msg.obj;
225 try {
226 String callId = (String) args.arg1;
227 String event = (String) args.arg2;
228 Bundle extras = (Bundle) args.arg3;
229 mPhone.internalOnConnectionEvent(callId, event, extras);
230 } finally {
231 args.recycle();
232 }
233 break;
234 }
Hall Liu95d55872017-01-25 17:12:49 -0800235 case MSG_ON_RTT_UPGRADE_REQUEST: {
236 String callId = (String) msg.obj;
237 int requestId = msg.arg1;
238 mPhone.internalOnRttUpgradeRequest(callId, requestId);
239 break;
240 }
Hall Liu57006aa2017-02-06 10:49:48 -0800241 case MSG_ON_RTT_INITIATION_FAILURE: {
242 String callId = (String) msg.obj;
243 int reason = msg.arg1;
244 mPhone.internalOnRttInitiationFailure(callId, reason);
245 break;
246 }
Sanket Padawe85291f62017-12-01 13:59:27 -0800247 case MSG_ON_HANDOVER_FAILED: {
248 String callId = (String) msg.obj;
249 int error = msg.arg1;
250 mPhone.internalOnHandoverFailed(callId, error);
251 break;
252 }
Tyler Gunn858bfaf2018-01-22 15:17:54 -0800253 case MSG_ON_HANDOVER_COMPLETE: {
254 String callId = (String) msg.obj;
255 mPhone.internalOnHandoverComplete(callId);
256 break;
257 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800258 default:
259 break;
260 }
261 }
262 };
263
264 /** Manages the binder calls so that the implementor does not need to deal with it. */
265 private final class InCallServiceBinder extends IInCallService.Stub {
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800266 @Override
267 public void setInCallAdapter(IInCallAdapter inCallAdapter) {
268 mHandler.obtainMessage(MSG_SET_IN_CALL_ADAPTER, inCallAdapter).sendToTarget();
269 }
270
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800271 @Override
Santos Cordon88b771d2014-07-19 13:10:40 -0700272 public void addCall(ParcelableCall call) {
Sailesh Nepal60437932014-04-05 16:44:55 -0700273 mHandler.obtainMessage(MSG_ADD_CALL, call).sendToTarget();
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800274 }
275
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800276 @Override
Santos Cordon88b771d2014-07-19 13:10:40 -0700277 public void updateCall(ParcelableCall call) {
Sailesh Nepal60437932014-04-05 16:44:55 -0700278 mHandler.obtainMessage(MSG_UPDATE_CALL, call).sendToTarget();
Ihab Awad2f236642014-03-10 15:33:45 -0700279 }
280
281 @Override
282 public void setPostDial(String callId, String remaining) {
Ihab Awad5d0410f2014-07-30 10:07:40 -0700283 // TODO: Unused
Ihab Awad2f236642014-03-10 15:33:45 -0700284 }
285
286 @Override
287 public void setPostDialWait(String callId, String remaining) {
288 SomeArgs args = SomeArgs.obtain();
289 args.arg1 = callId;
290 args.arg2 = remaining;
291 mHandler.obtainMessage(MSG_SET_POST_DIAL_WAIT, args).sendToTarget();
292 }
Sailesh Nepalb632e5b2014-04-03 12:54:33 -0700293
294 @Override
Yorke Lee4af59352015-05-13 14:14:54 -0700295 public void onCallAudioStateChanged(CallAudioState callAudioState) {
296 mHandler.obtainMessage(MSG_ON_CALL_AUDIO_STATE_CHANGED, callAudioState).sendToTarget();
Sailesh Nepalb632e5b2014-04-03 12:54:33 -0700297 }
Santos Cordon3534ede2014-05-29 13:07:10 -0700298
Santos Cordon3534ede2014-05-29 13:07:10 -0700299 @Override
300 public void bringToForeground(boolean showDialpad) {
301 mHandler.obtainMessage(MSG_BRING_TO_FOREGROUND, showDialpad ? 1 : 0, 0).sendToTarget();
302 }
Santos Cordon6c912b72014-11-07 16:05:09 -0800303
304 @Override
305 public void onCanAddCallChanged(boolean canAddCall) {
306 mHandler.obtainMessage(MSG_ON_CAN_ADD_CALL_CHANGED, canAddCall ? 1 : 0, 0)
307 .sendToTarget();
308 }
Sailesh Nepal9c2618b2016-01-23 16:28:22 -0800309
310 @Override
311 public void silenceRinger() {
312 mHandler.obtainMessage(MSG_SILENCE_RINGER).sendToTarget();
313 }
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700314
315 @Override
316 public void onConnectionEvent(String callId, String event, Bundle extras) {
317 SomeArgs args = SomeArgs.obtain();
318 args.arg1 = callId;
319 args.arg2 = event;
320 args.arg3 = extras;
321 mHandler.obtainMessage(MSG_ON_CONNECTION_EVENT, args).sendToTarget();
322 }
Hall Liu95d55872017-01-25 17:12:49 -0800323
324 @Override
325 public void onRttUpgradeRequest(String callId, int id) {
326 mHandler.obtainMessage(MSG_ON_RTT_UPGRADE_REQUEST, id, 0, callId).sendToTarget();
327 }
Hall Liu57006aa2017-02-06 10:49:48 -0800328
329 @Override
330 public void onRttInitiationFailure(String callId, int reason) {
331 mHandler.obtainMessage(MSG_ON_RTT_INITIATION_FAILURE, reason, 0, callId).sendToTarget();
332 }
Sanket Padawe85291f62017-12-01 13:59:27 -0800333
334 @Override
335 public void onHandoverFailed(String callId, int error) {
336 mHandler.obtainMessage(MSG_ON_HANDOVER_FAILED, error, 0, callId).sendToTarget();
337 }
Tyler Gunn858bfaf2018-01-22 15:17:54 -0800338
339 @Override
340 public void onHandoverComplete(String callId) {
341 mHandler.obtainMessage(MSG_ON_HANDOVER_COMPLETE, callId).sendToTarget();
342 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800343 }
344
Santos Cordona2492812015-04-15 11:05:16 -0700345 private Phone.Listener mPhoneListener = new Phone.Listener() {
346 /** ${inheritDoc} */
347 @Override
348 public void onAudioStateChanged(Phone phone, AudioState audioState) {
349 InCallService.this.onAudioStateChanged(audioState);
350 }
351
Yorke Lee4af59352015-05-13 14:14:54 -0700352 public void onCallAudioStateChanged(Phone phone, CallAudioState callAudioState) {
353 InCallService.this.onCallAudioStateChanged(callAudioState);
354 };
355
Santos Cordona2492812015-04-15 11:05:16 -0700356 /** ${inheritDoc} */
357 @Override
358 public void onBringToForeground(Phone phone, boolean showDialpad) {
359 InCallService.this.onBringToForeground(showDialpad);
360 }
361
362 /** ${inheritDoc} */
363 @Override
364 public void onCallAdded(Phone phone, Call call) {
365 InCallService.this.onCallAdded(call);
366 }
367
368 /** ${inheritDoc} */
369 @Override
370 public void onCallRemoved(Phone phone, Call call) {
371 InCallService.this.onCallRemoved(call);
372 }
373
374 /** ${inheritDoc} */
375 @Override
376 public void onCanAddCallChanged(Phone phone, boolean canAddCall) {
377 InCallService.this.onCanAddCallChanged(canAddCall);
378 }
379
Sailesh Nepal9c2618b2016-01-23 16:28:22 -0800380 /** ${inheritDoc} */
381 @Override
382 public void onSilenceRinger(Phone phone) {
383 InCallService.this.onSilenceRinger();
384 }
385
Santos Cordona2492812015-04-15 11:05:16 -0700386 };
387
Ihab Awade63fadb2014-07-09 21:52:04 -0700388 private Phone mPhone;
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800389
Santos Cordon2f42b112014-07-19 13:19:37 -0700390 public InCallService() {
391 }
Evan Charlton924748f2014-04-03 08:36:38 -0700392
Santos Cordon2f42b112014-07-19 13:19:37 -0700393 @Override
394 public IBinder onBind(Intent intent) {
Ihab Awade63fadb2014-07-09 21:52:04 -0700395 return new InCallServiceBinder();
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800396 }
397
Santos Cordonf30d7e92014-08-26 09:54:33 -0700398 @Override
399 public boolean onUnbind(Intent intent) {
Santos Cordon619b3c02014-09-02 17:13:45 -0700400 if (mPhone != null) {
401 Phone oldPhone = mPhone;
402 mPhone = null;
Santos Cordonf30d7e92014-08-26 09:54:33 -0700403
Santos Cordon619b3c02014-09-02 17:13:45 -0700404 oldPhone.destroy();
Santos Cordona2492812015-04-15 11:05:16 -0700405 // destroy sets all the calls to disconnected if any live ones still exist. Therefore,
406 // it is important to remove the Listener *after* the call to destroy so that
407 // InCallService.on* callbacks are appropriately called.
408 oldPhone.removeListener(mPhoneListener);
409
Santos Cordon619b3c02014-09-02 17:13:45 -0700410 onPhoneDestroyed(oldPhone);
411 }
Santos Cordona2492812015-04-15 11:05:16 -0700412
Santos Cordonf30d7e92014-08-26 09:54:33 -0700413 return false;
414 }
415
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800416 /**
Ihab Awade63fadb2014-07-09 21:52:04 -0700417 * Obtain the {@code Phone} associated with this {@code InCallService}.
418 *
419 * @return The {@code Phone} object associated with this {@code InCallService}, or {@code null}
Santos Cordon2f42b112014-07-19 13:19:37 -0700420 * if the {@code InCallService} is not in a state where it has an associated
421 * {@code Phone}.
Santos Cordona2492812015-04-15 11:05:16 -0700422 * @hide
Santos Cordon29886d82015-04-16 15:34:07 -0700423 * @deprecated Use direct methods on InCallService instead of {@link Phone}.
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800424 */
Santos Cordona2492812015-04-15 11:05:16 -0700425 @SystemApi
Santos Cordon29886d82015-04-16 15:34:07 -0700426 @Deprecated
427 public Phone getPhone() {
Ihab Awade63fadb2014-07-09 21:52:04 -0700428 return mPhone;
Evan Charlton924748f2014-04-03 08:36:38 -0700429 }
430
431 /**
Santos Cordon895d4b82015-06-25 16:41:48 -0700432 * Obtains the current list of {@code Call}s to be displayed by this in-call service.
Santos Cordona2492812015-04-15 11:05:16 -0700433 *
434 * @return A list of the relevant {@code Call}s.
435 */
436 public final List<Call> getCalls() {
437 return mPhone == null ? Collections.<Call>emptyList() : mPhone.getCalls();
438 }
439
440 /**
441 * Returns if the device can support additional calls.
442 *
443 * @return Whether the phone supports adding more calls.
444 */
445 public final boolean canAddCall() {
446 return mPhone == null ? false : mPhone.canAddCall();
447 }
448
449 /**
450 * Obtains the current phone call audio state.
451 *
452 * @return An object encapsulating the audio state. Returns null if the service is not
453 * fully initialized.
Yorke Lee4af59352015-05-13 14:14:54 -0700454 * @deprecated Use {@link #getCallAudioState()} instead.
455 * @hide
Santos Cordona2492812015-04-15 11:05:16 -0700456 */
Yorke Lee4af59352015-05-13 14:14:54 -0700457 @Deprecated
Santos Cordona2492812015-04-15 11:05:16 -0700458 public final AudioState getAudioState() {
459 return mPhone == null ? null : mPhone.getAudioState();
460 }
461
462 /**
Yorke Lee4af59352015-05-13 14:14:54 -0700463 * Obtains the current phone call audio state.
464 *
465 * @return An object encapsulating the audio state. Returns null if the service is not
466 * fully initialized.
467 */
468 public final CallAudioState getCallAudioState() {
469 return mPhone == null ? null : mPhone.getCallAudioState();
470 }
471
472 /**
Santos Cordona2492812015-04-15 11:05:16 -0700473 * Sets the microphone mute state. When this request is honored, there will be change to
Yorke Lee4af59352015-05-13 14:14:54 -0700474 * the {@link #getCallAudioState()}.
Santos Cordona2492812015-04-15 11:05:16 -0700475 *
476 * @param state {@code true} if the microphone should be muted; {@code false} otherwise.
477 */
478 public final void setMuted(boolean state) {
479 if (mPhone != null) {
480 mPhone.setMuted(state);
481 }
482 }
483
484 /**
485 * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will
Yorke Lee4af59352015-05-13 14:14:54 -0700486 * be change to the {@link #getCallAudioState()}.
Santos Cordona2492812015-04-15 11:05:16 -0700487 *
488 * @param route The audio route to use.
489 */
490 public final void setAudioRoute(int route) {
491 if (mPhone != null) {
492 mPhone.setAudioRoute(route);
493 }
494 }
495
496 /**
Hall Liua98f58b52017-11-07 17:59:28 -0800497 * Request audio routing to a specific bluetooth device. Calling this method may result in
498 * the device routing audio to a different bluetooth device than the one specified if the
499 * bluetooth stack is unable to route audio to the requested device.
500 * A list of available devices can be obtained via
501 * {@link CallAudioState#getSupportedBluetoothDevices()}
502 *
Hall Liu15392832018-04-02 13:52:57 -0700503 * @param bluetoothDevice The bluetooth device to connect to.
Hall Liua98f58b52017-11-07 17:59:28 -0800504 */
Hall Liu15392832018-04-02 13:52:57 -0700505 public final void requestBluetoothAudio(@NonNull BluetoothDevice bluetoothDevice) {
Hall Liua98f58b52017-11-07 17:59:28 -0800506 if (mPhone != null) {
Hall Liu15392832018-04-02 13:52:57 -0700507 mPhone.requestBluetoothAudio(bluetoothDevice.getAddress());
Hall Liua98f58b52017-11-07 17:59:28 -0800508 }
509 }
510
511 /**
Ihab Awade63fadb2014-07-09 21:52:04 -0700512 * Invoked when the {@code Phone} has been created. This is a signal to the in-call experience
513 * to start displaying in-call information to the user. Each instance of {@code InCallService}
Santos Cordon2f42b112014-07-19 13:19:37 -0700514 * will have only one {@code Phone}, and this method will be called exactly once in the lifetime
515 * of the {@code InCallService}.
Evan Charlton924748f2014-04-03 08:36:38 -0700516 *
Ihab Awade63fadb2014-07-09 21:52:04 -0700517 * @param phone The {@code Phone} object associated with this {@code InCallService}.
Santos Cordona2492812015-04-15 11:05:16 -0700518 * @hide
Santos Cordon29886d82015-04-16 15:34:07 -0700519 * @deprecated Use direct methods on InCallService instead of {@link Phone}.
Evan Charlton924748f2014-04-03 08:36:38 -0700520 */
Santos Cordona2492812015-04-15 11:05:16 -0700521 @SystemApi
Santos Cordon29886d82015-04-16 15:34:07 -0700522 @Deprecated
Santos Cordon2f42b112014-07-19 13:19:37 -0700523 public void onPhoneCreated(Phone phone) {
524 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800525
526 /**
Ihab Awade63fadb2014-07-09 21:52:04 -0700527 * Invoked when a {@code Phone} has been destroyed. This is a signal to the in-call experience
528 * to stop displaying in-call information to the user. This method will be called exactly once
529 * in the lifetime of the {@code InCallService}, and it will always be called after a previous
530 * call to {@link #onPhoneCreated(Phone)}.
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800531 *
Ihab Awade63fadb2014-07-09 21:52:04 -0700532 * @param phone The {@code Phone} object associated with this {@code InCallService}.
Santos Cordona2492812015-04-15 11:05:16 -0700533 * @hide
Santos Cordon29886d82015-04-16 15:34:07 -0700534 * @deprecated Use direct methods on InCallService instead of {@link Phone}.
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800535 */
Santos Cordona2492812015-04-15 11:05:16 -0700536 @SystemApi
Santos Cordon29886d82015-04-16 15:34:07 -0700537 @Deprecated
Santos Cordon2f42b112014-07-19 13:19:37 -0700538 public void onPhoneDestroyed(Phone phone) {
539 }
Andrew Lee50aca232014-07-22 16:41:54 -0700540
541 /**
Santos Cordona2492812015-04-15 11:05:16 -0700542 * Called when the audio state changes.
543 *
544 * @param audioState The new {@link AudioState}.
Yorke Lee4af59352015-05-13 14:14:54 -0700545 * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState) instead}.
546 * @hide
Santos Cordona2492812015-04-15 11:05:16 -0700547 */
Yorke Lee4af59352015-05-13 14:14:54 -0700548 @Deprecated
Santos Cordona2492812015-04-15 11:05:16 -0700549 public void onAudioStateChanged(AudioState audioState) {
550 }
551
552 /**
Yorke Lee4af59352015-05-13 14:14:54 -0700553 * Called when the audio state changes.
554 *
555 * @param audioState The new {@link CallAudioState}.
556 */
557 public void onCallAudioStateChanged(CallAudioState audioState) {
558 }
559
560 /**
Santos Cordona2492812015-04-15 11:05:16 -0700561 * Called to bring the in-call screen to the foreground. The in-call experience should
562 * respond immediately by coming to the foreground to inform the user of the state of
563 * ongoing {@code Call}s.
564 *
565 * @param showDialpad If true, put up the dialpad when the screen is shown.
566 */
567 public void onBringToForeground(boolean showDialpad) {
568 }
569
570 /**
571 * Called when a {@code Call} has been added to this in-call session. The in-call user
572 * experience should add necessary state listeners to the specified {@code Call} and
573 * immediately start to show the user information about the existence
574 * and nature of this {@code Call}. Subsequent invocations of {@link #getCalls()} will
575 * include this {@code Call}.
576 *
577 * @param call A newly added {@code Call}.
578 */
579 public void onCallAdded(Call call) {
580 }
581
582 /**
583 * Called when a {@code Call} has been removed from this in-call session. The in-call user
584 * experience should remove any state listeners from the specified {@code Call} and
585 * immediately stop displaying any information about this {@code Call}.
586 * Subsequent invocations of {@link #getCalls()} will no longer include this {@code Call}.
587 *
588 * @param call A newly removed {@code Call}.
589 */
590 public void onCallRemoved(Call call) {
591 }
592
593 /**
594 * Called when the ability to add more calls changes. If the phone cannot
595 * support more calls then {@code canAddCall} is set to {@code false}. If it can, then it
596 * is set to {@code true}. This can be used to control the visibility of UI to add more calls.
597 *
598 * @param canAddCall Indicates whether an additional call can be added.
599 */
600 public void onCanAddCallChanged(boolean canAddCall) {
601 }
602
603 /**
Sailesh Nepal9c2618b2016-01-23 16:28:22 -0800604 * Called to silence the ringer if a ringing call exists.
605 */
606 public void onSilenceRinger() {
607 }
608
609 /**
Tyler Gunn06f3fa62016-08-25 09:26:15 -0700610 * Unused; to handle connection events issued by a {@link ConnectionService}, implement the
611 * {@link android.telecom.Call.Callback#onConnectionEvent(Call, String, Bundle)} callback.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700612 * <p>
613 * See {@link Connection#sendConnectionEvent(String, Bundle)}.
614 *
615 * @param call The call the event is associated with.
616 * @param event The event.
617 * @param extras Any associated extras.
618 */
619 public void onConnectionEvent(Call call, String event, Bundle extras) {
620 }
621
622 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700623 * Used to issue commands to the {@link Connection.VideoProvider} associated with a
624 * {@link Call}.
Andrew Lee50aca232014-07-22 16:41:54 -0700625 */
626 public static abstract class VideoCall {
627
Andrew Lee011728f2015-04-23 15:47:06 -0700628 /** @hide */
629 public abstract void destroy();
630
Andrew Lee50aca232014-07-22 16:41:54 -0700631 /**
Andrew Lee7c9ee2b2015-04-16 15:26:08 -0700632 * Registers a callback to receive commands and state changes for video calls.
Andrew Lee50aca232014-07-22 16:41:54 -0700633 *
Andrew Lee7c9ee2b2015-04-16 15:26:08 -0700634 * @param callback The video call callback.
Andrew Lee50aca232014-07-22 16:41:54 -0700635 */
Andrew Leeda80c872015-04-15 14:09:50 -0700636 public abstract void registerCallback(VideoCall.Callback callback);
637
638 /**
Andrew Lee011728f2015-04-23 15:47:06 -0700639 * Registers a callback to receive commands and state changes for video calls.
640 *
641 * @param callback The video call callback.
642 * @param handler A handler which commands and status changes will be delivered to.
643 */
644 public abstract void registerCallback(VideoCall.Callback callback, Handler handler);
645
646 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700647 * Clears the video call callback set via {@link #registerCallback}.
Tyler Gunn295f5d72015-06-04 11:08:54 -0700648 *
649 * @param callback The video call callback to clear.
Tyler Gunn75958422015-04-15 14:23:42 -0700650 */
Andrew Lee011728f2015-04-23 15:47:06 -0700651 public abstract void unregisterCallback(VideoCall.Callback callback);
Tyler Gunn75958422015-04-15 14:23:42 -0700652
653 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700654 * Sets the camera to be used for the outgoing video.
655 * <p>
656 * Handled by {@link Connection.VideoProvider#onSetCamera(String)}.
Andrew Lee50aca232014-07-22 16:41:54 -0700657 *
Tyler Gunnb702ef82015-05-29 11:51:53 -0700658 * @param cameraId The id of the camera (use ids as reported by
659 * {@link CameraManager#getCameraIdList()}).
Andrew Lee50aca232014-07-22 16:41:54 -0700660 */
661 public abstract void setCamera(String cameraId);
662
663 /**
664 * Sets the surface to be used for displaying a preview of what the user's camera is
665 * currently capturing. When video transmission is enabled, this is the video signal which
666 * is sent to the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -0700667 * <p>
668 * Handled by {@link Connection.VideoProvider#onSetPreviewSurface(Surface)}.
Andrew Lee50aca232014-07-22 16:41:54 -0700669 *
Tyler Gunnb702ef82015-05-29 11:51:53 -0700670 * @param surface The {@link Surface}.
Andrew Lee50aca232014-07-22 16:41:54 -0700671 */
672 public abstract void setPreviewSurface(Surface surface);
673
674 /**
675 * Sets the surface to be used for displaying the video received from the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -0700676 * <p>
677 * Handled by {@link Connection.VideoProvider#onSetDisplaySurface(Surface)}.
Andrew Lee50aca232014-07-22 16:41:54 -0700678 *
Tyler Gunnb702ef82015-05-29 11:51:53 -0700679 * @param surface The {@link Surface}.
Andrew Lee50aca232014-07-22 16:41:54 -0700680 */
681 public abstract void setDisplaySurface(Surface surface);
682
683 /**
684 * Sets the device orientation, in degrees. Assumes that a standard portrait orientation of
685 * the device is 0 degrees.
Tyler Gunnb702ef82015-05-29 11:51:53 -0700686 * <p>
687 * Handled by {@link Connection.VideoProvider#onSetDeviceOrientation(int)}.
Andrew Lee50aca232014-07-22 16:41:54 -0700688 *
689 * @param rotation The device orientation, in degrees.
690 */
691 public abstract void setDeviceOrientation(int rotation);
692
693 /**
694 * Sets camera zoom ratio.
Tyler Gunnb702ef82015-05-29 11:51:53 -0700695 * <p>
696 * Handled by {@link Connection.VideoProvider#onSetZoom(float)}.
Andrew Lee50aca232014-07-22 16:41:54 -0700697 *
698 * @param value The camera zoom ratio.
699 */
700 public abstract void setZoom(float value);
701
702 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700703 * Issues a request to modify the properties of the current video session.
704 * <p>
705 * Example scenarios include: requesting an audio-only call to be upgraded to a
706 * bi-directional video call, turning on or off the user's camera, sending a pause signal
707 * when the {@link InCallService} is no longer the foreground application.
708 * <p>
709 * Handled by
710 * {@link Connection.VideoProvider#onSendSessionModifyRequest(VideoProfile, VideoProfile)}.
Andrew Lee50aca232014-07-22 16:41:54 -0700711 *
712 * @param requestProfile The requested call video properties.
713 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700714 public abstract void sendSessionModifyRequest(VideoProfile requestProfile);
Andrew Lee50aca232014-07-22 16:41:54 -0700715
716 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700717 * Provides a response to a request to change the current call video session
718 * properties. This should be called in response to a request the {@link InCallService} has
719 * received via {@link VideoCall.Callback#onSessionModifyRequestReceived}.
720 * <p>
721 * Handled by
722 * {@link Connection.VideoProvider#onSendSessionModifyResponse(VideoProfile)}.
Andrew Lee50aca232014-07-22 16:41:54 -0700723 *
724 * @param responseProfile The response call video properties.
725 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700726 public abstract void sendSessionModifyResponse(VideoProfile responseProfile);
Andrew Lee50aca232014-07-22 16:41:54 -0700727
728 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700729 * Issues a request to the {@link Connection.VideoProvider} to retrieve the capabilities
730 * of the current camera. The current camera is selected using
731 * {@link VideoCall#setCamera(String)}.
732 * <p>
733 * Camera capabilities are reported to the caller via
734 * {@link VideoCall.Callback#onCameraCapabilitiesChanged(VideoProfile.CameraCapabilities)}.
735 * <p>
736 * Handled by {@link Connection.VideoProvider#onRequestCameraCapabilities()}.
Andrew Lee50aca232014-07-22 16:41:54 -0700737 */
738 public abstract void requestCameraCapabilities();
739
740 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700741 * Issues a request to the {@link Connection.VideoProvider} to retrieve the cumulative data
742 * usage for the video component of the current call (in bytes). Data usage is reported
743 * to the caller via {@link VideoCall.Callback#onCallDataUsageChanged}.
744 * <p>
745 * Handled by {@link Connection.VideoProvider#onRequestConnectionDataUsage()}.
Andrew Lee50aca232014-07-22 16:41:54 -0700746 */
747 public abstract void requestCallDataUsage();
748
749 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700750 * Provides the {@link Connection.VideoProvider} with the {@link Uri} of an image to be
751 * displayed to the peer device when the video signal is paused.
752 * <p>
753 * Handled by {@link Connection.VideoProvider#onSetPauseImage(Uri)}.
Andrew Lee50aca232014-07-22 16:41:54 -0700754 *
755 * @param uri URI of image to display.
756 */
Yorke Lee32f24732015-05-12 16:18:03 -0700757 public abstract void setPauseImage(Uri uri);
Andrew Lee50aca232014-07-22 16:41:54 -0700758
759 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700760 * The {@link InCallService} extends this class to provide a means of receiving callbacks
Tyler Gunn295f5d72015-06-04 11:08:54 -0700761 * from the {@link Connection.VideoProvider}.
762 * <p>
Tyler Gunnb702ef82015-05-29 11:51:53 -0700763 * When the {@link InCallService} receives the
764 * {@link Call.Callback#onVideoCallChanged(Call, VideoCall)} callback, it should create an
765 * instance its {@link VideoCall.Callback} implementation and set it on the
766 * {@link VideoCall} using {@link VideoCall#registerCallback(Callback)}.
Andrew Lee50aca232014-07-22 16:41:54 -0700767 */
Andrew Leeda80c872015-04-15 14:09:50 -0700768 public static abstract class Callback {
Andrew Lee50aca232014-07-22 16:41:54 -0700769 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700770 * Called when the {@link Connection.VideoProvider} receives a session modification
Tyler Gunn295f5d72015-06-04 11:08:54 -0700771 * request from the peer device.
Tyler Gunnb702ef82015-05-29 11:51:53 -0700772 * <p>
773 * The {@link InCallService} may potentially prompt the user to confirm whether they
774 * wish to accept the request, or decide to automatically accept the request. In either
775 * case the {@link InCallService} should call
776 * {@link VideoCall#sendSessionModifyResponse(VideoProfile)} to indicate the video
777 * profile agreed upon.
778 * <p>
779 * Callback originates from
780 * {@link Connection.VideoProvider#receiveSessionModifyRequest(VideoProfile)}.
Andrew Lee50aca232014-07-22 16:41:54 -0700781 *
Tyler Gunnb702ef82015-05-29 11:51:53 -0700782 * @param videoProfile The requested video profile.
Andrew Lee50aca232014-07-22 16:41:54 -0700783 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700784 public abstract void onSessionModifyRequestReceived(VideoProfile videoProfile);
Andrew Lee50aca232014-07-22 16:41:54 -0700785
786 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700787 * Called when the {@link Connection.VideoProvider} receives a response to a session
788 * modification request previously sent to the peer device.
789 * <p>
790 * The new video state should not be considered active by the {@link InCallService}
791 * until the {@link Call} video state changes (the
792 * {@link Call.Callback#onDetailsChanged(Call, Call.Details)} callback is triggered
793 * when the video state changes).
794 * <p>
795 * Callback originates from
796 * {@link Connection.VideoProvider#receiveSessionModifyResponse(int, VideoProfile,
797 * VideoProfile)}.
Andrew Lee50aca232014-07-22 16:41:54 -0700798 *
799 * @param status Status of the session modify request. Valid values are
Tyler Gunnb702ef82015-05-29 11:51:53 -0700800 * {@link Connection.VideoProvider#SESSION_MODIFY_REQUEST_SUCCESS},
801 * {@link Connection.VideoProvider#SESSION_MODIFY_REQUEST_FAIL},
802 * {@link Connection.VideoProvider#SESSION_MODIFY_REQUEST_INVALID},
803 * {@link Connection.VideoProvider#SESSION_MODIFY_REQUEST_TIMED_OUT},
804 * {@link Connection.VideoProvider#SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE}.
805 * @param requestedProfile The original request which was sent to the peer device.
806 * @param responseProfile The actual profile changes made by the peer device.
Andrew Lee50aca232014-07-22 16:41:54 -0700807 */
808 public abstract void onSessionModifyResponseReceived(int status,
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700809 VideoProfile requestedProfile, VideoProfile responseProfile);
Andrew Lee50aca232014-07-22 16:41:54 -0700810
811 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700812 * Handles events related to the current video session which the {@link InCallService}
813 * may wish to handle. These are separate from requested changes to the session due to
814 * the underlying protocol or connection.
815 * <p>
816 * Callback originates from
817 * {@link Connection.VideoProvider#handleCallSessionEvent(int)}.
Andrew Lee50aca232014-07-22 16:41:54 -0700818 *
Tyler Gunnb702ef82015-05-29 11:51:53 -0700819 * @param event The event. Valid values are:
820 * {@link Connection.VideoProvider#SESSION_EVENT_RX_PAUSE},
821 * {@link Connection.VideoProvider#SESSION_EVENT_RX_RESUME},
822 * {@link Connection.VideoProvider#SESSION_EVENT_TX_START},
823 * {@link Connection.VideoProvider#SESSION_EVENT_TX_STOP},
824 * {@link Connection.VideoProvider#SESSION_EVENT_CAMERA_FAILURE},
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -0800825 * {@link Connection.VideoProvider#SESSION_EVENT_CAMERA_READY},
826 * {@link Connection.VideoProvider#SESSION_EVENT_CAMERA_PERMISSION_ERROR}.
Andrew Lee50aca232014-07-22 16:41:54 -0700827 */
828 public abstract void onCallSessionEvent(int event);
829
830 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700831 * Handles a change to the video dimensions from the peer device. This could happen if,
832 * for example, the peer changes orientation of their device, or switches cameras.
833 * <p>
834 * Callback originates from
835 * {@link Connection.VideoProvider#changePeerDimensions(int, int)}.
Andrew Lee50aca232014-07-22 16:41:54 -0700836 *
837 * @param width The updated peer video width.
838 * @param height The updated peer video height.
839 */
840 public abstract void onPeerDimensionsChanged(int width, int height);
841
842 /**
Rekha Kumar07366812015-03-24 16:42:31 -0700843 * Handles a change to the video quality.
Tyler Gunnb702ef82015-05-29 11:51:53 -0700844 * <p>
845 * Callback originates from {@link Connection.VideoProvider#changeVideoQuality(int)}.
Rekha Kumar07366812015-03-24 16:42:31 -0700846 *
Tyler Gunnb702ef82015-05-29 11:51:53 -0700847 * @param videoQuality The updated peer video quality. Valid values:
848 * {@link VideoProfile#QUALITY_HIGH},
849 * {@link VideoProfile#QUALITY_MEDIUM},
850 * {@link VideoProfile#QUALITY_LOW},
851 * {@link VideoProfile#QUALITY_DEFAULT}.
Rekha Kumar07366812015-03-24 16:42:31 -0700852 */
853 public abstract void onVideoQualityChanged(int videoQuality);
854
855 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700856 * Handles an update to the total data used for the current video session.
857 * <p>
858 * Used by the {@link Connection.VideoProvider} in response to
859 * {@link VideoCall#requestCallDataUsage()}. May also be called periodically by the
860 * {@link Connection.VideoProvider}.
861 * <p>
862 * Callback originates from {@link Connection.VideoProvider#setCallDataUsage(long)}.
Andrew Lee50aca232014-07-22 16:41:54 -0700863 *
Tyler Gunnb702ef82015-05-29 11:51:53 -0700864 * @param dataUsage The updated data usage (in bytes).
Andrew Lee50aca232014-07-22 16:41:54 -0700865 */
Rekha Kumar07366812015-03-24 16:42:31 -0700866 public abstract void onCallDataUsageChanged(long dataUsage);
Andrew Lee50aca232014-07-22 16:41:54 -0700867
868 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700869 * Handles a change in the capabilities of the currently selected camera.
870 * <p>
871 * Used by the {@link Connection.VideoProvider} in response to
872 * {@link VideoCall#requestCameraCapabilities()}. The {@link Connection.VideoProvider}
873 * may also report the camera capabilities after a call to
874 * {@link VideoCall#setCamera(String)}.
875 * <p>
876 * Callback originates from
877 * {@link Connection.VideoProvider#changeCameraCapabilities(
878 * VideoProfile.CameraCapabilities)}.
Andrew Lee50aca232014-07-22 16:41:54 -0700879 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700880 * @param cameraCapabilities The changed camera capabilities.
Andrew Lee50aca232014-07-22 16:41:54 -0700881 */
Yorke Lee400470f2015-05-12 13:31:25 -0700882 public abstract void onCameraCapabilitiesChanged(
883 VideoProfile.CameraCapabilities cameraCapabilities);
Andrew Lee50aca232014-07-22 16:41:54 -0700884 }
885 }
Sailesh Nepalab5d2822014-03-08 18:01:06 -0800886}