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