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