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