| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -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 | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 18 | |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 19 | import com.android.internal.telecom.IVideoCallback; |
| 20 | import com.android.internal.telecom.IVideoProvider; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 21 | |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 22 | import android.annotation.SystemApi; |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 23 | import android.net.Uri; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 24 | import android.os.Handler; |
| 25 | import android.os.IBinder; |
| 26 | import android.os.Message; |
| 27 | import android.os.RemoteException; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 28 | import android.view.Surface; |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 29 | |
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 30 | import java.util.ArrayList; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 31 | import java.util.Collections; |
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 32 | import java.util.List; |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 33 | import java.util.Set; |
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 34 | import java.util.concurrent.ConcurrentHashMap; |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Represents a connection to a remote endpoint that carries voice traffic. |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 38 | * <p> |
| 39 | * Implementations create a custom subclass of {@code Connection} and return it to the framework |
| 40 | * as the return value of |
| 41 | * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)} |
| 42 | * or |
| 43 | * {@link ConnectionService#onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}. |
| 44 | * Implementations are then responsible for updating the state of the {@code Connection}, and |
| 45 | * must call {@link #destroy()} to signal to the framework that the {@code Connection} is no |
| 46 | * longer used and associated resources may be recovered. |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 47 | * @hide |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 48 | */ |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 49 | @SystemApi |
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 50 | public abstract class Connection implements IConferenceable { |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 51 | |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 52 | public static final int STATE_INITIALIZING = 0; |
| 53 | |
| 54 | public static final int STATE_NEW = 1; |
| 55 | |
| 56 | public static final int STATE_RINGING = 2; |
| 57 | |
| 58 | public static final int STATE_DIALING = 3; |
| 59 | |
| 60 | public static final int STATE_ACTIVE = 4; |
| 61 | |
| 62 | public static final int STATE_HOLDING = 5; |
| 63 | |
| 64 | public static final int STATE_DISCONNECTED = 6; |
| 65 | |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 66 | /** Connection can currently be put on hold or unheld. */ |
| 67 | public static final int CAPABILITY_HOLD = 0x00000001; |
| 68 | |
| 69 | /** Connection supports the hold feature. */ |
| 70 | public static final int CAPABILITY_SUPPORT_HOLD = 0x00000002; |
| 71 | |
| 72 | /** |
| 73 | * Connections within a conference can be merged. A {@link ConnectionService} has the option to |
| 74 | * add a {@link Conference} before the child {@link Connection}s are merged. This is how |
| 75 | * CDMA-based {@link Connection}s are implemented. For these unmerged {@link Conference}s, this |
| 76 | * capability allows a merge button to be shown while the conference is in the foreground |
| 77 | * of the in-call UI. |
| 78 | * <p> |
| 79 | * This is only intended for use by a {@link Conference}. |
| 80 | */ |
| 81 | public static final int CAPABILITY_MERGE_CONFERENCE = 0x00000004; |
| 82 | |
| 83 | /** |
| 84 | * Connections within a conference can be swapped between foreground and background. |
| 85 | * See {@link #CAPABILITY_MERGE_CONFERENCE} for additional information. |
| 86 | * <p> |
| 87 | * This is only intended for use by a {@link Conference}. |
| 88 | */ |
| 89 | public static final int CAPABILITY_SWAP_CONFERENCE = 0x00000008; |
| 90 | |
| 91 | /** |
| 92 | * @hide |
| 93 | */ |
| 94 | public static final int CAPABILITY_UNUSED = 0x00000010; |
| 95 | |
| 96 | /** Connection supports responding via text option. */ |
| 97 | public static final int CAPABILITY_RESPOND_VIA_TEXT = 0x00000020; |
| 98 | |
| 99 | /** Connection can be muted. */ |
| 100 | public static final int CAPABILITY_MUTE = 0x00000040; |
| 101 | |
| 102 | /** |
| 103 | * Connection supports conference management. This capability only applies to |
| 104 | * {@link Conference}s which can have {@link Connection}s as children. |
| 105 | */ |
| 106 | public static final int CAPABILITY_MANAGE_CONFERENCE = 0x00000080; |
| 107 | |
| 108 | /** |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 109 | * Local device supports receiving video. |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 110 | * @hide |
| 111 | */ |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 112 | public static final int CAPABILITY_SUPPORTS_VT_LOCAL_RX = 0x00000100; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 113 | |
| 114 | /** |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 115 | * Local device supports transmitting video. |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 116 | * @hide |
| 117 | */ |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 118 | public static final int CAPABILITY_SUPPORTS_VT_LOCAL_TX = 0x00000200; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 119 | |
| 120 | /** |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 121 | * Local device supports bidirectional video calling. |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 122 | * @hide |
| 123 | */ |
| Andrew Lee | 9a8f9ce | 2015-04-10 18:09:46 -0700 | [diff] [blame] | 124 | public static final int CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL = |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 125 | CAPABILITY_SUPPORTS_VT_LOCAL_RX | CAPABILITY_SUPPORTS_VT_LOCAL_TX; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 126 | |
| 127 | /** |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 128 | * Remote device supports receiving video. |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 129 | * @hide |
| 130 | */ |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 131 | public static final int CAPABILITY_SUPPORTS_VT_REMOTE_RX = 0x00000400; |
| 132 | |
| 133 | /** |
| 134 | * Remote device supports transmitting video. |
| 135 | * @hide |
| 136 | */ |
| 137 | public static final int CAPABILITY_SUPPORTS_VT_REMOTE_TX = 0x00000800; |
| 138 | |
| 139 | /** |
| 140 | * Remote device supports bidirectional video calling. |
| 141 | * @hide |
| 142 | */ |
| Andrew Lee | 9a8f9ce | 2015-04-10 18:09:46 -0700 | [diff] [blame] | 143 | public static final int CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL = |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 144 | CAPABILITY_SUPPORTS_VT_REMOTE_RX | CAPABILITY_SUPPORTS_VT_REMOTE_TX; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 145 | |
| 146 | /** |
| 147 | * Connection is able to be separated from its parent {@code Conference}, if any. |
| 148 | */ |
| 149 | public static final int CAPABILITY_SEPARATE_FROM_CONFERENCE = 0x00001000; |
| 150 | |
| 151 | /** |
| 152 | * Connection is able to be individually disconnected when in a {@code Conference}. |
| 153 | */ |
| 154 | public static final int CAPABILITY_DISCONNECT_FROM_CONFERENCE = 0x00002000; |
| 155 | |
| 156 | /** |
| 157 | * Whether the call is a generic conference, where we do not know the precise state of |
| 158 | * participants in the conference (eg. on CDMA). |
| 159 | * |
| 160 | * @hide |
| 161 | */ |
| 162 | public static final int CAPABILITY_GENERIC_CONFERENCE = 0x00004000; |
| 163 | |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 164 | /** |
| 165 | * Connection is using high definition audio. |
| 166 | * @hide |
| 167 | */ |
| 168 | public static final int CAPABILITY_HIGH_DEF_AUDIO = 0x00008000; |
| 169 | |
| 170 | /** |
| 171 | * Connection is using WIFI. |
| 172 | * @hide |
| 173 | */ |
| Tyler Gunn | d11a315 | 2015-03-18 13:09:14 -0700 | [diff] [blame] | 174 | public static final int CAPABILITY_WIFI = 0x00010000; |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 175 | |
| Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 176 | /** |
| 177 | * Indicates that the current device callback number should be shown. |
| 178 | * |
| 179 | * @hide |
| 180 | */ |
| Tyler Gunn | 96d6c40 | 2015-03-18 12:39:23 -0700 | [diff] [blame] | 181 | public static final int CAPABILITY_SHOW_CALLBACK_NUMBER = 0x00020000; |
| Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 182 | |
| Tyler Gunn | 96d6c40 | 2015-03-18 12:39:23 -0700 | [diff] [blame] | 183 | /** |
| Dong Zhou | 89f41eb | 2015-03-15 11:59:49 -0500 | [diff] [blame] | 184 | * Speed up audio setup for MT call. |
| 185 | * @hide |
| Tyler Gunn | 96d6c40 | 2015-03-18 12:39:23 -0700 | [diff] [blame] | 186 | */ |
| 187 | public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00040000; |
| Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 188 | |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 189 | /** |
| 190 | * Call type can be modified for IMS call |
| 191 | * @hide |
| 192 | */ |
| 193 | public static final int CAPABILITY_CAN_UPGRADE_TO_VIDEO = 0x00080000; |
| 194 | |
| Tyler Gunn | 96d6c40 | 2015-03-18 12:39:23 -0700 | [diff] [blame] | 195 | //********************************************************************************************** |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 196 | // Next CAPABILITY value: 0x00100000 |
| Tyler Gunn | 96d6c40 | 2015-03-18 12:39:23 -0700 | [diff] [blame] | 197 | //********************************************************************************************** |
| Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 198 | |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 199 | /** |
| 200 | * Call substate bitmask values |
| 201 | */ |
| 202 | |
| 203 | /* Default case */ |
| 204 | /** |
| 205 | * @hide |
| 206 | */ |
| 207 | public static final int SUBSTATE_NONE = 0; |
| 208 | |
| 209 | /* Indicates that the call is connected but audio attribute is suspended */ |
| 210 | /** |
| 211 | * @hide |
| 212 | */ |
| 213 | public static final int SUBSTATE_AUDIO_CONNECTED_SUSPENDED = 0x1; |
| 214 | |
| 215 | /* Indicates that the call is connected but video attribute is suspended */ |
| 216 | /** |
| 217 | * @hide |
| 218 | */ |
| 219 | public static final int SUBSTATE_VIDEO_CONNECTED_SUSPENDED = 0x2; |
| 220 | |
| 221 | /* Indicates that the call is established but media retry is needed */ |
| 222 | /** |
| 223 | * @hide |
| 224 | */ |
| 225 | public static final int SUBSTATE_AVP_RETRY = 0x4; |
| 226 | |
| 227 | /* Indicates that the call is multitasking */ |
| 228 | /** |
| 229 | * @hide |
| 230 | */ |
| 231 | public static final int SUBSTATE_MEDIA_PAUSED = 0x8; |
| 232 | |
| 233 | /* Mask containing all the call substate bits set */ |
| 234 | /** |
| 235 | * @hide |
| 236 | */ |
| 237 | public static final int SUBSTATE_ALL = SUBSTATE_AUDIO_CONNECTED_SUSPENDED | |
| 238 | SUBSTATE_VIDEO_CONNECTED_SUSPENDED | SUBSTATE_AVP_RETRY | |
| 239 | SUBSTATE_MEDIA_PAUSED; |
| 240 | |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 241 | // Flag controlling whether PII is emitted into the logs |
| 242 | private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG); |
| 243 | |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 244 | /** |
| 245 | * Whether the given capabilities support the specified capability. |
| 246 | * |
| 247 | * @param capabilities A capability bit field. |
| 248 | * @param capability The capability to check capabilities for. |
| 249 | * @return Whether the specified capability is supported. |
| 250 | * @hide |
| 251 | */ |
| 252 | public static boolean can(int capabilities, int capability) { |
| 253 | return (capabilities & capability) != 0; |
| 254 | } |
| 255 | |
| 256 | /** |
| 257 | * Whether the capabilities of this {@code Connection} supports the specified capability. |
| 258 | * |
| 259 | * @param capability The capability to check capabilities for. |
| 260 | * @return Whether the specified capability is supported. |
| 261 | * @hide |
| 262 | */ |
| 263 | public boolean can(int capability) { |
| 264 | return can(mConnectionCapabilities, capability); |
| 265 | } |
| 266 | |
| 267 | /** |
| 268 | * Removes the specified capability from the set of capabilities of this {@code Connection}. |
| 269 | * |
| 270 | * @param capability The capability to remove from the set. |
| 271 | * @hide |
| 272 | */ |
| 273 | public void removeCapability(int capability) { |
| 274 | mConnectionCapabilities &= ~capability; |
| 275 | } |
| 276 | |
| 277 | /** |
| 278 | * Adds the specified capability to the set of capabilities of this {@code Connection}. |
| 279 | * |
| 280 | * @param capability The capability to add to the set. |
| 281 | * @hide |
| 282 | */ |
| 283 | public void addCapability(int capability) { |
| 284 | mConnectionCapabilities |= capability; |
| 285 | } |
| 286 | |
| 287 | |
| 288 | public static String capabilitiesToString(int capabilities) { |
| 289 | StringBuilder builder = new StringBuilder(); |
| 290 | builder.append("[Capabilities:"); |
| 291 | if (can(capabilities, CAPABILITY_HOLD)) { |
| 292 | builder.append(" CAPABILITY_HOLD"); |
| 293 | } |
| 294 | if (can(capabilities, CAPABILITY_SUPPORT_HOLD)) { |
| 295 | builder.append(" CAPABILITY_SUPPORT_HOLD"); |
| 296 | } |
| 297 | if (can(capabilities, CAPABILITY_MERGE_CONFERENCE)) { |
| 298 | builder.append(" CAPABILITY_MERGE_CONFERENCE"); |
| 299 | } |
| 300 | if (can(capabilities, CAPABILITY_SWAP_CONFERENCE)) { |
| 301 | builder.append(" CAPABILITY_SWAP_CONFERENCE"); |
| 302 | } |
| 303 | if (can(capabilities, CAPABILITY_RESPOND_VIA_TEXT)) { |
| 304 | builder.append(" CAPABILITY_RESPOND_VIA_TEXT"); |
| 305 | } |
| 306 | if (can(capabilities, CAPABILITY_MUTE)) { |
| 307 | builder.append(" CAPABILITY_MUTE"); |
| 308 | } |
| 309 | if (can(capabilities, CAPABILITY_MANAGE_CONFERENCE)) { |
| 310 | builder.append(" CAPABILITY_MANAGE_CONFERENCE"); |
| 311 | } |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 312 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_RX)) { |
| 313 | builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_RX"); |
| 314 | } |
| 315 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_TX)) { |
| 316 | builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_TX"); |
| 317 | } |
| Andrew Lee | 9a8f9ce | 2015-04-10 18:09:46 -0700 | [diff] [blame] | 318 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL)) { |
| 319 | builder.append(" CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL"); |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 320 | } |
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 321 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_RX)) { |
| 322 | builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_RX"); |
| 323 | } |
| 324 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_TX)) { |
| 325 | builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_TX"); |
| 326 | } |
| Andrew Lee | 9a8f9ce | 2015-04-10 18:09:46 -0700 | [diff] [blame] | 327 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL)) { |
| 328 | builder.append(" CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL"); |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 329 | } |
| Andrew Lee | 80fff3c | 2014-11-25 17:36:51 -0800 | [diff] [blame] | 330 | if (can(capabilities, CAPABILITY_HIGH_DEF_AUDIO)) { |
| 331 | builder.append(" CAPABILITY_HIGH_DEF_AUDIO"); |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 332 | } |
| Andrew Lee | 1a8ae3e | 2015-02-02 13:42:38 -0800 | [diff] [blame] | 333 | if (can(capabilities, CAPABILITY_WIFI)) { |
| 334 | builder.append(" CAPABILITY_WIFI"); |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 335 | } |
| 336 | if (can(capabilities, CAPABILITY_GENERIC_CONFERENCE)) { |
| 337 | builder.append(" CAPABILITY_GENERIC_CONFERENCE"); |
| 338 | } |
| Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 339 | if (can(capabilities, CAPABILITY_SHOW_CALLBACK_NUMBER)) { |
| 340 | builder.append(" CAPABILITY_SHOW_CALLBACK_NUMBER"); |
| 341 | } |
| Dong Zhou | 89f41eb | 2015-03-15 11:59:49 -0500 | [diff] [blame] | 342 | if (can(capabilities, CAPABILITY_SPEED_UP_MT_AUDIO)) { |
| Tyler Gunn | d11a315 | 2015-03-18 13:09:14 -0700 | [diff] [blame] | 343 | builder.append(" CAPABILITY_SPEED_UP_MT_AUDIO"); |
| Dong Zhou | 89f41eb | 2015-03-15 11:59:49 -0500 | [diff] [blame] | 344 | } |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 345 | if (can(capabilities, CAPABILITY_CAN_UPGRADE_TO_VIDEO)) { |
| 346 | builder.append(" CAPABILITY_CAN_UPGRADE_TO_VIDEO"); |
| 347 | } |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 348 | builder.append("]"); |
| 349 | return builder.toString(); |
| 350 | } |
| 351 | |
| Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 352 | /** @hide */ |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 353 | public abstract static class Listener { |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 354 | public void onStateChanged(Connection c, int state) {} |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 355 | public void onAddressChanged(Connection c, Uri newAddress, int presentation) {} |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 356 | public void onCallerDisplayNameChanged( |
| 357 | Connection c, String callerDisplayName, int presentation) {} |
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 358 | public void onVideoStateChanged(Connection c, int videoState) {} |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 359 | public void onDisconnected(Connection c, DisconnectCause disconnectCause) {} |
| Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 360 | public void onPostDialWait(Connection c, String remaining) {} |
| Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 361 | public void onPostDialChar(Connection c, char nextChar) {} |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 362 | public void onRingbackRequested(Connection c, boolean ringback) {} |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 363 | public void onDestroyed(Connection c) {} |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 364 | public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {} |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 365 | public void onVideoProviderChanged( |
| 366 | Connection c, VideoProvider videoProvider) {} |
| Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 367 | public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {} |
| 368 | public void onStatusHintsChanged(Connection c, StatusHints statusHints) {} |
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 369 | public void onConferenceablesChanged( |
| 370 | Connection c, List<IConferenceable> conferenceables) {} |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 371 | public void onConferenceChanged(Connection c, Conference conference) {} |
| Tyler Gunn | 3bffcf7 | 2014-10-28 13:51:27 -0700 | [diff] [blame] | 372 | /** @hide */ |
| Tyler Gunn | ab4650c | 2014-11-06 20:06:23 -0800 | [diff] [blame] | 373 | public void onConferenceParticipantsChanged(Connection c, |
| 374 | List<ConferenceParticipant> participants) {} |
| Tyler Gunn | 8a2b119 | 2015-01-29 11:47:24 -0800 | [diff] [blame] | 375 | public void onConferenceStarted() {} |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 376 | public void onCallSubstateChanged(Connection c, int substate) {} |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 377 | } |
| 378 | |
| Tyler Gunn | 27d1e25 | 2014-08-21 16:38:40 -0700 | [diff] [blame] | 379 | /** @hide */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 380 | public static abstract class VideoProvider { |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 381 | |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 382 | /** |
| 383 | * Video is not being received (no protocol pause was issued). |
| 384 | */ |
| 385 | public static final int SESSION_EVENT_RX_PAUSE = 1; |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 386 | |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 387 | /** |
| 388 | * Video reception has resumed after a SESSION_EVENT_RX_PAUSE. |
| 389 | */ |
| 390 | public static final int SESSION_EVENT_RX_RESUME = 2; |
| 391 | |
| 392 | /** |
| 393 | * Video transmission has begun. This occurs after a negotiated start of video transmission |
| 394 | * when the underlying protocol has actually begun transmitting video to the remote party. |
| 395 | */ |
| 396 | public static final int SESSION_EVENT_TX_START = 3; |
| 397 | |
| 398 | /** |
| 399 | * Video transmission has stopped. This occurs after a negotiated stop of video transmission |
| 400 | * when the underlying protocol has actually stopped transmitting video to the remote party. |
| 401 | */ |
| 402 | public static final int SESSION_EVENT_TX_STOP = 4; |
| 403 | |
| 404 | /** |
| 405 | * A camera failure has occurred for the selected camera. The In-Call UI can use this as a |
| 406 | * cue to inform the user the camera is not available. |
| 407 | */ |
| 408 | public static final int SESSION_EVENT_CAMERA_FAILURE = 5; |
| 409 | |
| 410 | /** |
| 411 | * Issued after {@code SESSION_EVENT_CAMERA_FAILURE} when the camera is once again ready for |
| 412 | * operation. The In-Call UI can use this as a cue to inform the user that the camera has |
| 413 | * become available again. |
| 414 | */ |
| 415 | public static final int SESSION_EVENT_CAMERA_READY = 6; |
| 416 | |
| 417 | /** |
| 418 | * Session modify request was successful. |
| 419 | */ |
| 420 | public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1; |
| 421 | |
| 422 | /** |
| 423 | * Session modify request failed. |
| 424 | */ |
| 425 | public static final int SESSION_MODIFY_REQUEST_FAIL = 2; |
| 426 | |
| 427 | /** |
| 428 | * Session modify request ignored due to invalid parameters. |
| 429 | */ |
| 430 | public static final int SESSION_MODIFY_REQUEST_INVALID = 3; |
| 431 | |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 432 | /** |
| 433 | * Session modify request timed out. |
| 434 | */ |
| 435 | public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4; |
| 436 | |
| 437 | /** |
| 438 | * Session modify request rejected by remote UE. |
| 439 | */ |
| 440 | public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5; |
| 441 | |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 442 | private static final int MSG_SET_VIDEO_CALLBACK = 1; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 443 | private static final int MSG_SET_CAMERA = 2; |
| 444 | private static final int MSG_SET_PREVIEW_SURFACE = 3; |
| 445 | private static final int MSG_SET_DISPLAY_SURFACE = 4; |
| 446 | private static final int MSG_SET_DEVICE_ORIENTATION = 5; |
| 447 | private static final int MSG_SET_ZOOM = 6; |
| 448 | private static final int MSG_SEND_SESSION_MODIFY_REQUEST = 7; |
| 449 | private static final int MSG_SEND_SESSION_MODIFY_RESPONSE = 8; |
| 450 | private static final int MSG_REQUEST_CAMERA_CAPABILITIES = 9; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 451 | private static final int MSG_REQUEST_CONNECTION_DATA_USAGE = 10; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 452 | private static final int MSG_SET_PAUSE_IMAGE = 11; |
| 453 | |
| 454 | private final VideoProvider.VideoProviderHandler |
| 455 | mMessageHandler = new VideoProvider.VideoProviderHandler(); |
| 456 | private final VideoProvider.VideoProviderBinder mBinder; |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 457 | private IVideoCallback mVideoCallback; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 458 | |
| 459 | /** |
| 460 | * Default handler used to consolidate binder method calls onto a single thread. |
| 461 | */ |
| 462 | private final class VideoProviderHandler extends Handler { |
| 463 | @Override |
| 464 | public void handleMessage(Message msg) { |
| 465 | switch (msg.what) { |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 466 | case MSG_SET_VIDEO_CALLBACK: |
| 467 | mVideoCallback = IVideoCallback.Stub.asInterface((IBinder) msg.obj); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 468 | break; |
| 469 | case MSG_SET_CAMERA: |
| 470 | onSetCamera((String) msg.obj); |
| 471 | break; |
| 472 | case MSG_SET_PREVIEW_SURFACE: |
| 473 | onSetPreviewSurface((Surface) msg.obj); |
| 474 | break; |
| 475 | case MSG_SET_DISPLAY_SURFACE: |
| 476 | onSetDisplaySurface((Surface) msg.obj); |
| 477 | break; |
| 478 | case MSG_SET_DEVICE_ORIENTATION: |
| 479 | onSetDeviceOrientation(msg.arg1); |
| 480 | break; |
| 481 | case MSG_SET_ZOOM: |
| 482 | onSetZoom((Float) msg.obj); |
| 483 | break; |
| 484 | case MSG_SEND_SESSION_MODIFY_REQUEST: |
| 485 | onSendSessionModifyRequest((VideoProfile) msg.obj); |
| 486 | break; |
| 487 | case MSG_SEND_SESSION_MODIFY_RESPONSE: |
| 488 | onSendSessionModifyResponse((VideoProfile) msg.obj); |
| 489 | break; |
| 490 | case MSG_REQUEST_CAMERA_CAPABILITIES: |
| 491 | onRequestCameraCapabilities(); |
| 492 | break; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 493 | case MSG_REQUEST_CONNECTION_DATA_USAGE: |
| 494 | onRequestConnectionDataUsage(); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 495 | break; |
| 496 | case MSG_SET_PAUSE_IMAGE: |
| 497 | onSetPauseImage((String) msg.obj); |
| 498 | break; |
| 499 | default: |
| 500 | break; |
| 501 | } |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | /** |
| 506 | * IVideoProvider stub implementation. |
| 507 | */ |
| 508 | private final class VideoProviderBinder extends IVideoProvider.Stub { |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 509 | public void setVideoCallback(IBinder videoCallbackBinder) { |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 510 | mMessageHandler.obtainMessage( |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 511 | MSG_SET_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget(); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | public void setCamera(String cameraId) { |
| 515 | mMessageHandler.obtainMessage(MSG_SET_CAMERA, cameraId).sendToTarget(); |
| 516 | } |
| 517 | |
| 518 | public void setPreviewSurface(Surface surface) { |
| 519 | mMessageHandler.obtainMessage(MSG_SET_PREVIEW_SURFACE, surface).sendToTarget(); |
| 520 | } |
| 521 | |
| 522 | public void setDisplaySurface(Surface surface) { |
| 523 | mMessageHandler.obtainMessage(MSG_SET_DISPLAY_SURFACE, surface).sendToTarget(); |
| 524 | } |
| 525 | |
| 526 | public void setDeviceOrientation(int rotation) { |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 527 | mMessageHandler.obtainMessage( |
| 528 | MSG_SET_DEVICE_ORIENTATION, rotation, 0).sendToTarget(); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | public void setZoom(float value) { |
| 532 | mMessageHandler.obtainMessage(MSG_SET_ZOOM, value).sendToTarget(); |
| 533 | } |
| 534 | |
| 535 | public void sendSessionModifyRequest(VideoProfile requestProfile) { |
| 536 | mMessageHandler.obtainMessage( |
| 537 | MSG_SEND_SESSION_MODIFY_REQUEST, requestProfile).sendToTarget(); |
| 538 | } |
| 539 | |
| 540 | public void sendSessionModifyResponse(VideoProfile responseProfile) { |
| 541 | mMessageHandler.obtainMessage( |
| 542 | MSG_SEND_SESSION_MODIFY_RESPONSE, responseProfile).sendToTarget(); |
| 543 | } |
| 544 | |
| 545 | public void requestCameraCapabilities() { |
| 546 | mMessageHandler.obtainMessage(MSG_REQUEST_CAMERA_CAPABILITIES).sendToTarget(); |
| 547 | } |
| 548 | |
| 549 | public void requestCallDataUsage() { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 550 | mMessageHandler.obtainMessage(MSG_REQUEST_CONNECTION_DATA_USAGE).sendToTarget(); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | public void setPauseImage(String uri) { |
| 554 | mMessageHandler.obtainMessage(MSG_SET_PAUSE_IMAGE, uri).sendToTarget(); |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | public VideoProvider() { |
| 559 | mBinder = new VideoProvider.VideoProviderBinder(); |
| 560 | } |
| 561 | |
| 562 | /** |
| 563 | * Returns binder object which can be used across IPC methods. |
| 564 | * @hide |
| 565 | */ |
| 566 | public final IVideoProvider getInterface() { |
| 567 | return mBinder; |
| 568 | } |
| 569 | |
| 570 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 571 | * Sets the camera to be used for video recording in a video connection. |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 572 | * |
| 573 | * @param cameraId The id of the camera. |
| 574 | */ |
| 575 | public abstract void onSetCamera(String cameraId); |
| 576 | |
| 577 | /** |
| 578 | * Sets the surface to be used for displaying a preview of what the user's camera is |
| 579 | * currently capturing. When video transmission is enabled, this is the video signal which |
| 580 | * is sent to the remote device. |
| 581 | * |
| 582 | * @param surface The surface. |
| 583 | */ |
| 584 | public abstract void onSetPreviewSurface(Surface surface); |
| 585 | |
| 586 | /** |
| 587 | * Sets the surface to be used for displaying the video received from the remote device. |
| 588 | * |
| 589 | * @param surface The surface. |
| 590 | */ |
| 591 | public abstract void onSetDisplaySurface(Surface surface); |
| 592 | |
| 593 | /** |
| 594 | * Sets the device orientation, in degrees. Assumes that a standard portrait orientation of |
| 595 | * the device is 0 degrees. |
| 596 | * |
| 597 | * @param rotation The device orientation, in degrees. |
| 598 | */ |
| 599 | public abstract void onSetDeviceOrientation(int rotation); |
| 600 | |
| 601 | /** |
| 602 | * Sets camera zoom ratio. |
| 603 | * |
| 604 | * @param value The camera zoom ratio. |
| 605 | */ |
| 606 | public abstract void onSetZoom(float value); |
| 607 | |
| 608 | /** |
| 609 | * Issues a request to modify the properties of the current session. The request is |
| 610 | * sent to the remote device where it it handled by the In-Call UI. |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 611 | * Some examples of session modification requests: upgrade connection from audio to video, |
| 612 | * downgrade connection from video to audio, pause video. |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 613 | * |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 614 | * @param requestProfile The requested connection video properties. |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 615 | */ |
| 616 | public abstract void onSendSessionModifyRequest(VideoProfile requestProfile); |
| 617 | |
| 618 | /**te |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 619 | * Provides a response to a request to change the current connection session video |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 620 | * properties. |
| 621 | * This is in response to a request the InCall UI has received via the InCall UI. |
| 622 | * |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 623 | * @param responseProfile The response connection video properties. |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 624 | */ |
| 625 | public abstract void onSendSessionModifyResponse(VideoProfile responseProfile); |
| 626 | |
| 627 | /** |
| 628 | * Issues a request to the video provider to retrieve the camera capabilities. |
| 629 | * Camera capabilities are reported back to the caller via the In-Call UI. |
| 630 | */ |
| 631 | public abstract void onRequestCameraCapabilities(); |
| 632 | |
| 633 | /** |
| 634 | * Issues a request to the video telephony framework to retrieve the cumulative data usage |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 635 | * for the current connection. Data usage is reported back to the caller via the |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 636 | * InCall UI. |
| 637 | */ |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 638 | public abstract void onRequestConnectionDataUsage(); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 639 | |
| 640 | /** |
| 641 | * Provides the video telephony framework with the URI of an image to be displayed to remote |
| 642 | * devices when the video signal is paused. |
| 643 | * |
| 644 | * @param uri URI of image to display. |
| 645 | */ |
| 646 | public abstract void onSetPauseImage(String uri); |
| 647 | |
| 648 | /** |
| 649 | * Invokes callback method defined in In-Call UI. |
| 650 | * |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 651 | * @param videoProfile The requested video connection profile. |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 652 | */ |
| 653 | public void receiveSessionModifyRequest(VideoProfile videoProfile) { |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 654 | if (mVideoCallback != null) { |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 655 | try { |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 656 | mVideoCallback.receiveSessionModifyRequest(videoProfile); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 657 | } catch (RemoteException ignored) { |
| 658 | } |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | /** |
| 663 | * Invokes callback method defined in In-Call UI. |
| 664 | * |
| 665 | * @param status Status of the session modify request. Valid values are |
| 666 | * {@link VideoProvider#SESSION_MODIFY_REQUEST_SUCCESS}, |
| 667 | * {@link VideoProvider#SESSION_MODIFY_REQUEST_FAIL}, |
| 668 | * {@link VideoProvider#SESSION_MODIFY_REQUEST_INVALID} |
| 669 | * @param requestedProfile The original request which was sent to the remote device. |
| 670 | * @param responseProfile The actual profile changes made by the remote device. |
| 671 | */ |
| 672 | public void receiveSessionModifyResponse(int status, |
| 673 | VideoProfile requestedProfile, VideoProfile responseProfile) { |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 674 | if (mVideoCallback != null) { |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 675 | try { |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 676 | mVideoCallback.receiveSessionModifyResponse( |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 677 | status, requestedProfile, responseProfile); |
| 678 | } catch (RemoteException ignored) { |
| 679 | } |
| 680 | } |
| 681 | } |
| 682 | |
| 683 | /** |
| 684 | * Invokes callback method defined in In-Call UI. |
| 685 | * |
| 686 | * Valid values are: {@link VideoProvider#SESSION_EVENT_RX_PAUSE}, |
| 687 | * {@link VideoProvider#SESSION_EVENT_RX_RESUME}, |
| 688 | * {@link VideoProvider#SESSION_EVENT_TX_START}, |
| 689 | * {@link VideoProvider#SESSION_EVENT_TX_STOP} |
| 690 | * |
| 691 | * @param event The event. |
| 692 | */ |
| 693 | public void handleCallSessionEvent(int event) { |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 694 | if (mVideoCallback != null) { |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 695 | try { |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 696 | mVideoCallback.handleCallSessionEvent(event); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 697 | } catch (RemoteException ignored) { |
| 698 | } |
| 699 | } |
| 700 | } |
| 701 | |
| 702 | /** |
| 703 | * Invokes callback method defined in In-Call UI. |
| 704 | * |
| 705 | * @param width The updated peer video width. |
| 706 | * @param height The updated peer video height. |
| 707 | */ |
| 708 | public void changePeerDimensions(int width, int height) { |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 709 | if (mVideoCallback != null) { |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 710 | try { |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 711 | mVideoCallback.changePeerDimensions(width, height); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 712 | } catch (RemoteException ignored) { |
| 713 | } |
| 714 | } |
| 715 | } |
| 716 | |
| 717 | /** |
| 718 | * Invokes callback method defined in In-Call UI. |
| 719 | * |
| 720 | * @param dataUsage The updated data usage. |
| 721 | */ |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 722 | public void changeCallDataUsage(long dataUsage) { |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 723 | if (mVideoCallback != null) { |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 724 | try { |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 725 | mVideoCallback.changeCallDataUsage(dataUsage); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 726 | } catch (RemoteException ignored) { |
| 727 | } |
| 728 | } |
| 729 | } |
| 730 | |
| 731 | /** |
| 732 | * Invokes callback method defined in In-Call UI. |
| 733 | * |
| 734 | * @param cameraCapabilities The changed camera capabilities. |
| 735 | */ |
| 736 | public void changeCameraCapabilities(CameraCapabilities cameraCapabilities) { |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 737 | if (mVideoCallback != null) { |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 738 | try { |
| Ihab Awad | a64627c | 2014-08-20 09:36:40 -0700 | [diff] [blame] | 739 | mVideoCallback.changeCameraCapabilities(cameraCapabilities); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 740 | } catch (RemoteException ignored) { |
| 741 | } |
| 742 | } |
| 743 | } |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 744 | |
| 745 | /** |
| 746 | * Invokes callback method defined in In-Call UI. |
| 747 | * |
| 748 | * @param videoQuality The updated video quality. |
| 749 | */ |
| 750 | public void changeVideoQuality(int videoQuality) { |
| 751 | if (mVideoCallback != null) { |
| 752 | try { |
| 753 | mVideoCallback.changeVideoQuality(videoQuality); |
| 754 | } catch (RemoteException ignored) { |
| 755 | } |
| 756 | } |
| 757 | } |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 758 | } |
| 759 | |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 760 | private final Listener mConnectionDeathListener = new Listener() { |
| 761 | @Override |
| 762 | public void onDestroyed(Connection c) { |
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 763 | if (mConferenceables.remove(c)) { |
| 764 | fireOnConferenceableConnectionsChanged(); |
| 765 | } |
| 766 | } |
| 767 | }; |
| 768 | |
| 769 | private final Conference.Listener mConferenceDeathListener = new Conference.Listener() { |
| 770 | @Override |
| 771 | public void onDestroyed(Conference c) { |
| 772 | if (mConferenceables.remove(c)) { |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 773 | fireOnConferenceableConnectionsChanged(); |
| 774 | } |
| 775 | } |
| 776 | }; |
| 777 | |
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 778 | /** |
| 779 | * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is |
| 780 | * load factor before resizing, 1 means we only expect a single thread to |
| 781 | * access the map so make only a single shard |
| 782 | */ |
| 783 | private final Set<Listener> mListeners = Collections.newSetFromMap( |
| 784 | new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1)); |
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 785 | private final List<IConferenceable> mConferenceables = new ArrayList<>(); |
| 786 | private final List<IConferenceable> mUnmodifiableConferenceables = |
| 787 | Collections.unmodifiableList(mConferenceables); |
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 788 | |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 789 | private int mState = STATE_NEW; |
| 790 | private AudioState mAudioState; |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 791 | private Uri mAddress; |
| 792 | private int mAddressPresentation; |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 793 | private String mCallerDisplayName; |
| 794 | private int mCallerDisplayNamePresentation; |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 795 | private boolean mRingbackRequested = false; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 796 | private int mConnectionCapabilities; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 797 | private VideoProvider mVideoProvider; |
| Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 798 | private boolean mAudioModeIsVoip; |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 799 | private StatusHints mStatusHints; |
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 800 | private int mVideoState; |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 801 | private DisconnectCause mDisconnectCause; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 802 | private Conference mConference; |
| 803 | private ConnectionService mConnectionService; |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 804 | private int mCallSubstate; |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 805 | |
| 806 | /** |
| 807 | * Create a new Connection. |
| 808 | */ |
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 809 | public Connection() {} |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 810 | |
| 811 | /** |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 812 | * @return The address (e.g., phone number) to which this Connection is currently communicating. |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 813 | */ |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 814 | public final Uri getAddress() { |
| 815 | return mAddress; |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 816 | } |
| 817 | |
| 818 | /** |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 819 | * @return The presentation requirements for the address. |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 820 | * See {@link TelecomManager} for valid values. |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 821 | */ |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 822 | public final int getAddressPresentation() { |
| 823 | return mAddressPresentation; |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 824 | } |
| 825 | |
| 826 | /** |
| 827 | * @return The caller display name (CNAP). |
| 828 | */ |
| 829 | public final String getCallerDisplayName() { |
| 830 | return mCallerDisplayName; |
| 831 | } |
| 832 | |
| 833 | /** |
| Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 834 | * @return The presentation requirements for the handle. |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 835 | * See {@link TelecomManager} for valid values. |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 836 | */ |
| 837 | public final int getCallerDisplayNamePresentation() { |
| 838 | return mCallerDisplayNamePresentation; |
| 839 | } |
| 840 | |
| 841 | /** |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 842 | * @return The state of this Connection. |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 843 | */ |
| 844 | public final int getState() { |
| 845 | return mState; |
| 846 | } |
| 847 | |
| 848 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 849 | * Returns the video state of the connection. |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 850 | * Valid values: {@link VideoProfile.VideoState#AUDIO_ONLY}, |
| 851 | * {@link VideoProfile.VideoState#BIDIRECTIONAL}, |
| 852 | * {@link VideoProfile.VideoState#TX_ENABLED}, |
| 853 | * {@link VideoProfile.VideoState#RX_ENABLED}. |
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 854 | * |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 855 | * @return The video state of the connection. |
| Tyler Gunn | 27d1e25 | 2014-08-21 16:38:40 -0700 | [diff] [blame] | 856 | * @hide |
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 857 | */ |
| 858 | public final int getVideoState() { |
| 859 | return mVideoState; |
| 860 | } |
| 861 | |
| 862 | /** |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 863 | * Returns the call substate of the call. |
| 864 | * Valid values: {@link Connection#SUBSTATE_NONE}, |
| 865 | * {@link Connection#SUBSTATE_AUDIO_CONNECTED_SUSPENDED}, |
| 866 | * {@link Connection#SUBSTATE_VIDEO_CONNECTED_SUSPENDED}, |
| 867 | * {@link Connection#SUBSTATE_AVP_RETRY}, |
| 868 | * {@link Connection#SUBSTATE_MEDIA_PAUSED}. |
| 869 | * |
| 870 | * @param callSubstate The new call substate. |
| 871 | * @hide |
| 872 | */ |
| 873 | public final int getCallSubstate() { |
| 874 | return mCallSubstate; |
| 875 | } |
| 876 | |
| 877 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 878 | * @return The audio state of the connection, describing how its audio is currently |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 879 | * being routed by the system. This is {@code null} if this Connection |
| 880 | * does not directly know about its audio state. |
| 881 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 882 | public final AudioState getAudioState() { |
| 883 | return mAudioState; |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 884 | } |
| 885 | |
| 886 | /** |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 887 | * @return The conference that this connection is a part of. Null if it is not part of any |
| 888 | * conference. |
| 889 | */ |
| 890 | public final Conference getConference() { |
| 891 | return mConference; |
| 892 | } |
| 893 | |
| 894 | /** |
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 895 | * Returns whether this connection is requesting that the system play a ringback tone |
| 896 | * on its behalf. |
| 897 | */ |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 898 | public final boolean isRingbackRequested() { |
| 899 | return mRingbackRequested; |
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 900 | } |
| 901 | |
| 902 | /** |
| Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 903 | * @return True if the connection's audio mode is VOIP. |
| 904 | */ |
| 905 | public final boolean getAudioModeIsVoip() { |
| 906 | return mAudioModeIsVoip; |
| 907 | } |
| 908 | |
| 909 | /** |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 910 | * @return The status hints for this connection. |
| 911 | */ |
| 912 | public final StatusHints getStatusHints() { |
| 913 | return mStatusHints; |
| 914 | } |
| 915 | |
| 916 | /** |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 917 | * Assign a listener to be notified of state changes. |
| 918 | * |
| 919 | * @param l A listener. |
| 920 | * @return This Connection. |
| 921 | * |
| 922 | * @hide |
| 923 | */ |
| 924 | public final Connection addConnectionListener(Listener l) { |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 925 | mListeners.add(l); |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 926 | return this; |
| 927 | } |
| 928 | |
| 929 | /** |
| 930 | * Remove a previously assigned listener that was being notified of state changes. |
| 931 | * |
| 932 | * @param l A Listener. |
| 933 | * @return This Connection. |
| 934 | * |
| 935 | * @hide |
| 936 | */ |
| 937 | public final Connection removeConnectionListener(Listener l) { |
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 938 | if (l != null) { |
| 939 | mListeners.remove(l); |
| 940 | } |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 941 | return this; |
| 942 | } |
| 943 | |
| 944 | /** |
| Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 945 | * @return The {@link DisconnectCause} for this connection. |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 946 | */ |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 947 | public final DisconnectCause getDisconnectCause() { |
| Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 948 | return mDisconnectCause; |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 949 | } |
| 950 | |
| 951 | /** |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 952 | * Inform this Connection that the state of its audio output has been changed externally. |
| 953 | * |
| 954 | * @param state The new audio state. |
| Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 955 | * @hide |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 956 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 957 | final void setAudioState(AudioState state) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 958 | checkImmutable(); |
| Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 959 | Log.d(this, "setAudioState %s", state); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 960 | mAudioState = state; |
| Nancy Chen | 354b2bd | 2014-09-08 18:27:26 -0700 | [diff] [blame] | 961 | onAudioStateChanged(state); |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 962 | } |
| 963 | |
| 964 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 965 | * @param state An integer value of a {@code STATE_*} constant. |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 966 | * @return A string representation of the value. |
| 967 | */ |
| 968 | public static String stateToString(int state) { |
| 969 | switch (state) { |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 970 | case STATE_INITIALIZING: |
| 971 | return "STATE_INITIALIZING"; |
| 972 | case STATE_NEW: |
| 973 | return "STATE_NEW"; |
| 974 | case STATE_RINGING: |
| 975 | return "STATE_RINGING"; |
| 976 | case STATE_DIALING: |
| 977 | return "STATE_DIALING"; |
| 978 | case STATE_ACTIVE: |
| 979 | return "STATE_ACTIVE"; |
| 980 | case STATE_HOLDING: |
| 981 | return "STATE_HOLDING"; |
| 982 | case STATE_DISCONNECTED: |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 983 | return "DISCONNECTED"; |
| 984 | default: |
| Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 985 | Log.wtf(Connection.class, "Unknown state %d", state); |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 986 | return "UNKNOWN"; |
| 987 | } |
| 988 | } |
| 989 | |
| 990 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 991 | * Returns the connection's capabilities, as a bit mask of the {@code CAPABILITY_*} constants. |
| Ihab Awad | 52a28f6 | 2014-06-18 10:26:34 -0700 | [diff] [blame] | 992 | */ |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 993 | public final int getConnectionCapabilities() { |
| 994 | return mConnectionCapabilities; |
| Ihab Awad | 52a28f6 | 2014-06-18 10:26:34 -0700 | [diff] [blame] | 995 | } |
| 996 | |
| Sailesh Nepal | ef77f0e | 2014-12-02 15:18:25 -0800 | [diff] [blame] | 997 | /** @hide */ |
| 998 | @SystemApi @Deprecated public final int getCallCapabilities() { |
| 999 | return getConnectionCapabilities(); |
| 1000 | } |
| 1001 | |
| Ihab Awad | 52a28f6 | 2014-06-18 10:26:34 -0700 | [diff] [blame] | 1002 | /** |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1003 | * Sets the value of the {@link #getAddress()} property. |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1004 | * |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1005 | * @param address The new address. |
| 1006 | * @param presentation The presentation requirements for the address. |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1007 | * See {@link TelecomManager} for valid values. |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1008 | */ |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1009 | public final void setAddress(Uri address, int presentation) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1010 | checkImmutable(); |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1011 | Log.d(this, "setAddress %s", address); |
| 1012 | mAddress = address; |
| 1013 | mAddressPresentation = presentation; |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1014 | for (Listener l : mListeners) { |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1015 | l.onAddressChanged(this, address, presentation); |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1016 | } |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1017 | } |
| 1018 | |
| 1019 | /** |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1020 | * Sets the caller display name (CNAP). |
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1021 | * |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1022 | * @param callerDisplayName The new display name. |
| Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 1023 | * @param presentation The presentation requirements for the handle. |
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1024 | * See {@link TelecomManager} for valid values. |
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1025 | */ |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1026 | public final void setCallerDisplayName(String callerDisplayName, int presentation) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1027 | checkImmutable(); |
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1028 | Log.d(this, "setCallerDisplayName %s", callerDisplayName); |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1029 | mCallerDisplayName = callerDisplayName; |
| 1030 | mCallerDisplayNamePresentation = presentation; |
| 1031 | for (Listener l : mListeners) { |
| 1032 | l.onCallerDisplayNameChanged(this, callerDisplayName, presentation); |
| 1033 | } |
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1034 | } |
| 1035 | |
| 1036 | /** |
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 1037 | * Set the video state for the connection. |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1038 | * Valid values: {@link VideoProfile.VideoState#AUDIO_ONLY}, |
| 1039 | * {@link VideoProfile.VideoState#BIDIRECTIONAL}, |
| 1040 | * {@link VideoProfile.VideoState#TX_ENABLED}, |
| 1041 | * {@link VideoProfile.VideoState#RX_ENABLED}. |
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 1042 | * |
| 1043 | * @param videoState The new video state. |
| Tyler Gunn | 27d1e25 | 2014-08-21 16:38:40 -0700 | [diff] [blame] | 1044 | * @hide |
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 1045 | */ |
| 1046 | public final void setVideoState(int videoState) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1047 | checkImmutable(); |
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 1048 | Log.d(this, "setVideoState %d", videoState); |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1049 | mVideoState = videoState; |
| 1050 | for (Listener l : mListeners) { |
| 1051 | l.onVideoStateChanged(this, mVideoState); |
| 1052 | } |
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 1053 | } |
| 1054 | |
| 1055 | /** |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1056 | * Set the call substate for the connection. |
| 1057 | * Valid values: {@link Connection#SUBSTATE_NONE}, |
| 1058 | * {@link Connection#SUBSTATE_AUDIO_CONNECTED_SUSPENDED}, |
| 1059 | * {@link Connection#SUBSTATE_VIDEO_CONNECTED_SUSPENDED}, |
| 1060 | * {@link Connection#SUBSTATE_AVP_RETRY}, |
| 1061 | * {@link Connection#SUBSTATE_MEDIA_PAUSED}. |
| 1062 | * |
| 1063 | * @param callSubstate The new call substate. |
| 1064 | * @hide |
| 1065 | */ |
| 1066 | public final void setCallSubstate(int callSubstate) { |
| 1067 | Log.d(this, "setCallSubstate %d", callSubstate); |
| 1068 | mCallSubstate = callSubstate; |
| 1069 | for (Listener l : mListeners) { |
| 1070 | l.onCallSubstateChanged(this, mCallSubstate); |
| 1071 | } |
| 1072 | } |
| 1073 | |
| 1074 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1075 | * Sets state to active (e.g., an ongoing connection where two or more parties can actively |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1076 | * communicate). |
| 1077 | */ |
| Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 1078 | public final void setActive() { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1079 | checkImmutable(); |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1080 | setRingbackRequested(false); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1081 | setState(STATE_ACTIVE); |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1082 | } |
| 1083 | |
| 1084 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1085 | * Sets state to ringing (e.g., an inbound ringing connection). |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1086 | */ |
| Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 1087 | public final void setRinging() { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1088 | checkImmutable(); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1089 | setState(STATE_RINGING); |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1090 | } |
| 1091 | |
| 1092 | /** |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1093 | * Sets state to initializing (this Connection is not yet ready to be used). |
| 1094 | */ |
| 1095 | public final void setInitializing() { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1096 | checkImmutable(); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1097 | setState(STATE_INITIALIZING); |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1098 | } |
| 1099 | |
| 1100 | /** |
| 1101 | * Sets state to initialized (the Connection has been set up and is now ready to be used). |
| 1102 | */ |
| 1103 | public final void setInitialized() { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1104 | checkImmutable(); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1105 | setState(STATE_NEW); |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1106 | } |
| 1107 | |
| 1108 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1109 | * Sets state to dialing (e.g., dialing an outbound connection). |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1110 | */ |
| Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 1111 | public final void setDialing() { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1112 | checkImmutable(); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1113 | setState(STATE_DIALING); |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1114 | } |
| 1115 | |
| 1116 | /** |
| 1117 | * Sets state to be on hold. |
| 1118 | */ |
| Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 1119 | public final void setOnHold() { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1120 | checkImmutable(); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1121 | setState(STATE_HOLDING); |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1122 | } |
| 1123 | |
| 1124 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1125 | * Sets the video connection provider. |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1126 | * @param videoProvider The video provider. |
| Tyler Gunn | 27d1e25 | 2014-08-21 16:38:40 -0700 | [diff] [blame] | 1127 | * @hide |
| Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 1128 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1129 | public final void setVideoProvider(VideoProvider videoProvider) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1130 | checkImmutable(); |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1131 | mVideoProvider = videoProvider; |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1132 | for (Listener l : mListeners) { |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1133 | l.onVideoProviderChanged(this, videoProvider); |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1134 | } |
| Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 1135 | } |
| 1136 | |
| Tyler Gunn | 27d1e25 | 2014-08-21 16:38:40 -0700 | [diff] [blame] | 1137 | /** @hide */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1138 | public final VideoProvider getVideoProvider() { |
| 1139 | return mVideoProvider; |
| Andrew Lee | a27a193 | 2014-07-09 17:07:13 -0700 | [diff] [blame] | 1140 | } |
| 1141 | |
| Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 1142 | /** |
| Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 1143 | * Sets state to disconnected. |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1144 | * |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1145 | * @param disconnectCause The reason for the disconnection, as specified by |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1146 | * {@link DisconnectCause}. |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1147 | */ |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1148 | public final void setDisconnected(DisconnectCause disconnectCause) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1149 | checkImmutable(); |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1150 | mDisconnectCause = disconnectCause; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1151 | setState(STATE_DISCONNECTED); |
| mike dooley | f34519b | 2014-09-16 17:33:40 -0700 | [diff] [blame] | 1152 | Log.d(this, "Disconnected with cause %s", disconnectCause); |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1153 | for (Listener l : mListeners) { |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1154 | l.onDisconnected(this, disconnectCause); |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1155 | } |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1156 | } |
| 1157 | |
| 1158 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1159 | * Informs listeners that this {@code Connection} is in a post-dial wait state. This is done |
| 1160 | * when (a) the {@code Connection} is issuing a DTMF sequence; (b) it has encountered a "wait" |
| 1161 | * character; and (c) it wishes to inform the In-Call app that it is waiting for the end-user |
| 1162 | * to send an {@link #onPostDialContinue(boolean)} signal. |
| 1163 | * |
| 1164 | * @param remaining The DTMF character sequence remaining to be emitted once the |
| 1165 | * {@link #onPostDialContinue(boolean)} is received, including any "wait" characters |
| 1166 | * that remaining sequence may contain. |
| Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 1167 | */ |
| 1168 | public final void setPostDialWait(String remaining) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1169 | checkImmutable(); |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1170 | for (Listener l : mListeners) { |
| 1171 | l.onPostDialWait(this, remaining); |
| 1172 | } |
| Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 1173 | } |
| 1174 | |
| 1175 | /** |
| Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 1176 | * Informs listeners that this {@code Connection} has processed a character in the post-dial |
| 1177 | * started state. This is done when (a) the {@code Connection} is issuing a DTMF sequence; |
| Sailesh Nepal | 1ed8561 | 2015-01-31 15:17:19 -0800 | [diff] [blame] | 1178 | * and (b) it wishes to signal Telecom to play the corresponding DTMF tone locally. |
| Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 1179 | * |
| 1180 | * @param nextChar The DTMF character that was just processed by the {@code Connection}. |
| Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 1181 | */ |
| Sailesh Nepal | 1ed8561 | 2015-01-31 15:17:19 -0800 | [diff] [blame] | 1182 | public final void setNextPostDialChar(char nextChar) { |
| Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 1183 | checkImmutable(); |
| 1184 | for (Listener l : mListeners) { |
| 1185 | l.onPostDialChar(this, nextChar); |
| 1186 | } |
| 1187 | } |
| 1188 | |
| 1189 | /** |
| Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 1190 | * Requests that the framework play a ringback tone. This is to be invoked by implementations |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1191 | * that do not play a ringback tone themselves in the connection's audio stream. |
| Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 1192 | * |
| 1193 | * @param ringback Whether the ringback tone is to be played. |
| 1194 | */ |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1195 | public final void setRingbackRequested(boolean ringback) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1196 | checkImmutable(); |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1197 | if (mRingbackRequested != ringback) { |
| 1198 | mRingbackRequested = ringback; |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1199 | for (Listener l : mListeners) { |
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1200 | l.onRingbackRequested(this, ringback); |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1201 | } |
| 1202 | } |
| Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 1203 | } |
| 1204 | |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1205 | /** @hide */ |
| Ihab Awad | de06133 | 2014-12-01 12:19:57 -0800 | [diff] [blame] | 1206 | @SystemApi @Deprecated public final void setCallCapabilities(int connectionCapabilities) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1207 | setConnectionCapabilities(connectionCapabilities); |
| 1208 | } |
| 1209 | |
| Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 1210 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1211 | * Sets the connection's capabilities as a bit mask of the {@code CAPABILITY_*} constants. |
| Sailesh Nepal | 1a7061b | 2014-07-09 21:03:20 -0700 | [diff] [blame] | 1212 | * |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1213 | * @param connectionCapabilities The new connection capabilities. |
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1214 | */ |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1215 | public final void setConnectionCapabilities(int connectionCapabilities) { |
| 1216 | checkImmutable(); |
| 1217 | if (mConnectionCapabilities != connectionCapabilities) { |
| 1218 | mConnectionCapabilities = connectionCapabilities; |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1219 | for (Listener l : mListeners) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1220 | l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities); |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1221 | } |
| 1222 | } |
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1223 | } |
| 1224 | |
| 1225 | /** |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1226 | * Tears down the Connection object. |
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1227 | */ |
| Evan Charlton | 36a7134 | 2014-07-19 16:31:02 -0700 | [diff] [blame] | 1228 | public final void destroy() { |
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 1229 | for (Listener l : mListeners) { |
| 1230 | l.onDestroyed(this); |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1231 | } |
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1232 | } |
| 1233 | |
| 1234 | /** |
| Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 1235 | * Requests that the framework use VOIP audio mode for this connection. |
| 1236 | * |
| 1237 | * @param isVoip True if the audio mode is VOIP. |
| 1238 | */ |
| 1239 | public final void setAudioModeIsVoip(boolean isVoip) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1240 | checkImmutable(); |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1241 | mAudioModeIsVoip = isVoip; |
| 1242 | for (Listener l : mListeners) { |
| 1243 | l.onAudioModeIsVoipChanged(this, isVoip); |
| 1244 | } |
| Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 1245 | } |
| 1246 | |
| 1247 | /** |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 1248 | * Sets the label and icon status to display in the in-call UI. |
| 1249 | * |
| 1250 | * @param statusHints The status label and icon to set. |
| 1251 | */ |
| 1252 | public final void setStatusHints(StatusHints statusHints) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1253 | checkImmutable(); |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1254 | mStatusHints = statusHints; |
| 1255 | for (Listener l : mListeners) { |
| 1256 | l.onStatusHintsChanged(this, statusHints); |
| 1257 | } |
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 1258 | } |
| 1259 | |
| 1260 | /** |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1261 | * Sets the connections with which this connection can be conferenced. |
| 1262 | * |
| 1263 | * @param conferenceableConnections The set of connections this connection can conference with. |
| 1264 | */ |
| 1265 | public final void setConferenceableConnections(List<Connection> conferenceableConnections) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1266 | checkImmutable(); |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1267 | clearConferenceableList(); |
| 1268 | for (Connection c : conferenceableConnections) { |
| 1269 | // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a |
| 1270 | // small amount of items here. |
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1271 | if (!mConferenceables.contains(c)) { |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1272 | c.addConnectionListener(mConnectionDeathListener); |
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1273 | mConferenceables.add(c); |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1274 | } |
| 1275 | } |
| 1276 | fireOnConferenceableConnectionsChanged(); |
| 1277 | } |
| 1278 | |
| 1279 | /** |
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1280 | * Similar to {@link #setConferenceableConnections(java.util.List)}, sets a list of connections |
| 1281 | * or conferences with which this connection can be conferenced. |
| 1282 | * |
| 1283 | * @param conferenceables The conferenceables. |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1284 | */ |
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1285 | public final void setConferenceables(List<IConferenceable> conferenceables) { |
| 1286 | clearConferenceableList(); |
| 1287 | for (IConferenceable c : conferenceables) { |
| 1288 | // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a |
| 1289 | // small amount of items here. |
| 1290 | if (!mConferenceables.contains(c)) { |
| 1291 | if (c instanceof Connection) { |
| 1292 | Connection connection = (Connection) c; |
| 1293 | connection.addConnectionListener(mConnectionDeathListener); |
| 1294 | } else if (c instanceof Conference) { |
| 1295 | Conference conference = (Conference) c; |
| 1296 | conference.addListener(mConferenceDeathListener); |
| 1297 | } |
| 1298 | mConferenceables.add(c); |
| 1299 | } |
| 1300 | } |
| 1301 | fireOnConferenceableConnectionsChanged(); |
| 1302 | } |
| 1303 | |
| 1304 | /** |
| 1305 | * Returns the connections or conferences with which this connection can be conferenced. |
| 1306 | */ |
| 1307 | public final List<IConferenceable> getConferenceables() { |
| 1308 | return mUnmodifiableConferenceables; |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1309 | } |
| 1310 | |
| Evan Charlton | 8635c57 | 2014-09-24 14:04:51 -0700 | [diff] [blame] | 1311 | /* |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1312 | * @hide |
| 1313 | */ |
| 1314 | public final void setConnectionService(ConnectionService connectionService) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1315 | checkImmutable(); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1316 | if (mConnectionService != null) { |
| 1317 | Log.e(this, new Exception(), "Trying to set ConnectionService on a connection " + |
| 1318 | "which is already associated with another ConnectionService."); |
| 1319 | } else { |
| 1320 | mConnectionService = connectionService; |
| 1321 | } |
| 1322 | } |
| 1323 | |
| 1324 | /** |
| 1325 | * @hide |
| 1326 | */ |
| 1327 | public final void unsetConnectionService(ConnectionService connectionService) { |
| 1328 | if (mConnectionService != connectionService) { |
| 1329 | Log.e(this, new Exception(), "Trying to remove ConnectionService from a Connection " + |
| 1330 | "that does not belong to the ConnectionService."); |
| 1331 | } else { |
| 1332 | mConnectionService = null; |
| 1333 | } |
| 1334 | } |
| 1335 | |
| 1336 | /** |
| Santos Cordon | af1b296 | 2014-10-16 19:23:54 -0700 | [diff] [blame] | 1337 | * @hide |
| 1338 | */ |
| 1339 | public final ConnectionService getConnectionService() { |
| 1340 | return mConnectionService; |
| 1341 | } |
| 1342 | |
| 1343 | /** |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1344 | * Sets the conference that this connection is a part of. This will fail if the connection is |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1345 | * already part of a conference. {@link #resetConference} to un-set the conference first. |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1346 | * |
| 1347 | * @param conference The conference. |
| 1348 | * @return {@code true} if the conference was successfully set. |
| 1349 | * @hide |
| 1350 | */ |
| 1351 | public final boolean setConference(Conference conference) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1352 | checkImmutable(); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1353 | // We check to see if it is already part of another conference. |
| Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 1354 | if (mConference == null) { |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1355 | mConference = conference; |
| Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 1356 | if (mConnectionService != null && mConnectionService.containsConference(conference)) { |
| 1357 | fireConferenceChanged(); |
| 1358 | } |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1359 | return true; |
| 1360 | } |
| 1361 | return false; |
| 1362 | } |
| 1363 | |
| 1364 | /** |
| 1365 | * Resets the conference that this connection is a part of. |
| 1366 | * @hide |
| 1367 | */ |
| 1368 | public final void resetConference() { |
| 1369 | if (mConference != null) { |
| Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 1370 | Log.d(this, "Conference reset"); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1371 | mConference = null; |
| 1372 | fireConferenceChanged(); |
| 1373 | } |
| 1374 | } |
| 1375 | |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1376 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1377 | * Notifies this Connection that the {@link #getAudioState()} property has a new value. |
| Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 1378 | * |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1379 | * @param state The new connection audio state. |
| Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 1380 | */ |
| Nancy Chen | 354b2bd | 2014-09-08 18:27:26 -0700 | [diff] [blame] | 1381 | public void onAudioStateChanged(AudioState state) {} |
| Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 1382 | |
| 1383 | /** |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1384 | * Notifies this Connection of an internal state change. This method is called after the |
| 1385 | * state is changed. |
| Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 1386 | * |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1387 | * @param state The new state, one of the {@code STATE_*} constants. |
| Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 1388 | */ |
| Nancy Chen | 354b2bd | 2014-09-08 18:27:26 -0700 | [diff] [blame] | 1389 | public void onStateChanged(int state) {} |
| Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 1390 | |
| 1391 | /** |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1392 | * Notifies this Connection of a request to play a DTMF tone. |
| 1393 | * |
| 1394 | * @param c A DTMF character. |
| 1395 | */ |
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 1396 | public void onPlayDtmfTone(char c) {} |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1397 | |
| 1398 | /** |
| 1399 | * Notifies this Connection of a request to stop any currently playing DTMF tones. |
| 1400 | */ |
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 1401 | public void onStopDtmfTone() {} |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1402 | |
| 1403 | /** |
| 1404 | * Notifies this Connection of a request to disconnect. |
| 1405 | */ |
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 1406 | public void onDisconnect() {} |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1407 | |
| 1408 | /** |
| Tyler Gunn | 3b4b1dc | 2014-11-04 14:53:37 -0800 | [diff] [blame] | 1409 | * Notifies this Connection of a request to disconnect a participant of the conference managed |
| 1410 | * by the connection. |
| 1411 | * |
| 1412 | * @param endpoint the {@link Uri} of the participant to disconnect. |
| 1413 | * @hide |
| 1414 | */ |
| 1415 | public void onDisconnectConferenceParticipant(Uri endpoint) {} |
| 1416 | |
| 1417 | /** |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1418 | * Notifies this Connection of a request to separate from its parent conference. |
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1419 | */ |
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 1420 | public void onSeparate() {} |
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1421 | |
| 1422 | /** |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1423 | * Notifies this Connection of a request to abort. |
| 1424 | */ |
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 1425 | public void onAbort() {} |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1426 | |
| 1427 | /** |
| 1428 | * Notifies this Connection of a request to hold. |
| 1429 | */ |
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 1430 | public void onHold() {} |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1431 | |
| 1432 | /** |
| 1433 | * Notifies this Connection of a request to exit a hold state. |
| 1434 | */ |
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 1435 | public void onUnhold() {} |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1436 | |
| 1437 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1438 | * Notifies this Connection, which is in {@link #STATE_RINGING}, of |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1439 | * a request to accept. |
| Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 1440 | * |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1441 | * @param videoState The video state in which to answer the connection. |
| Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 1442 | * @hide |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1443 | */ |
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 1444 | public void onAnswer(int videoState) {} |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1445 | |
| 1446 | /** |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1447 | * Notifies this Connection, which is in {@link #STATE_RINGING}, of |
| Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 1448 | * a request to accept. |
| 1449 | */ |
| 1450 | public void onAnswer() { |
| 1451 | onAnswer(VideoProfile.VideoState.AUDIO_ONLY); |
| 1452 | } |
| 1453 | |
| 1454 | /** |
| 1455 | * Notifies this Connection, which is in {@link #STATE_RINGING}, of |
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1456 | * a request to reject. |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1457 | */ |
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 1458 | public void onReject() {} |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1459 | |
| Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 1460 | /** |
| 1461 | * Notifies this Connection whether the user wishes to proceed with the post-dial DTMF codes. |
| 1462 | */ |
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 1463 | public void onPostDialContinue(boolean proceed) {} |
| Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 1464 | |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1465 | static String toLogSafePhoneNumber(String number) { |
| 1466 | // For unknown number, log empty string. |
| 1467 | if (number == null) { |
| 1468 | return ""; |
| 1469 | } |
| 1470 | |
| 1471 | if (PII_DEBUG) { |
| 1472 | // When PII_DEBUG is true we emit PII. |
| 1473 | return number; |
| 1474 | } |
| 1475 | |
| 1476 | // Do exactly same thing as Uri#toSafeString() does, which will enable us to compare |
| 1477 | // sanitized phone numbers. |
| 1478 | StringBuilder builder = new StringBuilder(); |
| 1479 | for (int i = 0; i < number.length(); i++) { |
| 1480 | char c = number.charAt(i); |
| 1481 | if (c == '-' || c == '@' || c == '.') { |
| 1482 | builder.append(c); |
| 1483 | } else { |
| 1484 | builder.append('x'); |
| 1485 | } |
| 1486 | } |
| 1487 | return builder.toString(); |
| 1488 | } |
| 1489 | |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1490 | private void setState(int state) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1491 | checkImmutable(); |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1492 | if (mState == STATE_DISCONNECTED && mState != state) { |
| 1493 | Log.d(this, "Connection already DISCONNECTED; cannot transition out of this state."); |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1494 | return; |
| Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 1495 | } |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1496 | if (mState != state) { |
| 1497 | Log.d(this, "setState: %s", stateToString(state)); |
| 1498 | mState = state; |
| Nancy Chen | 354b2bd | 2014-09-08 18:27:26 -0700 | [diff] [blame] | 1499 | onStateChanged(state); |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1500 | for (Listener l : mListeners) { |
| 1501 | l.onStateChanged(this, state); |
| 1502 | } |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1503 | } |
| 1504 | } |
| 1505 | |
| Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1506 | private static class FailureSignalingConnection extends Connection { |
| Ihab Awad | 90e34e3 | 2014-12-01 16:23:17 -0800 | [diff] [blame] | 1507 | private boolean mImmutable = false; |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1508 | public FailureSignalingConnection(DisconnectCause disconnectCause) { |
| 1509 | setDisconnected(disconnectCause); |
| Ihab Awad | 90e34e3 | 2014-12-01 16:23:17 -0800 | [diff] [blame] | 1510 | mImmutable = true; |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1511 | } |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1512 | |
| 1513 | public void checkImmutable() { |
| Ihab Awad | 90e34e3 | 2014-12-01 16:23:17 -0800 | [diff] [blame] | 1514 | if (mImmutable) { |
| 1515 | throw new UnsupportedOperationException("Connection is immutable"); |
| 1516 | } |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1517 | } |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1518 | } |
| 1519 | |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1520 | /** |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1521 | * Return a {@code Connection} which represents a failed connection attempt. The returned |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1522 | * {@code Connection} will have a {@link android.telecom.DisconnectCause} and as specified, |
| 1523 | * and a {@link #getState()} of {@link #STATE_DISCONNECTED}. |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1524 | * <p> |
| 1525 | * The returned {@code Connection} can be assumed to {@link #destroy()} itself when appropriate, |
| 1526 | * so users of this method need not maintain a reference to its return value to destroy it. |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1527 | * |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1528 | * @param disconnectCause The disconnect cause, ({@see android.telecomm.DisconnectCause}). |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1529 | * @return A {@code Connection} which indicates failure. |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1530 | */ |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1531 | public static Connection createFailedConnection(DisconnectCause disconnectCause) { |
| 1532 | return new FailureSignalingConnection(disconnectCause); |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1533 | } |
| 1534 | |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1535 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1536 | * Override to throw an {@link UnsupportedOperationException} if this {@code Connection} is |
| 1537 | * not intended to be mutated, e.g., if it is a marker for failure. Only for framework use; |
| 1538 | * this should never be un-@hide-den. |
| 1539 | * |
| 1540 | * @hide |
| 1541 | */ |
| 1542 | public void checkImmutable() {} |
| 1543 | |
| 1544 | /** |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1545 | * Return a {@code Connection} which represents a canceled connection attempt. The returned |
| 1546 | * {@code Connection} will have state {@link #STATE_DISCONNECTED}, and cannot be moved out of |
| 1547 | * that state. This connection should not be used for anything, and no other |
| 1548 | * {@code Connection}s should be attempted. |
| 1549 | * <p> |
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 1550 | * so users of this method need not maintain a reference to its return value to destroy it. |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1551 | * |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1552 | * @return A {@code Connection} which indicates that the underlying connection should |
| 1553 | * be canceled. |
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1554 | */ |
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1555 | public static Connection createCanceledConnection() { |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1556 | return new FailureSignalingConnection(new DisconnectCause(DisconnectCause.CANCELED)); |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1557 | } |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1558 | |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1559 | private final void fireOnConferenceableConnectionsChanged() { |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1560 | for (Listener l : mListeners) { |
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1561 | l.onConferenceablesChanged(this, getConferenceables()); |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1562 | } |
| 1563 | } |
| 1564 | |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1565 | private final void fireConferenceChanged() { |
| 1566 | for (Listener l : mListeners) { |
| 1567 | l.onConferenceChanged(this, mConference); |
| 1568 | } |
| 1569 | } |
| 1570 | |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1571 | private final void clearConferenceableList() { |
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1572 | for (IConferenceable c : mConferenceables) { |
| 1573 | if (c instanceof Connection) { |
| 1574 | Connection connection = (Connection) c; |
| 1575 | connection.removeConnectionListener(mConnectionDeathListener); |
| 1576 | } else if (c instanceof Conference) { |
| 1577 | Conference conference = (Conference) c; |
| 1578 | conference.removeListener(mConferenceDeathListener); |
| 1579 | } |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1580 | } |
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1581 | mConferenceables.clear(); |
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1582 | } |
| Tyler Gunn | 3bffcf7 | 2014-10-28 13:51:27 -0700 | [diff] [blame] | 1583 | |
| 1584 | /** |
| Tyler Gunn | ab4650c | 2014-11-06 20:06:23 -0800 | [diff] [blame] | 1585 | * Notifies listeners of a change to conference participant(s). |
| Tyler Gunn | 3bffcf7 | 2014-10-28 13:51:27 -0700 | [diff] [blame] | 1586 | * |
| Tyler Gunn | ab4650c | 2014-11-06 20:06:23 -0800 | [diff] [blame] | 1587 | * @param conferenceParticipants The participants. |
| Tyler Gunn | 3bffcf7 | 2014-10-28 13:51:27 -0700 | [diff] [blame] | 1588 | * @hide |
| 1589 | */ |
| Tyler Gunn | ab4650c | 2014-11-06 20:06:23 -0800 | [diff] [blame] | 1590 | protected final void updateConferenceParticipants( |
| 1591 | List<ConferenceParticipant> conferenceParticipants) { |
| Tyler Gunn | 3bffcf7 | 2014-10-28 13:51:27 -0700 | [diff] [blame] | 1592 | for (Listener l : mListeners) { |
| Tyler Gunn | ab4650c | 2014-11-06 20:06:23 -0800 | [diff] [blame] | 1593 | l.onConferenceParticipantsChanged(this, conferenceParticipants); |
| Tyler Gunn | 3bffcf7 | 2014-10-28 13:51:27 -0700 | [diff] [blame] | 1594 | } |
| 1595 | } |
| Tyler Gunn | 8a2b119 | 2015-01-29 11:47:24 -0800 | [diff] [blame] | 1596 | |
| 1597 | /** |
| 1598 | * Notifies listeners that a conference call has been started. |
| 1599 | */ |
| 1600 | protected void notifyConferenceStarted() { |
| 1601 | for (Listener l : mListeners) { |
| 1602 | l.onConferenceStarted(); |
| 1603 | } |
| 1604 | } |
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1605 | } |