blob: 80eae14ff338ce14c7ab44aa0d75209677efe798 [file] [log] [blame]
Ihab Awad542e0ea2014-05-16 10:22:16 -07001/*
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 Gunnef9f6f92014-09-12 22:16:17 -070017package android.telecom;
Ihab Awad542e0ea2014-05-16 10:22:16 -070018
Tyler Gunn45382162015-05-06 08:52:27 -070019import com.android.internal.os.SomeArgs;
Tyler Gunnef9f6f92014-09-12 22:16:17 -070020import com.android.internal.telecom.IVideoCallback;
21import com.android.internal.telecom.IVideoProvider;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070022
Tyler Gunndee56a82016-03-23 16:06:34 -070023import android.annotation.NonNull;
Santos Cordon6b7f9552015-05-27 17:21:45 -070024import android.annotation.Nullable;
Yorke Lee4af59352015-05-13 14:14:54 -070025import android.annotation.SystemApi;
Mathew Inwood42346d12018-08-01 11:33:05 +010026import android.annotation.UnsupportedAppUsage;
Tyler Gunn159f35c2017-03-02 09:28:37 -080027import android.app.Notification;
Hall Liua98f58b52017-11-07 17:59:28 -080028import android.bluetooth.BluetoothDevice;
Tyler Gunn159f35c2017-03-02 09:28:37 -080029import android.content.Intent;
Tyler Gunnb702ef82015-05-29 11:51:53 -070030import android.hardware.camera2.CameraManager;
Ihab Awad542e0ea2014-05-16 10:22:16 -070031import android.net.Uri;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -080032import android.os.Binder;
Santos Cordon6b7f9552015-05-27 17:21:45 -070033import android.os.Bundle;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070034import android.os.Handler;
35import android.os.IBinder;
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -070036import android.os.Looper;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070037import android.os.Message;
Hall Liu95d55872017-01-25 17:12:49 -080038import android.os.ParcelFileDescriptor;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070039import android.os.RemoteException;
Tyler Gunn3fa819c2017-08-04 09:27:26 -070040import android.os.SystemClock;
Tyler Gunndee56a82016-03-23 16:06:34 -070041import android.util.ArraySet;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070042import android.view.Surface;
Ihab Awad542e0ea2014-05-16 10:22:16 -070043
Hall Liua549fed2018-02-09 16:40:03 -080044import java.io.FileInputStream;
45import java.io.FileOutputStream;
Hall Liu95d55872017-01-25 17:12:49 -080046import java.io.IOException;
47import java.io.InputStreamReader;
48import java.io.OutputStreamWriter;
Santos Cordonb6939982014-06-04 20:20:58 -070049import java.util.ArrayList;
Tyler Gunn071be6f2016-05-10 14:52:33 -070050import java.util.Arrays;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070051import java.util.Collections;
Santos Cordonb6939982014-06-04 20:20:58 -070052import java.util.List;
Ihab Awad542e0ea2014-05-16 10:22:16 -070053import java.util.Set;
Jay Shrauner229e3822014-08-15 09:23:07 -070054import java.util.concurrent.ConcurrentHashMap;
Ihab Awad542e0ea2014-05-16 10:22:16 -070055
56/**
Santos Cordon895d4b82015-06-25 16:41:48 -070057 * Represents a phone call or connection to a remote endpoint that carries voice and/or video
58 * traffic.
Ihab Awad6107bab2014-08-18 09:23:25 -070059 * <p>
60 * Implementations create a custom subclass of {@code Connection} and return it to the framework
61 * as the return value of
62 * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)}
63 * or
64 * {@link ConnectionService#onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
65 * Implementations are then responsible for updating the state of the {@code Connection}, and
66 * must call {@link #destroy()} to signal to the framework that the {@code Connection} is no
67 * longer used and associated resources may be recovered.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -070068 * <p>
69 * Subclasses of {@code Connection} override the {@code on*} methods to provide the the
70 * {@link ConnectionService}'s implementation of calling functionality. The {@code on*} methods are
71 * called by Telecom to inform an instance of a {@code Connection} of actions specific to that
72 * {@code Connection} instance.
73 * <p>
74 * Basic call support requires overriding the following methods: {@link #onAnswer()},
75 * {@link #onDisconnect()}, {@link #onReject()}, {@link #onAbort()}
76 * <p>
77 * Where a {@code Connection} has {@link #CAPABILITY_SUPPORT_HOLD}, the {@link #onHold()} and
78 * {@link #onUnhold()} methods should be overridden to provide hold support for the
79 * {@code Connection}.
80 * <p>
81 * Where a {@code Connection} supports a variation of video calling (e.g. the
82 * {@code CAPABILITY_SUPPORTS_VT_*} capability bits), {@link #onAnswer(int)} should be overridden
83 * to support answering a call as a video call.
84 * <p>
85 * Where a {@code Connection} has {@link #PROPERTY_IS_EXTERNAL_CALL} and
86 * {@link #CAPABILITY_CAN_PULL_CALL}, {@link #onPullExternalCall()} should be overridden to provide
87 * support for pulling the external call.
88 * <p>
89 * Where a {@code Connection} supports conference calling {@link #onSeparate()} should be
90 * overridden.
91 * <p>
92 * There are a number of other {@code on*} methods which a {@code Connection} can choose to
93 * implement, depending on whether it is concerned with the associated calls from Telecom. If,
94 * for example, call events from a {@link InCallService} are handled,
95 * {@link #onCallEvent(String, Bundle)} should be overridden. Another example is
96 * {@link #onExtrasChanged(Bundle)}, which should be overridden if the {@code Connection} wishes to
97 * make use of extra information provided via the {@link Call#putExtras(Bundle)} and
98 * {@link Call#removeExtras(String...)} methods.
Ihab Awad542e0ea2014-05-16 10:22:16 -070099 */
Yorke Leeabfcfdc2015-05-13 18:55:18 -0700100public abstract class Connection extends Conferenceable {
Ihab Awad542e0ea2014-05-16 10:22:16 -0700101
Santos Cordon895d4b82015-06-25 16:41:48 -0700102 /**
103 * The connection is initializing. This is generally the first state for a {@code Connection}
104 * returned by a {@link ConnectionService}.
105 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700106 public static final int STATE_INITIALIZING = 0;
107
Santos Cordon895d4b82015-06-25 16:41:48 -0700108 /**
109 * The connection is new and not connected.
110 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700111 public static final int STATE_NEW = 1;
112
Santos Cordon895d4b82015-06-25 16:41:48 -0700113 /**
114 * An incoming connection is in the ringing state. During this state, the user's ringer or
115 * vibration feature will be activated.
116 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700117 public static final int STATE_RINGING = 2;
118
Santos Cordon895d4b82015-06-25 16:41:48 -0700119 /**
120 * An outgoing connection is in the dialing state. In this state the other party has not yet
121 * answered the call and the user traditionally hears a ringback tone.
122 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700123 public static final int STATE_DIALING = 3;
124
Santos Cordon895d4b82015-06-25 16:41:48 -0700125 /**
126 * A connection is active. Both parties are connected to the call and can actively communicate.
127 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700128 public static final int STATE_ACTIVE = 4;
129
Santos Cordon895d4b82015-06-25 16:41:48 -0700130 /**
131 * A connection is on hold.
132 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700133 public static final int STATE_HOLDING = 5;
134
Santos Cordon895d4b82015-06-25 16:41:48 -0700135 /**
136 * A connection has been disconnected. This is the final state once the user has been
137 * disconnected from a call either locally, remotely or by an error in the service.
138 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700139 public static final int STATE_DISCONNECTED = 6;
140
Santos Cordon895d4b82015-06-25 16:41:48 -0700141 /**
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700142 * The state of an external connection which is in the process of being pulled from a remote
143 * device to the local device.
144 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -0700145 * A connection can only be in this state if the {@link #PROPERTY_IS_EXTERNAL_CALL} property and
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700146 * {@link #CAPABILITY_CAN_PULL_CALL} capability bits are set on the connection.
147 */
148 public static final int STATE_PULLING_CALL = 7;
149
150 /**
Santos Cordon895d4b82015-06-25 16:41:48 -0700151 * Connection can currently be put on hold or unheld. This is distinct from
152 * {@link #CAPABILITY_SUPPORT_HOLD} in that although a connection may support 'hold' most times,
153 * it does not at the moment support the function. This can be true while the call is in the
154 * state {@link #STATE_DIALING}, for example. During this condition, an in-call UI may
155 * display a disabled 'hold' button.
156 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800157 public static final int CAPABILITY_HOLD = 0x00000001;
158
159 /** Connection supports the hold feature. */
160 public static final int CAPABILITY_SUPPORT_HOLD = 0x00000002;
161
162 /**
163 * Connections within a conference can be merged. A {@link ConnectionService} has the option to
164 * add a {@link Conference} before the child {@link Connection}s are merged. This is how
165 * CDMA-based {@link Connection}s are implemented. For these unmerged {@link Conference}s, this
166 * capability allows a merge button to be shown while the conference is in the foreground
167 * of the in-call UI.
168 * <p>
169 * This is only intended for use by a {@link Conference}.
170 */
171 public static final int CAPABILITY_MERGE_CONFERENCE = 0x00000004;
172
173 /**
174 * Connections within a conference can be swapped between foreground and background.
175 * See {@link #CAPABILITY_MERGE_CONFERENCE} for additional information.
176 * <p>
177 * This is only intended for use by a {@link Conference}.
178 */
179 public static final int CAPABILITY_SWAP_CONFERENCE = 0x00000008;
180
181 /**
182 * @hide
183 */
184 public static final int CAPABILITY_UNUSED = 0x00000010;
185
186 /** Connection supports responding via text option. */
187 public static final int CAPABILITY_RESPOND_VIA_TEXT = 0x00000020;
188
189 /** Connection can be muted. */
190 public static final int CAPABILITY_MUTE = 0x00000040;
191
192 /**
193 * Connection supports conference management. This capability only applies to
194 * {@link Conference}s which can have {@link Connection}s as children.
195 */
196 public static final int CAPABILITY_MANAGE_CONFERENCE = 0x00000080;
197
198 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700199 * Local device supports receiving video.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800200 */
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700201 public static final int CAPABILITY_SUPPORTS_VT_LOCAL_RX = 0x00000100;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800202
203 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700204 * Local device supports transmitting video.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800205 */
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700206 public static final int CAPABILITY_SUPPORTS_VT_LOCAL_TX = 0x00000200;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800207
208 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700209 * Local device supports bidirectional video calling.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800210 */
Andrew Lee9a8f9ce2015-04-10 18:09:46 -0700211 public static final int CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL =
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700212 CAPABILITY_SUPPORTS_VT_LOCAL_RX | CAPABILITY_SUPPORTS_VT_LOCAL_TX;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800213
214 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700215 * Remote device supports receiving video.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800216 */
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700217 public static final int CAPABILITY_SUPPORTS_VT_REMOTE_RX = 0x00000400;
218
219 /**
220 * Remote device supports transmitting video.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700221 */
222 public static final int CAPABILITY_SUPPORTS_VT_REMOTE_TX = 0x00000800;
223
224 /**
225 * Remote device supports bidirectional video calling.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700226 */
Andrew Lee9a8f9ce2015-04-10 18:09:46 -0700227 public static final int CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL =
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700228 CAPABILITY_SUPPORTS_VT_REMOTE_RX | CAPABILITY_SUPPORTS_VT_REMOTE_TX;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800229
230 /**
231 * Connection is able to be separated from its parent {@code Conference}, if any.
232 */
233 public static final int CAPABILITY_SEPARATE_FROM_CONFERENCE = 0x00001000;
234
235 /**
236 * Connection is able to be individually disconnected when in a {@code Conference}.
237 */
238 public static final int CAPABILITY_DISCONNECT_FROM_CONFERENCE = 0x00002000;
239
240 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700241 * Un-used.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800242 * @hide
243 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700244 public static final int CAPABILITY_UNUSED_2 = 0x00004000;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800245
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700246 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700247 * Un-used.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700248 * @hide
249 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700250 public static final int CAPABILITY_UNUSED_3 = 0x00008000;
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700251
252 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700253 * Un-used.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700254 * @hide
255 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700256 public static final int CAPABILITY_UNUSED_4 = 0x00010000;
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700257
Tyler Gunn068085b2015-02-06 13:56:52 -0800258 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700259 * Un-used.
Tyler Gunn068085b2015-02-06 13:56:52 -0800260 * @hide
261 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700262 public static final int CAPABILITY_UNUSED_5 = 0x00020000;
Tyler Gunn068085b2015-02-06 13:56:52 -0800263
Tyler Gunn96d6c402015-03-18 12:39:23 -0700264 /**
Dong Zhou89f41eb2015-03-15 11:59:49 -0500265 * Speed up audio setup for MT call.
266 * @hide
Tyler Gunn96d6c402015-03-18 12:39:23 -0700267 */
268 public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00040000;
Tyler Gunn068085b2015-02-06 13:56:52 -0800269
Rekha Kumar07366812015-03-24 16:42:31 -0700270 /**
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700271 * Call can be upgraded to a video call.
Rekha Kumar07366812015-03-24 16:42:31 -0700272 */
273 public static final int CAPABILITY_CAN_UPGRADE_TO_VIDEO = 0x00080000;
274
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700275 /**
276 * For video calls, indicates whether the outgoing video for the call can be paused using
Yorke Lee32f24732015-05-12 16:18:03 -0700277 * the {@link android.telecom.VideoProfile#STATE_PAUSED} VideoState.
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700278 */
279 public static final int CAPABILITY_CAN_PAUSE_VIDEO = 0x00100000;
280
Tyler Gunnd4091732015-06-29 09:15:37 -0700281 /**
282 * For a conference, indicates the conference will not have child connections.
283 * <p>
284 * An example of a conference with child connections is a GSM conference call, where the radio
285 * retains connections to the individual participants of the conference. Another example is an
286 * IMS conference call where conference event package functionality is supported; in this case
287 * the conference server ensures the radio is aware of the participants in the conference, which
288 * are represented by child connections.
289 * <p>
290 * An example of a conference with no child connections is an IMS conference call with no
291 * conference event package support. Such a conference is represented by the radio as a single
292 * connection to the IMS conference server.
293 * <p>
294 * Indicating whether a conference has children or not is important to help user interfaces
295 * visually represent a conference. A conference with no children, for example, will have the
296 * conference connection shown in the list of calls on a Bluetooth device, where if the
297 * conference has children, only the children will be shown in the list of calls on a Bluetooth
298 * device.
299 * @hide
300 */
301 public static final int CAPABILITY_CONFERENCE_HAS_NO_CHILDREN = 0x00200000;
302
Bryce Lee81901682015-08-28 16:38:02 -0700303 /**
304 * Indicates that the connection itself wants to handle any sort of reply response, rather than
305 * relying on SMS.
Bryce Lee81901682015-08-28 16:38:02 -0700306 */
307 public static final int CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION = 0x00400000;
308
Tyler Gunnf97a0092016-01-19 15:59:34 -0800309 /**
310 * When set, prevents a video call from being downgraded to an audio-only call.
311 * <p>
312 * Should be set when the VideoState has the {@link VideoProfile#STATE_TX_ENABLED} or
313 * {@link VideoProfile#STATE_RX_ENABLED} bits set to indicate that the connection cannot be
314 * downgraded from a video call back to a VideoState of
315 * {@link VideoProfile#STATE_AUDIO_ONLY}.
316 * <p>
317 * Intuitively, a call which can be downgraded to audio should also have local and remote
318 * video
319 * capabilities (see {@link #CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL} and
320 * {@link #CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL}).
321 */
322 public static final int CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO = 0x00800000;
323
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700324 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700325 * When set for an external connection, indicates that this {@code Connection} can be pulled
326 * from a remote device to the current device.
327 * <p>
328 * Should only be set on a {@code Connection} where {@link #PROPERTY_IS_EXTERNAL_CALL}
329 * is set.
330 */
331 public static final int CAPABILITY_CAN_PULL_CALL = 0x01000000;
332
Pooja Jaind34698d2017-12-28 14:15:31 +0530333 /** Call supports the deflect feature. */
334 public static final int CAPABILITY_SUPPORT_DEFLECT = 0x02000000;
335
Tyler Gunn720c6642016-03-22 09:02:47 -0700336 //**********************************************************************************************
Pooja Jaind34698d2017-12-28 14:15:31 +0530337 // Next CAPABILITY value: 0x04000000
Tyler Gunn720c6642016-03-22 09:02:47 -0700338 //**********************************************************************************************
339
340 /**
341 * Indicates that the current device callback number should be shown.
342 *
343 * @hide
344 */
Hall Liu25c7c4d2016-08-30 13:41:02 -0700345 public static final int PROPERTY_EMERGENCY_CALLBACK_MODE = 1<<0;
Tyler Gunn720c6642016-03-22 09:02:47 -0700346
347 /**
348 * Whether the call is a generic conference, where we do not know the precise state of
349 * participants in the conference (eg. on CDMA).
350 *
351 * @hide
352 */
353 public static final int PROPERTY_GENERIC_CONFERENCE = 1<<1;
354
355 /**
356 * Connection is using high definition audio.
357 * @hide
358 */
359 public static final int PROPERTY_HIGH_DEF_AUDIO = 1<<2;
360
361 /**
362 * Connection is using WIFI.
363 * @hide
364 */
365 public static final int PROPERTY_WIFI = 1<<3;
366
367 /**
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700368 * When set, indicates that the {@code Connection} does not actually exist locally for the
369 * {@link ConnectionService}.
370 * <p>
371 * Consider, for example, a scenario where a user has two devices with the same phone number.
372 * When a user places a call on one devices, the telephony stack can represent that call on the
373 * other device by adding is to the {@link ConnectionService} with the
Tyler Gunn720c6642016-03-22 09:02:47 -0700374 * {@link #PROPERTY_IS_EXTERNAL_CALL} capability set.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700375 * <p>
376 * An {@link ConnectionService} should not assume that all {@link InCallService}s will handle
377 * external connections. Only those {@link InCallService}s which have the
378 * {@link TelecomManager#METADATA_INCLUDE_EXTERNAL_CALLS} metadata set to {@code true} in its
379 * manifest will see external connections.
380 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700381 public static final int PROPERTY_IS_EXTERNAL_CALL = 1<<4;
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700382
Brad Ebinger15847072016-05-18 11:08:36 -0700383 /**
384 * Indicates that the connection has CDMA Enhanced Voice Privacy enabled.
385 */
386 public static final int PROPERTY_HAS_CDMA_VOICE_PRIVACY = 1<<5;
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700387
Hall Liu9f332c72016-07-14 15:37:37 -0700388 /**
389 * Indicates that the connection represents a downgraded IMS conference.
390 * @hide
391 */
392 public static final int PROPERTY_IS_DOWNGRADED_CONFERENCE = 1<<6;
393
Tyler Gunnf5035432017-01-09 09:43:12 -0800394 /**
395 * Set by the framework to indicate that the {@link Connection} originated from a self-managed
396 * {@link ConnectionService}.
397 * <p>
398 * See {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.
399 */
400 public static final int PROPERTY_SELF_MANAGED = 1<<7;
401
Hall Liu95d55872017-01-25 17:12:49 -0800402 /**
Hall Liuffa4a812017-03-02 16:11:00 -0800403 * Set by the framework to indicate that a connection has an active RTT session associated with
404 * it.
Hall Liu95d55872017-01-25 17:12:49 -0800405 */
406 public static final int PROPERTY_IS_RTT = 1 << 8;
407
Eric Erfanian62706c52017-12-06 16:27:53 -0800408 /**
409 * Set by the framework to indicate that a connection is using assisted dialing.
Eric Erfaniandd2db2f2018-02-21 19:27:53 +0000410 * @hide
Eric Erfanian62706c52017-12-06 16:27:53 -0800411 */
412 public static final int PROPERTY_ASSISTED_DIALING_USED = 1 << 9;
413
Tyler Gunn96d6c402015-03-18 12:39:23 -0700414 //**********************************************************************************************
Eric Erfanian62706c52017-12-06 16:27:53 -0800415 // Next PROPERTY value: 1<<10
Tyler Gunn96d6c402015-03-18 12:39:23 -0700416 //**********************************************************************************************
Tyler Gunn068085b2015-02-06 13:56:52 -0800417
Tyler Gunn335ff2e2015-07-30 14:18:33 -0700418 /**
419 * Connection extra key used to store the last forwarded number associated with the current
420 * connection. Used to communicate to the user interface that the connection was forwarded via
421 * the specified number.
422 */
423 public static final String EXTRA_LAST_FORWARDED_NUMBER =
424 "android.telecom.extra.LAST_FORWARDED_NUMBER";
425
426 /**
427 * Connection extra key used to store a child number associated with the current connection.
428 * Used to communicate to the user interface that the connection was received via
429 * a child address (i.e. phone number) associated with the {@link PhoneAccount}'s primary
430 * address.
431 */
432 public static final String EXTRA_CHILD_ADDRESS = "android.telecom.extra.CHILD_ADDRESS";
433
434 /**
435 * Connection extra key used to store the subject for an incoming call. The user interface can
436 * query this extra and display its contents for incoming calls. Will only be used if the
437 * {@link PhoneAccount} supports the capability {@link PhoneAccount#CAPABILITY_CALL_SUBJECT}.
438 */
439 public static final String EXTRA_CALL_SUBJECT = "android.telecom.extra.CALL_SUBJECT";
440
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800441 /**
Tyler Gunn4b6614e2016-06-22 10:35:13 -0700442 * Boolean connection extra key set on a {@link Connection} in
443 * {@link Connection#STATE_RINGING} state to indicate that answering the call will cause the
444 * current active foreground call to be dropped.
445 */
446 public static final String EXTRA_ANSWERING_DROPS_FG_CALL =
447 "android.telecom.extra.ANSWERING_DROPS_FG_CALL";
448
449 /**
Tyler Gunn37653562017-03-13 18:15:15 -0700450 * String connection extra key set on a {@link Connection} in {@link Connection#STATE_RINGING}
451 * state to indicate the name of the third-party app which is responsible for the current
452 * foreground call.
453 * <p>
454 * Used when {@link #EXTRA_ANSWERING_DROPS_FG_CALL} is true to ensure that the default Phone app
455 * is able to inform the user that answering the new incoming call will cause a call owned by
456 * another app to be dropped when the incoming call is answered.
457 */
458 public static final String EXTRA_ANSWERING_DROPS_FG_CALL_APP_NAME =
459 "android.telecom.extra.ANSWERING_DROPS_FG_CALL_APP_NAME";
460
461 /**
Hall Liu10208662016-06-15 17:55:00 -0700462 * Boolean connection extra key on a {@link Connection} which indicates that adding an
Hall Liuee6e86b2016-07-06 16:32:43 -0700463 * additional call is disallowed.
Hall Liu10208662016-06-15 17:55:00 -0700464 * @hide
465 */
Hall Liuee6e86b2016-07-06 16:32:43 -0700466 public static final String EXTRA_DISABLE_ADD_CALL =
467 "android.telecom.extra.DISABLE_ADD_CALL";
Hall Liu10208662016-06-15 17:55:00 -0700468
469 /**
Tyler Gunncd6ccfd2016-10-17 15:48:19 -0700470 * String connection extra key on a {@link Connection} or {@link Conference} which contains the
471 * original Connection ID associated with the connection. Used in
472 * {@link RemoteConnectionService} to track the Connection ID which was originally assigned to a
473 * connection/conference added via
474 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)} and
475 * {@link ConnectionService#addConference(Conference)} APIs. This is important to pass to
476 * Telecom for when it deals with RemoteConnections. When the ConnectionManager wraps the
477 * {@link RemoteConnection} and {@link RemoteConference} and adds it to Telecom, there needs to
478 * be a way to ensure that we don't add the connection again as a duplicate.
479 * <p>
480 * For example, the TelephonyCS calls addExistingConnection for a Connection with ID
481 * {@code TelephonyCS@1}. The ConnectionManager learns of this via
482 * {@link ConnectionService#onRemoteExistingConnectionAdded(RemoteConnection)}, and wraps this
483 * in a new {@link Connection} which it adds to Telecom via
484 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)}. As part of
485 * this process, the wrapped RemoteConnection gets assigned a new ID (e.g. {@code ConnMan@1}).
486 * The TelephonyCS will ALSO try to add the existing connection to Telecom, except with the
487 * ID it originally referred to the connection as. Thus Telecom needs to know that the
488 * Connection with ID {@code ConnMan@1} is really the same as {@code TelephonyCS@1}.
489 * @hide
490 */
491 public static final String EXTRA_ORIGINAL_CONNECTION_ID =
492 "android.telecom.extra.ORIGINAL_CONNECTION_ID";
493
494 /**
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800495 * Connection event used to inform Telecom that it should play the on hold tone. This is used
496 * to play a tone when the peer puts the current call on hold. Sent to Telecom via
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700497 * {@link #sendConnectionEvent(String, Bundle)}.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800498 * @hide
499 */
500 public static final String EVENT_ON_HOLD_TONE_START =
501 "android.telecom.event.ON_HOLD_TONE_START";
502
503 /**
504 * Connection event used to inform Telecom that it should stop the on hold tone. This is used
505 * to stop a tone when the peer puts the current call on hold. Sent to Telecom via
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700506 * {@link #sendConnectionEvent(String, Bundle)}.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800507 * @hide
508 */
509 public static final String EVENT_ON_HOLD_TONE_END =
510 "android.telecom.event.ON_HOLD_TONE_END";
511
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700512 /**
513 * Connection event used to inform {@link InCallService}s when pulling of an external call has
514 * failed. The user interface should inform the user of the error.
515 * <p>
516 * Expected to be used by the {@link ConnectionService} when the {@link Call#pullExternalCall()}
517 * API is called on a {@link Call} with the properties
518 * {@link Call.Details#PROPERTY_IS_EXTERNAL_CALL} and
519 * {@link Call.Details#CAPABILITY_CAN_PULL_CALL}, but the {@link ConnectionService} could not
520 * pull the external call due to an error condition.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700521 * <p>
522 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
523 * expected to be null when this connection event is used.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700524 */
525 public static final String EVENT_CALL_PULL_FAILED = "android.telecom.event.CALL_PULL_FAILED";
526
Brad Ebinger2c1c16452016-05-27 15:58:10 -0700527 /**
528 * Connection event used to inform {@link InCallService}s when the merging of two calls has
529 * failed. The User Interface should use this message to inform the user of the error.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700530 * <p>
531 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
532 * expected to be null when this connection event is used.
Brad Ebinger2c1c16452016-05-27 15:58:10 -0700533 */
534 public static final String EVENT_CALL_MERGE_FAILED = "android.telecom.event.CALL_MERGE_FAILED";
535
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700536 /**
Tyler Gunn78da7812017-05-09 14:34:57 -0700537 * Connection event used to inform {@link InCallService}s when the process of merging a
538 * Connection into a conference has begun.
539 * <p>
540 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
541 * expected to be null when this connection event is used.
542 * @hide
543 */
544 public static final String EVENT_MERGE_START = "android.telecom.event.MERGE_START";
545
546 /**
547 * Connection event used to inform {@link InCallService}s when the process of merging a
548 * Connection into a conference has completed.
549 * <p>
550 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
551 * expected to be null when this connection event is used.
552 * @hide
553 */
554 public static final String EVENT_MERGE_COMPLETE = "android.telecom.event.MERGE_COMPLETE";
555
556 /**
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700557 * Connection event used to inform {@link InCallService}s when a call has been put on hold by
558 * the remote party.
559 * <p>
560 * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the
561 * call is being held locally on the device. When a capable {@link ConnectionService} receives
562 * signalling to indicate that the remote party has put the call on hold, it can send this
563 * connection event.
564 * @hide
565 */
566 public static final String EVENT_CALL_REMOTELY_HELD =
567 "android.telecom.event.CALL_REMOTELY_HELD";
568
569 /**
570 * Connection event used to inform {@link InCallService}s when a call which was remotely held
571 * (see {@link #EVENT_CALL_REMOTELY_HELD}) has been un-held by the remote party.
572 * <p>
573 * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the
574 * call is being held locally on the device. When a capable {@link ConnectionService} receives
575 * signalling to indicate that the remote party has taken the call off hold, it can send this
576 * connection event.
577 * @hide
578 */
579 public static final String EVENT_CALL_REMOTELY_UNHELD =
580 "android.telecom.event.CALL_REMOTELY_UNHELD";
581
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700582 /**
583 * Connection event used to inform an {@link InCallService} which initiated a call handover via
584 * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has
585 * successfully completed.
586 * @hide
Tyler Gunn1a505fa2018-09-14 13:36:38 -0700587 * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated
588 * APIs instead.
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700589 */
590 public static final String EVENT_HANDOVER_COMPLETE =
591 "android.telecom.event.HANDOVER_COMPLETE";
592
593 /**
594 * Connection event used to inform an {@link InCallService} which initiated a call handover via
595 * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has failed
596 * to complete.
597 * @hide
Tyler Gunn1a505fa2018-09-14 13:36:38 -0700598 * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated
599 * APIs instead.
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700600 */
601 public static final String EVENT_HANDOVER_FAILED =
602 "android.telecom.event.HANDOVER_FAILED";
603
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700604 // Flag controlling whether PII is emitted into the logs
605 private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG);
606
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800607 /**
608 * Whether the given capabilities support the specified capability.
609 *
610 * @param capabilities A capability bit field.
611 * @param capability The capability to check capabilities for.
612 * @return Whether the specified capability is supported.
613 * @hide
614 */
615 public static boolean can(int capabilities, int capability) {
Tyler Gunn014c7112015-12-18 14:33:57 -0800616 return (capabilities & capability) == capability;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800617 }
618
619 /**
620 * Whether the capabilities of this {@code Connection} supports the specified capability.
621 *
622 * @param capability The capability to check capabilities for.
623 * @return Whether the specified capability is supported.
624 * @hide
625 */
626 public boolean can(int capability) {
627 return can(mConnectionCapabilities, capability);
628 }
629
630 /**
631 * Removes the specified capability from the set of capabilities of this {@code Connection}.
632 *
633 * @param capability The capability to remove from the set.
634 * @hide
635 */
636 public void removeCapability(int capability) {
637 mConnectionCapabilities &= ~capability;
638 }
639
640 /**
641 * Adds the specified capability to the set of capabilities of this {@code Connection}.
642 *
643 * @param capability The capability to add to the set.
644 * @hide
645 */
646 public void addCapability(int capability) {
647 mConnectionCapabilities |= capability;
648 }
649
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700650 /**
651 * Renders a set of capability bits ({@code CAPABILITY_*}) as a human readable string.
652 *
653 * @param capabilities A capability bit field.
654 * @return A human readable string representation.
655 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800656 public static String capabilitiesToString(int capabilities) {
Santos Cordon1a749302016-07-26 16:08:53 -0700657 return capabilitiesToStringInternal(capabilities, true /* isLong */);
658 }
659
660 /**
661 * Renders a set of capability bits ({@code CAPABILITY_*}) as a *short* human readable
662 * string.
663 *
664 * @param capabilities A capability bit field.
665 * @return A human readable string representation.
666 * @hide
667 */
668 public static String capabilitiesToStringShort(int capabilities) {
669 return capabilitiesToStringInternal(capabilities, false /* isLong */);
670 }
671
672 private static String capabilitiesToStringInternal(int capabilities, boolean isLong) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800673 StringBuilder builder = new StringBuilder();
Santos Cordon1a749302016-07-26 16:08:53 -0700674 builder.append("[");
675 if (isLong) {
676 builder.append("Capabilities:");
677 }
678
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800679 if (can(capabilities, CAPABILITY_HOLD)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700680 builder.append(isLong ? " CAPABILITY_HOLD" : " hld");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800681 }
682 if (can(capabilities, CAPABILITY_SUPPORT_HOLD)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700683 builder.append(isLong ? " CAPABILITY_SUPPORT_HOLD" : " sup_hld");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800684 }
685 if (can(capabilities, CAPABILITY_MERGE_CONFERENCE)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700686 builder.append(isLong ? " CAPABILITY_MERGE_CONFERENCE" : " mrg_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800687 }
688 if (can(capabilities, CAPABILITY_SWAP_CONFERENCE)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700689 builder.append(isLong ? " CAPABILITY_SWAP_CONFERENCE" : " swp_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800690 }
691 if (can(capabilities, CAPABILITY_RESPOND_VIA_TEXT)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700692 builder.append(isLong ? " CAPABILITY_RESPOND_VIA_TEXT" : " txt");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800693 }
694 if (can(capabilities, CAPABILITY_MUTE)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700695 builder.append(isLong ? " CAPABILITY_MUTE" : " mut");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800696 }
697 if (can(capabilities, CAPABILITY_MANAGE_CONFERENCE)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700698 builder.append(isLong ? " CAPABILITY_MANAGE_CONFERENCE" : " mng_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800699 }
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700700 if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_RX)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700701 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_RX" : " VTlrx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700702 }
703 if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_TX)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700704 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_TX" : " VTltx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700705 }
Andrew Lee9a8f9ce2015-04-10 18:09:46 -0700706 if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700707 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL" : " VTlbi");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800708 }
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700709 if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_RX)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700710 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_RX" : " VTrrx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700711 }
712 if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_TX)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700713 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_TX" : " VTrtx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700714 }
Andrew Lee9a8f9ce2015-04-10 18:09:46 -0700715 if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700716 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL" : " VTrbi");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800717 }
Tyler Gunnf97a0092016-01-19 15:59:34 -0800718 if (can(capabilities, CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700719 builder.append(isLong ? " CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO" : " !v2a");
Tyler Gunnf97a0092016-01-19 15:59:34 -0800720 }
Dong Zhou89f41eb2015-03-15 11:59:49 -0500721 if (can(capabilities, CAPABILITY_SPEED_UP_MT_AUDIO)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700722 builder.append(isLong ? " CAPABILITY_SPEED_UP_MT_AUDIO" : " spd_aud");
Dong Zhou89f41eb2015-03-15 11:59:49 -0500723 }
Rekha Kumar07366812015-03-24 16:42:31 -0700724 if (can(capabilities, CAPABILITY_CAN_UPGRADE_TO_VIDEO)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700725 builder.append(isLong ? " CAPABILITY_CAN_UPGRADE_TO_VIDEO" : " a2v");
Rekha Kumar07366812015-03-24 16:42:31 -0700726 }
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700727 if (can(capabilities, CAPABILITY_CAN_PAUSE_VIDEO)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700728 builder.append(isLong ? " CAPABILITY_CAN_PAUSE_VIDEO" : " paus_VT");
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700729 }
Tyler Gunnd4091732015-06-29 09:15:37 -0700730 if (can(capabilities, CAPABILITY_CONFERENCE_HAS_NO_CHILDREN)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700731 builder.append(isLong ? " CAPABILITY_SINGLE_PARTY_CONFERENCE" : " 1p_cnf");
Tyler Gunnd4091732015-06-29 09:15:37 -0700732 }
Bryce Lee81901682015-08-28 16:38:02 -0700733 if (can(capabilities, CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700734 builder.append(isLong ? " CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION" : " rsp_by_con");
Bryce Lee81901682015-08-28 16:38:02 -0700735 }
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700736 if (can(capabilities, CAPABILITY_CAN_PULL_CALL)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700737 builder.append(isLong ? " CAPABILITY_CAN_PULL_CALL" : " pull");
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700738 }
Pooja Jaind34698d2017-12-28 14:15:31 +0530739 if (can(capabilities, CAPABILITY_SUPPORT_DEFLECT)) {
740 builder.append(isLong ? " CAPABILITY_SUPPORT_DEFLECT" : " sup_def");
741 }
Bryce Lee81901682015-08-28 16:38:02 -0700742
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800743 builder.append("]");
744 return builder.toString();
745 }
746
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700747 /**
748 * Renders a set of property bits ({@code PROPERTY_*}) as a human readable string.
749 *
750 * @param properties A property bit field.
751 * @return A human readable string representation.
752 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700753 public static String propertiesToString(int properties) {
Santos Cordon1a749302016-07-26 16:08:53 -0700754 return propertiesToStringInternal(properties, true /* isLong */);
755 }
756
757 /**
758 * Renders a set of property bits ({@code PROPERTY_*}) as a *short* human readable string.
759 *
760 * @param properties A property bit field.
761 * @return A human readable string representation.
762 * @hide
763 */
764 public static String propertiesToStringShort(int properties) {
765 return propertiesToStringInternal(properties, false /* isLong */);
766 }
767
768 private static String propertiesToStringInternal(int properties, boolean isLong) {
Tyler Gunn720c6642016-03-22 09:02:47 -0700769 StringBuilder builder = new StringBuilder();
Santos Cordon1a749302016-07-26 16:08:53 -0700770 builder.append("[");
771 if (isLong) {
772 builder.append("Properties:");
773 }
Tyler Gunn720c6642016-03-22 09:02:47 -0700774
Tyler Gunnf5035432017-01-09 09:43:12 -0800775 if (can(properties, PROPERTY_SELF_MANAGED)) {
776 builder.append(isLong ? " PROPERTY_SELF_MANAGED" : " self_mng");
777 }
778
Hall Liu25c7c4d2016-08-30 13:41:02 -0700779 if (can(properties, PROPERTY_EMERGENCY_CALLBACK_MODE)) {
780 builder.append(isLong ? " PROPERTY_EMERGENCY_CALLBACK_MODE" : " ecbm");
Tyler Gunn720c6642016-03-22 09:02:47 -0700781 }
782
783 if (can(properties, PROPERTY_HIGH_DEF_AUDIO)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700784 builder.append(isLong ? " PROPERTY_HIGH_DEF_AUDIO" : " HD");
Tyler Gunn720c6642016-03-22 09:02:47 -0700785 }
786
787 if (can(properties, PROPERTY_WIFI)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700788 builder.append(isLong ? " PROPERTY_WIFI" : " wifi");
Tyler Gunn720c6642016-03-22 09:02:47 -0700789 }
790
791 if (can(properties, PROPERTY_GENERIC_CONFERENCE)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700792 builder.append(isLong ? " PROPERTY_GENERIC_CONFERENCE" : " gen_conf");
Tyler Gunn720c6642016-03-22 09:02:47 -0700793 }
794
795 if (can(properties, PROPERTY_IS_EXTERNAL_CALL)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700796 builder.append(isLong ? " PROPERTY_IS_EXTERNAL_CALL" : " xtrnl");
Tyler Gunn720c6642016-03-22 09:02:47 -0700797 }
798
Brad Ebinger15847072016-05-18 11:08:36 -0700799 if (can(properties, PROPERTY_HAS_CDMA_VOICE_PRIVACY)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700800 builder.append(isLong ? " PROPERTY_HAS_CDMA_VOICE_PRIVACY" : " priv");
Brad Ebinger15847072016-05-18 11:08:36 -0700801 }
802
Hall Liud4d2a8a2018-01-29 17:22:02 -0800803 if (can(properties, PROPERTY_IS_RTT)) {
804 builder.append(isLong ? " PROPERTY_IS_RTT" : " rtt");
805 }
806
Tyler Gunn720c6642016-03-22 09:02:47 -0700807 builder.append("]");
808 return builder.toString();
809 }
810
Sailesh Nepal091768c2014-06-30 15:15:23 -0700811 /** @hide */
Sailesh Nepal61203862014-07-11 14:50:13 -0700812 public abstract static class Listener {
Ihab Awad542e0ea2014-05-16 10:22:16 -0700813 public void onStateChanged(Connection c, int state) {}
Andrew Lee100e2932014-09-08 15:34:24 -0700814 public void onAddressChanged(Connection c, Uri newAddress, int presentation) {}
Sailesh Nepal61203862014-07-11 14:50:13 -0700815 public void onCallerDisplayNameChanged(
816 Connection c, String callerDisplayName, int presentation) {}
Tyler Gunnaa07df82014-07-17 07:50:22 -0700817 public void onVideoStateChanged(Connection c, int videoState) {}
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700818 public void onDisconnected(Connection c, DisconnectCause disconnectCause) {}
Sailesh Nepal091768c2014-06-30 15:15:23 -0700819 public void onPostDialWait(Connection c, String remaining) {}
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800820 public void onPostDialChar(Connection c, char nextChar) {}
Andrew Lee100e2932014-09-08 15:34:24 -0700821 public void onRingbackRequested(Connection c, boolean ringback) {}
Sailesh Nepal61203862014-07-11 14:50:13 -0700822 public void onDestroyed(Connection c) {}
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800823 public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {}
Tyler Gunn720c6642016-03-22 09:02:47 -0700824 public void onConnectionPropertiesChanged(Connection c, int properties) {}
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800825 public void onSupportedAudioRoutesChanged(Connection c, int supportedAudioRoutes) {}
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700826 public void onVideoProviderChanged(
827 Connection c, VideoProvider videoProvider) {}
Sailesh Nepal001bbbb2014-07-15 14:40:39 -0700828 public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {}
829 public void onStatusHintsChanged(Connection c, StatusHints statusHints) {}
Tyler Gunn6d76ca02014-11-17 15:49:51 -0800830 public void onConferenceablesChanged(
Tyler Gunndf2cbc82015-04-20 09:13:01 -0700831 Connection c, List<Conferenceable> conferenceables) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -0700832 public void onConferenceChanged(Connection c, Conference conference) {}
Tyler Gunn3bffcf72014-10-28 13:51:27 -0700833 /** @hide */
Tyler Gunnab4650c2014-11-06 20:06:23 -0800834 public void onConferenceParticipantsChanged(Connection c,
835 List<ConferenceParticipant> participants) {}
Tyler Gunn8a2b1192015-01-29 11:47:24 -0800836 public void onConferenceStarted() {}
Anthony Lee17455a32015-04-24 15:25:29 -0700837 public void onConferenceMergeFailed(Connection c) {}
Santos Cordon6b7f9552015-05-27 17:21:45 -0700838 public void onExtrasChanged(Connection c, Bundle extras) {}
Tyler Gunndee56a82016-03-23 16:06:34 -0700839 public void onExtrasRemoved(Connection c, List<String> keys) {}
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700840 public void onConnectionEvent(Connection c, String event, Bundle extras) {}
Tyler Gunn7d633d32016-06-24 07:30:10 -0700841 /** @hide */
842 public void onConferenceSupportedChanged(Connection c, boolean isConferenceSupported) {}
Hall Liua98f58b52017-11-07 17:59:28 -0800843 public void onAudioRouteChanged(Connection c, int audioRoute, String bluetoothAddress) {}
Hall Liub64ac4c2017-02-06 10:49:48 -0800844 public void onRttInitiationSuccess(Connection c) {}
845 public void onRttInitiationFailure(Connection c, int reason) {}
846 public void onRttSessionRemotelyTerminated(Connection c) {}
847 public void onRemoteRttRequest(Connection c) {}
Srikanth Chintalafcb15012017-05-04 20:58:34 +0530848 /** @hide */
849 public void onPhoneAccountChanged(Connection c, PhoneAccountHandle pHandle) {}
Mengjun Leng25707742017-07-04 11:10:37 +0800850 public void onConnectionTimeReset(Connection c) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -0700851 }
852
Tyler Gunnb702ef82015-05-29 11:51:53 -0700853 /**
Hall Liu95d55872017-01-25 17:12:49 -0800854 * Provides methods to read and write RTT data to/from the in-call app.
Hall Liu95d55872017-01-25 17:12:49 -0800855 */
856 public static final class RttTextStream {
857 private static final int READ_BUFFER_SIZE = 1000;
858 private final InputStreamReader mPipeFromInCall;
859 private final OutputStreamWriter mPipeToInCall;
Hall Liub64ac4c2017-02-06 10:49:48 -0800860 private final ParcelFileDescriptor mFdFromInCall;
861 private final ParcelFileDescriptor mFdToInCall;
Hall Liu95d55872017-01-25 17:12:49 -0800862 private char[] mReadBuffer = new char[READ_BUFFER_SIZE];
863
864 /**
865 * @hide
866 */
867 public RttTextStream(ParcelFileDescriptor toInCall, ParcelFileDescriptor fromInCall) {
Hall Liub64ac4c2017-02-06 10:49:48 -0800868 mFdFromInCall = fromInCall;
869 mFdToInCall = toInCall;
Hall Liu95d55872017-01-25 17:12:49 -0800870 mPipeFromInCall = new InputStreamReader(
Hall Liua549fed2018-02-09 16:40:03 -0800871 new FileInputStream(fromInCall.getFileDescriptor()));
Hall Liu95d55872017-01-25 17:12:49 -0800872 mPipeToInCall = new OutputStreamWriter(
Hall Liua549fed2018-02-09 16:40:03 -0800873 new FileOutputStream(toInCall.getFileDescriptor()));
Hall Liu95d55872017-01-25 17:12:49 -0800874 }
875
876 /**
877 * Writes the string {@param input} into the text stream to the UI for this RTT call. Since
878 * RTT transmits text in real-time, this method should be called as often as text snippets
879 * are received from the remote user, even if it is only one character.
Hall Liua549fed2018-02-09 16:40:03 -0800880 * <p>
Hall Liu95d55872017-01-25 17:12:49 -0800881 * This method is not thread-safe -- calling it from multiple threads simultaneously may
882 * lead to interleaved text.
Hall Liua549fed2018-02-09 16:40:03 -0800883 *
Hall Liu95d55872017-01-25 17:12:49 -0800884 * @param input The message to send to the in-call app.
885 */
886 public void write(String input) throws IOException {
887 mPipeToInCall.write(input);
888 mPipeToInCall.flush();
889 }
890
891
892 /**
893 * Reads a string from the in-call app, blocking if there is no data available. Returns
894 * {@code null} if the RTT conversation has been terminated and there is no further data
895 * to read.
Hall Liua549fed2018-02-09 16:40:03 -0800896 * <p>
Hall Liu95d55872017-01-25 17:12:49 -0800897 * This method is not thread-safe -- calling it from multiple threads simultaneously may
898 * lead to interleaved text.
Hall Liua549fed2018-02-09 16:40:03 -0800899 *
Hall Liu95d55872017-01-25 17:12:49 -0800900 * @return A string containing text entered by the user, or {@code null} if the
901 * conversation has been terminated or if there was an error while reading.
902 */
Hall Liuffa4a812017-03-02 16:11:00 -0800903 public String read() throws IOException {
904 int numRead = mPipeFromInCall.read(mReadBuffer, 0, READ_BUFFER_SIZE);
905 if (numRead < 0) {
906 return null;
907 }
908 return new String(mReadBuffer, 0, numRead);
909 }
910
911 /**
912 * Non-blocking version of {@link #read()}. Returns {@code null} if there is nothing to
913 * be read.
Hall Liua549fed2018-02-09 16:40:03 -0800914 *
Hall Liuffa4a812017-03-02 16:11:00 -0800915 * @return A string containing text entered by the user, or {@code null} if the user has
916 * not entered any new text yet.
917 */
918 public String readImmediately() throws IOException {
919 if (mPipeFromInCall.ready()) {
920 return read();
921 } else {
Hall Liu95d55872017-01-25 17:12:49 -0800922 return null;
923 }
924 }
Hall Liub64ac4c2017-02-06 10:49:48 -0800925
926 /** @hide */
927 public ParcelFileDescriptor getFdFromInCall() {
928 return mFdFromInCall;
929 }
930
931 /** @hide */
932 public ParcelFileDescriptor getFdToInCall() {
933 return mFdToInCall;
934 }
935 }
936
937 /**
938 * Provides constants to represent the results of responses to session modify requests sent via
939 * {@link Call#sendRttRequest()}
940 */
941 public static final class RttModifyStatus {
Hall Liu8dd49082017-04-21 14:33:12 -0700942 private RttModifyStatus() {}
Hall Liub64ac4c2017-02-06 10:49:48 -0800943 /**
944 * Session modify request was successful.
945 */
946 public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1;
947
948 /**
949 * Session modify request failed.
950 */
951 public static final int SESSION_MODIFY_REQUEST_FAIL = 2;
952
953 /**
954 * Session modify request ignored due to invalid parameters.
955 */
956 public static final int SESSION_MODIFY_REQUEST_INVALID = 3;
957
958 /**
959 * Session modify request timed out.
960 */
961 public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4;
962
963 /**
964 * Session modify request rejected by remote user.
965 */
966 public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5;
Hall Liu95d55872017-01-25 17:12:49 -0800967 }
968
969 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700970 * Provides a means of controlling the video session associated with a {@link Connection}.
971 * <p>
972 * Implementations create a custom subclass of {@link VideoProvider} and the
973 * {@link ConnectionService} creates an instance sets it on the {@link Connection} using
974 * {@link Connection#setVideoProvider(VideoProvider)}. Any connection which supports video
975 * should set the {@link VideoProvider}.
976 * <p>
977 * The {@link VideoProvider} serves two primary purposes: it provides a means for Telecom and
978 * {@link InCallService} implementations to issue requests related to the video session;
979 * it provides a means for the {@link ConnectionService} to report events and information
980 * related to the video session to Telecom and the {@link InCallService} implementations.
981 * <p>
982 * {@link InCallService} implementations interact with the {@link VideoProvider} via
983 * {@link android.telecom.InCallService.VideoCall}.
984 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700985 public static abstract class VideoProvider {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700986 /**
987 * Video is not being received (no protocol pause was issued).
Tyler Gunnb702ef82015-05-29 11:51:53 -0700988 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700989 */
990 public static final int SESSION_EVENT_RX_PAUSE = 1;
Evan Charltonbf11f982014-07-20 22:06:28 -0700991
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700992 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700993 * Video reception has resumed after a {@link #SESSION_EVENT_RX_PAUSE}.
994 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700995 */
996 public static final int SESSION_EVENT_RX_RESUME = 2;
997
998 /**
999 * Video transmission has begun. This occurs after a negotiated start of video transmission
1000 * when the underlying protocol has actually begun transmitting video to the remote party.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001001 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001002 */
1003 public static final int SESSION_EVENT_TX_START = 3;
1004
1005 /**
1006 * Video transmission has stopped. This occurs after a negotiated stop of video transmission
1007 * when the underlying protocol has actually stopped transmitting video to the remote party.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001008 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001009 */
1010 public static final int SESSION_EVENT_TX_STOP = 4;
1011
1012 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001013 * A camera failure has occurred for the selected camera. The {@link VideoProvider} can use
Tyler Gunnb702ef82015-05-29 11:51:53 -07001014 * this as a cue to inform the user the camera is not available.
1015 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001016 */
1017 public static final int SESSION_EVENT_CAMERA_FAILURE = 5;
1018
1019 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001020 * Issued after {@link #SESSION_EVENT_CAMERA_FAILURE} when the camera is once again ready
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001021 * for operation. The {@link VideoProvider} can use this as a cue to inform the user that
Tyler Gunnb702ef82015-05-29 11:51:53 -07001022 * the camera has become available again.
1023 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001024 */
1025 public static final int SESSION_EVENT_CAMERA_READY = 6;
1026
1027 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001028 * Session event raised by Telecom when
1029 * {@link android.telecom.InCallService.VideoCall#setCamera(String)} is called and the
1030 * caller does not have the necessary {@link android.Manifest.permission#CAMERA} permission.
1031 * @see #handleCallSessionEvent(int)
1032 */
1033 public static final int SESSION_EVENT_CAMERA_PERMISSION_ERROR = 7;
1034
1035 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001036 * Session modify request was successful.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001037 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001038 */
1039 public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1;
1040
1041 /**
1042 * Session modify request failed.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001043 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001044 */
1045 public static final int SESSION_MODIFY_REQUEST_FAIL = 2;
1046
1047 /**
1048 * Session modify request ignored due to invalid parameters.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001049 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001050 */
1051 public static final int SESSION_MODIFY_REQUEST_INVALID = 3;
1052
Rekha Kumar07366812015-03-24 16:42:31 -07001053 /**
1054 * Session modify request timed out.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001055 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Rekha Kumar07366812015-03-24 16:42:31 -07001056 */
1057 public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4;
1058
1059 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001060 * Session modify request rejected by remote user.
1061 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Rekha Kumar07366812015-03-24 16:42:31 -07001062 */
1063 public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5;
1064
Tyler Gunn75958422015-04-15 14:23:42 -07001065 private static final int MSG_ADD_VIDEO_CALLBACK = 1;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001066 private static final int MSG_SET_CAMERA = 2;
1067 private static final int MSG_SET_PREVIEW_SURFACE = 3;
1068 private static final int MSG_SET_DISPLAY_SURFACE = 4;
1069 private static final int MSG_SET_DEVICE_ORIENTATION = 5;
1070 private static final int MSG_SET_ZOOM = 6;
1071 private static final int MSG_SEND_SESSION_MODIFY_REQUEST = 7;
1072 private static final int MSG_SEND_SESSION_MODIFY_RESPONSE = 8;
1073 private static final int MSG_REQUEST_CAMERA_CAPABILITIES = 9;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001074 private static final int MSG_REQUEST_CONNECTION_DATA_USAGE = 10;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001075 private static final int MSG_SET_PAUSE_IMAGE = 11;
Tyler Gunn75958422015-04-15 14:23:42 -07001076 private static final int MSG_REMOVE_VIDEO_CALLBACK = 12;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001077
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001078 private static final String SESSION_EVENT_RX_PAUSE_STR = "RX_PAUSE";
1079 private static final String SESSION_EVENT_RX_RESUME_STR = "RX_RESUME";
1080 private static final String SESSION_EVENT_TX_START_STR = "TX_START";
1081 private static final String SESSION_EVENT_TX_STOP_STR = "TX_STOP";
1082 private static final String SESSION_EVENT_CAMERA_FAILURE_STR = "CAMERA_FAIL";
1083 private static final String SESSION_EVENT_CAMERA_READY_STR = "CAMERA_READY";
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001084 private static final String SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR =
1085 "CAMERA_PERMISSION_ERROR";
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001086 private static final String SESSION_EVENT_UNKNOWN_STR = "UNKNOWN";
1087
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001088 private VideoProvider.VideoProviderHandler mMessageHandler;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001089 private final VideoProvider.VideoProviderBinder mBinder;
Tyler Gunn75958422015-04-15 14:23:42 -07001090
1091 /**
1092 * Stores a list of the video callbacks, keyed by IBinder.
Tyler Gunn84f381b2015-06-12 09:26:45 -07001093 *
1094 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
1095 * load factor before resizing, 1 means we only expect a single thread to
1096 * access the map so make only a single shard
Tyler Gunn75958422015-04-15 14:23:42 -07001097 */
Tyler Gunn84f381b2015-06-12 09:26:45 -07001098 private ConcurrentHashMap<IBinder, IVideoCallback> mVideoCallbacks =
1099 new ConcurrentHashMap<IBinder, IVideoCallback>(8, 0.9f, 1);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001100
1101 /**
1102 * Default handler used to consolidate binder method calls onto a single thread.
1103 */
1104 private final class VideoProviderHandler extends Handler {
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001105 public VideoProviderHandler() {
1106 super();
1107 }
1108
1109 public VideoProviderHandler(Looper looper) {
1110 super(looper);
1111 }
1112
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001113 @Override
1114 public void handleMessage(Message msg) {
1115 switch (msg.what) {
Tyler Gunn75958422015-04-15 14:23:42 -07001116 case MSG_ADD_VIDEO_CALLBACK: {
1117 IBinder binder = (IBinder) msg.obj;
1118 IVideoCallback callback = IVideoCallback.Stub
1119 .asInterface((IBinder) msg.obj);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001120 if (callback == null) {
1121 Log.w(this, "addVideoProvider - skipped; callback is null.");
1122 break;
1123 }
1124
Tyler Gunn75958422015-04-15 14:23:42 -07001125 if (mVideoCallbacks.containsKey(binder)) {
1126 Log.i(this, "addVideoProvider - skipped; already present.");
1127 break;
1128 }
1129 mVideoCallbacks.put(binder, callback);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001130 break;
Tyler Gunn75958422015-04-15 14:23:42 -07001131 }
1132 case MSG_REMOVE_VIDEO_CALLBACK: {
1133 IBinder binder = (IBinder) msg.obj;
1134 IVideoCallback callback = IVideoCallback.Stub
1135 .asInterface((IBinder) msg.obj);
1136 if (!mVideoCallbacks.containsKey(binder)) {
1137 Log.i(this, "removeVideoProvider - skipped; not present.");
1138 break;
1139 }
1140 mVideoCallbacks.remove(binder);
1141 break;
1142 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001143 case MSG_SET_CAMERA:
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001144 {
1145 SomeArgs args = (SomeArgs) msg.obj;
1146 try {
1147 onSetCamera((String) args.arg1);
1148 onSetCamera((String) args.arg1, (String) args.arg2, args.argi1,
Tyler Gunn159f35c2017-03-02 09:28:37 -08001149 args.argi2, args.argi3);
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001150 } finally {
1151 args.recycle();
1152 }
1153 }
1154 break;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001155 case MSG_SET_PREVIEW_SURFACE:
1156 onSetPreviewSurface((Surface) msg.obj);
1157 break;
1158 case MSG_SET_DISPLAY_SURFACE:
1159 onSetDisplaySurface((Surface) msg.obj);
1160 break;
1161 case MSG_SET_DEVICE_ORIENTATION:
1162 onSetDeviceOrientation(msg.arg1);
1163 break;
1164 case MSG_SET_ZOOM:
1165 onSetZoom((Float) msg.obj);
1166 break;
Tyler Gunn45382162015-05-06 08:52:27 -07001167 case MSG_SEND_SESSION_MODIFY_REQUEST: {
1168 SomeArgs args = (SomeArgs) msg.obj;
1169 try {
1170 onSendSessionModifyRequest((VideoProfile) args.arg1,
1171 (VideoProfile) args.arg2);
1172 } finally {
1173 args.recycle();
1174 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001175 break;
Tyler Gunn45382162015-05-06 08:52:27 -07001176 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001177 case MSG_SEND_SESSION_MODIFY_RESPONSE:
1178 onSendSessionModifyResponse((VideoProfile) msg.obj);
1179 break;
1180 case MSG_REQUEST_CAMERA_CAPABILITIES:
1181 onRequestCameraCapabilities();
1182 break;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001183 case MSG_REQUEST_CONNECTION_DATA_USAGE:
1184 onRequestConnectionDataUsage();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001185 break;
1186 case MSG_SET_PAUSE_IMAGE:
Yorke Lee32f24732015-05-12 16:18:03 -07001187 onSetPauseImage((Uri) msg.obj);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001188 break;
1189 default:
1190 break;
1191 }
1192 }
1193 }
1194
1195 /**
1196 * IVideoProvider stub implementation.
1197 */
1198 private final class VideoProviderBinder extends IVideoProvider.Stub {
Tyler Gunn75958422015-04-15 14:23:42 -07001199 public void addVideoCallback(IBinder videoCallbackBinder) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001200 mMessageHandler.obtainMessage(
Tyler Gunn75958422015-04-15 14:23:42 -07001201 MSG_ADD_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget();
1202 }
1203
1204 public void removeVideoCallback(IBinder videoCallbackBinder) {
1205 mMessageHandler.obtainMessage(
1206 MSG_REMOVE_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001207 }
1208
Tyler Gunn159f35c2017-03-02 09:28:37 -08001209 public void setCamera(String cameraId, String callingPackageName,
1210 int targetSdkVersion) {
1211
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001212 SomeArgs args = SomeArgs.obtain();
1213 args.arg1 = cameraId;
1214 // Propagate the calling package; originally determined in
1215 // android.telecom.InCallService.VideoCall#setCamera(String) from the calling
1216 // process.
1217 args.arg2 = callingPackageName;
1218 // Pass along the uid and pid of the calling app; this gets lost when we put the
1219 // message onto the handler. These are required for Telecom to perform a permission
1220 // check to see if the calling app is able to use the camera.
1221 args.argi1 = Binder.getCallingUid();
1222 args.argi2 = Binder.getCallingPid();
Tyler Gunn159f35c2017-03-02 09:28:37 -08001223 // Pass along the target SDK version of the calling InCallService. This is used to
1224 // maintain backwards compatibility of the API for older callers.
1225 args.argi3 = targetSdkVersion;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001226 mMessageHandler.obtainMessage(MSG_SET_CAMERA, args).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001227 }
1228
1229 public void setPreviewSurface(Surface surface) {
1230 mMessageHandler.obtainMessage(MSG_SET_PREVIEW_SURFACE, surface).sendToTarget();
1231 }
1232
1233 public void setDisplaySurface(Surface surface) {
1234 mMessageHandler.obtainMessage(MSG_SET_DISPLAY_SURFACE, surface).sendToTarget();
1235 }
1236
1237 public void setDeviceOrientation(int rotation) {
Rekha Kumar07366812015-03-24 16:42:31 -07001238 mMessageHandler.obtainMessage(
1239 MSG_SET_DEVICE_ORIENTATION, rotation, 0).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001240 }
1241
1242 public void setZoom(float value) {
1243 mMessageHandler.obtainMessage(MSG_SET_ZOOM, value).sendToTarget();
1244 }
1245
Tyler Gunn45382162015-05-06 08:52:27 -07001246 public void sendSessionModifyRequest(VideoProfile fromProfile, VideoProfile toProfile) {
1247 SomeArgs args = SomeArgs.obtain();
1248 args.arg1 = fromProfile;
1249 args.arg2 = toProfile;
1250 mMessageHandler.obtainMessage(MSG_SEND_SESSION_MODIFY_REQUEST, args).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001251 }
1252
1253 public void sendSessionModifyResponse(VideoProfile responseProfile) {
1254 mMessageHandler.obtainMessage(
1255 MSG_SEND_SESSION_MODIFY_RESPONSE, responseProfile).sendToTarget();
1256 }
1257
1258 public void requestCameraCapabilities() {
1259 mMessageHandler.obtainMessage(MSG_REQUEST_CAMERA_CAPABILITIES).sendToTarget();
1260 }
1261
1262 public void requestCallDataUsage() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001263 mMessageHandler.obtainMessage(MSG_REQUEST_CONNECTION_DATA_USAGE).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001264 }
1265
Yorke Lee32f24732015-05-12 16:18:03 -07001266 public void setPauseImage(Uri uri) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001267 mMessageHandler.obtainMessage(MSG_SET_PAUSE_IMAGE, uri).sendToTarget();
1268 }
1269 }
1270
1271 public VideoProvider() {
1272 mBinder = new VideoProvider.VideoProviderBinder();
Tyler Gunn84f381b2015-06-12 09:26:45 -07001273 mMessageHandler = new VideoProvider.VideoProviderHandler(Looper.getMainLooper());
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001274 }
1275
1276 /**
1277 * Creates an instance of the {@link VideoProvider}, specifying the looper to use.
1278 *
1279 * @param looper The looper.
1280 * @hide
1281 */
Mathew Inwood42346d12018-08-01 11:33:05 +01001282 @UnsupportedAppUsage
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001283 public VideoProvider(Looper looper) {
1284 mBinder = new VideoProvider.VideoProviderBinder();
1285 mMessageHandler = new VideoProvider.VideoProviderHandler(looper);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001286 }
1287
1288 /**
1289 * Returns binder object which can be used across IPC methods.
1290 * @hide
1291 */
1292 public final IVideoProvider getInterface() {
1293 return mBinder;
1294 }
1295
1296 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001297 * Sets the camera to be used for the outgoing video.
1298 * <p>
1299 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1300 * camera via
1301 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1302 * <p>
1303 * Sent from the {@link InCallService} via
1304 * {@link InCallService.VideoCall#setCamera(String)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001305 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001306 * @param cameraId The id of the camera (use ids as reported by
1307 * {@link CameraManager#getCameraIdList()}).
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001308 */
1309 public abstract void onSetCamera(String cameraId);
1310
1311 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001312 * Sets the camera to be used for the outgoing video.
1313 * <p>
1314 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1315 * camera via
1316 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1317 * <p>
1318 * This prototype is used internally to ensure that the calling package name, UID and PID
1319 * are sent to Telecom so that can perform a camera permission check on the caller.
1320 * <p>
1321 * Sent from the {@link InCallService} via
1322 * {@link InCallService.VideoCall#setCamera(String)}.
1323 *
1324 * @param cameraId The id of the camera (use ids as reported by
1325 * {@link CameraManager#getCameraIdList()}).
1326 * @param callingPackageName The AppOpps package name of the caller.
1327 * @param callingUid The UID of the caller.
1328 * @param callingPid The PID of the caller.
Tyler Gunn159f35c2017-03-02 09:28:37 -08001329 * @param targetSdkVersion The target SDK version of the caller.
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001330 * @hide
1331 */
1332 public void onSetCamera(String cameraId, String callingPackageName, int callingUid,
Tyler Gunn159f35c2017-03-02 09:28:37 -08001333 int callingPid, int targetSdkVersion) {}
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001334
1335 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001336 * Sets the surface to be used for displaying a preview of what the user's camera is
1337 * currently capturing. When video transmission is enabled, this is the video signal which
1338 * is sent to the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001339 * <p>
1340 * Sent from the {@link InCallService} via
1341 * {@link InCallService.VideoCall#setPreviewSurface(Surface)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001342 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001343 * @param surface The {@link Surface}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001344 */
1345 public abstract void onSetPreviewSurface(Surface surface);
1346
1347 /**
1348 * Sets the surface to be used for displaying the video received from the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001349 * <p>
1350 * Sent from the {@link InCallService} via
1351 * {@link InCallService.VideoCall#setDisplaySurface(Surface)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001352 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001353 * @param surface The {@link Surface}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001354 */
1355 public abstract void onSetDisplaySurface(Surface surface);
1356
1357 /**
1358 * Sets the device orientation, in degrees. Assumes that a standard portrait orientation of
1359 * the device is 0 degrees.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001360 * <p>
1361 * Sent from the {@link InCallService} via
1362 * {@link InCallService.VideoCall#setDeviceOrientation(int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001363 *
1364 * @param rotation The device orientation, in degrees.
1365 */
1366 public abstract void onSetDeviceOrientation(int rotation);
1367
1368 /**
1369 * Sets camera zoom ratio.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001370 * <p>
1371 * Sent from the {@link InCallService} via {@link InCallService.VideoCall#setZoom(float)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001372 *
1373 * @param value The camera zoom ratio.
1374 */
1375 public abstract void onSetZoom(float value);
1376
1377 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001378 * Issues a request to modify the properties of the current video session.
1379 * <p>
1380 * Example scenarios include: requesting an audio-only call to be upgraded to a
1381 * bi-directional video call, turning on or off the user's camera, sending a pause signal
1382 * when the {@link InCallService} is no longer the foreground application.
1383 * <p>
1384 * If the {@link VideoProvider} determines a request to be invalid, it should call
1385 * {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)} to report the
1386 * invalid request back to the {@link InCallService}.
1387 * <p>
1388 * Where a request requires confirmation from the user of the peer device, the
1389 * {@link VideoProvider} must communicate the request to the peer device and handle the
1390 * user's response. {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)}
1391 * is used to inform the {@link InCallService} of the result of the request.
1392 * <p>
1393 * Sent from the {@link InCallService} via
1394 * {@link InCallService.VideoCall#sendSessionModifyRequest(VideoProfile)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001395 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001396 * @param fromProfile The video profile prior to the request.
1397 * @param toProfile The video profile with the requested changes made.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001398 */
Tyler Gunn45382162015-05-06 08:52:27 -07001399 public abstract void onSendSessionModifyRequest(VideoProfile fromProfile,
1400 VideoProfile toProfile);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001401
Tyler Gunnb702ef82015-05-29 11:51:53 -07001402 /**
1403 * Provides a response to a request to change the current video session properties.
1404 * <p>
1405 * For example, if the peer requests and upgrade from an audio-only call to a bi-directional
1406 * video call, could decline the request and keep the call as audio-only.
1407 * In such a scenario, the {@code responseProfile} would have a video state of
1408 * {@link VideoProfile#STATE_AUDIO_ONLY}. If the user had decided to accept the request,
1409 * the video state would be {@link VideoProfile#STATE_BIDIRECTIONAL}.
1410 * <p>
1411 * Sent from the {@link InCallService} via
1412 * {@link InCallService.VideoCall#sendSessionModifyResponse(VideoProfile)} in response to
1413 * a {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)}
1414 * callback.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001415 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001416 * @param responseProfile The response video profile.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001417 */
1418 public abstract void onSendSessionModifyResponse(VideoProfile responseProfile);
1419
1420 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001421 * Issues a request to the {@link VideoProvider} to retrieve the camera capabilities.
1422 * <p>
1423 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1424 * camera via
1425 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1426 * <p>
1427 * Sent from the {@link InCallService} via
1428 * {@link InCallService.VideoCall#requestCameraCapabilities()}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001429 */
1430 public abstract void onRequestCameraCapabilities();
1431
1432 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001433 * Issues a request to the {@link VideoProvider} to retrieve the current data usage for the
1434 * video component of the current {@link Connection}.
1435 * <p>
1436 * The {@link VideoProvider} should respond by communicating current data usage, in bytes,
1437 * via {@link VideoProvider#setCallDataUsage(long)}.
1438 * <p>
1439 * Sent from the {@link InCallService} via
1440 * {@link InCallService.VideoCall#requestCallDataUsage()}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001441 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001442 public abstract void onRequestConnectionDataUsage();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001443
1444 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001445 * Provides the {@link VideoProvider} with the {@link Uri} of an image to be displayed to
1446 * the peer device when the video signal is paused.
1447 * <p>
1448 * Sent from the {@link InCallService} via
1449 * {@link InCallService.VideoCall#setPauseImage(Uri)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001450 *
1451 * @param uri URI of image to display.
1452 */
Yorke Lee32f24732015-05-12 16:18:03 -07001453 public abstract void onSetPauseImage(Uri uri);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001454
1455 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001456 * Used to inform listening {@link InCallService} implementations when the
1457 * {@link VideoProvider} receives a session modification request.
1458 * <p>
1459 * Received by the {@link InCallService} via
1460 * {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)},
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001461 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001462 * @param videoProfile The requested video profile.
1463 * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001464 */
1465 public void receiveSessionModifyRequest(VideoProfile videoProfile) {
Tyler Gunn75958422015-04-15 14:23:42 -07001466 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001467 for (IVideoCallback callback : mVideoCallbacks.values()) {
1468 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001469 callback.receiveSessionModifyRequest(videoProfile);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001470 } catch (RemoteException ignored) {
1471 Log.w(this, "receiveSessionModifyRequest callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001472 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001473 }
1474 }
1475 }
1476
1477 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001478 * Used to inform listening {@link InCallService} implementations when the
1479 * {@link VideoProvider} receives a response to a session modification request.
1480 * <p>
1481 * Received by the {@link InCallService} via
1482 * {@link InCallService.VideoCall.Callback#onSessionModifyResponseReceived(int,
1483 * VideoProfile, VideoProfile)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001484 *
1485 * @param status Status of the session modify request. Valid values are
1486 * {@link VideoProvider#SESSION_MODIFY_REQUEST_SUCCESS},
1487 * {@link VideoProvider#SESSION_MODIFY_REQUEST_FAIL},
Tyler Gunnb702ef82015-05-29 11:51:53 -07001488 * {@link VideoProvider#SESSION_MODIFY_REQUEST_INVALID},
1489 * {@link VideoProvider#SESSION_MODIFY_REQUEST_TIMED_OUT},
1490 * {@link VideoProvider#SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE}
1491 * @param requestedProfile The original request which was sent to the peer device.
1492 * @param responseProfile The actual profile changes agreed to by the peer device.
1493 * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001494 */
1495 public void receiveSessionModifyResponse(int status,
1496 VideoProfile requestedProfile, VideoProfile responseProfile) {
Tyler Gunn75958422015-04-15 14:23:42 -07001497 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001498 for (IVideoCallback callback : mVideoCallbacks.values()) {
1499 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001500 callback.receiveSessionModifyResponse(status, requestedProfile,
1501 responseProfile);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001502 } catch (RemoteException ignored) {
1503 Log.w(this, "receiveSessionModifyResponse callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001504 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001505 }
1506 }
1507 }
1508
1509 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001510 * Used to inform listening {@link InCallService} implementations when the
1511 * {@link VideoProvider} reports a call session event.
1512 * <p>
1513 * Received by the {@link InCallService} via
1514 * {@link InCallService.VideoCall.Callback#onCallSessionEvent(int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001515 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001516 * @param event The event. Valid values are: {@link VideoProvider#SESSION_EVENT_RX_PAUSE},
1517 * {@link VideoProvider#SESSION_EVENT_RX_RESUME},
1518 * {@link VideoProvider#SESSION_EVENT_TX_START},
1519 * {@link VideoProvider#SESSION_EVENT_TX_STOP},
1520 * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE},
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001521 * {@link VideoProvider#SESSION_EVENT_CAMERA_READY},
1522 * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001523 */
1524 public void handleCallSessionEvent(int event) {
Tyler Gunn75958422015-04-15 14:23:42 -07001525 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001526 for (IVideoCallback callback : mVideoCallbacks.values()) {
1527 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001528 callback.handleCallSessionEvent(event);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001529 } catch (RemoteException ignored) {
1530 Log.w(this, "handleCallSessionEvent callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001531 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001532 }
1533 }
1534 }
1535
1536 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001537 * Used to inform listening {@link InCallService} implementations when the dimensions of the
1538 * peer's video have changed.
1539 * <p>
1540 * This could occur if, for example, the peer rotates their device, changing the aspect
1541 * ratio of the video, or if the user switches between the back and front cameras.
1542 * <p>
1543 * Received by the {@link InCallService} via
1544 * {@link InCallService.VideoCall.Callback#onPeerDimensionsChanged(int, int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001545 *
1546 * @param width The updated peer video width.
1547 * @param height The updated peer video height.
1548 */
1549 public void changePeerDimensions(int width, int height) {
Tyler Gunn75958422015-04-15 14:23:42 -07001550 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001551 for (IVideoCallback callback : mVideoCallbacks.values()) {
1552 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001553 callback.changePeerDimensions(width, height);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001554 } catch (RemoteException ignored) {
1555 Log.w(this, "changePeerDimensions callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001556 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001557 }
1558 }
1559 }
1560
1561 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001562 * Used to inform listening {@link InCallService} implementations when the data usage of the
1563 * video associated with the current {@link Connection} has changed.
1564 * <p>
1565 * This could be in response to a preview request via
1566 * {@link #onRequestConnectionDataUsage()}, or as a periodic update by the
Tyler Gunn295f5d72015-06-04 11:08:54 -07001567 * {@link VideoProvider}. Where periodic updates of data usage are provided, they should be
1568 * provided at most for every 1 MB of data transferred and no more than once every 10 sec.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001569 * <p>
1570 * Received by the {@link InCallService} via
1571 * {@link InCallService.VideoCall.Callback#onCallDataUsageChanged(long)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001572 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001573 * @param dataUsage The updated data usage (in bytes). Reported as the cumulative bytes
1574 * used since the start of the call.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001575 */
Yorke Lee32f24732015-05-12 16:18:03 -07001576 public void setCallDataUsage(long dataUsage) {
Tyler Gunn75958422015-04-15 14:23:42 -07001577 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001578 for (IVideoCallback callback : mVideoCallbacks.values()) {
1579 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001580 callback.changeCallDataUsage(dataUsage);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001581 } catch (RemoteException ignored) {
1582 Log.w(this, "setCallDataUsage callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001583 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001584 }
1585 }
1586 }
1587
1588 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001589 * @see #setCallDataUsage(long)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001590 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001591 * @param dataUsage The updated data usage (in byes).
Yorke Lee32f24732015-05-12 16:18:03 -07001592 * @deprecated - Use {@link #setCallDataUsage(long)} instead.
1593 * @hide
1594 */
1595 public void changeCallDataUsage(long dataUsage) {
1596 setCallDataUsage(dataUsage);
1597 }
1598
1599 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001600 * Used to inform listening {@link InCallService} implementations when the capabilities of
1601 * the current camera have changed.
1602 * <p>
1603 * The {@link VideoProvider} should call this in response to
1604 * {@link VideoProvider#onRequestCameraCapabilities()}, or when the current camera is
1605 * changed via {@link VideoProvider#onSetCamera(String)}.
1606 * <p>
1607 * Received by the {@link InCallService} via
1608 * {@link InCallService.VideoCall.Callback#onCameraCapabilitiesChanged(
1609 * VideoProfile.CameraCapabilities)}.
Yorke Lee32f24732015-05-12 16:18:03 -07001610 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001611 * @param cameraCapabilities The new camera capabilities.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001612 */
Yorke Lee400470f2015-05-12 13:31:25 -07001613 public void changeCameraCapabilities(VideoProfile.CameraCapabilities cameraCapabilities) {
Tyler Gunn75958422015-04-15 14:23:42 -07001614 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001615 for (IVideoCallback callback : mVideoCallbacks.values()) {
1616 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001617 callback.changeCameraCapabilities(cameraCapabilities);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001618 } catch (RemoteException ignored) {
1619 Log.w(this, "changeCameraCapabilities callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001620 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001621 }
1622 }
1623 }
Rekha Kumar07366812015-03-24 16:42:31 -07001624
1625 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001626 * Used to inform listening {@link InCallService} implementations when the video quality
1627 * of the call has changed.
1628 * <p>
1629 * Received by the {@link InCallService} via
1630 * {@link InCallService.VideoCall.Callback#onVideoQualityChanged(int)}.
Rekha Kumar07366812015-03-24 16:42:31 -07001631 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001632 * @param videoQuality The updated video quality. Valid values:
1633 * {@link VideoProfile#QUALITY_HIGH},
1634 * {@link VideoProfile#QUALITY_MEDIUM},
1635 * {@link VideoProfile#QUALITY_LOW},
1636 * {@link VideoProfile#QUALITY_DEFAULT}.
Rekha Kumar07366812015-03-24 16:42:31 -07001637 */
1638 public void changeVideoQuality(int videoQuality) {
Tyler Gunn75958422015-04-15 14:23:42 -07001639 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001640 for (IVideoCallback callback : mVideoCallbacks.values()) {
1641 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001642 callback.changeVideoQuality(videoQuality);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001643 } catch (RemoteException ignored) {
1644 Log.w(this, "changeVideoQuality callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001645 }
Rekha Kumar07366812015-03-24 16:42:31 -07001646 }
1647 }
1648 }
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001649
1650 /**
1651 * Returns a string representation of a call session event.
1652 *
1653 * @param event A call session event passed to {@link #handleCallSessionEvent(int)}.
1654 * @return String representation of the call session event.
1655 * @hide
1656 */
1657 public static String sessionEventToString(int event) {
1658 switch (event) {
1659 case SESSION_EVENT_CAMERA_FAILURE:
1660 return SESSION_EVENT_CAMERA_FAILURE_STR;
1661 case SESSION_EVENT_CAMERA_READY:
1662 return SESSION_EVENT_CAMERA_READY_STR;
1663 case SESSION_EVENT_RX_PAUSE:
1664 return SESSION_EVENT_RX_PAUSE_STR;
1665 case SESSION_EVENT_RX_RESUME:
1666 return SESSION_EVENT_RX_RESUME_STR;
1667 case SESSION_EVENT_TX_START:
1668 return SESSION_EVENT_TX_START_STR;
1669 case SESSION_EVENT_TX_STOP:
1670 return SESSION_EVENT_TX_STOP_STR;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001671 case SESSION_EVENT_CAMERA_PERMISSION_ERROR:
1672 return SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR;
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001673 default:
1674 return SESSION_EVENT_UNKNOWN_STR + " " + event;
1675 }
1676 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07001677 }
1678
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07001679 private final Listener mConnectionDeathListener = new Listener() {
1680 @Override
1681 public void onDestroyed(Connection c) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08001682 if (mConferenceables.remove(c)) {
1683 fireOnConferenceableConnectionsChanged();
1684 }
1685 }
1686 };
1687
1688 private final Conference.Listener mConferenceDeathListener = new Conference.Listener() {
1689 @Override
1690 public void onDestroyed(Conference c) {
1691 if (mConferenceables.remove(c)) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07001692 fireOnConferenceableConnectionsChanged();
1693 }
1694 }
1695 };
1696
Jay Shrauner229e3822014-08-15 09:23:07 -07001697 /**
1698 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
1699 * load factor before resizing, 1 means we only expect a single thread to
1700 * access the map so make only a single shard
1701 */
1702 private final Set<Listener> mListeners = Collections.newSetFromMap(
1703 new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1));
Tyler Gunndf2cbc82015-04-20 09:13:01 -07001704 private final List<Conferenceable> mConferenceables = new ArrayList<>();
1705 private final List<Conferenceable> mUnmodifiableConferenceables =
Tyler Gunn6d76ca02014-11-17 15:49:51 -08001706 Collections.unmodifiableList(mConferenceables);
Santos Cordonb6939982014-06-04 20:20:58 -07001707
Tyler Gunnf0500bd2015-09-01 10:59:48 -07001708 // The internal telecom call ID associated with this connection.
1709 private String mTelecomCallId;
Pengquan Meng70c9885332017-10-02 18:09:03 -07001710 // The PhoneAccountHandle associated with this connection.
1711 private PhoneAccountHandle mPhoneAccountHandle;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001712 private int mState = STATE_NEW;
Yorke Lee4af59352015-05-13 14:14:54 -07001713 private CallAudioState mCallAudioState;
Andrew Lee100e2932014-09-08 15:34:24 -07001714 private Uri mAddress;
1715 private int mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -07001716 private String mCallerDisplayName;
1717 private int mCallerDisplayNamePresentation;
Andrew Lee100e2932014-09-08 15:34:24 -07001718 private boolean mRingbackRequested = false;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001719 private int mConnectionCapabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -07001720 private int mConnectionProperties;
Christine Hallstrom2830ce92016-11-30 16:06:42 -08001721 private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001722 private VideoProvider mVideoProvider;
Sailesh Nepal33aaae42014-07-07 22:49:44 -07001723 private boolean mAudioModeIsVoip;
Roshan Piuse927ec02015-07-15 15:47:21 -07001724 private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Tyler Gunn3fa819c2017-08-04 09:27:26 -07001725 private long mConnectElapsedTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07001726 private StatusHints mStatusHints;
Tyler Gunnaa07df82014-07-17 07:50:22 -07001727 private int mVideoState;
Andrew Lee7f3d41f2014-09-11 17:33:16 -07001728 private DisconnectCause mDisconnectCause;
Santos Cordon823fd3c2014-08-07 18:35:18 -07001729 private Conference mConference;
1730 private ConnectionService mConnectionService;
Santos Cordon6b7f9552015-05-27 17:21:45 -07001731 private Bundle mExtras;
Brad Ebinger4fa6a012016-06-14 17:04:01 -07001732 private final Object mExtrasLock = new Object();
Ihab Awad542e0ea2014-05-16 10:22:16 -07001733
1734 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07001735 * Tracks the key set for the extras bundle provided on the last invocation of
1736 * {@link #setExtras(Bundle)}. Used so that on subsequent invocations we can remove any extras
1737 * keys which were set previously but are no longer present in the replacement Bundle.
1738 */
1739 private Set<String> mPreviousExtraKeys;
1740
1741 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07001742 * Create a new Connection.
1743 */
Santos Cordonf2951102014-07-20 19:06:29 -07001744 public Connection() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07001745
1746 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07001747 * Returns the Telecom internal call ID associated with this connection. Should only be used
1748 * for debugging and tracing purposes.
1749 *
1750 * @return The Telecom call ID.
1751 * @hide
1752 */
1753 public final String getTelecomCallId() {
1754 return mTelecomCallId;
1755 }
1756
1757 /**
Andrew Lee100e2932014-09-08 15:34:24 -07001758 * @return The address (e.g., phone number) to which this Connection is currently communicating.
Ihab Awad542e0ea2014-05-16 10:22:16 -07001759 */
Andrew Lee100e2932014-09-08 15:34:24 -07001760 public final Uri getAddress() {
1761 return mAddress;
Ihab Awad542e0ea2014-05-16 10:22:16 -07001762 }
1763
1764 /**
Andrew Lee100e2932014-09-08 15:34:24 -07001765 * @return The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07001766 * See {@link TelecomManager} for valid values.
Sailesh Nepal61203862014-07-11 14:50:13 -07001767 */
Andrew Lee100e2932014-09-08 15:34:24 -07001768 public final int getAddressPresentation() {
1769 return mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -07001770 }
1771
1772 /**
1773 * @return The caller display name (CNAP).
1774 */
1775 public final String getCallerDisplayName() {
1776 return mCallerDisplayName;
1777 }
1778
1779 /**
Nancy Chen9d568c02014-09-08 14:17:59 -07001780 * @return The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07001781 * See {@link TelecomManager} for valid values.
Sailesh Nepal61203862014-07-11 14:50:13 -07001782 */
1783 public final int getCallerDisplayNamePresentation() {
1784 return mCallerDisplayNamePresentation;
1785 }
1786
1787 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07001788 * @return The state of this Connection.
Ihab Awad542e0ea2014-05-16 10:22:16 -07001789 */
1790 public final int getState() {
1791 return mState;
1792 }
1793
1794 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001795 * Returns the video state of the connection.
Yorke Lee32f24732015-05-12 16:18:03 -07001796 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
1797 * {@link VideoProfile#STATE_BIDIRECTIONAL},
1798 * {@link VideoProfile#STATE_TX_ENABLED},
1799 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -07001800 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001801 * @return The video state of the connection.
Tyler Gunn27d1e252014-08-21 16:38:40 -07001802 * @hide
Tyler Gunnaa07df82014-07-17 07:50:22 -07001803 */
1804 public final int getVideoState() {
1805 return mVideoState;
1806 }
1807
1808 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001809 * @return The audio state of the connection, describing how its audio is currently
Ihab Awad542e0ea2014-05-16 10:22:16 -07001810 * being routed by the system. This is {@code null} if this Connection
1811 * does not directly know about its audio state.
Yorke Lee4af59352015-05-13 14:14:54 -07001812 * @deprecated Use {@link #getCallAudioState()} instead.
1813 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -07001814 */
Yorke Lee4af59352015-05-13 14:14:54 -07001815 @SystemApi
1816 @Deprecated
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001817 public final AudioState getAudioState() {
Sailesh Nepal000d38a2015-06-21 10:25:13 -07001818 if (mCallAudioState == null) {
1819 return null;
1820 }
Yorke Lee4af59352015-05-13 14:14:54 -07001821 return new AudioState(mCallAudioState);
1822 }
1823
1824 /**
1825 * @return The audio state of the connection, describing how its audio is currently
1826 * being routed by the system. This is {@code null} if this Connection
1827 * does not directly know about its audio state.
1828 */
1829 public final CallAudioState getCallAudioState() {
1830 return mCallAudioState;
Ihab Awad542e0ea2014-05-16 10:22:16 -07001831 }
1832
1833 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07001834 * @return The conference that this connection is a part of. Null if it is not part of any
1835 * conference.
1836 */
1837 public final Conference getConference() {
1838 return mConference;
1839 }
1840
1841 /**
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001842 * Returns whether this connection is requesting that the system play a ringback tone
1843 * on its behalf.
1844 */
Andrew Lee100e2932014-09-08 15:34:24 -07001845 public final boolean isRingbackRequested() {
1846 return mRingbackRequested;
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001847 }
1848
1849 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -07001850 * @return True if the connection's audio mode is VOIP.
1851 */
1852 public final boolean getAudioModeIsVoip() {
1853 return mAudioModeIsVoip;
1854 }
1855
1856 /**
Roshan Piuse927ec02015-07-15 15:47:21 -07001857 * Retrieves the connection start time of the {@code Connnection}, if specified. A value of
1858 * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
1859 * start time of the conference.
1860 *
1861 * @return The time at which the {@code Connnection} was connected.
1862 *
1863 * @hide
1864 */
1865 public final long getConnectTimeMillis() {
1866 return mConnectTimeMillis;
1867 }
1868
1869 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -07001870 * Retrieves the connection start time of the {@link Connection}, if specified. A value of
1871 * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
1872 * start time of the conference.
1873 *
1874 * Based on the value of {@link SystemClock#elapsedRealtime()}, which ensures that wall-clock
1875 * changes do not impact the call duration.
1876 *
1877 * @return The time at which the {@link Connection} was connected.
1878 *
1879 * @hide
1880 */
1881 public final long getConnectElapsedTimeMillis() {
1882 return mConnectElapsedTimeMillis;
1883 }
1884
1885 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07001886 * @return The status hints for this connection.
1887 */
1888 public final StatusHints getStatusHints() {
1889 return mStatusHints;
1890 }
1891
1892 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07001893 * Returns the extras associated with this connection.
Tyler Gunn2cbe2b52016-05-04 15:48:10 +00001894 * <p>
1895 * Extras should be updated using {@link #putExtras(Bundle)}.
1896 * <p>
1897 * Telecom or an {@link InCallService} can also update the extras via
1898 * {@link android.telecom.Call#putExtras(Bundle)}, and
1899 * {@link Call#removeExtras(List)}.
1900 * <p>
1901 * The connection is notified of changes to the extras made by Telecom or an
1902 * {@link InCallService} by {@link #onExtrasChanged(Bundle)}.
Tyler Gunndee56a82016-03-23 16:06:34 -07001903 *
Santos Cordon6b7f9552015-05-27 17:21:45 -07001904 * @return The extras associated with this connection.
1905 */
1906 public final Bundle getExtras() {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07001907 Bundle extras = null;
1908 synchronized (mExtrasLock) {
1909 if (mExtras != null) {
1910 extras = new Bundle(mExtras);
1911 }
1912 }
1913 return extras;
Santos Cordon6b7f9552015-05-27 17:21:45 -07001914 }
1915
1916 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07001917 * Assign a listener to be notified of state changes.
1918 *
1919 * @param l A listener.
1920 * @return This Connection.
1921 *
1922 * @hide
1923 */
1924 public final Connection addConnectionListener(Listener l) {
Santos Cordond34e5712014-08-05 18:54:03 +00001925 mListeners.add(l);
Ihab Awad542e0ea2014-05-16 10:22:16 -07001926 return this;
1927 }
1928
1929 /**
1930 * Remove a previously assigned listener that was being notified of state changes.
1931 *
1932 * @param l A Listener.
1933 * @return This Connection.
1934 *
1935 * @hide
1936 */
1937 public final Connection removeConnectionListener(Listener l) {
Jay Shrauner229e3822014-08-15 09:23:07 -07001938 if (l != null) {
1939 mListeners.remove(l);
1940 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07001941 return this;
1942 }
1943
1944 /**
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07001945 * @return The {@link DisconnectCause} for this connection.
Evan Charltonbf11f982014-07-20 22:06:28 -07001946 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07001947 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07001948 return mDisconnectCause;
Evan Charltonbf11f982014-07-20 22:06:28 -07001949 }
1950
1951 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07001952 * Sets the telecom call ID associated with this Connection. The Telecom Call ID should be used
1953 * ONLY for debugging purposes.
1954 *
1955 * @param callId The telecom call ID.
1956 * @hide
1957 */
1958 public void setTelecomCallId(String callId) {
1959 mTelecomCallId = callId;
1960 }
1961
1962 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07001963 * Inform this Connection that the state of its audio output has been changed externally.
1964 *
1965 * @param state The new audio state.
Sailesh Nepal400cc482014-06-26 12:04:00 -07001966 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -07001967 */
Yorke Lee4af59352015-05-13 14:14:54 -07001968 final void setCallAudioState(CallAudioState state) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001969 checkImmutable();
Ihab Awad60ac30b2014-05-20 22:32:12 -07001970 Log.d(this, "setAudioState %s", state);
Yorke Lee4af59352015-05-13 14:14:54 -07001971 mCallAudioState = state;
1972 onAudioStateChanged(getAudioState());
1973 onCallAudioStateChanged(state);
Ihab Awad542e0ea2014-05-16 10:22:16 -07001974 }
1975
1976 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001977 * @param state An integer value of a {@code STATE_*} constant.
Ihab Awad542e0ea2014-05-16 10:22:16 -07001978 * @return A string representation of the value.
1979 */
1980 public static String stateToString(int state) {
1981 switch (state) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001982 case STATE_INITIALIZING:
Yorke Leee911c8d2015-07-14 11:39:36 -07001983 return "INITIALIZING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001984 case STATE_NEW:
Yorke Leee911c8d2015-07-14 11:39:36 -07001985 return "NEW";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001986 case STATE_RINGING:
Yorke Leee911c8d2015-07-14 11:39:36 -07001987 return "RINGING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001988 case STATE_DIALING:
Yorke Leee911c8d2015-07-14 11:39:36 -07001989 return "DIALING";
Tyler Gunnc96b5e02016-07-07 22:53:57 -07001990 case STATE_PULLING_CALL:
1991 return "PULLING_CALL";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001992 case STATE_ACTIVE:
Yorke Leee911c8d2015-07-14 11:39:36 -07001993 return "ACTIVE";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001994 case STATE_HOLDING:
Yorke Leee911c8d2015-07-14 11:39:36 -07001995 return "HOLDING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001996 case STATE_DISCONNECTED:
Ihab Awad542e0ea2014-05-16 10:22:16 -07001997 return "DISCONNECTED";
1998 default:
Ihab Awad60ac30b2014-05-20 22:32:12 -07001999 Log.wtf(Connection.class, "Unknown state %d", state);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002000 return "UNKNOWN";
2001 }
2002 }
2003
2004 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002005 * Returns the connection's capabilities, as a bit mask of the {@code CAPABILITY_*} constants.
Ihab Awad52a28f62014-06-18 10:26:34 -07002006 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002007 public final int getConnectionCapabilities() {
2008 return mConnectionCapabilities;
Ihab Awad52a28f62014-06-18 10:26:34 -07002009 }
2010
2011 /**
Tyler Gunn720c6642016-03-22 09:02:47 -07002012 * Returns the connection's properties, as a bit mask of the {@code PROPERTY_*} constants.
2013 */
2014 public final int getConnectionProperties() {
2015 return mConnectionProperties;
2016 }
2017
2018 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002019 * Returns the connection's supported audio routes.
2020 *
2021 * @hide
2022 */
2023 public final int getSupportedAudioRoutes() {
2024 return mSupportedAudioRoutes;
2025 }
2026
2027 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002028 * Sets the value of the {@link #getAddress()} property.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002029 *
Andrew Lee100e2932014-09-08 15:34:24 -07002030 * @param address The new address.
2031 * @param presentation The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002032 * See {@link TelecomManager} for valid values.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002033 */
Andrew Lee100e2932014-09-08 15:34:24 -07002034 public final void setAddress(Uri address, int presentation) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002035 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002036 Log.d(this, "setAddress %s", address);
2037 mAddress = address;
2038 mAddressPresentation = presentation;
Santos Cordond34e5712014-08-05 18:54:03 +00002039 for (Listener l : mListeners) {
Andrew Lee100e2932014-09-08 15:34:24 -07002040 l.onAddressChanged(this, address, presentation);
Santos Cordond34e5712014-08-05 18:54:03 +00002041 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002042 }
2043
2044 /**
Sailesh Nepal61203862014-07-11 14:50:13 -07002045 * Sets the caller display name (CNAP).
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002046 *
Sailesh Nepal61203862014-07-11 14:50:13 -07002047 * @param callerDisplayName The new display name.
Nancy Chen9d568c02014-09-08 14:17:59 -07002048 * @param presentation The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002049 * See {@link TelecomManager} for valid values.
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002050 */
Sailesh Nepal61203862014-07-11 14:50:13 -07002051 public final void setCallerDisplayName(String callerDisplayName, int presentation) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002052 checkImmutable();
Sailesh Nepal61203862014-07-11 14:50:13 -07002053 Log.d(this, "setCallerDisplayName %s", callerDisplayName);
Santos Cordond34e5712014-08-05 18:54:03 +00002054 mCallerDisplayName = callerDisplayName;
2055 mCallerDisplayNamePresentation = presentation;
2056 for (Listener l : mListeners) {
2057 l.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
2058 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002059 }
2060
2061 /**
Tyler Gunnaa07df82014-07-17 07:50:22 -07002062 * Set the video state for the connection.
Yorke Lee32f24732015-05-12 16:18:03 -07002063 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
2064 * {@link VideoProfile#STATE_BIDIRECTIONAL},
2065 * {@link VideoProfile#STATE_TX_ENABLED},
2066 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002067 *
2068 * @param videoState The new video state.
2069 */
2070 public final void setVideoState(int videoState) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002071 checkImmutable();
Tyler Gunnaa07df82014-07-17 07:50:22 -07002072 Log.d(this, "setVideoState %d", videoState);
Santos Cordond34e5712014-08-05 18:54:03 +00002073 mVideoState = videoState;
2074 for (Listener l : mListeners) {
2075 l.onVideoStateChanged(this, mVideoState);
2076 }
Tyler Gunnaa07df82014-07-17 07:50:22 -07002077 }
2078
2079 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002080 * Sets state to active (e.g., an ongoing connection where two or more parties can actively
Ihab Awad542e0ea2014-05-16 10:22:16 -07002081 * communicate).
2082 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002083 public final void setActive() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002084 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002085 setRingbackRequested(false);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002086 setState(STATE_ACTIVE);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002087 }
2088
2089 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002090 * Sets state to ringing (e.g., an inbound ringing connection).
Ihab Awad542e0ea2014-05-16 10:22:16 -07002091 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002092 public final void setRinging() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002093 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002094 setState(STATE_RINGING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002095 }
2096
2097 /**
Evan Charltonbf11f982014-07-20 22:06:28 -07002098 * Sets state to initializing (this Connection is not yet ready to be used).
2099 */
2100 public final void setInitializing() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002101 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002102 setState(STATE_INITIALIZING);
Evan Charltonbf11f982014-07-20 22:06:28 -07002103 }
2104
2105 /**
2106 * Sets state to initialized (the Connection has been set up and is now ready to be used).
2107 */
2108 public final void setInitialized() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002109 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002110 setState(STATE_NEW);
Evan Charltonbf11f982014-07-20 22:06:28 -07002111 }
2112
2113 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002114 * Sets state to dialing (e.g., dialing an outbound connection).
Ihab Awad542e0ea2014-05-16 10:22:16 -07002115 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002116 public final void setDialing() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002117 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002118 setState(STATE_DIALING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002119 }
2120
2121 /**
Tyler Gunnc242ceb2016-06-29 22:35:45 -07002122 * Sets state to pulling (e.g. the connection is being pulled to the local device from another
2123 * device). Only applicable for {@link Connection}s with
2124 * {@link Connection#PROPERTY_IS_EXTERNAL_CALL} and {@link Connection#CAPABILITY_CAN_PULL_CALL}.
2125 */
2126 public final void setPulling() {
2127 checkImmutable();
2128 setState(STATE_PULLING_CALL);
2129 }
2130
2131 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002132 * Sets state to be on hold.
2133 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002134 public final void setOnHold() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002135 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002136 setState(STATE_HOLDING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002137 }
2138
2139 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002140 * Sets the video connection provider.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002141 * @param videoProvider The video provider.
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002142 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002143 public final void setVideoProvider(VideoProvider videoProvider) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002144 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002145 mVideoProvider = videoProvider;
Santos Cordond34e5712014-08-05 18:54:03 +00002146 for (Listener l : mListeners) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002147 l.onVideoProviderChanged(this, videoProvider);
Santos Cordond34e5712014-08-05 18:54:03 +00002148 }
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002149 }
2150
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002151 public final VideoProvider getVideoProvider() {
2152 return mVideoProvider;
Andrew Leea27a1932014-07-09 17:07:13 -07002153 }
2154
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002155 /**
Sailesh Nepal091768c2014-06-30 15:15:23 -07002156 * Sets state to disconnected.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002157 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002158 * @param disconnectCause The reason for the disconnection, as specified by
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002159 * {@link DisconnectCause}.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002160 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002161 public final void setDisconnected(DisconnectCause disconnectCause) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002162 checkImmutable();
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002163 mDisconnectCause = disconnectCause;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002164 setState(STATE_DISCONNECTED);
mike dooleyf34519b2014-09-16 17:33:40 -07002165 Log.d(this, "Disconnected with cause %s", disconnectCause);
Santos Cordond34e5712014-08-05 18:54:03 +00002166 for (Listener l : mListeners) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002167 l.onDisconnected(this, disconnectCause);
Santos Cordond34e5712014-08-05 18:54:03 +00002168 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002169 }
2170
2171 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002172 * Informs listeners that this {@code Connection} is in a post-dial wait state. This is done
2173 * when (a) the {@code Connection} is issuing a DTMF sequence; (b) it has encountered a "wait"
2174 * character; and (c) it wishes to inform the In-Call app that it is waiting for the end-user
2175 * to send an {@link #onPostDialContinue(boolean)} signal.
2176 *
2177 * @param remaining The DTMF character sequence remaining to be emitted once the
2178 * {@link #onPostDialContinue(boolean)} is received, including any "wait" characters
2179 * that remaining sequence may contain.
Sailesh Nepal091768c2014-06-30 15:15:23 -07002180 */
2181 public final void setPostDialWait(String remaining) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002182 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002183 for (Listener l : mListeners) {
2184 l.onPostDialWait(this, remaining);
2185 }
Sailesh Nepal091768c2014-06-30 15:15:23 -07002186 }
2187
2188 /**
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002189 * Informs listeners that this {@code Connection} has processed a character in the post-dial
2190 * started state. This is done when (a) the {@code Connection} is issuing a DTMF sequence;
Sailesh Nepal1ed85612015-01-31 15:17:19 -08002191 * and (b) it wishes to signal Telecom to play the corresponding DTMF tone locally.
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002192 *
2193 * @param nextChar The DTMF character that was just processed by the {@code Connection}.
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002194 */
Sailesh Nepal1ed85612015-01-31 15:17:19 -08002195 public final void setNextPostDialChar(char nextChar) {
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002196 checkImmutable();
2197 for (Listener l : mListeners) {
2198 l.onPostDialChar(this, nextChar);
2199 }
2200 }
2201
2202 /**
Ihab Awadf8358972014-05-28 16:46:42 -07002203 * Requests that the framework play a ringback tone. This is to be invoked by implementations
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002204 * that do not play a ringback tone themselves in the connection's audio stream.
Ihab Awadf8358972014-05-28 16:46:42 -07002205 *
2206 * @param ringback Whether the ringback tone is to be played.
2207 */
Andrew Lee100e2932014-09-08 15:34:24 -07002208 public final void setRingbackRequested(boolean ringback) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002209 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002210 if (mRingbackRequested != ringback) {
2211 mRingbackRequested = ringback;
Santos Cordond34e5712014-08-05 18:54:03 +00002212 for (Listener l : mListeners) {
Andrew Lee100e2932014-09-08 15:34:24 -07002213 l.onRingbackRequested(this, ringback);
Santos Cordond34e5712014-08-05 18:54:03 +00002214 }
2215 }
Ihab Awadf8358972014-05-28 16:46:42 -07002216 }
2217
2218 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002219 * Sets the connection's capabilities as a bit mask of the {@code CAPABILITY_*} constants.
Sailesh Nepal1a7061b2014-07-09 21:03:20 -07002220 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002221 * @param connectionCapabilities The new connection capabilities.
Santos Cordonb6939982014-06-04 20:20:58 -07002222 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002223 public final void setConnectionCapabilities(int connectionCapabilities) {
2224 checkImmutable();
2225 if (mConnectionCapabilities != connectionCapabilities) {
2226 mConnectionCapabilities = connectionCapabilities;
Santos Cordond34e5712014-08-05 18:54:03 +00002227 for (Listener l : mListeners) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002228 l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities);
Santos Cordond34e5712014-08-05 18:54:03 +00002229 }
2230 }
Santos Cordonb6939982014-06-04 20:20:58 -07002231 }
2232
2233 /**
Tyler Gunn720c6642016-03-22 09:02:47 -07002234 * Sets the connection's properties as a bit mask of the {@code PROPERTY_*} constants.
2235 *
2236 * @param connectionProperties The new connection properties.
2237 */
2238 public final void setConnectionProperties(int connectionProperties) {
2239 checkImmutable();
2240 if (mConnectionProperties != connectionProperties) {
2241 mConnectionProperties = connectionProperties;
2242 for (Listener l : mListeners) {
2243 l.onConnectionPropertiesChanged(this, mConnectionProperties);
2244 }
2245 }
2246 }
2247
2248 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002249 * Sets the supported audio routes.
2250 *
2251 * @param supportedAudioRoutes the supported audio routes as a bitmask.
2252 * See {@link CallAudioState}
2253 * @hide
2254 */
2255 public final void setSupportedAudioRoutes(int supportedAudioRoutes) {
2256 if ((supportedAudioRoutes
2257 & (CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_SPEAKER)) == 0) {
2258 throw new IllegalArgumentException(
2259 "supported audio routes must include either speaker or earpiece");
2260 }
2261
2262 if (mSupportedAudioRoutes != supportedAudioRoutes) {
2263 mSupportedAudioRoutes = supportedAudioRoutes;
2264 for (Listener l : mListeners) {
2265 l.onSupportedAudioRoutesChanged(this, mSupportedAudioRoutes);
2266 }
2267 }
2268 }
2269
2270 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002271 * Tears down the Connection object.
Santos Cordonb6939982014-06-04 20:20:58 -07002272 */
Evan Charlton36a71342014-07-19 16:31:02 -07002273 public final void destroy() {
Jay Shrauner229e3822014-08-15 09:23:07 -07002274 for (Listener l : mListeners) {
2275 l.onDestroyed(this);
Santos Cordond34e5712014-08-05 18:54:03 +00002276 }
Santos Cordonb6939982014-06-04 20:20:58 -07002277 }
2278
2279 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002280 * Requests that the framework use VOIP audio mode for this connection.
2281 *
2282 * @param isVoip True if the audio mode is VOIP.
2283 */
2284 public final void setAudioModeIsVoip(boolean isVoip) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002285 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002286 mAudioModeIsVoip = isVoip;
2287 for (Listener l : mListeners) {
2288 l.onAudioModeIsVoipChanged(this, isVoip);
2289 }
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002290 }
2291
2292 /**
Roshan Piuse927ec02015-07-15 15:47:21 -07002293 * Sets the time at which a call became active on this Connection. This is set only
2294 * when a conference call becomes active on this connection.
2295 *
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002296 * @param connectTimeMillis The connection time, in milliseconds. Should be set using a value
2297 * obtained from {@link System#currentTimeMillis()}.
Roshan Piuse927ec02015-07-15 15:47:21 -07002298 *
2299 * @hide
2300 */
2301 public final void setConnectTimeMillis(long connectTimeMillis) {
2302 mConnectTimeMillis = connectTimeMillis;
2303 }
2304
2305 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002306 * Sets the time at which a call became active on this Connection. This is set only
2307 * when a conference call becomes active on this connection.
2308 *
2309 * @param connectElapsedTimeMillis The connection time, in milliseconds. Stored in the format
2310 * {@link SystemClock#elapsedRealtime()}.
2311 *
2312 * @hide
2313 */
Tyler Gunn17541392018-02-01 08:58:38 -08002314 public final void setConnectionStartElapsedRealTime(long connectElapsedTimeMillis) {
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002315 mConnectElapsedTimeMillis = connectElapsedTimeMillis;
2316 }
2317
2318 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002319 * Sets the label and icon status to display in the in-call UI.
2320 *
2321 * @param statusHints The status label and icon to set.
2322 */
2323 public final void setStatusHints(StatusHints statusHints) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002324 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002325 mStatusHints = statusHints;
2326 for (Listener l : mListeners) {
2327 l.onStatusHintsChanged(this, statusHints);
2328 }
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002329 }
2330
2331 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002332 * Sets the connections with which this connection can be conferenced.
2333 *
2334 * @param conferenceableConnections The set of connections this connection can conference with.
2335 */
2336 public final void setConferenceableConnections(List<Connection> conferenceableConnections) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002337 checkImmutable();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002338 clearConferenceableList();
2339 for (Connection c : conferenceableConnections) {
2340 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
2341 // small amount of items here.
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002342 if (!mConferenceables.contains(c)) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002343 c.addConnectionListener(mConnectionDeathListener);
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002344 mConferenceables.add(c);
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002345 }
2346 }
2347 fireOnConferenceableConnectionsChanged();
2348 }
2349
2350 /**
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002351 * Similar to {@link #setConferenceableConnections(java.util.List)}, sets a list of connections
2352 * or conferences with which this connection can be conferenced.
2353 *
2354 * @param conferenceables The conferenceables.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002355 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002356 public final void setConferenceables(List<Conferenceable> conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002357 clearConferenceableList();
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002358 for (Conferenceable c : conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002359 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
2360 // small amount of items here.
2361 if (!mConferenceables.contains(c)) {
2362 if (c instanceof Connection) {
2363 Connection connection = (Connection) c;
2364 connection.addConnectionListener(mConnectionDeathListener);
2365 } else if (c instanceof Conference) {
2366 Conference conference = (Conference) c;
2367 conference.addListener(mConferenceDeathListener);
2368 }
2369 mConferenceables.add(c);
2370 }
2371 }
2372 fireOnConferenceableConnectionsChanged();
2373 }
2374
2375 /**
Mengjun Leng25707742017-07-04 11:10:37 +08002376 * @hide
2377 * Resets the cdma connection time.
2378 */
2379 public final void resetConnectionTime() {
2380 for (Listener l : mListeners) {
2381 l.onConnectionTimeReset(this);
2382 }
2383 }
2384
2385 /**
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002386 * Returns the connections or conferences with which this connection can be conferenced.
2387 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002388 public final List<Conferenceable> getConferenceables() {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002389 return mUnmodifiableConferenceables;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002390 }
2391
Yorke Lee53463962015-08-04 16:07:19 -07002392 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002393 * @hide
2394 */
2395 public final void setConnectionService(ConnectionService connectionService) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002396 checkImmutable();
Santos Cordon823fd3c2014-08-07 18:35:18 -07002397 if (mConnectionService != null) {
2398 Log.e(this, new Exception(), "Trying to set ConnectionService on a connection " +
2399 "which is already associated with another ConnectionService.");
2400 } else {
2401 mConnectionService = connectionService;
2402 }
2403 }
2404
2405 /**
2406 * @hide
2407 */
2408 public final void unsetConnectionService(ConnectionService connectionService) {
2409 if (mConnectionService != connectionService) {
2410 Log.e(this, new Exception(), "Trying to remove ConnectionService from a Connection " +
2411 "that does not belong to the ConnectionService.");
2412 } else {
2413 mConnectionService = null;
2414 }
2415 }
2416
2417 /**
Santos Cordonaf1b2962014-10-16 19:23:54 -07002418 * @hide
2419 */
2420 public final ConnectionService getConnectionService() {
2421 return mConnectionService;
2422 }
2423
2424 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002425 * Sets the conference that this connection is a part of. This will fail if the connection is
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002426 * already part of a conference. {@link #resetConference} to un-set the conference first.
Santos Cordon823fd3c2014-08-07 18:35:18 -07002427 *
2428 * @param conference The conference.
2429 * @return {@code true} if the conference was successfully set.
2430 * @hide
2431 */
2432 public final boolean setConference(Conference conference) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002433 checkImmutable();
Santos Cordon823fd3c2014-08-07 18:35:18 -07002434 // We check to see if it is already part of another conference.
Santos Cordon0159ac02014-08-21 14:28:11 -07002435 if (mConference == null) {
Santos Cordon823fd3c2014-08-07 18:35:18 -07002436 mConference = conference;
Santos Cordon0159ac02014-08-21 14:28:11 -07002437 if (mConnectionService != null && mConnectionService.containsConference(conference)) {
2438 fireConferenceChanged();
2439 }
Santos Cordon823fd3c2014-08-07 18:35:18 -07002440 return true;
2441 }
2442 return false;
2443 }
2444
2445 /**
2446 * Resets the conference that this connection is a part of.
2447 * @hide
2448 */
2449 public final void resetConference() {
2450 if (mConference != null) {
Santos Cordon0159ac02014-08-21 14:28:11 -07002451 Log.d(this, "Conference reset");
Santos Cordon823fd3c2014-08-07 18:35:18 -07002452 mConference = null;
2453 fireConferenceChanged();
2454 }
2455 }
2456
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002457 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002458 * Set some extras that can be associated with this {@code Connection}.
2459 * <p>
2460 * New or existing keys are replaced in the {@code Connection} extras. Keys which are no longer
2461 * in the new extras, but were present the last time {@code setExtras} was called are removed.
2462 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07002463 * Alternatively you may use the {@link #putExtras(Bundle)}, and
2464 * {@link #removeExtras(String...)} methods to modify the extras.
2465 * <p>
Tyler Gunndee56a82016-03-23 16:06:34 -07002466 * No assumptions should be made as to how an In-Call UI or service will handle these extras.
Santos Cordon6b7f9552015-05-27 17:21:45 -07002467 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
2468 *
2469 * @param extras The extras associated with this {@code Connection}.
2470 */
2471 public final void setExtras(@Nullable Bundle extras) {
2472 checkImmutable();
Tyler Gunndee56a82016-03-23 16:06:34 -07002473
2474 // Add/replace any new or changed extras values.
2475 putExtras(extras);
2476
2477 // If we have used "setExtras" in the past, compare the key set from the last invocation to
2478 // the current one and remove any keys that went away.
2479 if (mPreviousExtraKeys != null) {
2480 List<String> toRemove = new ArrayList<String>();
2481 for (String oldKey : mPreviousExtraKeys) {
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07002482 if (extras == null || !extras.containsKey(oldKey)) {
Tyler Gunndee56a82016-03-23 16:06:34 -07002483 toRemove.add(oldKey);
2484 }
2485 }
2486 if (!toRemove.isEmpty()) {
2487 removeExtras(toRemove);
2488 }
2489 }
2490
2491 // Track the keys the last time set called setExtras. This way, the next time setExtras is
2492 // called we can see if the caller has removed any extras values.
2493 if (mPreviousExtraKeys == null) {
2494 mPreviousExtraKeys = new ArraySet<String>();
2495 }
2496 mPreviousExtraKeys.clear();
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07002497 if (extras != null) {
2498 mPreviousExtraKeys.addAll(extras.keySet());
2499 }
Tyler Gunndee56a82016-03-23 16:06:34 -07002500 }
2501
2502 /**
2503 * Adds some extras to this {@code Connection}. Existing keys are replaced and new ones are
2504 * added.
2505 * <p>
2506 * No assumptions should be made as to how an In-Call UI or service will handle these extras.
2507 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
2508 *
2509 * @param extras The extras to add.
2510 */
2511 public final void putExtras(@NonNull Bundle extras) {
2512 checkImmutable();
2513 if (extras == null) {
2514 return;
2515 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002516 // Creating a duplicate bundle so we don't have to synchronize on mExtrasLock while calling
2517 // the listeners.
2518 Bundle listenerExtras;
2519 synchronized (mExtrasLock) {
2520 if (mExtras == null) {
2521 mExtras = new Bundle();
2522 }
2523 mExtras.putAll(extras);
2524 listenerExtras = new Bundle(mExtras);
Tyler Gunndee56a82016-03-23 16:06:34 -07002525 }
Santos Cordon6b7f9552015-05-27 17:21:45 -07002526 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002527 // Create a new clone of the extras for each listener so that they don't clobber
2528 // each other
2529 l.onExtrasChanged(this, new Bundle(listenerExtras));
Santos Cordon6b7f9552015-05-27 17:21:45 -07002530 }
2531 }
2532
2533 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002534 * Adds a boolean extra to this {@code Connection}.
2535 *
2536 * @param key The extra key.
2537 * @param value The value.
2538 * @hide
2539 */
2540 public final void putExtra(String key, boolean value) {
2541 Bundle newExtras = new Bundle();
2542 newExtras.putBoolean(key, value);
2543 putExtras(newExtras);
2544 }
2545
2546 /**
2547 * Adds an integer extra to this {@code Connection}.
2548 *
2549 * @param key The extra key.
2550 * @param value The value.
2551 * @hide
2552 */
2553 public final void putExtra(String key, int value) {
2554 Bundle newExtras = new Bundle();
2555 newExtras.putInt(key, value);
2556 putExtras(newExtras);
2557 }
2558
2559 /**
2560 * Adds a string extra to this {@code Connection}.
2561 *
2562 * @param key The extra key.
2563 * @param value The value.
2564 * @hide
2565 */
2566 public final void putExtra(String key, String value) {
2567 Bundle newExtras = new Bundle();
2568 newExtras.putString(key, value);
2569 putExtras(newExtras);
2570 }
2571
2572 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -07002573 * Removes extras from this {@code Connection}.
Tyler Gunndee56a82016-03-23 16:06:34 -07002574 *
Tyler Gunn071be6f2016-05-10 14:52:33 -07002575 * @param keys The keys of the extras to remove.
Tyler Gunndee56a82016-03-23 16:06:34 -07002576 */
2577 public final void removeExtras(List<String> keys) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002578 synchronized (mExtrasLock) {
2579 if (mExtras != null) {
2580 for (String key : keys) {
2581 mExtras.remove(key);
2582 }
Tyler Gunndee56a82016-03-23 16:06:34 -07002583 }
2584 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002585 List<String> unmodifiableKeys = Collections.unmodifiableList(keys);
Tyler Gunndee56a82016-03-23 16:06:34 -07002586 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002587 l.onExtrasRemoved(this, unmodifiableKeys);
Tyler Gunndee56a82016-03-23 16:06:34 -07002588 }
2589 }
2590
2591 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -07002592 * Removes extras from this {@code Connection}.
2593 *
2594 * @param keys The keys of the extras to remove.
2595 */
2596 public final void removeExtras(String ... keys) {
2597 removeExtras(Arrays.asList(keys));
2598 }
2599
2600 /**
Tyler Gunnf5035432017-01-09 09:43:12 -08002601 * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will
2602 * be change to the {@link #getCallAudioState()}.
2603 * <p>
2604 * Used by self-managed {@link ConnectionService}s which wish to change the audio route for a
2605 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
2606 * <p>
2607 * See also {@link InCallService#setAudioRoute(int)}.
2608 *
2609 * @param route The audio route to use (one of {@link CallAudioState#ROUTE_BLUETOOTH},
2610 * {@link CallAudioState#ROUTE_EARPIECE}, {@link CallAudioState#ROUTE_SPEAKER}, or
2611 * {@link CallAudioState#ROUTE_WIRED_HEADSET}).
2612 */
2613 public final void setAudioRoute(int route) {
2614 for (Listener l : mListeners) {
Hall Liua98f58b52017-11-07 17:59:28 -08002615 l.onAudioRouteChanged(this, route, null);
2616 }
2617 }
2618
2619 /**
Hall Liua98f58b52017-11-07 17:59:28 -08002620 * Request audio routing to a specific bluetooth device. Calling this method may result in
2621 * the device routing audio to a different bluetooth device than the one specified if the
2622 * bluetooth stack is unable to route audio to the requested device.
2623 * A list of available devices can be obtained via
2624 * {@link CallAudioState#getSupportedBluetoothDevices()}
2625 *
2626 * <p>
2627 * Used by self-managed {@link ConnectionService}s which wish to use bluetooth audio for a
2628 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
2629 * <p>
Hall Liu15392832018-04-02 13:52:57 -07002630 * See also {@link InCallService#requestBluetoothAudio(BluetoothDevice)}
2631 * @param bluetoothDevice The bluetooth device to connect to.
Hall Liua98f58b52017-11-07 17:59:28 -08002632 */
Hall Liu15392832018-04-02 13:52:57 -07002633 public void requestBluetoothAudio(@NonNull BluetoothDevice bluetoothDevice) {
Hall Liua98f58b52017-11-07 17:59:28 -08002634 for (Listener l : mListeners) {
Hall Liu15392832018-04-02 13:52:57 -07002635 l.onAudioRouteChanged(this, CallAudioState.ROUTE_BLUETOOTH,
2636 bluetoothDevice.getAddress());
Tyler Gunnf5035432017-01-09 09:43:12 -08002637 }
2638 }
2639
2640 /**
Hall Liub64ac4c2017-02-06 10:49:48 -08002641 * Informs listeners that a previously requested RTT session via
2642 * {@link ConnectionRequest#isRequestingRtt()} or
Hall Liu37dfdb02017-12-04 14:19:30 -08002643 * {@link #onStartRtt(RttTextStream)} has succeeded.
Hall Liub64ac4c2017-02-06 10:49:48 -08002644 */
2645 public final void sendRttInitiationSuccess() {
2646 mListeners.forEach((l) -> l.onRttInitiationSuccess(Connection.this));
2647 }
2648
2649 /**
2650 * Informs listeners that a previously requested RTT session via
Hall Liu37dfdb02017-12-04 14:19:30 -08002651 * {@link ConnectionRequest#isRequestingRtt()} or {@link #onStartRtt(RttTextStream)}
Hall Liub64ac4c2017-02-06 10:49:48 -08002652 * has failed.
2653 * @param reason One of the reason codes defined in {@link RttModifyStatus}, with the
2654 * exception of {@link RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}.
Hall Liub64ac4c2017-02-06 10:49:48 -08002655 */
2656 public final void sendRttInitiationFailure(int reason) {
2657 mListeners.forEach((l) -> l.onRttInitiationFailure(Connection.this, reason));
2658 }
2659
2660 /**
2661 * Informs listeners that a currently active RTT session has been terminated by the remote
2662 * side of the coll.
Hall Liub64ac4c2017-02-06 10:49:48 -08002663 */
2664 public final void sendRttSessionRemotelyTerminated() {
2665 mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this));
2666 }
2667
2668 /**
2669 * Informs listeners that the remote side of the call has requested an upgrade to include an
2670 * RTT session in the call.
Hall Liub64ac4c2017-02-06 10:49:48 -08002671 */
2672 public final void sendRemoteRttRequest() {
2673 mListeners.forEach((l) -> l.onRemoteRttRequest(Connection.this));
2674 }
2675
2676 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002677 * Notifies this Connection that the {@link #getAudioState()} property has a new value.
Sailesh Nepal400cc482014-06-26 12:04:00 -07002678 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002679 * @param state The new connection audio state.
Yorke Lee4af59352015-05-13 14:14:54 -07002680 * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead.
2681 * @hide
Sailesh Nepal400cc482014-06-26 12:04:00 -07002682 */
Yorke Lee4af59352015-05-13 14:14:54 -07002683 @SystemApi
2684 @Deprecated
Nancy Chen354b2bd2014-09-08 18:27:26 -07002685 public void onAudioStateChanged(AudioState state) {}
Sailesh Nepal400cc482014-06-26 12:04:00 -07002686
2687 /**
Yorke Lee4af59352015-05-13 14:14:54 -07002688 * Notifies this Connection that the {@link #getCallAudioState()} property has a new value.
2689 *
2690 * @param state The new connection audio state.
2691 */
2692 public void onCallAudioStateChanged(CallAudioState state) {}
2693
2694 /**
Evan Charltonbf11f982014-07-20 22:06:28 -07002695 * Notifies this Connection of an internal state change. This method is called after the
2696 * state is changed.
Ihab Awadf8358972014-05-28 16:46:42 -07002697 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002698 * @param state The new state, one of the {@code STATE_*} constants.
Ihab Awadf8358972014-05-28 16:46:42 -07002699 */
Nancy Chen354b2bd2014-09-08 18:27:26 -07002700 public void onStateChanged(int state) {}
Ihab Awadf8358972014-05-28 16:46:42 -07002701
2702 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002703 * Notifies this Connection of a request to play a DTMF tone.
2704 *
2705 * @param c A DTMF character.
2706 */
Santos Cordonf2951102014-07-20 19:06:29 -07002707 public void onPlayDtmfTone(char c) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002708
2709 /**
2710 * Notifies this Connection of a request to stop any currently playing DTMF tones.
2711 */
Santos Cordonf2951102014-07-20 19:06:29 -07002712 public void onStopDtmfTone() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002713
2714 /**
2715 * Notifies this Connection of a request to disconnect.
2716 */
Santos Cordonf2951102014-07-20 19:06:29 -07002717 public void onDisconnect() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002718
2719 /**
Tyler Gunn3b4b1dc2014-11-04 14:53:37 -08002720 * Notifies this Connection of a request to disconnect a participant of the conference managed
2721 * by the connection.
2722 *
2723 * @param endpoint the {@link Uri} of the participant to disconnect.
2724 * @hide
2725 */
2726 public void onDisconnectConferenceParticipant(Uri endpoint) {}
2727
2728 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002729 * Notifies this Connection of a request to separate from its parent conference.
Santos Cordonb6939982014-06-04 20:20:58 -07002730 */
Santos Cordonf2951102014-07-20 19:06:29 -07002731 public void onSeparate() {}
Santos Cordonb6939982014-06-04 20:20:58 -07002732
2733 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002734 * Notifies this Connection of a request to abort.
2735 */
Santos Cordonf2951102014-07-20 19:06:29 -07002736 public void onAbort() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002737
2738 /**
2739 * Notifies this Connection of a request to hold.
2740 */
Santos Cordonf2951102014-07-20 19:06:29 -07002741 public void onHold() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002742
2743 /**
2744 * Notifies this Connection of a request to exit a hold state.
2745 */
Santos Cordonf2951102014-07-20 19:06:29 -07002746 public void onUnhold() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002747
2748 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002749 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Santos Cordond34e5712014-08-05 18:54:03 +00002750 * a request to accept.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08002751 * <p>
2752 * For managed {@link ConnectionService}s, this will be called when the user answers a call via
2753 * the default dialer's {@link InCallService}.
2754 * <p>
2755 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
2756 * Telecom framework may request that the call is answered in the following circumstances:
2757 * <ul>
2758 * <li>The user chooses to answer an incoming call via a Bluetooth device.</li>
2759 * <li>A car mode {@link InCallService} is in use which has declared
2760 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
2761 * {@link InCallService} will be able to see calls from self-managed
2762 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
2763 * behalf.</li>
2764 * </ul>
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002765 * @param videoState The video state in which to answer the connection.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002766 */
Santos Cordonf2951102014-07-20 19:06:29 -07002767 public void onAnswer(int videoState) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002768
2769 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002770 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Tyler Gunnbe74de02014-08-29 14:51:48 -07002771 * a request to accept.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08002772 * <p>
2773 * For managed {@link ConnectionService}s, this will be called when the user answers a call via
2774 * the default dialer's {@link InCallService}.
2775 * <p>
2776 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
2777 * Telecom framework may request that the call is answered in the following circumstances:
2778 * <ul>
2779 * <li>The user chooses to answer an incoming call via a Bluetooth device.</li>
2780 * <li>A car mode {@link InCallService} is in use which has declared
2781 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
2782 * {@link InCallService} will be able to see calls from self-managed
2783 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
2784 * behalf.</li>
2785 * </ul>
Tyler Gunnbe74de02014-08-29 14:51:48 -07002786 */
2787 public void onAnswer() {
Tyler Gunn87b73f32015-06-03 10:09:59 -07002788 onAnswer(VideoProfile.STATE_AUDIO_ONLY);
Tyler Gunnbe74de02014-08-29 14:51:48 -07002789 }
2790
2791 /**
2792 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Pooja Jaind34698d2017-12-28 14:15:31 +05302793 * a request to deflect.
2794 */
2795 public void onDeflect(Uri address) {}
2796
2797 /**
2798 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Santos Cordond34e5712014-08-05 18:54:03 +00002799 * a request to reject.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08002800 * <p>
2801 * For managed {@link ConnectionService}s, this will be called when the user rejects a call via
2802 * the default dialer's {@link InCallService}.
2803 * <p>
2804 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
2805 * Telecom framework may request that the call is rejected in the following circumstances:
2806 * <ul>
2807 * <li>The user chooses to reject an incoming call via a Bluetooth device.</li>
2808 * <li>A car mode {@link InCallService} is in use which has declared
2809 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
2810 * {@link InCallService} will be able to see calls from self-managed
2811 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
2812 * behalf.</li>
2813 * </ul>
Ihab Awad542e0ea2014-05-16 10:22:16 -07002814 */
Santos Cordonf2951102014-07-20 19:06:29 -07002815 public void onReject() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002816
Evan Charlton6dea4ac2014-06-03 14:07:13 -07002817 /**
Hall Liu712acbe2016-03-14 16:38:56 -07002818 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
2819 * a request to reject with a message.
Bryce Lee81901682015-08-28 16:38:02 -07002820 */
2821 public void onReject(String replyMessage) {}
2822
2823 /**
Tyler Gunn06f06162018-06-18 11:24:15 -07002824 * Notifies this Connection of a request to silence the ringer.
2825 * <p>
2826 * The ringer may be silenced by any of the following methods:
2827 * <ul>
2828 * <li>{@link TelecomManager#silenceRinger()}</li>
2829 * <li>The user presses the volume-down button while a call is ringing.</li>
2830 * </ul>
2831 * <p>
2832 * Self-managed {@link ConnectionService} implementations should override this method in their
2833 * {@link Connection} implementation and implement logic to silence their app's ringtone. If
2834 * your app set the ringtone as part of the incoming call {@link Notification} (see
2835 * {@link #onShowIncomingCallUi()}), it should re-post the notification now, except call
2836 * {@link android.app.Notification.Builder#setOnlyAlertOnce(boolean)} with {@code true}. This
2837 * will ensure the ringtone sound associated with your {@link android.app.NotificationChannel}
2838 * stops playing.
Bryce Leecac50772015-11-17 15:13:29 -08002839 */
2840 public void onSilence() {}
2841
2842 /**
Evan Charlton6dea4ac2014-06-03 14:07:13 -07002843 * Notifies this Connection whether the user wishes to proceed with the post-dial DTMF codes.
2844 */
Santos Cordonf2951102014-07-20 19:06:29 -07002845 public void onPostDialContinue(boolean proceed) {}
Evan Charlton6dea4ac2014-06-03 14:07:13 -07002846
Tyler Gunn876dbfb2016-03-14 15:18:07 -07002847 /**
2848 * Notifies this Connection of a request to pull an external call to the local device.
2849 * <p>
2850 * The {@link InCallService} issues a request to pull an external call to the local device via
2851 * {@link Call#pullExternalCall()}.
2852 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -07002853 * For a Connection to be pulled, both the {@link Connection#CAPABILITY_CAN_PULL_CALL}
2854 * capability and {@link Connection#PROPERTY_IS_EXTERNAL_CALL} property bits must be set.
Tyler Gunn876dbfb2016-03-14 15:18:07 -07002855 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -07002856 * For more information on external calls, see {@link Connection#PROPERTY_IS_EXTERNAL_CALL}.
Tyler Gunn876dbfb2016-03-14 15:18:07 -07002857 */
2858 public void onPullExternalCall() {}
2859
2860 /**
2861 * Notifies this Connection of a {@link Call} event initiated from an {@link InCallService}.
2862 * <p>
2863 * The {@link InCallService} issues a Call event via {@link Call#sendCallEvent(String, Bundle)}.
2864 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07002865 * Where possible, the Connection should make an attempt to handle {@link Call} events which
2866 * are part of the {@code android.telecom.*} namespace. The Connection should ignore any events
2867 * it does not wish to handle. Unexpected events should be handled gracefully, as it is
2868 * possible that a {@link InCallService} has defined its own Call events which a Connection is
2869 * not aware of.
2870 * <p>
Tyler Gunn876dbfb2016-03-14 15:18:07 -07002871 * See also {@link Call#sendCallEvent(String, Bundle)}.
2872 *
2873 * @param event The call event.
2874 * @param extras Extras associated with the call event.
2875 */
2876 public void onCallEvent(String event, Bundle extras) {}
2877
Tyler Gunndee56a82016-03-23 16:06:34 -07002878 /**
Tyler Gunn79bc1ec2018-01-22 15:17:54 -08002879 * Notifies this {@link Connection} that a handover has completed.
2880 * <p>
2881 * A handover is initiated with {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int,
2882 * Bundle)} on the initiating side of the handover, and
2883 * {@link TelecomManager#acceptHandover(Uri, int, PhoneAccountHandle)}.
2884 */
2885 public void onHandoverComplete() {}
2886
2887 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002888 * Notifies this {@link Connection} of a change to the extras made outside the
2889 * {@link ConnectionService}.
2890 * <p>
2891 * These extras changes can originate from Telecom itself, or from an {@link InCallService} via
2892 * the {@link android.telecom.Call#putExtras(Bundle)} and
2893 * {@link Call#removeExtras(List)}.
2894 *
2895 * @param extras The new extras bundle.
2896 */
2897 public void onExtrasChanged(Bundle extras) {}
2898
Tyler Gunnf5035432017-01-09 09:43:12 -08002899 /**
2900 * Notifies this {@link Connection} that its {@link ConnectionService} is responsible for
2901 * displaying its incoming call user interface for the {@link Connection}.
2902 * <p>
2903 * Will only be called for incoming calls added via a self-managed {@link ConnectionService}
2904 * (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}), where the {@link ConnectionService}
2905 * should show its own incoming call user interface.
2906 * <p>
2907 * Where there are ongoing calls in other self-managed {@link ConnectionService}s, or in a
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08002908 * regular {@link ConnectionService}, and it is not possible to hold these other calls, the
2909 * Telecom framework will display its own incoming call user interface to allow the user to
2910 * choose whether to answer the new incoming call and disconnect other ongoing calls, or to
2911 * reject the new incoming call.
Tyler Gunn159f35c2017-03-02 09:28:37 -08002912 * <p>
2913 * You should trigger the display of the incoming call user interface for your application by
2914 * showing a {@link Notification} with a full-screen {@link Intent} specified.
Tyler Gunn06f06162018-06-18 11:24:15 -07002915 *
2916 * In your application code, you should create a {@link android.app.NotificationChannel} for
2917 * incoming call notifications from your app:
2918 * <pre><code>
2919 * NotificationChannel channel = new NotificationChannel(YOUR_CHANNEL_ID, "Incoming Calls",
2920 * NotificationManager.IMPORTANCE_MAX);
2921 * // other channel setup stuff goes here.
2922 *
2923 * // We'll use the default system ringtone for our incoming call notification channel. You can
2924 * // use your own audio resource here.
2925 * Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
2926 * channel.setSound(ringtoneUri, new AudioAttributes.Builder()
2927 * // Setting the AudioAttributes is important as it identifies the purpose of your
2928 * // notification sound.
2929 * .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
2930 * .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
2931 * .build());
2932 *
2933 * NotificationManager mgr = getSystemService(NotificationManager.class);
2934 * mgr.createNotificationChannel(channel);
2935 * </code></pre>
2936 * When it comes time to post a notification for your incoming call, ensure it uses your
2937 * incoming call {@link android.app.NotificationChannel}.
Tyler Gunn159f35c2017-03-02 09:28:37 -08002938 * <pre><code>
2939 * // Create an intent which triggers your fullscreen incoming call user interface.
2940 * Intent intent = new Intent(Intent.ACTION_MAIN, null);
2941 * intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_ACTIVITY_NEW_TASK);
2942 * intent.setClass(context, YourIncomingCallActivity.class);
2943 * PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, 0);
2944 *
2945 * // Build the notification as an ongoing high priority item; this ensures it will show as
2946 * // a heads up notification which slides down over top of the current content.
2947 * final Notification.Builder builder = new Notification.Builder(context);
2948 * builder.setOngoing(true);
2949 * builder.setPriority(Notification.PRIORITY_HIGH);
2950 *
2951 * // Set notification content intent to take user to fullscreen UI if user taps on the
2952 * // notification body.
2953 * builder.setContentIntent(pendingIntent);
2954 * // Set full screen intent to trigger display of the fullscreen UI when the notification
2955 * // manager deems it appropriate.
2956 * builder.setFullScreenIntent(pendingIntent, true);
2957 *
2958 * // Setup notification content.
2959 * builder.setSmallIcon( yourIconResourceId );
2960 * builder.setContentTitle("Your notification title");
2961 * builder.setContentText("Your notification content.");
2962 *
Tyler Gunn06f06162018-06-18 11:24:15 -07002963 * // Set notification as insistent to cause your ringtone to loop.
2964 * Notification notification = builder.build();
2965 * notification.flags |= Notification.FLAG_INSISTENT;
Tyler Gunn159f35c2017-03-02 09:28:37 -08002966 *
Tyler Gunn06f06162018-06-18 11:24:15 -07002967 * // Use builder.addAction(..) to add buttons to answer or reject the call.
Tyler Gunn159f35c2017-03-02 09:28:37 -08002968 * NotificationManager notificationManager = mContext.getSystemService(
2969 * NotificationManager.class);
Tyler Gunn06f06162018-06-18 11:24:15 -07002970 * notificationManager.notify(YOUR_CHANNEL_ID, YOUR_TAG, YOUR_ID, notification);
Tyler Gunn159f35c2017-03-02 09:28:37 -08002971 * </code></pre>
Tyler Gunnf5035432017-01-09 09:43:12 -08002972 */
2973 public void onShowIncomingCallUi() {}
2974
Hall Liub64ac4c2017-02-06 10:49:48 -08002975 /**
2976 * Notifies this {@link Connection} that the user has requested an RTT session.
2977 * The connection service should call {@link #sendRttInitiationSuccess} or
2978 * {@link #sendRttInitiationFailure} to inform Telecom of the success or failure of the
2979 * request, respectively.
2980 * @param rttTextStream The object that should be used to send text to or receive text from
2981 * the in-call app.
Hall Liub64ac4c2017-02-06 10:49:48 -08002982 */
2983 public void onStartRtt(@NonNull RttTextStream rttTextStream) {}
2984
2985 /**
2986 * Notifies this {@link Connection} that it should terminate any existing RTT communication
2987 * channel. No response to Telecom is needed for this method.
Hall Liub64ac4c2017-02-06 10:49:48 -08002988 */
2989 public void onStopRtt() {}
2990
2991 /**
2992 * Notifies this connection of a response to a previous remotely-initiated RTT upgrade
2993 * request sent via {@link #sendRemoteRttRequest}. Acceptance of the request is
2994 * indicated by the supplied {@link RttTextStream} being non-null, and rejection is
2995 * indicated by {@code rttTextStream} being {@code null}
Hall Liub64ac4c2017-02-06 10:49:48 -08002996 * @param rttTextStream The object that should be used to send text to or receive text from
2997 * the in-call app.
2998 */
2999 public void handleRttUpgradeResponse(@Nullable RttTextStream rttTextStream) {}
3000
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003001 static String toLogSafePhoneNumber(String number) {
3002 // For unknown number, log empty string.
3003 if (number == null) {
3004 return "";
3005 }
3006
3007 if (PII_DEBUG) {
3008 // When PII_DEBUG is true we emit PII.
3009 return number;
3010 }
3011
3012 // Do exactly same thing as Uri#toSafeString() does, which will enable us to compare
3013 // sanitized phone numbers.
3014 StringBuilder builder = new StringBuilder();
3015 for (int i = 0; i < number.length(); i++) {
3016 char c = number.charAt(i);
3017 if (c == '-' || c == '@' || c == '.') {
3018 builder.append(c);
3019 } else {
3020 builder.append('x');
3021 }
3022 }
3023 return builder.toString();
3024 }
3025
Ihab Awad542e0ea2014-05-16 10:22:16 -07003026 private void setState(int state) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003027 checkImmutable();
Ihab Awad6107bab2014-08-18 09:23:25 -07003028 if (mState == STATE_DISCONNECTED && mState != state) {
3029 Log.d(this, "Connection already DISCONNECTED; cannot transition out of this state.");
Evan Charltonbf11f982014-07-20 22:06:28 -07003030 return;
Sailesh Nepal400cc482014-06-26 12:04:00 -07003031 }
Evan Charltonbf11f982014-07-20 22:06:28 -07003032 if (mState != state) {
3033 Log.d(this, "setState: %s", stateToString(state));
3034 mState = state;
Nancy Chen354b2bd2014-09-08 18:27:26 -07003035 onStateChanged(state);
Evan Charltonbf11f982014-07-20 22:06:28 -07003036 for (Listener l : mListeners) {
3037 l.onStateChanged(this, state);
3038 }
Evan Charltonbf11f982014-07-20 22:06:28 -07003039 }
3040 }
3041
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07003042 private static class FailureSignalingConnection extends Connection {
Ihab Awad90e34e32014-12-01 16:23:17 -08003043 private boolean mImmutable = false;
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003044 public FailureSignalingConnection(DisconnectCause disconnectCause) {
3045 setDisconnected(disconnectCause);
Ihab Awad90e34e32014-12-01 16:23:17 -08003046 mImmutable = true;
Ihab Awad6107bab2014-08-18 09:23:25 -07003047 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003048
3049 public void checkImmutable() {
Ihab Awad90e34e32014-12-01 16:23:17 -08003050 if (mImmutable) {
3051 throw new UnsupportedOperationException("Connection is immutable");
3052 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003053 }
Ihab Awad6107bab2014-08-18 09:23:25 -07003054 }
3055
Evan Charltonbf11f982014-07-20 22:06:28 -07003056 /**
Ihab Awad6107bab2014-08-18 09:23:25 -07003057 * Return a {@code Connection} which represents a failed connection attempt. The returned
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003058 * {@code Connection} will have a {@link android.telecom.DisconnectCause} and as specified,
3059 * and a {@link #getState()} of {@link #STATE_DISCONNECTED}.
Ihab Awad6107bab2014-08-18 09:23:25 -07003060 * <p>
3061 * The returned {@code Connection} can be assumed to {@link #destroy()} itself when appropriate,
3062 * so users of this method need not maintain a reference to its return value to destroy it.
Evan Charltonbf11f982014-07-20 22:06:28 -07003063 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003064 * @param disconnectCause The disconnect cause, ({@see android.telecomm.DisconnectCause}).
Ihab Awad6107bab2014-08-18 09:23:25 -07003065 * @return A {@code Connection} which indicates failure.
Evan Charltonbf11f982014-07-20 22:06:28 -07003066 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003067 public static Connection createFailedConnection(DisconnectCause disconnectCause) {
3068 return new FailureSignalingConnection(disconnectCause);
Evan Charltonbf11f982014-07-20 22:06:28 -07003069 }
3070
Evan Charltonbf11f982014-07-20 22:06:28 -07003071 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003072 * Override to throw an {@link UnsupportedOperationException} if this {@code Connection} is
3073 * not intended to be mutated, e.g., if it is a marker for failure. Only for framework use;
3074 * this should never be un-@hide-den.
3075 *
3076 * @hide
3077 */
3078 public void checkImmutable() {}
3079
3080 /**
Ihab Awad6107bab2014-08-18 09:23:25 -07003081 * Return a {@code Connection} which represents a canceled connection attempt. The returned
3082 * {@code Connection} will have state {@link #STATE_DISCONNECTED}, and cannot be moved out of
3083 * that state. This connection should not be used for anything, and no other
3084 * {@code Connection}s should be attempted.
3085 * <p>
Ihab Awad6107bab2014-08-18 09:23:25 -07003086 * so users of this method need not maintain a reference to its return value to destroy it.
Evan Charltonbf11f982014-07-20 22:06:28 -07003087 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003088 * @return A {@code Connection} which indicates that the underlying connection should
3089 * be canceled.
Evan Charltonbf11f982014-07-20 22:06:28 -07003090 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003091 public static Connection createCanceledConnection() {
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003092 return new FailureSignalingConnection(new DisconnectCause(DisconnectCause.CANCELED));
Ihab Awad542e0ea2014-05-16 10:22:16 -07003093 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003094
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003095 private final void fireOnConferenceableConnectionsChanged() {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003096 for (Listener l : mListeners) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003097 l.onConferenceablesChanged(this, getConferenceables());
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003098 }
3099 }
3100
Santos Cordon823fd3c2014-08-07 18:35:18 -07003101 private final void fireConferenceChanged() {
3102 for (Listener l : mListeners) {
3103 l.onConferenceChanged(this, mConference);
3104 }
3105 }
3106
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003107 private final void clearConferenceableList() {
Tyler Gunndf2cbc82015-04-20 09:13:01 -07003108 for (Conferenceable c : mConferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003109 if (c instanceof Connection) {
3110 Connection connection = (Connection) c;
3111 connection.removeConnectionListener(mConnectionDeathListener);
3112 } else if (c instanceof Conference) {
3113 Conference conference = (Conference) c;
3114 conference.removeListener(mConferenceDeathListener);
3115 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003116 }
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003117 mConferenceables.clear();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003118 }
Tyler Gunn3bffcf72014-10-28 13:51:27 -07003119
3120 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07003121 * Handles a change to extras received from Telecom.
3122 *
3123 * @param extras The new extras.
3124 * @hide
3125 */
3126 final void handleExtrasChanged(Bundle extras) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003127 Bundle b = null;
3128 synchronized (mExtrasLock) {
3129 mExtras = extras;
3130 if (mExtras != null) {
3131 b = new Bundle(mExtras);
3132 }
3133 }
3134 onExtrasChanged(b);
Tyler Gunndee56a82016-03-23 16:06:34 -07003135 }
3136
3137 /**
Anthony Lee17455a32015-04-24 15:25:29 -07003138 * Notifies listeners that the merge request failed.
3139 *
3140 * @hide
3141 */
3142 protected final void notifyConferenceMergeFailed() {
3143 for (Listener l : mListeners) {
3144 l.onConferenceMergeFailed(this);
3145 }
3146 }
3147
3148 /**
Tyler Gunnab4650c2014-11-06 20:06:23 -08003149 * Notifies listeners of a change to conference participant(s).
Tyler Gunn3bffcf72014-10-28 13:51:27 -07003150 *
Tyler Gunnab4650c2014-11-06 20:06:23 -08003151 * @param conferenceParticipants The participants.
Tyler Gunn3bffcf72014-10-28 13:51:27 -07003152 * @hide
3153 */
Tyler Gunnab4650c2014-11-06 20:06:23 -08003154 protected final void updateConferenceParticipants(
3155 List<ConferenceParticipant> conferenceParticipants) {
Tyler Gunn3bffcf72014-10-28 13:51:27 -07003156 for (Listener l : mListeners) {
Tyler Gunnab4650c2014-11-06 20:06:23 -08003157 l.onConferenceParticipantsChanged(this, conferenceParticipants);
Tyler Gunn3bffcf72014-10-28 13:51:27 -07003158 }
3159 }
Tyler Gunn8a2b1192015-01-29 11:47:24 -08003160
3161 /**
3162 * Notifies listeners that a conference call has been started.
Jay Shrauner55b97522015-04-09 15:15:43 -07003163 * @hide
Tyler Gunn8a2b1192015-01-29 11:47:24 -08003164 */
3165 protected void notifyConferenceStarted() {
3166 for (Listener l : mListeners) {
3167 l.onConferenceStarted();
3168 }
3169 }
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003170
3171 /**
Tyler Gunn7d633d32016-06-24 07:30:10 -07003172 * Notifies listeners when a change has occurred to the Connection which impacts its ability to
3173 * be a part of a conference call.
3174 * @param isConferenceSupported {@code true} if the connection supports being part of a
3175 * conference call, {@code false} otherwise.
3176 * @hide
3177 */
3178 protected void notifyConferenceSupportedChanged(boolean isConferenceSupported) {
3179 for (Listener l : mListeners) {
3180 l.onConferenceSupportedChanged(this, isConferenceSupported);
3181 }
3182 }
3183
3184 /**
Srikanth Chintalafcb15012017-05-04 20:58:34 +05303185 * Notifies listeners when phone account is changed. For example, when the PhoneAccount is
3186 * changed due to an emergency call being redialed.
3187 * @param pHandle The new PhoneAccountHandle for this connection.
3188 * @hide
3189 */
3190 public void notifyPhoneAccountChanged(PhoneAccountHandle pHandle) {
3191 for (Listener l : mListeners) {
3192 l.onPhoneAccountChanged(this, pHandle);
3193 }
3194 }
3195
3196 /**
Pengquan Meng70c9885332017-10-02 18:09:03 -07003197 * Sets the {@link PhoneAccountHandle} associated with this connection.
3198 *
3199 * @hide
3200 */
3201 public void setPhoneAccountHandle(PhoneAccountHandle phoneAccountHandle) {
3202 if (mPhoneAccountHandle != phoneAccountHandle) {
3203 mPhoneAccountHandle = phoneAccountHandle;
3204 notifyPhoneAccountChanged(phoneAccountHandle);
3205 }
3206 }
3207
3208 /**
3209 * Returns the {@link PhoneAccountHandle} associated with this connection.
3210 *
3211 * @hide
3212 */
3213 public PhoneAccountHandle getPhoneAccountHandle() {
3214 return mPhoneAccountHandle;
3215 }
3216
3217 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003218 * Sends an event associated with this {@code Connection} with associated event extras to the
3219 * {@link InCallService}.
3220 * <p>
3221 * Connection events are used to communicate point in time information from a
3222 * {@link ConnectionService} to a {@link InCallService} implementations. An example of a
3223 * custom connection event includes notifying the UI when a WIFI call has been handed over to
3224 * LTE, which the InCall UI might use to inform the user that billing charges may apply. The
3225 * Android Telephony framework will send the {@link #EVENT_CALL_MERGE_FAILED} connection event
3226 * when a call to {@link Call#mergeConference()} has failed to complete successfully. A
3227 * connection event could also be used to trigger UI in the {@link InCallService} which prompts
3228 * the user to make a choice (e.g. whether they want to incur roaming costs for making a call),
3229 * which is communicated back via {@link Call#sendCallEvent(String, Bundle)}.
3230 * <p>
3231 * Events are exposed to {@link InCallService} implementations via
3232 * {@link Call.Callback#onConnectionEvent(Call, String, Bundle)}.
3233 * <p>
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003234 * No assumptions should be made as to how an In-Call UI or service will handle these events.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003235 * The {@link ConnectionService} must assume that the In-Call UI could even chose to ignore
3236 * some events altogether.
3237 * <p>
3238 * Events should be fully qualified (e.g. {@code com.example.event.MY_EVENT}) to avoid
3239 * conflicts between {@link ConnectionService} implementations. Further, custom
3240 * {@link ConnectionService} implementations shall not re-purpose events in the
3241 * {@code android.*} namespace, nor shall they define new event types in this namespace. When
3242 * defining a custom event type, ensure the contents of the extras {@link Bundle} is clearly
3243 * defined. Extra keys for this bundle should be named similar to the event type (e.g.
3244 * {@code com.example.extra.MY_EXTRA}).
3245 * <p>
3246 * When defining events and the associated extras, it is important to keep their behavior
3247 * consistent when the associated {@link ConnectionService} is updated. Support for deprecated
3248 * events/extras should me maintained to ensure backwards compatibility with older
3249 * {@link InCallService} implementations which were built to support the older behavior.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003250 *
3251 * @param event The connection event.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003252 * @param extras Optional bundle containing extra information associated with the event.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003253 */
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003254 public void sendConnectionEvent(String event, Bundle extras) {
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003255 for (Listener l : mListeners) {
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07003256 l.onConnectionEvent(this, event, extras);
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003257 }
3258 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07003259}