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