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