Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 18 | |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 19 | import android.annotation.IntDef; |
Ravi Paluri | 404babb | 2020-01-23 19:02:44 +0530 | [diff] [blame] | 20 | import android.annotation.NonNull; |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 21 | import android.annotation.Nullable; |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 22 | import android.annotation.SystemApi; |
Hall Liu | 6dfa249 | 2019-10-01 17:20:39 -0700 | [diff] [blame] | 23 | import android.annotation.TestApi; |
Artur Satayev | 53ada2a | 2019-12-10 17:47:56 +0000 | [diff] [blame] | 24 | import android.compat.annotation.UnsupportedAppUsage; |
Tyler Gunn | 460b7d4 | 2020-05-15 10:19:32 -0700 | [diff] [blame] | 25 | import android.content.pm.ServiceInfo; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 26 | import android.net.Uri; |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 27 | import android.os.Build; |
Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 28 | import android.os.Bundle; |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 29 | import android.os.Handler; |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 30 | import android.os.ParcelFileDescriptor; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 31 | |
Tyler Gunn | d1fdf3a | 2019-11-05 15:47:58 -0800 | [diff] [blame] | 32 | import com.android.internal.telecom.IVideoProvider; |
| 33 | |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 34 | import java.io.IOException; |
| 35 | import java.io.InputStreamReader; |
| 36 | import java.io.OutputStreamWriter; |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 37 | import java.lang.annotation.Retention; |
| 38 | import java.lang.annotation.RetentionPolicy; |
| 39 | import java.nio.charset.StandardCharsets; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 40 | import java.util.ArrayList; |
Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 41 | import java.util.Arrays; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 42 | import java.util.Collections; |
| 43 | import java.util.List; |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 44 | import java.util.Map; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 45 | import java.util.Objects; |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 46 | import java.util.concurrent.CopyOnWriteArrayList; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 47 | |
| 48 | /** |
| 49 | * Represents an ongoing phone call that the in-call app should present to the user. |
| 50 | */ |
| 51 | public final class Call { |
| 52 | /** |
| 53 | * The state of a {@code Call} when newly created. |
| 54 | */ |
| 55 | public static final int STATE_NEW = 0; |
| 56 | |
| 57 | /** |
| 58 | * The state of an outgoing {@code Call} when dialing the remote number, but not yet connected. |
| 59 | */ |
| 60 | public static final int STATE_DIALING = 1; |
| 61 | |
| 62 | /** |
| 63 | * The state of an incoming {@code Call} when ringing locally, but not yet connected. |
| 64 | */ |
| 65 | public static final int STATE_RINGING = 2; |
| 66 | |
| 67 | /** |
| 68 | * The state of a {@code Call} when in a holding state. |
| 69 | */ |
| 70 | public static final int STATE_HOLDING = 3; |
| 71 | |
| 72 | /** |
| 73 | * The state of a {@code Call} when actively supporting conversation. |
| 74 | */ |
| 75 | public static final int STATE_ACTIVE = 4; |
| 76 | |
| 77 | /** |
| 78 | * The state of a {@code Call} when no further voice or other communication is being |
| 79 | * transmitted, the remote side has been or will inevitably be informed that the {@code Call} |
| 80 | * is no longer active, and the local data transport has or inevitably will release resources |
| 81 | * associated with this {@code Call}. |
| 82 | */ |
| 83 | public static final int STATE_DISCONNECTED = 7; |
| 84 | |
Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 85 | /** |
Santos Cordon | e3c507b | 2015-04-23 14:44:19 -0700 | [diff] [blame] | 86 | * The state of an outgoing {@code Call} when waiting on user to select a |
| 87 | * {@link PhoneAccount} through which to place the call. |
Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 88 | */ |
Santos Cordon | e3c507b | 2015-04-23 14:44:19 -0700 | [diff] [blame] | 89 | public static final int STATE_SELECT_PHONE_ACCOUNT = 8; |
| 90 | |
| 91 | /** |
| 92 | * @hide |
| 93 | * @deprecated use STATE_SELECT_PHONE_ACCOUNT. |
| 94 | */ |
| 95 | @Deprecated |
| 96 | @SystemApi |
| 97 | public static final int STATE_PRE_DIAL_WAIT = STATE_SELECT_PHONE_ACCOUNT; |
Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 98 | |
Nancy Chen | e20930f | 2014-08-07 16:17:21 -0700 | [diff] [blame] | 99 | /** |
Nancy Chen | e9b7a8e | 2014-08-08 14:26:27 -0700 | [diff] [blame] | 100 | * The initial state of an outgoing {@code Call}. |
| 101 | * Common transitions are to {@link #STATE_DIALING} state for a successful call or |
| 102 | * {@link #STATE_DISCONNECTED} if it failed. |
Nancy Chen | e20930f | 2014-08-07 16:17:21 -0700 | [diff] [blame] | 103 | */ |
| 104 | public static final int STATE_CONNECTING = 9; |
| 105 | |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 106 | /** |
Tyler Gunn | 4afc6af | 2014-10-07 10:14:55 -0700 | [diff] [blame] | 107 | * The state of a {@code Call} when the user has initiated a disconnection of the call, but the |
| 108 | * call has not yet been disconnected by the underlying {@code ConnectionService}. The next |
| 109 | * state of the call is (potentially) {@link #STATE_DISCONNECTED}. |
| 110 | */ |
| 111 | public static final int STATE_DISCONNECTING = 10; |
| 112 | |
| 113 | /** |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 114 | * The state of an external call which is in the process of being pulled from a remote device to |
| 115 | * the local device. |
| 116 | * <p> |
| 117 | * A call can only be in this state if the {@link Details#PROPERTY_IS_EXTERNAL_CALL} property |
| 118 | * and {@link Details#CAPABILITY_CAN_PULL_CALL} capability are set on the call. |
| 119 | * <p> |
| 120 | * An {@link InCallService} will only see this state if it has the |
| 121 | * {@link TelecomManager#METADATA_INCLUDE_EXTERNAL_CALLS} metadata set to {@code true} in its |
| 122 | * manifest. |
| 123 | */ |
| 124 | public static final int STATE_PULLING_CALL = 11; |
| 125 | |
| 126 | /** |
Hall Liu | 6dfa249 | 2019-10-01 17:20:39 -0700 | [diff] [blame] | 127 | * The state of a call that is active with the network, but the audio from the call is |
| 128 | * being intercepted by an app on the local device. Telecom does not hold audio focus in this |
| 129 | * state, and the call will be invisible to the user except for a persistent notification. |
| 130 | */ |
| 131 | public static final int STATE_AUDIO_PROCESSING = 12; |
| 132 | |
| 133 | /** |
| 134 | * The state of a call that is being presented to the user after being in |
| 135 | * {@link #STATE_AUDIO_PROCESSING}. The call is still active with the network in this case, and |
| 136 | * Telecom will hold audio focus and play a ringtone if appropriate. |
| 137 | */ |
| 138 | public static final int STATE_SIMULATED_RINGING = 13; |
| 139 | |
| 140 | /** |
Tyler Gunn | 1e406ca | 2021-03-18 16:47:14 -0700 | [diff] [blame] | 141 | * @hide |
| 142 | */ |
| 143 | @IntDef(prefix = { "STATE_" }, |
| 144 | value = { |
| 145 | STATE_NEW, |
| 146 | STATE_DIALING, |
| 147 | STATE_RINGING, |
| 148 | STATE_HOLDING, |
| 149 | STATE_ACTIVE, |
| 150 | STATE_DISCONNECTED, |
| 151 | STATE_SELECT_PHONE_ACCOUNT, |
| 152 | STATE_CONNECTING, |
| 153 | STATE_DISCONNECTING, |
| 154 | STATE_PULLING_CALL, |
| 155 | STATE_AUDIO_PROCESSING, |
| 156 | STATE_SIMULATED_RINGING |
| 157 | }) |
| 158 | @Retention(RetentionPolicy.SOURCE) |
| 159 | public @interface CallState {}; |
| 160 | |
| 161 | /** |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 162 | * The key to retrieve the optional {@code PhoneAccount}s Telecom can bundle with its Call |
| 163 | * extras. Used to pass the phone accounts to display on the front end to the user in order to |
| 164 | * select phone accounts to (for example) place a call. |
Hall Liu | 34d9e24 | 2018-11-21 17:05:58 -0800 | [diff] [blame] | 165 | * @deprecated Use the list from {@link #EXTRA_SUGGESTED_PHONE_ACCOUNTS} instead. |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 166 | */ |
Hall Liu | 34d9e24 | 2018-11-21 17:05:58 -0800 | [diff] [blame] | 167 | @Deprecated |
Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 168 | public static final String AVAILABLE_PHONE_ACCOUNTS = "selectPhoneAccountAccounts"; |
| 169 | |
mike dooley | 4af561f | 2016-12-20 08:55:17 -0800 | [diff] [blame] | 170 | /** |
Thomas Stuart | 5ca875eb | 2022-08-03 18:39:57 -0700 | [diff] [blame] | 171 | * Extra key intended for {@link InCallService}s that notify the user of an incoming call. When |
| 172 | * EXTRA_IS_SUPPRESSED_BY_DO_NOT_DISTURB returns true, the {@link InCallService} should not |
| 173 | * interrupt the user of the incoming call because the call is being suppressed by Do Not |
| 174 | * Disturb settings. |
| 175 | * |
| 176 | * This extra will be removed from the {@link Call} object for {@link InCallService}s that do |
| 177 | * not hold the {@link android.Manifest.permission#READ_CONTACTS} permission. |
| 178 | */ |
| 179 | public static final String EXTRA_IS_SUPPRESSED_BY_DO_NOT_DISTURB = |
| 180 | "android.telecom.extra.IS_SUPPRESSED_BY_DO_NOT_DISTURB"; |
| 181 | |
| 182 | /** |
Hall Liu | 34d9e24 | 2018-11-21 17:05:58 -0800 | [diff] [blame] | 183 | * Key for extra used to pass along a list of {@link PhoneAccountSuggestion}s to the in-call |
| 184 | * UI when a call enters the {@link #STATE_SELECT_PHONE_ACCOUNT} state. The list included here |
| 185 | * will have the same length and be in the same order as the list passed with |
| 186 | * {@link #AVAILABLE_PHONE_ACCOUNTS}. |
| 187 | */ |
| 188 | public static final String EXTRA_SUGGESTED_PHONE_ACCOUNTS = |
| 189 | "android.telecom.extra.SUGGESTED_PHONE_ACCOUNTS"; |
| 190 | |
| 191 | /** |
mike dooley | 9121742 | 2017-03-09 12:58:42 -0800 | [diff] [blame] | 192 | * Extra key used to indicate the time (in milliseconds since midnight, January 1, 1970 UTC) |
| 193 | * when the last outgoing emergency call was made. This is used to identify potential emergency |
| 194 | * callbacks. |
mike dooley | 4af561f | 2016-12-20 08:55:17 -0800 | [diff] [blame] | 195 | */ |
| 196 | public static final String EXTRA_LAST_EMERGENCY_CALLBACK_TIME_MILLIS = |
| 197 | "android.telecom.extra.LAST_EMERGENCY_CALLBACK_TIME_MILLIS"; |
| 198 | |
Usman Abdullah | b0dc29a | 2019-03-06 15:54:56 -0800 | [diff] [blame] | 199 | |
| 200 | /** |
| 201 | * Extra key used to indicate whether a {@link CallScreeningService} has requested to silence |
| 202 | * the ringtone for a call. If the {@link InCallService} declares |
| 203 | * {@link TelecomManager#METADATA_IN_CALL_SERVICE_RINGING} in its manifest, it should not |
| 204 | * play a ringtone for an incoming call with this extra key set. |
| 205 | */ |
| 206 | public static final String EXTRA_SILENT_RINGING_REQUESTED = |
| 207 | "android.telecom.extra.SILENT_RINGING_REQUESTED"; |
| 208 | |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 209 | /** |
| 210 | * Call event sent from a {@link Call} via {@link #sendCallEvent(String, Bundle)} to inform |
| 211 | * Telecom that the user has requested that the current {@link Call} should be handed over |
| 212 | * to another {@link ConnectionService}. |
| 213 | * <p> |
| 214 | * The caller must specify the {@link #EXTRA_HANDOVER_PHONE_ACCOUNT_HANDLE} to indicate to |
| 215 | * Telecom which {@link PhoneAccountHandle} the {@link Call} should be handed over to. |
| 216 | * @hide |
Tyler Gunn | 1a505fa | 2018-09-14 13:36:38 -0700 | [diff] [blame] | 217 | * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated |
| 218 | * APIs instead. |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 219 | */ |
| 220 | public static final String EVENT_REQUEST_HANDOVER = |
| 221 | "android.telecom.event.REQUEST_HANDOVER"; |
| 222 | |
| 223 | /** |
| 224 | * Extra key used with the {@link #EVENT_REQUEST_HANDOVER} call event. Specifies the |
| 225 | * {@link PhoneAccountHandle} to which a call should be handed over to. |
| 226 | * @hide |
Tyler Gunn | 1a505fa | 2018-09-14 13:36:38 -0700 | [diff] [blame] | 227 | * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated |
| 228 | * APIs instead. |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 229 | */ |
| 230 | public static final String EXTRA_HANDOVER_PHONE_ACCOUNT_HANDLE = |
| 231 | "android.telecom.extra.HANDOVER_PHONE_ACCOUNT_HANDLE"; |
| 232 | |
| 233 | /** |
| 234 | * Integer extra key used with the {@link #EVENT_REQUEST_HANDOVER} call event. Specifies the |
| 235 | * video state of the call when it is handed over to the new {@link PhoneAccount}. |
| 236 | * <p> |
| 237 | * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY}, |
| 238 | * {@link VideoProfile#STATE_BIDIRECTIONAL}, {@link VideoProfile#STATE_RX_ENABLED}, and |
| 239 | * {@link VideoProfile#STATE_TX_ENABLED}. |
| 240 | * @hide |
Tyler Gunn | 1a505fa | 2018-09-14 13:36:38 -0700 | [diff] [blame] | 241 | * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated |
| 242 | * APIs instead. |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 243 | */ |
| 244 | public static final String EXTRA_HANDOVER_VIDEO_STATE = |
| 245 | "android.telecom.extra.HANDOVER_VIDEO_STATE"; |
| 246 | |
| 247 | /** |
Tyler Gunn | 9f6f047 | 2017-04-17 18:25:22 -0700 | [diff] [blame] | 248 | * Extra key used with the {@link #EVENT_REQUEST_HANDOVER} call event. Used by the |
| 249 | * {@link InCallService} initiating a handover to provide a {@link Bundle} with extra |
| 250 | * information to the handover {@link ConnectionService} specified by |
| 251 | * {@link #EXTRA_HANDOVER_PHONE_ACCOUNT_HANDLE}. |
| 252 | * <p> |
| 253 | * This {@link Bundle} is not interpreted by Telecom, but passed as-is to the |
| 254 | * {@link ConnectionService} via the request extras when |
| 255 | * {@link ConnectionService#onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)} |
| 256 | * is called to initate the handover. |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 257 | * @hide |
Tyler Gunn | 1a505fa | 2018-09-14 13:36:38 -0700 | [diff] [blame] | 258 | * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated |
| 259 | * APIs instead. |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 260 | */ |
Tyler Gunn | 9f6f047 | 2017-04-17 18:25:22 -0700 | [diff] [blame] | 261 | public static final String EXTRA_HANDOVER_EXTRAS = "android.telecom.extra.HANDOVER_EXTRAS"; |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 262 | |
| 263 | /** |
Tyler Gunn | 9f6f047 | 2017-04-17 18:25:22 -0700 | [diff] [blame] | 264 | * Call event sent from Telecom to the handover {@link ConnectionService} via |
| 265 | * {@link Connection#onCallEvent(String, Bundle)} to inform a {@link Connection} that a handover |
| 266 | * to the {@link ConnectionService} has completed successfully. |
| 267 | * <p> |
| 268 | * A handover is initiated with the {@link #EVENT_REQUEST_HANDOVER} call event. |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 269 | * @hide |
Tyler Gunn | 1a505fa | 2018-09-14 13:36:38 -0700 | [diff] [blame] | 270 | * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated |
| 271 | * APIs instead. |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 272 | */ |
Tyler Gunn | 9f6f047 | 2017-04-17 18:25:22 -0700 | [diff] [blame] | 273 | public static final String EVENT_HANDOVER_COMPLETE = |
| 274 | "android.telecom.event.HANDOVER_COMPLETE"; |
Tyler Gunn | 34a2b31 | 2017-06-23 08:32:00 -0700 | [diff] [blame] | 275 | |
| 276 | /** |
| 277 | * Call event sent from Telecom to the handover destination {@link ConnectionService} via |
| 278 | * {@link Connection#onCallEvent(String, Bundle)} to inform the handover destination that the |
| 279 | * source connection has disconnected. The {@link Bundle} parameter for the call event will be |
| 280 | * {@code null}. |
| 281 | * <p> |
| 282 | * A handover is initiated with the {@link #EVENT_REQUEST_HANDOVER} call event. |
| 283 | * @hide |
Tyler Gunn | 1a505fa | 2018-09-14 13:36:38 -0700 | [diff] [blame] | 284 | * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated |
| 285 | * APIs instead. |
Tyler Gunn | 34a2b31 | 2017-06-23 08:32:00 -0700 | [diff] [blame] | 286 | */ |
| 287 | public static final String EVENT_HANDOVER_SOURCE_DISCONNECTED = |
| 288 | "android.telecom.event.HANDOVER_SOURCE_DISCONNECTED"; |
| 289 | |
Tyler Gunn | 9f6f047 | 2017-04-17 18:25:22 -0700 | [diff] [blame] | 290 | /** |
| 291 | * Call event sent from Telecom to the handover {@link ConnectionService} via |
| 292 | * {@link Connection#onCallEvent(String, Bundle)} to inform a {@link Connection} that a handover |
| 293 | * to the {@link ConnectionService} has failed. |
| 294 | * <p> |
| 295 | * A handover is initiated with the {@link #EVENT_REQUEST_HANDOVER} call event. |
| 296 | * @hide |
Tyler Gunn | 1a505fa | 2018-09-14 13:36:38 -0700 | [diff] [blame] | 297 | * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated |
| 298 | * APIs instead. |
Tyler Gunn | 9f6f047 | 2017-04-17 18:25:22 -0700 | [diff] [blame] | 299 | */ |
| 300 | public static final String EVENT_HANDOVER_FAILED = |
| 301 | "android.telecom.event.HANDOVER_FAILED"; |
Tyler Gunn | 8bf7657 | 2017-04-06 15:30:08 -0700 | [diff] [blame] | 302 | |
Tyler Gunn | d582184 | 2021-02-05 11:12:57 -0800 | [diff] [blame] | 303 | /** |
| 304 | * Event reported from the Telecom stack to report an in-call diagnostic message which the |
| 305 | * dialer app may opt to display to the user. A diagnostic message is used to communicate |
| 306 | * scenarios the device has detected which may impact the quality of the ongoing call. |
| 307 | * <p> |
| 308 | * For example a problem with a bluetooth headset may generate a recommendation for the user to |
| 309 | * try using the speakerphone instead, or if the device detects it has entered a poor service |
| 310 | * area, the user might be warned so that they can finish their call prior to it dropping. |
| 311 | * <p> |
| 312 | * A diagnostic message is considered persistent in nature. When the user enters a poor service |
| 313 | * area, for example, the accompanying diagnostic message persists until they leave the area |
| 314 | * of poor service. Each message is accompanied with a {@link #EXTRA_DIAGNOSTIC_MESSAGE_ID} |
| 315 | * which uniquely identifies the diagnostic condition being reported. The framework raises a |
| 316 | * call event of type {@link #EVENT_CLEAR_DIAGNOSTIC_MESSAGE} when the condition reported has |
| 317 | * been cleared. The dialer app should display the diagnostic message until it is cleared. |
| 318 | * If multiple diagnostic messages are sent with different IDs (which have not yet been cleared) |
| 319 | * the dialer app should prioritize the most recently received message, but still provide the |
| 320 | * user with a means to review past messages. |
| 321 | * <p> |
| 322 | * The text of the message is found in {@link #EXTRA_DIAGNOSTIC_MESSAGE} in the form of a human |
| 323 | * readable {@link CharSequence} which is intended for display in the call UX. |
| 324 | * <p> |
| 325 | * The telecom framework audibly notifies the user of the presence of a diagnostic message, so |
| 326 | * the dialer app needs only to concern itself with visually displaying the message. |
| 327 | * <p> |
| 328 | * The dialer app receives this event via |
| 329 | * {@link Call.Callback#onConnectionEvent(Call, String, Bundle)}. |
| 330 | */ |
| 331 | public static final String EVENT_DISPLAY_DIAGNOSTIC_MESSAGE = |
| 332 | "android.telecom.event.DISPLAY_DIAGNOSTIC_MESSAGE"; |
| 333 | |
| 334 | /** |
| 335 | * Event reported from the telecom framework when a diagnostic message previously raised with |
| 336 | * {@link #EVENT_DISPLAY_DIAGNOSTIC_MESSAGE} has cleared and is no longer pertinent. |
| 337 | * <p> |
| 338 | * The {@link #EXTRA_DIAGNOSTIC_MESSAGE_ID} indicates the diagnostic message which has been |
| 339 | * cleared. |
| 340 | * <p> |
| 341 | * The dialer app receives this event via |
| 342 | * {@link Call.Callback#onConnectionEvent(Call, String, Bundle)}. |
| 343 | */ |
| 344 | public static final String EVENT_CLEAR_DIAGNOSTIC_MESSAGE = |
| 345 | "android.telecom.event.CLEAR_DIAGNOSTIC_MESSAGE"; |
| 346 | |
| 347 | /** |
| 348 | * Integer extra representing a message ID for a message posted via |
| 349 | * {@link #EVENT_DISPLAY_DIAGNOSTIC_MESSAGE}. Used to ensure that the dialer app knows when |
| 350 | * the message in question has cleared via {@link #EVENT_CLEAR_DIAGNOSTIC_MESSAGE}. |
| 351 | */ |
| 352 | public static final String EXTRA_DIAGNOSTIC_MESSAGE_ID = |
| 353 | "android.telecom.extra.DIAGNOSTIC_MESSAGE_ID"; |
| 354 | |
| 355 | /** |
| 356 | * {@link CharSequence} extra used with {@link #EVENT_DISPLAY_DIAGNOSTIC_MESSAGE}. This is the |
| 357 | * diagnostic message the dialer app should display. |
| 358 | */ |
| 359 | public static final String EXTRA_DIAGNOSTIC_MESSAGE = |
| 360 | "android.telecom.extra.DIAGNOSTIC_MESSAGE"; |
Tyler Gunn | facfdee | 2020-01-23 13:10:37 -0800 | [diff] [blame] | 361 | |
| 362 | /** |
| 363 | * Reject reason used with {@link #reject(int)} to indicate that the user is rejecting this |
| 364 | * call because they have declined to answer it. This typically means that they are unable |
| 365 | * to answer the call at this time and would prefer it be sent to voicemail. |
| 366 | */ |
| 367 | public static final int REJECT_REASON_DECLINED = 1; |
| 368 | |
| 369 | /** |
| 370 | * Reject reason used with {@link #reject(int)} to indicate that the user is rejecting this |
| 371 | * call because it is an unwanted call. This allows the user to indicate that they are |
| 372 | * rejecting a call because it is likely a nuisance call. |
| 373 | */ |
| 374 | public static final int REJECT_REASON_UNWANTED = 2; |
| 375 | |
| 376 | /** |
| 377 | * @hide |
| 378 | */ |
| 379 | @IntDef(prefix = { "REJECT_REASON_" }, |
| 380 | value = {REJECT_REASON_DECLINED, REJECT_REASON_UNWANTED}) |
| 381 | @Retention(RetentionPolicy.SOURCE) |
| 382 | public @interface RejectReason {}; |
| 383 | |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 384 | public static class Details { |
Tyler Gunn | 94f8f11 | 2018-12-17 09:56:11 -0800 | [diff] [blame] | 385 | /** @hide */ |
| 386 | @Retention(RetentionPolicy.SOURCE) |
| 387 | @IntDef( |
| 388 | prefix = { "DIRECTION_" }, |
| 389 | value = {DIRECTION_UNKNOWN, DIRECTION_INCOMING, DIRECTION_OUTGOING}) |
| 390 | public @interface CallDirection {} |
| 391 | |
| 392 | /** |
| 393 | * Indicates that the call is neither and incoming nor an outgoing call. This can be the |
| 394 | * case for calls reported directly by a {@link ConnectionService} in special cases such as |
| 395 | * call handovers. |
| 396 | */ |
| 397 | public static final int DIRECTION_UNKNOWN = -1; |
| 398 | |
| 399 | /** |
| 400 | * Indicates that the call is an incoming call. |
| 401 | */ |
| 402 | public static final int DIRECTION_INCOMING = 0; |
| 403 | |
| 404 | /** |
| 405 | * Indicates that the call is an outgoing call. |
| 406 | */ |
| 407 | public static final int DIRECTION_OUTGOING = 1; |
| 408 | |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 409 | /** Call can currently be put on hold or unheld. */ |
| 410 | public static final int CAPABILITY_HOLD = 0x00000001; |
| 411 | |
| 412 | /** Call supports the hold feature. */ |
| 413 | public static final int CAPABILITY_SUPPORT_HOLD = 0x00000002; |
| 414 | |
| 415 | /** |
| 416 | * Calls within a conference can be merged. A {@link ConnectionService} has the option to |
| 417 | * add a {@link Conference} call before the child {@link Connection}s are merged. This is how |
| 418 | * CDMA-based {@link Connection}s are implemented. For these unmerged {@link Conference}s, this |
| 419 | * capability allows a merge button to be shown while the conference call is in the foreground |
| 420 | * of the in-call UI. |
| 421 | * <p> |
| 422 | * This is only intended for use by a {@link Conference}. |
| 423 | */ |
| 424 | public static final int CAPABILITY_MERGE_CONFERENCE = 0x00000004; |
| 425 | |
| 426 | /** |
| 427 | * Calls within a conference can be swapped between foreground and background. |
| 428 | * See {@link #CAPABILITY_MERGE_CONFERENCE} for additional information. |
| 429 | * <p> |
| 430 | * This is only intended for use by a {@link Conference}. |
| 431 | */ |
| 432 | public static final int CAPABILITY_SWAP_CONFERENCE = 0x00000008; |
| 433 | |
| 434 | /** |
| 435 | * @hide |
| 436 | */ |
Andrew Lee | 2378ea7 | 2015-04-29 14:38:11 -0700 | [diff] [blame] | 437 | public static final int CAPABILITY_UNUSED_1 = 0x00000010; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 438 | |
| 439 | /** Call supports responding via text option. */ |
| 440 | public static final int CAPABILITY_RESPOND_VIA_TEXT = 0x00000020; |
| 441 | |
| 442 | /** Call can be muted. */ |
| 443 | public static final int CAPABILITY_MUTE = 0x00000040; |
| 444 | |
| 445 | /** |
| 446 | * Call supports conference call management. This capability only applies to {@link Conference} |
| 447 | * calls which can have {@link Connection}s as children. |
| 448 | */ |
| 449 | public static final int CAPABILITY_MANAGE_CONFERENCE = 0x00000080; |
| 450 | |
| 451 | /** |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 452 | * Local device supports receiving video. |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 453 | */ |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 454 | public static final int CAPABILITY_SUPPORTS_VT_LOCAL_RX = 0x00000100; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 455 | |
| 456 | /** |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 457 | * Local device supports transmitting video. |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 458 | */ |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 459 | public static final int CAPABILITY_SUPPORTS_VT_LOCAL_TX = 0x00000200; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 460 | |
| 461 | /** |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 462 | * Local device supports bidirectional video calling. |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 463 | */ |
Andrew Lee | 9a8f9ce | 2015-04-10 18:09:46 -0700 | [diff] [blame] | 464 | public static final int CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL = |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 465 | CAPABILITY_SUPPORTS_VT_LOCAL_RX | CAPABILITY_SUPPORTS_VT_LOCAL_TX; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 466 | |
| 467 | /** |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 468 | * Remote device supports receiving video. |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 469 | */ |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 470 | public static final int CAPABILITY_SUPPORTS_VT_REMOTE_RX = 0x00000400; |
| 471 | |
| 472 | /** |
| 473 | * Remote device supports transmitting video. |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 474 | */ |
| 475 | public static final int CAPABILITY_SUPPORTS_VT_REMOTE_TX = 0x00000800; |
| 476 | |
| 477 | /** |
| 478 | * Remote device supports bidirectional video calling. |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 479 | */ |
Andrew Lee | 9a8f9ce | 2015-04-10 18:09:46 -0700 | [diff] [blame] | 480 | public static final int CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL = |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 481 | CAPABILITY_SUPPORTS_VT_REMOTE_RX | CAPABILITY_SUPPORTS_VT_REMOTE_TX; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 482 | |
| 483 | /** |
| 484 | * Call is able to be separated from its parent {@code Conference}, if any. |
| 485 | */ |
| 486 | public static final int CAPABILITY_SEPARATE_FROM_CONFERENCE = 0x00001000; |
| 487 | |
| 488 | /** |
| 489 | * Call is able to be individually disconnected when in a {@code Conference}. |
| 490 | */ |
| 491 | public static final int CAPABILITY_DISCONNECT_FROM_CONFERENCE = 0x00002000; |
| 492 | |
| 493 | /** |
Dong Zhou | 89f41eb | 2015-03-15 11:59:49 -0500 | [diff] [blame] | 494 | * Speed up audio setup for MT call. |
| 495 | * @hide |
| 496 | */ |
Tyler Gunn | 96d6c40 | 2015-03-18 12:39:23 -0700 | [diff] [blame] | 497 | public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00040000; |
| 498 | |
Tyler Gunn | b5e0cfb | 2015-04-07 16:10:51 -0700 | [diff] [blame] | 499 | /** |
| 500 | * Call can be upgraded to a video call. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 501 | * @hide |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 502 | * @deprecated Use {@link #CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL} and |
| 503 | * {@link #CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL} to indicate for a call |
| 504 | * whether or not video calling is supported. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 505 | */ |
Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 506 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 119305590) |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 507 | public static final int CAPABILITY_CAN_UPGRADE_TO_VIDEO = 0x00080000; |
| 508 | |
Tyler Gunn | b5e0cfb | 2015-04-07 16:10:51 -0700 | [diff] [blame] | 509 | /** |
| 510 | * For video calls, indicates whether the outgoing video for the call can be paused using |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 511 | * the {@link android.telecom.VideoProfile#STATE_PAUSED} VideoState. |
Tyler Gunn | b5e0cfb | 2015-04-07 16:10:51 -0700 | [diff] [blame] | 512 | */ |
| 513 | public static final int CAPABILITY_CAN_PAUSE_VIDEO = 0x00100000; |
| 514 | |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 515 | /** |
| 516 | * Call sends responses through connection. |
| 517 | * @hide |
| 518 | */ |
Tyler Gunn | f97a009 | 2016-01-19 15:59:34 -0800 | [diff] [blame] | 519 | public static final int CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION = 0x00200000; |
| 520 | |
| 521 | /** |
| 522 | * When set, prevents a video {@code Call} from being downgraded to an audio-only call. |
| 523 | * <p> |
| 524 | * Should be set when the VideoState has the {@link VideoProfile#STATE_TX_ENABLED} or |
| 525 | * {@link VideoProfile#STATE_RX_ENABLED} bits set to indicate that the connection cannot be |
| 526 | * downgraded from a video call back to a VideoState of |
| 527 | * {@link VideoProfile#STATE_AUDIO_ONLY}. |
| 528 | * <p> |
| 529 | * Intuitively, a call which can be downgraded to audio should also have local and remote |
| 530 | * video |
| 531 | * capabilities (see {@link #CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL} and |
| 532 | * {@link #CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL}). |
| 533 | */ |
| 534 | public static final int CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO = 0x00400000; |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 535 | |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 536 | /** |
| 537 | * When set for an external call, indicates that this {@code Call} can be pulled from a |
| 538 | * remote device to the current device. |
| 539 | * <p> |
| 540 | * Should only be set on a {@code Call} where {@link #PROPERTY_IS_EXTERNAL_CALL} is set. |
| 541 | * <p> |
| 542 | * An {@link InCallService} will only see calls with this capability if it has the |
| 543 | * {@link TelecomManager#METADATA_INCLUDE_EXTERNAL_CALLS} metadata set to {@code true} |
| 544 | * in its manifest. |
| 545 | * <p> |
| 546 | * See {@link Connection#CAPABILITY_CAN_PULL_CALL} and |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 547 | * {@link Connection#PROPERTY_IS_EXTERNAL_CALL}. |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 548 | */ |
| 549 | public static final int CAPABILITY_CAN_PULL_CALL = 0x00800000; |
| 550 | |
Pooja Jain | d34698d | 2017-12-28 14:15:31 +0530 | [diff] [blame] | 551 | /** Call supports the deflect feature. */ |
| 552 | public static final int CAPABILITY_SUPPORT_DEFLECT = 0x01000000; |
| 553 | |
Tyler Gunn | 0c62ef0 | 2020-02-11 14:39:43 -0800 | [diff] [blame] | 554 | /** |
| 555 | * Call supports adding participants to the call via |
Grace Jia | 8587ee5 | 2020-07-10 15:42:32 -0700 | [diff] [blame] | 556 | * {@link #addConferenceParticipants(List)}. Once participants are added, the call becomes |
| 557 | * an adhoc conference call ({@link #PROPERTY_IS_ADHOC_CONFERENCE}). |
Tyler Gunn | 0c62ef0 | 2020-02-11 14:39:43 -0800 | [diff] [blame] | 558 | */ |
Ravi Paluri | 404babb | 2020-01-23 19:02:44 +0530 | [diff] [blame] | 559 | public static final int CAPABILITY_ADD_PARTICIPANT = 0x02000000; |
Ravi Paluri | f4b38e7 | 2020-02-05 12:35:41 +0530 | [diff] [blame] | 560 | |
| 561 | /** |
| 562 | * When set for a call, indicates that this {@code Call} can be transferred to another |
| 563 | * number. |
Tyler Gunn | 460360d | 2020-07-29 10:21:45 -0700 | [diff] [blame] | 564 | * Call supports the confirmed and unconfirmed call transfer feature. |
Ravi Paluri | f4b38e7 | 2020-02-05 12:35:41 +0530 | [diff] [blame] | 565 | * |
| 566 | * @hide |
| 567 | */ |
| 568 | public static final int CAPABILITY_TRANSFER = 0x04000000; |
| 569 | |
| 570 | /** |
| 571 | * When set for a call, indicates that this {@code Call} can be transferred to another |
| 572 | * ongoing call. |
| 573 | * Call supports the consultative call transfer feature. |
| 574 | * |
| 575 | * @hide |
| 576 | */ |
| 577 | public static final int CAPABILITY_TRANSFER_CONSULTATIVE = 0x08000000; |
| 578 | |
Alvin Dey | 2f37d77 | 2018-05-18 23:16:10 +0530 | [diff] [blame] | 579 | /** |
| 580 | * Indicates whether the remote party supports RTT or not to the UI. |
| 581 | */ |
| 582 | |
| 583 | public static final int CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT = 0x10000000; |
| 584 | |
Tyler Gunn | d11a315 | 2015-03-18 13:09:14 -0700 | [diff] [blame] | 585 | //****************************************************************************************** |
Alvin Dey | 2f37d77 | 2018-05-18 23:16:10 +0530 | [diff] [blame] | 586 | // Next CAPABILITY value: 0x20000000 |
Andrew Lee | 2378ea7 | 2015-04-29 14:38:11 -0700 | [diff] [blame] | 587 | //****************************************************************************************** |
| 588 | |
| 589 | /** |
| 590 | * Whether the call is currently a conference. |
| 591 | */ |
| 592 | public static final int PROPERTY_CONFERENCE = 0x00000001; |
| 593 | |
| 594 | /** |
| 595 | * Whether the call is a generic conference, where we do not know the precise state of |
| 596 | * participants in the conference (eg. on CDMA). |
| 597 | */ |
| 598 | public static final int PROPERTY_GENERIC_CONFERENCE = 0x00000002; |
| 599 | |
| 600 | /** |
| 601 | * Whether the call is made while the device is in emergency callback mode. |
| 602 | */ |
| 603 | public static final int PROPERTY_EMERGENCY_CALLBACK_MODE = 0x00000004; |
| 604 | |
| 605 | /** |
| 606 | * Connection is using WIFI. |
| 607 | */ |
| 608 | public static final int PROPERTY_WIFI = 0x00000008; |
| 609 | |
| 610 | /** |
Tyler Gunn | 6b6ae55 | 2018-10-11 10:42:10 -0700 | [diff] [blame] | 611 | * When set, the UI should indicate to the user that a call is using high definition |
| 612 | * audio. |
| 613 | * <p> |
| 614 | * The underlying {@link ConnectionService} is responsible for reporting this |
| 615 | * property. It is important to note that this property is not intended to report the |
| 616 | * actual audio codec being used for a Call, but whether the call should be indicated |
| 617 | * to the user as high definition. |
| 618 | * <p> |
| 619 | * The Android Telephony stack reports this property for calls based on a number |
| 620 | * of factors, including which audio codec is used and whether a call is using an HD |
| 621 | * codec end-to-end. Some mobile operators choose to suppress display of an HD indication, |
| 622 | * and in these cases this property will not be set for a call even if the underlying audio |
| 623 | * codec is in fact "high definition". |
Andrew Lee | 2378ea7 | 2015-04-29 14:38:11 -0700 | [diff] [blame] | 624 | */ |
| 625 | public static final int PROPERTY_HIGH_DEF_AUDIO = 0x00000010; |
| 626 | |
Tony Mak | a68dcce | 2015-12-17 09:31:18 +0000 | [diff] [blame] | 627 | /** |
Tony Mak | 53b5df4 | 2016-05-19 13:40:38 +0100 | [diff] [blame] | 628 | * Whether the call is associated with the work profile. |
| 629 | */ |
| 630 | public static final int PROPERTY_ENTERPRISE_CALL = 0x00000020; |
| 631 | |
| 632 | /** |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 633 | * When set, indicates that this {@code Call} does not actually exist locally for the |
| 634 | * {@link ConnectionService}. |
| 635 | * <p> |
| 636 | * Consider, for example, a scenario where a user has two phones with the same phone number. |
| 637 | * When a user places a call on one device, the telephony stack can represent that call on |
| 638 | * the other device by adding it to the {@link ConnectionService} with the |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 639 | * {@link Connection#PROPERTY_IS_EXTERNAL_CALL} property set. |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 640 | * <p> |
| 641 | * An {@link InCallService} will only see calls with this property if it has the |
| 642 | * {@link TelecomManager#METADATA_INCLUDE_EXTERNAL_CALLS} metadata set to {@code true} |
| 643 | * in its manifest. |
| 644 | * <p> |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 645 | * See {@link Connection#PROPERTY_IS_EXTERNAL_CALL}. |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 646 | */ |
| 647 | public static final int PROPERTY_IS_EXTERNAL_CALL = 0x00000040; |
| 648 | |
Brad Ebinger | 1584707 | 2016-05-18 11:08:36 -0700 | [diff] [blame] | 649 | /** |
| 650 | * Indicates that the call has CDMA Enhanced Voice Privacy enabled. |
| 651 | */ |
| 652 | public static final int PROPERTY_HAS_CDMA_VOICE_PRIVACY = 0x00000080; |
| 653 | |
Tyler Gunn | 24e1833 | 2017-02-10 09:42:49 -0800 | [diff] [blame] | 654 | /** |
| 655 | * Indicates that the call is from a self-managed {@link ConnectionService}. |
| 656 | * <p> |
| 657 | * See also {@link Connection#PROPERTY_SELF_MANAGED} |
| 658 | */ |
| 659 | public static final int PROPERTY_SELF_MANAGED = 0x00000100; |
| 660 | |
Eric Erfanian | ec88187 | 2017-12-06 16:27:53 -0800 | [diff] [blame] | 661 | /** |
| 662 | * Indicates the call used Assisted Dialing. |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 663 | * |
| 664 | * @see TelecomManager#EXTRA_USE_ASSISTED_DIALING |
Eric Erfanian | ec88187 | 2017-12-06 16:27:53 -0800 | [diff] [blame] | 665 | */ |
Tyler Gunn | c9503d6 | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 666 | public static final int PROPERTY_ASSISTED_DIALING = 0x00000200; |
Eric Erfanian | ec88187 | 2017-12-06 16:27:53 -0800 | [diff] [blame] | 667 | |
Hall Liu | e904124 | 2018-02-09 16:40:03 -0800 | [diff] [blame] | 668 | /** |
| 669 | * Indicates that the call is an RTT call. Use {@link #getRttCall()} to get the |
| 670 | * {@link RttCall} object that is used to send and receive text. |
| 671 | */ |
| 672 | public static final int PROPERTY_RTT = 0x00000400; |
| 673 | |
Tyler Gunn | 5bd9085 | 2018-09-21 09:37:07 -0700 | [diff] [blame] | 674 | /** |
| 675 | * Indicates that the call has been identified as the network as an emergency call. This |
| 676 | * property may be set for both incoming and outgoing calls which the network identifies as |
| 677 | * emergency calls. |
| 678 | */ |
| 679 | public static final int PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL = 0x00000800; |
| 680 | |
Tyler Gunn | 80a5e1e | 2018-06-22 15:52:27 -0700 | [diff] [blame] | 681 | /** |
| 682 | * Indicates that the call is using VoIP audio mode. |
| 683 | * <p> |
| 684 | * When this property is set, the {@link android.media.AudioManager} audio mode for this |
| 685 | * call will be {@link android.media.AudioManager#MODE_IN_COMMUNICATION}. When this |
| 686 | * property is not set, the audio mode for this call will be |
| 687 | * {@link android.media.AudioManager#MODE_IN_CALL}. |
| 688 | * <p> |
| 689 | * This property reflects changes made using {@link Connection#setAudioModeIsVoip(boolean)}. |
| 690 | * <p> |
| 691 | * You can use this property to determine whether an un-answered incoming call or a held |
| 692 | * call will use VoIP audio mode (if the call does not currently have focus, the system |
| 693 | * audio mode may not reflect the mode the call will use). |
| 694 | */ |
| 695 | public static final int PROPERTY_VOIP_AUDIO_MODE = 0x00001000; |
| 696 | |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 697 | /** |
| 698 | * Indicates that the call is an adhoc conference call. This property can be set for both |
Grace Jia | 8587ee5 | 2020-07-10 15:42:32 -0700 | [diff] [blame] | 699 | * incoming and outgoing calls. An adhoc conference call is formed using |
| 700 | * {@link #addConferenceParticipants(List)}, |
| 701 | * {@link TelecomManager#addNewIncomingConference(PhoneAccountHandle, Bundle)}, or |
| 702 | * {@link TelecomManager#startConference(List, Bundle)}, rather than by merging existing |
| 703 | * call using {@link #conference(Call)}. |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 704 | */ |
| 705 | public static final int PROPERTY_IS_ADHOC_CONFERENCE = 0x00002000; |
| 706 | |
Sooraj Sasindran | 64f05b1 | 2020-11-18 12:07:10 -0800 | [diff] [blame] | 707 | /** |
Sooraj Sasindran | fa1e57a | 2021-03-22 13:44:14 -0700 | [diff] [blame] | 708 | * Connection is using cross sim technology. |
| 709 | * <p> |
| 710 | * Indicates that the {@link Connection} is using a cross sim technology which would |
| 711 | * register IMS over internet APN of default data subscription. |
| 712 | * <p> |
Sooraj Sasindran | 64f05b1 | 2020-11-18 12:07:10 -0800 | [diff] [blame] | 713 | */ |
| 714 | public static final int PROPERTY_CROSS_SIM = 0x00004000; |
| 715 | |
Andrew Lee | 2378ea7 | 2015-04-29 14:38:11 -0700 | [diff] [blame] | 716 | //****************************************************************************************** |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 717 | // Next PROPERTY value: 0x00004000 |
Tyler Gunn | d11a315 | 2015-03-18 13:09:14 -0700 | [diff] [blame] | 718 | //****************************************************************************************** |
Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 719 | |
Tyler Gunn | 1e406ca | 2021-03-18 16:47:14 -0700 | [diff] [blame] | 720 | private final @CallState int mState; |
Sailesh Nepal | 1bef339 | 2016-01-24 18:21:53 -0800 | [diff] [blame] | 721 | private final String mTelecomCallId; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 722 | private final Uri mHandle; |
| 723 | private final int mHandlePresentation; |
| 724 | private final String mCallerDisplayName; |
| 725 | private final int mCallerDisplayNamePresentation; |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 726 | private final PhoneAccountHandle mAccountHandle; |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 727 | private final int mCallCapabilities; |
Andrew Lee | 223ad14 | 2014-08-27 16:33:08 -0700 | [diff] [blame] | 728 | private final int mCallProperties; |
Christine Hallstrom | 4e22d6d | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 729 | private final int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 730 | private final DisconnectCause mDisconnectCause; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 731 | private final long mConnectTimeMillis; |
| 732 | private final GatewayInfo mGatewayInfo; |
Andrew Lee | 85f5d42 | 2014-07-11 17:22:03 -0700 | [diff] [blame] | 733 | private final int mVideoState; |
Evan Charlton | 5b49ade | 2014-07-15 17:03:20 -0700 | [diff] [blame] | 734 | private final StatusHints mStatusHints; |
Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 735 | private final Bundle mExtras; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 736 | private final Bundle mIntentExtras; |
Tyler Gunn | c0bf6de | 2017-03-17 11:27:09 -0700 | [diff] [blame] | 737 | private final long mCreationTimeMillis; |
Hall Liu | ef98bf8 | 2020-01-09 15:22:44 -0800 | [diff] [blame] | 738 | private final String mContactDisplayName; |
Tyler Gunn | 94f8f11 | 2018-12-17 09:56:11 -0800 | [diff] [blame] | 739 | private final @CallDirection int mCallDirection; |
Tyler Gunn | d57d76c | 2019-09-24 14:53:23 -0700 | [diff] [blame] | 740 | private final @Connection.VerificationStatus int mCallerNumberVerificationStatus; |
Edgar Arriaga | e5bec82 | 2022-10-14 14:25:43 -0700 | [diff] [blame^] | 741 | private final Uri mContactPhotoUri; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 742 | |
| 743 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 744 | * Whether the supplied capabilities supports the specified capability. |
| 745 | * |
| 746 | * @param capabilities A bit field of capabilities. |
| 747 | * @param capability The capability to check capabilities for. |
| 748 | * @return Whether the specified capability is supported. |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 749 | */ |
| 750 | public static boolean can(int capabilities, int capability) { |
Tyler Gunn | 014c711 | 2015-12-18 14:33:57 -0800 | [diff] [blame] | 751 | return (capabilities & capability) == capability; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 752 | } |
| 753 | |
| 754 | /** |
| 755 | * Whether the capabilities of this {@code Details} supports the specified capability. |
| 756 | * |
| 757 | * @param capability The capability to check capabilities for. |
| 758 | * @return Whether the specified capability is supported. |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 759 | */ |
| 760 | public boolean can(int capability) { |
| 761 | return can(mCallCapabilities, capability); |
| 762 | } |
| 763 | |
| 764 | /** |
| 765 | * Render a set of capability bits ({@code CAPABILITY_*}) as a human readable string. |
| 766 | * |
| 767 | * @param capabilities A capability bit field. |
| 768 | * @return A human readable string representation. |
| 769 | */ |
| 770 | public static String capabilitiesToString(int capabilities) { |
| 771 | StringBuilder builder = new StringBuilder(); |
| 772 | builder.append("[Capabilities:"); |
| 773 | if (can(capabilities, CAPABILITY_HOLD)) { |
| 774 | builder.append(" CAPABILITY_HOLD"); |
| 775 | } |
| 776 | if (can(capabilities, CAPABILITY_SUPPORT_HOLD)) { |
| 777 | builder.append(" CAPABILITY_SUPPORT_HOLD"); |
| 778 | } |
| 779 | if (can(capabilities, CAPABILITY_MERGE_CONFERENCE)) { |
| 780 | builder.append(" CAPABILITY_MERGE_CONFERENCE"); |
| 781 | } |
| 782 | if (can(capabilities, CAPABILITY_SWAP_CONFERENCE)) { |
| 783 | builder.append(" CAPABILITY_SWAP_CONFERENCE"); |
| 784 | } |
| 785 | if (can(capabilities, CAPABILITY_RESPOND_VIA_TEXT)) { |
| 786 | builder.append(" CAPABILITY_RESPOND_VIA_TEXT"); |
| 787 | } |
| 788 | if (can(capabilities, CAPABILITY_MUTE)) { |
| 789 | builder.append(" CAPABILITY_MUTE"); |
| 790 | } |
| 791 | if (can(capabilities, CAPABILITY_MANAGE_CONFERENCE)) { |
| 792 | builder.append(" CAPABILITY_MANAGE_CONFERENCE"); |
| 793 | } |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 794 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_RX)) { |
| 795 | builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_RX"); |
| 796 | } |
| 797 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_TX)) { |
| 798 | builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_TX"); |
| 799 | } |
Andrew Lee | 9a8f9ce | 2015-04-10 18:09:46 -0700 | [diff] [blame] | 800 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL)) { |
| 801 | builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL"); |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 802 | } |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 803 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_RX)) { |
| 804 | builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_RX"); |
| 805 | } |
| 806 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_TX)) { |
| 807 | builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_TX"); |
| 808 | } |
Tyler Gunn | f97a009 | 2016-01-19 15:59:34 -0800 | [diff] [blame] | 809 | if (can(capabilities, CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO)) { |
| 810 | builder.append(" CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO"); |
| 811 | } |
Andrew Lee | 9a8f9ce | 2015-04-10 18:09:46 -0700 | [diff] [blame] | 812 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL)) { |
| 813 | builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL"); |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 814 | } |
Dong Zhou | 89f41eb | 2015-03-15 11:59:49 -0500 | [diff] [blame] | 815 | if (can(capabilities, CAPABILITY_SPEED_UP_MT_AUDIO)) { |
Tyler Gunn | d11a315 | 2015-03-18 13:09:14 -0700 | [diff] [blame] | 816 | builder.append(" CAPABILITY_SPEED_UP_MT_AUDIO"); |
Dong Zhou | 89f41eb | 2015-03-15 11:59:49 -0500 | [diff] [blame] | 817 | } |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 818 | if (can(capabilities, CAPABILITY_CAN_UPGRADE_TO_VIDEO)) { |
| 819 | builder.append(" CAPABILITY_CAN_UPGRADE_TO_VIDEO"); |
| 820 | } |
Tyler Gunn | b5e0cfb | 2015-04-07 16:10:51 -0700 | [diff] [blame] | 821 | if (can(capabilities, CAPABILITY_CAN_PAUSE_VIDEO)) { |
| 822 | builder.append(" CAPABILITY_CAN_PAUSE_VIDEO"); |
| 823 | } |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 824 | if (can(capabilities, CAPABILITY_CAN_PULL_CALL)) { |
| 825 | builder.append(" CAPABILITY_CAN_PULL_CALL"); |
| 826 | } |
Pooja Jain | d34698d | 2017-12-28 14:15:31 +0530 | [diff] [blame] | 827 | if (can(capabilities, CAPABILITY_SUPPORT_DEFLECT)) { |
| 828 | builder.append(" CAPABILITY_SUPPORT_DEFLECT"); |
| 829 | } |
Ravi Paluri | 404babb | 2020-01-23 19:02:44 +0530 | [diff] [blame] | 830 | if (can(capabilities, CAPABILITY_ADD_PARTICIPANT)) { |
| 831 | builder.append(" CAPABILITY_ADD_PARTICIPANT"); |
| 832 | } |
Ravi Paluri | f4b38e7 | 2020-02-05 12:35:41 +0530 | [diff] [blame] | 833 | if (can(capabilities, CAPABILITY_TRANSFER)) { |
| 834 | builder.append(" CAPABILITY_TRANSFER"); |
| 835 | } |
| 836 | if (can(capabilities, CAPABILITY_TRANSFER_CONSULTATIVE)) { |
| 837 | builder.append(" CAPABILITY_TRANSFER_CONSULTATIVE"); |
| 838 | } |
Alvin Dey | 2f37d77 | 2018-05-18 23:16:10 +0530 | [diff] [blame] | 839 | if (can(capabilities, CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT)) { |
| 840 | builder.append(" CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT"); |
| 841 | } |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 842 | builder.append("]"); |
| 843 | return builder.toString(); |
| 844 | } |
| 845 | |
| 846 | /** |
Andrew Lee | 2378ea7 | 2015-04-29 14:38:11 -0700 | [diff] [blame] | 847 | * Whether the supplied properties includes the specified property. |
| 848 | * |
| 849 | * @param properties A bit field of properties. |
| 850 | * @param property The property to check properties for. |
| 851 | * @return Whether the specified property is supported. |
| 852 | */ |
| 853 | public static boolean hasProperty(int properties, int property) { |
Tyler Gunn | 014c711 | 2015-12-18 14:33:57 -0800 | [diff] [blame] | 854 | return (properties & property) == property; |
Andrew Lee | 2378ea7 | 2015-04-29 14:38:11 -0700 | [diff] [blame] | 855 | } |
| 856 | |
| 857 | /** |
| 858 | * Whether the properties of this {@code Details} includes the specified property. |
| 859 | * |
| 860 | * @param property The property to check properties for. |
| 861 | * @return Whether the specified property is supported. |
| 862 | */ |
| 863 | public boolean hasProperty(int property) { |
| 864 | return hasProperty(mCallProperties, property); |
| 865 | } |
| 866 | |
| 867 | /** |
| 868 | * Render a set of property bits ({@code PROPERTY_*}) as a human readable string. |
| 869 | * |
| 870 | * @param properties A property bit field. |
| 871 | * @return A human readable string representation. |
| 872 | */ |
| 873 | public static String propertiesToString(int properties) { |
| 874 | StringBuilder builder = new StringBuilder(); |
| 875 | builder.append("[Properties:"); |
| 876 | if (hasProperty(properties, PROPERTY_CONFERENCE)) { |
| 877 | builder.append(" PROPERTY_CONFERENCE"); |
| 878 | } |
| 879 | if (hasProperty(properties, PROPERTY_GENERIC_CONFERENCE)) { |
| 880 | builder.append(" PROPERTY_GENERIC_CONFERENCE"); |
| 881 | } |
| 882 | if (hasProperty(properties, PROPERTY_WIFI)) { |
| 883 | builder.append(" PROPERTY_WIFI"); |
| 884 | } |
| 885 | if (hasProperty(properties, PROPERTY_HIGH_DEF_AUDIO)) { |
| 886 | builder.append(" PROPERTY_HIGH_DEF_AUDIO"); |
| 887 | } |
| 888 | if (hasProperty(properties, PROPERTY_EMERGENCY_CALLBACK_MODE)) { |
Yorke Lee | be2a4a2 | 2015-06-12 10:10:55 -0700 | [diff] [blame] | 889 | builder.append(" PROPERTY_EMERGENCY_CALLBACK_MODE"); |
Andrew Lee | 2378ea7 | 2015-04-29 14:38:11 -0700 | [diff] [blame] | 890 | } |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 891 | if (hasProperty(properties, PROPERTY_IS_EXTERNAL_CALL)) { |
| 892 | builder.append(" PROPERTY_IS_EXTERNAL_CALL"); |
| 893 | } |
Tyler Gunn | 80a5e1e | 2018-06-22 15:52:27 -0700 | [diff] [blame] | 894 | if (hasProperty(properties, PROPERTY_HAS_CDMA_VOICE_PRIVACY)) { |
Brad Ebinger | 1584707 | 2016-05-18 11:08:36 -0700 | [diff] [blame] | 895 | builder.append(" PROPERTY_HAS_CDMA_VOICE_PRIVACY"); |
| 896 | } |
Tyler Gunn | c9503d6 | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 897 | if (hasProperty(properties, PROPERTY_ASSISTED_DIALING)) { |
Eric Erfanian | ec88187 | 2017-12-06 16:27:53 -0800 | [diff] [blame] | 898 | builder.append(" PROPERTY_ASSISTED_DIALING_USED"); |
| 899 | } |
Tyler Gunn | 5bd9085 | 2018-09-21 09:37:07 -0700 | [diff] [blame] | 900 | if (hasProperty(properties, PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL)) { |
| 901 | builder.append(" PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL"); |
| 902 | } |
Tyler Gunn | 80a5e1e | 2018-06-22 15:52:27 -0700 | [diff] [blame] | 903 | if (hasProperty(properties, PROPERTY_RTT)) { |
| 904 | builder.append(" PROPERTY_RTT"); |
| 905 | } |
| 906 | if (hasProperty(properties, PROPERTY_VOIP_AUDIO_MODE)) { |
| 907 | builder.append(" PROPERTY_VOIP_AUDIO_MODE"); |
| 908 | } |
Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 909 | if (hasProperty(properties, PROPERTY_IS_ADHOC_CONFERENCE)) { |
| 910 | builder.append(" PROPERTY_IS_ADHOC_CONFERENCE"); |
| 911 | } |
Sooraj Sasindran | 64f05b1 | 2020-11-18 12:07:10 -0800 | [diff] [blame] | 912 | if (hasProperty(properties, PROPERTY_CROSS_SIM)) { |
| 913 | builder.append(" PROPERTY_CROSS_SIM"); |
| 914 | } |
Andrew Lee | 2378ea7 | 2015-04-29 14:38:11 -0700 | [diff] [blame] | 915 | builder.append("]"); |
| 916 | return builder.toString(); |
| 917 | } |
| 918 | |
Tyler Gunn | 1e406ca | 2021-03-18 16:47:14 -0700 | [diff] [blame] | 919 | /** |
| 920 | * @return the state of the {@link Call} represented by this {@link Call.Details}. |
| 921 | */ |
| 922 | public final @CallState int getState() { |
| 923 | return mState; |
| 924 | } |
| 925 | |
Sailesh Nepal | 1bef339 | 2016-01-24 18:21:53 -0800 | [diff] [blame] | 926 | /** {@hide} */ |
Hall Liu | 31de23d | 2019-10-11 15:38:29 -0700 | [diff] [blame] | 927 | @TestApi |
Sailesh Nepal | 1bef339 | 2016-01-24 18:21:53 -0800 | [diff] [blame] | 928 | public String getTelecomCallId() { |
| 929 | return mTelecomCallId; |
| 930 | } |
| 931 | |
Andrew Lee | 2378ea7 | 2015-04-29 14:38:11 -0700 | [diff] [blame] | 932 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 933 | * @return The handle (e.g., phone number) to which the {@code Call} is currently |
| 934 | * connected. |
| 935 | */ |
| 936 | public Uri getHandle() { |
| 937 | return mHandle; |
| 938 | } |
| 939 | |
| 940 | /** |
| 941 | * @return The presentation requirements for the handle. See |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 942 | * {@link TelecomManager} for valid values. |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 943 | */ |
| 944 | public int getHandlePresentation() { |
| 945 | return mHandlePresentation; |
| 946 | } |
| 947 | |
| 948 | /** |
Edgar Arriaga | e5bec82 | 2022-10-14 14:25:43 -0700 | [diff] [blame^] | 949 | * @return The contact photo URI which corresponds to |
| 950 | * {@link android.provider.ContactsContract.PhoneLookup#PHOTO_URI}, or {@code null} if the |
| 951 | * lookup is not yet complete, if there's no contacts entry for the caller, |
| 952 | * or if the {@link InCallService} does not hold the |
| 953 | * {@link android.Manifest.permission#READ_CONTACTS} permission. |
| 954 | */ |
| 955 | public @Nullable Uri getContactPhotoUri() { |
| 956 | return mContactPhotoUri; |
| 957 | } |
| 958 | |
| 959 | /** |
Tyler Gunn | d081f04 | 2018-12-04 12:56:45 -0800 | [diff] [blame] | 960 | * The display name for the caller. |
| 961 | * <p> |
| 962 | * This is the name as reported by the {@link ConnectionService} associated with this call. |
Tyler Gunn | d081f04 | 2018-12-04 12:56:45 -0800 | [diff] [blame] | 963 | * |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 964 | * @return The display name for the caller. |
| 965 | */ |
| 966 | public String getCallerDisplayName() { |
| 967 | return mCallerDisplayName; |
| 968 | } |
| 969 | |
| 970 | /** |
| 971 | * @return The presentation requirements for the caller display name. See |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 972 | * {@link TelecomManager} for valid values. |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 973 | */ |
| 974 | public int getCallerDisplayNamePresentation() { |
| 975 | return mCallerDisplayNamePresentation; |
| 976 | } |
| 977 | |
| 978 | /** |
Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 979 | * @return The {@code PhoneAccountHandle} whereby the {@code Call} is currently being |
| 980 | * routed. |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 981 | */ |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 982 | public PhoneAccountHandle getAccountHandle() { |
| 983 | return mAccountHandle; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 984 | } |
| 985 | |
| 986 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 987 | * @return A bitmask of the capabilities of the {@code Call}, as defined by the various |
| 988 | * {@code CAPABILITY_*} constants in this class. |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 989 | */ |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 990 | public int getCallCapabilities() { |
| 991 | return mCallCapabilities; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 992 | } |
| 993 | |
| 994 | /** |
Andrew Lee | 2378ea7 | 2015-04-29 14:38:11 -0700 | [diff] [blame] | 995 | * @return A bitmask of the properties of the {@code Call}, as defined by the various |
| 996 | * {@code PROPERTY_*} constants in this class. |
Andrew Lee | 223ad14 | 2014-08-27 16:33:08 -0700 | [diff] [blame] | 997 | */ |
| 998 | public int getCallProperties() { |
| 999 | return mCallProperties; |
| 1000 | } |
| 1001 | |
| 1002 | /** |
Christine Hallstrom | 4e22d6d | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 1003 | * @return a bitmask of the audio routes available for the call. |
| 1004 | * |
| 1005 | * @hide |
| 1006 | */ |
| 1007 | public int getSupportedAudioRoutes() { |
| 1008 | return mSupportedAudioRoutes; |
| 1009 | } |
| 1010 | |
| 1011 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1012 | * @return For a {@link #STATE_DISCONNECTED} {@code Call}, the disconnect cause expressed |
Nancy Chen | f4cf77c | 2014-09-19 10:53:21 -0700 | [diff] [blame] | 1013 | * by {@link android.telecom.DisconnectCause}. |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1014 | */ |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1015 | public DisconnectCause getDisconnectCause() { |
| 1016 | return mDisconnectCause; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1017 | } |
| 1018 | |
| 1019 | /** |
Tyler Gunn | c0bf6de | 2017-03-17 11:27:09 -0700 | [diff] [blame] | 1020 | * Returns the time the {@link Call} connected (i.e. became active). This information is |
| 1021 | * updated periodically, but user interfaces should not rely on this to display the "call |
| 1022 | * time clock". For the time when the call was first added to Telecom, see |
| 1023 | * {@link #getCreationTimeMillis()}. |
| 1024 | * |
| 1025 | * @return The time the {@link Call} connected in milliseconds since the epoch. |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1026 | */ |
Jay Shrauner | 164a0ac | 2015-04-14 18:16:10 -0700 | [diff] [blame] | 1027 | public final long getConnectTimeMillis() { |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1028 | return mConnectTimeMillis; |
| 1029 | } |
| 1030 | |
| 1031 | /** |
| 1032 | * @return Information about any calling gateway the {@code Call} may be using. |
| 1033 | */ |
| 1034 | public GatewayInfo getGatewayInfo() { |
| 1035 | return mGatewayInfo; |
| 1036 | } |
| 1037 | |
Andrew Lee | 7a34138 | 2014-07-15 17:05:08 -0700 | [diff] [blame] | 1038 | /** |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 1039 | * @return The video state of the {@code Call}. |
Andrew Lee | 7a34138 | 2014-07-15 17:05:08 -0700 | [diff] [blame] | 1040 | */ |
| 1041 | public int getVideoState() { |
| 1042 | return mVideoState; |
| 1043 | } |
| 1044 | |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 1045 | /** |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1046 | * @return The current {@link android.telecom.StatusHints}, or {@code null} if none |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 1047 | * have been set. |
Evan Charlton | 5b49ade | 2014-07-15 17:03:20 -0700 | [diff] [blame] | 1048 | */ |
| 1049 | public StatusHints getStatusHints() { |
| 1050 | return mStatusHints; |
| 1051 | } |
| 1052 | |
Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 1053 | /** |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1054 | * @return The extras associated with this call. |
Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 1055 | */ |
| 1056 | public Bundle getExtras() { |
| 1057 | return mExtras; |
| 1058 | } |
| 1059 | |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1060 | /** |
| 1061 | * @return The extras used with the original intent to place this call. |
| 1062 | */ |
| 1063 | public Bundle getIntentExtras() { |
| 1064 | return mIntentExtras; |
| 1065 | } |
| 1066 | |
Tyler Gunn | c0bf6de | 2017-03-17 11:27:09 -0700 | [diff] [blame] | 1067 | /** |
| 1068 | * Returns the time when the call was first created and added to Telecom. This is the same |
| 1069 | * time that is logged as the start time in the Call Log (see |
| 1070 | * {@link android.provider.CallLog.Calls#DATE}). To determine when the call was connected |
| 1071 | * (became active), see {@link #getConnectTimeMillis()}. |
| 1072 | * |
| 1073 | * @return The creation time of the call, in millis since the epoch. |
| 1074 | */ |
| 1075 | public long getCreationTimeMillis() { |
| 1076 | return mCreationTimeMillis; |
| 1077 | } |
| 1078 | |
Tyler Gunn | d081f04 | 2018-12-04 12:56:45 -0800 | [diff] [blame] | 1079 | /** |
Hall Liu | ef98bf8 | 2020-01-09 15:22:44 -0800 | [diff] [blame] | 1080 | * Returns the name of the caller on the remote end, as derived from a |
| 1081 | * {@link android.provider.ContactsContract} lookup of the call's handle. |
| 1082 | * @return The name of the caller, or {@code null} if the lookup is not yet complete, if |
| 1083 | * there's no contacts entry for the caller, or if the {@link InCallService} does |
| 1084 | * not hold the {@link android.Manifest.permission#READ_CONTACTS} permission. |
| 1085 | */ |
| 1086 | public @Nullable String getContactDisplayName() { |
| 1087 | return mContactDisplayName; |
| 1088 | } |
| 1089 | |
| 1090 | /** |
Tyler Gunn | 94f8f11 | 2018-12-17 09:56:11 -0800 | [diff] [blame] | 1091 | * Indicates whether the call is an incoming or outgoing call. |
| 1092 | * @return The call's direction. |
| 1093 | */ |
| 1094 | public @CallDirection int getCallDirection() { |
| 1095 | return mCallDirection; |
| 1096 | } |
| 1097 | |
Tyler Gunn | d57d76c | 2019-09-24 14:53:23 -0700 | [diff] [blame] | 1098 | /** |
| 1099 | * Gets the verification status for the phone number of an incoming call as identified in |
| 1100 | * ATIS-1000082. |
Tyler Gunn | 9c64249 | 2020-10-08 13:37:03 -0700 | [diff] [blame] | 1101 | * <p> |
| 1102 | * For incoming calls, the number verification status indicates whether the device was |
| 1103 | * able to verify the authenticity of the calling number using the STIR process outlined |
| 1104 | * in ATIS-1000082. {@link Connection#VERIFICATION_STATUS_NOT_VERIFIED} indicates that |
| 1105 | * the network was not able to use STIR to verify the caller's number (i.e. nothing is |
| 1106 | * known regarding the authenticity of the number. |
| 1107 | * {@link Connection#VERIFICATION_STATUS_PASSED} indicates that the network was able to |
| 1108 | * use STIR to verify the caller's number. This indicates that the network has a high |
| 1109 | * degree of confidence that the incoming call actually originated from the indicated |
| 1110 | * number. {@link Connection#VERIFICATION_STATUS_FAILED} indicates that the network's |
| 1111 | * STIR verification did not pass. This indicates that the incoming call may not |
| 1112 | * actually be from the indicated number. This could occur if, for example, the caller |
| 1113 | * is using an impersonated phone number. |
| 1114 | * <p> |
| 1115 | * A {@link CallScreeningService} can use this information to help determine if an |
| 1116 | * incoming call is potentially an unwanted call. A verification status of |
| 1117 | * {@link Connection#VERIFICATION_STATUS_FAILED} indicates that an incoming call may not |
| 1118 | * actually be from the number indicated on the call (i.e. impersonated number) and that it |
| 1119 | * should potentially be blocked. Likewise, |
| 1120 | * {@link Connection#VERIFICATION_STATUS_PASSED} can be used as a positive signal to |
| 1121 | * help clarify that the incoming call is originating from the indicated number and it |
| 1122 | * is less likely to be an undesirable call. |
| 1123 | * <p> |
| 1124 | * An {@link InCallService} can use this information to provide a visual indicator to the |
| 1125 | * user regarding the verification status of a call and to help identify calls from |
| 1126 | * potentially impersonated numbers. |
Tyler Gunn | d57d76c | 2019-09-24 14:53:23 -0700 | [diff] [blame] | 1127 | * @return the verification status. |
| 1128 | */ |
| 1129 | public @Connection.VerificationStatus int getCallerNumberVerificationStatus() { |
| 1130 | return mCallerNumberVerificationStatus; |
| 1131 | } |
| 1132 | |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1133 | @Override |
| 1134 | public boolean equals(Object o) { |
| 1135 | if (o instanceof Details) { |
| 1136 | Details d = (Details) o; |
| 1137 | return |
Tyler Gunn | 1e406ca | 2021-03-18 16:47:14 -0700 | [diff] [blame] | 1138 | Objects.equals(mState, d.mState) && |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1139 | Objects.equals(mHandle, d.mHandle) && |
| 1140 | Objects.equals(mHandlePresentation, d.mHandlePresentation) && |
| 1141 | Objects.equals(mCallerDisplayName, d.mCallerDisplayName) && |
| 1142 | Objects.equals(mCallerDisplayNamePresentation, |
| 1143 | d.mCallerDisplayNamePresentation) && |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1144 | Objects.equals(mAccountHandle, d.mAccountHandle) && |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 1145 | Objects.equals(mCallCapabilities, d.mCallCapabilities) && |
Andrew Lee | 223ad14 | 2014-08-27 16:33:08 -0700 | [diff] [blame] | 1146 | Objects.equals(mCallProperties, d.mCallProperties) && |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1147 | Objects.equals(mDisconnectCause, d.mDisconnectCause) && |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1148 | Objects.equals(mConnectTimeMillis, d.mConnectTimeMillis) && |
Andrew Lee | 85f5d42 | 2014-07-11 17:22:03 -0700 | [diff] [blame] | 1149 | Objects.equals(mGatewayInfo, d.mGatewayInfo) && |
Evan Charlton | 5b49ade | 2014-07-15 17:03:20 -0700 | [diff] [blame] | 1150 | Objects.equals(mVideoState, d.mVideoState) && |
Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 1151 | Objects.equals(mStatusHints, d.mStatusHints) && |
Tyler Gunn | 1e9bfc6 | 2015-08-19 11:18:58 -0700 | [diff] [blame] | 1152 | areBundlesEqual(mExtras, d.mExtras) && |
Tyler Gunn | c0bf6de | 2017-03-17 11:27:09 -0700 | [diff] [blame] | 1153 | areBundlesEqual(mIntentExtras, d.mIntentExtras) && |
Tyler Gunn | d081f04 | 2018-12-04 12:56:45 -0800 | [diff] [blame] | 1154 | Objects.equals(mCreationTimeMillis, d.mCreationTimeMillis) && |
Hall Liu | ef98bf8 | 2020-01-09 15:22:44 -0800 | [diff] [blame] | 1155 | Objects.equals(mContactDisplayName, d.mContactDisplayName) && |
Tyler Gunn | d57d76c | 2019-09-24 14:53:23 -0700 | [diff] [blame] | 1156 | Objects.equals(mCallDirection, d.mCallDirection) && |
| 1157 | Objects.equals(mCallerNumberVerificationStatus, |
Edgar Arriaga | e5bec82 | 2022-10-14 14:25:43 -0700 | [diff] [blame^] | 1158 | d.mCallerNumberVerificationStatus) && |
| 1159 | Objects.equals(mContactPhotoUri, d.mContactPhotoUri); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1160 | } |
| 1161 | return false; |
| 1162 | } |
| 1163 | |
| 1164 | @Override |
| 1165 | public int hashCode() { |
Tyler Gunn | 1e406ca | 2021-03-18 16:47:14 -0700 | [diff] [blame] | 1166 | return Objects.hash(mState, |
| 1167 | mHandle, |
Tyler Gunn | c0bf6de | 2017-03-17 11:27:09 -0700 | [diff] [blame] | 1168 | mHandlePresentation, |
| 1169 | mCallerDisplayName, |
| 1170 | mCallerDisplayNamePresentation, |
| 1171 | mAccountHandle, |
| 1172 | mCallCapabilities, |
| 1173 | mCallProperties, |
| 1174 | mDisconnectCause, |
| 1175 | mConnectTimeMillis, |
| 1176 | mGatewayInfo, |
| 1177 | mVideoState, |
| 1178 | mStatusHints, |
| 1179 | mExtras, |
| 1180 | mIntentExtras, |
Tyler Gunn | d081f04 | 2018-12-04 12:56:45 -0800 | [diff] [blame] | 1181 | mCreationTimeMillis, |
Hall Liu | ef98bf8 | 2020-01-09 15:22:44 -0800 | [diff] [blame] | 1182 | mContactDisplayName, |
Tyler Gunn | d57d76c | 2019-09-24 14:53:23 -0700 | [diff] [blame] | 1183 | mCallDirection, |
Edgar Arriaga | e5bec82 | 2022-10-14 14:25:43 -0700 | [diff] [blame^] | 1184 | mCallerNumberVerificationStatus, |
| 1185 | mContactPhotoUri); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1186 | } |
| 1187 | |
| 1188 | /** {@hide} */ |
| 1189 | public Details( |
Tyler Gunn | 1e406ca | 2021-03-18 16:47:14 -0700 | [diff] [blame] | 1190 | @CallState int state, |
Sailesh Nepal | 1bef339 | 2016-01-24 18:21:53 -0800 | [diff] [blame] | 1191 | String telecomCallId, |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1192 | Uri handle, |
| 1193 | int handlePresentation, |
| 1194 | String callerDisplayName, |
| 1195 | int callerDisplayNamePresentation, |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1196 | PhoneAccountHandle accountHandle, |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1197 | int capabilities, |
Andrew Lee | 223ad14 | 2014-08-27 16:33:08 -0700 | [diff] [blame] | 1198 | int properties, |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1199 | DisconnectCause disconnectCause, |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1200 | long connectTimeMillis, |
Andrew Lee | 85f5d42 | 2014-07-11 17:22:03 -0700 | [diff] [blame] | 1201 | GatewayInfo gatewayInfo, |
Evan Charlton | 5b49ade | 2014-07-15 17:03:20 -0700 | [diff] [blame] | 1202 | int videoState, |
Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 1203 | StatusHints statusHints, |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1204 | Bundle extras, |
Tyler Gunn | c0bf6de | 2017-03-17 11:27:09 -0700 | [diff] [blame] | 1205 | Bundle intentExtras, |
Tyler Gunn | d081f04 | 2018-12-04 12:56:45 -0800 | [diff] [blame] | 1206 | long creationTimeMillis, |
Hall Liu | ef98bf8 | 2020-01-09 15:22:44 -0800 | [diff] [blame] | 1207 | String contactDisplayName, |
Tyler Gunn | d57d76c | 2019-09-24 14:53:23 -0700 | [diff] [blame] | 1208 | int callDirection, |
Edgar Arriaga | e5bec82 | 2022-10-14 14:25:43 -0700 | [diff] [blame^] | 1209 | int callerNumberVerificationStatus, |
| 1210 | Uri contactPhotoUri) { |
Tyler Gunn | 1e406ca | 2021-03-18 16:47:14 -0700 | [diff] [blame] | 1211 | mState = state; |
Sailesh Nepal | 1bef339 | 2016-01-24 18:21:53 -0800 | [diff] [blame] | 1212 | mTelecomCallId = telecomCallId; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1213 | mHandle = handle; |
| 1214 | mHandlePresentation = handlePresentation; |
| 1215 | mCallerDisplayName = callerDisplayName; |
| 1216 | mCallerDisplayNamePresentation = callerDisplayNamePresentation; |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1217 | mAccountHandle = accountHandle; |
Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 1218 | mCallCapabilities = capabilities; |
Andrew Lee | 223ad14 | 2014-08-27 16:33:08 -0700 | [diff] [blame] | 1219 | mCallProperties = properties; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1220 | mDisconnectCause = disconnectCause; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1221 | mConnectTimeMillis = connectTimeMillis; |
| 1222 | mGatewayInfo = gatewayInfo; |
Andrew Lee | 85f5d42 | 2014-07-11 17:22:03 -0700 | [diff] [blame] | 1223 | mVideoState = videoState; |
Evan Charlton | 5b49ade | 2014-07-15 17:03:20 -0700 | [diff] [blame] | 1224 | mStatusHints = statusHints; |
Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 1225 | mExtras = extras; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1226 | mIntentExtras = intentExtras; |
Tyler Gunn | c0bf6de | 2017-03-17 11:27:09 -0700 | [diff] [blame] | 1227 | mCreationTimeMillis = creationTimeMillis; |
Hall Liu | ef98bf8 | 2020-01-09 15:22:44 -0800 | [diff] [blame] | 1228 | mContactDisplayName = contactDisplayName; |
Tyler Gunn | 94f8f11 | 2018-12-17 09:56:11 -0800 | [diff] [blame] | 1229 | mCallDirection = callDirection; |
Tyler Gunn | d57d76c | 2019-09-24 14:53:23 -0700 | [diff] [blame] | 1230 | mCallerNumberVerificationStatus = callerNumberVerificationStatus; |
Edgar Arriaga | e5bec82 | 2022-10-14 14:25:43 -0700 | [diff] [blame^] | 1231 | mContactPhotoUri = contactPhotoUri; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1232 | } |
Sailesh Nepal | 1bef339 | 2016-01-24 18:21:53 -0800 | [diff] [blame] | 1233 | |
| 1234 | /** {@hide} */ |
| 1235 | public static Details createFromParcelableCall(ParcelableCall parcelableCall) { |
| 1236 | return new Details( |
Tyler Gunn | 1e406ca | 2021-03-18 16:47:14 -0700 | [diff] [blame] | 1237 | parcelableCall.getState(), |
Sailesh Nepal | 1bef339 | 2016-01-24 18:21:53 -0800 | [diff] [blame] | 1238 | parcelableCall.getId(), |
| 1239 | parcelableCall.getHandle(), |
| 1240 | parcelableCall.getHandlePresentation(), |
| 1241 | parcelableCall.getCallerDisplayName(), |
| 1242 | parcelableCall.getCallerDisplayNamePresentation(), |
| 1243 | parcelableCall.getAccountHandle(), |
| 1244 | parcelableCall.getCapabilities(), |
| 1245 | parcelableCall.getProperties(), |
| 1246 | parcelableCall.getDisconnectCause(), |
| 1247 | parcelableCall.getConnectTimeMillis(), |
| 1248 | parcelableCall.getGatewayInfo(), |
| 1249 | parcelableCall.getVideoState(), |
| 1250 | parcelableCall.getStatusHints(), |
| 1251 | parcelableCall.getExtras(), |
Tyler Gunn | c0bf6de | 2017-03-17 11:27:09 -0700 | [diff] [blame] | 1252 | parcelableCall.getIntentExtras(), |
Tyler Gunn | d081f04 | 2018-12-04 12:56:45 -0800 | [diff] [blame] | 1253 | parcelableCall.getCreationTimeMillis(), |
Hall Liu | ef98bf8 | 2020-01-09 15:22:44 -0800 | [diff] [blame] | 1254 | parcelableCall.getContactDisplayName(), |
Tyler Gunn | d57d76c | 2019-09-24 14:53:23 -0700 | [diff] [blame] | 1255 | parcelableCall.getCallDirection(), |
Edgar Arriaga | e5bec82 | 2022-10-14 14:25:43 -0700 | [diff] [blame^] | 1256 | parcelableCall.getCallerNumberVerificationStatus(), |
| 1257 | parcelableCall.getContactPhotoUri() |
| 1258 | ); |
Sailesh Nepal | 1bef339 | 2016-01-24 18:21:53 -0800 | [diff] [blame] | 1259 | } |
Santos Cordon | 3c20d63 | 2016-02-25 16:12:35 -0800 | [diff] [blame] | 1260 | |
| 1261 | @Override |
| 1262 | public String toString() { |
| 1263 | StringBuilder sb = new StringBuilder(); |
Tyler Gunn | 3cd820f | 2018-11-30 14:21:18 -0800 | [diff] [blame] | 1264 | sb.append("[id: "); |
| 1265 | sb.append(mTelecomCallId); |
Tyler Gunn | 1e406ca | 2021-03-18 16:47:14 -0700 | [diff] [blame] | 1266 | sb.append(", state: "); |
| 1267 | sb.append(Call.stateToString(mState)); |
Tyler Gunn | 3cd820f | 2018-11-30 14:21:18 -0800 | [diff] [blame] | 1268 | sb.append(", pa: "); |
Santos Cordon | 3c20d63 | 2016-02-25 16:12:35 -0800 | [diff] [blame] | 1269 | sb.append(mAccountHandle); |
| 1270 | sb.append(", hdl: "); |
Tyler Gunn | 3cd820f | 2018-11-30 14:21:18 -0800 | [diff] [blame] | 1271 | sb.append(Log.piiHandle(mHandle)); |
| 1272 | sb.append(", hdlPres: "); |
| 1273 | sb.append(mHandlePresentation); |
| 1274 | sb.append(", videoState: "); |
| 1275 | sb.append(VideoProfile.videoStateToString(mVideoState)); |
Santos Cordon | 3c20d63 | 2016-02-25 16:12:35 -0800 | [diff] [blame] | 1276 | sb.append(", caps: "); |
| 1277 | sb.append(capabilitiesToString(mCallCapabilities)); |
| 1278 | sb.append(", props: "); |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1279 | sb.append(propertiesToString(mCallProperties)); |
Santos Cordon | 3c20d63 | 2016-02-25 16:12:35 -0800 | [diff] [blame] | 1280 | sb.append("]"); |
| 1281 | return sb.toString(); |
| 1282 | } |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1283 | } |
| 1284 | |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 1285 | /** |
| 1286 | * Defines callbacks which inform the {@link InCallService} of changes to a {@link Call}. |
| 1287 | * These callbacks can originate from the Telecom framework, or a {@link ConnectionService} |
| 1288 | * implementation. |
| 1289 | * <p> |
| 1290 | * You can handle these callbacks by extending the {@link Callback} class and overriding the |
| 1291 | * callbacks that your {@link InCallService} is interested in. The callback methods include the |
| 1292 | * {@link Call} for which the callback applies, allowing reuse of a single instance of your |
| 1293 | * {@link Callback} implementation, if desired. |
| 1294 | * <p> |
| 1295 | * Use {@link Call#registerCallback(Callback)} to register your callback(s). Ensure |
| 1296 | * {@link Call#unregisterCallback(Callback)} is called when you no longer require callbacks |
| 1297 | * (typically in {@link InCallService#onCallRemoved(Call)}). |
| 1298 | * Note: Callbacks which occur before you call {@link Call#registerCallback(Callback)} will not |
| 1299 | * reach your implementation of {@link Callback}, so it is important to register your callback |
| 1300 | * as soon as your {@link InCallService} is notified of a new call via |
| 1301 | * {@link InCallService#onCallAdded(Call)}. |
| 1302 | */ |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 1303 | public static abstract class Callback { |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1304 | /** |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 1305 | * @hide |
| 1306 | */ |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 1307 | @IntDef(prefix = { "HANDOVER_" }, |
| 1308 | value = {HANDOVER_FAILURE_DEST_APP_REJECTED, HANDOVER_FAILURE_NOT_SUPPORTED, |
Tyler Gunn | 5c60d71 | 2018-03-16 09:53:44 -0700 | [diff] [blame] | 1309 | HANDOVER_FAILURE_USER_REJECTED, HANDOVER_FAILURE_ONGOING_EMERGENCY_CALL, |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 1310 | HANDOVER_FAILURE_UNKNOWN}) |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 1311 | @Retention(RetentionPolicy.SOURCE) |
| 1312 | public @interface HandoverFailureErrors {} |
| 1313 | |
| 1314 | /** |
| 1315 | * Handover failure reason returned via {@link #onHandoverFailed(Call, int)} when the app |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 1316 | * to handover the call to rejects the handover request. |
| 1317 | * <p> |
| 1318 | * Will be returned when {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} is called |
| 1319 | * and the destination {@link PhoneAccountHandle}'s {@link ConnectionService} returns a |
| 1320 | * {@code null} {@link Connection} from |
| 1321 | * {@link ConnectionService#onCreateOutgoingHandoverConnection(PhoneAccountHandle, |
| 1322 | * ConnectionRequest)}. |
| 1323 | * <p> |
| 1324 | * For more information on call handovers, see |
| 1325 | * {@link #handoverTo(PhoneAccountHandle, int, Bundle)}. |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 1326 | */ |
| 1327 | public static final int HANDOVER_FAILURE_DEST_APP_REJECTED = 1; |
| 1328 | |
| 1329 | /** |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 1330 | * Handover failure reason returned via {@link #onHandoverFailed(Call, int)} when a handover |
| 1331 | * is initiated but the source or destination app does not support handover. |
| 1332 | * <p> |
| 1333 | * Will be returned when a handover is requested via |
| 1334 | * {@link #handoverTo(PhoneAccountHandle, int, Bundle)} and the destination |
| 1335 | * {@link PhoneAccountHandle} does not declare |
| 1336 | * {@link PhoneAccount#EXTRA_SUPPORTS_HANDOVER_TO}. May also be returned when a handover is |
| 1337 | * requested at the {@link PhoneAccountHandle} for the current call (i.e. the source call's |
| 1338 | * {@link Details#getAccountHandle()}) does not declare |
| 1339 | * {@link PhoneAccount#EXTRA_SUPPORTS_HANDOVER_FROM}. |
| 1340 | * <p> |
| 1341 | * For more information on call handovers, see |
| 1342 | * {@link #handoverTo(PhoneAccountHandle, int, Bundle)}. |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 1343 | */ |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 1344 | public static final int HANDOVER_FAILURE_NOT_SUPPORTED = 2; |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 1345 | |
| 1346 | /** |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 1347 | * Handover failure reason returned via {@link #onHandoverFailed(Call, int)} when the remote |
| 1348 | * user rejects the handover request. |
| 1349 | * <p> |
| 1350 | * For more information on call handovers, see |
| 1351 | * {@link #handoverTo(PhoneAccountHandle, int, Bundle)}. |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 1352 | */ |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 1353 | public static final int HANDOVER_FAILURE_USER_REJECTED = 3; |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 1354 | |
Sanket Padawe | 85291f6 | 2017-12-01 13:59:27 -0800 | [diff] [blame] | 1355 | /** |
| 1356 | * Handover failure reason returned via {@link #onHandoverFailed(Call, int)} when there |
| 1357 | * is ongoing emergency call. |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 1358 | * <p> |
| 1359 | * This error code is returned when {@link #handoverTo(PhoneAccountHandle, int, Bundle)} is |
| 1360 | * called on an emergency call, or if any other call is an emergency call. |
| 1361 | * <p> |
| 1362 | * Handovers are not permitted while there are ongoing emergency calls. |
| 1363 | * <p> |
| 1364 | * For more information on call handovers, see |
| 1365 | * {@link #handoverTo(PhoneAccountHandle, int, Bundle)}. |
Sanket Padawe | 85291f6 | 2017-12-01 13:59:27 -0800 | [diff] [blame] | 1366 | */ |
Tyler Gunn | 5c60d71 | 2018-03-16 09:53:44 -0700 | [diff] [blame] | 1367 | public static final int HANDOVER_FAILURE_ONGOING_EMERGENCY_CALL = 4; |
Sanket Padawe | 85291f6 | 2017-12-01 13:59:27 -0800 | [diff] [blame] | 1368 | |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 1369 | /** |
| 1370 | * Handover failure reason returned via {@link #onHandoverFailed(Call, int)} when a handover |
| 1371 | * fails for an unknown reason. |
| 1372 | * <p> |
| 1373 | * For more information on call handovers, see |
| 1374 | * {@link #handoverTo(PhoneAccountHandle, int, Bundle)}. |
| 1375 | */ |
| 1376 | public static final int HANDOVER_FAILURE_UNKNOWN = 5; |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 1377 | |
| 1378 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1379 | * Invoked when the state of this {@code Call} has changed. See {@link #getState()}. |
| 1380 | * |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1381 | * @param call The {@code Call} invoking this method. |
| 1382 | * @param state The new state of the {@code Call}. |
| 1383 | */ |
Tyler Gunn | 1e406ca | 2021-03-18 16:47:14 -0700 | [diff] [blame] | 1384 | public void onStateChanged(Call call, @CallState int state) {} |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1385 | |
| 1386 | /** |
| 1387 | * Invoked when the parent of this {@code Call} has changed. See {@link #getParent()}. |
| 1388 | * |
| 1389 | * @param call The {@code Call} invoking this method. |
| 1390 | * @param parent The new parent of the {@code Call}. |
| 1391 | */ |
| 1392 | public void onParentChanged(Call call, Call parent) {} |
| 1393 | |
| 1394 | /** |
| 1395 | * Invoked when the children of this {@code Call} have changed. See {@link #getChildren()}. |
| 1396 | * |
| 1397 | * @param call The {@code Call} invoking this method. |
| 1398 | * @param children The new children of the {@code Call}. |
| 1399 | */ |
| 1400 | public void onChildrenChanged(Call call, List<Call> children) {} |
| 1401 | |
| 1402 | /** |
| 1403 | * Invoked when the details of this {@code Call} have changed. See {@link #getDetails()}. |
| 1404 | * |
| 1405 | * @param call The {@code Call} invoking this method. |
| 1406 | * @param details A {@code Details} object describing the {@code Call}. |
| 1407 | */ |
| 1408 | public void onDetailsChanged(Call call, Details details) {} |
| 1409 | |
| 1410 | /** |
| 1411 | * Invoked when the text messages that can be used as responses to the incoming |
| 1412 | * {@code Call} are loaded from the relevant database. |
| 1413 | * See {@link #getCannedTextResponses()}. |
| 1414 | * |
| 1415 | * @param call The {@code Call} invoking this method. |
| 1416 | * @param cannedTextResponses The text messages useable as responses. |
| 1417 | */ |
| 1418 | public void onCannedTextResponsesLoaded(Call call, List<String> cannedTextResponses) {} |
| 1419 | |
| 1420 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1421 | * Invoked when the post-dial sequence in the outgoing {@code Call} has reached a pause |
| 1422 | * character. This causes the post-dial signals to stop pending user confirmation. An |
| 1423 | * implementation should present this choice to the user and invoke |
| 1424 | * {@link #postDialContinue(boolean)} when the user makes the choice. |
| 1425 | * |
| 1426 | * @param call The {@code Call} invoking this method. |
| 1427 | * @param remainingPostDialSequence The post-dial characters that remain to be sent. |
| 1428 | */ |
| 1429 | public void onPostDialWait(Call call, String remainingPostDialSequence) {} |
| 1430 | |
| 1431 | /** |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 1432 | * Invoked when the {@code Call.VideoCall} of the {@code Call} has changed. |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1433 | * |
| 1434 | * @param call The {@code Call} invoking this method. |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 1435 | * @param videoCall The {@code Call.VideoCall} associated with the {@code Call}. |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1436 | */ |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 1437 | public void onVideoCallChanged(Call call, InCallService.VideoCall videoCall) {} |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1438 | |
| 1439 | /** |
| 1440 | * Invoked when the {@code Call} is destroyed. Clients should refrain from cleaning |
| 1441 | * up their UI for the {@code Call} in response to state transitions. Specifically, |
| 1442 | * clients should not assume that a {@link #onStateChanged(Call, int)} with a state of |
| 1443 | * {@link #STATE_DISCONNECTED} is the final notification the {@code Call} will send. Rather, |
| 1444 | * clients should wait for this method to be invoked. |
| 1445 | * |
| 1446 | * @param call The {@code Call} being destroyed. |
| 1447 | */ |
| 1448 | public void onCallDestroyed(Call call) {} |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1449 | |
| 1450 | /** |
| 1451 | * Invoked upon changes to the set of {@code Call}s with which this {@code Call} can be |
| 1452 | * conferenced. |
| 1453 | * |
| 1454 | * @param call The {@code Call} being updated. |
| 1455 | * @param conferenceableCalls The {@code Call}s with which this {@code Call} can be |
| 1456 | * conferenced. |
| 1457 | */ |
| 1458 | public void onConferenceableCallsChanged(Call call, List<Call> conferenceableCalls) {} |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1459 | |
| 1460 | /** |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1461 | * Invoked when a {@link Call} receives an event from its associated {@link Connection} or |
| 1462 | * {@link Conference}. |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 1463 | * <p> |
| 1464 | * Where possible, the Call should make an attempt to handle {@link Connection} events which |
| 1465 | * are part of the {@code android.telecom.*} namespace. The Call should ignore any events |
| 1466 | * it does not wish to handle. Unexpected events should be handled gracefully, as it is |
| 1467 | * possible that a {@link ConnectionService} has defined its own Connection events which a |
| 1468 | * Call is not aware of. |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1469 | * <p> |
Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 1470 | * See {@link Connection#sendConnectionEvent(String, Bundle)}, |
| 1471 | * {@link Conference#sendConferenceEvent(String, Bundle)}. |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1472 | * |
| 1473 | * @param call The {@code Call} receiving the event. |
| 1474 | * @param event The event. |
| 1475 | * @param extras Extras associated with the connection event. |
| 1476 | */ |
| 1477 | public void onConnectionEvent(Call call, String event, Bundle extras) {} |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1478 | |
| 1479 | /** |
| 1480 | * Invoked when the RTT mode changes for this call. |
| 1481 | * @param call The call whose RTT mode has changed. |
| 1482 | * @param mode the new RTT mode, one of |
| 1483 | * {@link RttCall#RTT_MODE_FULL}, {@link RttCall#RTT_MODE_HCO}, |
| 1484 | * or {@link RttCall#RTT_MODE_VCO} |
| 1485 | */ |
| 1486 | public void onRttModeChanged(Call call, int mode) {} |
| 1487 | |
| 1488 | /** |
| 1489 | * Invoked when the call's RTT status changes, either from off to on or from on to off. |
| 1490 | * @param call The call whose RTT status has changed. |
| 1491 | * @param enabled whether RTT is now enabled or disabled |
| 1492 | * @param rttCall the {@link RttCall} object to use for reading and writing if RTT is now |
| 1493 | * on, null otherwise. |
| 1494 | */ |
| 1495 | public void onRttStatusChanged(Call call, boolean enabled, RttCall rttCall) {} |
| 1496 | |
| 1497 | /** |
| 1498 | * Invoked when the remote end of the connection has requested that an RTT communication |
| 1499 | * channel be opened. A response to this should be sent via {@link #respondToRttRequest} |
| 1500 | * with the same ID that this method is invoked with. |
| 1501 | * @param call The call which the RTT request was placed on |
| 1502 | * @param id The ID of the request. |
| 1503 | */ |
| 1504 | public void onRttRequest(Call call, int id) {} |
Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 1505 | |
| 1506 | /** |
| 1507 | * Invoked when the RTT session failed to initiate for some reason, including rejection |
| 1508 | * by the remote party. |
Tyler Gunn | b9a0496 | 2022-02-17 08:23:54 -0800 | [diff] [blame] | 1509 | * <p> |
| 1510 | * This callback will ONLY be invoked to report a failure related to a user initiated |
| 1511 | * session modification request (i.e. {@link Call#sendRttRequest()}). |
| 1512 | * <p> |
| 1513 | * If a call is initiated with {@link TelecomManager#EXTRA_START_CALL_WITH_RTT} specified, |
| 1514 | * the availability of RTT can be determined by checking {@link Details#PROPERTY_RTT} |
| 1515 | * once the call enters state {@link Details#STATE_ACTIVE}. |
| 1516 | * |
Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 1517 | * @param call The call which the RTT initiation failure occurred on. |
| 1518 | * @param reason One of the status codes defined in |
Tyler Gunn | b9a0496 | 2022-02-17 08:23:54 -0800 | [diff] [blame] | 1519 | * {@link android.telecom.Connection.RttModifyStatus}, with the exception of |
| 1520 | * {@link android.telecom.Connection.RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}. |
Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 1521 | */ |
Tyler Gunn | b9a0496 | 2022-02-17 08:23:54 -0800 | [diff] [blame] | 1522 | public void onRttInitiationFailure(Call call, |
| 1523 | @android.telecom.Connection.RttModifyStatus.RttSessionModifyStatus int reason) {} |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 1524 | |
| 1525 | /** |
| 1526 | * Invoked when Call handover from one {@link PhoneAccount} to other {@link PhoneAccount} |
| 1527 | * has completed successfully. |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 1528 | * <p> |
| 1529 | * For a full discussion of the handover process and the APIs involved, see |
| 1530 | * {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int, Bundle)}. |
| 1531 | * |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 1532 | * @param call The call which had initiated handover. |
| 1533 | */ |
| 1534 | public void onHandoverComplete(Call call) {} |
| 1535 | |
| 1536 | /** |
| 1537 | * Invoked when Call handover from one {@link PhoneAccount} to other {@link PhoneAccount} |
| 1538 | * has failed. |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 1539 | * <p> |
| 1540 | * For a full discussion of the handover process and the APIs involved, see |
| 1541 | * {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int, Bundle)}. |
| 1542 | * |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 1543 | * @param call The call which had initiated handover. |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 1544 | * @param failureReason Error reason for failure. |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 1545 | */ |
| 1546 | public void onHandoverFailed(Call call, @HandoverFailureErrors int failureReason) {} |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1547 | } |
| 1548 | |
| 1549 | /** |
| 1550 | * A class that holds the state that describes the state of the RTT channel to the remote |
| 1551 | * party, if it is active. |
| 1552 | */ |
| 1553 | public static final class RttCall { |
Hall Liu | 07094df | 2017-02-28 15:17:44 -0800 | [diff] [blame] | 1554 | /** @hide */ |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1555 | @Retention(RetentionPolicy.SOURCE) |
| 1556 | @IntDef({RTT_MODE_INVALID, RTT_MODE_FULL, RTT_MODE_HCO, RTT_MODE_VCO}) |
| 1557 | public @interface RttAudioMode {} |
| 1558 | |
| 1559 | /** |
| 1560 | * For metrics use. Default value in the proto. |
| 1561 | * @hide |
| 1562 | */ |
| 1563 | public static final int RTT_MODE_INVALID = 0; |
| 1564 | |
| 1565 | /** |
| 1566 | * Indicates that there should be a bidirectional audio stream between the two parties |
| 1567 | * on the call. |
| 1568 | */ |
| 1569 | public static final int RTT_MODE_FULL = 1; |
| 1570 | |
| 1571 | /** |
| 1572 | * Indicates that the local user should be able to hear the audio stream from the remote |
| 1573 | * user, but not vice versa. Equivalent to muting the microphone. |
| 1574 | */ |
| 1575 | public static final int RTT_MODE_HCO = 2; |
| 1576 | |
| 1577 | /** |
| 1578 | * Indicates that the remote user should be able to hear the audio stream from the local |
| 1579 | * user, but not vice versa. Equivalent to setting the volume to zero. |
| 1580 | */ |
| 1581 | public static final int RTT_MODE_VCO = 3; |
| 1582 | |
| 1583 | private static final int READ_BUFFER_SIZE = 1000; |
| 1584 | |
| 1585 | private InputStreamReader mReceiveStream; |
| 1586 | private OutputStreamWriter mTransmitStream; |
| 1587 | private int mRttMode; |
| 1588 | private final InCallAdapter mInCallAdapter; |
Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 1589 | private final String mTelecomCallId; |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1590 | private char[] mReadBuffer = new char[READ_BUFFER_SIZE]; |
| 1591 | |
| 1592 | /** |
| 1593 | * @hide |
| 1594 | */ |
Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 1595 | public RttCall(String telecomCallId, InputStreamReader receiveStream, |
| 1596 | OutputStreamWriter transmitStream, int mode, InCallAdapter inCallAdapter) { |
| 1597 | mTelecomCallId = telecomCallId; |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1598 | mReceiveStream = receiveStream; |
| 1599 | mTransmitStream = transmitStream; |
| 1600 | mRttMode = mode; |
| 1601 | mInCallAdapter = inCallAdapter; |
| 1602 | } |
| 1603 | |
| 1604 | /** |
| 1605 | * Returns the current RTT audio mode. |
| 1606 | * @return Current RTT audio mode. One of {@link #RTT_MODE_FULL}, {@link #RTT_MODE_VCO}, or |
| 1607 | * {@link #RTT_MODE_HCO}. |
| 1608 | */ |
| 1609 | public int getRttAudioMode() { |
| 1610 | return mRttMode; |
| 1611 | } |
| 1612 | |
| 1613 | /** |
| 1614 | * Sets the RTT audio mode. The requested mode change will be communicated through |
| 1615 | * {@link Callback#onRttModeChanged(Call, int)}. |
| 1616 | * @param mode The desired RTT audio mode, one of {@link #RTT_MODE_FULL}, |
| 1617 | * {@link #RTT_MODE_VCO}, or {@link #RTT_MODE_HCO}. |
| 1618 | */ |
| 1619 | public void setRttMode(@RttAudioMode int mode) { |
Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 1620 | mInCallAdapter.setRttMode(mTelecomCallId, mode); |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1621 | } |
| 1622 | |
| 1623 | /** |
| 1624 | * Writes the string {@param input} into the outgoing text stream for this RTT call. Since |
Hall Liu | dc46c85 | 2020-10-29 16:15:33 -0700 | [diff] [blame] | 1625 | * RTT transmits text in real-time, this method should be called once for each user action. |
| 1626 | * For example, when the user enters text as discrete characters using the keyboard, this |
| 1627 | * method should be called once for each character. However, if the user enters text by |
| 1628 | * pasting or autocomplete, the entire contents of the pasted or autocompleted text should |
| 1629 | * be sent in one call to this method. |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1630 | * |
| 1631 | * This method is not thread-safe -- calling it from multiple threads simultaneously may |
| 1632 | * lead to interleaved text. |
| 1633 | * @param input The message to send to the remote user. |
| 1634 | */ |
| 1635 | public void write(String input) throws IOException { |
| 1636 | mTransmitStream.write(input); |
| 1637 | mTransmitStream.flush(); |
| 1638 | } |
| 1639 | |
| 1640 | /** |
| 1641 | * Reads a string from the remote user, blocking if there is no data available. Returns |
| 1642 | * {@code null} if the RTT conversation has been terminated and there is no further data |
| 1643 | * to read. |
| 1644 | * |
| 1645 | * This method is not thread-safe -- calling it from multiple threads simultaneously may |
| 1646 | * lead to interleaved text. |
| 1647 | * @return A string containing text sent by the remote user, or {@code null} if the |
| 1648 | * conversation has been terminated or if there was an error while reading. |
| 1649 | */ |
Hall Liu | b1c8a77 | 2017-07-17 17:04:41 -0700 | [diff] [blame] | 1650 | public String read() { |
| 1651 | try { |
| 1652 | int numRead = mReceiveStream.read(mReadBuffer, 0, READ_BUFFER_SIZE); |
| 1653 | if (numRead < 0) { |
| 1654 | return null; |
| 1655 | } |
| 1656 | return new String(mReadBuffer, 0, numRead); |
| 1657 | } catch (IOException e) { |
| 1658 | Log.w(this, "Exception encountered when reading from InputStreamReader: %s", e); |
Jeff Sharkey | 9039636 | 2017-06-12 16:26:53 -0600 | [diff] [blame] | 1659 | return null; |
Hall Liu | ffa4a81 | 2017-03-02 16:11:00 -0800 | [diff] [blame] | 1660 | } |
Hall Liu | ffa4a81 | 2017-03-02 16:11:00 -0800 | [diff] [blame] | 1661 | } |
| 1662 | |
| 1663 | /** |
| 1664 | * Non-blocking version of {@link #read()}. Returns {@code null} if there is nothing to |
| 1665 | * be read. |
| 1666 | * @return A string containing text entered by the user, or {@code null} if the user has |
| 1667 | * not entered any new text yet. |
| 1668 | */ |
| 1669 | public String readImmediately() throws IOException { |
| 1670 | if (mReceiveStream.ready()) { |
Hall Liu | b1c8a77 | 2017-07-17 17:04:41 -0700 | [diff] [blame] | 1671 | int numRead = mReceiveStream.read(mReadBuffer, 0, READ_BUFFER_SIZE); |
| 1672 | if (numRead < 0) { |
| 1673 | return null; |
| 1674 | } |
| 1675 | return new String(mReadBuffer, 0, numRead); |
Hall Liu | ffa4a81 | 2017-03-02 16:11:00 -0800 | [diff] [blame] | 1676 | } else { |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1677 | return null; |
| 1678 | } |
| 1679 | } |
Hall Liu | e904124 | 2018-02-09 16:40:03 -0800 | [diff] [blame] | 1680 | |
| 1681 | /** |
| 1682 | * Closes the underlying file descriptors |
| 1683 | * @hide |
| 1684 | */ |
| 1685 | public void close() { |
| 1686 | try { |
| 1687 | mReceiveStream.close(); |
| 1688 | } catch (IOException e) { |
| 1689 | // ignore |
| 1690 | } |
| 1691 | try { |
| 1692 | mTransmitStream.close(); |
| 1693 | } catch (IOException e) { |
| 1694 | // ignore |
| 1695 | } |
| 1696 | } |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1697 | } |
| 1698 | |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 1699 | /** |
| 1700 | * @deprecated Use {@code Call.Callback} instead. |
| 1701 | * @hide |
| 1702 | */ |
| 1703 | @Deprecated |
| 1704 | @SystemApi |
| 1705 | public static abstract class Listener extends Callback { } |
| 1706 | |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1707 | private final Phone mPhone; |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1708 | private final String mTelecomCallId; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1709 | private final InCallAdapter mInCallAdapter; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1710 | private final List<String> mChildrenIds = new ArrayList<>(); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1711 | private final List<Call> mChildren = new ArrayList<>(); |
| 1712 | private final List<Call> mUnmodifiableChildren = Collections.unmodifiableList(mChildren); |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 1713 | private final List<CallbackRecord<Callback>> mCallbackRecords = new CopyOnWriteArrayList<>(); |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1714 | private final List<Call> mConferenceableCalls = new ArrayList<>(); |
| 1715 | private final List<Call> mUnmodifiableConferenceableCalls = |
| 1716 | Collections.unmodifiableList(mConferenceableCalls); |
| 1717 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1718 | private boolean mChildrenCached; |
| 1719 | private String mParentId = null; |
Hall Liu | ef98bf8 | 2020-01-09 15:22:44 -0800 | [diff] [blame] | 1720 | private String mActiveGenericConferenceChild = null; |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1721 | private int mState; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1722 | private List<String> mCannedTextResponses = null; |
Tyler Gunn | b88b311 | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 1723 | private String mCallingPackage; |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 1724 | private int mTargetSdkVersion; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1725 | private String mRemainingPostDialSequence; |
Tyler Gunn | 584ba6c | 2015-12-08 10:53:41 -0800 | [diff] [blame] | 1726 | private VideoCallImpl mVideoCallImpl; |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1727 | private RttCall mRttCall; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1728 | private Details mDetails; |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1729 | private Bundle mExtras; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1730 | |
| 1731 | /** |
| 1732 | * Obtains the post-dial sequence remaining to be emitted by this {@code Call}, if any. |
| 1733 | * |
| 1734 | * @return The remaining post-dial sequence, or {@code null} if there is no post-dial sequence |
| 1735 | * remaining or this {@code Call} is not in a post-dial state. |
| 1736 | */ |
| 1737 | public String getRemainingPostDialSequence() { |
| 1738 | return mRemainingPostDialSequence; |
| 1739 | } |
| 1740 | |
| 1741 | /** |
| 1742 | * Instructs this {@link #STATE_RINGING} {@code Call} to answer. |
Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 1743 | * @param videoState The video state in which to answer the call. |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1744 | */ |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 1745 | public void answer(@VideoProfile.VideoState int videoState) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1746 | mInCallAdapter.answerCall(mTelecomCallId, videoState); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1747 | } |
| 1748 | |
| 1749 | /** |
Pooja Jain | d34698d | 2017-12-28 14:15:31 +0530 | [diff] [blame] | 1750 | * Instructs this {@link #STATE_RINGING} {@code Call} to deflect. |
| 1751 | * |
| 1752 | * @param address The address to which the call will be deflected. |
| 1753 | */ |
| 1754 | public void deflect(Uri address) { |
| 1755 | mInCallAdapter.deflectCall(mTelecomCallId, address); |
| 1756 | } |
| 1757 | |
| 1758 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1759 | * Instructs this {@link #STATE_RINGING} {@code Call} to reject. |
| 1760 | * |
| 1761 | * @param rejectWithMessage Whether to reject with a text message. |
| 1762 | * @param textMessage An optional text message with which to respond. |
| 1763 | */ |
| 1764 | public void reject(boolean rejectWithMessage, String textMessage) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1765 | mInCallAdapter.rejectCall(mTelecomCallId, rejectWithMessage, textMessage); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1766 | } |
| 1767 | |
| 1768 | /** |
Tyler Gunn | facfdee | 2020-01-23 13:10:37 -0800 | [diff] [blame] | 1769 | * Instructs the {@link ConnectionService} providing this {@link #STATE_RINGING} call that the |
| 1770 | * user has chosen to reject the call and has indicated a reason why the call is being rejected. |
| 1771 | * |
| 1772 | * @param rejectReason the reason the call is being rejected. |
| 1773 | */ |
| 1774 | public void reject(@RejectReason int rejectReason) { |
| 1775 | mInCallAdapter.rejectCall(mTelecomCallId, rejectReason); |
| 1776 | } |
| 1777 | |
| 1778 | /** |
Ravi Paluri | f4b38e7 | 2020-02-05 12:35:41 +0530 | [diff] [blame] | 1779 | * Instructs this {@code Call} to be transferred to another number. |
| 1780 | * |
| 1781 | * @param targetNumber The address to which the call will be transferred. |
Tyler Gunn | 460360d | 2020-07-29 10:21:45 -0700 | [diff] [blame] | 1782 | * @param isConfirmationRequired if {@code true} it will initiate a confirmed transfer, |
| 1783 | * if {@code false}, it will initiate an unconfirmed transfer. |
Ravi Paluri | f4b38e7 | 2020-02-05 12:35:41 +0530 | [diff] [blame] | 1784 | * |
| 1785 | * @hide |
| 1786 | */ |
| 1787 | public void transfer(@NonNull Uri targetNumber, boolean isConfirmationRequired) { |
| 1788 | mInCallAdapter.transferCall(mTelecomCallId, targetNumber, isConfirmationRequired); |
| 1789 | } |
| 1790 | |
| 1791 | /** |
| 1792 | * Instructs this {@code Call} to be transferred to another ongoing call. |
| 1793 | * This will initiate CONSULTATIVE transfer. |
| 1794 | * @param toCall The other ongoing {@code Call} to which this call will be transferred. |
| 1795 | * |
| 1796 | * @hide |
| 1797 | */ |
| 1798 | public void transfer(@NonNull android.telecom.Call toCall) { |
| 1799 | mInCallAdapter.transferCall(mTelecomCallId, toCall.mTelecomCallId); |
| 1800 | } |
| 1801 | |
| 1802 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1803 | * Instructs this {@code Call} to disconnect. |
| 1804 | */ |
| 1805 | public void disconnect() { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1806 | mInCallAdapter.disconnectCall(mTelecomCallId); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1807 | } |
| 1808 | |
| 1809 | /** |
| 1810 | * Instructs this {@code Call} to go on hold. |
| 1811 | */ |
| 1812 | public void hold() { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1813 | mInCallAdapter.holdCall(mTelecomCallId); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1814 | } |
| 1815 | |
| 1816 | /** |
| 1817 | * Instructs this {@link #STATE_HOLDING} call to release from hold. |
| 1818 | */ |
| 1819 | public void unhold() { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1820 | mInCallAdapter.unholdCall(mTelecomCallId); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1821 | } |
| 1822 | |
| 1823 | /** |
Hall Liu | 6dfa249 | 2019-10-01 17:20:39 -0700 | [diff] [blame] | 1824 | * Instructs Telecom to put the call into the background audio processing state. |
Tyler Gunn | 460b7d4 | 2020-05-15 10:19:32 -0700 | [diff] [blame] | 1825 | * <p> |
Hall Liu | 6dfa249 | 2019-10-01 17:20:39 -0700 | [diff] [blame] | 1826 | * This method can be called either when the call is in {@link #STATE_RINGING} or |
| 1827 | * {@link #STATE_ACTIVE}. After Telecom acknowledges the request by setting the call's state to |
| 1828 | * {@link #STATE_AUDIO_PROCESSING}, your app may setup the audio paths with the audio stack in |
| 1829 | * order to capture and play audio on the call stream. |
Tyler Gunn | 460b7d4 | 2020-05-15 10:19:32 -0700 | [diff] [blame] | 1830 | * <p> |
Hall Liu | 6dfa249 | 2019-10-01 17:20:39 -0700 | [diff] [blame] | 1831 | * This method can only be called by the default dialer app. |
Tyler Gunn | 460b7d4 | 2020-05-15 10:19:32 -0700 | [diff] [blame] | 1832 | * <p> |
| 1833 | * Apps built with SDK version {@link android.os.Build.VERSION_CODES#R} or later which are using |
| 1834 | * the microphone as part of audio processing should specify the foreground service type using |
| 1835 | * the attribute {@link android.R.attr#foregroundServiceType} in the {@link InCallService} |
| 1836 | * service element of the app's manifest file. |
| 1837 | * The {@link ServiceInfo#FOREGROUND_SERVICE_TYPE_MICROPHONE} attribute should be specified. |
| 1838 | * @see <a href="https://developer.android.com/preview/privacy/foreground-service-types"> |
| 1839 | * the Android Developer Site</a> for more information. |
Hall Liu | 6dfa249 | 2019-10-01 17:20:39 -0700 | [diff] [blame] | 1840 | * @hide |
| 1841 | */ |
| 1842 | @SystemApi |
Hall Liu | 6dfa249 | 2019-10-01 17:20:39 -0700 | [diff] [blame] | 1843 | public void enterBackgroundAudioProcessing() { |
| 1844 | if (mState != STATE_ACTIVE && mState != STATE_RINGING) { |
| 1845 | throw new IllegalStateException("Call must be active or ringing"); |
| 1846 | } |
| 1847 | mInCallAdapter.enterBackgroundAudioProcessing(mTelecomCallId); |
| 1848 | } |
| 1849 | |
| 1850 | /** |
| 1851 | * Instructs Telecom to come out of the background audio processing state requested by |
| 1852 | * {@link #enterBackgroundAudioProcessing()} or from the call screening service. |
| 1853 | * |
| 1854 | * This method can only be called when the call is in {@link #STATE_AUDIO_PROCESSING}. |
| 1855 | * |
| 1856 | * @param shouldRing If true, Telecom will put the call into the |
| 1857 | * {@link #STATE_SIMULATED_RINGING} state and notify other apps that there is |
| 1858 | * a ringing call. Otherwise, the call will go into {@link #STATE_ACTIVE} |
| 1859 | * immediately. |
| 1860 | * @hide |
| 1861 | */ |
| 1862 | @SystemApi |
Hall Liu | 6dfa249 | 2019-10-01 17:20:39 -0700 | [diff] [blame] | 1863 | public void exitBackgroundAudioProcessing(boolean shouldRing) { |
| 1864 | if (mState != STATE_AUDIO_PROCESSING) { |
| 1865 | throw new IllegalStateException("Call must in the audio processing state"); |
| 1866 | } |
| 1867 | mInCallAdapter.exitBackgroundAudioProcessing(mTelecomCallId, shouldRing); |
| 1868 | } |
| 1869 | |
| 1870 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1871 | * Instructs this {@code Call} to play a dual-tone multi-frequency signaling (DTMF) tone. |
| 1872 | * |
| 1873 | * Any other currently playing DTMF tone in the specified call is immediately stopped. |
| 1874 | * |
| 1875 | * @param digit A character representing the DTMF digit for which to play the tone. This |
| 1876 | * value must be one of {@code '0'} through {@code '9'}, {@code '*'} or {@code '#'}. |
| 1877 | */ |
| 1878 | public void playDtmfTone(char digit) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1879 | mInCallAdapter.playDtmfTone(mTelecomCallId, digit); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1880 | } |
| 1881 | |
| 1882 | /** |
| 1883 | * Instructs this {@code Call} to stop any dual-tone multi-frequency signaling (DTMF) tone |
| 1884 | * currently playing. |
| 1885 | * |
| 1886 | * DTMF tones are played by calling {@link #playDtmfTone(char)}. If no DTMF tone is |
| 1887 | * currently playing, this method will do nothing. |
| 1888 | */ |
| 1889 | public void stopDtmfTone() { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1890 | mInCallAdapter.stopDtmfTone(mTelecomCallId); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1891 | } |
| 1892 | |
| 1893 | /** |
| 1894 | * Instructs this {@code Call} to continue playing a post-dial DTMF string. |
| 1895 | * |
| 1896 | * A post-dial DTMF string is a string of digits entered after a phone number, when dialed, |
| 1897 | * that are immediately sent as DTMF tones to the recipient as soon as the connection is made. |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1898 | * |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1899 | * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_PAUSE} symbol, this |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1900 | * {@code Call} will temporarily pause playing the tones for a pre-defined period of time. |
| 1901 | * |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1902 | * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_WAIT} symbol, this |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 1903 | * {@code Call} will pause playing the tones and notify callbacks via |
| 1904 | * {@link Callback#onPostDialWait(Call, String)}. At this point, the in-call app |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1905 | * should display to the user an indication of this state and an affordance to continue |
| 1906 | * the postdial sequence. When the user decides to continue the postdial sequence, the in-call |
| 1907 | * app should invoke the {@link #postDialContinue(boolean)} method. |
| 1908 | * |
| 1909 | * @param proceed Whether or not to continue with the post-dial sequence. |
| 1910 | */ |
| 1911 | public void postDialContinue(boolean proceed) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1912 | mInCallAdapter.postDialContinue(mTelecomCallId, proceed); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1913 | } |
| 1914 | |
| 1915 | /** |
Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 1916 | * Notifies this {@code Call} that an account has been selected and to proceed with placing |
Nancy Chen | 36c62f3 | 2014-10-21 18:36:39 -0700 | [diff] [blame] | 1917 | * an outgoing call. Optionally sets this account as the default account. |
Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 1918 | */ |
Nancy Chen | 36c62f3 | 2014-10-21 18:36:39 -0700 | [diff] [blame] | 1919 | public void phoneAccountSelected(PhoneAccountHandle accountHandle, boolean setDefault) { |
| 1920 | mInCallAdapter.phoneAccountSelected(mTelecomCallId, accountHandle, setDefault); |
Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 1921 | |
| 1922 | } |
| 1923 | |
| 1924 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1925 | * Instructs this {@code Call} to enter a conference. |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1926 | * |
| 1927 | * @param callToConferenceWith The other call with which to conference. |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1928 | */ |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1929 | public void conference(Call callToConferenceWith) { |
| 1930 | if (callToConferenceWith != null) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1931 | mInCallAdapter.conference(mTelecomCallId, callToConferenceWith.mTelecomCallId); |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1932 | } |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1933 | } |
| 1934 | |
| 1935 | /** |
| 1936 | * Instructs this {@code Call} to split from any conference call with which it may be |
| 1937 | * connected. |
| 1938 | */ |
| 1939 | public void splitFromConference() { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1940 | mInCallAdapter.splitFromConference(mTelecomCallId); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1941 | } |
| 1942 | |
| 1943 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1944 | * Merges the calls within this conference. See {@link Details#CAPABILITY_MERGE_CONFERENCE}. |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 1945 | */ |
| 1946 | public void mergeConference() { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1947 | mInCallAdapter.mergeConference(mTelecomCallId); |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 1948 | } |
| 1949 | |
| 1950 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1951 | * Swaps the calls within this conference. See {@link Details#CAPABILITY_SWAP_CONFERENCE}. |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 1952 | */ |
| 1953 | public void swapConference() { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1954 | mInCallAdapter.swapConference(mTelecomCallId); |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 1955 | } |
| 1956 | |
| 1957 | /** |
Ravi Paluri | 404babb | 2020-01-23 19:02:44 +0530 | [diff] [blame] | 1958 | * Pulls participants to existing call by forming a conference call. |
| 1959 | * See {@link Details#CAPABILITY_ADD_PARTICIPANT}. |
| 1960 | * |
| 1961 | * @param participants participants to be pulled to existing call. |
| 1962 | */ |
| 1963 | public void addConferenceParticipants(@NonNull List<Uri> participants) { |
| 1964 | mInCallAdapter.addConferenceParticipants(mTelecomCallId, participants); |
| 1965 | } |
| 1966 | |
| 1967 | /** |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1968 | * Initiates a request to the {@link ConnectionService} to pull an external call to the local |
| 1969 | * device. |
| 1970 | * <p> |
| 1971 | * Calls to this method are ignored if the call does not have the |
| 1972 | * {@link Call.Details#PROPERTY_IS_EXTERNAL_CALL} property set. |
| 1973 | * <p> |
| 1974 | * An {@link InCallService} will only see calls which support this method if it has the |
| 1975 | * {@link TelecomManager#METADATA_INCLUDE_EXTERNAL_CALLS} metadata set to {@code true} |
| 1976 | * in its manifest. |
| 1977 | */ |
| 1978 | public void pullExternalCall() { |
| 1979 | // If this isn't an external call, ignore the request. |
| 1980 | if (!mDetails.hasProperty(Details.PROPERTY_IS_EXTERNAL_CALL)) { |
| 1981 | return; |
| 1982 | } |
| 1983 | |
| 1984 | mInCallAdapter.pullExternalCall(mTelecomCallId); |
| 1985 | } |
| 1986 | |
| 1987 | /** |
| 1988 | * Sends a {@code Call} event from this {@code Call} to the associated {@link Connection} in |
| 1989 | * the {@link ConnectionService}. |
| 1990 | * <p> |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 1991 | * Call events are used to communicate point in time information from an {@link InCallService} |
| 1992 | * to a {@link ConnectionService}. A {@link ConnectionService} implementation could define |
| 1993 | * events which enable the {@link InCallService}, for example, toggle a unique feature of the |
| 1994 | * {@link ConnectionService}. |
| 1995 | * <p> |
| 1996 | * A {@link ConnectionService} can communicate to the {@link InCallService} using |
| 1997 | * {@link Connection#sendConnectionEvent(String, Bundle)}. |
| 1998 | * <p> |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1999 | * Events are exposed to {@link ConnectionService} implementations via |
| 2000 | * {@link android.telecom.Connection#onCallEvent(String, Bundle)}. |
| 2001 | * <p> |
| 2002 | * No assumptions should be made as to how a {@link ConnectionService} will handle these events. |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 2003 | * The {@link InCallService} must assume that the {@link ConnectionService} could chose to |
| 2004 | * ignore some events altogether. |
| 2005 | * <p> |
| 2006 | * Events should be fully qualified (e.g., {@code com.example.event.MY_EVENT}) to avoid |
| 2007 | * conflicts between {@link InCallService} implementations. Further, {@link InCallService} |
| 2008 | * implementations shall not re-purpose events in the {@code android.*} namespace, nor shall |
| 2009 | * they define their own event types in this namespace. When defining a custom event type, |
| 2010 | * ensure the contents of the extras {@link Bundle} is clearly defined. Extra keys for this |
| 2011 | * bundle should be named similar to the event type (e.g. {@code com.example.extra.MY_EXTRA}). |
| 2012 | * <p> |
| 2013 | * When defining events and the associated extras, it is important to keep their behavior |
| 2014 | * consistent when the associated {@link InCallService} is updated. Support for deprecated |
| 2015 | * events/extras should me maintained to ensure backwards compatibility with older |
| 2016 | * {@link ConnectionService} implementations which were built to support the older behavior. |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 2017 | * |
| 2018 | * @param event The connection event. |
| 2019 | * @param extras Bundle containing extra information associated with the event. |
| 2020 | */ |
| 2021 | public void sendCallEvent(String event, Bundle extras) { |
Sanket Padawe | f6a9e5b | 2018-01-05 14:26:16 -0800 | [diff] [blame] | 2022 | mInCallAdapter.sendCallEvent(mTelecomCallId, event, mTargetSdkVersion, extras); |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 2023 | } |
| 2024 | |
| 2025 | /** |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 2026 | * Sends an RTT upgrade request to the remote end of the connection. Success is not |
| 2027 | * guaranteed, and notification of success will be via the |
| 2028 | * {@link Callback#onRttStatusChanged(Call, boolean, RttCall)} callback. |
| 2029 | */ |
| 2030 | public void sendRttRequest() { |
Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 2031 | mInCallAdapter.sendRttRequest(mTelecomCallId); |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 2032 | } |
| 2033 | |
| 2034 | /** |
| 2035 | * Responds to an RTT request received via the {@link Callback#onRttRequest(Call, int)} )} |
| 2036 | * callback. |
| 2037 | * The ID used here should be the same as the ID that was received via the callback. |
| 2038 | * @param id The request ID received via {@link Callback#onRttRequest(Call, int)} |
| 2039 | * @param accept {@code true} if the RTT request should be accepted, {@code false} otherwise. |
| 2040 | */ |
| 2041 | public void respondToRttRequest(int id, boolean accept) { |
Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 2042 | mInCallAdapter.respondToRttRequest(mTelecomCallId, id, accept); |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 2043 | } |
| 2044 | |
| 2045 | /** |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 2046 | * Initiates a handover of this {@link Call} to the {@link ConnectionService} identified |
| 2047 | * by {@code toHandle}. The videoState specified indicates the desired video state after the |
| 2048 | * handover. |
| 2049 | * <p> |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 2050 | * A call handover is the process where an ongoing call is transferred from one app (i.e. |
| 2051 | * {@link ConnectionService} to another app. The user could, for example, choose to continue a |
| 2052 | * mobile network call in a video calling app. The mobile network call via the Telephony stack |
| 2053 | * is referred to as the source of the handover, and the video calling app is referred to as the |
| 2054 | * destination. |
| 2055 | * <p> |
| 2056 | * When considering a handover scenario the device this method is called on is considered the |
| 2057 | * <em>initiating</em> device (since the user initiates the handover from this device), and the |
| 2058 | * other device is considered the <em>receiving</em> device. |
| 2059 | * <p> |
| 2060 | * When this method is called on the <em>initiating</em> device, the Telecom framework will bind |
| 2061 | * to the {@link ConnectionService} defined by the {@code toHandle} {@link PhoneAccountHandle} |
| 2062 | * and invoke |
| 2063 | * {@link ConnectionService#onCreateOutgoingHandoverConnection(PhoneAccountHandle, |
| 2064 | * ConnectionRequest)} to inform the destination app that a request has been made to handover a |
| 2065 | * call to it. The app returns an instance of {@link Connection} to represent the handover call |
| 2066 | * At this point the app should display UI to indicate to the user that a call |
| 2067 | * handover is in process. |
| 2068 | * <p> |
| 2069 | * The destination app is responsible for communicating the handover request from the |
| 2070 | * <em>initiating</em> device to the <em>receiving</em> device. |
| 2071 | * <p> |
| 2072 | * When the app on the <em>receiving</em> device receives the handover request, it calls |
| 2073 | * {@link TelecomManager#acceptHandover(Uri, int, PhoneAccountHandle)} to continue the handover |
| 2074 | * process from the <em>initiating</em> device to the <em>receiving</em> device. At this point |
| 2075 | * the destination app on the <em>receiving</em> device should show UI to allow the user to |
| 2076 | * choose whether they want to continue their call in the destination app. |
| 2077 | * <p> |
| 2078 | * When the destination app on the <em>receiving</em> device calls |
| 2079 | * {@link TelecomManager#acceptHandover(Uri, int, PhoneAccountHandle)}, Telecom will bind to its |
| 2080 | * {@link ConnectionService} and call |
| 2081 | * {@link ConnectionService#onCreateIncomingHandoverConnection(PhoneAccountHandle, |
| 2082 | * ConnectionRequest)} to inform it of the handover request. The app returns an instance of |
| 2083 | * {@link Connection} to represent the handover call. |
| 2084 | * <p> |
| 2085 | * If the user of the <em>receiving</em> device accepts the handover, the app calls |
| 2086 | * {@link Connection#setActive()} to complete the handover process; Telecom will disconnect the |
| 2087 | * original call. If the user rejects the handover, the app calls |
| 2088 | * {@link Connection#setDisconnected(DisconnectCause)} and specifies a {@link DisconnectCause} |
| 2089 | * of {@link DisconnectCause#CANCELED} to indicate that the handover has been cancelled. |
| 2090 | * <p> |
| 2091 | * Telecom will only allow handovers from {@link PhoneAccount}s which declare |
| 2092 | * {@link PhoneAccount#EXTRA_SUPPORTS_HANDOVER_FROM}. Similarly, the {@link PhoneAccount} |
| 2093 | * specified by {@code toHandle} must declare {@link PhoneAccount#EXTRA_SUPPORTS_HANDOVER_TO}. |
| 2094 | * <p> |
| 2095 | * Errors in the handover process are reported to the {@link InCallService} via |
| 2096 | * {@link Callback#onHandoverFailed(Call, int)}. Errors in the handover process are reported to |
| 2097 | * the involved {@link ConnectionService}s via |
| 2098 | * {@link ConnectionService#onHandoverFailed(ConnectionRequest, int)}. |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 2099 | * |
| 2100 | * @param toHandle {@link PhoneAccountHandle} of the {@link ConnectionService} to handover |
| 2101 | * this call to. |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 2102 | * @param videoState Indicates the video state desired after the handover (see the |
| 2103 | * {@code STATE_*} constants defined in {@link VideoProfile}). |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 2104 | * @param extras Bundle containing extra information to be passed to the |
| 2105 | * {@link ConnectionService} |
| 2106 | */ |
Tyler Gunn | 9d12773 | 2018-03-02 15:45:51 -0800 | [diff] [blame] | 2107 | public void handoverTo(PhoneAccountHandle toHandle, @VideoProfile.VideoState int videoState, |
| 2108 | Bundle extras) { |
Sanket Padawe | a8eddd4 | 2017-11-03 11:07:35 -0700 | [diff] [blame] | 2109 | mInCallAdapter.handoverTo(mTelecomCallId, toHandle, videoState, extras); |
| 2110 | } |
| 2111 | |
| 2112 | /** |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 2113 | * Terminate the RTT session on this call. The resulting state change will be notified via |
| 2114 | * the {@link Callback#onRttStatusChanged(Call, boolean, RttCall)} callback. |
| 2115 | */ |
| 2116 | public void stopRtt() { |
Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 2117 | mInCallAdapter.stopRtt(mTelecomCallId); |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 2118 | } |
| 2119 | |
| 2120 | /** |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2121 | * Adds some extras to this {@link Call}. Existing keys are replaced and new ones are |
| 2122 | * added. |
| 2123 | * <p> |
| 2124 | * No assumptions should be made as to how an In-Call UI or service will handle these |
| 2125 | * extras. Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts. |
| 2126 | * |
| 2127 | * @param extras The extras to add. |
| 2128 | */ |
| 2129 | public final void putExtras(Bundle extras) { |
| 2130 | if (extras == null) { |
| 2131 | return; |
| 2132 | } |
| 2133 | |
| 2134 | if (mExtras == null) { |
| 2135 | mExtras = new Bundle(); |
| 2136 | } |
| 2137 | mExtras.putAll(extras); |
| 2138 | mInCallAdapter.putExtras(mTelecomCallId, extras); |
| 2139 | } |
| 2140 | |
| 2141 | /** |
| 2142 | * Adds a boolean extra to this {@link Call}. |
| 2143 | * |
| 2144 | * @param key The extra key. |
| 2145 | * @param value The value. |
| 2146 | * @hide |
| 2147 | */ |
| 2148 | public final void putExtra(String key, boolean value) { |
| 2149 | if (mExtras == null) { |
| 2150 | mExtras = new Bundle(); |
| 2151 | } |
| 2152 | mExtras.putBoolean(key, value); |
| 2153 | mInCallAdapter.putExtra(mTelecomCallId, key, value); |
| 2154 | } |
| 2155 | |
| 2156 | /** |
Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 2157 | * Adds an integer extra to this {@link Call}. |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2158 | * |
| 2159 | * @param key The extra key. |
| 2160 | * @param value The value. |
| 2161 | * @hide |
| 2162 | */ |
| 2163 | public final void putExtra(String key, int value) { |
| 2164 | if (mExtras == null) { |
| 2165 | mExtras = new Bundle(); |
| 2166 | } |
| 2167 | mExtras.putInt(key, value); |
| 2168 | mInCallAdapter.putExtra(mTelecomCallId, key, value); |
| 2169 | } |
| 2170 | |
| 2171 | /** |
Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 2172 | * Adds a string extra to this {@link Call}. |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2173 | * |
| 2174 | * @param key The extra key. |
| 2175 | * @param value The value. |
| 2176 | * @hide |
| 2177 | */ |
| 2178 | public final void putExtra(String key, String value) { |
| 2179 | if (mExtras == null) { |
| 2180 | mExtras = new Bundle(); |
| 2181 | } |
| 2182 | mExtras.putString(key, value); |
| 2183 | mInCallAdapter.putExtra(mTelecomCallId, key, value); |
| 2184 | } |
| 2185 | |
| 2186 | /** |
Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 2187 | * Removes extras from this {@link Call}. |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2188 | * |
| 2189 | * @param keys The keys of the extras to remove. |
| 2190 | */ |
| 2191 | public final void removeExtras(List<String> keys) { |
| 2192 | if (mExtras != null) { |
| 2193 | for (String key : keys) { |
| 2194 | mExtras.remove(key); |
| 2195 | } |
| 2196 | if (mExtras.size() == 0) { |
| 2197 | mExtras = null; |
| 2198 | } |
| 2199 | } |
| 2200 | mInCallAdapter.removeExtras(mTelecomCallId, keys); |
| 2201 | } |
| 2202 | |
| 2203 | /** |
Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 2204 | * Removes extras from this {@link Call}. |
| 2205 | * |
| 2206 | * @param keys The keys of the extras to remove. |
| 2207 | */ |
| 2208 | public final void removeExtras(String ... keys) { |
| 2209 | removeExtras(Arrays.asList(keys)); |
| 2210 | } |
| 2211 | |
| 2212 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2213 | * Obtains the parent of this {@code Call} in a conference, if any. |
| 2214 | * |
| 2215 | * @return The parent {@code Call}, or {@code null} if this {@code Call} is not a |
| 2216 | * child of any conference {@code Call}s. |
| 2217 | */ |
| 2218 | public Call getParent() { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2219 | if (mParentId != null) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2220 | return mPhone.internalGetCallByTelecomId(mParentId); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2221 | } |
| 2222 | return null; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2223 | } |
| 2224 | |
| 2225 | /** |
| 2226 | * Obtains the children of this conference {@code Call}, if any. |
| 2227 | * |
| 2228 | * @return The children of this {@code Call} if this {@code Call} is a conference, or an empty |
| 2229 | * {@code List} otherwise. |
| 2230 | */ |
| 2231 | public List<Call> getChildren() { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2232 | if (!mChildrenCached) { |
| 2233 | mChildrenCached = true; |
| 2234 | mChildren.clear(); |
| 2235 | |
| 2236 | for(String id : mChildrenIds) { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2237 | Call call = mPhone.internalGetCallByTelecomId(id); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2238 | if (call == null) { |
| 2239 | // At least one child was still not found, so do not save true for "cached" |
| 2240 | mChildrenCached = false; |
| 2241 | } else { |
| 2242 | mChildren.add(call); |
| 2243 | } |
| 2244 | } |
| 2245 | } |
| 2246 | |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2247 | return mUnmodifiableChildren; |
| 2248 | } |
| 2249 | |
| 2250 | /** |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2251 | * Returns the list of {@code Call}s with which this {@code Call} is allowed to conference. |
| 2252 | * |
| 2253 | * @return The list of conferenceable {@code Call}s. |
| 2254 | */ |
| 2255 | public List<Call> getConferenceableCalls() { |
| 2256 | return mUnmodifiableConferenceableCalls; |
| 2257 | } |
| 2258 | |
| 2259 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2260 | * Obtains the state of this {@code Call}. |
| 2261 | * |
Tyler Gunn | 1e406ca | 2021-03-18 16:47:14 -0700 | [diff] [blame] | 2262 | * @return The call state. |
| 2263 | * @deprecated The call state is available via {@link Call.Details#getState()}. |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2264 | */ |
Tyler Gunn | 1e406ca | 2021-03-18 16:47:14 -0700 | [diff] [blame] | 2265 | @Deprecated |
| 2266 | public @CallState int getState() { |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2267 | return mState; |
| 2268 | } |
| 2269 | |
| 2270 | /** |
Hall Liu | ef98bf8 | 2020-01-09 15:22:44 -0800 | [diff] [blame] | 2271 | * Returns the child {@link Call} in a generic conference that is currently active. |
Hall Liu | 135e53aa | 2020-02-27 18:34:11 -0800 | [diff] [blame] | 2272 | * |
| 2273 | * A "generic conference" is the mechanism used to support two simultaneous calls on a device |
| 2274 | * in CDMA networks. It is effectively equivalent to having one call active and one call on hold |
| 2275 | * in GSM or IMS calls. This method returns the currently active call. |
| 2276 | * |
| 2277 | * In a generic conference, the network exposes the conference to us as a single call, and we |
| 2278 | * switch between talking to the two participants using a CDMA flash command. Since the network |
| 2279 | * exposes no additional information about the call, the only way we know which caller we're |
| 2280 | * currently talking to is by keeping track of the flash commands that we've sent to the |
| 2281 | * network. |
| 2282 | * |
Hall Liu | ef98bf8 | 2020-01-09 15:22:44 -0800 | [diff] [blame] | 2283 | * For calls that are not generic conferences, or when the generic conference has more than |
| 2284 | * 2 children, returns {@code null}. |
| 2285 | * @see Details#PROPERTY_GENERIC_CONFERENCE |
| 2286 | * @return The active child call. |
| 2287 | */ |
| 2288 | public @Nullable Call getGenericConferenceActiveChildCall() { |
| 2289 | if (mActiveGenericConferenceChild != null) { |
| 2290 | return mPhone.internalGetCallByTelecomId(mActiveGenericConferenceChild); |
| 2291 | } |
| 2292 | return null; |
| 2293 | } |
| 2294 | |
| 2295 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2296 | * Obtains a list of canned, pre-configured message responses to present to the user as |
Tyler Gunn | 434fc2c | 2020-10-06 14:23:54 -0700 | [diff] [blame] | 2297 | * ways of rejecting an incoming {@code Call} using via a text message. |
| 2298 | * <p> |
| 2299 | * <em>Note:</em> Since canned responses may be loaded from the file system, they are not |
| 2300 | * guaranteed to be present when this {@link Call} is first added to the {@link InCallService} |
| 2301 | * via {@link InCallService#onCallAdded(Call)}. The callback |
| 2302 | * {@link Call.Callback#onCannedTextResponsesLoaded(Call, List)} will be called when/if canned |
| 2303 | * responses for the call become available. |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2304 | * |
| 2305 | * @see #reject(boolean, String) |
| 2306 | * |
| 2307 | * @return A list of canned text message responses. |
| 2308 | */ |
| 2309 | public List<String> getCannedTextResponses() { |
| 2310 | return mCannedTextResponses; |
| 2311 | } |
| 2312 | |
| 2313 | /** |
| 2314 | * Obtains an object that can be used to display video from this {@code Call}. |
| 2315 | * |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 2316 | * @return An {@code Call.VideoCall}. |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2317 | */ |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 2318 | public InCallService.VideoCall getVideoCall() { |
Tyler Gunn | 584ba6c | 2015-12-08 10:53:41 -0800 | [diff] [blame] | 2319 | return mVideoCallImpl; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2320 | } |
| 2321 | |
| 2322 | /** |
| 2323 | * Obtains an object containing call details. |
| 2324 | * |
| 2325 | * @return A {@link Details} object. Depending on the state of the {@code Call}, the |
| 2326 | * result may be {@code null}. |
| 2327 | */ |
| 2328 | public Details getDetails() { |
| 2329 | return mDetails; |
| 2330 | } |
| 2331 | |
| 2332 | /** |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 2333 | * Returns this call's RttCall object. The {@link RttCall} instance is used to send and |
| 2334 | * receive RTT text data, as well as to change the RTT mode. |
| 2335 | * @return A {@link Call.RttCall}. {@code null} if there is no active RTT connection. |
| 2336 | */ |
| 2337 | public @Nullable RttCall getRttCall() { |
| 2338 | return mRttCall; |
| 2339 | } |
| 2340 | |
| 2341 | /** |
| 2342 | * Returns whether this call has an active RTT connection. |
| 2343 | * @return true if there is a connection, false otherwise. |
| 2344 | */ |
| 2345 | public boolean isRttActive() { |
Hall Liu | e904124 | 2018-02-09 16:40:03 -0800 | [diff] [blame] | 2346 | return mRttCall != null && mDetails.hasProperty(Details.PROPERTY_RTT); |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 2347 | } |
| 2348 | |
| 2349 | /** |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 2350 | * Registers a callback to this {@code Call}. |
| 2351 | * |
| 2352 | * @param callback A {@code Callback}. |
| 2353 | */ |
| 2354 | public void registerCallback(Callback callback) { |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 2355 | registerCallback(callback, new Handler()); |
| 2356 | } |
| 2357 | |
| 2358 | /** |
| 2359 | * Registers a callback to this {@code Call}. |
| 2360 | * |
| 2361 | * @param callback A {@code Callback}. |
| 2362 | * @param handler A handler which command and status changes will be delivered to. |
| 2363 | */ |
| 2364 | public void registerCallback(Callback callback, Handler handler) { |
| 2365 | unregisterCallback(callback); |
Roshan Pius | 1ca6207 | 2015-07-07 17:34:51 -0700 | [diff] [blame] | 2366 | // Don't allow new callback registration if the call is already being destroyed. |
| 2367 | if (callback != null && handler != null && mState != STATE_DISCONNECTED) { |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 2368 | mCallbackRecords.add(new CallbackRecord<Callback>(callback, handler)); |
| 2369 | } |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 2370 | } |
| 2371 | |
| 2372 | /** |
| 2373 | * Unregisters a callback from this {@code Call}. |
| 2374 | * |
| 2375 | * @param callback A {@code Callback}. |
| 2376 | */ |
| 2377 | public void unregisterCallback(Callback callback) { |
Roshan Pius | 1ca6207 | 2015-07-07 17:34:51 -0700 | [diff] [blame] | 2378 | // Don't allow callback deregistration if the call is already being destroyed. |
| 2379 | if (callback != null && mState != STATE_DISCONNECTED) { |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 2380 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 2381 | if (record.getCallback() == callback) { |
| 2382 | mCallbackRecords.remove(record); |
| 2383 | break; |
| 2384 | } |
| 2385 | } |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 2386 | } |
| 2387 | } |
| 2388 | |
Santos Cordon | 3c20d63 | 2016-02-25 16:12:35 -0800 | [diff] [blame] | 2389 | @Override |
| 2390 | public String toString() { |
| 2391 | return new StringBuilder(). |
| 2392 | append("Call [id: "). |
| 2393 | append(mTelecomCallId). |
| 2394 | append(", state: "). |
| 2395 | append(stateToString(mState)). |
| 2396 | append(", details: "). |
| 2397 | append(mDetails). |
| 2398 | append("]").toString(); |
| 2399 | } |
| 2400 | |
| 2401 | /** |
| 2402 | * @param state An integer value of a {@code STATE_*} constant. |
| 2403 | * @return A string representation of the value. |
| 2404 | */ |
| 2405 | private static String stateToString(int state) { |
| 2406 | switch (state) { |
| 2407 | case STATE_NEW: |
| 2408 | return "NEW"; |
| 2409 | case STATE_RINGING: |
| 2410 | return "RINGING"; |
| 2411 | case STATE_DIALING: |
| 2412 | return "DIALING"; |
| 2413 | case STATE_ACTIVE: |
| 2414 | return "ACTIVE"; |
| 2415 | case STATE_HOLDING: |
| 2416 | return "HOLDING"; |
| 2417 | case STATE_DISCONNECTED: |
| 2418 | return "DISCONNECTED"; |
| 2419 | case STATE_CONNECTING: |
| 2420 | return "CONNECTING"; |
| 2421 | case STATE_DISCONNECTING: |
| 2422 | return "DISCONNECTING"; |
| 2423 | case STATE_SELECT_PHONE_ACCOUNT: |
| 2424 | return "SELECT_PHONE_ACCOUNT"; |
Hall Liu | 4e35b64 | 2019-10-14 17:50:45 -0700 | [diff] [blame] | 2425 | case STATE_SIMULATED_RINGING: |
| 2426 | return "SIMULATED_RINGING"; |
| 2427 | case STATE_AUDIO_PROCESSING: |
| 2428 | return "AUDIO_PROCESSING"; |
Santos Cordon | 3c20d63 | 2016-02-25 16:12:35 -0800 | [diff] [blame] | 2429 | default: |
| 2430 | Log.w(Call.class, "Unknown state %d", state); |
| 2431 | return "UNKNOWN"; |
| 2432 | } |
| 2433 | } |
| 2434 | |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 2435 | /** |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2436 | * Adds a listener to this {@code Call}. |
| 2437 | * |
| 2438 | * @param listener A {@code Listener}. |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 2439 | * @deprecated Use {@link #registerCallback} instead. |
| 2440 | * @hide |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2441 | */ |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 2442 | @Deprecated |
| 2443 | @SystemApi |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2444 | public void addListener(Listener listener) { |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 2445 | registerCallback(listener); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2446 | } |
| 2447 | |
| 2448 | /** |
| 2449 | * Removes a listener from this {@code Call}. |
| 2450 | * |
| 2451 | * @param listener A {@code Listener}. |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 2452 | * @deprecated Use {@link #unregisterCallback} instead. |
| 2453 | * @hide |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2454 | */ |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 2455 | @Deprecated |
| 2456 | @SystemApi |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2457 | public void removeListener(Listener listener) { |
Andrew Lee | da80c87 | 2015-04-15 14:09:50 -0700 | [diff] [blame] | 2458 | unregisterCallback(listener); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2459 | } |
| 2460 | |
| 2461 | /** {@hide} */ |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 2462 | Call(Phone phone, String telecomCallId, InCallAdapter inCallAdapter, String callingPackage, |
| 2463 | int targetSdkVersion) { |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2464 | mPhone = phone; |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2465 | mTelecomCallId = telecomCallId; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2466 | mInCallAdapter = inCallAdapter; |
| 2467 | mState = STATE_NEW; |
Tyler Gunn | b88b311 | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 2468 | mCallingPackage = callingPackage; |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 2469 | mTargetSdkVersion = targetSdkVersion; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2470 | } |
| 2471 | |
| 2472 | /** {@hide} */ |
Tyler Gunn | b88b311 | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 2473 | Call(Phone phone, String telecomCallId, InCallAdapter inCallAdapter, int state, |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 2474 | String callingPackage, int targetSdkVersion) { |
Shriram Ganesh | ddf570e | 2015-05-31 09:18:48 -0700 | [diff] [blame] | 2475 | mPhone = phone; |
| 2476 | mTelecomCallId = telecomCallId; |
| 2477 | mInCallAdapter = inCallAdapter; |
| 2478 | mState = state; |
Tyler Gunn | b88b311 | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 2479 | mCallingPackage = callingPackage; |
Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 2480 | mTargetSdkVersion = targetSdkVersion; |
Shriram Ganesh | ddf570e | 2015-05-31 09:18:48 -0700 | [diff] [blame] | 2481 | } |
| 2482 | |
| 2483 | /** {@hide} */ |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2484 | final String internalGetCallId() { |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2485 | return mTelecomCallId; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2486 | } |
| 2487 | |
| 2488 | /** {@hide} */ |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2489 | final void internalUpdate(ParcelableCall parcelableCall, Map<String, Call> callIdMap) { |
Tyler Gunn | b88b311 | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 2490 | |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2491 | // First, we update the internal state as far as possible before firing any updates. |
Sailesh Nepal | 1bef339 | 2016-01-24 18:21:53 -0800 | [diff] [blame] | 2492 | Details details = Details.createFromParcelableCall(parcelableCall); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2493 | boolean detailsChanged = !Objects.equals(mDetails, details); |
| 2494 | if (detailsChanged) { |
| 2495 | mDetails = details; |
| 2496 | } |
| 2497 | |
| 2498 | boolean cannedTextResponsesChanged = false; |
Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 2499 | if (mCannedTextResponses == null && parcelableCall.getCannedSmsResponses() != null |
| 2500 | && !parcelableCall.getCannedSmsResponses().isEmpty()) { |
| 2501 | mCannedTextResponses = |
| 2502 | Collections.unmodifiableList(parcelableCall.getCannedSmsResponses()); |
Yorke Lee | e886f63 | 2015-08-04 13:43:31 -0700 | [diff] [blame] | 2503 | cannedTextResponsesChanged = true; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2504 | } |
| 2505 | |
Tyler Gunn | d1fdf3a | 2019-11-05 15:47:58 -0800 | [diff] [blame] | 2506 | IVideoProvider previousVideoProvider = mVideoCallImpl == null ? null : |
| 2507 | mVideoCallImpl.getVideoProvider(); |
| 2508 | IVideoProvider newVideoProvider = parcelableCall.getVideoProvider(); |
| 2509 | |
| 2510 | // parcelableCall.isVideoCallProviderChanged is only true when we have a video provider |
| 2511 | // specified; so we should check if the actual IVideoProvider changes as well. |
| 2512 | boolean videoCallChanged = parcelableCall.isVideoCallProviderChanged() |
| 2513 | && !Objects.equals(previousVideoProvider, newVideoProvider); |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 2514 | if (videoCallChanged) { |
Tyler Gunn | d1fdf3a | 2019-11-05 15:47:58 -0800 | [diff] [blame] | 2515 | if (mVideoCallImpl != null) { |
| 2516 | mVideoCallImpl.destroy(); |
| 2517 | } |
| 2518 | mVideoCallImpl = parcelableCall.isVideoCallProviderChanged() ? |
| 2519 | parcelableCall.getVideoCallImpl(mCallingPackage, mTargetSdkVersion) : null; |
Tyler Gunn | 584ba6c | 2015-12-08 10:53:41 -0800 | [diff] [blame] | 2520 | } |
Tyler Gunn | d1fdf3a | 2019-11-05 15:47:58 -0800 | [diff] [blame] | 2521 | |
Tyler Gunn | 584ba6c | 2015-12-08 10:53:41 -0800 | [diff] [blame] | 2522 | if (mVideoCallImpl != null) { |
| 2523 | mVideoCallImpl.setVideoState(getDetails().getVideoState()); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2524 | } |
| 2525 | |
Santos Cordon | e3c507b | 2015-04-23 14:44:19 -0700 | [diff] [blame] | 2526 | int state = parcelableCall.getState(); |
Hall Liu | 31de23d | 2019-10-11 15:38:29 -0700 | [diff] [blame] | 2527 | if (mTargetSdkVersion < Phone.SDK_VERSION_R && state == Call.STATE_SIMULATED_RINGING) { |
| 2528 | state = Call.STATE_RINGING; |
| 2529 | } |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2530 | boolean stateChanged = mState != state; |
| 2531 | if (stateChanged) { |
| 2532 | mState = state; |
| 2533 | } |
| 2534 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2535 | String parentId = parcelableCall.getParentCallId(); |
| 2536 | boolean parentChanged = !Objects.equals(mParentId, parentId); |
| 2537 | if (parentChanged) { |
| 2538 | mParentId = parentId; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2539 | } |
| 2540 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2541 | List<String> childCallIds = parcelableCall.getChildCallIds(); |
| 2542 | boolean childrenChanged = !Objects.equals(childCallIds, mChildrenIds); |
| 2543 | if (childrenChanged) { |
| 2544 | mChildrenIds.clear(); |
| 2545 | mChildrenIds.addAll(parcelableCall.getChildCallIds()); |
| 2546 | mChildrenCached = false; |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2547 | } |
| 2548 | |
Hall Liu | ef98bf8 | 2020-01-09 15:22:44 -0800 | [diff] [blame] | 2549 | String activeChildCallId = parcelableCall.getActiveChildCallId(); |
| 2550 | boolean activeChildChanged = !Objects.equals(activeChildCallId, |
| 2551 | mActiveGenericConferenceChild); |
| 2552 | if (activeChildChanged) { |
| 2553 | mActiveGenericConferenceChild = activeChildCallId; |
| 2554 | } |
| 2555 | |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2556 | List<String> conferenceableCallIds = parcelableCall.getConferenceableCallIds(); |
| 2557 | List<Call> conferenceableCalls = new ArrayList<Call>(conferenceableCallIds.size()); |
| 2558 | for (String otherId : conferenceableCallIds) { |
| 2559 | if (callIdMap.containsKey(otherId)) { |
| 2560 | conferenceableCalls.add(callIdMap.get(otherId)); |
| 2561 | } |
| 2562 | } |
| 2563 | |
| 2564 | if (!Objects.equals(mConferenceableCalls, conferenceableCalls)) { |
| 2565 | mConferenceableCalls.clear(); |
| 2566 | mConferenceableCalls.addAll(conferenceableCalls); |
| 2567 | fireConferenceableCallsChanged(); |
| 2568 | } |
| 2569 | |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 2570 | boolean isRttChanged = false; |
| 2571 | boolean rttModeChanged = false; |
Hall Liu | e904124 | 2018-02-09 16:40:03 -0800 | [diff] [blame] | 2572 | if (parcelableCall.getIsRttCallChanged() |
| 2573 | && mDetails.hasProperty(Details.PROPERTY_RTT)) { |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 2574 | ParcelableRttCall parcelableRttCall = parcelableCall.getParcelableRttCall(); |
| 2575 | InputStreamReader receiveStream = new InputStreamReader( |
| 2576 | new ParcelFileDescriptor.AutoCloseInputStream( |
| 2577 | parcelableRttCall.getReceiveStream()), |
| 2578 | StandardCharsets.UTF_8); |
| 2579 | OutputStreamWriter transmitStream = new OutputStreamWriter( |
| 2580 | new ParcelFileDescriptor.AutoCloseOutputStream( |
| 2581 | parcelableRttCall.getTransmitStream()), |
| 2582 | StandardCharsets.UTF_8); |
Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 2583 | RttCall newRttCall = new Call.RttCall(mTelecomCallId, |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 2584 | receiveStream, transmitStream, parcelableRttCall.getRttMode(), mInCallAdapter); |
| 2585 | if (mRttCall == null) { |
| 2586 | isRttChanged = true; |
| 2587 | } else if (mRttCall.getRttAudioMode() != newRttCall.getRttAudioMode()) { |
| 2588 | rttModeChanged = true; |
| 2589 | } |
| 2590 | mRttCall = newRttCall; |
| 2591 | } else if (mRttCall != null && parcelableCall.getParcelableRttCall() == null |
| 2592 | && parcelableCall.getIsRttCallChanged()) { |
| 2593 | isRttChanged = true; |
Tyler Gunn | 4cd4248 | 2021-04-30 16:23:15 -0700 | [diff] [blame] | 2594 | mRttCall.close(); |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 2595 | mRttCall = null; |
| 2596 | } |
| 2597 | |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2598 | // Now we fire updates, ensuring that any client who listens to any of these notifications |
| 2599 | // gets the most up-to-date state. |
| 2600 | |
| 2601 | if (stateChanged) { |
| 2602 | fireStateChanged(mState); |
| 2603 | } |
| 2604 | if (detailsChanged) { |
| 2605 | fireDetailsChanged(mDetails); |
| 2606 | } |
| 2607 | if (cannedTextResponsesChanged) { |
| 2608 | fireCannedTextResponsesLoaded(mCannedTextResponses); |
| 2609 | } |
Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 2610 | if (videoCallChanged) { |
Tyler Gunn | 584ba6c | 2015-12-08 10:53:41 -0800 | [diff] [blame] | 2611 | fireVideoCallChanged(mVideoCallImpl); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2612 | } |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2613 | if (parentChanged) { |
| 2614 | fireParentChanged(getParent()); |
| 2615 | } |
Hall Liu | ef98bf8 | 2020-01-09 15:22:44 -0800 | [diff] [blame] | 2616 | if (childrenChanged || activeChildChanged) { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2617 | fireChildrenChanged(getChildren()); |
| 2618 | } |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 2619 | if (isRttChanged) { |
| 2620 | fireOnIsRttChanged(mRttCall != null, mRttCall); |
| 2621 | } |
| 2622 | if (rttModeChanged) { |
| 2623 | fireOnRttModeChanged(mRttCall.getRttAudioMode()); |
| 2624 | } |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2625 | |
| 2626 | // If we have transitioned to DISCONNECTED, that means we need to notify clients and |
| 2627 | // remove ourselves from the Phone. Note that we do this after completing all state updates |
| 2628 | // so a client can cleanly transition all their UI to the state appropriate for a |
| 2629 | // DISCONNECTED Call while still relying on the existence of that Call in the Phone's list. |
| 2630 | if (mState == STATE_DISCONNECTED) { |
| 2631 | fireCallDestroyed(); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2632 | } |
| 2633 | } |
| 2634 | |
| 2635 | /** {@hide} */ |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2636 | final void internalSetPostDialWait(String remaining) { |
| 2637 | mRemainingPostDialSequence = remaining; |
| 2638 | firePostDialWait(mRemainingPostDialSequence); |
| 2639 | } |
| 2640 | |
Sailesh Nepal | 2ab88cc | 2014-07-18 14:49:18 -0700 | [diff] [blame] | 2641 | /** {@hide} */ |
Santos Cordon | f30d7e9 | 2014-08-26 09:54:33 -0700 | [diff] [blame] | 2642 | final void internalSetDisconnected() { |
| 2643 | if (mState != Call.STATE_DISCONNECTED) { |
| 2644 | mState = Call.STATE_DISCONNECTED; |
Tyler Gunn | 1e406ca | 2021-03-18 16:47:14 -0700 | [diff] [blame] | 2645 | if (mDetails != null) { |
| 2646 | mDetails = new Details(mState, |
| 2647 | mDetails.getTelecomCallId(), |
| 2648 | mDetails.getHandle(), |
| 2649 | mDetails.getHandlePresentation(), |
| 2650 | mDetails.getCallerDisplayName(), |
| 2651 | mDetails.getCallerDisplayNamePresentation(), |
| 2652 | mDetails.getAccountHandle(), |
| 2653 | mDetails.getCallCapabilities(), |
| 2654 | mDetails.getCallProperties(), |
| 2655 | mDetails.getDisconnectCause(), |
| 2656 | mDetails.getConnectTimeMillis(), |
| 2657 | mDetails.getGatewayInfo(), |
| 2658 | mDetails.getVideoState(), |
| 2659 | mDetails.getStatusHints(), |
| 2660 | mDetails.getExtras(), |
| 2661 | mDetails.getIntentExtras(), |
| 2662 | mDetails.getCreationTimeMillis(), |
| 2663 | mDetails.getContactDisplayName(), |
| 2664 | mDetails.getCallDirection(), |
Edgar Arriaga | e5bec82 | 2022-10-14 14:25:43 -0700 | [diff] [blame^] | 2665 | mDetails.getCallerNumberVerificationStatus(), |
| 2666 | mDetails.getContactPhotoUri() |
Tyler Gunn | 1e406ca | 2021-03-18 16:47:14 -0700 | [diff] [blame] | 2667 | ); |
| 2668 | fireDetailsChanged(mDetails); |
| 2669 | } |
Santos Cordon | f30d7e9 | 2014-08-26 09:54:33 -0700 | [diff] [blame] | 2670 | fireStateChanged(mState); |
| 2671 | fireCallDestroyed(); |
Santos Cordon | f30d7e9 | 2014-08-26 09:54:33 -0700 | [diff] [blame] | 2672 | } |
| 2673 | } |
| 2674 | |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 2675 | /** {@hide} */ |
| 2676 | final void internalOnConnectionEvent(String event, Bundle extras) { |
| 2677 | fireOnConnectionEvent(event, extras); |
| 2678 | } |
| 2679 | |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 2680 | /** {@hide} */ |
| 2681 | final void internalOnRttUpgradeRequest(final int requestId) { |
| 2682 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 2683 | final Call call = this; |
| 2684 | final Callback callback = record.getCallback(); |
| 2685 | record.getHandler().post(() -> callback.onRttRequest(call, requestId)); |
| 2686 | } |
| 2687 | } |
| 2688 | |
Hall Liu | 57006aa | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 2689 | /** @hide */ |
| 2690 | final void internalOnRttInitiationFailure(int reason) { |
| 2691 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 2692 | final Call call = this; |
| 2693 | final Callback callback = record.getCallback(); |
| 2694 | record.getHandler().post(() -> callback.onRttInitiationFailure(call, reason)); |
| 2695 | } |
| 2696 | } |
| 2697 | |
Sanket Padawe | 85291f6 | 2017-12-01 13:59:27 -0800 | [diff] [blame] | 2698 | /** {@hide} */ |
| 2699 | final void internalOnHandoverFailed(int error) { |
| 2700 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 2701 | final Call call = this; |
| 2702 | final Callback callback = record.getCallback(); |
| 2703 | record.getHandler().post(() -> callback.onHandoverFailed(call, error)); |
| 2704 | } |
| 2705 | } |
| 2706 | |
Tyler Gunn | 858bfaf | 2018-01-22 15:17:54 -0800 | [diff] [blame] | 2707 | /** {@hide} */ |
| 2708 | final void internalOnHandoverComplete() { |
| 2709 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 2710 | final Call call = this; |
| 2711 | final Callback callback = record.getCallback(); |
| 2712 | record.getHandler().post(() -> callback.onHandoverComplete(call)); |
| 2713 | } |
| 2714 | } |
| 2715 | |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 2716 | private void fireStateChanged(final int newState) { |
| 2717 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 2718 | final Call call = this; |
| 2719 | final Callback callback = record.getCallback(); |
| 2720 | record.getHandler().post(new Runnable() { |
| 2721 | @Override |
| 2722 | public void run() { |
| 2723 | callback.onStateChanged(call, newState); |
| 2724 | } |
| 2725 | }); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2726 | } |
| 2727 | } |
| 2728 | |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 2729 | private void fireParentChanged(final Call newParent) { |
| 2730 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 2731 | final Call call = this; |
| 2732 | final Callback callback = record.getCallback(); |
| 2733 | record.getHandler().post(new Runnable() { |
| 2734 | @Override |
| 2735 | public void run() { |
| 2736 | callback.onParentChanged(call, newParent); |
| 2737 | } |
| 2738 | }); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2739 | } |
| 2740 | } |
| 2741 | |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 2742 | private void fireChildrenChanged(final List<Call> children) { |
| 2743 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 2744 | final Call call = this; |
| 2745 | final Callback callback = record.getCallback(); |
| 2746 | record.getHandler().post(new Runnable() { |
| 2747 | @Override |
| 2748 | public void run() { |
| 2749 | callback.onChildrenChanged(call, children); |
| 2750 | } |
| 2751 | }); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2752 | } |
| 2753 | } |
| 2754 | |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 2755 | private void fireDetailsChanged(final Details details) { |
| 2756 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 2757 | final Call call = this; |
| 2758 | final Callback callback = record.getCallback(); |
| 2759 | record.getHandler().post(new Runnable() { |
| 2760 | @Override |
| 2761 | public void run() { |
| 2762 | callback.onDetailsChanged(call, details); |
| 2763 | } |
| 2764 | }); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2765 | } |
| 2766 | } |
| 2767 | |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 2768 | private void fireCannedTextResponsesLoaded(final List<String> cannedTextResponses) { |
| 2769 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 2770 | final Call call = this; |
| 2771 | final Callback callback = record.getCallback(); |
| 2772 | record.getHandler().post(new Runnable() { |
| 2773 | @Override |
| 2774 | public void run() { |
| 2775 | callback.onCannedTextResponsesLoaded(call, cannedTextResponses); |
| 2776 | } |
| 2777 | }); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2778 | } |
| 2779 | } |
| 2780 | |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 2781 | private void fireVideoCallChanged(final InCallService.VideoCall videoCall) { |
| 2782 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 2783 | final Call call = this; |
| 2784 | final Callback callback = record.getCallback(); |
| 2785 | record.getHandler().post(new Runnable() { |
| 2786 | @Override |
| 2787 | public void run() { |
| 2788 | callback.onVideoCallChanged(call, videoCall); |
| 2789 | } |
| 2790 | }); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2791 | } |
| 2792 | } |
| 2793 | |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 2794 | private void firePostDialWait(final String remainingPostDialSequence) { |
| 2795 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 2796 | final Call call = this; |
| 2797 | final Callback callback = record.getCallback(); |
| 2798 | record.getHandler().post(new Runnable() { |
| 2799 | @Override |
| 2800 | public void run() { |
| 2801 | callback.onPostDialWait(call, remainingPostDialSequence); |
| 2802 | } |
| 2803 | }); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2804 | } |
| 2805 | } |
| 2806 | |
| 2807 | private void fireCallDestroyed() { |
Roshan Pius | 1ca6207 | 2015-07-07 17:34:51 -0700 | [diff] [blame] | 2808 | /** |
| 2809 | * To preserve the ordering of the Call's onCallDestroyed callback and Phone's |
| 2810 | * onCallRemoved callback, we remove this call from the Phone's record |
| 2811 | * only once all of the registered onCallDestroyed callbacks are executed. |
| 2812 | * All the callbacks get removed from our records as a part of this operation |
| 2813 | * since onCallDestroyed is the final callback. |
| 2814 | */ |
| 2815 | final Call call = this; |
| 2816 | if (mCallbackRecords.isEmpty()) { |
| 2817 | // No callbacks registered, remove the call from Phone's record. |
| 2818 | mPhone.internalRemoveCall(call); |
| 2819 | } |
| 2820 | for (final CallbackRecord<Callback> record : mCallbackRecords) { |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 2821 | final Callback callback = record.getCallback(); |
| 2822 | record.getHandler().post(new Runnable() { |
| 2823 | @Override |
| 2824 | public void run() { |
Roshan Pius | 1ca6207 | 2015-07-07 17:34:51 -0700 | [diff] [blame] | 2825 | boolean isFinalRemoval = false; |
| 2826 | RuntimeException toThrow = null; |
| 2827 | try { |
| 2828 | callback.onCallDestroyed(call); |
| 2829 | } catch (RuntimeException e) { |
| 2830 | toThrow = e; |
| 2831 | } |
| 2832 | synchronized(Call.this) { |
| 2833 | mCallbackRecords.remove(record); |
| 2834 | if (mCallbackRecords.isEmpty()) { |
| 2835 | isFinalRemoval = true; |
| 2836 | } |
| 2837 | } |
| 2838 | if (isFinalRemoval) { |
| 2839 | mPhone.internalRemoveCall(call); |
| 2840 | } |
| 2841 | if (toThrow != null) { |
| 2842 | throw toThrow; |
| 2843 | } |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 2844 | } |
| 2845 | }); |
Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 2846 | } |
| 2847 | } |
| 2848 | |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2849 | private void fireConferenceableCallsChanged() { |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 2850 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 2851 | final Call call = this; |
| 2852 | final Callback callback = record.getCallback(); |
| 2853 | record.getHandler().post(new Runnable() { |
| 2854 | @Override |
| 2855 | public void run() { |
| 2856 | callback.onConferenceableCallsChanged(call, mUnmodifiableConferenceableCalls); |
| 2857 | } |
| 2858 | }); |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2859 | } |
| 2860 | } |
Tyler Gunn | 1e9bfc6 | 2015-08-19 11:18:58 -0700 | [diff] [blame] | 2861 | |
| 2862 | /** |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 2863 | * Notifies listeners of an incoming connection event. |
| 2864 | * <p> |
| 2865 | * Connection events are issued via {@link Connection#sendConnectionEvent(String, Bundle)}. |
| 2866 | * |
| 2867 | * @param event |
| 2868 | * @param extras |
| 2869 | */ |
| 2870 | private void fireOnConnectionEvent(final String event, final Bundle extras) { |
| 2871 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 2872 | final Call call = this; |
| 2873 | final Callback callback = record.getCallback(); |
| 2874 | record.getHandler().post(new Runnable() { |
| 2875 | @Override |
| 2876 | public void run() { |
| 2877 | callback.onConnectionEvent(call, event, extras); |
| 2878 | } |
| 2879 | }); |
| 2880 | } |
| 2881 | } |
| 2882 | |
| 2883 | /** |
Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 2884 | * Notifies listeners of an RTT on/off change |
| 2885 | * |
| 2886 | * @param enabled True if RTT is now enabled, false otherwise |
| 2887 | */ |
| 2888 | private void fireOnIsRttChanged(final boolean enabled, final RttCall rttCall) { |
| 2889 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 2890 | final Call call = this; |
| 2891 | final Callback callback = record.getCallback(); |
| 2892 | record.getHandler().post(() -> callback.onRttStatusChanged(call, enabled, rttCall)); |
| 2893 | } |
| 2894 | } |
| 2895 | |
| 2896 | /** |
| 2897 | * Notifies listeners of a RTT mode change |
| 2898 | * |
| 2899 | * @param mode The new RTT mode |
| 2900 | */ |
| 2901 | private void fireOnRttModeChanged(final int mode) { |
| 2902 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 2903 | final Call call = this; |
| 2904 | final Callback callback = record.getCallback(); |
| 2905 | record.getHandler().post(() -> callback.onRttModeChanged(call, mode)); |
| 2906 | } |
| 2907 | } |
| 2908 | |
| 2909 | /** |
Tyler Gunn | 1e9bfc6 | 2015-08-19 11:18:58 -0700 | [diff] [blame] | 2910 | * Determines if two bundles are equal. |
| 2911 | * |
| 2912 | * @param bundle The original bundle. |
| 2913 | * @param newBundle The bundle to compare with. |
| 2914 | * @retrun {@code true} if the bundles are equal, {@code false} otherwise. |
| 2915 | */ |
| 2916 | private static boolean areBundlesEqual(Bundle bundle, Bundle newBundle) { |
| 2917 | if (bundle == null || newBundle == null) { |
| 2918 | return bundle == newBundle; |
| 2919 | } |
| 2920 | |
| 2921 | if (bundle.size() != newBundle.size()) { |
| 2922 | return false; |
| 2923 | } |
| 2924 | |
| 2925 | for(String key : bundle.keySet()) { |
| 2926 | if (key != null) { |
| 2927 | final Object value = bundle.get(key); |
| 2928 | final Object newValue = newBundle.get(key); |
Grace Jia | 17005bd | 2022-05-12 12:49:02 -0700 | [diff] [blame] | 2929 | if (!newBundle.containsKey(key)) { |
| 2930 | return false; |
| 2931 | } |
| 2932 | if (value instanceof Bundle && newValue instanceof Bundle) { |
| 2933 | if (!areBundlesEqual((Bundle) value, (Bundle) newValue)) { |
| 2934 | return false; |
| 2935 | } |
| 2936 | } |
| 2937 | if (value instanceof byte[] && newValue instanceof byte[]) { |
| 2938 | if (!Arrays.equals((byte[]) value, (byte[]) newValue)) { |
| 2939 | return false; |
| 2940 | } |
| 2941 | } else if (!Objects.equals(value, newValue)) { |
Tyler Gunn | 1e9bfc6 | 2015-08-19 11:18:58 -0700 | [diff] [blame] | 2942 | return false; |
| 2943 | } |
| 2944 | } |
| 2945 | } |
| 2946 | return true; |
| 2947 | } |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2948 | } |