Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 1 | /* |
| 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 Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 17 | package android.telecom; |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 18 | |
Hall Liu | a98f58b | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 19 | import android.annotation.NonNull; |
Tyler Gunn | 2ac4010 | 2014-08-18 16:23:10 -0700 | [diff] [blame] | 20 | import android.annotation.SdkConstant; |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 21 | import android.annotation.SystemApi; |
Santos Cordon | 2f42b11 | 2014-07-19 13:19:37 -0700 | [diff] [blame] | 22 | import android.app.Service; |
Hall Liu | a98f58b | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 23 | import android.bluetooth.BluetoothDevice; |
Santos Cordon | 2f42b11 | 2014-07-19 13:19:37 -0700 | [diff] [blame] | 24 | import android.content.Intent; |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 25 | import android.hardware.camera2.CameraManager; |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 26 | import android.net.Uri; |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 27 | import android.os.Bundle; |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 28 | import android.os.Handler; |
| 29 | import android.os.IBinder; |
| 30 | import android.os.Looper; |
| 31 | import android.os.Message; |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 32 | import android.view.Surface; |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 33 | |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 34 | import com.android.internal.os.SomeArgs; |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 35 | import com.android.internal.telecom.IInCallAdapter; |
| 36 | import com.android.internal.telecom.IInCallService; |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 37 | |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 38 | import java.lang.String; |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 39 | import java.util.Collections; |
| 40 | import java.util.List; |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 41 | |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 42 | /** |
Tyler Gunn | 94f8f11 | 2018-12-17 09:56:11 -0800 | [diff] [blame] | 43 | * This service is implemented by an app that wishes to provide functionality for managing |
| 44 | * phone calls. |
| 45 | * <p> |
| 46 | * There are three types of apps which Telecom can bind to when there exists a live (active or |
| 47 | * incoming) call: |
| 48 | * <ol> |
| 49 | * <li>Default Dialer/Phone app - the default dialer/phone app is one which provides the |
| 50 | * in-call user interface while the device is in a call. A device is bundled with a system |
| 51 | * provided default dialer/phone app. The user may choose a single app to take over this role |
| 52 | * from the system app.</li> |
| 53 | * <li>Default Car-mode Dialer/Phone app - the default car-mode dialer/phone app is one which |
| 54 | * provides the in-call user interface while the device is in a call and the device is in car |
| 55 | * mode. The user may choose a single app to fill this role.</li> |
| 56 | * <li>Call Companion app - a call companion app is one which provides no user interface itself, |
| 57 | * but exposes call information to another display surface, such as a wearable device. The |
| 58 | * user may choose multiple apps to fill this role.</li> |
| 59 | * </ol> |
| 60 | * <p> |
| 61 | * Apps which wish to fulfill one of the above roles use the {@code android.app.role.RoleManager} |
| 62 | * to request that they fill the desired role. |
| 63 | * |
| 64 | * <h2>Becoming the Default Phone App</h2> |
| 65 | * An app filling the role of the default phone app provides a user interface while the device is in |
| 66 | * a call, and the device is not in car mode. |
Santos Cordon | f2600eb | 2015-06-22 15:02:20 -0700 | [diff] [blame] | 67 | * <p> |
| 68 | * Below is an example manifest registration for an {@code InCallService}. The meta-data |
Tyler Gunn | dc6e6c4 | 2018-07-03 16:08:17 -0700 | [diff] [blame] | 69 | * {@link TelecomManager#METADATA_IN_CALL_SERVICE_UI} indicates that this particular |
Santos Cordon | f2600eb | 2015-06-22 15:02:20 -0700 | [diff] [blame] | 70 | * {@code InCallService} implementation intends to replace the built-in in-call UI. |
Tyler Gunn | dc6e6c4 | 2018-07-03 16:08:17 -0700 | [diff] [blame] | 71 | * The meta-data {@link TelecomManager#METADATA_IN_CALL_SERVICE_RINGING} indicates that this |
| 72 | * {@link InCallService} will play the ringtone for incoming calls. See |
| 73 | * <a href="#incomingCallNotification">below</a> for more information on showing the incoming call |
| 74 | * UI and playing the ringtone in your app. |
Santos Cordon | f2600eb | 2015-06-22 15:02:20 -0700 | [diff] [blame] | 75 | * <pre> |
| 76 | * {@code |
Neil Fuller | 71fbb81 | 2015-11-30 09:51:33 +0000 | [diff] [blame] | 77 | * <service android:name="your.package.YourInCallServiceImplementation" |
Sailesh Nepal | 78f3ba6 | 2015-12-28 16:20:56 -0800 | [diff] [blame] | 78 | * android:permission="android.permission.BIND_INCALL_SERVICE"> |
Neil Fuller | 71fbb81 | 2015-11-30 09:51:33 +0000 | [diff] [blame] | 79 | * <meta-data android:name="android.telecom.IN_CALL_SERVICE_UI" android:value="true" /> |
Tyler Gunn | dc6e6c4 | 2018-07-03 16:08:17 -0700 | [diff] [blame] | 80 | * <meta-data android:name="android.telecom.IN_CALL_SERVICE_RINGING" |
| 81 | * android:value="true" /> |
Neil Fuller | 71fbb81 | 2015-11-30 09:51:33 +0000 | [diff] [blame] | 82 | * <intent-filter> |
| 83 | * <action android:name="android.telecom.InCallService"/> |
| 84 | * </intent-filter> |
| 85 | * </service> |
Santos Cordon | f2600eb | 2015-06-22 15:02:20 -0700 | [diff] [blame] | 86 | * } |
| 87 | * </pre> |
Tyler Gunn | fe39efa | 2018-02-02 13:18:02 -0800 | [diff] [blame] | 88 | * <p> |
| 89 | * In addition to implementing the {@link InCallService} API, you must also declare an activity in |
| 90 | * your manifest which handles the {@link Intent#ACTION_DIAL} intent. The example below illustrates |
| 91 | * how this is done: |
| 92 | * <pre> |
| 93 | * {@code |
| 94 | * <activity android:name="your.package.YourDialerActivity" |
| 95 | * android:label="@string/yourDialerActivityLabel"> |
| 96 | * <intent-filter> |
| 97 | * <action android:name="android.intent.action.DIAL" /> |
| 98 | * <category android:name="android.intent.category.DEFAULT" /> |
| 99 | * </intent-filter> |
| 100 | * </activity> |
| 101 | * } |
| 102 | * </pre> |
| 103 | * <p> |
Tyler Gunn | 94f8f11 | 2018-12-17 09:56:11 -0800 | [diff] [blame] | 104 | * When a user installs your application and runs it for the first time, you should use the |
| 105 | * {@code android.app.role.RoleManager} to prompt the user to see if they would like your app to |
| 106 | * be the new default phone app. |
| 107 | * <p id="requestRole"> |
| 108 | * The code below shows how your app can request to become the default phone/dialer app: |
| 109 | * <pre> |
| 110 | * {@code |
| 111 | * private static final int REQUEST_ID = 1; |
| 112 | * |
| 113 | * public void requestRole() { |
| 114 | * RoleManager roleManager = (RoleManager) getSystemService(ROLE_SERVICE); |
| 115 | * Intent intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_DIALER); |
| 116 | * startActivityForResult(intent, REQUEST_ID); |
| 117 | * } |
| 118 | * |
| 119 | * @Override |
| 120 | * public void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 121 | * if (requestCode == REQUEST_ID) { |
| 122 | * if (resultCode == android.app.Activity.RESULT_OK) { |
| 123 | * // Your app is now the default dialer app |
| 124 | * } else { |
| 125 | * // Your app is not the default dialer app |
| 126 | * } |
| 127 | * } |
| 128 | * } |
| 129 | * </pre> |
Tyler Gunn | dc6e6c4 | 2018-07-03 16:08:17 -0700 | [diff] [blame] | 130 | * <p id="incomingCallNotification"> |
Tyler Gunn | 94f8f11 | 2018-12-17 09:56:11 -0800 | [diff] [blame] | 131 | * <h3>Showing the Incoming Call Notification</h3> |
Tyler Gunn | dc6e6c4 | 2018-07-03 16:08:17 -0700 | [diff] [blame] | 132 | * When your app receives a new incoming call via {@link InCallService#onCallAdded(Call)}, it is |
| 133 | * responsible for displaying an incoming call UI for the incoming call. It should do this using |
| 134 | * {@link android.app.NotificationManager} APIs to post a new incoming call notification. |
| 135 | * <p> |
| 136 | * Where your app declares the meta-data {@link TelecomManager#METADATA_IN_CALL_SERVICE_RINGING}, it |
| 137 | * is responsible for playing the ringtone for incoming calls. Your app should create a |
| 138 | * {@link android.app.NotificationChannel} which specifies the desired ringtone. For example: |
| 139 | * <pre><code> |
| 140 | * NotificationChannel channel = new NotificationChannel(YOUR_CHANNEL_ID, "Incoming Calls", |
| 141 | * NotificationManager.IMPORTANCE_MAX); |
| 142 | * // other channel setup stuff goes here. |
| 143 | * |
| 144 | * // We'll use the default system ringtone for our incoming call notification channel. You can |
| 145 | * // use your own audio resource here. |
| 146 | * Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE); |
| 147 | * channel.setSound(ringtoneUri, new AudioAttributes.Builder() |
| 148 | * // Setting the AudioAttributes is important as it identifies the purpose of your |
| 149 | * // notification sound. |
| 150 | * .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE) |
| 151 | * .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) |
| 152 | * .build()); |
| 153 | * |
| 154 | * NotificationManager mgr = getSystemService(NotificationManager.class); |
| 155 | * mgr.createNotificationChannel(channel); |
| 156 | * </code></pre> |
| 157 | * <p> |
| 158 | * When your app receives a new incoming call, it creates a {@link android.app.Notification} for the |
| 159 | * incoming call and associates it with your incoming call notification channel. You can specify a |
| 160 | * {@link android.app.PendingIntent} on the notification which will launch your full screen |
| 161 | * incoming call UI. The notification manager framework will display your notification as a |
| 162 | * heads-up notification if the user is actively using the phone. When the user is not using the |
| 163 | * phone, your full-screen incoming call UI is used instead. |
| 164 | * For example: |
Tyler Gunn | 94f8f11 | 2018-12-17 09:56:11 -0800 | [diff] [blame] | 165 | * <pre><code>{@code |
Tyler Gunn | dc6e6c4 | 2018-07-03 16:08:17 -0700 | [diff] [blame] | 166 | * // Create an intent which triggers your fullscreen incoming call user interface. |
| 167 | * Intent intent = new Intent(Intent.ACTION_MAIN, null); |
| 168 | * intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_ACTIVITY_NEW_TASK); |
| 169 | * intent.setClass(context, YourIncomingCallActivity.class); |
| 170 | * PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, 0); |
| 171 | * |
| 172 | * // Build the notification as an ongoing high priority item; this ensures it will show as |
| 173 | * // a heads up notification which slides down over top of the current content. |
| 174 | * final Notification.Builder builder = new Notification.Builder(context); |
| 175 | * builder.setOngoing(true); |
| 176 | * builder.setPriority(Notification.PRIORITY_HIGH); |
| 177 | * |
| 178 | * // Set notification content intent to take user to the fullscreen UI if user taps on the |
| 179 | * // notification body. |
| 180 | * builder.setContentIntent(pendingIntent); |
| 181 | * // Set full screen intent to trigger display of the fullscreen UI when the notification |
| 182 | * // manager deems it appropriate. |
| 183 | * builder.setFullScreenIntent(pendingIntent, true); |
| 184 | * |
| 185 | * // Setup notification content. |
| 186 | * builder.setSmallIcon( yourIconResourceId ); |
| 187 | * builder.setContentTitle("Your notification title"); |
| 188 | * builder.setContentText("Your notification content."); |
| 189 | * |
| 190 | * // Use builder.addAction(..) to add buttons to answer or reject the call. |
| 191 | * |
| 192 | * NotificationManager notificationManager = mContext.getSystemService( |
| 193 | * NotificationManager.class); |
| 194 | * notificationManager.notify(YOUR_CHANNEL_ID, YOUR_TAG, YOUR_ID, builder.build()); |
Tyler Gunn | 94f8f11 | 2018-12-17 09:56:11 -0800 | [diff] [blame] | 195 | * }</pre> |
| 196 | * <p> |
| 197 | * <h2>Becoming the Default Car-mode Phone App</h2> |
| 198 | * An app filling the role of the default car-mode dialer/phone app provides a user interface while |
| 199 | * the device is in a call, and in car mode. See |
| 200 | * {@link android.app.UiModeManager#ACTION_ENTER_CAR_MODE} for more information about car mode. |
| 201 | * When the device is in car mode, Telecom binds to the default car-mode dialer/phone app instead |
| 202 | * of the usual dialer/phone app. |
| 203 | * <p> |
| 204 | * Similar to the requirements for becoming the default dialer/phone app, your app must declare a |
| 205 | * manifest entry for its {@link InCallService} implementation. Your manifest entry should ensure |
| 206 | * the following conditions are met: |
| 207 | * <ul> |
| 208 | * <li>Do NOT declare the {@link TelecomManager#METADATA_IN_CALL_SERVICE_UI} metadata.</li> |
| 209 | * <li>Set the {@link TelecomManager#METADATA_IN_CALL_SERVICE_CAR_MODE_UI} metadata to |
| 210 | * {@code true}<li> |
| 211 | * <li>Your app must request the permission |
| 212 | * {@link android.Manifest.permission.CALL_COMPANION_APP}.</li> |
| 213 | * </ul> |
| 214 | * <p> |
| 215 | * Your app should request to fill the role {@code android.app.role.CAR_MODE_DIALER_APP} in order to |
| 216 | * become the default (see <a href="#requestRole">above</a> for how to request your app fills this |
| 217 | * role). |
| 218 | * |
| 219 | * <h2>Becoming a Call Companion App</h2> |
| 220 | * An app which fills the companion app role does not directly provide a user interface while the |
| 221 | * device is in a call. Instead, it is typically used to relay information about calls to another |
| 222 | * display surface, such as a wearable device. |
| 223 | * <p> |
| 224 | * Similar to the requirements for becoming the default dialer/phone app, your app must declare a |
| 225 | * manifest entry for its {@link InCallService} implementation. Your manifest entry should |
| 226 | * ensure the following conditions are met: |
| 227 | * <ul> |
| 228 | * <li>Do NOT declare the {@link TelecomManager#METADATA_IN_CALL_SERVICE_UI} metadata.</li> |
| 229 | * <li>Do NOT declare the {@link TelecomManager#METADATA_IN_CALL_SERVICE_CAR_MODE_UI} |
| 230 | * metadata.</li> |
| 231 | * <li>Your app must request the permission |
| 232 | * {@link android.Manifest.permission.CALL_COMPANION_APP}.</li> |
| 233 | * </ul> |
| 234 | * <p> |
| 235 | * Your app should request to fill the role {@code android.app.role.CALL_COMPANION_APP} in order to |
| 236 | * become a call companion app (see <a href="#requestRole">above</a> for how to request your app |
| 237 | * fills this role). |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 238 | */ |
Santos Cordon | 2f42b11 | 2014-07-19 13:19:37 -0700 | [diff] [blame] | 239 | public abstract class InCallService extends Service { |
Tyler Gunn | 2ac4010 | 2014-08-18 16:23:10 -0700 | [diff] [blame] | 240 | |
| 241 | /** |
| 242 | * The {@link Intent} that must be declared as handled by the service. |
| 243 | */ |
| 244 | @SdkConstant(SdkConstant.SdkConstantType.SERVICE_ACTION) |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 245 | public static final String SERVICE_INTERFACE = "android.telecom.InCallService"; |
Tyler Gunn | 2ac4010 | 2014-08-18 16:23:10 -0700 | [diff] [blame] | 246 | |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 247 | private static final int MSG_SET_IN_CALL_ADAPTER = 1; |
| 248 | private static final int MSG_ADD_CALL = 2; |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 249 | private static final int MSG_UPDATE_CALL = 3; |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 250 | private static final int MSG_SET_POST_DIAL_WAIT = 4; |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 251 | private static final int MSG_ON_CALL_AUDIO_STATE_CHANGED = 5; |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 252 | private static final int MSG_BRING_TO_FOREGROUND = 6; |
Santos Cordon | 6c912b7 | 2014-11-07 16:05:09 -0800 | [diff] [blame] | 253 | private static final int MSG_ON_CAN_ADD_CALL_CHANGED = 7; |
Sailesh Nepal | 9c2618b | 2016-01-23 16:28:22 -0800 | [diff] [blame] | 254 | private static final int MSG_SILENCE_RINGER = 8; |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 255 | private static final int MSG_ON_CONNECTION_EVENT = 9; |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 256 | private static final int MSG_ON_RTT_UPGRADE_REQUEST = 10; |
Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 257 | private static final int MSG_ON_RTT_INITIATION_FAILURE = 11; |
Sanket Padawe | 85291f6 | 2017-12-01 13:59:27 -0800 | [diff] [blame] | 258 | private static final int MSG_ON_HANDOVER_FAILED = 12; |
Tyler Gunn | 858bfaf | 2018-01-22 15:17:54 -0800 | [diff] [blame] | 259 | private static final int MSG_ON_HANDOVER_COMPLETE = 13; |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 260 | |
| 261 | /** Default Handler used to consolidate binder method calls onto a single thread. */ |
| 262 | private final Handler mHandler = new Handler(Looper.getMainLooper()) { |
| 263 | @Override |
| 264 | public void handleMessage(Message msg) { |
Jay Shrauner | 5e6162d | 2014-09-22 20:47:45 -0700 | [diff] [blame] | 265 | if (mPhone == null && msg.what != MSG_SET_IN_CALL_ADAPTER) { |
| 266 | return; |
| 267 | } |
| 268 | |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 269 | switch (msg.what) { |
| 270 | case MSG_SET_IN_CALL_ADAPTER: |
Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 271 | String callingPackage = getApplicationContext().getOpPackageName(); |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 272 | mPhone = new Phone(new InCallAdapter((IInCallAdapter) msg.obj), callingPackage, |
| 273 | getApplicationContext().getApplicationInfo().targetSdkVersion); |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 274 | mPhone.addListener(mPhoneListener); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 275 | onPhoneCreated(mPhone); |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 276 | break; |
| 277 | case MSG_ADD_CALL: |
Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 278 | mPhone.internalAddCall((ParcelableCall) msg.obj); |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 279 | break; |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 280 | case MSG_UPDATE_CALL: |
Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 281 | mPhone.internalUpdateCall((ParcelableCall) msg.obj); |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 282 | break; |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 283 | case MSG_SET_POST_DIAL_WAIT: { |
| 284 | SomeArgs args = (SomeArgs) msg.obj; |
| 285 | try { |
| 286 | String callId = (String) args.arg1; |
| 287 | String remaining = (String) args.arg2; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 288 | mPhone.internalSetPostDialWait(callId, remaining); |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 289 | } finally { |
| 290 | args.recycle(); |
| 291 | } |
| 292 | break; |
| 293 | } |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 294 | case MSG_ON_CALL_AUDIO_STATE_CHANGED: |
| 295 | mPhone.internalCallAudioStateChanged((CallAudioState) msg.obj); |
Sailesh Nepal | b632e5b | 2014-04-03 12:54:33 -0700 | [diff] [blame] | 296 | break; |
Santos Cordon | 3534ede | 2014-05-29 13:07:10 -0700 | [diff] [blame] | 297 | case MSG_BRING_TO_FOREGROUND: |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 298 | mPhone.internalBringToForeground(msg.arg1 == 1); |
Santos Cordon | 3534ede | 2014-05-29 13:07:10 -0700 | [diff] [blame] | 299 | break; |
Santos Cordon | 6c912b7 | 2014-11-07 16:05:09 -0800 | [diff] [blame] | 300 | case MSG_ON_CAN_ADD_CALL_CHANGED: |
| 301 | mPhone.internalSetCanAddCall(msg.arg1 == 1); |
| 302 | break; |
Sailesh Nepal | 9c2618b | 2016-01-23 16:28:22 -0800 | [diff] [blame] | 303 | case MSG_SILENCE_RINGER: |
| 304 | mPhone.internalSilenceRinger(); |
| 305 | break; |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 306 | case MSG_ON_CONNECTION_EVENT: { |
| 307 | SomeArgs args = (SomeArgs) msg.obj; |
| 308 | try { |
| 309 | String callId = (String) args.arg1; |
| 310 | String event = (String) args.arg2; |
| 311 | Bundle extras = (Bundle) args.arg3; |
| 312 | mPhone.internalOnConnectionEvent(callId, event, extras); |
| 313 | } finally { |
| 314 | args.recycle(); |
| 315 | } |
| 316 | break; |
| 317 | } |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 318 | case MSG_ON_RTT_UPGRADE_REQUEST: { |
| 319 | String callId = (String) msg.obj; |
| 320 | int requestId = msg.arg1; |
| 321 | mPhone.internalOnRttUpgradeRequest(callId, requestId); |
| 322 | break; |
| 323 | } |
Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 324 | case MSG_ON_RTT_INITIATION_FAILURE: { |
| 325 | String callId = (String) msg.obj; |
| 326 | int reason = msg.arg1; |
| 327 | mPhone.internalOnRttInitiationFailure(callId, reason); |
| 328 | break; |
| 329 | } |
Sanket Padawe | 85291f6 | 2017-12-01 13:59:27 -0800 | [diff] [blame] | 330 | case MSG_ON_HANDOVER_FAILED: { |
| 331 | String callId = (String) msg.obj; |
| 332 | int error = msg.arg1; |
| 333 | mPhone.internalOnHandoverFailed(callId, error); |
| 334 | break; |
| 335 | } |
Tyler Gunn | 858bfaf | 2018-01-22 15:17:54 -0800 | [diff] [blame] | 336 | case MSG_ON_HANDOVER_COMPLETE: { |
| 337 | String callId = (String) msg.obj; |
| 338 | mPhone.internalOnHandoverComplete(callId); |
| 339 | break; |
| 340 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 341 | default: |
| 342 | break; |
| 343 | } |
| 344 | } |
| 345 | }; |
| 346 | |
| 347 | /** Manages the binder calls so that the implementor does not need to deal with it. */ |
| 348 | private final class InCallServiceBinder extends IInCallService.Stub { |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 349 | @Override |
| 350 | public void setInCallAdapter(IInCallAdapter inCallAdapter) { |
| 351 | mHandler.obtainMessage(MSG_SET_IN_CALL_ADAPTER, inCallAdapter).sendToTarget(); |
| 352 | } |
| 353 | |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 354 | @Override |
Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 355 | public void addCall(ParcelableCall call) { |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 356 | mHandler.obtainMessage(MSG_ADD_CALL, call).sendToTarget(); |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 357 | } |
| 358 | |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 359 | @Override |
Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 360 | public void updateCall(ParcelableCall call) { |
Sailesh Nepal | 6043793 | 2014-04-05 16:44:55 -0700 | [diff] [blame] | 361 | mHandler.obtainMessage(MSG_UPDATE_CALL, call).sendToTarget(); |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | @Override |
| 365 | public void setPostDial(String callId, String remaining) { |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 366 | // TODO: Unused |
Ihab Awad | 2f23664 | 2014-03-10 15:33:45 -0700 | [diff] [blame] | 367 | } |
| 368 | |
| 369 | @Override |
| 370 | public void setPostDialWait(String callId, String remaining) { |
| 371 | SomeArgs args = SomeArgs.obtain(); |
| 372 | args.arg1 = callId; |
| 373 | args.arg2 = remaining; |
| 374 | mHandler.obtainMessage(MSG_SET_POST_DIAL_WAIT, args).sendToTarget(); |
| 375 | } |
Sailesh Nepal | b632e5b | 2014-04-03 12:54:33 -0700 | [diff] [blame] | 376 | |
| 377 | @Override |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 378 | public void onCallAudioStateChanged(CallAudioState callAudioState) { |
| 379 | mHandler.obtainMessage(MSG_ON_CALL_AUDIO_STATE_CHANGED, callAudioState).sendToTarget(); |
Sailesh Nepal | b632e5b | 2014-04-03 12:54:33 -0700 | [diff] [blame] | 380 | } |
Santos Cordon | 3534ede | 2014-05-29 13:07:10 -0700 | [diff] [blame] | 381 | |
Santos Cordon | 3534ede | 2014-05-29 13:07:10 -0700 | [diff] [blame] | 382 | @Override |
| 383 | public void bringToForeground(boolean showDialpad) { |
| 384 | mHandler.obtainMessage(MSG_BRING_TO_FOREGROUND, showDialpad ? 1 : 0, 0).sendToTarget(); |
| 385 | } |
Santos Cordon | 6c912b7 | 2014-11-07 16:05:09 -0800 | [diff] [blame] | 386 | |
| 387 | @Override |
| 388 | public void onCanAddCallChanged(boolean canAddCall) { |
| 389 | mHandler.obtainMessage(MSG_ON_CAN_ADD_CALL_CHANGED, canAddCall ? 1 : 0, 0) |
| 390 | .sendToTarget(); |
| 391 | } |
Sailesh Nepal | 9c2618b | 2016-01-23 16:28:22 -0800 | [diff] [blame] | 392 | |
| 393 | @Override |
| 394 | public void silenceRinger() { |
| 395 | mHandler.obtainMessage(MSG_SILENCE_RINGER).sendToTarget(); |
| 396 | } |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 397 | |
| 398 | @Override |
| 399 | public void onConnectionEvent(String callId, String event, Bundle extras) { |
| 400 | SomeArgs args = SomeArgs.obtain(); |
| 401 | args.arg1 = callId; |
| 402 | args.arg2 = event; |
| 403 | args.arg3 = extras; |
| 404 | mHandler.obtainMessage(MSG_ON_CONNECTION_EVENT, args).sendToTarget(); |
| 405 | } |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 406 | |
| 407 | @Override |
| 408 | public void onRttUpgradeRequest(String callId, int id) { |
| 409 | mHandler.obtainMessage(MSG_ON_RTT_UPGRADE_REQUEST, id, 0, callId).sendToTarget(); |
| 410 | } |
Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 411 | |
| 412 | @Override |
| 413 | public void onRttInitiationFailure(String callId, int reason) { |
| 414 | mHandler.obtainMessage(MSG_ON_RTT_INITIATION_FAILURE, reason, 0, callId).sendToTarget(); |
| 415 | } |
Sanket Padawe | 85291f6 | 2017-12-01 13:59:27 -0800 | [diff] [blame] | 416 | |
| 417 | @Override |
| 418 | public void onHandoverFailed(String callId, int error) { |
| 419 | mHandler.obtainMessage(MSG_ON_HANDOVER_FAILED, error, 0, callId).sendToTarget(); |
| 420 | } |
Tyler Gunn | 858bfaf | 2018-01-22 15:17:54 -0800 | [diff] [blame] | 421 | |
| 422 | @Override |
| 423 | public void onHandoverComplete(String callId) { |
| 424 | mHandler.obtainMessage(MSG_ON_HANDOVER_COMPLETE, callId).sendToTarget(); |
| 425 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 426 | } |
| 427 | |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 428 | private Phone.Listener mPhoneListener = new Phone.Listener() { |
| 429 | /** ${inheritDoc} */ |
| 430 | @Override |
| 431 | public void onAudioStateChanged(Phone phone, AudioState audioState) { |
| 432 | InCallService.this.onAudioStateChanged(audioState); |
| 433 | } |
| 434 | |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 435 | public void onCallAudioStateChanged(Phone phone, CallAudioState callAudioState) { |
| 436 | InCallService.this.onCallAudioStateChanged(callAudioState); |
| 437 | }; |
| 438 | |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 439 | /** ${inheritDoc} */ |
| 440 | @Override |
| 441 | public void onBringToForeground(Phone phone, boolean showDialpad) { |
| 442 | InCallService.this.onBringToForeground(showDialpad); |
| 443 | } |
| 444 | |
| 445 | /** ${inheritDoc} */ |
| 446 | @Override |
| 447 | public void onCallAdded(Phone phone, Call call) { |
| 448 | InCallService.this.onCallAdded(call); |
| 449 | } |
| 450 | |
| 451 | /** ${inheritDoc} */ |
| 452 | @Override |
| 453 | public void onCallRemoved(Phone phone, Call call) { |
| 454 | InCallService.this.onCallRemoved(call); |
| 455 | } |
| 456 | |
| 457 | /** ${inheritDoc} */ |
| 458 | @Override |
| 459 | public void onCanAddCallChanged(Phone phone, boolean canAddCall) { |
| 460 | InCallService.this.onCanAddCallChanged(canAddCall); |
| 461 | } |
| 462 | |
Sailesh Nepal | 9c2618b | 2016-01-23 16:28:22 -0800 | [diff] [blame] | 463 | /** ${inheritDoc} */ |
| 464 | @Override |
| 465 | public void onSilenceRinger(Phone phone) { |
| 466 | InCallService.this.onSilenceRinger(); |
| 467 | } |
| 468 | |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 469 | }; |
| 470 | |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 471 | private Phone mPhone; |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 472 | |
Santos Cordon | 2f42b11 | 2014-07-19 13:19:37 -0700 | [diff] [blame] | 473 | public InCallService() { |
| 474 | } |
Evan Charlton | 924748f | 2014-04-03 08:36:38 -0700 | [diff] [blame] | 475 | |
Santos Cordon | 2f42b11 | 2014-07-19 13:19:37 -0700 | [diff] [blame] | 476 | @Override |
| 477 | public IBinder onBind(Intent intent) { |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 478 | return new InCallServiceBinder(); |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 479 | } |
| 480 | |
Santos Cordon | f30d7e9 | 2014-08-26 09:54:33 -0700 | [diff] [blame] | 481 | @Override |
| 482 | public boolean onUnbind(Intent intent) { |
Santos Cordon | 619b3c0 | 2014-09-02 17:13:45 -0700 | [diff] [blame] | 483 | if (mPhone != null) { |
| 484 | Phone oldPhone = mPhone; |
| 485 | mPhone = null; |
Santos Cordon | f30d7e9 | 2014-08-26 09:54:33 -0700 | [diff] [blame] | 486 | |
Santos Cordon | 619b3c0 | 2014-09-02 17:13:45 -0700 | [diff] [blame] | 487 | oldPhone.destroy(); |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 488 | // destroy sets all the calls to disconnected if any live ones still exist. Therefore, |
| 489 | // it is important to remove the Listener *after* the call to destroy so that |
| 490 | // InCallService.on* callbacks are appropriately called. |
| 491 | oldPhone.removeListener(mPhoneListener); |
| 492 | |
Santos Cordon | 619b3c0 | 2014-09-02 17:13:45 -0700 | [diff] [blame] | 493 | onPhoneDestroyed(oldPhone); |
| 494 | } |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 495 | |
Santos Cordon | f30d7e9 | 2014-08-26 09:54:33 -0700 | [diff] [blame] | 496 | return false; |
| 497 | } |
| 498 | |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 499 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 500 | * Obtain the {@code Phone} associated with this {@code InCallService}. |
| 501 | * |
| 502 | * @return The {@code Phone} object associated with this {@code InCallService}, or {@code null} |
Santos Cordon | 2f42b11 | 2014-07-19 13:19:37 -0700 | [diff] [blame] | 503 | * if the {@code InCallService} is not in a state where it has an associated |
| 504 | * {@code Phone}. |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 505 | * @hide |
Santos Cordon | 29886d8 | 2015-04-16 15:34:07 -0700 | [diff] [blame] | 506 | * @deprecated Use direct methods on InCallService instead of {@link Phone}. |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 507 | */ |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 508 | @SystemApi |
Santos Cordon | 29886d8 | 2015-04-16 15:34:07 -0700 | [diff] [blame] | 509 | @Deprecated |
| 510 | public Phone getPhone() { |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 511 | return mPhone; |
Evan Charlton | 924748f | 2014-04-03 08:36:38 -0700 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | /** |
Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 515 | * Obtains the current list of {@code Call}s to be displayed by this in-call service. |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 516 | * |
| 517 | * @return A list of the relevant {@code Call}s. |
| 518 | */ |
| 519 | public final List<Call> getCalls() { |
| 520 | return mPhone == null ? Collections.<Call>emptyList() : mPhone.getCalls(); |
| 521 | } |
| 522 | |
| 523 | /** |
| 524 | * Returns if the device can support additional calls. |
| 525 | * |
| 526 | * @return Whether the phone supports adding more calls. |
| 527 | */ |
| 528 | public final boolean canAddCall() { |
| 529 | return mPhone == null ? false : mPhone.canAddCall(); |
| 530 | } |
| 531 | |
| 532 | /** |
| 533 | * Obtains the current phone call audio state. |
| 534 | * |
| 535 | * @return An object encapsulating the audio state. Returns null if the service is not |
| 536 | * fully initialized. |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 537 | * @deprecated Use {@link #getCallAudioState()} instead. |
| 538 | * @hide |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 539 | */ |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 540 | @Deprecated |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 541 | public final AudioState getAudioState() { |
| 542 | return mPhone == null ? null : mPhone.getAudioState(); |
| 543 | } |
| 544 | |
| 545 | /** |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 546 | * Obtains the current phone call audio state. |
| 547 | * |
| 548 | * @return An object encapsulating the audio state. Returns null if the service is not |
| 549 | * fully initialized. |
| 550 | */ |
| 551 | public final CallAudioState getCallAudioState() { |
| 552 | return mPhone == null ? null : mPhone.getCallAudioState(); |
| 553 | } |
| 554 | |
| 555 | /** |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 556 | * Sets the microphone mute state. When this request is honored, there will be change to |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 557 | * the {@link #getCallAudioState()}. |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 558 | * |
| 559 | * @param state {@code true} if the microphone should be muted; {@code false} otherwise. |
| 560 | */ |
| 561 | public final void setMuted(boolean state) { |
| 562 | if (mPhone != null) { |
| 563 | mPhone.setMuted(state); |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | /** |
| 568 | * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 569 | * be change to the {@link #getCallAudioState()}. |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 570 | * |
| 571 | * @param route The audio route to use. |
| 572 | */ |
| 573 | public final void setAudioRoute(int route) { |
| 574 | if (mPhone != null) { |
| 575 | mPhone.setAudioRoute(route); |
| 576 | } |
| 577 | } |
| 578 | |
| 579 | /** |
Hall Liu | a98f58b | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 580 | * Request audio routing to a specific bluetooth device. Calling this method may result in |
| 581 | * the device routing audio to a different bluetooth device than the one specified if the |
| 582 | * bluetooth stack is unable to route audio to the requested device. |
| 583 | * A list of available devices can be obtained via |
| 584 | * {@link CallAudioState#getSupportedBluetoothDevices()} |
| 585 | * |
Hall Liu | 1539283 | 2018-04-02 13:52:57 -0700 | [diff] [blame] | 586 | * @param bluetoothDevice The bluetooth device to connect to. |
Hall Liu | a98f58b | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 587 | */ |
Hall Liu | 1539283 | 2018-04-02 13:52:57 -0700 | [diff] [blame] | 588 | public final void requestBluetoothAudio(@NonNull BluetoothDevice bluetoothDevice) { |
Hall Liu | a98f58b | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 589 | if (mPhone != null) { |
Hall Liu | 1539283 | 2018-04-02 13:52:57 -0700 | [diff] [blame] | 590 | mPhone.requestBluetoothAudio(bluetoothDevice.getAddress()); |
Hall Liu | a98f58b | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 591 | } |
| 592 | } |
| 593 | |
| 594 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 595 | * Invoked when the {@code Phone} has been created. This is a signal to the in-call experience |
| 596 | * to start displaying in-call information to the user. Each instance of {@code InCallService} |
Santos Cordon | 2f42b11 | 2014-07-19 13:19:37 -0700 | [diff] [blame] | 597 | * will have only one {@code Phone}, and this method will be called exactly once in the lifetime |
| 598 | * of the {@code InCallService}. |
Evan Charlton | 924748f | 2014-04-03 08:36:38 -0700 | [diff] [blame] | 599 | * |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 600 | * @param phone The {@code Phone} object associated with this {@code InCallService}. |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 601 | * @hide |
Santos Cordon | 29886d8 | 2015-04-16 15:34:07 -0700 | [diff] [blame] | 602 | * @deprecated Use direct methods on InCallService instead of {@link Phone}. |
Evan Charlton | 924748f | 2014-04-03 08:36:38 -0700 | [diff] [blame] | 603 | */ |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 604 | @SystemApi |
Santos Cordon | 29886d8 | 2015-04-16 15:34:07 -0700 | [diff] [blame] | 605 | @Deprecated |
Santos Cordon | 2f42b11 | 2014-07-19 13:19:37 -0700 | [diff] [blame] | 606 | public void onPhoneCreated(Phone phone) { |
| 607 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 608 | |
| 609 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 610 | * Invoked when a {@code Phone} has been destroyed. This is a signal to the in-call experience |
| 611 | * to stop displaying in-call information to the user. This method will be called exactly once |
| 612 | * in the lifetime of the {@code InCallService}, and it will always be called after a previous |
| 613 | * call to {@link #onPhoneCreated(Phone)}. |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 614 | * |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 615 | * @param phone The {@code Phone} object associated with this {@code InCallService}. |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 616 | * @hide |
Santos Cordon | 29886d8 | 2015-04-16 15:34:07 -0700 | [diff] [blame] | 617 | * @deprecated Use direct methods on InCallService instead of {@link Phone}. |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 618 | */ |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 619 | @SystemApi |
Santos Cordon | 29886d8 | 2015-04-16 15:34:07 -0700 | [diff] [blame] | 620 | @Deprecated |
Santos Cordon | 2f42b11 | 2014-07-19 13:19:37 -0700 | [diff] [blame] | 621 | public void onPhoneDestroyed(Phone phone) { |
| 622 | } |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 623 | |
| 624 | /** |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 625 | * Called when the audio state changes. |
| 626 | * |
| 627 | * @param audioState The new {@link AudioState}. |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 628 | * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState) instead}. |
| 629 | * @hide |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 630 | */ |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 631 | @Deprecated |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 632 | public void onAudioStateChanged(AudioState audioState) { |
| 633 | } |
| 634 | |
| 635 | /** |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 636 | * Called when the audio state changes. |
| 637 | * |
| 638 | * @param audioState The new {@link CallAudioState}. |
| 639 | */ |
| 640 | public void onCallAudioStateChanged(CallAudioState audioState) { |
| 641 | } |
| 642 | |
| 643 | /** |
Santos Cordon | a249281 | 2015-04-15 11:05:16 -0700 | [diff] [blame] | 644 | * Called to bring the in-call screen to the foreground. The in-call experience should |
| 645 | * respond immediately by coming to the foreground to inform the user of the state of |
| 646 | * ongoing {@code Call}s. |
| 647 | * |
| 648 | * @param showDialpad If true, put up the dialpad when the screen is shown. |
| 649 | */ |
| 650 | public void onBringToForeground(boolean showDialpad) { |
| 651 | } |
| 652 | |
| 653 | /** |
| 654 | * Called when a {@code Call} has been added to this in-call session. The in-call user |
| 655 | * experience should add necessary state listeners to the specified {@code Call} and |
| 656 | * immediately start to show the user information about the existence |
| 657 | * and nature of this {@code Call}. Subsequent invocations of {@link #getCalls()} will |
| 658 | * include this {@code Call}. |
| 659 | * |
| 660 | * @param call A newly added {@code Call}. |
| 661 | */ |
| 662 | public void onCallAdded(Call call) { |
| 663 | } |
| 664 | |
| 665 | /** |
| 666 | * Called when a {@code Call} has been removed from this in-call session. The in-call user |
| 667 | * experience should remove any state listeners from the specified {@code Call} and |
| 668 | * immediately stop displaying any information about this {@code Call}. |
| 669 | * Subsequent invocations of {@link #getCalls()} will no longer include this {@code Call}. |
| 670 | * |
| 671 | * @param call A newly removed {@code Call}. |
| 672 | */ |
| 673 | public void onCallRemoved(Call call) { |
| 674 | } |
| 675 | |
| 676 | /** |
| 677 | * Called when the ability to add more calls changes. If the phone cannot |
| 678 | * support more calls then {@code canAddCall} is set to {@code false}. If it can, then it |
| 679 | * is set to {@code true}. This can be used to control the visibility of UI to add more calls. |
| 680 | * |
| 681 | * @param canAddCall Indicates whether an additional call can be added. |
| 682 | */ |
| 683 | public void onCanAddCallChanged(boolean canAddCall) { |
| 684 | } |
| 685 | |
| 686 | /** |
Sailesh Nepal | 9c2618b | 2016-01-23 16:28:22 -0800 | [diff] [blame] | 687 | * Called to silence the ringer if a ringing call exists. |
| 688 | */ |
| 689 | public void onSilenceRinger() { |
| 690 | } |
| 691 | |
| 692 | /** |
Tyler Gunn | 06f3fa6 | 2016-08-25 09:26:15 -0700 | [diff] [blame] | 693 | * Unused; to handle connection events issued by a {@link ConnectionService}, implement the |
| 694 | * {@link android.telecom.Call.Callback#onConnectionEvent(Call, String, Bundle)} callback. |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 695 | * <p> |
| 696 | * See {@link Connection#sendConnectionEvent(String, Bundle)}. |
| 697 | * |
| 698 | * @param call The call the event is associated with. |
| 699 | * @param event The event. |
| 700 | * @param extras Any associated extras. |
| 701 | */ |
| 702 | public void onConnectionEvent(Call call, String event, Bundle extras) { |
| 703 | } |
| 704 | |
| 705 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 706 | * Used to issue commands to the {@link Connection.VideoProvider} associated with a |
| 707 | * {@link Call}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 708 | */ |
| 709 | public static abstract class VideoCall { |
| 710 | |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 711 | /** @hide */ |
| 712 | public abstract void destroy(); |
| 713 | |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 714 | /** |
Andrew Lee | 7c9ee2b | 2015-04-16 15:26:08 -0700 | [diff] [blame] | 715 | * Registers a callback to receive commands and state changes for video calls. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 716 | * |
Andrew Lee | 7c9ee2b | 2015-04-16 15:26:08 -0700 | [diff] [blame] | 717 | * @param callback The video call callback. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 718 | */ |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 719 | public abstract void registerCallback(VideoCall.Callback callback); |
| 720 | |
| 721 | /** |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 722 | * Registers a callback to receive commands and state changes for video calls. |
| 723 | * |
| 724 | * @param callback The video call callback. |
| 725 | * @param handler A handler which commands and status changes will be delivered to. |
| 726 | */ |
| 727 | public abstract void registerCallback(VideoCall.Callback callback, Handler handler); |
| 728 | |
| 729 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 730 | * Clears the video call callback set via {@link #registerCallback}. |
Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 731 | * |
| 732 | * @param callback The video call callback to clear. |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 733 | */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 734 | public abstract void unregisterCallback(VideoCall.Callback callback); |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 735 | |
| 736 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 737 | * Sets the camera to be used for the outgoing video. |
| 738 | * <p> |
| 739 | * Handled by {@link Connection.VideoProvider#onSetCamera(String)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 740 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 741 | * @param cameraId The id of the camera (use ids as reported by |
| 742 | * {@link CameraManager#getCameraIdList()}). |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 743 | */ |
| 744 | public abstract void setCamera(String cameraId); |
| 745 | |
| 746 | /** |
| 747 | * Sets the surface to be used for displaying a preview of what the user's camera is |
| 748 | * currently capturing. When video transmission is enabled, this is the video signal which |
| 749 | * is sent to the remote device. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 750 | * <p> |
| 751 | * Handled by {@link Connection.VideoProvider#onSetPreviewSurface(Surface)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 752 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 753 | * @param surface The {@link Surface}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 754 | */ |
| 755 | public abstract void setPreviewSurface(Surface surface); |
| 756 | |
| 757 | /** |
| 758 | * Sets the surface to be used for displaying the video received from the remote device. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 759 | * <p> |
| 760 | * Handled by {@link Connection.VideoProvider#onSetDisplaySurface(Surface)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 761 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 762 | * @param surface The {@link Surface}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 763 | */ |
| 764 | public abstract void setDisplaySurface(Surface surface); |
| 765 | |
| 766 | /** |
| 767 | * Sets the device orientation, in degrees. Assumes that a standard portrait orientation of |
| 768 | * the device is 0 degrees. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 769 | * <p> |
| 770 | * Handled by {@link Connection.VideoProvider#onSetDeviceOrientation(int)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 771 | * |
| 772 | * @param rotation The device orientation, in degrees. |
| 773 | */ |
| 774 | public abstract void setDeviceOrientation(int rotation); |
| 775 | |
| 776 | /** |
| 777 | * Sets camera zoom ratio. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 778 | * <p> |
| 779 | * Handled by {@link Connection.VideoProvider#onSetZoom(float)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 780 | * |
| 781 | * @param value The camera zoom ratio. |
| 782 | */ |
| 783 | public abstract void setZoom(float value); |
| 784 | |
| 785 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 786 | * Issues a request to modify the properties of the current video session. |
| 787 | * <p> |
| 788 | * Example scenarios include: requesting an audio-only call to be upgraded to a |
| 789 | * bi-directional video call, turning on or off the user's camera, sending a pause signal |
| 790 | * when the {@link InCallService} is no longer the foreground application. |
| 791 | * <p> |
| 792 | * Handled by |
| 793 | * {@link Connection.VideoProvider#onSendSessionModifyRequest(VideoProfile, VideoProfile)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 794 | * |
| 795 | * @param requestProfile The requested call video properties. |
| 796 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 797 | public abstract void sendSessionModifyRequest(VideoProfile requestProfile); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 798 | |
| 799 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 800 | * Provides a response to a request to change the current call video session |
| 801 | * properties. This should be called in response to a request the {@link InCallService} has |
| 802 | * received via {@link VideoCall.Callback#onSessionModifyRequestReceived}. |
| 803 | * <p> |
| 804 | * Handled by |
| 805 | * {@link Connection.VideoProvider#onSendSessionModifyResponse(VideoProfile)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 806 | * |
| 807 | * @param responseProfile The response call video properties. |
| 808 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 809 | public abstract void sendSessionModifyResponse(VideoProfile responseProfile); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 810 | |
| 811 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 812 | * Issues a request to the {@link Connection.VideoProvider} to retrieve the capabilities |
| 813 | * of the current camera. The current camera is selected using |
| 814 | * {@link VideoCall#setCamera(String)}. |
| 815 | * <p> |
| 816 | * Camera capabilities are reported to the caller via |
| 817 | * {@link VideoCall.Callback#onCameraCapabilitiesChanged(VideoProfile.CameraCapabilities)}. |
| 818 | * <p> |
| 819 | * Handled by {@link Connection.VideoProvider#onRequestCameraCapabilities()}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 820 | */ |
| 821 | public abstract void requestCameraCapabilities(); |
| 822 | |
| 823 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 824 | * Issues a request to the {@link Connection.VideoProvider} to retrieve the cumulative data |
| 825 | * usage for the video component of the current call (in bytes). Data usage is reported |
| 826 | * to the caller via {@link VideoCall.Callback#onCallDataUsageChanged}. |
| 827 | * <p> |
| 828 | * Handled by {@link Connection.VideoProvider#onRequestConnectionDataUsage()}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 829 | */ |
| 830 | public abstract void requestCallDataUsage(); |
| 831 | |
| 832 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 833 | * Provides the {@link Connection.VideoProvider} with the {@link Uri} of an image to be |
| 834 | * displayed to the peer device when the video signal is paused. |
| 835 | * <p> |
| 836 | * Handled by {@link Connection.VideoProvider#onSetPauseImage(Uri)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 837 | * |
| 838 | * @param uri URI of image to display. |
| 839 | */ |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 840 | public abstract void setPauseImage(Uri uri); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 841 | |
| 842 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 843 | * The {@link InCallService} extends this class to provide a means of receiving callbacks |
Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 844 | * from the {@link Connection.VideoProvider}. |
| 845 | * <p> |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 846 | * When the {@link InCallService} receives the |
| 847 | * {@link Call.Callback#onVideoCallChanged(Call, VideoCall)} callback, it should create an |
| 848 | * instance its {@link VideoCall.Callback} implementation and set it on the |
| 849 | * {@link VideoCall} using {@link VideoCall#registerCallback(Callback)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 850 | */ |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 851 | public static abstract class Callback { |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 852 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 853 | * Called when the {@link Connection.VideoProvider} receives a session modification |
Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 854 | * request from the peer device. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 855 | * <p> |
| 856 | * The {@link InCallService} may potentially prompt the user to confirm whether they |
| 857 | * wish to accept the request, or decide to automatically accept the request. In either |
| 858 | * case the {@link InCallService} should call |
| 859 | * {@link VideoCall#sendSessionModifyResponse(VideoProfile)} to indicate the video |
| 860 | * profile agreed upon. |
| 861 | * <p> |
| 862 | * Callback originates from |
| 863 | * {@link Connection.VideoProvider#receiveSessionModifyRequest(VideoProfile)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 864 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 865 | * @param videoProfile The requested video profile. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 866 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 867 | public abstract void onSessionModifyRequestReceived(VideoProfile videoProfile); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 868 | |
| 869 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 870 | * Called when the {@link Connection.VideoProvider} receives a response to a session |
| 871 | * modification request previously sent to the peer device. |
| 872 | * <p> |
| 873 | * The new video state should not be considered active by the {@link InCallService} |
| 874 | * until the {@link Call} video state changes (the |
| 875 | * {@link Call.Callback#onDetailsChanged(Call, Call.Details)} callback is triggered |
| 876 | * when the video state changes). |
| 877 | * <p> |
| 878 | * Callback originates from |
| 879 | * {@link Connection.VideoProvider#receiveSessionModifyResponse(int, VideoProfile, |
| 880 | * VideoProfile)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 881 | * |
| 882 | * @param status Status of the session modify request. Valid values are |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 883 | * {@link Connection.VideoProvider#SESSION_MODIFY_REQUEST_SUCCESS}, |
| 884 | * {@link Connection.VideoProvider#SESSION_MODIFY_REQUEST_FAIL}, |
| 885 | * {@link Connection.VideoProvider#SESSION_MODIFY_REQUEST_INVALID}, |
| 886 | * {@link Connection.VideoProvider#SESSION_MODIFY_REQUEST_TIMED_OUT}, |
| 887 | * {@link Connection.VideoProvider#SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE}. |
| 888 | * @param requestedProfile The original request which was sent to the peer device. |
| 889 | * @param responseProfile The actual profile changes made by the peer device. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 890 | */ |
| 891 | public abstract void onSessionModifyResponseReceived(int status, |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 892 | VideoProfile requestedProfile, VideoProfile responseProfile); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 893 | |
| 894 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 895 | * Handles events related to the current video session which the {@link InCallService} |
| 896 | * may wish to handle. These are separate from requested changes to the session due to |
| 897 | * the underlying protocol or connection. |
| 898 | * <p> |
| 899 | * Callback originates from |
| 900 | * {@link Connection.VideoProvider#handleCallSessionEvent(int)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 901 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 902 | * @param event The event. Valid values are: |
| 903 | * {@link Connection.VideoProvider#SESSION_EVENT_RX_PAUSE}, |
| 904 | * {@link Connection.VideoProvider#SESSION_EVENT_RX_RESUME}, |
| 905 | * {@link Connection.VideoProvider#SESSION_EVENT_TX_START}, |
| 906 | * {@link Connection.VideoProvider#SESSION_EVENT_TX_STOP}, |
| 907 | * {@link Connection.VideoProvider#SESSION_EVENT_CAMERA_FAILURE}, |
Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 908 | * {@link Connection.VideoProvider#SESSION_EVENT_CAMERA_READY}, |
| 909 | * {@link Connection.VideoProvider#SESSION_EVENT_CAMERA_PERMISSION_ERROR}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 910 | */ |
| 911 | public abstract void onCallSessionEvent(int event); |
| 912 | |
| 913 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 914 | * Handles a change to the video dimensions from the peer device. This could happen if, |
| 915 | * for example, the peer changes orientation of their device, or switches cameras. |
| 916 | * <p> |
| 917 | * Callback originates from |
| 918 | * {@link Connection.VideoProvider#changePeerDimensions(int, int)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 919 | * |
| 920 | * @param width The updated peer video width. |
| 921 | * @param height The updated peer video height. |
| 922 | */ |
| 923 | public abstract void onPeerDimensionsChanged(int width, int height); |
| 924 | |
| 925 | /** |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 926 | * Handles a change to the video quality. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 927 | * <p> |
| 928 | * Callback originates from {@link Connection.VideoProvider#changeVideoQuality(int)}. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 929 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 930 | * @param videoQuality The updated peer video quality. Valid values: |
| 931 | * {@link VideoProfile#QUALITY_HIGH}, |
| 932 | * {@link VideoProfile#QUALITY_MEDIUM}, |
| 933 | * {@link VideoProfile#QUALITY_LOW}, |
| 934 | * {@link VideoProfile#QUALITY_DEFAULT}. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 935 | */ |
| 936 | public abstract void onVideoQualityChanged(int videoQuality); |
| 937 | |
| 938 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 939 | * Handles an update to the total data used for the current video session. |
| 940 | * <p> |
| 941 | * Used by the {@link Connection.VideoProvider} in response to |
| 942 | * {@link VideoCall#requestCallDataUsage()}. May also be called periodically by the |
| 943 | * {@link Connection.VideoProvider}. |
| 944 | * <p> |
| 945 | * Callback originates from {@link Connection.VideoProvider#setCallDataUsage(long)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 946 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 947 | * @param dataUsage The updated data usage (in bytes). |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 948 | */ |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 949 | public abstract void onCallDataUsageChanged(long dataUsage); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 950 | |
| 951 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 952 | * Handles a change in the capabilities of the currently selected camera. |
| 953 | * <p> |
| 954 | * Used by the {@link Connection.VideoProvider} in response to |
| 955 | * {@link VideoCall#requestCameraCapabilities()}. The {@link Connection.VideoProvider} |
| 956 | * may also report the camera capabilities after a call to |
| 957 | * {@link VideoCall#setCamera(String)}. |
| 958 | * <p> |
| 959 | * Callback originates from |
| 960 | * {@link Connection.VideoProvider#changeCameraCapabilities( |
| 961 | * VideoProfile.CameraCapabilities)}. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 962 | * |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 963 | * @param cameraCapabilities The changed camera capabilities. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 964 | */ |
Yorke Lee | 400470f | 2015-05-12 13:31:25 -0700 | [diff] [blame] | 965 | public abstract void onCameraCapabilitiesChanged( |
| 966 | VideoProfile.CameraCapabilities cameraCapabilities); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 967 | } |
| 968 | } |
Sailesh Nepal | ab5d282 | 2014-03-08 18:01:06 -0800 | [diff] [blame] | 969 | } |