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