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 | |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 23 | import android.annotation.NonNull; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 24 | import android.annotation.Nullable; |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 25 | import android.annotation.SystemApi; |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 26 | import android.hardware.camera2.CameraManager; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 27 | import android.net.Uri; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 28 | import android.os.Bundle; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 29 | import android.os.Handler; |
| 30 | import android.os.IBinder; |
Tyler Gunn | 4e9bbaf | 2015-05-22 15:43:28 -0700 | [diff] [blame] | 31 | import android.os.Looper; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 32 | import android.os.Message; |
| 33 | import android.os.RemoteException; |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 34 | import android.util.ArraySet; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 35 | import android.view.Surface; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 36 | |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 37 | import java.util.ArrayList; |
Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 38 | import java.util.Arrays; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 39 | import java.util.Collections; |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 40 | import java.util.List; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 41 | import java.util.Set; |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 42 | import java.util.concurrent.ConcurrentHashMap; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 43 | |
| 44 | /** |
Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 45 | * Represents a phone call or connection to a remote endpoint that carries voice and/or video |
| 46 | * traffic. |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 47 | * <p> |
| 48 | * Implementations create a custom subclass of {@code Connection} and return it to the framework |
| 49 | * as the return value of |
| 50 | * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)} |
| 51 | * or |
| 52 | * {@link ConnectionService#onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}. |
| 53 | * Implementations are then responsible for updating the state of the {@code Connection}, and |
| 54 | * must call {@link #destroy()} to signal to the framework that the {@code Connection} is no |
| 55 | * longer used and associated resources may be recovered. |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 56 | * <p> |
| 57 | * Subclasses of {@code Connection} override the {@code on*} methods to provide the the |
| 58 | * {@link ConnectionService}'s implementation of calling functionality. The {@code on*} methods are |
| 59 | * called by Telecom to inform an instance of a {@code Connection} of actions specific to that |
| 60 | * {@code Connection} instance. |
| 61 | * <p> |
| 62 | * Basic call support requires overriding the following methods: {@link #onAnswer()}, |
| 63 | * {@link #onDisconnect()}, {@link #onReject()}, {@link #onAbort()} |
| 64 | * <p> |
| 65 | * Where a {@code Connection} has {@link #CAPABILITY_SUPPORT_HOLD}, the {@link #onHold()} and |
| 66 | * {@link #onUnhold()} methods should be overridden to provide hold support for the |
| 67 | * {@code Connection}. |
| 68 | * <p> |
| 69 | * Where a {@code Connection} supports a variation of video calling (e.g. the |
| 70 | * {@code CAPABILITY_SUPPORTS_VT_*} capability bits), {@link #onAnswer(int)} should be overridden |
| 71 | * to support answering a call as a video call. |
| 72 | * <p> |
| 73 | * Where a {@code Connection} has {@link #PROPERTY_IS_EXTERNAL_CALL} and |
| 74 | * {@link #CAPABILITY_CAN_PULL_CALL}, {@link #onPullExternalCall()} should be overridden to provide |
| 75 | * support for pulling the external call. |
| 76 | * <p> |
| 77 | * Where a {@code Connection} supports conference calling {@link #onSeparate()} should be |
| 78 | * overridden. |
| 79 | * <p> |
| 80 | * There are a number of other {@code on*} methods which a {@code Connection} can choose to |
| 81 | * implement, depending on whether it is concerned with the associated calls from Telecom. If, |
| 82 | * for example, call events from a {@link InCallService} are handled, |
| 83 | * {@link #onCallEvent(String, Bundle)} should be overridden. Another example is |
| 84 | * {@link #onExtrasChanged(Bundle)}, which should be overridden if the {@code Connection} wishes to |
| 85 | * make use of extra information provided via the {@link Call#putExtras(Bundle)} and |
| 86 | * {@link Call#removeExtras(String...)} methods. |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 87 | */ |
Yorke Lee | abfcfdc | 2015-05-13 18:55:18 -0700 | [diff] [blame] | 88 | public abstract class Connection extends Conferenceable { |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 89 | |
Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 90 | /** |
| 91 | * The connection is initializing. This is generally the first state for a {@code Connection} |
| 92 | * returned by a {@link ConnectionService}. |
| 93 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 94 | public static final int STATE_INITIALIZING = 0; |
| 95 | |
Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 96 | /** |
| 97 | * The connection is new and not connected. |
| 98 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 99 | public static final int STATE_NEW = 1; |
| 100 | |
Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 101 | /** |
| 102 | * An incoming connection is in the ringing state. During this state, the user's ringer or |
| 103 | * vibration feature will be activated. |
| 104 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 105 | public static final int STATE_RINGING = 2; |
| 106 | |
Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 107 | /** |
| 108 | * An outgoing connection is in the dialing state. In this state the other party has not yet |
| 109 | * answered the call and the user traditionally hears a ringback tone. |
| 110 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 111 | public static final int STATE_DIALING = 3; |
| 112 | |
Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 113 | /** |
| 114 | * A connection is active. Both parties are connected to the call and can actively communicate. |
| 115 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 116 | public static final int STATE_ACTIVE = 4; |
| 117 | |
Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 118 | /** |
| 119 | * A connection is on hold. |
| 120 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 121 | public static final int STATE_HOLDING = 5; |
| 122 | |
Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 123 | /** |
| 124 | * A connection has been disconnected. This is the final state once the user has been |
| 125 | * disconnected from a call either locally, remotely or by an error in the service. |
| 126 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 127 | public static final int STATE_DISCONNECTED = 6; |
| 128 | |
Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 129 | /** |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 130 | * The state of an external connection which is in the process of being pulled from a remote |
| 131 | * device to the local device. |
| 132 | * <p> |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 133 | * A connection can only be in this state if the {@link #PROPERTY_IS_EXTERNAL_CALL} property and |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 134 | * {@link #CAPABILITY_CAN_PULL_CALL} capability bits are set on the connection. |
| 135 | */ |
| 136 | public static final int STATE_PULLING_CALL = 7; |
| 137 | |
| 138 | /** |
Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 139 | * Connection can currently be put on hold or unheld. This is distinct from |
| 140 | * {@link #CAPABILITY_SUPPORT_HOLD} in that although a connection may support 'hold' most times, |
| 141 | * it does not at the moment support the function. This can be true while the call is in the |
| 142 | * state {@link #STATE_DIALING}, for example. During this condition, an in-call UI may |
| 143 | * display a disabled 'hold' button. |
| 144 | */ |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 145 | public static final int CAPABILITY_HOLD = 0x00000001; |
| 146 | |
| 147 | /** Connection supports the hold feature. */ |
| 148 | public static final int CAPABILITY_SUPPORT_HOLD = 0x00000002; |
| 149 | |
| 150 | /** |
| 151 | * Connections within a conference can be merged. A {@link ConnectionService} has the option to |
| 152 | * add a {@link Conference} before the child {@link Connection}s are merged. This is how |
| 153 | * CDMA-based {@link Connection}s are implemented. For these unmerged {@link Conference}s, this |
| 154 | * capability allows a merge button to be shown while the conference is in the foreground |
| 155 | * of the in-call UI. |
| 156 | * <p> |
| 157 | * This is only intended for use by a {@link Conference}. |
| 158 | */ |
| 159 | public static final int CAPABILITY_MERGE_CONFERENCE = 0x00000004; |
| 160 | |
| 161 | /** |
| 162 | * Connections within a conference can be swapped between foreground and background. |
| 163 | * See {@link #CAPABILITY_MERGE_CONFERENCE} for additional information. |
| 164 | * <p> |
| 165 | * This is only intended for use by a {@link Conference}. |
| 166 | */ |
| 167 | public static final int CAPABILITY_SWAP_CONFERENCE = 0x00000008; |
| 168 | |
| 169 | /** |
| 170 | * @hide |
| 171 | */ |
| 172 | public static final int CAPABILITY_UNUSED = 0x00000010; |
| 173 | |
| 174 | /** Connection supports responding via text option. */ |
| 175 | public static final int CAPABILITY_RESPOND_VIA_TEXT = 0x00000020; |
| 176 | |
| 177 | /** Connection can be muted. */ |
| 178 | public static final int CAPABILITY_MUTE = 0x00000040; |
| 179 | |
| 180 | /** |
| 181 | * Connection supports conference management. This capability only applies to |
| 182 | * {@link Conference}s which can have {@link Connection}s as children. |
| 183 | */ |
| 184 | public static final int CAPABILITY_MANAGE_CONFERENCE = 0x00000080; |
| 185 | |
| 186 | /** |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 187 | * Local device supports receiving video. |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 188 | */ |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 189 | public static final int CAPABILITY_SUPPORTS_VT_LOCAL_RX = 0x00000100; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 190 | |
| 191 | /** |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 192 | * Local device supports transmitting video. |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 193 | */ |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 194 | public static final int CAPABILITY_SUPPORTS_VT_LOCAL_TX = 0x00000200; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 195 | |
| 196 | /** |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 197 | * Local device supports bidirectional video calling. |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 198 | */ |
Andrew Lee | 9a8f9ce | 2015-04-10 18:09:46 -0700 | [diff] [blame] | 199 | public static final int CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL = |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 200 | CAPABILITY_SUPPORTS_VT_LOCAL_RX | CAPABILITY_SUPPORTS_VT_LOCAL_TX; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 201 | |
| 202 | /** |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 203 | * Remote device supports receiving video. |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 204 | */ |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 205 | public static final int CAPABILITY_SUPPORTS_VT_REMOTE_RX = 0x00000400; |
| 206 | |
| 207 | /** |
| 208 | * Remote device supports transmitting video. |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 209 | */ |
| 210 | public static final int CAPABILITY_SUPPORTS_VT_REMOTE_TX = 0x00000800; |
| 211 | |
| 212 | /** |
| 213 | * Remote device supports bidirectional video calling. |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 214 | */ |
Andrew Lee | 9a8f9ce | 2015-04-10 18:09:46 -0700 | [diff] [blame] | 215 | public static final int CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL = |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 216 | CAPABILITY_SUPPORTS_VT_REMOTE_RX | CAPABILITY_SUPPORTS_VT_REMOTE_TX; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 217 | |
| 218 | /** |
| 219 | * Connection is able to be separated from its parent {@code Conference}, if any. |
| 220 | */ |
| 221 | public static final int CAPABILITY_SEPARATE_FROM_CONFERENCE = 0x00001000; |
| 222 | |
| 223 | /** |
| 224 | * Connection is able to be individually disconnected when in a {@code Conference}. |
| 225 | */ |
| 226 | public static final int CAPABILITY_DISCONNECT_FROM_CONFERENCE = 0x00002000; |
| 227 | |
| 228 | /** |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 229 | * Un-used. |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 230 | * @hide |
| 231 | */ |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 232 | public static final int CAPABILITY_UNUSED_2 = 0x00004000; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 233 | |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 234 | /** |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 235 | * Un-used. |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 236 | * @hide |
| 237 | */ |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 238 | public static final int CAPABILITY_UNUSED_3 = 0x00008000; |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 239 | |
| 240 | /** |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 241 | * Un-used. |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 242 | * @hide |
| 243 | */ |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 244 | public static final int CAPABILITY_UNUSED_4 = 0x00010000; |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 245 | |
Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 246 | /** |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 247 | * Un-used. |
Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 248 | * @hide |
| 249 | */ |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 250 | public static final int CAPABILITY_UNUSED_5 = 0x00020000; |
Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 251 | |
Tyler Gunn | 96d6c40 | 2015-03-18 12:39:23 -0700 | [diff] [blame] | 252 | /** |
Dong Zhou | 89f41eb | 2015-03-15 11:59:49 -0500 | [diff] [blame] | 253 | * Speed up audio setup for MT call. |
| 254 | * @hide |
Tyler Gunn | 96d6c40 | 2015-03-18 12:39:23 -0700 | [diff] [blame] | 255 | */ |
| 256 | public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00040000; |
Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 257 | |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 258 | /** |
Tyler Gunn | b5e0cfb | 2015-04-07 16:10:51 -0700 | [diff] [blame] | 259 | * Call can be upgraded to a video call. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 260 | */ |
| 261 | public static final int CAPABILITY_CAN_UPGRADE_TO_VIDEO = 0x00080000; |
| 262 | |
Tyler Gunn | b5e0cfb | 2015-04-07 16:10:51 -0700 | [diff] [blame] | 263 | /** |
| 264 | * 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] | 265 | * the {@link android.telecom.VideoProfile#STATE_PAUSED} VideoState. |
Tyler Gunn | b5e0cfb | 2015-04-07 16:10:51 -0700 | [diff] [blame] | 266 | */ |
| 267 | public static final int CAPABILITY_CAN_PAUSE_VIDEO = 0x00100000; |
| 268 | |
Tyler Gunn | d409173 | 2015-06-29 09:15:37 -0700 | [diff] [blame] | 269 | /** |
| 270 | * For a conference, indicates the conference will not have child connections. |
| 271 | * <p> |
| 272 | * An example of a conference with child connections is a GSM conference call, where the radio |
| 273 | * retains connections to the individual participants of the conference. Another example is an |
| 274 | * IMS conference call where conference event package functionality is supported; in this case |
| 275 | * the conference server ensures the radio is aware of the participants in the conference, which |
| 276 | * are represented by child connections. |
| 277 | * <p> |
| 278 | * An example of a conference with no child connections is an IMS conference call with no |
| 279 | * conference event package support. Such a conference is represented by the radio as a single |
| 280 | * connection to the IMS conference server. |
| 281 | * <p> |
| 282 | * Indicating whether a conference has children or not is important to help user interfaces |
| 283 | * visually represent a conference. A conference with no children, for example, will have the |
| 284 | * conference connection shown in the list of calls on a Bluetooth device, where if the |
| 285 | * conference has children, only the children will be shown in the list of calls on a Bluetooth |
| 286 | * device. |
| 287 | * @hide |
| 288 | */ |
| 289 | public static final int CAPABILITY_CONFERENCE_HAS_NO_CHILDREN = 0x00200000; |
| 290 | |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 291 | /** |
| 292 | * Indicates that the connection itself wants to handle any sort of reply response, rather than |
| 293 | * relying on SMS. |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 294 | */ |
| 295 | public static final int CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION = 0x00400000; |
| 296 | |
Tyler Gunn | f97a009 | 2016-01-19 15:59:34 -0800 | [diff] [blame] | 297 | /** |
| 298 | * When set, prevents a video call from being downgraded to an audio-only call. |
| 299 | * <p> |
| 300 | * Should be set when the VideoState has the {@link VideoProfile#STATE_TX_ENABLED} or |
| 301 | * {@link VideoProfile#STATE_RX_ENABLED} bits set to indicate that the connection cannot be |
| 302 | * downgraded from a video call back to a VideoState of |
| 303 | * {@link VideoProfile#STATE_AUDIO_ONLY}. |
| 304 | * <p> |
| 305 | * Intuitively, a call which can be downgraded to audio should also have local and remote |
| 306 | * video |
| 307 | * capabilities (see {@link #CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL} and |
| 308 | * {@link #CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL}). |
| 309 | */ |
| 310 | public static final int CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO = 0x00800000; |
| 311 | |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 312 | /** |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 313 | * When set for an external connection, indicates that this {@code Connection} can be pulled |
| 314 | * from a remote device to the current device. |
| 315 | * <p> |
| 316 | * Should only be set on a {@code Connection} where {@link #PROPERTY_IS_EXTERNAL_CALL} |
| 317 | * is set. |
| 318 | */ |
| 319 | public static final int CAPABILITY_CAN_PULL_CALL = 0x01000000; |
| 320 | |
| 321 | //********************************************************************************************** |
| 322 | // Next CAPABILITY value: 0x02000000 |
| 323 | //********************************************************************************************** |
| 324 | |
| 325 | /** |
| 326 | * Indicates that the current device callback number should be shown. |
| 327 | * |
| 328 | * @hide |
| 329 | */ |
Hall Liu | 25c7c4d | 2016-08-30 13:41:02 -0700 | [diff] [blame] | 330 | public static final int PROPERTY_EMERGENCY_CALLBACK_MODE = 1<<0; |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 331 | |
| 332 | /** |
| 333 | * Whether the call is a generic conference, where we do not know the precise state of |
| 334 | * participants in the conference (eg. on CDMA). |
| 335 | * |
| 336 | * @hide |
| 337 | */ |
| 338 | public static final int PROPERTY_GENERIC_CONFERENCE = 1<<1; |
| 339 | |
| 340 | /** |
| 341 | * Connection is using high definition audio. |
| 342 | * @hide |
| 343 | */ |
| 344 | public static final int PROPERTY_HIGH_DEF_AUDIO = 1<<2; |
| 345 | |
| 346 | /** |
| 347 | * Connection is using WIFI. |
| 348 | * @hide |
| 349 | */ |
| 350 | public static final int PROPERTY_WIFI = 1<<3; |
| 351 | |
| 352 | /** |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 353 | * When set, indicates that the {@code Connection} does not actually exist locally for the |
| 354 | * {@link ConnectionService}. |
| 355 | * <p> |
| 356 | * Consider, for example, a scenario where a user has two devices with the same phone number. |
| 357 | * When a user places a call on one devices, the telephony stack can represent that call on the |
| 358 | * other device by adding is to the {@link ConnectionService} with the |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 359 | * {@link #PROPERTY_IS_EXTERNAL_CALL} capability set. |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 360 | * <p> |
| 361 | * An {@link ConnectionService} should not assume that all {@link InCallService}s will handle |
| 362 | * external connections. Only those {@link InCallService}s which have the |
| 363 | * {@link TelecomManager#METADATA_INCLUDE_EXTERNAL_CALLS} metadata set to {@code true} in its |
| 364 | * manifest will see external connections. |
| 365 | */ |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 366 | public static final int PROPERTY_IS_EXTERNAL_CALL = 1<<4; |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 367 | |
Brad Ebinger | 1584707 | 2016-05-18 11:08:36 -0700 | [diff] [blame] | 368 | /** |
| 369 | * Indicates that the connection has CDMA Enhanced Voice Privacy enabled. |
| 370 | */ |
| 371 | public static final int PROPERTY_HAS_CDMA_VOICE_PRIVACY = 1<<5; |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 372 | |
Hall Liu | 9f332c7 | 2016-07-14 15:37:37 -0700 | [diff] [blame] | 373 | /** |
| 374 | * Indicates that the connection represents a downgraded IMS conference. |
| 375 | * @hide |
| 376 | */ |
| 377 | public static final int PROPERTY_IS_DOWNGRADED_CONFERENCE = 1<<6; |
| 378 | |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 379 | /** |
| 380 | * Set by the framework to indicate that the {@link Connection} originated from a self-managed |
| 381 | * {@link ConnectionService}. |
| 382 | * <p> |
| 383 | * See {@link PhoneAccount#CAPABILITY_SELF_MANAGED}. |
| 384 | */ |
| 385 | public static final int PROPERTY_SELF_MANAGED = 1<<7; |
| 386 | |
Tyler Gunn | 96d6c40 | 2015-03-18 12:39:23 -0700 | [diff] [blame] | 387 | //********************************************************************************************** |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 388 | // Next PROPERTY value: 1<<8 |
Tyler Gunn | 96d6c40 | 2015-03-18 12:39:23 -0700 | [diff] [blame] | 389 | //********************************************************************************************** |
Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 390 | |
Tyler Gunn | 335ff2e | 2015-07-30 14:18:33 -0700 | [diff] [blame] | 391 | /** |
| 392 | * Connection extra key used to store the last forwarded number associated with the current |
| 393 | * connection. Used to communicate to the user interface that the connection was forwarded via |
| 394 | * the specified number. |
| 395 | */ |
| 396 | public static final String EXTRA_LAST_FORWARDED_NUMBER = |
| 397 | "android.telecom.extra.LAST_FORWARDED_NUMBER"; |
| 398 | |
| 399 | /** |
| 400 | * Connection extra key used to store a child number associated with the current connection. |
| 401 | * Used to communicate to the user interface that the connection was received via |
| 402 | * a child address (i.e. phone number) associated with the {@link PhoneAccount}'s primary |
| 403 | * address. |
| 404 | */ |
| 405 | public static final String EXTRA_CHILD_ADDRESS = "android.telecom.extra.CHILD_ADDRESS"; |
| 406 | |
| 407 | /** |
| 408 | * Connection extra key used to store the subject for an incoming call. The user interface can |
| 409 | * query this extra and display its contents for incoming calls. Will only be used if the |
| 410 | * {@link PhoneAccount} supports the capability {@link PhoneAccount#CAPABILITY_CALL_SUBJECT}. |
| 411 | */ |
| 412 | public static final String EXTRA_CALL_SUBJECT = "android.telecom.extra.CALL_SUBJECT"; |
| 413 | |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 414 | /** |
Tyler Gunn | 4b6614e | 2016-06-22 10:35:13 -0700 | [diff] [blame] | 415 | * Boolean connection extra key set on a {@link Connection} in |
| 416 | * {@link Connection#STATE_RINGING} state to indicate that answering the call will cause the |
| 417 | * current active foreground call to be dropped. |
| 418 | */ |
| 419 | public static final String EXTRA_ANSWERING_DROPS_FG_CALL = |
| 420 | "android.telecom.extra.ANSWERING_DROPS_FG_CALL"; |
| 421 | |
| 422 | /** |
Hall Liu | 1020866 | 2016-06-15 17:55:00 -0700 | [diff] [blame] | 423 | * Boolean connection extra key on a {@link Connection} which indicates that adding an |
Hall Liu | ee6e86b | 2016-07-06 16:32:43 -0700 | [diff] [blame] | 424 | * additional call is disallowed. |
Hall Liu | 1020866 | 2016-06-15 17:55:00 -0700 | [diff] [blame] | 425 | * @hide |
| 426 | */ |
Hall Liu | ee6e86b | 2016-07-06 16:32:43 -0700 | [diff] [blame] | 427 | public static final String EXTRA_DISABLE_ADD_CALL = |
| 428 | "android.telecom.extra.DISABLE_ADD_CALL"; |
Hall Liu | 1020866 | 2016-06-15 17:55:00 -0700 | [diff] [blame] | 429 | |
| 430 | /** |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 431 | * Connection event used to inform Telecom that it should play the on hold tone. This is used |
| 432 | * to play a tone when the peer puts the current call on hold. Sent to Telecom via |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 433 | * {@link #sendConnectionEvent(String, Bundle)}. |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 434 | * @hide |
| 435 | */ |
| 436 | public static final String EVENT_ON_HOLD_TONE_START = |
| 437 | "android.telecom.event.ON_HOLD_TONE_START"; |
| 438 | |
| 439 | /** |
| 440 | * Connection event used to inform Telecom that it should stop the on hold tone. This is used |
| 441 | * to stop a tone when the peer puts the current call on hold. Sent to Telecom via |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 442 | * {@link #sendConnectionEvent(String, Bundle)}. |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 443 | * @hide |
| 444 | */ |
| 445 | public static final String EVENT_ON_HOLD_TONE_END = |
| 446 | "android.telecom.event.ON_HOLD_TONE_END"; |
| 447 | |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 448 | /** |
| 449 | * Connection event used to inform {@link InCallService}s when pulling of an external call has |
| 450 | * failed. The user interface should inform the user of the error. |
| 451 | * <p> |
| 452 | * Expected to be used by the {@link ConnectionService} when the {@link Call#pullExternalCall()} |
| 453 | * API is called on a {@link Call} with the properties |
| 454 | * {@link Call.Details#PROPERTY_IS_EXTERNAL_CALL} and |
| 455 | * {@link Call.Details#CAPABILITY_CAN_PULL_CALL}, but the {@link ConnectionService} could not |
| 456 | * pull the external call due to an error condition. |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 457 | * <p> |
| 458 | * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is |
| 459 | * expected to be null when this connection event is used. |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 460 | */ |
| 461 | public static final String EVENT_CALL_PULL_FAILED = "android.telecom.event.CALL_PULL_FAILED"; |
| 462 | |
Brad Ebinger | 2c1c1645 | 2016-05-27 15:58:10 -0700 | [diff] [blame] | 463 | /** |
| 464 | * Connection event used to inform {@link InCallService}s when the merging of two calls has |
| 465 | * failed. The User Interface should use this message to inform the user of the error. |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 466 | * <p> |
| 467 | * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is |
| 468 | * expected to be null when this connection event is used. |
Brad Ebinger | 2c1c1645 | 2016-05-27 15:58:10 -0700 | [diff] [blame] | 469 | */ |
| 470 | public static final String EVENT_CALL_MERGE_FAILED = "android.telecom.event.CALL_MERGE_FAILED"; |
| 471 | |
Tyler Gunn | b5ed860 | 2016-08-17 13:48:27 -0700 | [diff] [blame] | 472 | /** |
| 473 | * Connection event used to inform {@link InCallService}s when a call has been put on hold by |
| 474 | * the remote party. |
| 475 | * <p> |
| 476 | * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the |
| 477 | * call is being held locally on the device. When a capable {@link ConnectionService} receives |
| 478 | * signalling to indicate that the remote party has put the call on hold, it can send this |
| 479 | * connection event. |
| 480 | * @hide |
| 481 | */ |
| 482 | public static final String EVENT_CALL_REMOTELY_HELD = |
| 483 | "android.telecom.event.CALL_REMOTELY_HELD"; |
| 484 | |
| 485 | /** |
| 486 | * Connection event used to inform {@link InCallService}s when a call which was remotely held |
| 487 | * (see {@link #EVENT_CALL_REMOTELY_HELD}) has been un-held by the remote party. |
| 488 | * <p> |
| 489 | * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the |
| 490 | * call is being held locally on the device. When a capable {@link ConnectionService} receives |
| 491 | * signalling to indicate that the remote party has taken the call off hold, it can send this |
| 492 | * connection event. |
| 493 | * @hide |
| 494 | */ |
| 495 | public static final String EVENT_CALL_REMOTELY_UNHELD = |
| 496 | "android.telecom.event.CALL_REMOTELY_UNHELD"; |
| 497 | |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 498 | // Flag controlling whether PII is emitted into the logs |
| 499 | private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG); |
| 500 | |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 501 | /** |
| 502 | * Whether the given capabilities support the specified capability. |
| 503 | * |
| 504 | * @param capabilities A capability bit field. |
| 505 | * @param capability The capability to check capabilities for. |
| 506 | * @return Whether the specified capability is supported. |
| 507 | * @hide |
| 508 | */ |
| 509 | public static boolean can(int capabilities, int capability) { |
Tyler Gunn | 014c711 | 2015-12-18 14:33:57 -0800 | [diff] [blame] | 510 | return (capabilities & capability) == capability; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | /** |
| 514 | * Whether the capabilities of this {@code Connection} supports the specified capability. |
| 515 | * |
| 516 | * @param capability The capability to check capabilities for. |
| 517 | * @return Whether the specified capability is supported. |
| 518 | * @hide |
| 519 | */ |
| 520 | public boolean can(int capability) { |
| 521 | return can(mConnectionCapabilities, capability); |
| 522 | } |
| 523 | |
| 524 | /** |
| 525 | * Removes the specified capability from the set of capabilities of this {@code Connection}. |
| 526 | * |
| 527 | * @param capability The capability to remove from the set. |
| 528 | * @hide |
| 529 | */ |
| 530 | public void removeCapability(int capability) { |
| 531 | mConnectionCapabilities &= ~capability; |
| 532 | } |
| 533 | |
| 534 | /** |
| 535 | * Adds the specified capability to the set of capabilities of this {@code Connection}. |
| 536 | * |
| 537 | * @param capability The capability to add to the set. |
| 538 | * @hide |
| 539 | */ |
| 540 | public void addCapability(int capability) { |
| 541 | mConnectionCapabilities |= capability; |
| 542 | } |
| 543 | |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 544 | /** |
| 545 | * Renders a set of capability bits ({@code CAPABILITY_*}) as a human readable string. |
| 546 | * |
| 547 | * @param capabilities A capability bit field. |
| 548 | * @return A human readable string representation. |
| 549 | */ |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 550 | public static String capabilitiesToString(int capabilities) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 551 | return capabilitiesToStringInternal(capabilities, true /* isLong */); |
| 552 | } |
| 553 | |
| 554 | /** |
| 555 | * Renders a set of capability bits ({@code CAPABILITY_*}) as a *short* human readable |
| 556 | * string. |
| 557 | * |
| 558 | * @param capabilities A capability bit field. |
| 559 | * @return A human readable string representation. |
| 560 | * @hide |
| 561 | */ |
| 562 | public static String capabilitiesToStringShort(int capabilities) { |
| 563 | return capabilitiesToStringInternal(capabilities, false /* isLong */); |
| 564 | } |
| 565 | |
| 566 | private static String capabilitiesToStringInternal(int capabilities, boolean isLong) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 567 | StringBuilder builder = new StringBuilder(); |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 568 | builder.append("["); |
| 569 | if (isLong) { |
| 570 | builder.append("Capabilities:"); |
| 571 | } |
| 572 | |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 573 | if (can(capabilities, CAPABILITY_HOLD)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 574 | builder.append(isLong ? " CAPABILITY_HOLD" : " hld"); |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 575 | } |
| 576 | if (can(capabilities, CAPABILITY_SUPPORT_HOLD)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 577 | builder.append(isLong ? " CAPABILITY_SUPPORT_HOLD" : " sup_hld"); |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 578 | } |
| 579 | if (can(capabilities, CAPABILITY_MERGE_CONFERENCE)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 580 | builder.append(isLong ? " CAPABILITY_MERGE_CONFERENCE" : " mrg_cnf"); |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 581 | } |
| 582 | if (can(capabilities, CAPABILITY_SWAP_CONFERENCE)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 583 | builder.append(isLong ? " CAPABILITY_SWAP_CONFERENCE" : " swp_cnf"); |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 584 | } |
| 585 | if (can(capabilities, CAPABILITY_RESPOND_VIA_TEXT)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 586 | builder.append(isLong ? " CAPABILITY_RESPOND_VIA_TEXT" : " txt"); |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 587 | } |
| 588 | if (can(capabilities, CAPABILITY_MUTE)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 589 | builder.append(isLong ? " CAPABILITY_MUTE" : " mut"); |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 590 | } |
| 591 | if (can(capabilities, CAPABILITY_MANAGE_CONFERENCE)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 592 | builder.append(isLong ? " CAPABILITY_MANAGE_CONFERENCE" : " mng_cnf"); |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 593 | } |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 594 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_RX)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 595 | builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_RX" : " VTlrx"); |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 596 | } |
| 597 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_TX)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 598 | builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_TX" : " VTltx"); |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 599 | } |
Andrew Lee | 9a8f9ce | 2015-04-10 18:09:46 -0700 | [diff] [blame] | 600 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 601 | builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL" : " VTlbi"); |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 602 | } |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 603 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_RX)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 604 | builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_RX" : " VTrrx"); |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 605 | } |
| 606 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_TX)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 607 | builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_TX" : " VTrtx"); |
Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 608 | } |
Andrew Lee | 9a8f9ce | 2015-04-10 18:09:46 -0700 | [diff] [blame] | 609 | if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 610 | builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL" : " VTrbi"); |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 611 | } |
Tyler Gunn | f97a009 | 2016-01-19 15:59:34 -0800 | [diff] [blame] | 612 | if (can(capabilities, CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 613 | builder.append(isLong ? " CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO" : " !v2a"); |
Tyler Gunn | f97a009 | 2016-01-19 15:59:34 -0800 | [diff] [blame] | 614 | } |
Dong Zhou | 89f41eb | 2015-03-15 11:59:49 -0500 | [diff] [blame] | 615 | if (can(capabilities, CAPABILITY_SPEED_UP_MT_AUDIO)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 616 | builder.append(isLong ? " CAPABILITY_SPEED_UP_MT_AUDIO" : " spd_aud"); |
Dong Zhou | 89f41eb | 2015-03-15 11:59:49 -0500 | [diff] [blame] | 617 | } |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 618 | if (can(capabilities, CAPABILITY_CAN_UPGRADE_TO_VIDEO)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 619 | builder.append(isLong ? " CAPABILITY_CAN_UPGRADE_TO_VIDEO" : " a2v"); |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 620 | } |
Tyler Gunn | b5e0cfb | 2015-04-07 16:10:51 -0700 | [diff] [blame] | 621 | if (can(capabilities, CAPABILITY_CAN_PAUSE_VIDEO)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 622 | builder.append(isLong ? " CAPABILITY_CAN_PAUSE_VIDEO" : " paus_VT"); |
Tyler Gunn | b5e0cfb | 2015-04-07 16:10:51 -0700 | [diff] [blame] | 623 | } |
Tyler Gunn | d409173 | 2015-06-29 09:15:37 -0700 | [diff] [blame] | 624 | if (can(capabilities, CAPABILITY_CONFERENCE_HAS_NO_CHILDREN)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 625 | builder.append(isLong ? " CAPABILITY_SINGLE_PARTY_CONFERENCE" : " 1p_cnf"); |
Tyler Gunn | d409173 | 2015-06-29 09:15:37 -0700 | [diff] [blame] | 626 | } |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 627 | if (can(capabilities, CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 628 | builder.append(isLong ? " CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION" : " rsp_by_con"); |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 629 | } |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 630 | if (can(capabilities, CAPABILITY_CAN_PULL_CALL)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 631 | builder.append(isLong ? " CAPABILITY_CAN_PULL_CALL" : " pull"); |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 632 | } |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 633 | |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 634 | builder.append("]"); |
| 635 | return builder.toString(); |
| 636 | } |
| 637 | |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 638 | /** |
| 639 | * Renders a set of property bits ({@code PROPERTY_*}) as a human readable string. |
| 640 | * |
| 641 | * @param properties A property bit field. |
| 642 | * @return A human readable string representation. |
| 643 | */ |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 644 | public static String propertiesToString(int properties) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 645 | return propertiesToStringInternal(properties, true /* isLong */); |
| 646 | } |
| 647 | |
| 648 | /** |
| 649 | * Renders a set of property bits ({@code PROPERTY_*}) as a *short* human readable string. |
| 650 | * |
| 651 | * @param properties A property bit field. |
| 652 | * @return A human readable string representation. |
| 653 | * @hide |
| 654 | */ |
| 655 | public static String propertiesToStringShort(int properties) { |
| 656 | return propertiesToStringInternal(properties, false /* isLong */); |
| 657 | } |
| 658 | |
| 659 | private static String propertiesToStringInternal(int properties, boolean isLong) { |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 660 | StringBuilder builder = new StringBuilder(); |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 661 | builder.append("["); |
| 662 | if (isLong) { |
| 663 | builder.append("Properties:"); |
| 664 | } |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 665 | |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 666 | if (can(properties, PROPERTY_SELF_MANAGED)) { |
| 667 | builder.append(isLong ? " PROPERTY_SELF_MANAGED" : " self_mng"); |
| 668 | } |
| 669 | |
Hall Liu | 25c7c4d | 2016-08-30 13:41:02 -0700 | [diff] [blame] | 670 | if (can(properties, PROPERTY_EMERGENCY_CALLBACK_MODE)) { |
| 671 | builder.append(isLong ? " PROPERTY_EMERGENCY_CALLBACK_MODE" : " ecbm"); |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | if (can(properties, PROPERTY_HIGH_DEF_AUDIO)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 675 | builder.append(isLong ? " PROPERTY_HIGH_DEF_AUDIO" : " HD"); |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 676 | } |
| 677 | |
| 678 | if (can(properties, PROPERTY_WIFI)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 679 | builder.append(isLong ? " PROPERTY_WIFI" : " wifi"); |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 680 | } |
| 681 | |
| 682 | if (can(properties, PROPERTY_GENERIC_CONFERENCE)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 683 | builder.append(isLong ? " PROPERTY_GENERIC_CONFERENCE" : " gen_conf"); |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 684 | } |
| 685 | |
| 686 | if (can(properties, PROPERTY_IS_EXTERNAL_CALL)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 687 | builder.append(isLong ? " PROPERTY_IS_EXTERNAL_CALL" : " xtrnl"); |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 688 | } |
| 689 | |
Brad Ebinger | 1584707 | 2016-05-18 11:08:36 -0700 | [diff] [blame] | 690 | if (can(properties, PROPERTY_HAS_CDMA_VOICE_PRIVACY)) { |
Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 691 | builder.append(isLong ? " PROPERTY_HAS_CDMA_VOICE_PRIVACY" : " priv"); |
Brad Ebinger | 1584707 | 2016-05-18 11:08:36 -0700 | [diff] [blame] | 692 | } |
| 693 | |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 694 | builder.append("]"); |
| 695 | return builder.toString(); |
| 696 | } |
| 697 | |
Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 698 | /** @hide */ |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 699 | public abstract static class Listener { |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 700 | public void onStateChanged(Connection c, int state) {} |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 701 | public void onAddressChanged(Connection c, Uri newAddress, int presentation) {} |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 702 | public void onCallerDisplayNameChanged( |
| 703 | Connection c, String callerDisplayName, int presentation) {} |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 704 | public void onVideoStateChanged(Connection c, int videoState) {} |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 705 | public void onDisconnected(Connection c, DisconnectCause disconnectCause) {} |
Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 706 | public void onPostDialWait(Connection c, String remaining) {} |
Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 707 | public void onPostDialChar(Connection c, char nextChar) {} |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 708 | public void onRingbackRequested(Connection c, boolean ringback) {} |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 709 | public void onDestroyed(Connection c) {} |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 710 | public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {} |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 711 | public void onConnectionPropertiesChanged(Connection c, int properties) {} |
Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 712 | public void onSupportedAudioRoutesChanged(Connection c, int supportedAudioRoutes) {} |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 713 | public void onVideoProviderChanged( |
| 714 | Connection c, VideoProvider videoProvider) {} |
Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 715 | public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {} |
| 716 | public void onStatusHintsChanged(Connection c, StatusHints statusHints) {} |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 717 | public void onConferenceablesChanged( |
Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 718 | Connection c, List<Conferenceable> conferenceables) {} |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 719 | public void onConferenceChanged(Connection c, Conference conference) {} |
Tyler Gunn | 3bffcf7 | 2014-10-28 13:51:27 -0700 | [diff] [blame] | 720 | /** @hide */ |
Tyler Gunn | ab4650c | 2014-11-06 20:06:23 -0800 | [diff] [blame] | 721 | public void onConferenceParticipantsChanged(Connection c, |
| 722 | List<ConferenceParticipant> participants) {} |
Tyler Gunn | 8a2b119 | 2015-01-29 11:47:24 -0800 | [diff] [blame] | 723 | public void onConferenceStarted() {} |
Anthony Lee | 17455a3 | 2015-04-24 15:25:29 -0700 | [diff] [blame] | 724 | public void onConferenceMergeFailed(Connection c) {} |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 725 | public void onExtrasChanged(Connection c, Bundle extras) {} |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 726 | public void onExtrasRemoved(Connection c, List<String> keys) {} |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 727 | public void onConnectionEvent(Connection c, String event, Bundle extras) {} |
Tyler Gunn | 7d633d3 | 2016-06-24 07:30:10 -0700 | [diff] [blame] | 728 | /** @hide */ |
| 729 | public void onConferenceSupportedChanged(Connection c, boolean isConferenceSupported) {} |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 730 | public void onAudioRouteChanged(Connection c, int audioRoute) {} |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 731 | } |
| 732 | |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 733 | /** |
| 734 | * Provides a means of controlling the video session associated with a {@link Connection}. |
| 735 | * <p> |
| 736 | * Implementations create a custom subclass of {@link VideoProvider} and the |
| 737 | * {@link ConnectionService} creates an instance sets it on the {@link Connection} using |
| 738 | * {@link Connection#setVideoProvider(VideoProvider)}. Any connection which supports video |
| 739 | * should set the {@link VideoProvider}. |
| 740 | * <p> |
| 741 | * The {@link VideoProvider} serves two primary purposes: it provides a means for Telecom and |
| 742 | * {@link InCallService} implementations to issue requests related to the video session; |
| 743 | * it provides a means for the {@link ConnectionService} to report events and information |
| 744 | * related to the video session to Telecom and the {@link InCallService} implementations. |
| 745 | * <p> |
| 746 | * {@link InCallService} implementations interact with the {@link VideoProvider} via |
| 747 | * {@link android.telecom.InCallService.VideoCall}. |
| 748 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 749 | public static abstract class VideoProvider { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 750 | /** |
| 751 | * Video is not being received (no protocol pause was issued). |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 752 | * @see #handleCallSessionEvent(int) |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 753 | */ |
| 754 | public static final int SESSION_EVENT_RX_PAUSE = 1; |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 755 | |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 756 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 757 | * Video reception has resumed after a {@link #SESSION_EVENT_RX_PAUSE}. |
| 758 | * @see #handleCallSessionEvent(int) |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 759 | */ |
| 760 | public static final int SESSION_EVENT_RX_RESUME = 2; |
| 761 | |
| 762 | /** |
| 763 | * Video transmission has begun. This occurs after a negotiated start of video transmission |
| 764 | * 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] | 765 | * @see #handleCallSessionEvent(int) |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 766 | */ |
| 767 | public static final int SESSION_EVENT_TX_START = 3; |
| 768 | |
| 769 | /** |
| 770 | * Video transmission has stopped. This occurs after a negotiated stop of video transmission |
| 771 | * 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] | 772 | * @see #handleCallSessionEvent(int) |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 773 | */ |
| 774 | public static final int SESSION_EVENT_TX_STOP = 4; |
| 775 | |
| 776 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 777 | * A camera failure has occurred for the selected camera. The {@link InCallService} can use |
| 778 | * this as a cue to inform the user the camera is not available. |
| 779 | * @see #handleCallSessionEvent(int) |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 780 | */ |
| 781 | public static final int SESSION_EVENT_CAMERA_FAILURE = 5; |
| 782 | |
| 783 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 784 | * Issued after {@link #SESSION_EVENT_CAMERA_FAILURE} when the camera is once again ready |
| 785 | * for operation. The {@link InCallService} can use this as a cue to inform the user that |
| 786 | * the camera has become available again. |
| 787 | * @see #handleCallSessionEvent(int) |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 788 | */ |
| 789 | public static final int SESSION_EVENT_CAMERA_READY = 6; |
| 790 | |
| 791 | /** |
| 792 | * Session modify request was successful. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 793 | * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile) |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 794 | */ |
| 795 | public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1; |
| 796 | |
| 797 | /** |
| 798 | * Session modify request failed. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 799 | * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile) |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 800 | */ |
| 801 | public static final int SESSION_MODIFY_REQUEST_FAIL = 2; |
| 802 | |
| 803 | /** |
| 804 | * Session modify request ignored due to invalid parameters. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 805 | * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile) |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 806 | */ |
| 807 | public static final int SESSION_MODIFY_REQUEST_INVALID = 3; |
| 808 | |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 809 | /** |
| 810 | * Session modify request timed out. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 811 | * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile) |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 812 | */ |
| 813 | public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4; |
| 814 | |
| 815 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 816 | * Session modify request rejected by remote user. |
| 817 | * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile) |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 818 | */ |
| 819 | public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5; |
| 820 | |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 821 | private static final int MSG_ADD_VIDEO_CALLBACK = 1; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 822 | private static final int MSG_SET_CAMERA = 2; |
| 823 | private static final int MSG_SET_PREVIEW_SURFACE = 3; |
| 824 | private static final int MSG_SET_DISPLAY_SURFACE = 4; |
| 825 | private static final int MSG_SET_DEVICE_ORIENTATION = 5; |
| 826 | private static final int MSG_SET_ZOOM = 6; |
| 827 | private static final int MSG_SEND_SESSION_MODIFY_REQUEST = 7; |
| 828 | private static final int MSG_SEND_SESSION_MODIFY_RESPONSE = 8; |
| 829 | private static final int MSG_REQUEST_CAMERA_CAPABILITIES = 9; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 830 | private static final int MSG_REQUEST_CONNECTION_DATA_USAGE = 10; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 831 | private static final int MSG_SET_PAUSE_IMAGE = 11; |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 832 | private static final int MSG_REMOVE_VIDEO_CALLBACK = 12; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 833 | |
Tyler Gunn | 6f657ee | 2016-09-02 09:55:25 -0700 | [diff] [blame] | 834 | private static final String SESSION_EVENT_RX_PAUSE_STR = "RX_PAUSE"; |
| 835 | private static final String SESSION_EVENT_RX_RESUME_STR = "RX_RESUME"; |
| 836 | private static final String SESSION_EVENT_TX_START_STR = "TX_START"; |
| 837 | private static final String SESSION_EVENT_TX_STOP_STR = "TX_STOP"; |
| 838 | private static final String SESSION_EVENT_CAMERA_FAILURE_STR = "CAMERA_FAIL"; |
| 839 | private static final String SESSION_EVENT_CAMERA_READY_STR = "CAMERA_READY"; |
| 840 | private static final String SESSION_EVENT_UNKNOWN_STR = "UNKNOWN"; |
| 841 | |
Tyler Gunn | 4e9bbaf | 2015-05-22 15:43:28 -0700 | [diff] [blame] | 842 | private VideoProvider.VideoProviderHandler mMessageHandler; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 843 | private final VideoProvider.VideoProviderBinder mBinder; |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 844 | |
| 845 | /** |
| 846 | * Stores a list of the video callbacks, keyed by IBinder. |
Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 847 | * |
| 848 | * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is |
| 849 | * load factor before resizing, 1 means we only expect a single thread to |
| 850 | * access the map so make only a single shard |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 851 | */ |
Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 852 | private ConcurrentHashMap<IBinder, IVideoCallback> mVideoCallbacks = |
| 853 | new ConcurrentHashMap<IBinder, IVideoCallback>(8, 0.9f, 1); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 854 | |
| 855 | /** |
| 856 | * Default handler used to consolidate binder method calls onto a single thread. |
| 857 | */ |
| 858 | private final class VideoProviderHandler extends Handler { |
Tyler Gunn | 4e9bbaf | 2015-05-22 15:43:28 -0700 | [diff] [blame] | 859 | public VideoProviderHandler() { |
| 860 | super(); |
| 861 | } |
| 862 | |
| 863 | public VideoProviderHandler(Looper looper) { |
| 864 | super(looper); |
| 865 | } |
| 866 | |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 867 | @Override |
| 868 | public void handleMessage(Message msg) { |
| 869 | switch (msg.what) { |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 870 | case MSG_ADD_VIDEO_CALLBACK: { |
| 871 | IBinder binder = (IBinder) msg.obj; |
| 872 | IVideoCallback callback = IVideoCallback.Stub |
| 873 | .asInterface((IBinder) msg.obj); |
Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 874 | if (callback == null) { |
| 875 | Log.w(this, "addVideoProvider - skipped; callback is null."); |
| 876 | break; |
| 877 | } |
| 878 | |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 879 | if (mVideoCallbacks.containsKey(binder)) { |
| 880 | Log.i(this, "addVideoProvider - skipped; already present."); |
| 881 | break; |
| 882 | } |
| 883 | mVideoCallbacks.put(binder, callback); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 884 | break; |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 885 | } |
| 886 | case MSG_REMOVE_VIDEO_CALLBACK: { |
| 887 | IBinder binder = (IBinder) msg.obj; |
| 888 | IVideoCallback callback = IVideoCallback.Stub |
| 889 | .asInterface((IBinder) msg.obj); |
| 890 | if (!mVideoCallbacks.containsKey(binder)) { |
| 891 | Log.i(this, "removeVideoProvider - skipped; not present."); |
| 892 | break; |
| 893 | } |
| 894 | mVideoCallbacks.remove(binder); |
| 895 | break; |
| 896 | } |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 897 | case MSG_SET_CAMERA: |
| 898 | onSetCamera((String) msg.obj); |
| 899 | break; |
| 900 | case MSG_SET_PREVIEW_SURFACE: |
| 901 | onSetPreviewSurface((Surface) msg.obj); |
| 902 | break; |
| 903 | case MSG_SET_DISPLAY_SURFACE: |
| 904 | onSetDisplaySurface((Surface) msg.obj); |
| 905 | break; |
| 906 | case MSG_SET_DEVICE_ORIENTATION: |
| 907 | onSetDeviceOrientation(msg.arg1); |
| 908 | break; |
| 909 | case MSG_SET_ZOOM: |
| 910 | onSetZoom((Float) msg.obj); |
| 911 | break; |
Tyler Gunn | 4538216 | 2015-05-06 08:52:27 -0700 | [diff] [blame] | 912 | case MSG_SEND_SESSION_MODIFY_REQUEST: { |
| 913 | SomeArgs args = (SomeArgs) msg.obj; |
| 914 | try { |
| 915 | onSendSessionModifyRequest((VideoProfile) args.arg1, |
| 916 | (VideoProfile) args.arg2); |
| 917 | } finally { |
| 918 | args.recycle(); |
| 919 | } |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 920 | break; |
Tyler Gunn | 4538216 | 2015-05-06 08:52:27 -0700 | [diff] [blame] | 921 | } |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 922 | case MSG_SEND_SESSION_MODIFY_RESPONSE: |
| 923 | onSendSessionModifyResponse((VideoProfile) msg.obj); |
| 924 | break; |
| 925 | case MSG_REQUEST_CAMERA_CAPABILITIES: |
| 926 | onRequestCameraCapabilities(); |
| 927 | break; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 928 | case MSG_REQUEST_CONNECTION_DATA_USAGE: |
| 929 | onRequestConnectionDataUsage(); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 930 | break; |
| 931 | case MSG_SET_PAUSE_IMAGE: |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 932 | onSetPauseImage((Uri) msg.obj); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 933 | break; |
| 934 | default: |
| 935 | break; |
| 936 | } |
| 937 | } |
| 938 | } |
| 939 | |
| 940 | /** |
| 941 | * IVideoProvider stub implementation. |
| 942 | */ |
| 943 | private final class VideoProviderBinder extends IVideoProvider.Stub { |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 944 | public void addVideoCallback(IBinder videoCallbackBinder) { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 945 | mMessageHandler.obtainMessage( |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 946 | MSG_ADD_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget(); |
| 947 | } |
| 948 | |
| 949 | public void removeVideoCallback(IBinder videoCallbackBinder) { |
| 950 | mMessageHandler.obtainMessage( |
| 951 | MSG_REMOVE_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget(); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 952 | } |
| 953 | |
| 954 | public void setCamera(String cameraId) { |
| 955 | mMessageHandler.obtainMessage(MSG_SET_CAMERA, cameraId).sendToTarget(); |
| 956 | } |
| 957 | |
| 958 | public void setPreviewSurface(Surface surface) { |
| 959 | mMessageHandler.obtainMessage(MSG_SET_PREVIEW_SURFACE, surface).sendToTarget(); |
| 960 | } |
| 961 | |
| 962 | public void setDisplaySurface(Surface surface) { |
| 963 | mMessageHandler.obtainMessage(MSG_SET_DISPLAY_SURFACE, surface).sendToTarget(); |
| 964 | } |
| 965 | |
| 966 | public void setDeviceOrientation(int rotation) { |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 967 | mMessageHandler.obtainMessage( |
| 968 | MSG_SET_DEVICE_ORIENTATION, rotation, 0).sendToTarget(); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 969 | } |
| 970 | |
| 971 | public void setZoom(float value) { |
| 972 | mMessageHandler.obtainMessage(MSG_SET_ZOOM, value).sendToTarget(); |
| 973 | } |
| 974 | |
Tyler Gunn | 4538216 | 2015-05-06 08:52:27 -0700 | [diff] [blame] | 975 | public void sendSessionModifyRequest(VideoProfile fromProfile, VideoProfile toProfile) { |
| 976 | SomeArgs args = SomeArgs.obtain(); |
| 977 | args.arg1 = fromProfile; |
| 978 | args.arg2 = toProfile; |
| 979 | mMessageHandler.obtainMessage(MSG_SEND_SESSION_MODIFY_REQUEST, args).sendToTarget(); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 980 | } |
| 981 | |
| 982 | public void sendSessionModifyResponse(VideoProfile responseProfile) { |
| 983 | mMessageHandler.obtainMessage( |
| 984 | MSG_SEND_SESSION_MODIFY_RESPONSE, responseProfile).sendToTarget(); |
| 985 | } |
| 986 | |
| 987 | public void requestCameraCapabilities() { |
| 988 | mMessageHandler.obtainMessage(MSG_REQUEST_CAMERA_CAPABILITIES).sendToTarget(); |
| 989 | } |
| 990 | |
| 991 | public void requestCallDataUsage() { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 992 | mMessageHandler.obtainMessage(MSG_REQUEST_CONNECTION_DATA_USAGE).sendToTarget(); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 993 | } |
| 994 | |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 995 | public void setPauseImage(Uri uri) { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 996 | mMessageHandler.obtainMessage(MSG_SET_PAUSE_IMAGE, uri).sendToTarget(); |
| 997 | } |
| 998 | } |
| 999 | |
| 1000 | public VideoProvider() { |
| 1001 | mBinder = new VideoProvider.VideoProviderBinder(); |
Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1002 | mMessageHandler = new VideoProvider.VideoProviderHandler(Looper.getMainLooper()); |
Tyler Gunn | 4e9bbaf | 2015-05-22 15:43:28 -0700 | [diff] [blame] | 1003 | } |
| 1004 | |
| 1005 | /** |
| 1006 | * Creates an instance of the {@link VideoProvider}, specifying the looper to use. |
| 1007 | * |
| 1008 | * @param looper The looper. |
| 1009 | * @hide |
| 1010 | */ |
| 1011 | public VideoProvider(Looper looper) { |
| 1012 | mBinder = new VideoProvider.VideoProviderBinder(); |
| 1013 | mMessageHandler = new VideoProvider.VideoProviderHandler(looper); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1014 | } |
| 1015 | |
| 1016 | /** |
| 1017 | * Returns binder object which can be used across IPC methods. |
| 1018 | * @hide |
| 1019 | */ |
| 1020 | public final IVideoProvider getInterface() { |
| 1021 | return mBinder; |
| 1022 | } |
| 1023 | |
| 1024 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1025 | * Sets the camera to be used for the outgoing video. |
| 1026 | * <p> |
| 1027 | * The {@link VideoProvider} should respond by communicating the capabilities of the chosen |
| 1028 | * camera via |
| 1029 | * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}. |
| 1030 | * <p> |
| 1031 | * Sent from the {@link InCallService} via |
| 1032 | * {@link InCallService.VideoCall#setCamera(String)}. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1033 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1034 | * @param cameraId The id of the camera (use ids as reported by |
| 1035 | * {@link CameraManager#getCameraIdList()}). |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1036 | */ |
| 1037 | public abstract void onSetCamera(String cameraId); |
| 1038 | |
| 1039 | /** |
| 1040 | * Sets the surface to be used for displaying a preview of what the user's camera is |
| 1041 | * currently capturing. When video transmission is enabled, this is the video signal which |
| 1042 | * is sent to the remote device. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1043 | * <p> |
| 1044 | * Sent from the {@link InCallService} via |
| 1045 | * {@link InCallService.VideoCall#setPreviewSurface(Surface)}. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1046 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1047 | * @param surface The {@link Surface}. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1048 | */ |
| 1049 | public abstract void onSetPreviewSurface(Surface surface); |
| 1050 | |
| 1051 | /** |
| 1052 | * 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] | 1053 | * <p> |
| 1054 | * Sent from the {@link InCallService} via |
| 1055 | * {@link InCallService.VideoCall#setDisplaySurface(Surface)}. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1056 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1057 | * @param surface The {@link Surface}. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1058 | */ |
| 1059 | public abstract void onSetDisplaySurface(Surface surface); |
| 1060 | |
| 1061 | /** |
| 1062 | * Sets the device orientation, in degrees. Assumes that a standard portrait orientation of |
| 1063 | * the device is 0 degrees. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1064 | * <p> |
| 1065 | * Sent from the {@link InCallService} via |
| 1066 | * {@link InCallService.VideoCall#setDeviceOrientation(int)}. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1067 | * |
| 1068 | * @param rotation The device orientation, in degrees. |
| 1069 | */ |
| 1070 | public abstract void onSetDeviceOrientation(int rotation); |
| 1071 | |
| 1072 | /** |
| 1073 | * Sets camera zoom ratio. |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1074 | * <p> |
| 1075 | * Sent from the {@link InCallService} via {@link InCallService.VideoCall#setZoom(float)}. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1076 | * |
| 1077 | * @param value The camera zoom ratio. |
| 1078 | */ |
| 1079 | public abstract void onSetZoom(float value); |
| 1080 | |
| 1081 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1082 | * Issues a request to modify the properties of the current video session. |
| 1083 | * <p> |
| 1084 | * Example scenarios include: requesting an audio-only call to be upgraded to a |
| 1085 | * bi-directional video call, turning on or off the user's camera, sending a pause signal |
| 1086 | * when the {@link InCallService} is no longer the foreground application. |
| 1087 | * <p> |
| 1088 | * If the {@link VideoProvider} determines a request to be invalid, it should call |
| 1089 | * {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)} to report the |
| 1090 | * invalid request back to the {@link InCallService}. |
| 1091 | * <p> |
| 1092 | * Where a request requires confirmation from the user of the peer device, the |
| 1093 | * {@link VideoProvider} must communicate the request to the peer device and handle the |
| 1094 | * user's response. {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)} |
| 1095 | * is used to inform the {@link InCallService} of the result of the request. |
| 1096 | * <p> |
| 1097 | * Sent from the {@link InCallService} via |
| 1098 | * {@link InCallService.VideoCall#sendSessionModifyRequest(VideoProfile)}. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1099 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1100 | * @param fromProfile The video profile prior to the request. |
| 1101 | * @param toProfile The video profile with the requested changes made. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1102 | */ |
Tyler Gunn | 4538216 | 2015-05-06 08:52:27 -0700 | [diff] [blame] | 1103 | public abstract void onSendSessionModifyRequest(VideoProfile fromProfile, |
| 1104 | VideoProfile toProfile); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1105 | |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1106 | /** |
| 1107 | * Provides a response to a request to change the current video session properties. |
| 1108 | * <p> |
| 1109 | * For example, if the peer requests and upgrade from an audio-only call to a bi-directional |
| 1110 | * video call, could decline the request and keep the call as audio-only. |
| 1111 | * In such a scenario, the {@code responseProfile} would have a video state of |
| 1112 | * {@link VideoProfile#STATE_AUDIO_ONLY}. If the user had decided to accept the request, |
| 1113 | * the video state would be {@link VideoProfile#STATE_BIDIRECTIONAL}. |
| 1114 | * <p> |
| 1115 | * Sent from the {@link InCallService} via |
| 1116 | * {@link InCallService.VideoCall#sendSessionModifyResponse(VideoProfile)} in response to |
| 1117 | * a {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)} |
| 1118 | * callback. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1119 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1120 | * @param responseProfile The response video profile. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1121 | */ |
| 1122 | public abstract void onSendSessionModifyResponse(VideoProfile responseProfile); |
| 1123 | |
| 1124 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1125 | * Issues a request to the {@link VideoProvider} to retrieve the camera capabilities. |
| 1126 | * <p> |
| 1127 | * The {@link VideoProvider} should respond by communicating the capabilities of the chosen |
| 1128 | * camera via |
| 1129 | * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}. |
| 1130 | * <p> |
| 1131 | * Sent from the {@link InCallService} via |
| 1132 | * {@link InCallService.VideoCall#requestCameraCapabilities()}. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1133 | */ |
| 1134 | public abstract void onRequestCameraCapabilities(); |
| 1135 | |
| 1136 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1137 | * Issues a request to the {@link VideoProvider} to retrieve the current data usage for the |
| 1138 | * video component of the current {@link Connection}. |
| 1139 | * <p> |
| 1140 | * The {@link VideoProvider} should respond by communicating current data usage, in bytes, |
| 1141 | * via {@link VideoProvider#setCallDataUsage(long)}. |
| 1142 | * <p> |
| 1143 | * Sent from the {@link InCallService} via |
| 1144 | * {@link InCallService.VideoCall#requestCallDataUsage()}. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1145 | */ |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1146 | public abstract void onRequestConnectionDataUsage(); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1147 | |
| 1148 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1149 | * Provides the {@link VideoProvider} with the {@link Uri} of an image to be displayed to |
| 1150 | * the peer device when the video signal is paused. |
| 1151 | * <p> |
| 1152 | * Sent from the {@link InCallService} via |
| 1153 | * {@link InCallService.VideoCall#setPauseImage(Uri)}. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1154 | * |
| 1155 | * @param uri URI of image to display. |
| 1156 | */ |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 1157 | public abstract void onSetPauseImage(Uri uri); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1158 | |
| 1159 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1160 | * Used to inform listening {@link InCallService} implementations when the |
| 1161 | * {@link VideoProvider} receives a session modification request. |
| 1162 | * <p> |
| 1163 | * Received by the {@link InCallService} via |
| 1164 | * {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)}, |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1165 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1166 | * @param videoProfile The requested video profile. |
| 1167 | * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile) |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1168 | */ |
| 1169 | public void receiveSessionModifyRequest(VideoProfile videoProfile) { |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1170 | if (mVideoCallbacks != null) { |
Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1171 | for (IVideoCallback callback : mVideoCallbacks.values()) { |
| 1172 | try { |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1173 | callback.receiveSessionModifyRequest(videoProfile); |
Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1174 | } catch (RemoteException ignored) { |
| 1175 | Log.w(this, "receiveSessionModifyRequest callback failed", ignored); |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1176 | } |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1177 | } |
| 1178 | } |
| 1179 | } |
| 1180 | |
| 1181 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1182 | * Used to inform listening {@link InCallService} implementations when the |
| 1183 | * {@link VideoProvider} receives a response to a session modification request. |
| 1184 | * <p> |
| 1185 | * Received by the {@link InCallService} via |
| 1186 | * {@link InCallService.VideoCall.Callback#onSessionModifyResponseReceived(int, |
| 1187 | * VideoProfile, VideoProfile)}. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1188 | * |
| 1189 | * @param status Status of the session modify request. Valid values are |
| 1190 | * {@link VideoProvider#SESSION_MODIFY_REQUEST_SUCCESS}, |
| 1191 | * {@link VideoProvider#SESSION_MODIFY_REQUEST_FAIL}, |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1192 | * {@link VideoProvider#SESSION_MODIFY_REQUEST_INVALID}, |
| 1193 | * {@link VideoProvider#SESSION_MODIFY_REQUEST_TIMED_OUT}, |
| 1194 | * {@link VideoProvider#SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE} |
| 1195 | * @param requestedProfile The original request which was sent to the peer device. |
| 1196 | * @param responseProfile The actual profile changes agreed to by the peer device. |
| 1197 | * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile) |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1198 | */ |
| 1199 | public void receiveSessionModifyResponse(int status, |
| 1200 | VideoProfile requestedProfile, VideoProfile responseProfile) { |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1201 | if (mVideoCallbacks != null) { |
Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1202 | for (IVideoCallback callback : mVideoCallbacks.values()) { |
| 1203 | try { |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1204 | callback.receiveSessionModifyResponse(status, requestedProfile, |
| 1205 | responseProfile); |
Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1206 | } catch (RemoteException ignored) { |
| 1207 | Log.w(this, "receiveSessionModifyResponse callback failed", ignored); |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1208 | } |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1209 | } |
| 1210 | } |
| 1211 | } |
| 1212 | |
| 1213 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1214 | * Used to inform listening {@link InCallService} implementations when the |
| 1215 | * {@link VideoProvider} reports a call session event. |
| 1216 | * <p> |
| 1217 | * Received by the {@link InCallService} via |
| 1218 | * {@link InCallService.VideoCall.Callback#onCallSessionEvent(int)}. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1219 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1220 | * @param event The event. Valid values are: {@link VideoProvider#SESSION_EVENT_RX_PAUSE}, |
| 1221 | * {@link VideoProvider#SESSION_EVENT_RX_RESUME}, |
| 1222 | * {@link VideoProvider#SESSION_EVENT_TX_START}, |
| 1223 | * {@link VideoProvider#SESSION_EVENT_TX_STOP}, |
| 1224 | * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE}, |
| 1225 | * {@link VideoProvider#SESSION_EVENT_CAMERA_READY}. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1226 | */ |
| 1227 | public void handleCallSessionEvent(int event) { |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1228 | if (mVideoCallbacks != null) { |
Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1229 | for (IVideoCallback callback : mVideoCallbacks.values()) { |
| 1230 | try { |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1231 | callback.handleCallSessionEvent(event); |
Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1232 | } catch (RemoteException ignored) { |
| 1233 | Log.w(this, "handleCallSessionEvent callback failed", ignored); |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1234 | } |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1235 | } |
| 1236 | } |
| 1237 | } |
| 1238 | |
| 1239 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1240 | * Used to inform listening {@link InCallService} implementations when the dimensions of the |
| 1241 | * peer's video have changed. |
| 1242 | * <p> |
| 1243 | * This could occur if, for example, the peer rotates their device, changing the aspect |
| 1244 | * ratio of the video, or if the user switches between the back and front cameras. |
| 1245 | * <p> |
| 1246 | * Received by the {@link InCallService} via |
| 1247 | * {@link InCallService.VideoCall.Callback#onPeerDimensionsChanged(int, int)}. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1248 | * |
| 1249 | * @param width The updated peer video width. |
| 1250 | * @param height The updated peer video height. |
| 1251 | */ |
| 1252 | public void changePeerDimensions(int width, int height) { |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1253 | if (mVideoCallbacks != null) { |
Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1254 | for (IVideoCallback callback : mVideoCallbacks.values()) { |
| 1255 | try { |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1256 | callback.changePeerDimensions(width, height); |
Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1257 | } catch (RemoteException ignored) { |
| 1258 | Log.w(this, "changePeerDimensions callback failed", ignored); |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1259 | } |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1260 | } |
| 1261 | } |
| 1262 | } |
| 1263 | |
| 1264 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1265 | * Used to inform listening {@link InCallService} implementations when the data usage of the |
| 1266 | * video associated with the current {@link Connection} has changed. |
| 1267 | * <p> |
| 1268 | * This could be in response to a preview request via |
| 1269 | * {@link #onRequestConnectionDataUsage()}, or as a periodic update by the |
Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 1270 | * {@link VideoProvider}. Where periodic updates of data usage are provided, they should be |
| 1271 | * 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] | 1272 | * <p> |
| 1273 | * Received by the {@link InCallService} via |
| 1274 | * {@link InCallService.VideoCall.Callback#onCallDataUsageChanged(long)}. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1275 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1276 | * @param dataUsage The updated data usage (in bytes). Reported as the cumulative bytes |
| 1277 | * used since the start of the call. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1278 | */ |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 1279 | public void setCallDataUsage(long dataUsage) { |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1280 | if (mVideoCallbacks != null) { |
Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1281 | for (IVideoCallback callback : mVideoCallbacks.values()) { |
| 1282 | try { |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1283 | callback.changeCallDataUsage(dataUsage); |
Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1284 | } catch (RemoteException ignored) { |
| 1285 | Log.w(this, "setCallDataUsage callback failed", ignored); |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1286 | } |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1287 | } |
| 1288 | } |
| 1289 | } |
| 1290 | |
| 1291 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1292 | * @see #setCallDataUsage(long) |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1293 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1294 | * @param dataUsage The updated data usage (in byes). |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 1295 | * @deprecated - Use {@link #setCallDataUsage(long)} instead. |
| 1296 | * @hide |
| 1297 | */ |
| 1298 | public void changeCallDataUsage(long dataUsage) { |
| 1299 | setCallDataUsage(dataUsage); |
| 1300 | } |
| 1301 | |
| 1302 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1303 | * Used to inform listening {@link InCallService} implementations when the capabilities of |
| 1304 | * the current camera have changed. |
| 1305 | * <p> |
| 1306 | * The {@link VideoProvider} should call this in response to |
| 1307 | * {@link VideoProvider#onRequestCameraCapabilities()}, or when the current camera is |
| 1308 | * changed via {@link VideoProvider#onSetCamera(String)}. |
| 1309 | * <p> |
| 1310 | * Received by the {@link InCallService} via |
| 1311 | * {@link InCallService.VideoCall.Callback#onCameraCapabilitiesChanged( |
| 1312 | * VideoProfile.CameraCapabilities)}. |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 1313 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1314 | * @param cameraCapabilities The new camera capabilities. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1315 | */ |
Yorke Lee | 400470f | 2015-05-12 13:31:25 -0700 | [diff] [blame] | 1316 | public void changeCameraCapabilities(VideoProfile.CameraCapabilities cameraCapabilities) { |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1317 | if (mVideoCallbacks != null) { |
Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1318 | for (IVideoCallback callback : mVideoCallbacks.values()) { |
| 1319 | try { |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1320 | callback.changeCameraCapabilities(cameraCapabilities); |
Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1321 | } catch (RemoteException ignored) { |
| 1322 | Log.w(this, "changeCameraCapabilities callback failed", ignored); |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1323 | } |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1324 | } |
| 1325 | } |
| 1326 | } |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1327 | |
| 1328 | /** |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1329 | * Used to inform listening {@link InCallService} implementations when the video quality |
| 1330 | * of the call has changed. |
| 1331 | * <p> |
| 1332 | * Received by the {@link InCallService} via |
| 1333 | * {@link InCallService.VideoCall.Callback#onVideoQualityChanged(int)}. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1334 | * |
Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1335 | * @param videoQuality The updated video quality. Valid values: |
| 1336 | * {@link VideoProfile#QUALITY_HIGH}, |
| 1337 | * {@link VideoProfile#QUALITY_MEDIUM}, |
| 1338 | * {@link VideoProfile#QUALITY_LOW}, |
| 1339 | * {@link VideoProfile#QUALITY_DEFAULT}. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1340 | */ |
| 1341 | public void changeVideoQuality(int videoQuality) { |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1342 | if (mVideoCallbacks != null) { |
Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1343 | for (IVideoCallback callback : mVideoCallbacks.values()) { |
| 1344 | try { |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1345 | callback.changeVideoQuality(videoQuality); |
Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1346 | } catch (RemoteException ignored) { |
| 1347 | Log.w(this, "changeVideoQuality callback failed", ignored); |
Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1348 | } |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1349 | } |
| 1350 | } |
| 1351 | } |
Tyler Gunn | 6f657ee | 2016-09-02 09:55:25 -0700 | [diff] [blame] | 1352 | |
| 1353 | /** |
| 1354 | * Returns a string representation of a call session event. |
| 1355 | * |
| 1356 | * @param event A call session event passed to {@link #handleCallSessionEvent(int)}. |
| 1357 | * @return String representation of the call session event. |
| 1358 | * @hide |
| 1359 | */ |
| 1360 | public static String sessionEventToString(int event) { |
| 1361 | switch (event) { |
| 1362 | case SESSION_EVENT_CAMERA_FAILURE: |
| 1363 | return SESSION_EVENT_CAMERA_FAILURE_STR; |
| 1364 | case SESSION_EVENT_CAMERA_READY: |
| 1365 | return SESSION_EVENT_CAMERA_READY_STR; |
| 1366 | case SESSION_EVENT_RX_PAUSE: |
| 1367 | return SESSION_EVENT_RX_PAUSE_STR; |
| 1368 | case SESSION_EVENT_RX_RESUME: |
| 1369 | return SESSION_EVENT_RX_RESUME_STR; |
| 1370 | case SESSION_EVENT_TX_START: |
| 1371 | return SESSION_EVENT_TX_START_STR; |
| 1372 | case SESSION_EVENT_TX_STOP: |
| 1373 | return SESSION_EVENT_TX_STOP_STR; |
| 1374 | default: |
| 1375 | return SESSION_EVENT_UNKNOWN_STR + " " + event; |
| 1376 | } |
| 1377 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1378 | } |
| 1379 | |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1380 | private final Listener mConnectionDeathListener = new Listener() { |
| 1381 | @Override |
| 1382 | public void onDestroyed(Connection c) { |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1383 | if (mConferenceables.remove(c)) { |
| 1384 | fireOnConferenceableConnectionsChanged(); |
| 1385 | } |
| 1386 | } |
| 1387 | }; |
| 1388 | |
| 1389 | private final Conference.Listener mConferenceDeathListener = new Conference.Listener() { |
| 1390 | @Override |
| 1391 | public void onDestroyed(Conference c) { |
| 1392 | if (mConferenceables.remove(c)) { |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1393 | fireOnConferenceableConnectionsChanged(); |
| 1394 | } |
| 1395 | } |
| 1396 | }; |
| 1397 | |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 1398 | /** |
| 1399 | * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is |
| 1400 | * load factor before resizing, 1 means we only expect a single thread to |
| 1401 | * access the map so make only a single shard |
| 1402 | */ |
| 1403 | private final Set<Listener> mListeners = Collections.newSetFromMap( |
| 1404 | new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1)); |
Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 1405 | private final List<Conferenceable> mConferenceables = new ArrayList<>(); |
| 1406 | private final List<Conferenceable> mUnmodifiableConferenceables = |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1407 | Collections.unmodifiableList(mConferenceables); |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1408 | |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 1409 | // The internal telecom call ID associated with this connection. |
| 1410 | private String mTelecomCallId; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1411 | private int mState = STATE_NEW; |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 1412 | private CallAudioState mCallAudioState; |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1413 | private Uri mAddress; |
| 1414 | private int mAddressPresentation; |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1415 | private String mCallerDisplayName; |
| 1416 | private int mCallerDisplayNamePresentation; |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1417 | private boolean mRingbackRequested = false; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1418 | private int mConnectionCapabilities; |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1419 | private int mConnectionProperties; |
Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 1420 | private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1421 | private VideoProvider mVideoProvider; |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 1422 | private boolean mAudioModeIsVoip; |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 1423 | private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED; |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 1424 | private StatusHints mStatusHints; |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 1425 | private int mVideoState; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1426 | private DisconnectCause mDisconnectCause; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1427 | private Conference mConference; |
| 1428 | private ConnectionService mConnectionService; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1429 | private Bundle mExtras; |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 1430 | private final Object mExtrasLock = new Object(); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1431 | |
| 1432 | /** |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1433 | * Tracks the key set for the extras bundle provided on the last invocation of |
| 1434 | * {@link #setExtras(Bundle)}. Used so that on subsequent invocations we can remove any extras |
| 1435 | * keys which were set previously but are no longer present in the replacement Bundle. |
| 1436 | */ |
| 1437 | private Set<String> mPreviousExtraKeys; |
| 1438 | |
| 1439 | /** |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1440 | * Create a new Connection. |
| 1441 | */ |
Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 1442 | public Connection() {} |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1443 | |
| 1444 | /** |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 1445 | * Returns the Telecom internal call ID associated with this connection. Should only be used |
| 1446 | * for debugging and tracing purposes. |
| 1447 | * |
| 1448 | * @return The Telecom call ID. |
| 1449 | * @hide |
| 1450 | */ |
| 1451 | public final String getTelecomCallId() { |
| 1452 | return mTelecomCallId; |
| 1453 | } |
| 1454 | |
| 1455 | /** |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1456 | * @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] | 1457 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1458 | public final Uri getAddress() { |
| 1459 | return mAddress; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1460 | } |
| 1461 | |
| 1462 | /** |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1463 | * @return The presentation requirements for the address. |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1464 | * See {@link TelecomManager} for valid values. |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1465 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1466 | public final int getAddressPresentation() { |
| 1467 | return mAddressPresentation; |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1468 | } |
| 1469 | |
| 1470 | /** |
| 1471 | * @return The caller display name (CNAP). |
| 1472 | */ |
| 1473 | public final String getCallerDisplayName() { |
| 1474 | return mCallerDisplayName; |
| 1475 | } |
| 1476 | |
| 1477 | /** |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 1478 | * @return The presentation requirements for the handle. |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1479 | * See {@link TelecomManager} for valid values. |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1480 | */ |
| 1481 | public final int getCallerDisplayNamePresentation() { |
| 1482 | return mCallerDisplayNamePresentation; |
| 1483 | } |
| 1484 | |
| 1485 | /** |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1486 | * @return The state of this Connection. |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1487 | */ |
| 1488 | public final int getState() { |
| 1489 | return mState; |
| 1490 | } |
| 1491 | |
| 1492 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1493 | * Returns the video state of the connection. |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 1494 | * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY}, |
| 1495 | * {@link VideoProfile#STATE_BIDIRECTIONAL}, |
| 1496 | * {@link VideoProfile#STATE_TX_ENABLED}, |
| 1497 | * {@link VideoProfile#STATE_RX_ENABLED}. |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 1498 | * |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1499 | * @return The video state of the connection. |
Tyler Gunn | 27d1e25 | 2014-08-21 16:38:40 -0700 | [diff] [blame] | 1500 | * @hide |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 1501 | */ |
| 1502 | public final int getVideoState() { |
| 1503 | return mVideoState; |
| 1504 | } |
| 1505 | |
| 1506 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1507 | * @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] | 1508 | * being routed by the system. This is {@code null} if this Connection |
| 1509 | * does not directly know about its audio state. |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 1510 | * @deprecated Use {@link #getCallAudioState()} instead. |
| 1511 | * @hide |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1512 | */ |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 1513 | @SystemApi |
| 1514 | @Deprecated |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1515 | public final AudioState getAudioState() { |
Sailesh Nepal | 000d38a | 2015-06-21 10:25:13 -0700 | [diff] [blame] | 1516 | if (mCallAudioState == null) { |
| 1517 | return null; |
| 1518 | } |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 1519 | return new AudioState(mCallAudioState); |
| 1520 | } |
| 1521 | |
| 1522 | /** |
| 1523 | * @return The audio state of the connection, describing how its audio is currently |
| 1524 | * being routed by the system. This is {@code null} if this Connection |
| 1525 | * does not directly know about its audio state. |
| 1526 | */ |
| 1527 | public final CallAudioState getCallAudioState() { |
| 1528 | return mCallAudioState; |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1529 | } |
| 1530 | |
| 1531 | /** |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1532 | * @return The conference that this connection is a part of. Null if it is not part of any |
| 1533 | * conference. |
| 1534 | */ |
| 1535 | public final Conference getConference() { |
| 1536 | return mConference; |
| 1537 | } |
| 1538 | |
| 1539 | /** |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1540 | * Returns whether this connection is requesting that the system play a ringback tone |
| 1541 | * on its behalf. |
| 1542 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1543 | public final boolean isRingbackRequested() { |
| 1544 | return mRingbackRequested; |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1545 | } |
| 1546 | |
| 1547 | /** |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 1548 | * @return True if the connection's audio mode is VOIP. |
| 1549 | */ |
| 1550 | public final boolean getAudioModeIsVoip() { |
| 1551 | return mAudioModeIsVoip; |
| 1552 | } |
| 1553 | |
| 1554 | /** |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 1555 | * Retrieves the connection start time of the {@code Connnection}, if specified. A value of |
| 1556 | * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the |
| 1557 | * start time of the conference. |
| 1558 | * |
| 1559 | * @return The time at which the {@code Connnection} was connected. |
| 1560 | * |
| 1561 | * @hide |
| 1562 | */ |
| 1563 | public final long getConnectTimeMillis() { |
| 1564 | return mConnectTimeMillis; |
| 1565 | } |
| 1566 | |
| 1567 | /** |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 1568 | * @return The status hints for this connection. |
| 1569 | */ |
| 1570 | public final StatusHints getStatusHints() { |
| 1571 | return mStatusHints; |
| 1572 | } |
| 1573 | |
| 1574 | /** |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1575 | * Returns the extras associated with this connection. |
Tyler Gunn | 2cbe2b5 | 2016-05-04 15:48:10 +0000 | [diff] [blame] | 1576 | * <p> |
| 1577 | * Extras should be updated using {@link #putExtras(Bundle)}. |
| 1578 | * <p> |
| 1579 | * Telecom or an {@link InCallService} can also update the extras via |
| 1580 | * {@link android.telecom.Call#putExtras(Bundle)}, and |
| 1581 | * {@link Call#removeExtras(List)}. |
| 1582 | * <p> |
| 1583 | * The connection is notified of changes to the extras made by Telecom or an |
| 1584 | * {@link InCallService} by {@link #onExtrasChanged(Bundle)}. |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1585 | * |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1586 | * @return The extras associated with this connection. |
| 1587 | */ |
| 1588 | public final Bundle getExtras() { |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 1589 | Bundle extras = null; |
| 1590 | synchronized (mExtrasLock) { |
| 1591 | if (mExtras != null) { |
| 1592 | extras = new Bundle(mExtras); |
| 1593 | } |
| 1594 | } |
| 1595 | return extras; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1596 | } |
| 1597 | |
| 1598 | /** |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1599 | * Assign a listener to be notified of state changes. |
| 1600 | * |
| 1601 | * @param l A listener. |
| 1602 | * @return This Connection. |
| 1603 | * |
| 1604 | * @hide |
| 1605 | */ |
| 1606 | public final Connection addConnectionListener(Listener l) { |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1607 | mListeners.add(l); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1608 | return this; |
| 1609 | } |
| 1610 | |
| 1611 | /** |
| 1612 | * Remove a previously assigned listener that was being notified of state changes. |
| 1613 | * |
| 1614 | * @param l A Listener. |
| 1615 | * @return This Connection. |
| 1616 | * |
| 1617 | * @hide |
| 1618 | */ |
| 1619 | public final Connection removeConnectionListener(Listener l) { |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 1620 | if (l != null) { |
| 1621 | mListeners.remove(l); |
| 1622 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1623 | return this; |
| 1624 | } |
| 1625 | |
| 1626 | /** |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1627 | * @return The {@link DisconnectCause} for this connection. |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1628 | */ |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1629 | public final DisconnectCause getDisconnectCause() { |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 1630 | return mDisconnectCause; |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1631 | } |
| 1632 | |
| 1633 | /** |
Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 1634 | * Sets the telecom call ID associated with this Connection. The Telecom Call ID should be used |
| 1635 | * ONLY for debugging purposes. |
| 1636 | * |
| 1637 | * @param callId The telecom call ID. |
| 1638 | * @hide |
| 1639 | */ |
| 1640 | public void setTelecomCallId(String callId) { |
| 1641 | mTelecomCallId = callId; |
| 1642 | } |
| 1643 | |
| 1644 | /** |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1645 | * Inform this Connection that the state of its audio output has been changed externally. |
| 1646 | * |
| 1647 | * @param state The new audio state. |
Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 1648 | * @hide |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1649 | */ |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 1650 | final void setCallAudioState(CallAudioState state) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1651 | checkImmutable(); |
Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 1652 | Log.d(this, "setAudioState %s", state); |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 1653 | mCallAudioState = state; |
| 1654 | onAudioStateChanged(getAudioState()); |
| 1655 | onCallAudioStateChanged(state); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1656 | } |
| 1657 | |
| 1658 | /** |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1659 | * @param state An integer value of a {@code STATE_*} constant. |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1660 | * @return A string representation of the value. |
| 1661 | */ |
| 1662 | public static String stateToString(int state) { |
| 1663 | switch (state) { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1664 | case STATE_INITIALIZING: |
Yorke Lee | e911c8d | 2015-07-14 11:39:36 -0700 | [diff] [blame] | 1665 | return "INITIALIZING"; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1666 | case STATE_NEW: |
Yorke Lee | e911c8d | 2015-07-14 11:39:36 -0700 | [diff] [blame] | 1667 | return "NEW"; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1668 | case STATE_RINGING: |
Yorke Lee | e911c8d | 2015-07-14 11:39:36 -0700 | [diff] [blame] | 1669 | return "RINGING"; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1670 | case STATE_DIALING: |
Yorke Lee | e911c8d | 2015-07-14 11:39:36 -0700 | [diff] [blame] | 1671 | return "DIALING"; |
Tyler Gunn | c96b5e0 | 2016-07-07 22:53:57 -0700 | [diff] [blame] | 1672 | case STATE_PULLING_CALL: |
| 1673 | return "PULLING_CALL"; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1674 | case STATE_ACTIVE: |
Yorke Lee | e911c8d | 2015-07-14 11:39:36 -0700 | [diff] [blame] | 1675 | return "ACTIVE"; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1676 | case STATE_HOLDING: |
Yorke Lee | e911c8d | 2015-07-14 11:39:36 -0700 | [diff] [blame] | 1677 | return "HOLDING"; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1678 | case STATE_DISCONNECTED: |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1679 | return "DISCONNECTED"; |
| 1680 | default: |
Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 1681 | Log.wtf(Connection.class, "Unknown state %d", state); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1682 | return "UNKNOWN"; |
| 1683 | } |
| 1684 | } |
| 1685 | |
| 1686 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1687 | * 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] | 1688 | */ |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1689 | public final int getConnectionCapabilities() { |
| 1690 | return mConnectionCapabilities; |
Ihab Awad | 52a28f6 | 2014-06-18 10:26:34 -0700 | [diff] [blame] | 1691 | } |
| 1692 | |
| 1693 | /** |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1694 | * Returns the connection's properties, as a bit mask of the {@code PROPERTY_*} constants. |
| 1695 | */ |
| 1696 | public final int getConnectionProperties() { |
| 1697 | return mConnectionProperties; |
| 1698 | } |
| 1699 | |
| 1700 | /** |
Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 1701 | * Returns the connection's supported audio routes. |
| 1702 | * |
| 1703 | * @hide |
| 1704 | */ |
| 1705 | public final int getSupportedAudioRoutes() { |
| 1706 | return mSupportedAudioRoutes; |
| 1707 | } |
| 1708 | |
| 1709 | /** |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1710 | * Sets the value of the {@link #getAddress()} property. |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1711 | * |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1712 | * @param address The new address. |
| 1713 | * @param presentation The presentation requirements for the address. |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1714 | * See {@link TelecomManager} for valid values. |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1715 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1716 | public final void setAddress(Uri address, int presentation) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1717 | checkImmutable(); |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1718 | Log.d(this, "setAddress %s", address); |
| 1719 | mAddress = address; |
| 1720 | mAddressPresentation = presentation; |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1721 | for (Listener l : mListeners) { |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1722 | l.onAddressChanged(this, address, presentation); |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1723 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1724 | } |
| 1725 | |
| 1726 | /** |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1727 | * Sets the caller display name (CNAP). |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1728 | * |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1729 | * @param callerDisplayName The new display name. |
Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 1730 | * @param presentation The presentation requirements for the handle. |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 1731 | * See {@link TelecomManager} for valid values. |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1732 | */ |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1733 | public final void setCallerDisplayName(String callerDisplayName, int presentation) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1734 | checkImmutable(); |
Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1735 | Log.d(this, "setCallerDisplayName %s", callerDisplayName); |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1736 | mCallerDisplayName = callerDisplayName; |
| 1737 | mCallerDisplayNamePresentation = presentation; |
| 1738 | for (Listener l : mListeners) { |
| 1739 | l.onCallerDisplayNameChanged(this, callerDisplayName, presentation); |
| 1740 | } |
Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 1741 | } |
| 1742 | |
| 1743 | /** |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 1744 | * Set the video state for the connection. |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 1745 | * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY}, |
| 1746 | * {@link VideoProfile#STATE_BIDIRECTIONAL}, |
| 1747 | * {@link VideoProfile#STATE_TX_ENABLED}, |
| 1748 | * {@link VideoProfile#STATE_RX_ENABLED}. |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 1749 | * |
| 1750 | * @param videoState The new video state. |
| 1751 | */ |
| 1752 | public final void setVideoState(int videoState) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1753 | checkImmutable(); |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 1754 | Log.d(this, "setVideoState %d", videoState); |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1755 | mVideoState = videoState; |
| 1756 | for (Listener l : mListeners) { |
| 1757 | l.onVideoStateChanged(this, mVideoState); |
| 1758 | } |
Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 1759 | } |
| 1760 | |
| 1761 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1762 | * 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] | 1763 | * communicate). |
| 1764 | */ |
Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 1765 | public final void setActive() { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1766 | checkImmutable(); |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1767 | setRingbackRequested(false); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1768 | setState(STATE_ACTIVE); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1769 | } |
| 1770 | |
| 1771 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1772 | * Sets state to ringing (e.g., an inbound ringing connection). |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1773 | */ |
Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 1774 | public final void setRinging() { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1775 | checkImmutable(); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1776 | setState(STATE_RINGING); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1777 | } |
| 1778 | |
| 1779 | /** |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1780 | * Sets state to initializing (this Connection is not yet ready to be used). |
| 1781 | */ |
| 1782 | public final void setInitializing() { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1783 | checkImmutable(); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1784 | setState(STATE_INITIALIZING); |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1785 | } |
| 1786 | |
| 1787 | /** |
| 1788 | * Sets state to initialized (the Connection has been set up and is now ready to be used). |
| 1789 | */ |
| 1790 | public final void setInitialized() { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1791 | checkImmutable(); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1792 | setState(STATE_NEW); |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1793 | } |
| 1794 | |
| 1795 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1796 | * Sets state to dialing (e.g., dialing an outbound connection). |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1797 | */ |
Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 1798 | public final void setDialing() { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1799 | checkImmutable(); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1800 | setState(STATE_DIALING); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1801 | } |
| 1802 | |
| 1803 | /** |
Tyler Gunn | c242ceb | 2016-06-29 22:35:45 -0700 | [diff] [blame] | 1804 | * Sets state to pulling (e.g. the connection is being pulled to the local device from another |
| 1805 | * device). Only applicable for {@link Connection}s with |
| 1806 | * {@link Connection#PROPERTY_IS_EXTERNAL_CALL} and {@link Connection#CAPABILITY_CAN_PULL_CALL}. |
| 1807 | */ |
| 1808 | public final void setPulling() { |
| 1809 | checkImmutable(); |
| 1810 | setState(STATE_PULLING_CALL); |
| 1811 | } |
| 1812 | |
| 1813 | /** |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1814 | * Sets state to be on hold. |
| 1815 | */ |
Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 1816 | public final void setOnHold() { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1817 | checkImmutable(); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1818 | setState(STATE_HOLDING); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1819 | } |
| 1820 | |
| 1821 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1822 | * Sets the video connection provider. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1823 | * @param videoProvider The video provider. |
Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 1824 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1825 | public final void setVideoProvider(VideoProvider videoProvider) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1826 | checkImmutable(); |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1827 | mVideoProvider = videoProvider; |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1828 | for (Listener l : mListeners) { |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1829 | l.onVideoProviderChanged(this, videoProvider); |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1830 | } |
Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 1831 | } |
| 1832 | |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1833 | public final VideoProvider getVideoProvider() { |
| 1834 | return mVideoProvider; |
Andrew Lee | a27a193 | 2014-07-09 17:07:13 -0700 | [diff] [blame] | 1835 | } |
| 1836 | |
Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 1837 | /** |
Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 1838 | * Sets state to disconnected. |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1839 | * |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1840 | * @param disconnectCause The reason for the disconnection, as specified by |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1841 | * {@link DisconnectCause}. |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1842 | */ |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1843 | public final void setDisconnected(DisconnectCause disconnectCause) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1844 | checkImmutable(); |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1845 | mDisconnectCause = disconnectCause; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1846 | setState(STATE_DISCONNECTED); |
mike dooley | f34519b | 2014-09-16 17:33:40 -0700 | [diff] [blame] | 1847 | Log.d(this, "Disconnected with cause %s", disconnectCause); |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1848 | for (Listener l : mListeners) { |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1849 | l.onDisconnected(this, disconnectCause); |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1850 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1851 | } |
| 1852 | |
| 1853 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1854 | * Informs listeners that this {@code Connection} is in a post-dial wait state. This is done |
| 1855 | * when (a) the {@code Connection} is issuing a DTMF sequence; (b) it has encountered a "wait" |
| 1856 | * character; and (c) it wishes to inform the In-Call app that it is waiting for the end-user |
| 1857 | * to send an {@link #onPostDialContinue(boolean)} signal. |
| 1858 | * |
| 1859 | * @param remaining The DTMF character sequence remaining to be emitted once the |
| 1860 | * {@link #onPostDialContinue(boolean)} is received, including any "wait" characters |
| 1861 | * that remaining sequence may contain. |
Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 1862 | */ |
| 1863 | public final void setPostDialWait(String remaining) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1864 | checkImmutable(); |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1865 | for (Listener l : mListeners) { |
| 1866 | l.onPostDialWait(this, remaining); |
| 1867 | } |
Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 1868 | } |
| 1869 | |
| 1870 | /** |
Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 1871 | * Informs listeners that this {@code Connection} has processed a character in the post-dial |
| 1872 | * 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] | 1873 | * 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] | 1874 | * |
| 1875 | * @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] | 1876 | */ |
Sailesh Nepal | 1ed8561 | 2015-01-31 15:17:19 -0800 | [diff] [blame] | 1877 | public final void setNextPostDialChar(char nextChar) { |
Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 1878 | checkImmutable(); |
| 1879 | for (Listener l : mListeners) { |
| 1880 | l.onPostDialChar(this, nextChar); |
| 1881 | } |
| 1882 | } |
| 1883 | |
| 1884 | /** |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 1885 | * 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] | 1886 | * 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] | 1887 | * |
| 1888 | * @param ringback Whether the ringback tone is to be played. |
| 1889 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1890 | public final void setRingbackRequested(boolean ringback) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1891 | checkImmutable(); |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1892 | if (mRingbackRequested != ringback) { |
| 1893 | mRingbackRequested = ringback; |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1894 | for (Listener l : mListeners) { |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1895 | l.onRingbackRequested(this, ringback); |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1896 | } |
| 1897 | } |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 1898 | } |
| 1899 | |
| 1900 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1901 | * 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] | 1902 | * |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1903 | * @param connectionCapabilities The new connection capabilities. |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1904 | */ |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1905 | public final void setConnectionCapabilities(int connectionCapabilities) { |
| 1906 | checkImmutable(); |
| 1907 | if (mConnectionCapabilities != connectionCapabilities) { |
| 1908 | mConnectionCapabilities = connectionCapabilities; |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1909 | for (Listener l : mListeners) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1910 | l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities); |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1911 | } |
| 1912 | } |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1913 | } |
| 1914 | |
| 1915 | /** |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1916 | * Sets the connection's properties as a bit mask of the {@code PROPERTY_*} constants. |
| 1917 | * |
| 1918 | * @param connectionProperties The new connection properties. |
| 1919 | */ |
| 1920 | public final void setConnectionProperties(int connectionProperties) { |
| 1921 | checkImmutable(); |
| 1922 | if (mConnectionProperties != connectionProperties) { |
| 1923 | mConnectionProperties = connectionProperties; |
| 1924 | for (Listener l : mListeners) { |
| 1925 | l.onConnectionPropertiesChanged(this, mConnectionProperties); |
| 1926 | } |
| 1927 | } |
| 1928 | } |
| 1929 | |
| 1930 | /** |
Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 1931 | * Sets the supported audio routes. |
| 1932 | * |
| 1933 | * @param supportedAudioRoutes the supported audio routes as a bitmask. |
| 1934 | * See {@link CallAudioState} |
| 1935 | * @hide |
| 1936 | */ |
| 1937 | public final void setSupportedAudioRoutes(int supportedAudioRoutes) { |
| 1938 | if ((supportedAudioRoutes |
| 1939 | & (CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_SPEAKER)) == 0) { |
| 1940 | throw new IllegalArgumentException( |
| 1941 | "supported audio routes must include either speaker or earpiece"); |
| 1942 | } |
| 1943 | |
| 1944 | if (mSupportedAudioRoutes != supportedAudioRoutes) { |
| 1945 | mSupportedAudioRoutes = supportedAudioRoutes; |
| 1946 | for (Listener l : mListeners) { |
| 1947 | l.onSupportedAudioRoutesChanged(this, mSupportedAudioRoutes); |
| 1948 | } |
| 1949 | } |
| 1950 | } |
| 1951 | |
| 1952 | /** |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 1953 | * Tears down the Connection object. |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1954 | */ |
Evan Charlton | 36a7134 | 2014-07-19 16:31:02 -0700 | [diff] [blame] | 1955 | public final void destroy() { |
Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 1956 | for (Listener l : mListeners) { |
| 1957 | l.onDestroyed(this); |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1958 | } |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 1959 | } |
| 1960 | |
| 1961 | /** |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 1962 | * Requests that the framework use VOIP audio mode for this connection. |
| 1963 | * |
| 1964 | * @param isVoip True if the audio mode is VOIP. |
| 1965 | */ |
| 1966 | public final void setAudioModeIsVoip(boolean isVoip) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1967 | checkImmutable(); |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1968 | mAudioModeIsVoip = isVoip; |
| 1969 | for (Listener l : mListeners) { |
| 1970 | l.onAudioModeIsVoipChanged(this, isVoip); |
| 1971 | } |
Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 1972 | } |
| 1973 | |
| 1974 | /** |
Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 1975 | * Sets the time at which a call became active on this Connection. This is set only |
| 1976 | * when a conference call becomes active on this connection. |
| 1977 | * |
| 1978 | * @param connectionTimeMillis The connection time, in milliseconds. |
| 1979 | * |
| 1980 | * @hide |
| 1981 | */ |
| 1982 | public final void setConnectTimeMillis(long connectTimeMillis) { |
| 1983 | mConnectTimeMillis = connectTimeMillis; |
| 1984 | } |
| 1985 | |
| 1986 | /** |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 1987 | * Sets the label and icon status to display in the in-call UI. |
| 1988 | * |
| 1989 | * @param statusHints The status label and icon to set. |
| 1990 | */ |
| 1991 | public final void setStatusHints(StatusHints statusHints) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1992 | checkImmutable(); |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 1993 | mStatusHints = statusHints; |
| 1994 | for (Listener l : mListeners) { |
| 1995 | l.onStatusHintsChanged(this, statusHints); |
| 1996 | } |
Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 1997 | } |
| 1998 | |
| 1999 | /** |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2000 | * Sets the connections with which this connection can be conferenced. |
| 2001 | * |
| 2002 | * @param conferenceableConnections The set of connections this connection can conference with. |
| 2003 | */ |
| 2004 | public final void setConferenceableConnections(List<Connection> conferenceableConnections) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2005 | checkImmutable(); |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2006 | clearConferenceableList(); |
| 2007 | for (Connection c : conferenceableConnections) { |
| 2008 | // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a |
| 2009 | // small amount of items here. |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2010 | if (!mConferenceables.contains(c)) { |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2011 | c.addConnectionListener(mConnectionDeathListener); |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2012 | mConferenceables.add(c); |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2013 | } |
| 2014 | } |
| 2015 | fireOnConferenceableConnectionsChanged(); |
| 2016 | } |
| 2017 | |
| 2018 | /** |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2019 | * Similar to {@link #setConferenceableConnections(java.util.List)}, sets a list of connections |
| 2020 | * or conferences with which this connection can be conferenced. |
| 2021 | * |
| 2022 | * @param conferenceables The conferenceables. |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2023 | */ |
Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 2024 | public final void setConferenceables(List<Conferenceable> conferenceables) { |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2025 | clearConferenceableList(); |
Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 2026 | for (Conferenceable c : conferenceables) { |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2027 | // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a |
| 2028 | // small amount of items here. |
| 2029 | if (!mConferenceables.contains(c)) { |
| 2030 | if (c instanceof Connection) { |
| 2031 | Connection connection = (Connection) c; |
| 2032 | connection.addConnectionListener(mConnectionDeathListener); |
| 2033 | } else if (c instanceof Conference) { |
| 2034 | Conference conference = (Conference) c; |
| 2035 | conference.addListener(mConferenceDeathListener); |
| 2036 | } |
| 2037 | mConferenceables.add(c); |
| 2038 | } |
| 2039 | } |
| 2040 | fireOnConferenceableConnectionsChanged(); |
| 2041 | } |
| 2042 | |
| 2043 | /** |
| 2044 | * Returns the connections or conferences with which this connection can be conferenced. |
| 2045 | */ |
Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 2046 | public final List<Conferenceable> getConferenceables() { |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2047 | return mUnmodifiableConferenceables; |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2048 | } |
| 2049 | |
Yorke Lee | 5346396 | 2015-08-04 16:07:19 -0700 | [diff] [blame] | 2050 | /** |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2051 | * @hide |
| 2052 | */ |
| 2053 | public final void setConnectionService(ConnectionService connectionService) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2054 | checkImmutable(); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2055 | if (mConnectionService != null) { |
| 2056 | Log.e(this, new Exception(), "Trying to set ConnectionService on a connection " + |
| 2057 | "which is already associated with another ConnectionService."); |
| 2058 | } else { |
| 2059 | mConnectionService = connectionService; |
| 2060 | } |
| 2061 | } |
| 2062 | |
| 2063 | /** |
| 2064 | * @hide |
| 2065 | */ |
| 2066 | public final void unsetConnectionService(ConnectionService connectionService) { |
| 2067 | if (mConnectionService != connectionService) { |
| 2068 | Log.e(this, new Exception(), "Trying to remove ConnectionService from a Connection " + |
| 2069 | "that does not belong to the ConnectionService."); |
| 2070 | } else { |
| 2071 | mConnectionService = null; |
| 2072 | } |
| 2073 | } |
| 2074 | |
| 2075 | /** |
Santos Cordon | af1b296 | 2014-10-16 19:23:54 -0700 | [diff] [blame] | 2076 | * @hide |
| 2077 | */ |
| 2078 | public final ConnectionService getConnectionService() { |
| 2079 | return mConnectionService; |
| 2080 | } |
| 2081 | |
| 2082 | /** |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2083 | * 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] | 2084 | * 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] | 2085 | * |
| 2086 | * @param conference The conference. |
| 2087 | * @return {@code true} if the conference was successfully set. |
| 2088 | * @hide |
| 2089 | */ |
| 2090 | public final boolean setConference(Conference conference) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2091 | checkImmutable(); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2092 | // We check to see if it is already part of another conference. |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 2093 | if (mConference == null) { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2094 | mConference = conference; |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 2095 | if (mConnectionService != null && mConnectionService.containsConference(conference)) { |
| 2096 | fireConferenceChanged(); |
| 2097 | } |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2098 | return true; |
| 2099 | } |
| 2100 | return false; |
| 2101 | } |
| 2102 | |
| 2103 | /** |
| 2104 | * Resets the conference that this connection is a part of. |
| 2105 | * @hide |
| 2106 | */ |
| 2107 | public final void resetConference() { |
| 2108 | if (mConference != null) { |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 2109 | Log.d(this, "Conference reset"); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2110 | mConference = null; |
| 2111 | fireConferenceChanged(); |
| 2112 | } |
| 2113 | } |
| 2114 | |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2115 | /** |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2116 | * Set some extras that can be associated with this {@code Connection}. |
| 2117 | * <p> |
| 2118 | * New or existing keys are replaced in the {@code Connection} extras. Keys which are no longer |
| 2119 | * in the new extras, but were present the last time {@code setExtras} was called are removed. |
| 2120 | * <p> |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 2121 | * Alternatively you may use the {@link #putExtras(Bundle)}, and |
| 2122 | * {@link #removeExtras(String...)} methods to modify the extras. |
| 2123 | * <p> |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2124 | * No assumptions should be made as to how an In-Call UI or service will handle these extras. |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 2125 | * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts. |
| 2126 | * |
| 2127 | * @param extras The extras associated with this {@code Connection}. |
| 2128 | */ |
| 2129 | public final void setExtras(@Nullable Bundle extras) { |
| 2130 | checkImmutable(); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2131 | |
| 2132 | // Add/replace any new or changed extras values. |
| 2133 | putExtras(extras); |
| 2134 | |
| 2135 | // If we have used "setExtras" in the past, compare the key set from the last invocation to |
| 2136 | // the current one and remove any keys that went away. |
| 2137 | if (mPreviousExtraKeys != null) { |
| 2138 | List<String> toRemove = new ArrayList<String>(); |
| 2139 | for (String oldKey : mPreviousExtraKeys) { |
Tyler Gunn | a8fb8ab | 2016-03-29 10:24:22 -0700 | [diff] [blame] | 2140 | if (extras == null || !extras.containsKey(oldKey)) { |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2141 | toRemove.add(oldKey); |
| 2142 | } |
| 2143 | } |
| 2144 | if (!toRemove.isEmpty()) { |
| 2145 | removeExtras(toRemove); |
| 2146 | } |
| 2147 | } |
| 2148 | |
| 2149 | // Track the keys the last time set called setExtras. This way, the next time setExtras is |
| 2150 | // called we can see if the caller has removed any extras values. |
| 2151 | if (mPreviousExtraKeys == null) { |
| 2152 | mPreviousExtraKeys = new ArraySet<String>(); |
| 2153 | } |
| 2154 | mPreviousExtraKeys.clear(); |
Tyler Gunn | a8fb8ab | 2016-03-29 10:24:22 -0700 | [diff] [blame] | 2155 | if (extras != null) { |
| 2156 | mPreviousExtraKeys.addAll(extras.keySet()); |
| 2157 | } |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2158 | } |
| 2159 | |
| 2160 | /** |
| 2161 | * Adds some extras to this {@code Connection}. Existing keys are replaced and new ones are |
| 2162 | * added. |
| 2163 | * <p> |
| 2164 | * No assumptions should be made as to how an In-Call UI or service will handle these extras. |
| 2165 | * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts. |
| 2166 | * |
| 2167 | * @param extras The extras to add. |
| 2168 | */ |
| 2169 | public final void putExtras(@NonNull Bundle extras) { |
| 2170 | checkImmutable(); |
| 2171 | if (extras == null) { |
| 2172 | return; |
| 2173 | } |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 2174 | // Creating a duplicate bundle so we don't have to synchronize on mExtrasLock while calling |
| 2175 | // the listeners. |
| 2176 | Bundle listenerExtras; |
| 2177 | synchronized (mExtrasLock) { |
| 2178 | if (mExtras == null) { |
| 2179 | mExtras = new Bundle(); |
| 2180 | } |
| 2181 | mExtras.putAll(extras); |
| 2182 | listenerExtras = new Bundle(mExtras); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2183 | } |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 2184 | for (Listener l : mListeners) { |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 2185 | // Create a new clone of the extras for each listener so that they don't clobber |
| 2186 | // each other |
| 2187 | l.onExtrasChanged(this, new Bundle(listenerExtras)); |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 2188 | } |
| 2189 | } |
| 2190 | |
| 2191 | /** |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2192 | * Adds a boolean extra to this {@code Connection}. |
| 2193 | * |
| 2194 | * @param key The extra key. |
| 2195 | * @param value The value. |
| 2196 | * @hide |
| 2197 | */ |
| 2198 | public final void putExtra(String key, boolean value) { |
| 2199 | Bundle newExtras = new Bundle(); |
| 2200 | newExtras.putBoolean(key, value); |
| 2201 | putExtras(newExtras); |
| 2202 | } |
| 2203 | |
| 2204 | /** |
| 2205 | * Adds an integer extra to this {@code Connection}. |
| 2206 | * |
| 2207 | * @param key The extra key. |
| 2208 | * @param value The value. |
| 2209 | * @hide |
| 2210 | */ |
| 2211 | public final void putExtra(String key, int value) { |
| 2212 | Bundle newExtras = new Bundle(); |
| 2213 | newExtras.putInt(key, value); |
| 2214 | putExtras(newExtras); |
| 2215 | } |
| 2216 | |
| 2217 | /** |
| 2218 | * Adds a string extra to this {@code Connection}. |
| 2219 | * |
| 2220 | * @param key The extra key. |
| 2221 | * @param value The value. |
| 2222 | * @hide |
| 2223 | */ |
| 2224 | public final void putExtra(String key, String value) { |
| 2225 | Bundle newExtras = new Bundle(); |
| 2226 | newExtras.putString(key, value); |
| 2227 | putExtras(newExtras); |
| 2228 | } |
| 2229 | |
| 2230 | /** |
Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 2231 | * Removes extras from this {@code Connection}. |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2232 | * |
Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 2233 | * @param keys The keys of the extras to remove. |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2234 | */ |
| 2235 | public final void removeExtras(List<String> keys) { |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 2236 | synchronized (mExtrasLock) { |
| 2237 | if (mExtras != null) { |
| 2238 | for (String key : keys) { |
| 2239 | mExtras.remove(key); |
| 2240 | } |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2241 | } |
| 2242 | } |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 2243 | List<String> unmodifiableKeys = Collections.unmodifiableList(keys); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2244 | for (Listener l : mListeners) { |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 2245 | l.onExtrasRemoved(this, unmodifiableKeys); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2246 | } |
| 2247 | } |
| 2248 | |
| 2249 | /** |
Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 2250 | * Removes extras from this {@code Connection}. |
| 2251 | * |
| 2252 | * @param keys The keys of the extras to remove. |
| 2253 | */ |
| 2254 | public final void removeExtras(String ... keys) { |
| 2255 | removeExtras(Arrays.asList(keys)); |
| 2256 | } |
| 2257 | |
| 2258 | /** |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2259 | * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will |
| 2260 | * be change to the {@link #getCallAudioState()}. |
| 2261 | * <p> |
| 2262 | * Used by self-managed {@link ConnectionService}s which wish to change the audio route for a |
| 2263 | * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.) |
| 2264 | * <p> |
| 2265 | * See also {@link InCallService#setAudioRoute(int)}. |
| 2266 | * |
| 2267 | * @param route The audio route to use (one of {@link CallAudioState#ROUTE_BLUETOOTH}, |
| 2268 | * {@link CallAudioState#ROUTE_EARPIECE}, {@link CallAudioState#ROUTE_SPEAKER}, or |
| 2269 | * {@link CallAudioState#ROUTE_WIRED_HEADSET}). |
| 2270 | */ |
| 2271 | public final void setAudioRoute(int route) { |
| 2272 | for (Listener l : mListeners) { |
| 2273 | l.onAudioRouteChanged(this, route); |
| 2274 | } |
| 2275 | } |
| 2276 | |
| 2277 | /** |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2278 | * Notifies this Connection that the {@link #getAudioState()} property has a new value. |
Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 2279 | * |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2280 | * @param state The new connection audio state. |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 2281 | * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead. |
| 2282 | * @hide |
Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 2283 | */ |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 2284 | @SystemApi |
| 2285 | @Deprecated |
Nancy Chen | 354b2bd | 2014-09-08 18:27:26 -0700 | [diff] [blame] | 2286 | public void onAudioStateChanged(AudioState state) {} |
Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 2287 | |
| 2288 | /** |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 2289 | * Notifies this Connection that the {@link #getCallAudioState()} property has a new value. |
| 2290 | * |
| 2291 | * @param state The new connection audio state. |
| 2292 | */ |
| 2293 | public void onCallAudioStateChanged(CallAudioState state) {} |
| 2294 | |
| 2295 | /** |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 2296 | * Notifies this Connection of an internal state change. This method is called after the |
| 2297 | * state is changed. |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 2298 | * |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2299 | * @param state The new state, one of the {@code STATE_*} constants. |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 2300 | */ |
Nancy Chen | 354b2bd | 2014-09-08 18:27:26 -0700 | [diff] [blame] | 2301 | public void onStateChanged(int state) {} |
Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 2302 | |
| 2303 | /** |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2304 | * Notifies this Connection of a request to play a DTMF tone. |
| 2305 | * |
| 2306 | * @param c A DTMF character. |
| 2307 | */ |
Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 2308 | public void onPlayDtmfTone(char c) {} |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2309 | |
| 2310 | /** |
| 2311 | * Notifies this Connection of a request to stop any currently playing DTMF tones. |
| 2312 | */ |
Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 2313 | public void onStopDtmfTone() {} |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2314 | |
| 2315 | /** |
| 2316 | * Notifies this Connection of a request to disconnect. |
| 2317 | */ |
Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 2318 | public void onDisconnect() {} |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2319 | |
| 2320 | /** |
Tyler Gunn | 3b4b1dc | 2014-11-04 14:53:37 -0800 | [diff] [blame] | 2321 | * Notifies this Connection of a request to disconnect a participant of the conference managed |
| 2322 | * by the connection. |
| 2323 | * |
| 2324 | * @param endpoint the {@link Uri} of the participant to disconnect. |
| 2325 | * @hide |
| 2326 | */ |
| 2327 | public void onDisconnectConferenceParticipant(Uri endpoint) {} |
| 2328 | |
| 2329 | /** |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2330 | * Notifies this Connection of a request to separate from its parent conference. |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 2331 | */ |
Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 2332 | public void onSeparate() {} |
Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 2333 | |
| 2334 | /** |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2335 | * Notifies this Connection of a request to abort. |
| 2336 | */ |
Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 2337 | public void onAbort() {} |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2338 | |
| 2339 | /** |
| 2340 | * Notifies this Connection of a request to hold. |
| 2341 | */ |
Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 2342 | public void onHold() {} |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2343 | |
| 2344 | /** |
| 2345 | * Notifies this Connection of a request to exit a hold state. |
| 2346 | */ |
Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 2347 | public void onUnhold() {} |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2348 | |
| 2349 | /** |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2350 | * Notifies this Connection, which is in {@link #STATE_RINGING}, of |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2351 | * a request to accept. |
Andrew Lee | 8da4c3c | 2014-07-16 10:11:42 -0700 | [diff] [blame] | 2352 | * |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2353 | * @param videoState The video state in which to answer the connection. |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2354 | */ |
Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 2355 | public void onAnswer(int videoState) {} |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2356 | |
| 2357 | /** |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2358 | * Notifies this Connection, which is in {@link #STATE_RINGING}, of |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 2359 | * a request to accept. |
| 2360 | */ |
| 2361 | public void onAnswer() { |
Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 2362 | onAnswer(VideoProfile.STATE_AUDIO_ONLY); |
Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 2363 | } |
| 2364 | |
| 2365 | /** |
| 2366 | * Notifies this Connection, which is in {@link #STATE_RINGING}, of |
Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2367 | * a request to reject. |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2368 | */ |
Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 2369 | public void onReject() {} |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2370 | |
Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 2371 | /** |
Hall Liu | 712acbe | 2016-03-14 16:38:56 -0700 | [diff] [blame] | 2372 | * Notifies this Connection, which is in {@link #STATE_RINGING}, of |
| 2373 | * a request to reject with a message. |
Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 2374 | */ |
| 2375 | public void onReject(String replyMessage) {} |
| 2376 | |
| 2377 | /** |
Bryce Lee | cac5077 | 2015-11-17 15:13:29 -0800 | [diff] [blame] | 2378 | * Notifies the Connection of a request to silence the ringer. |
| 2379 | * |
| 2380 | * @hide |
| 2381 | */ |
| 2382 | public void onSilence() {} |
| 2383 | |
| 2384 | /** |
Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 2385 | * Notifies this Connection whether the user wishes to proceed with the post-dial DTMF codes. |
| 2386 | */ |
Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 2387 | public void onPostDialContinue(boolean proceed) {} |
Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 2388 | |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 2389 | /** |
| 2390 | * Notifies this Connection of a request to pull an external call to the local device. |
| 2391 | * <p> |
| 2392 | * The {@link InCallService} issues a request to pull an external call to the local device via |
| 2393 | * {@link Call#pullExternalCall()}. |
| 2394 | * <p> |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 2395 | * For a Connection to be pulled, both the {@link Connection#CAPABILITY_CAN_PULL_CALL} |
| 2396 | * capability and {@link Connection#PROPERTY_IS_EXTERNAL_CALL} property bits must be set. |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 2397 | * <p> |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 2398 | * For more information on external calls, see {@link Connection#PROPERTY_IS_EXTERNAL_CALL}. |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 2399 | */ |
| 2400 | public void onPullExternalCall() {} |
| 2401 | |
| 2402 | /** |
| 2403 | * Notifies this Connection of a {@link Call} event initiated from an {@link InCallService}. |
| 2404 | * <p> |
| 2405 | * The {@link InCallService} issues a Call event via {@link Call#sendCallEvent(String, Bundle)}. |
| 2406 | * <p> |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 2407 | * Where possible, the Connection should make an attempt to handle {@link Call} events which |
| 2408 | * are part of the {@code android.telecom.*} namespace. The Connection should ignore any events |
| 2409 | * it does not wish to handle. Unexpected events should be handled gracefully, as it is |
| 2410 | * possible that a {@link InCallService} has defined its own Call events which a Connection is |
| 2411 | * not aware of. |
| 2412 | * <p> |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 2413 | * See also {@link Call#sendCallEvent(String, Bundle)}. |
| 2414 | * |
| 2415 | * @param event The call event. |
| 2416 | * @param extras Extras associated with the call event. |
| 2417 | */ |
| 2418 | public void onCallEvent(String event, Bundle extras) {} |
| 2419 | |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2420 | /** |
| 2421 | * Notifies this {@link Connection} of a change to the extras made outside the |
| 2422 | * {@link ConnectionService}. |
| 2423 | * <p> |
| 2424 | * These extras changes can originate from Telecom itself, or from an {@link InCallService} via |
| 2425 | * the {@link android.telecom.Call#putExtras(Bundle)} and |
| 2426 | * {@link Call#removeExtras(List)}. |
| 2427 | * |
| 2428 | * @param extras The new extras bundle. |
| 2429 | */ |
| 2430 | public void onExtrasChanged(Bundle extras) {} |
| 2431 | |
Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 2432 | /** |
| 2433 | * Notifies this {@link Connection} that its {@link ConnectionService} is responsible for |
| 2434 | * displaying its incoming call user interface for the {@link Connection}. |
| 2435 | * <p> |
| 2436 | * Will only be called for incoming calls added via a self-managed {@link ConnectionService} |
| 2437 | * (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}), where the {@link ConnectionService} |
| 2438 | * should show its own incoming call user interface. |
| 2439 | * <p> |
| 2440 | * Where there are ongoing calls in other self-managed {@link ConnectionService}s, or in a |
| 2441 | * regular {@link ConnectionService}, the Telecom framework will display its own incoming call |
| 2442 | * user interface to allow the user to choose whether to answer the new incoming call and |
| 2443 | * disconnect other ongoing calls, or to reject the new incoming call. |
| 2444 | */ |
| 2445 | public void onShowIncomingCallUi() {} |
| 2446 | |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2447 | static String toLogSafePhoneNumber(String number) { |
| 2448 | // For unknown number, log empty string. |
| 2449 | if (number == null) { |
| 2450 | return ""; |
| 2451 | } |
| 2452 | |
| 2453 | if (PII_DEBUG) { |
| 2454 | // When PII_DEBUG is true we emit PII. |
| 2455 | return number; |
| 2456 | } |
| 2457 | |
| 2458 | // Do exactly same thing as Uri#toSafeString() does, which will enable us to compare |
| 2459 | // sanitized phone numbers. |
| 2460 | StringBuilder builder = new StringBuilder(); |
| 2461 | for (int i = 0; i < number.length(); i++) { |
| 2462 | char c = number.charAt(i); |
| 2463 | if (c == '-' || c == '@' || c == '.') { |
| 2464 | builder.append(c); |
| 2465 | } else { |
| 2466 | builder.append('x'); |
| 2467 | } |
| 2468 | } |
| 2469 | return builder.toString(); |
| 2470 | } |
| 2471 | |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2472 | private void setState(int state) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2473 | checkImmutable(); |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 2474 | if (mState == STATE_DISCONNECTED && mState != state) { |
| 2475 | Log.d(this, "Connection already DISCONNECTED; cannot transition out of this state."); |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 2476 | return; |
Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 2477 | } |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 2478 | if (mState != state) { |
| 2479 | Log.d(this, "setState: %s", stateToString(state)); |
| 2480 | mState = state; |
Nancy Chen | 354b2bd | 2014-09-08 18:27:26 -0700 | [diff] [blame] | 2481 | onStateChanged(state); |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 2482 | for (Listener l : mListeners) { |
| 2483 | l.onStateChanged(this, state); |
| 2484 | } |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 2485 | } |
| 2486 | } |
| 2487 | |
Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 2488 | private static class FailureSignalingConnection extends Connection { |
Ihab Awad | 90e34e3 | 2014-12-01 16:23:17 -0800 | [diff] [blame] | 2489 | private boolean mImmutable = false; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 2490 | public FailureSignalingConnection(DisconnectCause disconnectCause) { |
| 2491 | setDisconnected(disconnectCause); |
Ihab Awad | 90e34e3 | 2014-12-01 16:23:17 -0800 | [diff] [blame] | 2492 | mImmutable = true; |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 2493 | } |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2494 | |
| 2495 | public void checkImmutable() { |
Ihab Awad | 90e34e3 | 2014-12-01 16:23:17 -0800 | [diff] [blame] | 2496 | if (mImmutable) { |
| 2497 | throw new UnsupportedOperationException("Connection is immutable"); |
| 2498 | } |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2499 | } |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 2500 | } |
| 2501 | |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 2502 | /** |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 2503 | * Return a {@code Connection} which represents a failed connection attempt. The returned |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 2504 | * {@code Connection} will have a {@link android.telecom.DisconnectCause} and as specified, |
| 2505 | * and a {@link #getState()} of {@link #STATE_DISCONNECTED}. |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 2506 | * <p> |
| 2507 | * The returned {@code Connection} can be assumed to {@link #destroy()} itself when appropriate, |
| 2508 | * 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] | 2509 | * |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 2510 | * @param disconnectCause The disconnect cause, ({@see android.telecomm.DisconnectCause}). |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 2511 | * @return A {@code Connection} which indicates failure. |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 2512 | */ |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 2513 | public static Connection createFailedConnection(DisconnectCause disconnectCause) { |
| 2514 | return new FailureSignalingConnection(disconnectCause); |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 2515 | } |
| 2516 | |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 2517 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2518 | * Override to throw an {@link UnsupportedOperationException} if this {@code Connection} is |
| 2519 | * not intended to be mutated, e.g., if it is a marker for failure. Only for framework use; |
| 2520 | * this should never be un-@hide-den. |
| 2521 | * |
| 2522 | * @hide |
| 2523 | */ |
| 2524 | public void checkImmutable() {} |
| 2525 | |
| 2526 | /** |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 2527 | * Return a {@code Connection} which represents a canceled connection attempt. The returned |
| 2528 | * {@code Connection} will have state {@link #STATE_DISCONNECTED}, and cannot be moved out of |
| 2529 | * that state. This connection should not be used for anything, and no other |
| 2530 | * {@code Connection}s should be attempted. |
| 2531 | * <p> |
Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 2532 | * 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] | 2533 | * |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2534 | * @return A {@code Connection} which indicates that the underlying connection should |
| 2535 | * be canceled. |
Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 2536 | */ |
Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2537 | public static Connection createCanceledConnection() { |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 2538 | return new FailureSignalingConnection(new DisconnectCause(DisconnectCause.CANCELED)); |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2539 | } |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2540 | |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2541 | private final void fireOnConferenceableConnectionsChanged() { |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2542 | for (Listener l : mListeners) { |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2543 | l.onConferenceablesChanged(this, getConferenceables()); |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2544 | } |
| 2545 | } |
| 2546 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2547 | private final void fireConferenceChanged() { |
| 2548 | for (Listener l : mListeners) { |
| 2549 | l.onConferenceChanged(this, mConference); |
| 2550 | } |
| 2551 | } |
| 2552 | |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2553 | private final void clearConferenceableList() { |
Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 2554 | for (Conferenceable c : mConferenceables) { |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2555 | if (c instanceof Connection) { |
| 2556 | Connection connection = (Connection) c; |
| 2557 | connection.removeConnectionListener(mConnectionDeathListener); |
| 2558 | } else if (c instanceof Conference) { |
| 2559 | Conference conference = (Conference) c; |
| 2560 | conference.removeListener(mConferenceDeathListener); |
| 2561 | } |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2562 | } |
Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2563 | mConferenceables.clear(); |
Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2564 | } |
Tyler Gunn | 3bffcf7 | 2014-10-28 13:51:27 -0700 | [diff] [blame] | 2565 | |
| 2566 | /** |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2567 | * Handles a change to extras received from Telecom. |
| 2568 | * |
| 2569 | * @param extras The new extras. |
| 2570 | * @hide |
| 2571 | */ |
| 2572 | final void handleExtrasChanged(Bundle extras) { |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 2573 | Bundle b = null; |
| 2574 | synchronized (mExtrasLock) { |
| 2575 | mExtras = extras; |
| 2576 | if (mExtras != null) { |
| 2577 | b = new Bundle(mExtras); |
| 2578 | } |
| 2579 | } |
| 2580 | onExtrasChanged(b); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2581 | } |
| 2582 | |
| 2583 | /** |
Anthony Lee | 17455a3 | 2015-04-24 15:25:29 -0700 | [diff] [blame] | 2584 | * Notifies listeners that the merge request failed. |
| 2585 | * |
| 2586 | * @hide |
| 2587 | */ |
| 2588 | protected final void notifyConferenceMergeFailed() { |
| 2589 | for (Listener l : mListeners) { |
| 2590 | l.onConferenceMergeFailed(this); |
| 2591 | } |
| 2592 | } |
| 2593 | |
| 2594 | /** |
Tyler Gunn | ab4650c | 2014-11-06 20:06:23 -0800 | [diff] [blame] | 2595 | * Notifies listeners of a change to conference participant(s). |
Tyler Gunn | 3bffcf7 | 2014-10-28 13:51:27 -0700 | [diff] [blame] | 2596 | * |
Tyler Gunn | ab4650c | 2014-11-06 20:06:23 -0800 | [diff] [blame] | 2597 | * @param conferenceParticipants The participants. |
Tyler Gunn | 3bffcf7 | 2014-10-28 13:51:27 -0700 | [diff] [blame] | 2598 | * @hide |
| 2599 | */ |
Tyler Gunn | ab4650c | 2014-11-06 20:06:23 -0800 | [diff] [blame] | 2600 | protected final void updateConferenceParticipants( |
| 2601 | List<ConferenceParticipant> conferenceParticipants) { |
Tyler Gunn | 3bffcf7 | 2014-10-28 13:51:27 -0700 | [diff] [blame] | 2602 | for (Listener l : mListeners) { |
Tyler Gunn | ab4650c | 2014-11-06 20:06:23 -0800 | [diff] [blame] | 2603 | l.onConferenceParticipantsChanged(this, conferenceParticipants); |
Tyler Gunn | 3bffcf7 | 2014-10-28 13:51:27 -0700 | [diff] [blame] | 2604 | } |
| 2605 | } |
Tyler Gunn | 8a2b119 | 2015-01-29 11:47:24 -0800 | [diff] [blame] | 2606 | |
| 2607 | /** |
| 2608 | * Notifies listeners that a conference call has been started. |
Jay Shrauner | 55b9752 | 2015-04-09 15:15:43 -0700 | [diff] [blame] | 2609 | * @hide |
Tyler Gunn | 8a2b119 | 2015-01-29 11:47:24 -0800 | [diff] [blame] | 2610 | */ |
| 2611 | protected void notifyConferenceStarted() { |
| 2612 | for (Listener l : mListeners) { |
| 2613 | l.onConferenceStarted(); |
| 2614 | } |
| 2615 | } |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 2616 | |
| 2617 | /** |
Tyler Gunn | 7d633d3 | 2016-06-24 07:30:10 -0700 | [diff] [blame] | 2618 | * Notifies listeners when a change has occurred to the Connection which impacts its ability to |
| 2619 | * be a part of a conference call. |
| 2620 | * @param isConferenceSupported {@code true} if the connection supports being part of a |
| 2621 | * conference call, {@code false} otherwise. |
| 2622 | * @hide |
| 2623 | */ |
| 2624 | protected void notifyConferenceSupportedChanged(boolean isConferenceSupported) { |
| 2625 | for (Listener l : mListeners) { |
| 2626 | l.onConferenceSupportedChanged(this, isConferenceSupported); |
| 2627 | } |
| 2628 | } |
| 2629 | |
| 2630 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 2631 | * Sends an event associated with this {@code Connection} with associated event extras to the |
| 2632 | * {@link InCallService}. |
| 2633 | * <p> |
| 2634 | * Connection events are used to communicate point in time information from a |
| 2635 | * {@link ConnectionService} to a {@link InCallService} implementations. An example of a |
| 2636 | * custom connection event includes notifying the UI when a WIFI call has been handed over to |
| 2637 | * LTE, which the InCall UI might use to inform the user that billing charges may apply. The |
| 2638 | * Android Telephony framework will send the {@link #EVENT_CALL_MERGE_FAILED} connection event |
| 2639 | * when a call to {@link Call#mergeConference()} has failed to complete successfully. A |
| 2640 | * connection event could also be used to trigger UI in the {@link InCallService} which prompts |
| 2641 | * the user to make a choice (e.g. whether they want to incur roaming costs for making a call), |
| 2642 | * which is communicated back via {@link Call#sendCallEvent(String, Bundle)}. |
| 2643 | * <p> |
| 2644 | * Events are exposed to {@link InCallService} implementations via |
| 2645 | * {@link Call.Callback#onConnectionEvent(Call, String, Bundle)}. |
| 2646 | * <p> |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 2647 | * No assumptions should be made as to how an In-Call UI or service will handle these events. |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 2648 | * The {@link ConnectionService} must assume that the In-Call UI could even chose to ignore |
| 2649 | * some events altogether. |
| 2650 | * <p> |
| 2651 | * Events should be fully qualified (e.g. {@code com.example.event.MY_EVENT}) to avoid |
| 2652 | * conflicts between {@link ConnectionService} implementations. Further, custom |
| 2653 | * {@link ConnectionService} implementations shall not re-purpose events in the |
| 2654 | * {@code android.*} namespace, nor shall they define new event types in this namespace. When |
| 2655 | * defining a custom event type, ensure the contents of the extras {@link Bundle} is clearly |
| 2656 | * defined. Extra keys for this bundle should be named similar to the event type (e.g. |
| 2657 | * {@code com.example.extra.MY_EXTRA}). |
| 2658 | * <p> |
| 2659 | * When defining events and the associated extras, it is important to keep their behavior |
| 2660 | * consistent when the associated {@link ConnectionService} is updated. Support for deprecated |
| 2661 | * events/extras should me maintained to ensure backwards compatibility with older |
| 2662 | * {@link InCallService} implementations which were built to support the older behavior. |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 2663 | * |
| 2664 | * @param event The connection event. |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 2665 | * @param extras Optional bundle containing extra information associated with the event. |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 2666 | */ |
Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 2667 | public void sendConnectionEvent(String event, Bundle extras) { |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 2668 | for (Listener l : mListeners) { |
Tyler Gunn | a8fb8ab | 2016-03-29 10:24:22 -0700 | [diff] [blame] | 2669 | l.onConnectionEvent(this, event, extras); |
Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 2670 | } |
| 2671 | } |
Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2672 | } |