blob: 5d5b15d346d38ae0683db6c12743da80edf676d6 [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
587 */
588 public static final String EVENT_HANDOVER_COMPLETE =
589 "android.telecom.event.HANDOVER_COMPLETE";
590
591 /**
592 * Connection event used to inform an {@link InCallService} which initiated a call handover via
593 * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has failed
594 * to complete.
595 * @hide
596 */
597 public static final String EVENT_HANDOVER_FAILED =
598 "android.telecom.event.HANDOVER_FAILED";
599
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700600 // Flag controlling whether PII is emitted into the logs
601 private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG);
602
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800603 /**
604 * Whether the given capabilities support the specified capability.
605 *
606 * @param capabilities A capability bit field.
607 * @param capability The capability to check capabilities for.
608 * @return Whether the specified capability is supported.
609 * @hide
610 */
611 public static boolean can(int capabilities, int capability) {
Tyler Gunn014c7112015-12-18 14:33:57 -0800612 return (capabilities & capability) == capability;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800613 }
614
615 /**
616 * Whether the capabilities of this {@code Connection} supports the specified capability.
617 *
618 * @param capability The capability to check capabilities for.
619 * @return Whether the specified capability is supported.
620 * @hide
621 */
622 public boolean can(int capability) {
623 return can(mConnectionCapabilities, capability);
624 }
625
626 /**
627 * Removes the specified capability from the set of capabilities of this {@code Connection}.
628 *
629 * @param capability The capability to remove from the set.
630 * @hide
631 */
632 public void removeCapability(int capability) {
633 mConnectionCapabilities &= ~capability;
634 }
635
636 /**
637 * Adds the specified capability to the set of capabilities of this {@code Connection}.
638 *
639 * @param capability The capability to add to the set.
640 * @hide
641 */
642 public void addCapability(int capability) {
643 mConnectionCapabilities |= capability;
644 }
645
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700646 /**
647 * Renders a set of capability bits ({@code CAPABILITY_*}) as a human readable string.
648 *
649 * @param capabilities A capability bit field.
650 * @return A human readable string representation.
651 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800652 public static String capabilitiesToString(int capabilities) {
Santos Cordon1a749302016-07-26 16:08:53 -0700653 return capabilitiesToStringInternal(capabilities, true /* isLong */);
654 }
655
656 /**
657 * Renders a set of capability bits ({@code CAPABILITY_*}) as a *short* human readable
658 * string.
659 *
660 * @param capabilities A capability bit field.
661 * @return A human readable string representation.
662 * @hide
663 */
664 public static String capabilitiesToStringShort(int capabilities) {
665 return capabilitiesToStringInternal(capabilities, false /* isLong */);
666 }
667
668 private static String capabilitiesToStringInternal(int capabilities, boolean isLong) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800669 StringBuilder builder = new StringBuilder();
Santos Cordon1a749302016-07-26 16:08:53 -0700670 builder.append("[");
671 if (isLong) {
672 builder.append("Capabilities:");
673 }
674
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800675 if (can(capabilities, CAPABILITY_HOLD)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700676 builder.append(isLong ? " CAPABILITY_HOLD" : " hld");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800677 }
678 if (can(capabilities, CAPABILITY_SUPPORT_HOLD)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700679 builder.append(isLong ? " CAPABILITY_SUPPORT_HOLD" : " sup_hld");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800680 }
681 if (can(capabilities, CAPABILITY_MERGE_CONFERENCE)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700682 builder.append(isLong ? " CAPABILITY_MERGE_CONFERENCE" : " mrg_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800683 }
684 if (can(capabilities, CAPABILITY_SWAP_CONFERENCE)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700685 builder.append(isLong ? " CAPABILITY_SWAP_CONFERENCE" : " swp_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800686 }
687 if (can(capabilities, CAPABILITY_RESPOND_VIA_TEXT)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700688 builder.append(isLong ? " CAPABILITY_RESPOND_VIA_TEXT" : " txt");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800689 }
690 if (can(capabilities, CAPABILITY_MUTE)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700691 builder.append(isLong ? " CAPABILITY_MUTE" : " mut");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800692 }
693 if (can(capabilities, CAPABILITY_MANAGE_CONFERENCE)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700694 builder.append(isLong ? " CAPABILITY_MANAGE_CONFERENCE" : " mng_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800695 }
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700696 if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_RX)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700697 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_RX" : " VTlrx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700698 }
699 if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_TX)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700700 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_TX" : " VTltx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700701 }
Andrew Lee9a8f9ce2015-04-10 18:09:46 -0700702 if (can(capabilities, CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700703 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL" : " VTlbi");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800704 }
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700705 if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_RX)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700706 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_RX" : " VTrrx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700707 }
708 if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_TX)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700709 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_TX" : " VTrtx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700710 }
Andrew Lee9a8f9ce2015-04-10 18:09:46 -0700711 if (can(capabilities, CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700712 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL" : " VTrbi");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800713 }
Tyler Gunnf97a0092016-01-19 15:59:34 -0800714 if (can(capabilities, CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700715 builder.append(isLong ? " CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO" : " !v2a");
Tyler Gunnf97a0092016-01-19 15:59:34 -0800716 }
Dong Zhou89f41eb2015-03-15 11:59:49 -0500717 if (can(capabilities, CAPABILITY_SPEED_UP_MT_AUDIO)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700718 builder.append(isLong ? " CAPABILITY_SPEED_UP_MT_AUDIO" : " spd_aud");
Dong Zhou89f41eb2015-03-15 11:59:49 -0500719 }
Rekha Kumar07366812015-03-24 16:42:31 -0700720 if (can(capabilities, CAPABILITY_CAN_UPGRADE_TO_VIDEO)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700721 builder.append(isLong ? " CAPABILITY_CAN_UPGRADE_TO_VIDEO" : " a2v");
Rekha Kumar07366812015-03-24 16:42:31 -0700722 }
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700723 if (can(capabilities, CAPABILITY_CAN_PAUSE_VIDEO)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700724 builder.append(isLong ? " CAPABILITY_CAN_PAUSE_VIDEO" : " paus_VT");
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700725 }
Tyler Gunnd4091732015-06-29 09:15:37 -0700726 if (can(capabilities, CAPABILITY_CONFERENCE_HAS_NO_CHILDREN)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700727 builder.append(isLong ? " CAPABILITY_SINGLE_PARTY_CONFERENCE" : " 1p_cnf");
Tyler Gunnd4091732015-06-29 09:15:37 -0700728 }
Bryce Lee81901682015-08-28 16:38:02 -0700729 if (can(capabilities, CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700730 builder.append(isLong ? " CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION" : " rsp_by_con");
Bryce Lee81901682015-08-28 16:38:02 -0700731 }
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700732 if (can(capabilities, CAPABILITY_CAN_PULL_CALL)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700733 builder.append(isLong ? " CAPABILITY_CAN_PULL_CALL" : " pull");
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700734 }
Pooja Jaind34698d2017-12-28 14:15:31 +0530735 if (can(capabilities, CAPABILITY_SUPPORT_DEFLECT)) {
736 builder.append(isLong ? " CAPABILITY_SUPPORT_DEFLECT" : " sup_def");
737 }
Bryce Lee81901682015-08-28 16:38:02 -0700738
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800739 builder.append("]");
740 return builder.toString();
741 }
742
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700743 /**
744 * Renders a set of property bits ({@code PROPERTY_*}) as a human readable string.
745 *
746 * @param properties A property bit field.
747 * @return A human readable string representation.
748 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700749 public static String propertiesToString(int properties) {
Santos Cordon1a749302016-07-26 16:08:53 -0700750 return propertiesToStringInternal(properties, true /* isLong */);
751 }
752
753 /**
754 * Renders a set of property bits ({@code PROPERTY_*}) as a *short* human readable string.
755 *
756 * @param properties A property bit field.
757 * @return A human readable string representation.
758 * @hide
759 */
760 public static String propertiesToStringShort(int properties) {
761 return propertiesToStringInternal(properties, false /* isLong */);
762 }
763
764 private static String propertiesToStringInternal(int properties, boolean isLong) {
Tyler Gunn720c6642016-03-22 09:02:47 -0700765 StringBuilder builder = new StringBuilder();
Santos Cordon1a749302016-07-26 16:08:53 -0700766 builder.append("[");
767 if (isLong) {
768 builder.append("Properties:");
769 }
Tyler Gunn720c6642016-03-22 09:02:47 -0700770
Tyler Gunnf5035432017-01-09 09:43:12 -0800771 if (can(properties, PROPERTY_SELF_MANAGED)) {
772 builder.append(isLong ? " PROPERTY_SELF_MANAGED" : " self_mng");
773 }
774
Hall Liu25c7c4d2016-08-30 13:41:02 -0700775 if (can(properties, PROPERTY_EMERGENCY_CALLBACK_MODE)) {
776 builder.append(isLong ? " PROPERTY_EMERGENCY_CALLBACK_MODE" : " ecbm");
Tyler Gunn720c6642016-03-22 09:02:47 -0700777 }
778
779 if (can(properties, PROPERTY_HIGH_DEF_AUDIO)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700780 builder.append(isLong ? " PROPERTY_HIGH_DEF_AUDIO" : " HD");
Tyler Gunn720c6642016-03-22 09:02:47 -0700781 }
782
783 if (can(properties, PROPERTY_WIFI)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700784 builder.append(isLong ? " PROPERTY_WIFI" : " wifi");
Tyler Gunn720c6642016-03-22 09:02:47 -0700785 }
786
787 if (can(properties, PROPERTY_GENERIC_CONFERENCE)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700788 builder.append(isLong ? " PROPERTY_GENERIC_CONFERENCE" : " gen_conf");
Tyler Gunn720c6642016-03-22 09:02:47 -0700789 }
790
791 if (can(properties, PROPERTY_IS_EXTERNAL_CALL)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700792 builder.append(isLong ? " PROPERTY_IS_EXTERNAL_CALL" : " xtrnl");
Tyler Gunn720c6642016-03-22 09:02:47 -0700793 }
794
Brad Ebinger15847072016-05-18 11:08:36 -0700795 if (can(properties, PROPERTY_HAS_CDMA_VOICE_PRIVACY)) {
Santos Cordon1a749302016-07-26 16:08:53 -0700796 builder.append(isLong ? " PROPERTY_HAS_CDMA_VOICE_PRIVACY" : " priv");
Brad Ebinger15847072016-05-18 11:08:36 -0700797 }
798
Hall Liud4d2a8a2018-01-29 17:22:02 -0800799 if (can(properties, PROPERTY_IS_RTT)) {
800 builder.append(isLong ? " PROPERTY_IS_RTT" : " rtt");
801 }
802
Tyler Gunn720c6642016-03-22 09:02:47 -0700803 builder.append("]");
804 return builder.toString();
805 }
806
Sailesh Nepal091768c2014-06-30 15:15:23 -0700807 /** @hide */
Sailesh Nepal61203862014-07-11 14:50:13 -0700808 public abstract static class Listener {
Ihab Awad542e0ea2014-05-16 10:22:16 -0700809 public void onStateChanged(Connection c, int state) {}
Andrew Lee100e2932014-09-08 15:34:24 -0700810 public void onAddressChanged(Connection c, Uri newAddress, int presentation) {}
Sailesh Nepal61203862014-07-11 14:50:13 -0700811 public void onCallerDisplayNameChanged(
812 Connection c, String callerDisplayName, int presentation) {}
Tyler Gunnaa07df82014-07-17 07:50:22 -0700813 public void onVideoStateChanged(Connection c, int videoState) {}
Andrew Lee7f3d41f2014-09-11 17:33:16 -0700814 public void onDisconnected(Connection c, DisconnectCause disconnectCause) {}
Sailesh Nepal091768c2014-06-30 15:15:23 -0700815 public void onPostDialWait(Connection c, String remaining) {}
Nancy Chen27d1c2d2014-12-15 16:12:50 -0800816 public void onPostDialChar(Connection c, char nextChar) {}
Andrew Lee100e2932014-09-08 15:34:24 -0700817 public void onRingbackRequested(Connection c, boolean ringback) {}
Sailesh Nepal61203862014-07-11 14:50:13 -0700818 public void onDestroyed(Connection c) {}
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800819 public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {}
Tyler Gunn720c6642016-03-22 09:02:47 -0700820 public void onConnectionPropertiesChanged(Connection c, int properties) {}
Christine Hallstrom2830ce92016-11-30 16:06:42 -0800821 public void onSupportedAudioRoutesChanged(Connection c, int supportedAudioRoutes) {}
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700822 public void onVideoProviderChanged(
823 Connection c, VideoProvider videoProvider) {}
Sailesh Nepal001bbbb2014-07-15 14:40:39 -0700824 public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {}
825 public void onStatusHintsChanged(Connection c, StatusHints statusHints) {}
Tyler Gunn6d76ca02014-11-17 15:49:51 -0800826 public void onConferenceablesChanged(
Tyler Gunndf2cbc82015-04-20 09:13:01 -0700827 Connection c, List<Conferenceable> conferenceables) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -0700828 public void onConferenceChanged(Connection c, Conference conference) {}
Tyler Gunn3bffcf72014-10-28 13:51:27 -0700829 /** @hide */
Tyler Gunnab4650c2014-11-06 20:06:23 -0800830 public void onConferenceParticipantsChanged(Connection c,
831 List<ConferenceParticipant> participants) {}
Tyler Gunn8a2b1192015-01-29 11:47:24 -0800832 public void onConferenceStarted() {}
Anthony Lee17455a32015-04-24 15:25:29 -0700833 public void onConferenceMergeFailed(Connection c) {}
Santos Cordon6b7f9552015-05-27 17:21:45 -0700834 public void onExtrasChanged(Connection c, Bundle extras) {}
Tyler Gunndee56a82016-03-23 16:06:34 -0700835 public void onExtrasRemoved(Connection c, List<String> keys) {}
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700836 public void onConnectionEvent(Connection c, String event, Bundle extras) {}
Tyler Gunn7d633d32016-06-24 07:30:10 -0700837 /** @hide */
838 public void onConferenceSupportedChanged(Connection c, boolean isConferenceSupported) {}
Hall Liua98f58b52017-11-07 17:59:28 -0800839 public void onAudioRouteChanged(Connection c, int audioRoute, String bluetoothAddress) {}
Hall Liub64ac4c2017-02-06 10:49:48 -0800840 public void onRttInitiationSuccess(Connection c) {}
841 public void onRttInitiationFailure(Connection c, int reason) {}
842 public void onRttSessionRemotelyTerminated(Connection c) {}
843 public void onRemoteRttRequest(Connection c) {}
Srikanth Chintalafcb15012017-05-04 20:58:34 +0530844 /** @hide */
845 public void onPhoneAccountChanged(Connection c, PhoneAccountHandle pHandle) {}
Mengjun Leng25707742017-07-04 11:10:37 +0800846 public void onConnectionTimeReset(Connection c) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -0700847 }
848
Tyler Gunnb702ef82015-05-29 11:51:53 -0700849 /**
Hall Liu95d55872017-01-25 17:12:49 -0800850 * Provides methods to read and write RTT data to/from the in-call app.
Hall Liu95d55872017-01-25 17:12:49 -0800851 */
852 public static final class RttTextStream {
853 private static final int READ_BUFFER_SIZE = 1000;
854 private final InputStreamReader mPipeFromInCall;
855 private final OutputStreamWriter mPipeToInCall;
Hall Liub64ac4c2017-02-06 10:49:48 -0800856 private final ParcelFileDescriptor mFdFromInCall;
857 private final ParcelFileDescriptor mFdToInCall;
Hall Liu95d55872017-01-25 17:12:49 -0800858 private char[] mReadBuffer = new char[READ_BUFFER_SIZE];
859
860 /**
861 * @hide
862 */
863 public RttTextStream(ParcelFileDescriptor toInCall, ParcelFileDescriptor fromInCall) {
Hall Liub64ac4c2017-02-06 10:49:48 -0800864 mFdFromInCall = fromInCall;
865 mFdToInCall = toInCall;
Hall Liu95d55872017-01-25 17:12:49 -0800866 mPipeFromInCall = new InputStreamReader(
Hall Liua549fed2018-02-09 16:40:03 -0800867 new FileInputStream(fromInCall.getFileDescriptor()));
Hall Liu95d55872017-01-25 17:12:49 -0800868 mPipeToInCall = new OutputStreamWriter(
Hall Liua549fed2018-02-09 16:40:03 -0800869 new FileOutputStream(toInCall.getFileDescriptor()));
Hall Liu95d55872017-01-25 17:12:49 -0800870 }
871
872 /**
873 * Writes the string {@param input} into the text stream to the UI for this RTT call. Since
874 * RTT transmits text in real-time, this method should be called as often as text snippets
875 * are received from the remote user, even if it is only one character.
Hall Liua549fed2018-02-09 16:40:03 -0800876 * <p>
Hall Liu95d55872017-01-25 17:12:49 -0800877 * This method is not thread-safe -- calling it from multiple threads simultaneously may
878 * lead to interleaved text.
Hall Liua549fed2018-02-09 16:40:03 -0800879 *
Hall Liu95d55872017-01-25 17:12:49 -0800880 * @param input The message to send to the in-call app.
881 */
882 public void write(String input) throws IOException {
883 mPipeToInCall.write(input);
884 mPipeToInCall.flush();
885 }
886
887
888 /**
889 * Reads a string from the in-call app, blocking if there is no data available. Returns
890 * {@code null} if the RTT conversation has been terminated and there is no further data
891 * to read.
Hall Liua549fed2018-02-09 16:40:03 -0800892 * <p>
Hall Liu95d55872017-01-25 17:12:49 -0800893 * This method is not thread-safe -- calling it from multiple threads simultaneously may
894 * lead to interleaved text.
Hall Liua549fed2018-02-09 16:40:03 -0800895 *
Hall Liu95d55872017-01-25 17:12:49 -0800896 * @return A string containing text entered by the user, or {@code null} if the
897 * conversation has been terminated or if there was an error while reading.
898 */
Hall Liuffa4a812017-03-02 16:11:00 -0800899 public String read() throws IOException {
900 int numRead = mPipeFromInCall.read(mReadBuffer, 0, READ_BUFFER_SIZE);
901 if (numRead < 0) {
902 return null;
903 }
904 return new String(mReadBuffer, 0, numRead);
905 }
906
907 /**
908 * Non-blocking version of {@link #read()}. Returns {@code null} if there is nothing to
909 * be read.
Hall Liua549fed2018-02-09 16:40:03 -0800910 *
Hall Liuffa4a812017-03-02 16:11:00 -0800911 * @return A string containing text entered by the user, or {@code null} if the user has
912 * not entered any new text yet.
913 */
914 public String readImmediately() throws IOException {
915 if (mPipeFromInCall.ready()) {
916 return read();
917 } else {
Hall Liu95d55872017-01-25 17:12:49 -0800918 return null;
919 }
920 }
Hall Liub64ac4c2017-02-06 10:49:48 -0800921
922 /** @hide */
923 public ParcelFileDescriptor getFdFromInCall() {
924 return mFdFromInCall;
925 }
926
927 /** @hide */
928 public ParcelFileDescriptor getFdToInCall() {
929 return mFdToInCall;
930 }
931 }
932
933 /**
934 * Provides constants to represent the results of responses to session modify requests sent via
935 * {@link Call#sendRttRequest()}
936 */
937 public static final class RttModifyStatus {
Hall Liu8dd49082017-04-21 14:33:12 -0700938 private RttModifyStatus() {}
Hall Liub64ac4c2017-02-06 10:49:48 -0800939 /**
940 * Session modify request was successful.
941 */
942 public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1;
943
944 /**
945 * Session modify request failed.
946 */
947 public static final int SESSION_MODIFY_REQUEST_FAIL = 2;
948
949 /**
950 * Session modify request ignored due to invalid parameters.
951 */
952 public static final int SESSION_MODIFY_REQUEST_INVALID = 3;
953
954 /**
955 * Session modify request timed out.
956 */
957 public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4;
958
959 /**
960 * Session modify request rejected by remote user.
961 */
962 public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5;
Hall Liu95d55872017-01-25 17:12:49 -0800963 }
964
965 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700966 * Provides a means of controlling the video session associated with a {@link Connection}.
967 * <p>
968 * Implementations create a custom subclass of {@link VideoProvider} and the
969 * {@link ConnectionService} creates an instance sets it on the {@link Connection} using
970 * {@link Connection#setVideoProvider(VideoProvider)}. Any connection which supports video
971 * should set the {@link VideoProvider}.
972 * <p>
973 * The {@link VideoProvider} serves two primary purposes: it provides a means for Telecom and
974 * {@link InCallService} implementations to issue requests related to the video session;
975 * it provides a means for the {@link ConnectionService} to report events and information
976 * related to the video session to Telecom and the {@link InCallService} implementations.
977 * <p>
978 * {@link InCallService} implementations interact with the {@link VideoProvider} via
979 * {@link android.telecom.InCallService.VideoCall}.
980 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700981 public static abstract class VideoProvider {
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700982 /**
983 * Video is not being received (no protocol pause was issued).
Tyler Gunnb702ef82015-05-29 11:51:53 -0700984 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700985 */
986 public static final int SESSION_EVENT_RX_PAUSE = 1;
Evan Charltonbf11f982014-07-20 22:06:28 -0700987
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700988 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -0700989 * Video reception has resumed after a {@link #SESSION_EVENT_RX_PAUSE}.
990 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700991 */
992 public static final int SESSION_EVENT_RX_RESUME = 2;
993
994 /**
995 * Video transmission has begun. This occurs after a negotiated start of video transmission
996 * when the underlying protocol has actually begun transmitting video to the remote party.
Tyler Gunnb702ef82015-05-29 11:51:53 -0700997 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700998 */
999 public static final int SESSION_EVENT_TX_START = 3;
1000
1001 /**
1002 * Video transmission has stopped. This occurs after a negotiated stop of video transmission
1003 * when the underlying protocol has actually stopped transmitting video to the remote party.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001004 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001005 */
1006 public static final int SESSION_EVENT_TX_STOP = 4;
1007
1008 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001009 * A camera failure has occurred for the selected camera. The {@link VideoProvider} can use
Tyler Gunnb702ef82015-05-29 11:51:53 -07001010 * this as a cue to inform the user the camera is not available.
1011 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001012 */
1013 public static final int SESSION_EVENT_CAMERA_FAILURE = 5;
1014
1015 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001016 * Issued after {@link #SESSION_EVENT_CAMERA_FAILURE} when the camera is once again ready
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001017 * for operation. The {@link VideoProvider} can use this as a cue to inform the user that
Tyler Gunnb702ef82015-05-29 11:51:53 -07001018 * the camera has become available again.
1019 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001020 */
1021 public static final int SESSION_EVENT_CAMERA_READY = 6;
1022
1023 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001024 * Session event raised by Telecom when
1025 * {@link android.telecom.InCallService.VideoCall#setCamera(String)} is called and the
1026 * caller does not have the necessary {@link android.Manifest.permission#CAMERA} permission.
1027 * @see #handleCallSessionEvent(int)
1028 */
1029 public static final int SESSION_EVENT_CAMERA_PERMISSION_ERROR = 7;
1030
1031 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001032 * Session modify request was successful.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001033 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001034 */
1035 public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1;
1036
1037 /**
1038 * Session modify request failed.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001039 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001040 */
1041 public static final int SESSION_MODIFY_REQUEST_FAIL = 2;
1042
1043 /**
1044 * Session modify request ignored due to invalid parameters.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001045 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001046 */
1047 public static final int SESSION_MODIFY_REQUEST_INVALID = 3;
1048
Rekha Kumar07366812015-03-24 16:42:31 -07001049 /**
1050 * Session modify request timed out.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001051 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Rekha Kumar07366812015-03-24 16:42:31 -07001052 */
1053 public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4;
1054
1055 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001056 * Session modify request rejected by remote user.
1057 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Rekha Kumar07366812015-03-24 16:42:31 -07001058 */
1059 public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5;
1060
Tyler Gunn75958422015-04-15 14:23:42 -07001061 private static final int MSG_ADD_VIDEO_CALLBACK = 1;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001062 private static final int MSG_SET_CAMERA = 2;
1063 private static final int MSG_SET_PREVIEW_SURFACE = 3;
1064 private static final int MSG_SET_DISPLAY_SURFACE = 4;
1065 private static final int MSG_SET_DEVICE_ORIENTATION = 5;
1066 private static final int MSG_SET_ZOOM = 6;
1067 private static final int MSG_SEND_SESSION_MODIFY_REQUEST = 7;
1068 private static final int MSG_SEND_SESSION_MODIFY_RESPONSE = 8;
1069 private static final int MSG_REQUEST_CAMERA_CAPABILITIES = 9;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001070 private static final int MSG_REQUEST_CONNECTION_DATA_USAGE = 10;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001071 private static final int MSG_SET_PAUSE_IMAGE = 11;
Tyler Gunn75958422015-04-15 14:23:42 -07001072 private static final int MSG_REMOVE_VIDEO_CALLBACK = 12;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001073
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001074 private static final String SESSION_EVENT_RX_PAUSE_STR = "RX_PAUSE";
1075 private static final String SESSION_EVENT_RX_RESUME_STR = "RX_RESUME";
1076 private static final String SESSION_EVENT_TX_START_STR = "TX_START";
1077 private static final String SESSION_EVENT_TX_STOP_STR = "TX_STOP";
1078 private static final String SESSION_EVENT_CAMERA_FAILURE_STR = "CAMERA_FAIL";
1079 private static final String SESSION_EVENT_CAMERA_READY_STR = "CAMERA_READY";
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001080 private static final String SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR =
1081 "CAMERA_PERMISSION_ERROR";
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001082 private static final String SESSION_EVENT_UNKNOWN_STR = "UNKNOWN";
1083
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001084 private VideoProvider.VideoProviderHandler mMessageHandler;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001085 private final VideoProvider.VideoProviderBinder mBinder;
Tyler Gunn75958422015-04-15 14:23:42 -07001086
1087 /**
1088 * Stores a list of the video callbacks, keyed by IBinder.
Tyler Gunn84f381b2015-06-12 09:26:45 -07001089 *
1090 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
1091 * load factor before resizing, 1 means we only expect a single thread to
1092 * access the map so make only a single shard
Tyler Gunn75958422015-04-15 14:23:42 -07001093 */
Tyler Gunn84f381b2015-06-12 09:26:45 -07001094 private ConcurrentHashMap<IBinder, IVideoCallback> mVideoCallbacks =
1095 new ConcurrentHashMap<IBinder, IVideoCallback>(8, 0.9f, 1);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001096
1097 /**
1098 * Default handler used to consolidate binder method calls onto a single thread.
1099 */
1100 private final class VideoProviderHandler extends Handler {
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001101 public VideoProviderHandler() {
1102 super();
1103 }
1104
1105 public VideoProviderHandler(Looper looper) {
1106 super(looper);
1107 }
1108
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001109 @Override
1110 public void handleMessage(Message msg) {
1111 switch (msg.what) {
Tyler Gunn75958422015-04-15 14:23:42 -07001112 case MSG_ADD_VIDEO_CALLBACK: {
1113 IBinder binder = (IBinder) msg.obj;
1114 IVideoCallback callback = IVideoCallback.Stub
1115 .asInterface((IBinder) msg.obj);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001116 if (callback == null) {
1117 Log.w(this, "addVideoProvider - skipped; callback is null.");
1118 break;
1119 }
1120
Tyler Gunn75958422015-04-15 14:23:42 -07001121 if (mVideoCallbacks.containsKey(binder)) {
1122 Log.i(this, "addVideoProvider - skipped; already present.");
1123 break;
1124 }
1125 mVideoCallbacks.put(binder, callback);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001126 break;
Tyler Gunn75958422015-04-15 14:23:42 -07001127 }
1128 case MSG_REMOVE_VIDEO_CALLBACK: {
1129 IBinder binder = (IBinder) msg.obj;
1130 IVideoCallback callback = IVideoCallback.Stub
1131 .asInterface((IBinder) msg.obj);
1132 if (!mVideoCallbacks.containsKey(binder)) {
1133 Log.i(this, "removeVideoProvider - skipped; not present.");
1134 break;
1135 }
1136 mVideoCallbacks.remove(binder);
1137 break;
1138 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001139 case MSG_SET_CAMERA:
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001140 {
1141 SomeArgs args = (SomeArgs) msg.obj;
1142 try {
1143 onSetCamera((String) args.arg1);
1144 onSetCamera((String) args.arg1, (String) args.arg2, args.argi1,
Tyler Gunn159f35c2017-03-02 09:28:37 -08001145 args.argi2, args.argi3);
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001146 } finally {
1147 args.recycle();
1148 }
1149 }
1150 break;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001151 case MSG_SET_PREVIEW_SURFACE:
1152 onSetPreviewSurface((Surface) msg.obj);
1153 break;
1154 case MSG_SET_DISPLAY_SURFACE:
1155 onSetDisplaySurface((Surface) msg.obj);
1156 break;
1157 case MSG_SET_DEVICE_ORIENTATION:
1158 onSetDeviceOrientation(msg.arg1);
1159 break;
1160 case MSG_SET_ZOOM:
1161 onSetZoom((Float) msg.obj);
1162 break;
Tyler Gunn45382162015-05-06 08:52:27 -07001163 case MSG_SEND_SESSION_MODIFY_REQUEST: {
1164 SomeArgs args = (SomeArgs) msg.obj;
1165 try {
1166 onSendSessionModifyRequest((VideoProfile) args.arg1,
1167 (VideoProfile) args.arg2);
1168 } finally {
1169 args.recycle();
1170 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001171 break;
Tyler Gunn45382162015-05-06 08:52:27 -07001172 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001173 case MSG_SEND_SESSION_MODIFY_RESPONSE:
1174 onSendSessionModifyResponse((VideoProfile) msg.obj);
1175 break;
1176 case MSG_REQUEST_CAMERA_CAPABILITIES:
1177 onRequestCameraCapabilities();
1178 break;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001179 case MSG_REQUEST_CONNECTION_DATA_USAGE:
1180 onRequestConnectionDataUsage();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001181 break;
1182 case MSG_SET_PAUSE_IMAGE:
Yorke Lee32f24732015-05-12 16:18:03 -07001183 onSetPauseImage((Uri) msg.obj);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001184 break;
1185 default:
1186 break;
1187 }
1188 }
1189 }
1190
1191 /**
1192 * IVideoProvider stub implementation.
1193 */
1194 private final class VideoProviderBinder extends IVideoProvider.Stub {
Tyler Gunn75958422015-04-15 14:23:42 -07001195 public void addVideoCallback(IBinder videoCallbackBinder) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001196 mMessageHandler.obtainMessage(
Tyler Gunn75958422015-04-15 14:23:42 -07001197 MSG_ADD_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget();
1198 }
1199
1200 public void removeVideoCallback(IBinder videoCallbackBinder) {
1201 mMessageHandler.obtainMessage(
1202 MSG_REMOVE_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001203 }
1204
Tyler Gunn159f35c2017-03-02 09:28:37 -08001205 public void setCamera(String cameraId, String callingPackageName,
1206 int targetSdkVersion) {
1207
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001208 SomeArgs args = SomeArgs.obtain();
1209 args.arg1 = cameraId;
1210 // Propagate the calling package; originally determined in
1211 // android.telecom.InCallService.VideoCall#setCamera(String) from the calling
1212 // process.
1213 args.arg2 = callingPackageName;
1214 // Pass along the uid and pid of the calling app; this gets lost when we put the
1215 // message onto the handler. These are required for Telecom to perform a permission
1216 // check to see if the calling app is able to use the camera.
1217 args.argi1 = Binder.getCallingUid();
1218 args.argi2 = Binder.getCallingPid();
Tyler Gunn159f35c2017-03-02 09:28:37 -08001219 // Pass along the target SDK version of the calling InCallService. This is used to
1220 // maintain backwards compatibility of the API for older callers.
1221 args.argi3 = targetSdkVersion;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001222 mMessageHandler.obtainMessage(MSG_SET_CAMERA, args).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001223 }
1224
1225 public void setPreviewSurface(Surface surface) {
1226 mMessageHandler.obtainMessage(MSG_SET_PREVIEW_SURFACE, surface).sendToTarget();
1227 }
1228
1229 public void setDisplaySurface(Surface surface) {
1230 mMessageHandler.obtainMessage(MSG_SET_DISPLAY_SURFACE, surface).sendToTarget();
1231 }
1232
1233 public void setDeviceOrientation(int rotation) {
Rekha Kumar07366812015-03-24 16:42:31 -07001234 mMessageHandler.obtainMessage(
1235 MSG_SET_DEVICE_ORIENTATION, rotation, 0).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001236 }
1237
1238 public void setZoom(float value) {
1239 mMessageHandler.obtainMessage(MSG_SET_ZOOM, value).sendToTarget();
1240 }
1241
Tyler Gunn45382162015-05-06 08:52:27 -07001242 public void sendSessionModifyRequest(VideoProfile fromProfile, VideoProfile toProfile) {
1243 SomeArgs args = SomeArgs.obtain();
1244 args.arg1 = fromProfile;
1245 args.arg2 = toProfile;
1246 mMessageHandler.obtainMessage(MSG_SEND_SESSION_MODIFY_REQUEST, args).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001247 }
1248
1249 public void sendSessionModifyResponse(VideoProfile responseProfile) {
1250 mMessageHandler.obtainMessage(
1251 MSG_SEND_SESSION_MODIFY_RESPONSE, responseProfile).sendToTarget();
1252 }
1253
1254 public void requestCameraCapabilities() {
1255 mMessageHandler.obtainMessage(MSG_REQUEST_CAMERA_CAPABILITIES).sendToTarget();
1256 }
1257
1258 public void requestCallDataUsage() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001259 mMessageHandler.obtainMessage(MSG_REQUEST_CONNECTION_DATA_USAGE).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001260 }
1261
Yorke Lee32f24732015-05-12 16:18:03 -07001262 public void setPauseImage(Uri uri) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001263 mMessageHandler.obtainMessage(MSG_SET_PAUSE_IMAGE, uri).sendToTarget();
1264 }
1265 }
1266
1267 public VideoProvider() {
1268 mBinder = new VideoProvider.VideoProviderBinder();
Tyler Gunn84f381b2015-06-12 09:26:45 -07001269 mMessageHandler = new VideoProvider.VideoProviderHandler(Looper.getMainLooper());
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001270 }
1271
1272 /**
1273 * Creates an instance of the {@link VideoProvider}, specifying the looper to use.
1274 *
1275 * @param looper The looper.
1276 * @hide
1277 */
Mathew Inwood42346d12018-08-01 11:33:05 +01001278 @UnsupportedAppUsage
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001279 public VideoProvider(Looper looper) {
1280 mBinder = new VideoProvider.VideoProviderBinder();
1281 mMessageHandler = new VideoProvider.VideoProviderHandler(looper);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001282 }
1283
1284 /**
1285 * Returns binder object which can be used across IPC methods.
1286 * @hide
1287 */
1288 public final IVideoProvider getInterface() {
1289 return mBinder;
1290 }
1291
1292 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001293 * Sets the camera to be used for the outgoing video.
1294 * <p>
1295 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1296 * camera via
1297 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1298 * <p>
1299 * Sent from the {@link InCallService} via
1300 * {@link InCallService.VideoCall#setCamera(String)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001301 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001302 * @param cameraId The id of the camera (use ids as reported by
1303 * {@link CameraManager#getCameraIdList()}).
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001304 */
1305 public abstract void onSetCamera(String cameraId);
1306
1307 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001308 * Sets the camera to be used for the outgoing video.
1309 * <p>
1310 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1311 * camera via
1312 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1313 * <p>
1314 * This prototype is used internally to ensure that the calling package name, UID and PID
1315 * are sent to Telecom so that can perform a camera permission check on the caller.
1316 * <p>
1317 * Sent from the {@link InCallService} via
1318 * {@link InCallService.VideoCall#setCamera(String)}.
1319 *
1320 * @param cameraId The id of the camera (use ids as reported by
1321 * {@link CameraManager#getCameraIdList()}).
1322 * @param callingPackageName The AppOpps package name of the caller.
1323 * @param callingUid The UID of the caller.
1324 * @param callingPid The PID of the caller.
Tyler Gunn159f35c2017-03-02 09:28:37 -08001325 * @param targetSdkVersion The target SDK version of the caller.
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001326 * @hide
1327 */
1328 public void onSetCamera(String cameraId, String callingPackageName, int callingUid,
Tyler Gunn159f35c2017-03-02 09:28:37 -08001329 int callingPid, int targetSdkVersion) {}
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001330
1331 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001332 * Sets the surface to be used for displaying a preview of what the user's camera is
1333 * currently capturing. When video transmission is enabled, this is the video signal which
1334 * is sent to the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001335 * <p>
1336 * Sent from the {@link InCallService} via
1337 * {@link InCallService.VideoCall#setPreviewSurface(Surface)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001338 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001339 * @param surface The {@link Surface}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001340 */
1341 public abstract void onSetPreviewSurface(Surface surface);
1342
1343 /**
1344 * Sets the surface to be used for displaying the video received from the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001345 * <p>
1346 * Sent from the {@link InCallService} via
1347 * {@link InCallService.VideoCall#setDisplaySurface(Surface)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001348 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001349 * @param surface The {@link Surface}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001350 */
1351 public abstract void onSetDisplaySurface(Surface surface);
1352
1353 /**
1354 * Sets the device orientation, in degrees. Assumes that a standard portrait orientation of
1355 * the device is 0 degrees.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001356 * <p>
1357 * Sent from the {@link InCallService} via
1358 * {@link InCallService.VideoCall#setDeviceOrientation(int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001359 *
1360 * @param rotation The device orientation, in degrees.
1361 */
1362 public abstract void onSetDeviceOrientation(int rotation);
1363
1364 /**
1365 * Sets camera zoom ratio.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001366 * <p>
1367 * Sent from the {@link InCallService} via {@link InCallService.VideoCall#setZoom(float)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001368 *
1369 * @param value The camera zoom ratio.
1370 */
1371 public abstract void onSetZoom(float value);
1372
1373 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001374 * Issues a request to modify the properties of the current video session.
1375 * <p>
1376 * Example scenarios include: requesting an audio-only call to be upgraded to a
1377 * bi-directional video call, turning on or off the user's camera, sending a pause signal
1378 * when the {@link InCallService} is no longer the foreground application.
1379 * <p>
1380 * If the {@link VideoProvider} determines a request to be invalid, it should call
1381 * {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)} to report the
1382 * invalid request back to the {@link InCallService}.
1383 * <p>
1384 * Where a request requires confirmation from the user of the peer device, the
1385 * {@link VideoProvider} must communicate the request to the peer device and handle the
1386 * user's response. {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)}
1387 * is used to inform the {@link InCallService} of the result of the request.
1388 * <p>
1389 * Sent from the {@link InCallService} via
1390 * {@link InCallService.VideoCall#sendSessionModifyRequest(VideoProfile)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001391 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001392 * @param fromProfile The video profile prior to the request.
1393 * @param toProfile The video profile with the requested changes made.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001394 */
Tyler Gunn45382162015-05-06 08:52:27 -07001395 public abstract void onSendSessionModifyRequest(VideoProfile fromProfile,
1396 VideoProfile toProfile);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001397
Tyler Gunnb702ef82015-05-29 11:51:53 -07001398 /**
1399 * Provides a response to a request to change the current video session properties.
1400 * <p>
1401 * For example, if the peer requests and upgrade from an audio-only call to a bi-directional
1402 * video call, could decline the request and keep the call as audio-only.
1403 * In such a scenario, the {@code responseProfile} would have a video state of
1404 * {@link VideoProfile#STATE_AUDIO_ONLY}. If the user had decided to accept the request,
1405 * the video state would be {@link VideoProfile#STATE_BIDIRECTIONAL}.
1406 * <p>
1407 * Sent from the {@link InCallService} via
1408 * {@link InCallService.VideoCall#sendSessionModifyResponse(VideoProfile)} in response to
1409 * a {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)}
1410 * callback.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001411 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001412 * @param responseProfile The response video profile.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001413 */
1414 public abstract void onSendSessionModifyResponse(VideoProfile responseProfile);
1415
1416 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001417 * Issues a request to the {@link VideoProvider} to retrieve the camera capabilities.
1418 * <p>
1419 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1420 * camera via
1421 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1422 * <p>
1423 * Sent from the {@link InCallService} via
1424 * {@link InCallService.VideoCall#requestCameraCapabilities()}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001425 */
1426 public abstract void onRequestCameraCapabilities();
1427
1428 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001429 * Issues a request to the {@link VideoProvider} to retrieve the current data usage for the
1430 * video component of the current {@link Connection}.
1431 * <p>
1432 * The {@link VideoProvider} should respond by communicating current data usage, in bytes,
1433 * via {@link VideoProvider#setCallDataUsage(long)}.
1434 * <p>
1435 * Sent from the {@link InCallService} via
1436 * {@link InCallService.VideoCall#requestCallDataUsage()}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001437 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001438 public abstract void onRequestConnectionDataUsage();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001439
1440 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001441 * Provides the {@link VideoProvider} with the {@link Uri} of an image to be displayed to
1442 * the peer device when the video signal is paused.
1443 * <p>
1444 * Sent from the {@link InCallService} via
1445 * {@link InCallService.VideoCall#setPauseImage(Uri)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001446 *
1447 * @param uri URI of image to display.
1448 */
Yorke Lee32f24732015-05-12 16:18:03 -07001449 public abstract void onSetPauseImage(Uri uri);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001450
1451 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001452 * Used to inform listening {@link InCallService} implementations when the
1453 * {@link VideoProvider} receives a session modification request.
1454 * <p>
1455 * Received by the {@link InCallService} via
1456 * {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)},
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001457 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001458 * @param videoProfile The requested video profile.
1459 * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001460 */
1461 public void receiveSessionModifyRequest(VideoProfile videoProfile) {
Tyler Gunn75958422015-04-15 14:23:42 -07001462 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001463 for (IVideoCallback callback : mVideoCallbacks.values()) {
1464 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001465 callback.receiveSessionModifyRequest(videoProfile);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001466 } catch (RemoteException ignored) {
1467 Log.w(this, "receiveSessionModifyRequest callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001468 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001469 }
1470 }
1471 }
1472
1473 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001474 * Used to inform listening {@link InCallService} implementations when the
1475 * {@link VideoProvider} receives a response to a session modification request.
1476 * <p>
1477 * Received by the {@link InCallService} via
1478 * {@link InCallService.VideoCall.Callback#onSessionModifyResponseReceived(int,
1479 * VideoProfile, VideoProfile)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001480 *
1481 * @param status Status of the session modify request. Valid values are
1482 * {@link VideoProvider#SESSION_MODIFY_REQUEST_SUCCESS},
1483 * {@link VideoProvider#SESSION_MODIFY_REQUEST_FAIL},
Tyler Gunnb702ef82015-05-29 11:51:53 -07001484 * {@link VideoProvider#SESSION_MODIFY_REQUEST_INVALID},
1485 * {@link VideoProvider#SESSION_MODIFY_REQUEST_TIMED_OUT},
1486 * {@link VideoProvider#SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE}
1487 * @param requestedProfile The original request which was sent to the peer device.
1488 * @param responseProfile The actual profile changes agreed to by the peer device.
1489 * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001490 */
1491 public void receiveSessionModifyResponse(int status,
1492 VideoProfile requestedProfile, VideoProfile responseProfile) {
Tyler Gunn75958422015-04-15 14:23:42 -07001493 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001494 for (IVideoCallback callback : mVideoCallbacks.values()) {
1495 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001496 callback.receiveSessionModifyResponse(status, requestedProfile,
1497 responseProfile);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001498 } catch (RemoteException ignored) {
1499 Log.w(this, "receiveSessionModifyResponse callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001500 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001501 }
1502 }
1503 }
1504
1505 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001506 * Used to inform listening {@link InCallService} implementations when the
1507 * {@link VideoProvider} reports a call session event.
1508 * <p>
1509 * Received by the {@link InCallService} via
1510 * {@link InCallService.VideoCall.Callback#onCallSessionEvent(int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001511 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001512 * @param event The event. Valid values are: {@link VideoProvider#SESSION_EVENT_RX_PAUSE},
1513 * {@link VideoProvider#SESSION_EVENT_RX_RESUME},
1514 * {@link VideoProvider#SESSION_EVENT_TX_START},
1515 * {@link VideoProvider#SESSION_EVENT_TX_STOP},
1516 * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE},
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001517 * {@link VideoProvider#SESSION_EVENT_CAMERA_READY},
1518 * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001519 */
1520 public void handleCallSessionEvent(int event) {
Tyler Gunn75958422015-04-15 14:23:42 -07001521 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001522 for (IVideoCallback callback : mVideoCallbacks.values()) {
1523 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001524 callback.handleCallSessionEvent(event);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001525 } catch (RemoteException ignored) {
1526 Log.w(this, "handleCallSessionEvent callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001527 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001528 }
1529 }
1530 }
1531
1532 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001533 * Used to inform listening {@link InCallService} implementations when the dimensions of the
1534 * peer's video have changed.
1535 * <p>
1536 * This could occur if, for example, the peer rotates their device, changing the aspect
1537 * ratio of the video, or if the user switches between the back and front cameras.
1538 * <p>
1539 * Received by the {@link InCallService} via
1540 * {@link InCallService.VideoCall.Callback#onPeerDimensionsChanged(int, int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001541 *
1542 * @param width The updated peer video width.
1543 * @param height The updated peer video height.
1544 */
1545 public void changePeerDimensions(int width, int height) {
Tyler Gunn75958422015-04-15 14:23:42 -07001546 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001547 for (IVideoCallback callback : mVideoCallbacks.values()) {
1548 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001549 callback.changePeerDimensions(width, height);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001550 } catch (RemoteException ignored) {
1551 Log.w(this, "changePeerDimensions callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001552 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001553 }
1554 }
1555 }
1556
1557 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001558 * Used to inform listening {@link InCallService} implementations when the data usage of the
1559 * video associated with the current {@link Connection} has changed.
1560 * <p>
1561 * This could be in response to a preview request via
1562 * {@link #onRequestConnectionDataUsage()}, or as a periodic update by the
Tyler Gunn295f5d72015-06-04 11:08:54 -07001563 * {@link VideoProvider}. Where periodic updates of data usage are provided, they should be
1564 * 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 -07001565 * <p>
1566 * Received by the {@link InCallService} via
1567 * {@link InCallService.VideoCall.Callback#onCallDataUsageChanged(long)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001568 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001569 * @param dataUsage The updated data usage (in bytes). Reported as the cumulative bytes
1570 * used since the start of the call.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001571 */
Yorke Lee32f24732015-05-12 16:18:03 -07001572 public void setCallDataUsage(long dataUsage) {
Tyler Gunn75958422015-04-15 14:23:42 -07001573 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001574 for (IVideoCallback callback : mVideoCallbacks.values()) {
1575 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001576 callback.changeCallDataUsage(dataUsage);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001577 } catch (RemoteException ignored) {
1578 Log.w(this, "setCallDataUsage callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001579 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001580 }
1581 }
1582 }
1583
1584 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001585 * @see #setCallDataUsage(long)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001586 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001587 * @param dataUsage The updated data usage (in byes).
Yorke Lee32f24732015-05-12 16:18:03 -07001588 * @deprecated - Use {@link #setCallDataUsage(long)} instead.
1589 * @hide
1590 */
1591 public void changeCallDataUsage(long dataUsage) {
1592 setCallDataUsage(dataUsage);
1593 }
1594
1595 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001596 * Used to inform listening {@link InCallService} implementations when the capabilities of
1597 * the current camera have changed.
1598 * <p>
1599 * The {@link VideoProvider} should call this in response to
1600 * {@link VideoProvider#onRequestCameraCapabilities()}, or when the current camera is
1601 * changed via {@link VideoProvider#onSetCamera(String)}.
1602 * <p>
1603 * Received by the {@link InCallService} via
1604 * {@link InCallService.VideoCall.Callback#onCameraCapabilitiesChanged(
1605 * VideoProfile.CameraCapabilities)}.
Yorke Lee32f24732015-05-12 16:18:03 -07001606 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001607 * @param cameraCapabilities The new camera capabilities.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001608 */
Yorke Lee400470f2015-05-12 13:31:25 -07001609 public void changeCameraCapabilities(VideoProfile.CameraCapabilities cameraCapabilities) {
Tyler Gunn75958422015-04-15 14:23:42 -07001610 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001611 for (IVideoCallback callback : mVideoCallbacks.values()) {
1612 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001613 callback.changeCameraCapabilities(cameraCapabilities);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001614 } catch (RemoteException ignored) {
1615 Log.w(this, "changeCameraCapabilities callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001616 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001617 }
1618 }
1619 }
Rekha Kumar07366812015-03-24 16:42:31 -07001620
1621 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001622 * Used to inform listening {@link InCallService} implementations when the video quality
1623 * of the call has changed.
1624 * <p>
1625 * Received by the {@link InCallService} via
1626 * {@link InCallService.VideoCall.Callback#onVideoQualityChanged(int)}.
Rekha Kumar07366812015-03-24 16:42:31 -07001627 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001628 * @param videoQuality The updated video quality. Valid values:
1629 * {@link VideoProfile#QUALITY_HIGH},
1630 * {@link VideoProfile#QUALITY_MEDIUM},
1631 * {@link VideoProfile#QUALITY_LOW},
1632 * {@link VideoProfile#QUALITY_DEFAULT}.
Rekha Kumar07366812015-03-24 16:42:31 -07001633 */
1634 public void changeVideoQuality(int videoQuality) {
Tyler Gunn75958422015-04-15 14:23:42 -07001635 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001636 for (IVideoCallback callback : mVideoCallbacks.values()) {
1637 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001638 callback.changeVideoQuality(videoQuality);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001639 } catch (RemoteException ignored) {
1640 Log.w(this, "changeVideoQuality callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001641 }
Rekha Kumar07366812015-03-24 16:42:31 -07001642 }
1643 }
1644 }
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001645
1646 /**
1647 * Returns a string representation of a call session event.
1648 *
1649 * @param event A call session event passed to {@link #handleCallSessionEvent(int)}.
1650 * @return String representation of the call session event.
1651 * @hide
1652 */
1653 public static String sessionEventToString(int event) {
1654 switch (event) {
1655 case SESSION_EVENT_CAMERA_FAILURE:
1656 return SESSION_EVENT_CAMERA_FAILURE_STR;
1657 case SESSION_EVENT_CAMERA_READY:
1658 return SESSION_EVENT_CAMERA_READY_STR;
1659 case SESSION_EVENT_RX_PAUSE:
1660 return SESSION_EVENT_RX_PAUSE_STR;
1661 case SESSION_EVENT_RX_RESUME:
1662 return SESSION_EVENT_RX_RESUME_STR;
1663 case SESSION_EVENT_TX_START:
1664 return SESSION_EVENT_TX_START_STR;
1665 case SESSION_EVENT_TX_STOP:
1666 return SESSION_EVENT_TX_STOP_STR;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001667 case SESSION_EVENT_CAMERA_PERMISSION_ERROR:
1668 return SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR;
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001669 default:
1670 return SESSION_EVENT_UNKNOWN_STR + " " + event;
1671 }
1672 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07001673 }
1674
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07001675 private final Listener mConnectionDeathListener = new Listener() {
1676 @Override
1677 public void onDestroyed(Connection c) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08001678 if (mConferenceables.remove(c)) {
1679 fireOnConferenceableConnectionsChanged();
1680 }
1681 }
1682 };
1683
1684 private final Conference.Listener mConferenceDeathListener = new Conference.Listener() {
1685 @Override
1686 public void onDestroyed(Conference c) {
1687 if (mConferenceables.remove(c)) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07001688 fireOnConferenceableConnectionsChanged();
1689 }
1690 }
1691 };
1692
Jay Shrauner229e3822014-08-15 09:23:07 -07001693 /**
1694 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
1695 * load factor before resizing, 1 means we only expect a single thread to
1696 * access the map so make only a single shard
1697 */
1698 private final Set<Listener> mListeners = Collections.newSetFromMap(
1699 new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1));
Tyler Gunndf2cbc82015-04-20 09:13:01 -07001700 private final List<Conferenceable> mConferenceables = new ArrayList<>();
1701 private final List<Conferenceable> mUnmodifiableConferenceables =
Tyler Gunn6d76ca02014-11-17 15:49:51 -08001702 Collections.unmodifiableList(mConferenceables);
Santos Cordonb6939982014-06-04 20:20:58 -07001703
Tyler Gunnf0500bd2015-09-01 10:59:48 -07001704 // The internal telecom call ID associated with this connection.
1705 private String mTelecomCallId;
Pengquan Meng70c9885332017-10-02 18:09:03 -07001706 // The PhoneAccountHandle associated with this connection.
1707 private PhoneAccountHandle mPhoneAccountHandle;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001708 private int mState = STATE_NEW;
Yorke Lee4af59352015-05-13 14:14:54 -07001709 private CallAudioState mCallAudioState;
Andrew Lee100e2932014-09-08 15:34:24 -07001710 private Uri mAddress;
1711 private int mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -07001712 private String mCallerDisplayName;
1713 private int mCallerDisplayNamePresentation;
Andrew Lee100e2932014-09-08 15:34:24 -07001714 private boolean mRingbackRequested = false;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001715 private int mConnectionCapabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -07001716 private int mConnectionProperties;
Christine Hallstrom2830ce92016-11-30 16:06:42 -08001717 private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001718 private VideoProvider mVideoProvider;
Sailesh Nepal33aaae42014-07-07 22:49:44 -07001719 private boolean mAudioModeIsVoip;
Roshan Piuse927ec02015-07-15 15:47:21 -07001720 private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Tyler Gunn3fa819c2017-08-04 09:27:26 -07001721 private long mConnectElapsedTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07001722 private StatusHints mStatusHints;
Tyler Gunnaa07df82014-07-17 07:50:22 -07001723 private int mVideoState;
Andrew Lee7f3d41f2014-09-11 17:33:16 -07001724 private DisconnectCause mDisconnectCause;
Santos Cordon823fd3c2014-08-07 18:35:18 -07001725 private Conference mConference;
1726 private ConnectionService mConnectionService;
Santos Cordon6b7f9552015-05-27 17:21:45 -07001727 private Bundle mExtras;
Brad Ebinger4fa6a012016-06-14 17:04:01 -07001728 private final Object mExtrasLock = new Object();
Ihab Awad542e0ea2014-05-16 10:22:16 -07001729
1730 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07001731 * Tracks the key set for the extras bundle provided on the last invocation of
1732 * {@link #setExtras(Bundle)}. Used so that on subsequent invocations we can remove any extras
1733 * keys which were set previously but are no longer present in the replacement Bundle.
1734 */
1735 private Set<String> mPreviousExtraKeys;
1736
1737 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07001738 * Create a new Connection.
1739 */
Santos Cordonf2951102014-07-20 19:06:29 -07001740 public Connection() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07001741
1742 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07001743 * Returns the Telecom internal call ID associated with this connection. Should only be used
1744 * for debugging and tracing purposes.
1745 *
1746 * @return The Telecom call ID.
1747 * @hide
1748 */
1749 public final String getTelecomCallId() {
1750 return mTelecomCallId;
1751 }
1752
1753 /**
Andrew Lee100e2932014-09-08 15:34:24 -07001754 * @return The address (e.g., phone number) to which this Connection is currently communicating.
Ihab Awad542e0ea2014-05-16 10:22:16 -07001755 */
Andrew Lee100e2932014-09-08 15:34:24 -07001756 public final Uri getAddress() {
1757 return mAddress;
Ihab Awad542e0ea2014-05-16 10:22:16 -07001758 }
1759
1760 /**
Andrew Lee100e2932014-09-08 15:34:24 -07001761 * @return The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07001762 * See {@link TelecomManager} for valid values.
Sailesh Nepal61203862014-07-11 14:50:13 -07001763 */
Andrew Lee100e2932014-09-08 15:34:24 -07001764 public final int getAddressPresentation() {
1765 return mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -07001766 }
1767
1768 /**
1769 * @return The caller display name (CNAP).
1770 */
1771 public final String getCallerDisplayName() {
1772 return mCallerDisplayName;
1773 }
1774
1775 /**
Nancy Chen9d568c02014-09-08 14:17:59 -07001776 * @return The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07001777 * See {@link TelecomManager} for valid values.
Sailesh Nepal61203862014-07-11 14:50:13 -07001778 */
1779 public final int getCallerDisplayNamePresentation() {
1780 return mCallerDisplayNamePresentation;
1781 }
1782
1783 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07001784 * @return The state of this Connection.
Ihab Awad542e0ea2014-05-16 10:22:16 -07001785 */
1786 public final int getState() {
1787 return mState;
1788 }
1789
1790 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001791 * Returns the video state of the connection.
Yorke Lee32f24732015-05-12 16:18:03 -07001792 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
1793 * {@link VideoProfile#STATE_BIDIRECTIONAL},
1794 * {@link VideoProfile#STATE_TX_ENABLED},
1795 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -07001796 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001797 * @return The video state of the connection.
Tyler Gunn27d1e252014-08-21 16:38:40 -07001798 * @hide
Tyler Gunnaa07df82014-07-17 07:50:22 -07001799 */
1800 public final int getVideoState() {
1801 return mVideoState;
1802 }
1803
1804 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001805 * @return The audio state of the connection, describing how its audio is currently
Ihab Awad542e0ea2014-05-16 10:22:16 -07001806 * being routed by the system. This is {@code null} if this Connection
1807 * does not directly know about its audio state.
Yorke Lee4af59352015-05-13 14:14:54 -07001808 * @deprecated Use {@link #getCallAudioState()} instead.
1809 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -07001810 */
Yorke Lee4af59352015-05-13 14:14:54 -07001811 @SystemApi
1812 @Deprecated
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001813 public final AudioState getAudioState() {
Sailesh Nepal000d38a2015-06-21 10:25:13 -07001814 if (mCallAudioState == null) {
1815 return null;
1816 }
Yorke Lee4af59352015-05-13 14:14:54 -07001817 return new AudioState(mCallAudioState);
1818 }
1819
1820 /**
1821 * @return The audio state of the connection, describing how its audio is currently
1822 * being routed by the system. This is {@code null} if this Connection
1823 * does not directly know about its audio state.
1824 */
1825 public final CallAudioState getCallAudioState() {
1826 return mCallAudioState;
Ihab Awad542e0ea2014-05-16 10:22:16 -07001827 }
1828
1829 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07001830 * @return The conference that this connection is a part of. Null if it is not part of any
1831 * conference.
1832 */
1833 public final Conference getConference() {
1834 return mConference;
1835 }
1836
1837 /**
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001838 * Returns whether this connection is requesting that the system play a ringback tone
1839 * on its behalf.
1840 */
Andrew Lee100e2932014-09-08 15:34:24 -07001841 public final boolean isRingbackRequested() {
1842 return mRingbackRequested;
Sailesh Nepal2a46b902014-07-04 17:21:07 -07001843 }
1844
1845 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -07001846 * @return True if the connection's audio mode is VOIP.
1847 */
1848 public final boolean getAudioModeIsVoip() {
1849 return mAudioModeIsVoip;
1850 }
1851
1852 /**
Roshan Piuse927ec02015-07-15 15:47:21 -07001853 * Retrieves the connection start time of the {@code Connnection}, if specified. A value of
1854 * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
1855 * start time of the conference.
1856 *
1857 * @return The time at which the {@code Connnection} was connected.
1858 *
1859 * @hide
1860 */
1861 public final long getConnectTimeMillis() {
1862 return mConnectTimeMillis;
1863 }
1864
1865 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -07001866 * Retrieves the connection start time of the {@link Connection}, if specified. A value of
1867 * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
1868 * start time of the conference.
1869 *
1870 * Based on the value of {@link SystemClock#elapsedRealtime()}, which ensures that wall-clock
1871 * changes do not impact the call duration.
1872 *
1873 * @return The time at which the {@link Connection} was connected.
1874 *
1875 * @hide
1876 */
1877 public final long getConnectElapsedTimeMillis() {
1878 return mConnectElapsedTimeMillis;
1879 }
1880
1881 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07001882 * @return The status hints for this connection.
1883 */
1884 public final StatusHints getStatusHints() {
1885 return mStatusHints;
1886 }
1887
1888 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07001889 * Returns the extras associated with this connection.
Tyler Gunn2cbe2b52016-05-04 15:48:10 +00001890 * <p>
1891 * Extras should be updated using {@link #putExtras(Bundle)}.
1892 * <p>
1893 * Telecom or an {@link InCallService} can also update the extras via
1894 * {@link android.telecom.Call#putExtras(Bundle)}, and
1895 * {@link Call#removeExtras(List)}.
1896 * <p>
1897 * The connection is notified of changes to the extras made by Telecom or an
1898 * {@link InCallService} by {@link #onExtrasChanged(Bundle)}.
Tyler Gunndee56a82016-03-23 16:06:34 -07001899 *
Santos Cordon6b7f9552015-05-27 17:21:45 -07001900 * @return The extras associated with this connection.
1901 */
1902 public final Bundle getExtras() {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07001903 Bundle extras = null;
1904 synchronized (mExtrasLock) {
1905 if (mExtras != null) {
1906 extras = new Bundle(mExtras);
1907 }
1908 }
1909 return extras;
Santos Cordon6b7f9552015-05-27 17:21:45 -07001910 }
1911
1912 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07001913 * Assign a listener to be notified of state changes.
1914 *
1915 * @param l A listener.
1916 * @return This Connection.
1917 *
1918 * @hide
1919 */
1920 public final Connection addConnectionListener(Listener l) {
Santos Cordond34e5712014-08-05 18:54:03 +00001921 mListeners.add(l);
Ihab Awad542e0ea2014-05-16 10:22:16 -07001922 return this;
1923 }
1924
1925 /**
1926 * Remove a previously assigned listener that was being notified of state changes.
1927 *
1928 * @param l A Listener.
1929 * @return This Connection.
1930 *
1931 * @hide
1932 */
1933 public final Connection removeConnectionListener(Listener l) {
Jay Shrauner229e3822014-08-15 09:23:07 -07001934 if (l != null) {
1935 mListeners.remove(l);
1936 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07001937 return this;
1938 }
1939
1940 /**
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07001941 * @return The {@link DisconnectCause} for this connection.
Evan Charltonbf11f982014-07-20 22:06:28 -07001942 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07001943 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07001944 return mDisconnectCause;
Evan Charltonbf11f982014-07-20 22:06:28 -07001945 }
1946
1947 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07001948 * Sets the telecom call ID associated with this Connection. The Telecom Call ID should be used
1949 * ONLY for debugging purposes.
1950 *
1951 * @param callId The telecom call ID.
1952 * @hide
1953 */
1954 public void setTelecomCallId(String callId) {
1955 mTelecomCallId = callId;
1956 }
1957
1958 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07001959 * Inform this Connection that the state of its audio output has been changed externally.
1960 *
1961 * @param state The new audio state.
Sailesh Nepal400cc482014-06-26 12:04:00 -07001962 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -07001963 */
Yorke Lee4af59352015-05-13 14:14:54 -07001964 final void setCallAudioState(CallAudioState state) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001965 checkImmutable();
Ihab Awad60ac30b2014-05-20 22:32:12 -07001966 Log.d(this, "setAudioState %s", state);
Yorke Lee4af59352015-05-13 14:14:54 -07001967 mCallAudioState = state;
1968 onAudioStateChanged(getAudioState());
1969 onCallAudioStateChanged(state);
Ihab Awad542e0ea2014-05-16 10:22:16 -07001970 }
1971
1972 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001973 * @param state An integer value of a {@code STATE_*} constant.
Ihab Awad542e0ea2014-05-16 10:22:16 -07001974 * @return A string representation of the value.
1975 */
1976 public static String stateToString(int state) {
1977 switch (state) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001978 case STATE_INITIALIZING:
Yorke Leee911c8d2015-07-14 11:39:36 -07001979 return "INITIALIZING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001980 case STATE_NEW:
Yorke Leee911c8d2015-07-14 11:39:36 -07001981 return "NEW";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001982 case STATE_RINGING:
Yorke Leee911c8d2015-07-14 11:39:36 -07001983 return "RINGING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001984 case STATE_DIALING:
Yorke Leee911c8d2015-07-14 11:39:36 -07001985 return "DIALING";
Tyler Gunnc96b5e02016-07-07 22:53:57 -07001986 case STATE_PULLING_CALL:
1987 return "PULLING_CALL";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001988 case STATE_ACTIVE:
Yorke Leee911c8d2015-07-14 11:39:36 -07001989 return "ACTIVE";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001990 case STATE_HOLDING:
Yorke Leee911c8d2015-07-14 11:39:36 -07001991 return "HOLDING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001992 case STATE_DISCONNECTED:
Ihab Awad542e0ea2014-05-16 10:22:16 -07001993 return "DISCONNECTED";
1994 default:
Ihab Awad60ac30b2014-05-20 22:32:12 -07001995 Log.wtf(Connection.class, "Unknown state %d", state);
Ihab Awad542e0ea2014-05-16 10:22:16 -07001996 return "UNKNOWN";
1997 }
1998 }
1999
2000 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002001 * Returns the connection's capabilities, as a bit mask of the {@code CAPABILITY_*} constants.
Ihab Awad52a28f62014-06-18 10:26:34 -07002002 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002003 public final int getConnectionCapabilities() {
2004 return mConnectionCapabilities;
Ihab Awad52a28f62014-06-18 10:26:34 -07002005 }
2006
2007 /**
Tyler Gunn720c6642016-03-22 09:02:47 -07002008 * Returns the connection's properties, as a bit mask of the {@code PROPERTY_*} constants.
2009 */
2010 public final int getConnectionProperties() {
2011 return mConnectionProperties;
2012 }
2013
2014 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002015 * Returns the connection's supported audio routes.
2016 *
2017 * @hide
2018 */
2019 public final int getSupportedAudioRoutes() {
2020 return mSupportedAudioRoutes;
2021 }
2022
2023 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002024 * Sets the value of the {@link #getAddress()} property.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002025 *
Andrew Lee100e2932014-09-08 15:34:24 -07002026 * @param address The new address.
2027 * @param presentation The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002028 * See {@link TelecomManager} for valid values.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002029 */
Andrew Lee100e2932014-09-08 15:34:24 -07002030 public final void setAddress(Uri address, int presentation) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002031 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002032 Log.d(this, "setAddress %s", address);
2033 mAddress = address;
2034 mAddressPresentation = presentation;
Santos Cordond34e5712014-08-05 18:54:03 +00002035 for (Listener l : mListeners) {
Andrew Lee100e2932014-09-08 15:34:24 -07002036 l.onAddressChanged(this, address, presentation);
Santos Cordond34e5712014-08-05 18:54:03 +00002037 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002038 }
2039
2040 /**
Sailesh Nepal61203862014-07-11 14:50:13 -07002041 * Sets the caller display name (CNAP).
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002042 *
Sailesh Nepal61203862014-07-11 14:50:13 -07002043 * @param callerDisplayName The new display name.
Nancy Chen9d568c02014-09-08 14:17:59 -07002044 * @param presentation The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002045 * See {@link TelecomManager} for valid values.
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002046 */
Sailesh Nepal61203862014-07-11 14:50:13 -07002047 public final void setCallerDisplayName(String callerDisplayName, int presentation) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002048 checkImmutable();
Sailesh Nepal61203862014-07-11 14:50:13 -07002049 Log.d(this, "setCallerDisplayName %s", callerDisplayName);
Santos Cordond34e5712014-08-05 18:54:03 +00002050 mCallerDisplayName = callerDisplayName;
2051 mCallerDisplayNamePresentation = presentation;
2052 for (Listener l : mListeners) {
2053 l.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
2054 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002055 }
2056
2057 /**
Tyler Gunnaa07df82014-07-17 07:50:22 -07002058 * Set the video state for the connection.
Yorke Lee32f24732015-05-12 16:18:03 -07002059 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
2060 * {@link VideoProfile#STATE_BIDIRECTIONAL},
2061 * {@link VideoProfile#STATE_TX_ENABLED},
2062 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002063 *
2064 * @param videoState The new video state.
2065 */
2066 public final void setVideoState(int videoState) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002067 checkImmutable();
Tyler Gunnaa07df82014-07-17 07:50:22 -07002068 Log.d(this, "setVideoState %d", videoState);
Santos Cordond34e5712014-08-05 18:54:03 +00002069 mVideoState = videoState;
2070 for (Listener l : mListeners) {
2071 l.onVideoStateChanged(this, mVideoState);
2072 }
Tyler Gunnaa07df82014-07-17 07:50:22 -07002073 }
2074
2075 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002076 * Sets state to active (e.g., an ongoing connection where two or more parties can actively
Ihab Awad542e0ea2014-05-16 10:22:16 -07002077 * communicate).
2078 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002079 public final void setActive() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002080 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002081 setRingbackRequested(false);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002082 setState(STATE_ACTIVE);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002083 }
2084
2085 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002086 * Sets state to ringing (e.g., an inbound ringing connection).
Ihab Awad542e0ea2014-05-16 10:22:16 -07002087 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002088 public final void setRinging() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002089 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002090 setState(STATE_RINGING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002091 }
2092
2093 /**
Evan Charltonbf11f982014-07-20 22:06:28 -07002094 * Sets state to initializing (this Connection is not yet ready to be used).
2095 */
2096 public final void setInitializing() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002097 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002098 setState(STATE_INITIALIZING);
Evan Charltonbf11f982014-07-20 22:06:28 -07002099 }
2100
2101 /**
2102 * Sets state to initialized (the Connection has been set up and is now ready to be used).
2103 */
2104 public final void setInitialized() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002105 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002106 setState(STATE_NEW);
Evan Charltonbf11f982014-07-20 22:06:28 -07002107 }
2108
2109 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002110 * Sets state to dialing (e.g., dialing an outbound connection).
Ihab Awad542e0ea2014-05-16 10:22:16 -07002111 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002112 public final void setDialing() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002113 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002114 setState(STATE_DIALING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002115 }
2116
2117 /**
Tyler Gunnc242ceb2016-06-29 22:35:45 -07002118 * Sets state to pulling (e.g. the connection is being pulled to the local device from another
2119 * device). Only applicable for {@link Connection}s with
2120 * {@link Connection#PROPERTY_IS_EXTERNAL_CALL} and {@link Connection#CAPABILITY_CAN_PULL_CALL}.
2121 */
2122 public final void setPulling() {
2123 checkImmutable();
2124 setState(STATE_PULLING_CALL);
2125 }
2126
2127 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002128 * Sets state to be on hold.
2129 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002130 public final void setOnHold() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002131 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002132 setState(STATE_HOLDING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002133 }
2134
2135 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002136 * Sets the video connection provider.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002137 * @param videoProvider The video provider.
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002138 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002139 public final void setVideoProvider(VideoProvider videoProvider) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002140 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002141 mVideoProvider = videoProvider;
Santos Cordond34e5712014-08-05 18:54:03 +00002142 for (Listener l : mListeners) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002143 l.onVideoProviderChanged(this, videoProvider);
Santos Cordond34e5712014-08-05 18:54:03 +00002144 }
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002145 }
2146
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002147 public final VideoProvider getVideoProvider() {
2148 return mVideoProvider;
Andrew Leea27a1932014-07-09 17:07:13 -07002149 }
2150
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002151 /**
Sailesh Nepal091768c2014-06-30 15:15:23 -07002152 * Sets state to disconnected.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002153 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002154 * @param disconnectCause The reason for the disconnection, as specified by
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002155 * {@link DisconnectCause}.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002156 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002157 public final void setDisconnected(DisconnectCause disconnectCause) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002158 checkImmutable();
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002159 mDisconnectCause = disconnectCause;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002160 setState(STATE_DISCONNECTED);
mike dooleyf34519b2014-09-16 17:33:40 -07002161 Log.d(this, "Disconnected with cause %s", disconnectCause);
Santos Cordond34e5712014-08-05 18:54:03 +00002162 for (Listener l : mListeners) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002163 l.onDisconnected(this, disconnectCause);
Santos Cordond34e5712014-08-05 18:54:03 +00002164 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002165 }
2166
2167 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002168 * Informs listeners that this {@code Connection} is in a post-dial wait state. This is done
2169 * when (a) the {@code Connection} is issuing a DTMF sequence; (b) it has encountered a "wait"
2170 * character; and (c) it wishes to inform the In-Call app that it is waiting for the end-user
2171 * to send an {@link #onPostDialContinue(boolean)} signal.
2172 *
2173 * @param remaining The DTMF character sequence remaining to be emitted once the
2174 * {@link #onPostDialContinue(boolean)} is received, including any "wait" characters
2175 * that remaining sequence may contain.
Sailesh Nepal091768c2014-06-30 15:15:23 -07002176 */
2177 public final void setPostDialWait(String remaining) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002178 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002179 for (Listener l : mListeners) {
2180 l.onPostDialWait(this, remaining);
2181 }
Sailesh Nepal091768c2014-06-30 15:15:23 -07002182 }
2183
2184 /**
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002185 * Informs listeners that this {@code Connection} has processed a character in the post-dial
2186 * started state. This is done when (a) the {@code Connection} is issuing a DTMF sequence;
Sailesh Nepal1ed85612015-01-31 15:17:19 -08002187 * and (b) it wishes to signal Telecom to play the corresponding DTMF tone locally.
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002188 *
2189 * @param nextChar The DTMF character that was just processed by the {@code Connection}.
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002190 */
Sailesh Nepal1ed85612015-01-31 15:17:19 -08002191 public final void setNextPostDialChar(char nextChar) {
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002192 checkImmutable();
2193 for (Listener l : mListeners) {
2194 l.onPostDialChar(this, nextChar);
2195 }
2196 }
2197
2198 /**
Ihab Awadf8358972014-05-28 16:46:42 -07002199 * Requests that the framework play a ringback tone. This is to be invoked by implementations
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002200 * that do not play a ringback tone themselves in the connection's audio stream.
Ihab Awadf8358972014-05-28 16:46:42 -07002201 *
2202 * @param ringback Whether the ringback tone is to be played.
2203 */
Andrew Lee100e2932014-09-08 15:34:24 -07002204 public final void setRingbackRequested(boolean ringback) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002205 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002206 if (mRingbackRequested != ringback) {
2207 mRingbackRequested = ringback;
Santos Cordond34e5712014-08-05 18:54:03 +00002208 for (Listener l : mListeners) {
Andrew Lee100e2932014-09-08 15:34:24 -07002209 l.onRingbackRequested(this, ringback);
Santos Cordond34e5712014-08-05 18:54:03 +00002210 }
2211 }
Ihab Awadf8358972014-05-28 16:46:42 -07002212 }
2213
2214 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002215 * Sets the connection's capabilities as a bit mask of the {@code CAPABILITY_*} constants.
Sailesh Nepal1a7061b2014-07-09 21:03:20 -07002216 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002217 * @param connectionCapabilities The new connection capabilities.
Santos Cordonb6939982014-06-04 20:20:58 -07002218 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002219 public final void setConnectionCapabilities(int connectionCapabilities) {
2220 checkImmutable();
2221 if (mConnectionCapabilities != connectionCapabilities) {
2222 mConnectionCapabilities = connectionCapabilities;
Santos Cordond34e5712014-08-05 18:54:03 +00002223 for (Listener l : mListeners) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002224 l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities);
Santos Cordond34e5712014-08-05 18:54:03 +00002225 }
2226 }
Santos Cordonb6939982014-06-04 20:20:58 -07002227 }
2228
2229 /**
Tyler Gunn720c6642016-03-22 09:02:47 -07002230 * Sets the connection's properties as a bit mask of the {@code PROPERTY_*} constants.
2231 *
2232 * @param connectionProperties The new connection properties.
2233 */
2234 public final void setConnectionProperties(int connectionProperties) {
2235 checkImmutable();
2236 if (mConnectionProperties != connectionProperties) {
2237 mConnectionProperties = connectionProperties;
2238 for (Listener l : mListeners) {
2239 l.onConnectionPropertiesChanged(this, mConnectionProperties);
2240 }
2241 }
2242 }
2243
2244 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002245 * Sets the supported audio routes.
2246 *
2247 * @param supportedAudioRoutes the supported audio routes as a bitmask.
2248 * See {@link CallAudioState}
2249 * @hide
2250 */
2251 public final void setSupportedAudioRoutes(int supportedAudioRoutes) {
2252 if ((supportedAudioRoutes
2253 & (CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_SPEAKER)) == 0) {
2254 throw new IllegalArgumentException(
2255 "supported audio routes must include either speaker or earpiece");
2256 }
2257
2258 if (mSupportedAudioRoutes != supportedAudioRoutes) {
2259 mSupportedAudioRoutes = supportedAudioRoutes;
2260 for (Listener l : mListeners) {
2261 l.onSupportedAudioRoutesChanged(this, mSupportedAudioRoutes);
2262 }
2263 }
2264 }
2265
2266 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002267 * Tears down the Connection object.
Santos Cordonb6939982014-06-04 20:20:58 -07002268 */
Evan Charlton36a71342014-07-19 16:31:02 -07002269 public final void destroy() {
Jay Shrauner229e3822014-08-15 09:23:07 -07002270 for (Listener l : mListeners) {
2271 l.onDestroyed(this);
Santos Cordond34e5712014-08-05 18:54:03 +00002272 }
Santos Cordonb6939982014-06-04 20:20:58 -07002273 }
2274
2275 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002276 * Requests that the framework use VOIP audio mode for this connection.
2277 *
2278 * @param isVoip True if the audio mode is VOIP.
2279 */
2280 public final void setAudioModeIsVoip(boolean isVoip) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002281 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002282 mAudioModeIsVoip = isVoip;
2283 for (Listener l : mListeners) {
2284 l.onAudioModeIsVoipChanged(this, isVoip);
2285 }
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002286 }
2287
2288 /**
Roshan Piuse927ec02015-07-15 15:47:21 -07002289 * Sets the time at which a call became active on this Connection. This is set only
2290 * when a conference call becomes active on this connection.
2291 *
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002292 * @param connectTimeMillis The connection time, in milliseconds. Should be set using a value
2293 * obtained from {@link System#currentTimeMillis()}.
Roshan Piuse927ec02015-07-15 15:47:21 -07002294 *
2295 * @hide
2296 */
2297 public final void setConnectTimeMillis(long connectTimeMillis) {
2298 mConnectTimeMillis = connectTimeMillis;
2299 }
2300
2301 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002302 * Sets the time at which a call became active on this Connection. This is set only
2303 * when a conference call becomes active on this connection.
2304 *
2305 * @param connectElapsedTimeMillis The connection time, in milliseconds. Stored in the format
2306 * {@link SystemClock#elapsedRealtime()}.
2307 *
2308 * @hide
2309 */
Tyler Gunn17541392018-02-01 08:58:38 -08002310 public final void setConnectionStartElapsedRealTime(long connectElapsedTimeMillis) {
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002311 mConnectElapsedTimeMillis = connectElapsedTimeMillis;
2312 }
2313
2314 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002315 * Sets the label and icon status to display in the in-call UI.
2316 *
2317 * @param statusHints The status label and icon to set.
2318 */
2319 public final void setStatusHints(StatusHints statusHints) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002320 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002321 mStatusHints = statusHints;
2322 for (Listener l : mListeners) {
2323 l.onStatusHintsChanged(this, statusHints);
2324 }
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002325 }
2326
2327 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002328 * Sets the connections with which this connection can be conferenced.
2329 *
2330 * @param conferenceableConnections The set of connections this connection can conference with.
2331 */
2332 public final void setConferenceableConnections(List<Connection> conferenceableConnections) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002333 checkImmutable();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002334 clearConferenceableList();
2335 for (Connection c : conferenceableConnections) {
2336 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
2337 // small amount of items here.
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002338 if (!mConferenceables.contains(c)) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002339 c.addConnectionListener(mConnectionDeathListener);
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002340 mConferenceables.add(c);
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002341 }
2342 }
2343 fireOnConferenceableConnectionsChanged();
2344 }
2345
2346 /**
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002347 * Similar to {@link #setConferenceableConnections(java.util.List)}, sets a list of connections
2348 * or conferences with which this connection can be conferenced.
2349 *
2350 * @param conferenceables The conferenceables.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002351 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002352 public final void setConferenceables(List<Conferenceable> conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002353 clearConferenceableList();
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002354 for (Conferenceable c : conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002355 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
2356 // small amount of items here.
2357 if (!mConferenceables.contains(c)) {
2358 if (c instanceof Connection) {
2359 Connection connection = (Connection) c;
2360 connection.addConnectionListener(mConnectionDeathListener);
2361 } else if (c instanceof Conference) {
2362 Conference conference = (Conference) c;
2363 conference.addListener(mConferenceDeathListener);
2364 }
2365 mConferenceables.add(c);
2366 }
2367 }
2368 fireOnConferenceableConnectionsChanged();
2369 }
2370
2371 /**
Mengjun Leng25707742017-07-04 11:10:37 +08002372 * @hide
2373 * Resets the cdma connection time.
2374 */
2375 public final void resetConnectionTime() {
2376 for (Listener l : mListeners) {
2377 l.onConnectionTimeReset(this);
2378 }
2379 }
2380
2381 /**
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002382 * Returns the connections or conferences with which this connection can be conferenced.
2383 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002384 public final List<Conferenceable> getConferenceables() {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002385 return mUnmodifiableConferenceables;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002386 }
2387
Yorke Lee53463962015-08-04 16:07:19 -07002388 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002389 * @hide
2390 */
2391 public final void setConnectionService(ConnectionService connectionService) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002392 checkImmutable();
Santos Cordon823fd3c2014-08-07 18:35:18 -07002393 if (mConnectionService != null) {
2394 Log.e(this, new Exception(), "Trying to set ConnectionService on a connection " +
2395 "which is already associated with another ConnectionService.");
2396 } else {
2397 mConnectionService = connectionService;
2398 }
2399 }
2400
2401 /**
2402 * @hide
2403 */
2404 public final void unsetConnectionService(ConnectionService connectionService) {
2405 if (mConnectionService != connectionService) {
2406 Log.e(this, new Exception(), "Trying to remove ConnectionService from a Connection " +
2407 "that does not belong to the ConnectionService.");
2408 } else {
2409 mConnectionService = null;
2410 }
2411 }
2412
2413 /**
Santos Cordonaf1b2962014-10-16 19:23:54 -07002414 * @hide
2415 */
2416 public final ConnectionService getConnectionService() {
2417 return mConnectionService;
2418 }
2419
2420 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002421 * Sets the conference that this connection is a part of. This will fail if the connection is
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002422 * already part of a conference. {@link #resetConference} to un-set the conference first.
Santos Cordon823fd3c2014-08-07 18:35:18 -07002423 *
2424 * @param conference The conference.
2425 * @return {@code true} if the conference was successfully set.
2426 * @hide
2427 */
2428 public final boolean setConference(Conference conference) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002429 checkImmutable();
Santos Cordon823fd3c2014-08-07 18:35:18 -07002430 // We check to see if it is already part of another conference.
Santos Cordon0159ac02014-08-21 14:28:11 -07002431 if (mConference == null) {
Santos Cordon823fd3c2014-08-07 18:35:18 -07002432 mConference = conference;
Santos Cordon0159ac02014-08-21 14:28:11 -07002433 if (mConnectionService != null && mConnectionService.containsConference(conference)) {
2434 fireConferenceChanged();
2435 }
Santos Cordon823fd3c2014-08-07 18:35:18 -07002436 return true;
2437 }
2438 return false;
2439 }
2440
2441 /**
2442 * Resets the conference that this connection is a part of.
2443 * @hide
2444 */
2445 public final void resetConference() {
2446 if (mConference != null) {
Santos Cordon0159ac02014-08-21 14:28:11 -07002447 Log.d(this, "Conference reset");
Santos Cordon823fd3c2014-08-07 18:35:18 -07002448 mConference = null;
2449 fireConferenceChanged();
2450 }
2451 }
2452
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002453 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002454 * Set some extras that can be associated with this {@code Connection}.
2455 * <p>
2456 * New or existing keys are replaced in the {@code Connection} extras. Keys which are no longer
2457 * in the new extras, but were present the last time {@code setExtras} was called are removed.
2458 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07002459 * Alternatively you may use the {@link #putExtras(Bundle)}, and
2460 * {@link #removeExtras(String...)} methods to modify the extras.
2461 * <p>
Tyler Gunndee56a82016-03-23 16:06:34 -07002462 * 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 -07002463 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
2464 *
2465 * @param extras The extras associated with this {@code Connection}.
2466 */
2467 public final void setExtras(@Nullable Bundle extras) {
2468 checkImmutable();
Tyler Gunndee56a82016-03-23 16:06:34 -07002469
2470 // Add/replace any new or changed extras values.
2471 putExtras(extras);
2472
2473 // If we have used "setExtras" in the past, compare the key set from the last invocation to
2474 // the current one and remove any keys that went away.
2475 if (mPreviousExtraKeys != null) {
2476 List<String> toRemove = new ArrayList<String>();
2477 for (String oldKey : mPreviousExtraKeys) {
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07002478 if (extras == null || !extras.containsKey(oldKey)) {
Tyler Gunndee56a82016-03-23 16:06:34 -07002479 toRemove.add(oldKey);
2480 }
2481 }
2482 if (!toRemove.isEmpty()) {
2483 removeExtras(toRemove);
2484 }
2485 }
2486
2487 // Track the keys the last time set called setExtras. This way, the next time setExtras is
2488 // called we can see if the caller has removed any extras values.
2489 if (mPreviousExtraKeys == null) {
2490 mPreviousExtraKeys = new ArraySet<String>();
2491 }
2492 mPreviousExtraKeys.clear();
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07002493 if (extras != null) {
2494 mPreviousExtraKeys.addAll(extras.keySet());
2495 }
Tyler Gunndee56a82016-03-23 16:06:34 -07002496 }
2497
2498 /**
2499 * Adds some extras to this {@code Connection}. Existing keys are replaced and new ones are
2500 * added.
2501 * <p>
2502 * No assumptions should be made as to how an In-Call UI or service will handle these extras.
2503 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
2504 *
2505 * @param extras The extras to add.
2506 */
2507 public final void putExtras(@NonNull Bundle extras) {
2508 checkImmutable();
2509 if (extras == null) {
2510 return;
2511 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002512 // Creating a duplicate bundle so we don't have to synchronize on mExtrasLock while calling
2513 // the listeners.
2514 Bundle listenerExtras;
2515 synchronized (mExtrasLock) {
2516 if (mExtras == null) {
2517 mExtras = new Bundle();
2518 }
2519 mExtras.putAll(extras);
2520 listenerExtras = new Bundle(mExtras);
Tyler Gunndee56a82016-03-23 16:06:34 -07002521 }
Santos Cordon6b7f9552015-05-27 17:21:45 -07002522 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002523 // Create a new clone of the extras for each listener so that they don't clobber
2524 // each other
2525 l.onExtrasChanged(this, new Bundle(listenerExtras));
Santos Cordon6b7f9552015-05-27 17:21:45 -07002526 }
2527 }
2528
2529 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002530 * Adds a boolean extra to this {@code Connection}.
2531 *
2532 * @param key The extra key.
2533 * @param value The value.
2534 * @hide
2535 */
2536 public final void putExtra(String key, boolean value) {
2537 Bundle newExtras = new Bundle();
2538 newExtras.putBoolean(key, value);
2539 putExtras(newExtras);
2540 }
2541
2542 /**
2543 * Adds an integer extra to this {@code Connection}.
2544 *
2545 * @param key The extra key.
2546 * @param value The value.
2547 * @hide
2548 */
2549 public final void putExtra(String key, int value) {
2550 Bundle newExtras = new Bundle();
2551 newExtras.putInt(key, value);
2552 putExtras(newExtras);
2553 }
2554
2555 /**
2556 * Adds a string extra to this {@code Connection}.
2557 *
2558 * @param key The extra key.
2559 * @param value The value.
2560 * @hide
2561 */
2562 public final void putExtra(String key, String value) {
2563 Bundle newExtras = new Bundle();
2564 newExtras.putString(key, value);
2565 putExtras(newExtras);
2566 }
2567
2568 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -07002569 * Removes extras from this {@code Connection}.
Tyler Gunndee56a82016-03-23 16:06:34 -07002570 *
Tyler Gunn071be6f2016-05-10 14:52:33 -07002571 * @param keys The keys of the extras to remove.
Tyler Gunndee56a82016-03-23 16:06:34 -07002572 */
2573 public final void removeExtras(List<String> keys) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002574 synchronized (mExtrasLock) {
2575 if (mExtras != null) {
2576 for (String key : keys) {
2577 mExtras.remove(key);
2578 }
Tyler Gunndee56a82016-03-23 16:06:34 -07002579 }
2580 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002581 List<String> unmodifiableKeys = Collections.unmodifiableList(keys);
Tyler Gunndee56a82016-03-23 16:06:34 -07002582 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002583 l.onExtrasRemoved(this, unmodifiableKeys);
Tyler Gunndee56a82016-03-23 16:06:34 -07002584 }
2585 }
2586
2587 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -07002588 * Removes extras from this {@code Connection}.
2589 *
2590 * @param keys The keys of the extras to remove.
2591 */
2592 public final void removeExtras(String ... keys) {
2593 removeExtras(Arrays.asList(keys));
2594 }
2595
2596 /**
Tyler Gunnf5035432017-01-09 09:43:12 -08002597 * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will
2598 * be change to the {@link #getCallAudioState()}.
2599 * <p>
2600 * Used by self-managed {@link ConnectionService}s which wish to change the audio route for a
2601 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
2602 * <p>
2603 * See also {@link InCallService#setAudioRoute(int)}.
2604 *
2605 * @param route The audio route to use (one of {@link CallAudioState#ROUTE_BLUETOOTH},
2606 * {@link CallAudioState#ROUTE_EARPIECE}, {@link CallAudioState#ROUTE_SPEAKER}, or
2607 * {@link CallAudioState#ROUTE_WIRED_HEADSET}).
2608 */
2609 public final void setAudioRoute(int route) {
2610 for (Listener l : mListeners) {
Hall Liua98f58b52017-11-07 17:59:28 -08002611 l.onAudioRouteChanged(this, route, null);
2612 }
2613 }
2614
2615 /**
Hall Liua98f58b52017-11-07 17:59:28 -08002616 * Request audio routing to a specific bluetooth device. Calling this method may result in
2617 * the device routing audio to a different bluetooth device than the one specified if the
2618 * bluetooth stack is unable to route audio to the requested device.
2619 * A list of available devices can be obtained via
2620 * {@link CallAudioState#getSupportedBluetoothDevices()}
2621 *
2622 * <p>
2623 * Used by self-managed {@link ConnectionService}s which wish to use bluetooth audio for a
2624 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
2625 * <p>
Hall Liu15392832018-04-02 13:52:57 -07002626 * See also {@link InCallService#requestBluetoothAudio(BluetoothDevice)}
2627 * @param bluetoothDevice The bluetooth device to connect to.
Hall Liua98f58b52017-11-07 17:59:28 -08002628 */
Hall Liu15392832018-04-02 13:52:57 -07002629 public void requestBluetoothAudio(@NonNull BluetoothDevice bluetoothDevice) {
Hall Liua98f58b52017-11-07 17:59:28 -08002630 for (Listener l : mListeners) {
Hall Liu15392832018-04-02 13:52:57 -07002631 l.onAudioRouteChanged(this, CallAudioState.ROUTE_BLUETOOTH,
2632 bluetoothDevice.getAddress());
Tyler Gunnf5035432017-01-09 09:43:12 -08002633 }
2634 }
2635
2636 /**
Hall Liub64ac4c2017-02-06 10:49:48 -08002637 * Informs listeners that a previously requested RTT session via
2638 * {@link ConnectionRequest#isRequestingRtt()} or
Hall Liu37dfdb02017-12-04 14:19:30 -08002639 * {@link #onStartRtt(RttTextStream)} has succeeded.
Hall Liub64ac4c2017-02-06 10:49:48 -08002640 */
2641 public final void sendRttInitiationSuccess() {
2642 mListeners.forEach((l) -> l.onRttInitiationSuccess(Connection.this));
2643 }
2644
2645 /**
2646 * Informs listeners that a previously requested RTT session via
Hall Liu37dfdb02017-12-04 14:19:30 -08002647 * {@link ConnectionRequest#isRequestingRtt()} or {@link #onStartRtt(RttTextStream)}
Hall Liub64ac4c2017-02-06 10:49:48 -08002648 * has failed.
2649 * @param reason One of the reason codes defined in {@link RttModifyStatus}, with the
2650 * exception of {@link RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}.
Hall Liub64ac4c2017-02-06 10:49:48 -08002651 */
2652 public final void sendRttInitiationFailure(int reason) {
2653 mListeners.forEach((l) -> l.onRttInitiationFailure(Connection.this, reason));
2654 }
2655
2656 /**
2657 * Informs listeners that a currently active RTT session has been terminated by the remote
2658 * side of the coll.
Hall Liub64ac4c2017-02-06 10:49:48 -08002659 */
2660 public final void sendRttSessionRemotelyTerminated() {
2661 mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this));
2662 }
2663
2664 /**
2665 * Informs listeners that the remote side of the call has requested an upgrade to include an
2666 * RTT session in the call.
Hall Liub64ac4c2017-02-06 10:49:48 -08002667 */
2668 public final void sendRemoteRttRequest() {
2669 mListeners.forEach((l) -> l.onRemoteRttRequest(Connection.this));
2670 }
2671
2672 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002673 * Notifies this Connection that the {@link #getAudioState()} property has a new value.
Sailesh Nepal400cc482014-06-26 12:04:00 -07002674 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002675 * @param state The new connection audio state.
Yorke Lee4af59352015-05-13 14:14:54 -07002676 * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead.
2677 * @hide
Sailesh Nepal400cc482014-06-26 12:04:00 -07002678 */
Yorke Lee4af59352015-05-13 14:14:54 -07002679 @SystemApi
2680 @Deprecated
Nancy Chen354b2bd2014-09-08 18:27:26 -07002681 public void onAudioStateChanged(AudioState state) {}
Sailesh Nepal400cc482014-06-26 12:04:00 -07002682
2683 /**
Yorke Lee4af59352015-05-13 14:14:54 -07002684 * Notifies this Connection that the {@link #getCallAudioState()} property has a new value.
2685 *
2686 * @param state The new connection audio state.
2687 */
2688 public void onCallAudioStateChanged(CallAudioState state) {}
2689
2690 /**
Evan Charltonbf11f982014-07-20 22:06:28 -07002691 * Notifies this Connection of an internal state change. This method is called after the
2692 * state is changed.
Ihab Awadf8358972014-05-28 16:46:42 -07002693 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002694 * @param state The new state, one of the {@code STATE_*} constants.
Ihab Awadf8358972014-05-28 16:46:42 -07002695 */
Nancy Chen354b2bd2014-09-08 18:27:26 -07002696 public void onStateChanged(int state) {}
Ihab Awadf8358972014-05-28 16:46:42 -07002697
2698 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002699 * Notifies this Connection of a request to play a DTMF tone.
2700 *
2701 * @param c A DTMF character.
2702 */
Santos Cordonf2951102014-07-20 19:06:29 -07002703 public void onPlayDtmfTone(char c) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002704
2705 /**
2706 * Notifies this Connection of a request to stop any currently playing DTMF tones.
2707 */
Santos Cordonf2951102014-07-20 19:06:29 -07002708 public void onStopDtmfTone() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002709
2710 /**
2711 * Notifies this Connection of a request to disconnect.
2712 */
Santos Cordonf2951102014-07-20 19:06:29 -07002713 public void onDisconnect() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002714
2715 /**
Tyler Gunn3b4b1dc2014-11-04 14:53:37 -08002716 * Notifies this Connection of a request to disconnect a participant of the conference managed
2717 * by the connection.
2718 *
2719 * @param endpoint the {@link Uri} of the participant to disconnect.
2720 * @hide
2721 */
2722 public void onDisconnectConferenceParticipant(Uri endpoint) {}
2723
2724 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002725 * Notifies this Connection of a request to separate from its parent conference.
Santos Cordonb6939982014-06-04 20:20:58 -07002726 */
Santos Cordonf2951102014-07-20 19:06:29 -07002727 public void onSeparate() {}
Santos Cordonb6939982014-06-04 20:20:58 -07002728
2729 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002730 * Notifies this Connection of a request to abort.
2731 */
Santos Cordonf2951102014-07-20 19:06:29 -07002732 public void onAbort() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002733
2734 /**
2735 * Notifies this Connection of a request to hold.
2736 */
Santos Cordonf2951102014-07-20 19:06:29 -07002737 public void onHold() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002738
2739 /**
2740 * Notifies this Connection of a request to exit a hold state.
2741 */
Santos Cordonf2951102014-07-20 19:06:29 -07002742 public void onUnhold() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002743
2744 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002745 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Santos Cordond34e5712014-08-05 18:54:03 +00002746 * a request to accept.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08002747 * <p>
2748 * For managed {@link ConnectionService}s, this will be called when the user answers a call via
2749 * the default dialer's {@link InCallService}.
2750 * <p>
2751 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
2752 * Telecom framework may request that the call is answered in the following circumstances:
2753 * <ul>
2754 * <li>The user chooses to answer an incoming call via a Bluetooth device.</li>
2755 * <li>A car mode {@link InCallService} is in use which has declared
2756 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
2757 * {@link InCallService} will be able to see calls from self-managed
2758 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
2759 * behalf.</li>
2760 * </ul>
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002761 * @param videoState The video state in which to answer the connection.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002762 */
Santos Cordonf2951102014-07-20 19:06:29 -07002763 public void onAnswer(int videoState) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002764
2765 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002766 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Tyler Gunnbe74de02014-08-29 14:51:48 -07002767 * a request to accept.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08002768 * <p>
2769 * For managed {@link ConnectionService}s, this will be called when the user answers a call via
2770 * the default dialer's {@link InCallService}.
2771 * <p>
2772 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
2773 * Telecom framework may request that the call is answered in the following circumstances:
2774 * <ul>
2775 * <li>The user chooses to answer an incoming call via a Bluetooth device.</li>
2776 * <li>A car mode {@link InCallService} is in use which has declared
2777 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
2778 * {@link InCallService} will be able to see calls from self-managed
2779 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
2780 * behalf.</li>
2781 * </ul>
Tyler Gunnbe74de02014-08-29 14:51:48 -07002782 */
2783 public void onAnswer() {
Tyler Gunn87b73f32015-06-03 10:09:59 -07002784 onAnswer(VideoProfile.STATE_AUDIO_ONLY);
Tyler Gunnbe74de02014-08-29 14:51:48 -07002785 }
2786
2787 /**
2788 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Pooja Jaind34698d2017-12-28 14:15:31 +05302789 * a request to deflect.
2790 */
2791 public void onDeflect(Uri address) {}
2792
2793 /**
2794 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Santos Cordond34e5712014-08-05 18:54:03 +00002795 * a request to reject.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08002796 * <p>
2797 * For managed {@link ConnectionService}s, this will be called when the user rejects a call via
2798 * the default dialer's {@link InCallService}.
2799 * <p>
2800 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
2801 * Telecom framework may request that the call is rejected in the following circumstances:
2802 * <ul>
2803 * <li>The user chooses to reject an incoming call via a Bluetooth device.</li>
2804 * <li>A car mode {@link InCallService} is in use which has declared
2805 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
2806 * {@link InCallService} will be able to see calls from self-managed
2807 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
2808 * behalf.</li>
2809 * </ul>
Ihab Awad542e0ea2014-05-16 10:22:16 -07002810 */
Santos Cordonf2951102014-07-20 19:06:29 -07002811 public void onReject() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002812
Evan Charlton6dea4ac2014-06-03 14:07:13 -07002813 /**
Hall Liu712acbe2016-03-14 16:38:56 -07002814 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
2815 * a request to reject with a message.
Bryce Lee81901682015-08-28 16:38:02 -07002816 */
2817 public void onReject(String replyMessage) {}
2818
2819 /**
Tyler Gunn06f06162018-06-18 11:24:15 -07002820 * Notifies this Connection of a request to silence the ringer.
2821 * <p>
2822 * The ringer may be silenced by any of the following methods:
2823 * <ul>
2824 * <li>{@link TelecomManager#silenceRinger()}</li>
2825 * <li>The user presses the volume-down button while a call is ringing.</li>
2826 * </ul>
2827 * <p>
2828 * Self-managed {@link ConnectionService} implementations should override this method in their
2829 * {@link Connection} implementation and implement logic to silence their app's ringtone. If
2830 * your app set the ringtone as part of the incoming call {@link Notification} (see
2831 * {@link #onShowIncomingCallUi()}), it should re-post the notification now, except call
2832 * {@link android.app.Notification.Builder#setOnlyAlertOnce(boolean)} with {@code true}. This
2833 * will ensure the ringtone sound associated with your {@link android.app.NotificationChannel}
2834 * stops playing.
Bryce Leecac50772015-11-17 15:13:29 -08002835 */
2836 public void onSilence() {}
2837
2838 /**
Evan Charlton6dea4ac2014-06-03 14:07:13 -07002839 * Notifies this Connection whether the user wishes to proceed with the post-dial DTMF codes.
2840 */
Santos Cordonf2951102014-07-20 19:06:29 -07002841 public void onPostDialContinue(boolean proceed) {}
Evan Charlton6dea4ac2014-06-03 14:07:13 -07002842
Tyler Gunn876dbfb2016-03-14 15:18:07 -07002843 /**
2844 * Notifies this Connection of a request to pull an external call to the local device.
2845 * <p>
2846 * The {@link InCallService} issues a request to pull an external call to the local device via
2847 * {@link Call#pullExternalCall()}.
2848 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -07002849 * For a Connection to be pulled, both the {@link Connection#CAPABILITY_CAN_PULL_CALL}
2850 * capability and {@link Connection#PROPERTY_IS_EXTERNAL_CALL} property bits must be set.
Tyler Gunn876dbfb2016-03-14 15:18:07 -07002851 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -07002852 * For more information on external calls, see {@link Connection#PROPERTY_IS_EXTERNAL_CALL}.
Tyler Gunn876dbfb2016-03-14 15:18:07 -07002853 */
2854 public void onPullExternalCall() {}
2855
2856 /**
2857 * Notifies this Connection of a {@link Call} event initiated from an {@link InCallService}.
2858 * <p>
2859 * The {@link InCallService} issues a Call event via {@link Call#sendCallEvent(String, Bundle)}.
2860 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07002861 * Where possible, the Connection should make an attempt to handle {@link Call} events which
2862 * are part of the {@code android.telecom.*} namespace. The Connection should ignore any events
2863 * it does not wish to handle. Unexpected events should be handled gracefully, as it is
2864 * possible that a {@link InCallService} has defined its own Call events which a Connection is
2865 * not aware of.
2866 * <p>
Tyler Gunn876dbfb2016-03-14 15:18:07 -07002867 * See also {@link Call#sendCallEvent(String, Bundle)}.
2868 *
2869 * @param event The call event.
2870 * @param extras Extras associated with the call event.
2871 */
2872 public void onCallEvent(String event, Bundle extras) {}
2873
Tyler Gunndee56a82016-03-23 16:06:34 -07002874 /**
Tyler Gunn79bc1ec2018-01-22 15:17:54 -08002875 * Notifies this {@link Connection} that a handover has completed.
2876 * <p>
2877 * A handover is initiated with {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int,
2878 * Bundle)} on the initiating side of the handover, and
2879 * {@link TelecomManager#acceptHandover(Uri, int, PhoneAccountHandle)}.
2880 */
2881 public void onHandoverComplete() {}
2882
2883 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002884 * Notifies this {@link Connection} of a change to the extras made outside the
2885 * {@link ConnectionService}.
2886 * <p>
2887 * These extras changes can originate from Telecom itself, or from an {@link InCallService} via
2888 * the {@link android.telecom.Call#putExtras(Bundle)} and
2889 * {@link Call#removeExtras(List)}.
2890 *
2891 * @param extras The new extras bundle.
2892 */
2893 public void onExtrasChanged(Bundle extras) {}
2894
Tyler Gunnf5035432017-01-09 09:43:12 -08002895 /**
2896 * Notifies this {@link Connection} that its {@link ConnectionService} is responsible for
2897 * displaying its incoming call user interface for the {@link Connection}.
2898 * <p>
2899 * Will only be called for incoming calls added via a self-managed {@link ConnectionService}
2900 * (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}), where the {@link ConnectionService}
2901 * should show its own incoming call user interface.
2902 * <p>
2903 * Where there are ongoing calls in other self-managed {@link ConnectionService}s, or in a
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08002904 * regular {@link ConnectionService}, and it is not possible to hold these other calls, the
2905 * Telecom framework will display its own incoming call user interface to allow the user to
2906 * choose whether to answer the new incoming call and disconnect other ongoing calls, or to
2907 * reject the new incoming call.
Tyler Gunn159f35c2017-03-02 09:28:37 -08002908 * <p>
2909 * You should trigger the display of the incoming call user interface for your application by
2910 * showing a {@link Notification} with a full-screen {@link Intent} specified.
Tyler Gunn06f06162018-06-18 11:24:15 -07002911 *
2912 * In your application code, you should create a {@link android.app.NotificationChannel} for
2913 * incoming call notifications from your app:
2914 * <pre><code>
2915 * NotificationChannel channel = new NotificationChannel(YOUR_CHANNEL_ID, "Incoming Calls",
2916 * NotificationManager.IMPORTANCE_MAX);
2917 * // other channel setup stuff goes here.
2918 *
2919 * // We'll use the default system ringtone for our incoming call notification channel. You can
2920 * // use your own audio resource here.
2921 * Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
2922 * channel.setSound(ringtoneUri, new AudioAttributes.Builder()
2923 * // Setting the AudioAttributes is important as it identifies the purpose of your
2924 * // notification sound.
2925 * .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
2926 * .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
2927 * .build());
2928 *
2929 * NotificationManager mgr = getSystemService(NotificationManager.class);
2930 * mgr.createNotificationChannel(channel);
2931 * </code></pre>
2932 * When it comes time to post a notification for your incoming call, ensure it uses your
2933 * incoming call {@link android.app.NotificationChannel}.
Tyler Gunn159f35c2017-03-02 09:28:37 -08002934 * <pre><code>
2935 * // Create an intent which triggers your fullscreen incoming call user interface.
2936 * Intent intent = new Intent(Intent.ACTION_MAIN, null);
2937 * intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_ACTIVITY_NEW_TASK);
2938 * intent.setClass(context, YourIncomingCallActivity.class);
2939 * PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, 0);
2940 *
2941 * // Build the notification as an ongoing high priority item; this ensures it will show as
2942 * // a heads up notification which slides down over top of the current content.
2943 * final Notification.Builder builder = new Notification.Builder(context);
2944 * builder.setOngoing(true);
2945 * builder.setPriority(Notification.PRIORITY_HIGH);
2946 *
2947 * // Set notification content intent to take user to fullscreen UI if user taps on the
2948 * // notification body.
2949 * builder.setContentIntent(pendingIntent);
2950 * // Set full screen intent to trigger display of the fullscreen UI when the notification
2951 * // manager deems it appropriate.
2952 * builder.setFullScreenIntent(pendingIntent, true);
2953 *
2954 * // Setup notification content.
2955 * builder.setSmallIcon( yourIconResourceId );
2956 * builder.setContentTitle("Your notification title");
2957 * builder.setContentText("Your notification content.");
2958 *
Tyler Gunn06f06162018-06-18 11:24:15 -07002959 * // Set notification as insistent to cause your ringtone to loop.
2960 * Notification notification = builder.build();
2961 * notification.flags |= Notification.FLAG_INSISTENT;
Tyler Gunn159f35c2017-03-02 09:28:37 -08002962 *
Tyler Gunn06f06162018-06-18 11:24:15 -07002963 * // Use builder.addAction(..) to add buttons to answer or reject the call.
Tyler Gunn159f35c2017-03-02 09:28:37 -08002964 * NotificationManager notificationManager = mContext.getSystemService(
2965 * NotificationManager.class);
Tyler Gunn06f06162018-06-18 11:24:15 -07002966 * notificationManager.notify(YOUR_CHANNEL_ID, YOUR_TAG, YOUR_ID, notification);
Tyler Gunn159f35c2017-03-02 09:28:37 -08002967 * </code></pre>
Tyler Gunnf5035432017-01-09 09:43:12 -08002968 */
2969 public void onShowIncomingCallUi() {}
2970
Hall Liub64ac4c2017-02-06 10:49:48 -08002971 /**
2972 * Notifies this {@link Connection} that the user has requested an RTT session.
2973 * The connection service should call {@link #sendRttInitiationSuccess} or
2974 * {@link #sendRttInitiationFailure} to inform Telecom of the success or failure of the
2975 * request, respectively.
2976 * @param rttTextStream The object that should be used to send text to or receive text from
2977 * the in-call app.
Hall Liub64ac4c2017-02-06 10:49:48 -08002978 */
2979 public void onStartRtt(@NonNull RttTextStream rttTextStream) {}
2980
2981 /**
2982 * Notifies this {@link Connection} that it should terminate any existing RTT communication
2983 * channel. No response to Telecom is needed for this method.
Hall Liub64ac4c2017-02-06 10:49:48 -08002984 */
2985 public void onStopRtt() {}
2986
2987 /**
2988 * Notifies this connection of a response to a previous remotely-initiated RTT upgrade
2989 * request sent via {@link #sendRemoteRttRequest}. Acceptance of the request is
2990 * indicated by the supplied {@link RttTextStream} being non-null, and rejection is
2991 * indicated by {@code rttTextStream} being {@code null}
Hall Liub64ac4c2017-02-06 10:49:48 -08002992 * @param rttTextStream The object that should be used to send text to or receive text from
2993 * the in-call app.
2994 */
2995 public void handleRttUpgradeResponse(@Nullable RttTextStream rttTextStream) {}
2996
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002997 static String toLogSafePhoneNumber(String number) {
2998 // For unknown number, log empty string.
2999 if (number == null) {
3000 return "";
3001 }
3002
3003 if (PII_DEBUG) {
3004 // When PII_DEBUG is true we emit PII.
3005 return number;
3006 }
3007
3008 // Do exactly same thing as Uri#toSafeString() does, which will enable us to compare
3009 // sanitized phone numbers.
3010 StringBuilder builder = new StringBuilder();
3011 for (int i = 0; i < number.length(); i++) {
3012 char c = number.charAt(i);
3013 if (c == '-' || c == '@' || c == '.') {
3014 builder.append(c);
3015 } else {
3016 builder.append('x');
3017 }
3018 }
3019 return builder.toString();
3020 }
3021
Ihab Awad542e0ea2014-05-16 10:22:16 -07003022 private void setState(int state) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003023 checkImmutable();
Ihab Awad6107bab2014-08-18 09:23:25 -07003024 if (mState == STATE_DISCONNECTED && mState != state) {
3025 Log.d(this, "Connection already DISCONNECTED; cannot transition out of this state.");
Evan Charltonbf11f982014-07-20 22:06:28 -07003026 return;
Sailesh Nepal400cc482014-06-26 12:04:00 -07003027 }
Evan Charltonbf11f982014-07-20 22:06:28 -07003028 if (mState != state) {
3029 Log.d(this, "setState: %s", stateToString(state));
3030 mState = state;
Nancy Chen354b2bd2014-09-08 18:27:26 -07003031 onStateChanged(state);
Evan Charltonbf11f982014-07-20 22:06:28 -07003032 for (Listener l : mListeners) {
3033 l.onStateChanged(this, state);
3034 }
Evan Charltonbf11f982014-07-20 22:06:28 -07003035 }
3036 }
3037
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07003038 private static class FailureSignalingConnection extends Connection {
Ihab Awad90e34e32014-12-01 16:23:17 -08003039 private boolean mImmutable = false;
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003040 public FailureSignalingConnection(DisconnectCause disconnectCause) {
3041 setDisconnected(disconnectCause);
Ihab Awad90e34e32014-12-01 16:23:17 -08003042 mImmutable = true;
Ihab Awad6107bab2014-08-18 09:23:25 -07003043 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003044
3045 public void checkImmutable() {
Ihab Awad90e34e32014-12-01 16:23:17 -08003046 if (mImmutable) {
3047 throw new UnsupportedOperationException("Connection is immutable");
3048 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003049 }
Ihab Awad6107bab2014-08-18 09:23:25 -07003050 }
3051
Evan Charltonbf11f982014-07-20 22:06:28 -07003052 /**
Ihab Awad6107bab2014-08-18 09:23:25 -07003053 * Return a {@code Connection} which represents a failed connection attempt. The returned
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003054 * {@code Connection} will have a {@link android.telecom.DisconnectCause} and as specified,
3055 * and a {@link #getState()} of {@link #STATE_DISCONNECTED}.
Ihab Awad6107bab2014-08-18 09:23:25 -07003056 * <p>
3057 * The returned {@code Connection} can be assumed to {@link #destroy()} itself when appropriate,
3058 * so users of this method need not maintain a reference to its return value to destroy it.
Evan Charltonbf11f982014-07-20 22:06:28 -07003059 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003060 * @param disconnectCause The disconnect cause, ({@see android.telecomm.DisconnectCause}).
Ihab Awad6107bab2014-08-18 09:23:25 -07003061 * @return A {@code Connection} which indicates failure.
Evan Charltonbf11f982014-07-20 22:06:28 -07003062 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003063 public static Connection createFailedConnection(DisconnectCause disconnectCause) {
3064 return new FailureSignalingConnection(disconnectCause);
Evan Charltonbf11f982014-07-20 22:06:28 -07003065 }
3066
Evan Charltonbf11f982014-07-20 22:06:28 -07003067 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003068 * Override to throw an {@link UnsupportedOperationException} if this {@code Connection} is
3069 * not intended to be mutated, e.g., if it is a marker for failure. Only for framework use;
3070 * this should never be un-@hide-den.
3071 *
3072 * @hide
3073 */
3074 public void checkImmutable() {}
3075
3076 /**
Ihab Awad6107bab2014-08-18 09:23:25 -07003077 * Return a {@code Connection} which represents a canceled connection attempt. The returned
3078 * {@code Connection} will have state {@link #STATE_DISCONNECTED}, and cannot be moved out of
3079 * that state. This connection should not be used for anything, and no other
3080 * {@code Connection}s should be attempted.
3081 * <p>
Ihab Awad6107bab2014-08-18 09:23:25 -07003082 * so users of this method need not maintain a reference to its return value to destroy it.
Evan Charltonbf11f982014-07-20 22:06:28 -07003083 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003084 * @return A {@code Connection} which indicates that the underlying connection should
3085 * be canceled.
Evan Charltonbf11f982014-07-20 22:06:28 -07003086 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003087 public static Connection createCanceledConnection() {
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003088 return new FailureSignalingConnection(new DisconnectCause(DisconnectCause.CANCELED));
Ihab Awad542e0ea2014-05-16 10:22:16 -07003089 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003090
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003091 private final void fireOnConferenceableConnectionsChanged() {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003092 for (Listener l : mListeners) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003093 l.onConferenceablesChanged(this, getConferenceables());
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003094 }
3095 }
3096
Santos Cordon823fd3c2014-08-07 18:35:18 -07003097 private final void fireConferenceChanged() {
3098 for (Listener l : mListeners) {
3099 l.onConferenceChanged(this, mConference);
3100 }
3101 }
3102
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003103 private final void clearConferenceableList() {
Tyler Gunndf2cbc82015-04-20 09:13:01 -07003104 for (Conferenceable c : mConferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003105 if (c instanceof Connection) {
3106 Connection connection = (Connection) c;
3107 connection.removeConnectionListener(mConnectionDeathListener);
3108 } else if (c instanceof Conference) {
3109 Conference conference = (Conference) c;
3110 conference.removeListener(mConferenceDeathListener);
3111 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003112 }
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003113 mConferenceables.clear();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003114 }
Tyler Gunn3bffcf72014-10-28 13:51:27 -07003115
3116 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07003117 * Handles a change to extras received from Telecom.
3118 *
3119 * @param extras The new extras.
3120 * @hide
3121 */
3122 final void handleExtrasChanged(Bundle extras) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003123 Bundle b = null;
3124 synchronized (mExtrasLock) {
3125 mExtras = extras;
3126 if (mExtras != null) {
3127 b = new Bundle(mExtras);
3128 }
3129 }
3130 onExtrasChanged(b);
Tyler Gunndee56a82016-03-23 16:06:34 -07003131 }
3132
3133 /**
Anthony Lee17455a32015-04-24 15:25:29 -07003134 * Notifies listeners that the merge request failed.
3135 *
3136 * @hide
3137 */
3138 protected final void notifyConferenceMergeFailed() {
3139 for (Listener l : mListeners) {
3140 l.onConferenceMergeFailed(this);
3141 }
3142 }
3143
3144 /**
Tyler Gunnab4650c2014-11-06 20:06:23 -08003145 * Notifies listeners of a change to conference participant(s).
Tyler Gunn3bffcf72014-10-28 13:51:27 -07003146 *
Tyler Gunnab4650c2014-11-06 20:06:23 -08003147 * @param conferenceParticipants The participants.
Tyler Gunn3bffcf72014-10-28 13:51:27 -07003148 * @hide
3149 */
Tyler Gunnab4650c2014-11-06 20:06:23 -08003150 protected final void updateConferenceParticipants(
3151 List<ConferenceParticipant> conferenceParticipants) {
Tyler Gunn3bffcf72014-10-28 13:51:27 -07003152 for (Listener l : mListeners) {
Tyler Gunnab4650c2014-11-06 20:06:23 -08003153 l.onConferenceParticipantsChanged(this, conferenceParticipants);
Tyler Gunn3bffcf72014-10-28 13:51:27 -07003154 }
3155 }
Tyler Gunn8a2b1192015-01-29 11:47:24 -08003156
3157 /**
3158 * Notifies listeners that a conference call has been started.
Jay Shrauner55b97522015-04-09 15:15:43 -07003159 * @hide
Tyler Gunn8a2b1192015-01-29 11:47:24 -08003160 */
3161 protected void notifyConferenceStarted() {
3162 for (Listener l : mListeners) {
3163 l.onConferenceStarted();
3164 }
3165 }
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003166
3167 /**
Tyler Gunn7d633d32016-06-24 07:30:10 -07003168 * Notifies listeners when a change has occurred to the Connection which impacts its ability to
3169 * be a part of a conference call.
3170 * @param isConferenceSupported {@code true} if the connection supports being part of a
3171 * conference call, {@code false} otherwise.
3172 * @hide
3173 */
3174 protected void notifyConferenceSupportedChanged(boolean isConferenceSupported) {
3175 for (Listener l : mListeners) {
3176 l.onConferenceSupportedChanged(this, isConferenceSupported);
3177 }
3178 }
3179
3180 /**
Srikanth Chintalafcb15012017-05-04 20:58:34 +05303181 * Notifies listeners when phone account is changed. For example, when the PhoneAccount is
3182 * changed due to an emergency call being redialed.
3183 * @param pHandle The new PhoneAccountHandle for this connection.
3184 * @hide
3185 */
3186 public void notifyPhoneAccountChanged(PhoneAccountHandle pHandle) {
3187 for (Listener l : mListeners) {
3188 l.onPhoneAccountChanged(this, pHandle);
3189 }
3190 }
3191
3192 /**
Pengquan Meng70c9885332017-10-02 18:09:03 -07003193 * Sets the {@link PhoneAccountHandle} associated with this connection.
3194 *
3195 * @hide
3196 */
3197 public void setPhoneAccountHandle(PhoneAccountHandle phoneAccountHandle) {
3198 if (mPhoneAccountHandle != phoneAccountHandle) {
3199 mPhoneAccountHandle = phoneAccountHandle;
3200 notifyPhoneAccountChanged(phoneAccountHandle);
3201 }
3202 }
3203
3204 /**
3205 * Returns the {@link PhoneAccountHandle} associated with this connection.
3206 *
3207 * @hide
3208 */
3209 public PhoneAccountHandle getPhoneAccountHandle() {
3210 return mPhoneAccountHandle;
3211 }
3212
3213 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003214 * Sends an event associated with this {@code Connection} with associated event extras to the
3215 * {@link InCallService}.
3216 * <p>
3217 * Connection events are used to communicate point in time information from a
3218 * {@link ConnectionService} to a {@link InCallService} implementations. An example of a
3219 * custom connection event includes notifying the UI when a WIFI call has been handed over to
3220 * LTE, which the InCall UI might use to inform the user that billing charges may apply. The
3221 * Android Telephony framework will send the {@link #EVENT_CALL_MERGE_FAILED} connection event
3222 * when a call to {@link Call#mergeConference()} has failed to complete successfully. A
3223 * connection event could also be used to trigger UI in the {@link InCallService} which prompts
3224 * the user to make a choice (e.g. whether they want to incur roaming costs for making a call),
3225 * which is communicated back via {@link Call#sendCallEvent(String, Bundle)}.
3226 * <p>
3227 * Events are exposed to {@link InCallService} implementations via
3228 * {@link Call.Callback#onConnectionEvent(Call, String, Bundle)}.
3229 * <p>
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003230 * 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 -07003231 * The {@link ConnectionService} must assume that the In-Call UI could even chose to ignore
3232 * some events altogether.
3233 * <p>
3234 * Events should be fully qualified (e.g. {@code com.example.event.MY_EVENT}) to avoid
3235 * conflicts between {@link ConnectionService} implementations. Further, custom
3236 * {@link ConnectionService} implementations shall not re-purpose events in the
3237 * {@code android.*} namespace, nor shall they define new event types in this namespace. When
3238 * defining a custom event type, ensure the contents of the extras {@link Bundle} is clearly
3239 * defined. Extra keys for this bundle should be named similar to the event type (e.g.
3240 * {@code com.example.extra.MY_EXTRA}).
3241 * <p>
3242 * When defining events and the associated extras, it is important to keep their behavior
3243 * consistent when the associated {@link ConnectionService} is updated. Support for deprecated
3244 * events/extras should me maintained to ensure backwards compatibility with older
3245 * {@link InCallService} implementations which were built to support the older behavior.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003246 *
3247 * @param event The connection event.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003248 * @param extras Optional bundle containing extra information associated with the event.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003249 */
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003250 public void sendConnectionEvent(String event, Bundle extras) {
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003251 for (Listener l : mListeners) {
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07003252 l.onConnectionEvent(this, event, extras);
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003253 }
3254 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07003255}