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