| 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 | |
| Gabriel Peal | b95f169 | 2014-08-19 14:24:18 -0700 | [diff] [blame] | 19 | import android.annotation.SystemApi; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 20 | import android.net.Uri; |
| Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 21 | import android.os.Bundle; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 22 | |
| Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 23 | import java.lang.String; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 24 | import java.util.ArrayList; |
| 25 | import java.util.Collections; |
| 26 | import java.util.List; |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 27 | import java.util.Map; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 28 | import java.util.Objects; |
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 29 | import java.util.concurrent.CopyOnWriteArrayList; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 30 | |
| 31 | /** |
| 32 | * Represents an ongoing phone call that the in-call app should present to the user. |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 33 | * |
| 34 | * {@hide} |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 35 | */ |
| Gabriel Peal | b95f169 | 2014-08-19 14:24:18 -0700 | [diff] [blame] | 36 | @SystemApi |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 37 | public final class Call { |
| 38 | /** |
| 39 | * The state of a {@code Call} when newly created. |
| 40 | */ |
| 41 | public static final int STATE_NEW = 0; |
| 42 | |
| 43 | /** |
| 44 | * The state of an outgoing {@code Call} when dialing the remote number, but not yet connected. |
| 45 | */ |
| 46 | public static final int STATE_DIALING = 1; |
| 47 | |
| 48 | /** |
| 49 | * The state of an incoming {@code Call} when ringing locally, but not yet connected. |
| 50 | */ |
| 51 | public static final int STATE_RINGING = 2; |
| 52 | |
| 53 | /** |
| 54 | * The state of a {@code Call} when in a holding state. |
| 55 | */ |
| 56 | public static final int STATE_HOLDING = 3; |
| 57 | |
| 58 | /** |
| 59 | * The state of a {@code Call} when actively supporting conversation. |
| 60 | */ |
| 61 | public static final int STATE_ACTIVE = 4; |
| 62 | |
| 63 | /** |
| 64 | * The state of a {@code Call} when no further voice or other communication is being |
| 65 | * transmitted, the remote side has been or will inevitably be informed that the {@code Call} |
| 66 | * is no longer active, and the local data transport has or inevitably will release resources |
| 67 | * associated with this {@code Call}. |
| 68 | */ |
| 69 | public static final int STATE_DISCONNECTED = 7; |
| 70 | |
| Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 71 | /** |
| 72 | * The state of an outgoing {@code Call}, but waiting for user input before proceeding. |
| 73 | */ |
| 74 | public static final int STATE_PRE_DIAL_WAIT = 8; |
| 75 | |
| Nancy Chen | e20930f | 2014-08-07 16:17:21 -0700 | [diff] [blame] | 76 | /** |
| Nancy Chen | e9b7a8e | 2014-08-08 14:26:27 -0700 | [diff] [blame] | 77 | * The initial state of an outgoing {@code Call}. |
| 78 | * Common transitions are to {@link #STATE_DIALING} state for a successful call or |
| 79 | * {@link #STATE_DISCONNECTED} if it failed. |
| Nancy Chen | e20930f | 2014-08-07 16:17:21 -0700 | [diff] [blame] | 80 | */ |
| 81 | public static final int STATE_CONNECTING = 9; |
| 82 | |
| Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 83 | /** |
| Tyler Gunn | 4afc6af | 2014-10-07 10:14:55 -0700 | [diff] [blame] | 84 | * The state of a {@code Call} when the user has initiated a disconnection of the call, but the |
| 85 | * call has not yet been disconnected by the underlying {@code ConnectionService}. The next |
| 86 | * state of the call is (potentially) {@link #STATE_DISCONNECTED}. |
| 87 | */ |
| 88 | public static final int STATE_DISCONNECTING = 10; |
| 89 | |
| 90 | /** |
| Nancy Chen | 513c892 | 2014-09-17 14:47:20 -0700 | [diff] [blame] | 91 | * The key to retrieve the optional {@code PhoneAccount}s Telecom can bundle with its Call |
| 92 | * extras. Used to pass the phone accounts to display on the front end to the user in order to |
| 93 | * select phone accounts to (for example) place a call. |
| 94 | * |
| 95 | * @hide |
| 96 | */ |
| 97 | public static final String AVAILABLE_PHONE_ACCOUNTS = "selectPhoneAccountAccounts"; |
| 98 | |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 99 | public static class Details { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 100 | |
| 101 | /** Call can currently be put on hold or unheld. */ |
| 102 | public static final int CAPABILITY_HOLD = 0x00000001; |
| 103 | |
| 104 | /** Call supports the hold feature. */ |
| 105 | public static final int CAPABILITY_SUPPORT_HOLD = 0x00000002; |
| 106 | |
| 107 | /** |
| 108 | * Calls within a conference can be merged. A {@link ConnectionService} has the option to |
| 109 | * add a {@link Conference} call before the child {@link Connection}s are merged. This is how |
| 110 | * CDMA-based {@link Connection}s are implemented. For these unmerged {@link Conference}s, this |
| 111 | * capability allows a merge button to be shown while the conference call is in the foreground |
| 112 | * of the in-call UI. |
| 113 | * <p> |
| 114 | * This is only intended for use by a {@link Conference}. |
| 115 | */ |
| 116 | public static final int CAPABILITY_MERGE_CONFERENCE = 0x00000004; |
| 117 | |
| 118 | /** |
| 119 | * Calls within a conference can be swapped between foreground and background. |
| 120 | * See {@link #CAPABILITY_MERGE_CONFERENCE} for additional information. |
| 121 | * <p> |
| 122 | * This is only intended for use by a {@link Conference}. |
| 123 | */ |
| 124 | public static final int CAPABILITY_SWAP_CONFERENCE = 0x00000008; |
| 125 | |
| 126 | /** |
| 127 | * @hide |
| 128 | */ |
| 129 | public static final int CAPABILITY_UNUSED = 0x00000010; |
| 130 | |
| 131 | /** Call supports responding via text option. */ |
| 132 | public static final int CAPABILITY_RESPOND_VIA_TEXT = 0x00000020; |
| 133 | |
| 134 | /** Call can be muted. */ |
| 135 | public static final int CAPABILITY_MUTE = 0x00000040; |
| 136 | |
| 137 | /** |
| 138 | * Call supports conference call management. This capability only applies to {@link Conference} |
| 139 | * calls which can have {@link Connection}s as children. |
| 140 | */ |
| 141 | public static final int CAPABILITY_MANAGE_CONFERENCE = 0x00000080; |
| 142 | |
| 143 | /** |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 144 | * Local device supports receiving video. |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 145 | * @hide |
| 146 | */ |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 147 | public static final int CAPABILITY_SUPPORTS_VT_LOCAL_RX = 0x00000100; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 148 | |
| 149 | /** |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 150 | * Local device supports transmitting video. |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 151 | * @hide |
| 152 | */ |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 153 | public static final int CAPABILITY_SUPPORTS_VT_LOCAL_TX = 0x00000200; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 154 | |
| 155 | /** |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 156 | * Local device supports bidirectional video calling. |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 157 | * @hide |
| 158 | */ |
| Andrew Lee | 9a8f9ce | 2015-04-10 18:09:46 -0700 | [diff] [blame^] | 159 | public static final int CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL = |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 160 | CAPABILITY_SUPPORTS_VT_LOCAL_RX | CAPABILITY_SUPPORTS_VT_LOCAL_TX; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 161 | |
| 162 | /** |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 163 | * Remote device supports receiving video. |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 164 | * @hide |
| 165 | */ |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 166 | public static final int CAPABILITY_SUPPORTS_VT_REMOTE_RX = 0x00000400; |
| 167 | |
| 168 | /** |
| 169 | * Remote device supports transmitting video. |
| 170 | * @hide |
| 171 | */ |
| 172 | public static final int CAPABILITY_SUPPORTS_VT_REMOTE_TX = 0x00000800; |
| 173 | |
| 174 | /** |
| 175 | * Remote device supports bidirectional video calling. |
| 176 | * @hide |
| 177 | */ |
| Andrew Lee | 9a8f9ce | 2015-04-10 18:09:46 -0700 | [diff] [blame^] | 178 | public static final int CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL = |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 179 | CAPABILITY_SUPPORTS_VT_REMOTE_RX | CAPABILITY_SUPPORTS_VT_REMOTE_TX; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 180 | |
| 181 | /** |
| 182 | * Call is able to be separated from its parent {@code Conference}, if any. |
| 183 | */ |
| 184 | public static final int CAPABILITY_SEPARATE_FROM_CONFERENCE = 0x00001000; |
| 185 | |
| 186 | /** |
| 187 | * Call is able to be individually disconnected when in a {@code Conference}. |
| 188 | */ |
| 189 | public static final int CAPABILITY_DISCONNECT_FROM_CONFERENCE = 0x00002000; |
| 190 | |
| 191 | /** |
| 192 | * Whether the call is a generic conference, where we do not know the precise state of |
| 193 | * participants in the conference (eg. on CDMA). |
| 194 | * |
| 195 | * @hide |
| 196 | */ |
| 197 | public static final int CAPABILITY_GENERIC_CONFERENCE = 0x00004000; |
| 198 | |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 199 | /** |
| 200 | * Call is using high definition audio. |
| 201 | * @hide |
| 202 | */ |
| 203 | public static final int CAPABILITY_HIGH_DEF_AUDIO = 0x00008000; |
| 204 | |
| 205 | /** |
| 206 | * Call is using WIFI. |
| 207 | * @hide |
| 208 | */ |
| 209 | public static final int CAPABILITY_WIFI = 0x00010000; |
| 210 | |
| Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 211 | /** |
| 212 | * Indicates that the current device callback number should be shown. |
| 213 | * |
| 214 | * @hide |
| 215 | */ |
| Tyler Gunn | 96d6c40 | 2015-03-18 12:39:23 -0700 | [diff] [blame] | 216 | public static final int CAPABILITY_SHOW_CALLBACK_NUMBER = 0x00020000; |
| 217 | |
| 218 | /** |
| Dong Zhou | 89f41eb | 2015-03-15 11:59:49 -0500 | [diff] [blame] | 219 | * Speed up audio setup for MT call. |
| 220 | * @hide |
| 221 | */ |
| Tyler Gunn | 96d6c40 | 2015-03-18 12:39:23 -0700 | [diff] [blame] | 222 | public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00040000; |
| 223 | |
| 224 | //********************************************************************************************** |
| 225 | // Next CAPABILITY value: 0x00080000 |
| Tyler Gunn | d11a315 | 2015-03-18 13:09:14 -0700 | [diff] [blame] | 226 | //****************************************************************************************** |
| Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 227 | |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 228 | private final Uri mHandle; |
| 229 | private final int mHandlePresentation; |
| 230 | private final String mCallerDisplayName; |
| 231 | private final int mCallerDisplayNamePresentation; |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 232 | private final PhoneAccountHandle mAccountHandle; |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 233 | private final int mCallCapabilities; |
| Andrew Lee | 223ad14 | 2014-08-27 16:33:08 -0700 | [diff] [blame] | 234 | private final int mCallProperties; |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 235 | private final DisconnectCause mDisconnectCause; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 236 | private final long mConnectTimeMillis; |
| 237 | private final GatewayInfo mGatewayInfo; |
| Andrew Lee | 85f5d42 | 2014-07-11 17:22:03 -0700 | [diff] [blame] | 238 | private final int mVideoState; |
| Evan Charlton | 5b49ade | 2014-07-15 17:03:20 -0700 | [diff] [blame] | 239 | private final StatusHints mStatusHints; |
| Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 240 | private final Bundle mExtras; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 241 | |
| 242 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 243 | * Whether the supplied capabilities supports the specified capability. |
| 244 | * |
| 245 | * @param capabilities A bit field of capabilities. |
| 246 | * @param capability The capability to check capabilities for. |
| 247 | * @return Whether the specified capability is supported. |
| 248 | * @hide |
| 249 | */ |
| 250 | public static boolean can(int capabilities, int capability) { |
| 251 | return (capabilities & capability) != 0; |
| 252 | } |
| 253 | |
| 254 | /** |
| 255 | * Whether the capabilities of this {@code Details} supports the specified capability. |
| 256 | * |
| 257 | * @param capability The capability to check capabilities for. |
| 258 | * @return Whether the specified capability is supported. |
| 259 | * @hide |
| 260 | */ |
| 261 | public boolean can(int capability) { |
| 262 | return can(mCallCapabilities, capability); |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * Render a set of capability bits ({@code CAPABILITY_*}) as a human readable string. |
| 267 | * |
| 268 | * @param capabilities A capability bit field. |
| 269 | * @return A human readable string representation. |
| 270 | */ |
| 271 | public static String capabilitiesToString(int capabilities) { |
| 272 | StringBuilder builder = new StringBuilder(); |
| 273 | builder.append("[Capabilities:"); |
| 274 | if (can(capabilities, CAPABILITY_HOLD)) { |
| 275 | builder.append(" CAPABILITY_HOLD"); |
| 276 | } |
| 277 | if (can(capabilities, CAPABILITY_SUPPORT_HOLD)) { |
| 278 | builder.append(" CAPABILITY_SUPPORT_HOLD"); |
| 279 | } |
| 280 | if (can(capabilities, CAPABILITY_MERGE_CONFERENCE)) { |
| 281 | builder.append(" CAPABILITY_MERGE_CONFERENCE"); |
| 282 | } |
| 283 | if (can(capabilities, CAPABILITY_SWAP_CONFERENCE)) { |
| 284 | builder.append(" CAPABILITY_SWAP_CONFERENCE"); |
| 285 | } |
| 286 | if (can(capabilities, CAPABILITY_RESPOND_VIA_TEXT)) { |
| 287 | builder.append(" CAPABILITY_RESPOND_VIA_TEXT"); |
| 288 | } |
| 289 | if (can(capabilities, CAPABILITY_MUTE)) { |
| 290 | builder.append(" CAPABILITY_MUTE"); |
| 291 | } |
| 292 | if (can(capabilities, CAPABILITY_MANAGE_CONFERENCE)) { |
| 293 | builder.append(" CAPABILITY_MANAGE_CONFERENCE"); |
| 294 | } |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 295 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_RX)) { |
| 296 | builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_RX"); |
| 297 | } |
| 298 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_TX)) { |
| 299 | builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_TX"); |
| 300 | } |
| Andrew Lee | 9a8f9ce | 2015-04-10 18:09:46 -0700 | [diff] [blame^] | 301 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL)) { |
| 302 | builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL"); |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 303 | } |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 304 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_RX)) { |
| 305 | builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_RX"); |
| 306 | } |
| 307 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_TX)) { |
| 308 | builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_TX"); |
| 309 | } |
| Andrew Lee | 9a8f9ce | 2015-04-10 18:09:46 -0700 | [diff] [blame^] | 310 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL)) { |
| 311 | builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL"); |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 312 | } |
| Andrew Lee | 80fff3c | 2014-11-25 17:36:51 -0800 | [diff] [blame] | 313 | if (can(capabilities, CAPABILITY_HIGH_DEF_AUDIO)) { |
| 314 | builder.append(" CAPABILITY_HIGH_DEF_AUDIO"); |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 315 | } |
| Andrew Lee | 1a8ae3e | 2015-02-02 13:42:38 -0800 | [diff] [blame] | 316 | if (can(capabilities, CAPABILITY_WIFI)) { |
| 317 | builder.append(" CAPABILITY_WIFI"); |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 318 | } |
| 319 | if (can(capabilities, CAPABILITY_GENERIC_CONFERENCE)) { |
| 320 | builder.append(" CAPABILITY_GENERIC_CONFERENCE"); |
| 321 | } |
| Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 322 | if (can(capabilities, CAPABILITY_SHOW_CALLBACK_NUMBER)) { |
| 323 | builder.append(" CAPABILITY_SHOW_CALLBACK_NUMBER"); |
| 324 | } |
| Dong Zhou | 89f41eb | 2015-03-15 11:59:49 -0500 | [diff] [blame] | 325 | if (can(capabilities, CAPABILITY_SPEED_UP_MT_AUDIO)) { |
| Tyler Gunn | d11a315 | 2015-03-18 13:09:14 -0700 | [diff] [blame] | 326 | builder.append(" CAPABILITY_SPEED_UP_MT_AUDIO"); |
| Dong Zhou | 89f41eb | 2015-03-15 11:59:49 -0500 | [diff] [blame] | 327 | } |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 328 | builder.append("]"); |
| 329 | return builder.toString(); |
| 330 | } |
| 331 | |
| 332 | /** |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 333 | * @return The handle (e.g., phone number) to which the {@code Call} is currently |
| 334 | * connected. |
| 335 | */ |
| 336 | public Uri getHandle() { |
| 337 | return mHandle; |
| 338 | } |
| 339 | |
| 340 | /** |
| 341 | * @return The presentation requirements for the handle. See |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 342 | * {@link TelecomManager} for valid values. |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 343 | */ |
| 344 | public int getHandlePresentation() { |
| 345 | return mHandlePresentation; |
| 346 | } |
| 347 | |
| 348 | /** |
| 349 | * @return The display name for the caller. |
| 350 | */ |
| 351 | public String getCallerDisplayName() { |
| 352 | return mCallerDisplayName; |
| 353 | } |
| 354 | |
| 355 | /** |
| 356 | * @return The presentation requirements for the caller display name. See |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 357 | * {@link TelecomManager} for valid values. |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 358 | */ |
| 359 | public int getCallerDisplayNamePresentation() { |
| 360 | return mCallerDisplayNamePresentation; |
| 361 | } |
| 362 | |
| 363 | /** |
| Evan Charlton | 6eb262c | 2014-07-19 18:18:19 -0700 | [diff] [blame] | 364 | * @return The {@code PhoneAccountHandle} whereby the {@code Call} is currently being |
| 365 | * routed. |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 366 | */ |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 367 | public PhoneAccountHandle getAccountHandle() { |
| 368 | return mAccountHandle; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 372 | * @return A bitmask of the capabilities of the {@code Call}, as defined by the various |
| 373 | * {@code CAPABILITY_*} constants in this class. |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 374 | */ |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 375 | public int getCallCapabilities() { |
| 376 | return mCallCapabilities; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | /** |
| Andrew Lee | 223ad14 | 2014-08-27 16:33:08 -0700 | [diff] [blame] | 380 | * @return A bitmask of the properties of the {@code Call}, as defined in |
| 381 | * {@link CallProperties}. |
| 382 | */ |
| 383 | public int getCallProperties() { |
| 384 | return mCallProperties; |
| 385 | } |
| 386 | |
| 387 | /** |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 388 | * @return For a {@link #STATE_DISCONNECTED} {@code Call}, the disconnect cause expressed |
| Nancy Chen | f4cf77c | 2014-09-19 10:53:21 -0700 | [diff] [blame] | 389 | * by {@link android.telecom.DisconnectCause}. |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 390 | */ |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 391 | public DisconnectCause getDisconnectCause() { |
| 392 | return mDisconnectCause; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | /** |
| 396 | * @return The time the {@code Call} has been connected. This information is updated |
| 397 | * periodically, but user interfaces should not rely on this to display any "call time |
| 398 | * clock". |
| 399 | */ |
| 400 | public long getConnectTimeMillis() { |
| 401 | return mConnectTimeMillis; |
| 402 | } |
| 403 | |
| 404 | /** |
| 405 | * @return Information about any calling gateway the {@code Call} may be using. |
| 406 | */ |
| 407 | public GatewayInfo getGatewayInfo() { |
| 408 | return mGatewayInfo; |
| 409 | } |
| 410 | |
| Andrew Lee | 7a34138 | 2014-07-15 17:05:08 -0700 | [diff] [blame] | 411 | /** |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 412 | * @return The video state of the {@code Call}. |
| Andrew Lee | 7a34138 | 2014-07-15 17:05:08 -0700 | [diff] [blame] | 413 | */ |
| 414 | public int getVideoState() { |
| 415 | return mVideoState; |
| 416 | } |
| 417 | |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 418 | /** |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 419 | * @return The current {@link android.telecom.StatusHints}, or {@code null} if none |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 420 | * have been set. |
| Evan Charlton | 5b49ade | 2014-07-15 17:03:20 -0700 | [diff] [blame] | 421 | */ |
| 422 | public StatusHints getStatusHints() { |
| 423 | return mStatusHints; |
| 424 | } |
| 425 | |
| Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 426 | /** |
| 427 | * @return A bundle extras to pass with the call |
| 428 | */ |
| 429 | public Bundle getExtras() { |
| 430 | return mExtras; |
| 431 | } |
| 432 | |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 433 | @Override |
| 434 | public boolean equals(Object o) { |
| 435 | if (o instanceof Details) { |
| 436 | Details d = (Details) o; |
| 437 | return |
| 438 | Objects.equals(mHandle, d.mHandle) && |
| 439 | Objects.equals(mHandlePresentation, d.mHandlePresentation) && |
| 440 | Objects.equals(mCallerDisplayName, d.mCallerDisplayName) && |
| 441 | Objects.equals(mCallerDisplayNamePresentation, |
| 442 | d.mCallerDisplayNamePresentation) && |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 443 | Objects.equals(mAccountHandle, d.mAccountHandle) && |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 444 | Objects.equals(mCallCapabilities, d.mCallCapabilities) && |
| Andrew Lee | 223ad14 | 2014-08-27 16:33:08 -0700 | [diff] [blame] | 445 | Objects.equals(mCallProperties, d.mCallProperties) && |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 446 | Objects.equals(mDisconnectCause, d.mDisconnectCause) && |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 447 | Objects.equals(mConnectTimeMillis, d.mConnectTimeMillis) && |
| Andrew Lee | 85f5d42 | 2014-07-11 17:22:03 -0700 | [diff] [blame] | 448 | Objects.equals(mGatewayInfo, d.mGatewayInfo) && |
| Evan Charlton | 5b49ade | 2014-07-15 17:03:20 -0700 | [diff] [blame] | 449 | Objects.equals(mVideoState, d.mVideoState) && |
| Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 450 | Objects.equals(mStatusHints, d.mStatusHints) && |
| 451 | Objects.equals(mExtras, d.mExtras); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 452 | } |
| 453 | return false; |
| 454 | } |
| 455 | |
| 456 | @Override |
| 457 | public int hashCode() { |
| 458 | return |
| 459 | Objects.hashCode(mHandle) + |
| 460 | Objects.hashCode(mHandlePresentation) + |
| 461 | Objects.hashCode(mCallerDisplayName) + |
| 462 | Objects.hashCode(mCallerDisplayNamePresentation) + |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 463 | Objects.hashCode(mAccountHandle) + |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 464 | Objects.hashCode(mCallCapabilities) + |
| Andrew Lee | 223ad14 | 2014-08-27 16:33:08 -0700 | [diff] [blame] | 465 | Objects.hashCode(mCallProperties) + |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 466 | Objects.hashCode(mDisconnectCause) + |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 467 | Objects.hashCode(mConnectTimeMillis) + |
| Andrew Lee | 85f5d42 | 2014-07-11 17:22:03 -0700 | [diff] [blame] | 468 | Objects.hashCode(mGatewayInfo) + |
| Evan Charlton | 5b49ade | 2014-07-15 17:03:20 -0700 | [diff] [blame] | 469 | Objects.hashCode(mVideoState) + |
| Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 470 | Objects.hashCode(mStatusHints) + |
| 471 | Objects.hashCode(mExtras); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | /** {@hide} */ |
| 475 | public Details( |
| 476 | Uri handle, |
| 477 | int handlePresentation, |
| 478 | String callerDisplayName, |
| 479 | int callerDisplayNamePresentation, |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 480 | PhoneAccountHandle accountHandle, |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 481 | int capabilities, |
| Andrew Lee | 223ad14 | 2014-08-27 16:33:08 -0700 | [diff] [blame] | 482 | int properties, |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 483 | DisconnectCause disconnectCause, |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 484 | long connectTimeMillis, |
| Andrew Lee | 85f5d42 | 2014-07-11 17:22:03 -0700 | [diff] [blame] | 485 | GatewayInfo gatewayInfo, |
| Evan Charlton | 5b49ade | 2014-07-15 17:03:20 -0700 | [diff] [blame] | 486 | int videoState, |
| Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 487 | StatusHints statusHints, |
| 488 | Bundle extras) { |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 489 | mHandle = handle; |
| 490 | mHandlePresentation = handlePresentation; |
| 491 | mCallerDisplayName = callerDisplayName; |
| 492 | mCallerDisplayNamePresentation = callerDisplayNamePresentation; |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 493 | mAccountHandle = accountHandle; |
| Ihab Awad | 5d0410f | 2014-07-30 10:07:40 -0700 | [diff] [blame] | 494 | mCallCapabilities = capabilities; |
| Andrew Lee | 223ad14 | 2014-08-27 16:33:08 -0700 | [diff] [blame] | 495 | mCallProperties = properties; |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 496 | mDisconnectCause = disconnectCause; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 497 | mConnectTimeMillis = connectTimeMillis; |
| 498 | mGatewayInfo = gatewayInfo; |
| Andrew Lee | 85f5d42 | 2014-07-11 17:22:03 -0700 | [diff] [blame] | 499 | mVideoState = videoState; |
| Evan Charlton | 5b49ade | 2014-07-15 17:03:20 -0700 | [diff] [blame] | 500 | mStatusHints = statusHints; |
| Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 501 | mExtras = extras; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 502 | } |
| 503 | } |
| 504 | |
| 505 | public static abstract class Listener { |
| 506 | /** |
| 507 | * Invoked when the state of this {@code Call} has changed. See {@link #getState()}. |
| 508 | * |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 509 | * @param call The {@code Call} invoking this method. |
| 510 | * @param state The new state of the {@code Call}. |
| 511 | */ |
| 512 | public void onStateChanged(Call call, int state) {} |
| 513 | |
| 514 | /** |
| 515 | * Invoked when the parent of this {@code Call} has changed. See {@link #getParent()}. |
| 516 | * |
| 517 | * @param call The {@code Call} invoking this method. |
| 518 | * @param parent The new parent of the {@code Call}. |
| 519 | */ |
| 520 | public void onParentChanged(Call call, Call parent) {} |
| 521 | |
| 522 | /** |
| 523 | * Invoked when the children of this {@code Call} have changed. See {@link #getChildren()}. |
| 524 | * |
| 525 | * @param call The {@code Call} invoking this method. |
| 526 | * @param children The new children of the {@code Call}. |
| 527 | */ |
| 528 | public void onChildrenChanged(Call call, List<Call> children) {} |
| 529 | |
| 530 | /** |
| 531 | * Invoked when the details of this {@code Call} have changed. See {@link #getDetails()}. |
| 532 | * |
| 533 | * @param call The {@code Call} invoking this method. |
| 534 | * @param details A {@code Details} object describing the {@code Call}. |
| 535 | */ |
| 536 | public void onDetailsChanged(Call call, Details details) {} |
| 537 | |
| 538 | /** |
| 539 | * Invoked when the text messages that can be used as responses to the incoming |
| 540 | * {@code Call} are loaded from the relevant database. |
| 541 | * See {@link #getCannedTextResponses()}. |
| 542 | * |
| 543 | * @param call The {@code Call} invoking this method. |
| 544 | * @param cannedTextResponses The text messages useable as responses. |
| 545 | */ |
| 546 | public void onCannedTextResponsesLoaded(Call call, List<String> cannedTextResponses) {} |
| 547 | |
| 548 | /** |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 549 | * Invoked when the post-dial sequence in the outgoing {@code Call} has reached a pause |
| 550 | * character. This causes the post-dial signals to stop pending user confirmation. An |
| 551 | * implementation should present this choice to the user and invoke |
| 552 | * {@link #postDialContinue(boolean)} when the user makes the choice. |
| 553 | * |
| 554 | * @param call The {@code Call} invoking this method. |
| 555 | * @param remainingPostDialSequence The post-dial characters that remain to be sent. |
| 556 | */ |
| 557 | public void onPostDialWait(Call call, String remainingPostDialSequence) {} |
| 558 | |
| 559 | /** |
| Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 560 | * Invoked when the {@code Call.VideoCall} of the {@code Call} has changed. |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 561 | * |
| 562 | * @param call The {@code Call} invoking this method. |
| Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 563 | * @param videoCall The {@code Call.VideoCall} associated with the {@code Call}. |
| Tyler Gunn | 75537ae | 2014-08-22 11:33:13 -0700 | [diff] [blame] | 564 | * @hide |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 565 | */ |
| Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 566 | public void onVideoCallChanged(Call call, InCallService.VideoCall videoCall) {} |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 567 | |
| 568 | /** |
| 569 | * Invoked when the {@code Call} is destroyed. Clients should refrain from cleaning |
| 570 | * up their UI for the {@code Call} in response to state transitions. Specifically, |
| 571 | * clients should not assume that a {@link #onStateChanged(Call, int)} with a state of |
| 572 | * {@link #STATE_DISCONNECTED} is the final notification the {@code Call} will send. Rather, |
| 573 | * clients should wait for this method to be invoked. |
| 574 | * |
| 575 | * @param call The {@code Call} being destroyed. |
| 576 | */ |
| 577 | public void onCallDestroyed(Call call) {} |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 578 | |
| 579 | /** |
| 580 | * Invoked upon changes to the set of {@code Call}s with which this {@code Call} can be |
| 581 | * conferenced. |
| 582 | * |
| 583 | * @param call The {@code Call} being updated. |
| 584 | * @param conferenceableCalls The {@code Call}s with which this {@code Call} can be |
| 585 | * conferenced. |
| 586 | */ |
| 587 | public void onConferenceableCallsChanged(Call call, List<Call> conferenceableCalls) {} |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 588 | } |
| 589 | |
| 590 | private final Phone mPhone; |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 591 | private final String mTelecomCallId; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 592 | private final InCallAdapter mInCallAdapter; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 593 | private final List<String> mChildrenIds = new ArrayList<>(); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 594 | private final List<Call> mChildren = new ArrayList<>(); |
| 595 | private final List<Call> mUnmodifiableChildren = Collections.unmodifiableList(mChildren); |
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 596 | private final List<Listener> mListeners = new CopyOnWriteArrayList<>(); |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 597 | private final List<Call> mConferenceableCalls = new ArrayList<>(); |
| 598 | private final List<Call> mUnmodifiableConferenceableCalls = |
| 599 | Collections.unmodifiableList(mConferenceableCalls); |
| 600 | |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 601 | private boolean mChildrenCached; |
| 602 | private String mParentId = null; |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 603 | private int mState; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 604 | private List<String> mCannedTextResponses = null; |
| 605 | private String mRemainingPostDialSequence; |
| Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 606 | private InCallService.VideoCall mVideoCall; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 607 | private Details mDetails; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 608 | |
| 609 | /** |
| 610 | * Obtains the post-dial sequence remaining to be emitted by this {@code Call}, if any. |
| 611 | * |
| 612 | * @return The remaining post-dial sequence, or {@code null} if there is no post-dial sequence |
| 613 | * remaining or this {@code Call} is not in a post-dial state. |
| 614 | */ |
| 615 | public String getRemainingPostDialSequence() { |
| 616 | return mRemainingPostDialSequence; |
| 617 | } |
| 618 | |
| 619 | /** |
| 620 | * Instructs this {@link #STATE_RINGING} {@code Call} to answer. |
| Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 621 | * @param videoState The video state in which to answer the call. |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 622 | */ |
| Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 623 | public void answer(int videoState) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 624 | mInCallAdapter.answerCall(mTelecomCallId, videoState); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 625 | } |
| 626 | |
| 627 | /** |
| 628 | * Instructs this {@link #STATE_RINGING} {@code Call} to reject. |
| 629 | * |
| 630 | * @param rejectWithMessage Whether to reject with a text message. |
| 631 | * @param textMessage An optional text message with which to respond. |
| 632 | */ |
| 633 | public void reject(boolean rejectWithMessage, String textMessage) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 634 | mInCallAdapter.rejectCall(mTelecomCallId, rejectWithMessage, textMessage); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 635 | } |
| 636 | |
| 637 | /** |
| 638 | * Instructs this {@code Call} to disconnect. |
| 639 | */ |
| 640 | public void disconnect() { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 641 | mInCallAdapter.disconnectCall(mTelecomCallId); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | /** |
| 645 | * Instructs this {@code Call} to go on hold. |
| 646 | */ |
| 647 | public void hold() { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 648 | mInCallAdapter.holdCall(mTelecomCallId); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 649 | } |
| 650 | |
| 651 | /** |
| 652 | * Instructs this {@link #STATE_HOLDING} call to release from hold. |
| 653 | */ |
| 654 | public void unhold() { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 655 | mInCallAdapter.unholdCall(mTelecomCallId); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 656 | } |
| 657 | |
| 658 | /** |
| 659 | * Instructs this {@code Call} to play a dual-tone multi-frequency signaling (DTMF) tone. |
| 660 | * |
| 661 | * Any other currently playing DTMF tone in the specified call is immediately stopped. |
| 662 | * |
| 663 | * @param digit A character representing the DTMF digit for which to play the tone. This |
| 664 | * value must be one of {@code '0'} through {@code '9'}, {@code '*'} or {@code '#'}. |
| 665 | */ |
| 666 | public void playDtmfTone(char digit) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 667 | mInCallAdapter.playDtmfTone(mTelecomCallId, digit); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 668 | } |
| 669 | |
| 670 | /** |
| 671 | * Instructs this {@code Call} to stop any dual-tone multi-frequency signaling (DTMF) tone |
| 672 | * currently playing. |
| 673 | * |
| 674 | * DTMF tones are played by calling {@link #playDtmfTone(char)}. If no DTMF tone is |
| 675 | * currently playing, this method will do nothing. |
| 676 | */ |
| 677 | public void stopDtmfTone() { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 678 | mInCallAdapter.stopDtmfTone(mTelecomCallId); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | /** |
| 682 | * Instructs this {@code Call} to continue playing a post-dial DTMF string. |
| 683 | * |
| 684 | * A post-dial DTMF string is a string of digits entered after a phone number, when dialed, |
| 685 | * 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] | 686 | * |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 687 | * 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] | 688 | * {@code Call} will temporarily pause playing the tones for a pre-defined period of time. |
| 689 | * |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 690 | * If the DTMF string contains a {@link TelecomManager#DTMF_CHARACTER_WAIT} symbol, this |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 691 | * {@code Call} will pause playing the tones and notify listeners via |
| 692 | * {@link Listener#onPostDialWait(Call, String)}. At this point, the in-call app |
| 693 | * should display to the user an indication of this state and an affordance to continue |
| 694 | * the postdial sequence. When the user decides to continue the postdial sequence, the in-call |
| 695 | * app should invoke the {@link #postDialContinue(boolean)} method. |
| 696 | * |
| 697 | * @param proceed Whether or not to continue with the post-dial sequence. |
| 698 | */ |
| 699 | public void postDialContinue(boolean proceed) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 700 | mInCallAdapter.postDialContinue(mTelecomCallId, proceed); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 701 | } |
| 702 | |
| 703 | /** |
| Evan Charlton | 8c8a062 | 2014-07-20 12:31:00 -0700 | [diff] [blame] | 704 | * 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] | 705 | * an outgoing call. Optionally sets this account as the default account. |
| Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 706 | */ |
| Nancy Chen | 36c62f3 | 2014-10-21 18:36:39 -0700 | [diff] [blame] | 707 | public void phoneAccountSelected(PhoneAccountHandle accountHandle, boolean setDefault) { |
| 708 | mInCallAdapter.phoneAccountSelected(mTelecomCallId, accountHandle, setDefault); |
| Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 709 | |
| 710 | } |
| 711 | |
| 712 | /** |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 713 | * Instructs this {@code Call} to enter a conference. |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 714 | * |
| 715 | * @param callToConferenceWith The other call with which to conference. |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 716 | */ |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 717 | public void conference(Call callToConferenceWith) { |
| 718 | if (callToConferenceWith != null) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 719 | mInCallAdapter.conference(mTelecomCallId, callToConferenceWith.mTelecomCallId); |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 720 | } |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 721 | } |
| 722 | |
| 723 | /** |
| 724 | * Instructs this {@code Call} to split from any conference call with which it may be |
| 725 | * connected. |
| 726 | */ |
| 727 | public void splitFromConference() { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 728 | mInCallAdapter.splitFromConference(mTelecomCallId); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 729 | } |
| 730 | |
| 731 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 732 | * Merges the calls within this conference. See {@link Details#CAPABILITY_MERGE_CONFERENCE}. |
| Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 733 | */ |
| 734 | public void mergeConference() { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 735 | mInCallAdapter.mergeConference(mTelecomCallId); |
| Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 736 | } |
| 737 | |
| 738 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 739 | * Swaps the calls within this conference. See {@link Details#CAPABILITY_SWAP_CONFERENCE}. |
| Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 740 | */ |
| 741 | public void swapConference() { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 742 | mInCallAdapter.swapConference(mTelecomCallId); |
| Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 743 | } |
| 744 | |
| 745 | /** |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 746 | * Obtains the parent of this {@code Call} in a conference, if any. |
| 747 | * |
| 748 | * @return The parent {@code Call}, or {@code null} if this {@code Call} is not a |
| 749 | * child of any conference {@code Call}s. |
| 750 | */ |
| 751 | public Call getParent() { |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 752 | if (mParentId != null) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 753 | return mPhone.internalGetCallByTelecomId(mParentId); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 754 | } |
| 755 | return null; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 756 | } |
| 757 | |
| 758 | /** |
| 759 | * Obtains the children of this conference {@code Call}, if any. |
| 760 | * |
| 761 | * @return The children of this {@code Call} if this {@code Call} is a conference, or an empty |
| 762 | * {@code List} otherwise. |
| 763 | */ |
| 764 | public List<Call> getChildren() { |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 765 | if (!mChildrenCached) { |
| 766 | mChildrenCached = true; |
| 767 | mChildren.clear(); |
| 768 | |
| 769 | for(String id : mChildrenIds) { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 770 | Call call = mPhone.internalGetCallByTelecomId(id); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 771 | if (call == null) { |
| 772 | // At least one child was still not found, so do not save true for "cached" |
| 773 | mChildrenCached = false; |
| 774 | } else { |
| 775 | mChildren.add(call); |
| 776 | } |
| 777 | } |
| 778 | } |
| 779 | |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 780 | return mUnmodifiableChildren; |
| 781 | } |
| 782 | |
| 783 | /** |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 784 | * Returns the list of {@code Call}s with which this {@code Call} is allowed to conference. |
| 785 | * |
| 786 | * @return The list of conferenceable {@code Call}s. |
| 787 | */ |
| 788 | public List<Call> getConferenceableCalls() { |
| 789 | return mUnmodifiableConferenceableCalls; |
| 790 | } |
| 791 | |
| 792 | /** |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 793 | * Obtains the state of this {@code Call}. |
| 794 | * |
| 795 | * @return A state value, chosen from the {@code STATE_*} constants. |
| 796 | */ |
| 797 | public int getState() { |
| 798 | return mState; |
| 799 | } |
| 800 | |
| 801 | /** |
| 802 | * Obtains a list of canned, pre-configured message responses to present to the user as |
| 803 | * ways of rejecting this {@code Call} using via a text message. |
| 804 | * |
| 805 | * @see #reject(boolean, String) |
| 806 | * |
| 807 | * @return A list of canned text message responses. |
| 808 | */ |
| 809 | public List<String> getCannedTextResponses() { |
| 810 | return mCannedTextResponses; |
| 811 | } |
| 812 | |
| 813 | /** |
| 814 | * Obtains an object that can be used to display video from this {@code Call}. |
| 815 | * |
| Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 816 | * @return An {@code Call.VideoCall}. |
| Tyler Gunn | 75537ae | 2014-08-22 11:33:13 -0700 | [diff] [blame] | 817 | * @hide |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 818 | */ |
| Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 819 | public InCallService.VideoCall getVideoCall() { |
| 820 | return mVideoCall; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 821 | } |
| 822 | |
| 823 | /** |
| 824 | * Obtains an object containing call details. |
| 825 | * |
| 826 | * @return A {@link Details} object. Depending on the state of the {@code Call}, the |
| 827 | * result may be {@code null}. |
| 828 | */ |
| 829 | public Details getDetails() { |
| 830 | return mDetails; |
| 831 | } |
| 832 | |
| 833 | /** |
| 834 | * Adds a listener to this {@code Call}. |
| 835 | * |
| 836 | * @param listener A {@code Listener}. |
| 837 | */ |
| 838 | public void addListener(Listener listener) { |
| 839 | mListeners.add(listener); |
| 840 | } |
| 841 | |
| 842 | /** |
| 843 | * Removes a listener from this {@code Call}. |
| 844 | * |
| 845 | * @param listener A {@code Listener}. |
| 846 | */ |
| 847 | public void removeListener(Listener listener) { |
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 848 | if (listener != null) { |
| 849 | mListeners.remove(listener); |
| 850 | } |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 851 | } |
| 852 | |
| 853 | /** {@hide} */ |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 854 | Call(Phone phone, String telecomCallId, InCallAdapter inCallAdapter) { |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 855 | mPhone = phone; |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 856 | mTelecomCallId = telecomCallId; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 857 | mInCallAdapter = inCallAdapter; |
| 858 | mState = STATE_NEW; |
| 859 | } |
| 860 | |
| 861 | /** {@hide} */ |
| 862 | final String internalGetCallId() { |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 863 | return mTelecomCallId; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 864 | } |
| 865 | |
| 866 | /** {@hide} */ |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 867 | final void internalUpdate(ParcelableCall parcelableCall, Map<String, Call> callIdMap) { |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 868 | // First, we update the internal state as far as possible before firing any updates. |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 869 | Details details = new Details( |
| Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 870 | parcelableCall.getHandle(), |
| 871 | parcelableCall.getHandlePresentation(), |
| 872 | parcelableCall.getCallerDisplayName(), |
| 873 | parcelableCall.getCallerDisplayNamePresentation(), |
| 874 | parcelableCall.getAccountHandle(), |
| 875 | parcelableCall.getCapabilities(), |
| Andrew Lee | 223ad14 | 2014-08-27 16:33:08 -0700 | [diff] [blame] | 876 | parcelableCall.getProperties(), |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 877 | parcelableCall.getDisconnectCause(), |
| Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 878 | parcelableCall.getConnectTimeMillis(), |
| 879 | parcelableCall.getGatewayInfo(), |
| 880 | parcelableCall.getVideoState(), |
| Nancy Chen | 10798dc | 2014-08-08 14:00:25 -0700 | [diff] [blame] | 881 | parcelableCall.getStatusHints(), |
| 882 | parcelableCall.getExtras()); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 883 | boolean detailsChanged = !Objects.equals(mDetails, details); |
| 884 | if (detailsChanged) { |
| 885 | mDetails = details; |
| 886 | } |
| 887 | |
| 888 | boolean cannedTextResponsesChanged = false; |
| Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 889 | if (mCannedTextResponses == null && parcelableCall.getCannedSmsResponses() != null |
| 890 | && !parcelableCall.getCannedSmsResponses().isEmpty()) { |
| 891 | mCannedTextResponses = |
| 892 | Collections.unmodifiableList(parcelableCall.getCannedSmsResponses()); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 893 | } |
| 894 | |
| Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 895 | boolean videoCallChanged = !Objects.equals(mVideoCall, parcelableCall.getVideoCall()); |
| 896 | if (videoCallChanged) { |
| 897 | mVideoCall = parcelableCall.getVideoCall(); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 898 | } |
| 899 | |
| Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 900 | int state = stateFromParcelableCallState(parcelableCall.getState()); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 901 | boolean stateChanged = mState != state; |
| 902 | if (stateChanged) { |
| 903 | mState = state; |
| 904 | } |
| 905 | |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 906 | String parentId = parcelableCall.getParentCallId(); |
| 907 | boolean parentChanged = !Objects.equals(mParentId, parentId); |
| 908 | if (parentChanged) { |
| 909 | mParentId = parentId; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 910 | } |
| 911 | |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 912 | List<String> childCallIds = parcelableCall.getChildCallIds(); |
| 913 | boolean childrenChanged = !Objects.equals(childCallIds, mChildrenIds); |
| 914 | if (childrenChanged) { |
| 915 | mChildrenIds.clear(); |
| 916 | mChildrenIds.addAll(parcelableCall.getChildCallIds()); |
| 917 | mChildrenCached = false; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 918 | } |
| 919 | |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 920 | List<String> conferenceableCallIds = parcelableCall.getConferenceableCallIds(); |
| 921 | List<Call> conferenceableCalls = new ArrayList<Call>(conferenceableCallIds.size()); |
| 922 | for (String otherId : conferenceableCallIds) { |
| 923 | if (callIdMap.containsKey(otherId)) { |
| 924 | conferenceableCalls.add(callIdMap.get(otherId)); |
| 925 | } |
| 926 | } |
| 927 | |
| 928 | if (!Objects.equals(mConferenceableCalls, conferenceableCalls)) { |
| 929 | mConferenceableCalls.clear(); |
| 930 | mConferenceableCalls.addAll(conferenceableCalls); |
| 931 | fireConferenceableCallsChanged(); |
| 932 | } |
| 933 | |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 934 | // Now we fire updates, ensuring that any client who listens to any of these notifications |
| 935 | // gets the most up-to-date state. |
| 936 | |
| 937 | if (stateChanged) { |
| 938 | fireStateChanged(mState); |
| 939 | } |
| 940 | if (detailsChanged) { |
| 941 | fireDetailsChanged(mDetails); |
| 942 | } |
| 943 | if (cannedTextResponsesChanged) { |
| 944 | fireCannedTextResponsesLoaded(mCannedTextResponses); |
| 945 | } |
| Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 946 | if (videoCallChanged) { |
| 947 | fireVideoCallChanged(mVideoCall); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 948 | } |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 949 | if (parentChanged) { |
| 950 | fireParentChanged(getParent()); |
| 951 | } |
| 952 | if (childrenChanged) { |
| 953 | fireChildrenChanged(getChildren()); |
| 954 | } |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 955 | |
| 956 | // If we have transitioned to DISCONNECTED, that means we need to notify clients and |
| 957 | // remove ourselves from the Phone. Note that we do this after completing all state updates |
| 958 | // so a client can cleanly transition all their UI to the state appropriate for a |
| 959 | // DISCONNECTED Call while still relying on the existence of that Call in the Phone's list. |
| 960 | if (mState == STATE_DISCONNECTED) { |
| 961 | fireCallDestroyed(); |
| 962 | mPhone.internalRemoveCall(this); |
| 963 | } |
| 964 | } |
| 965 | |
| 966 | /** {@hide} */ |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 967 | final void internalSetPostDialWait(String remaining) { |
| 968 | mRemainingPostDialSequence = remaining; |
| 969 | firePostDialWait(mRemainingPostDialSequence); |
| 970 | } |
| 971 | |
| Sailesh Nepal | 2ab88cc | 2014-07-18 14:49:18 -0700 | [diff] [blame] | 972 | /** {@hide} */ |
| Santos Cordon | f30d7e9 | 2014-08-26 09:54:33 -0700 | [diff] [blame] | 973 | final void internalSetDisconnected() { |
| 974 | if (mState != Call.STATE_DISCONNECTED) { |
| 975 | mState = Call.STATE_DISCONNECTED; |
| 976 | fireStateChanged(mState); |
| 977 | fireCallDestroyed(); |
| 978 | mPhone.internalRemoveCall(this); |
| 979 | } |
| 980 | } |
| 981 | |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 982 | private void fireStateChanged(int newState) { |
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 983 | for (Listener listener : mListeners) { |
| 984 | listener.onStateChanged(this, newState); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 985 | } |
| 986 | } |
| 987 | |
| 988 | private void fireParentChanged(Call newParent) { |
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 989 | for (Listener listener : mListeners) { |
| 990 | listener.onParentChanged(this, newParent); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 991 | } |
| 992 | } |
| 993 | |
| 994 | private void fireChildrenChanged(List<Call> children) { |
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 995 | for (Listener listener : mListeners) { |
| 996 | listener.onChildrenChanged(this, children); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 997 | } |
| 998 | } |
| 999 | |
| 1000 | private void fireDetailsChanged(Details details) { |
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 1001 | for (Listener listener : mListeners) { |
| 1002 | listener.onDetailsChanged(this, details); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1003 | } |
| 1004 | } |
| 1005 | |
| 1006 | private void fireCannedTextResponsesLoaded(List<String> cannedTextResponses) { |
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 1007 | for (Listener listener : mListeners) { |
| 1008 | listener.onCannedTextResponsesLoaded(this, cannedTextResponses); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1009 | } |
| 1010 | } |
| 1011 | |
| Andrew Lee | 50aca23 | 2014-07-22 16:41:54 -0700 | [diff] [blame] | 1012 | private void fireVideoCallChanged(InCallService.VideoCall videoCall) { |
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 1013 | for (Listener listener : mListeners) { |
| 1014 | listener.onVideoCallChanged(this, videoCall); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1015 | } |
| 1016 | } |
| 1017 | |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1018 | private void firePostDialWait(String remainingPostDialSequence) { |
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 1019 | for (Listener listener : mListeners) { |
| 1020 | listener.onPostDialWait(this, remainingPostDialSequence); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1021 | } |
| 1022 | } |
| 1023 | |
| 1024 | private void fireCallDestroyed() { |
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 1025 | for (Listener listener : mListeners) { |
| 1026 | listener.onCallDestroyed(this); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1027 | } |
| 1028 | } |
| 1029 | |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1030 | private void fireConferenceableCallsChanged() { |
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 1031 | for (Listener listener : mListeners) { |
| 1032 | listener.onConferenceableCallsChanged(this, mUnmodifiableConferenceableCalls); |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1033 | } |
| 1034 | } |
| 1035 | |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1036 | private int stateFromParcelableCallState(int parcelableCallState) { |
| Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 1037 | switch (parcelableCallState) { |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1038 | case CallState.NEW: |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1039 | return STATE_NEW; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1040 | case CallState.CONNECTING: |
| Nancy Chen | e20930f | 2014-08-07 16:17:21 -0700 | [diff] [blame] | 1041 | return STATE_CONNECTING; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1042 | case CallState.PRE_DIAL_WAIT: |
| Nancy Chen | 5da0fd5 | 2014-07-08 14:16:17 -0700 | [diff] [blame] | 1043 | return STATE_PRE_DIAL_WAIT; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1044 | case CallState.DIALING: |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1045 | return STATE_DIALING; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1046 | case CallState.RINGING: |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1047 | return STATE_RINGING; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1048 | case CallState.ACTIVE: |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1049 | return STATE_ACTIVE; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1050 | case CallState.ON_HOLD: |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1051 | return STATE_HOLDING; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1052 | case CallState.DISCONNECTED: |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1053 | return STATE_DISCONNECTED; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1054 | case CallState.ABORTED: |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1055 | return STATE_DISCONNECTED; |
| Tyler Gunn | 4afc6af | 2014-10-07 10:14:55 -0700 | [diff] [blame] | 1056 | case CallState.DISCONNECTING: |
| 1057 | return STATE_DISCONNECTING; |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1058 | default: |
| Santos Cordon | 88b771d | 2014-07-19 13:10:40 -0700 | [diff] [blame] | 1059 | Log.wtf(this, "Unrecognized CallState %s", parcelableCallState); |
| Ihab Awad | e63fadb | 2014-07-09 21:52:04 -0700 | [diff] [blame] | 1060 | return STATE_NEW; |
| 1061 | } |
| 1062 | } |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1063 | } |