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