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