blob: 0985bb1584760d27838e9be0103d9f39bcc10db2 [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 Gunnc9503d62020-01-27 10:30:51 -080019import static android.Manifest.permission.MODIFY_PHONE_STATE;
20
Hall Liu49cabcc2021-01-15 11:41:48 -080021import android.Manifest;
Tyler Gunnc9503d62020-01-27 10:30:51 -080022import android.annotation.ElapsedRealtimeLong;
Tyler Gunnd57d76c2019-09-24 14:53:23 -070023import android.annotation.IntDef;
Tyler Gunnc9503d62020-01-27 10:30:51 -080024import android.annotation.IntRange;
Tyler Gunndee56a82016-03-23 16:06:34 -070025import android.annotation.NonNull;
Santos Cordon6b7f9552015-05-27 17:21:45 -070026import android.annotation.Nullable;
Tyler Gunnc9503d62020-01-27 10:30:51 -080027import android.annotation.RequiresPermission;
Yorke Lee4af59352015-05-13 14:14:54 -070028import android.annotation.SystemApi;
Tyler Gunn159f35c2017-03-02 09:28:37 -080029import android.app.Notification;
Hall Liua98f58b52017-11-07 17:59:28 -080030import android.bluetooth.BluetoothDevice;
Artur Satayev53ada2a2019-12-10 17:47:56 +000031import android.compat.annotation.UnsupportedAppUsage;
Hall Liu73903142021-02-18 18:41:41 -080032import android.content.ComponentName;
Tyler Gunn159f35c2017-03-02 09:28:37 -080033import android.content.Intent;
Tyler Gunnb702ef82015-05-29 11:51:53 -070034import android.hardware.camera2.CameraManager;
Ihab Awad542e0ea2014-05-16 10:22:16 -070035import android.net.Uri;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -080036import android.os.Binder;
Santos Cordon6b7f9552015-05-27 17:21:45 -070037import android.os.Bundle;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070038import android.os.Handler;
39import android.os.IBinder;
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -070040import android.os.Looper;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070041import android.os.Message;
Hall Liu73903142021-02-18 18:41:41 -080042import android.os.Parcel;
Hall Liu95d55872017-01-25 17:12:49 -080043import android.os.ParcelFileDescriptor;
Hall Liu73903142021-02-18 18:41:41 -080044import android.os.Parcelable;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070045import android.os.RemoteException;
Tyler Gunn3fa819c2017-08-04 09:27:26 -070046import android.os.SystemClock;
Tyler Gunn0a1c6d12021-03-12 15:44:08 -080047import android.telephony.CallQuality;
Sooraj Sasindran065b77d2022-02-24 00:14:51 -080048import android.telephony.CellIdentity;
allenwtsu2aca9892019-11-25 14:38:21 +080049import android.telephony.ims.ImsStreamMediaProfile;
Tyler Gunndee56a82016-03-23 16:06:34 -070050import android.util.ArraySet;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070051import android.view.Surface;
Ihab Awad542e0ea2014-05-16 10:22:16 -070052
Youming Yed6de26e2019-01-30 11:20:35 -080053import com.android.internal.os.SomeArgs;
54import com.android.internal.telecom.IVideoCallback;
55import com.android.internal.telecom.IVideoProvider;
56
Hall Liua549fed2018-02-09 16:40:03 -080057import java.io.FileInputStream;
58import java.io.FileOutputStream;
Hall Liu95d55872017-01-25 17:12:49 -080059import java.io.IOException;
60import java.io.InputStreamReader;
61import java.io.OutputStreamWriter;
Tyler Gunnd57d76c2019-09-24 14:53:23 -070062import java.lang.annotation.Retention;
63import java.lang.annotation.RetentionPolicy;
Hall Liu730a2592018-06-25 19:48:33 -070064import java.nio.channels.Channels;
Santos Cordonb6939982014-06-04 20:20:58 -070065import java.util.ArrayList;
Tyler Gunn071be6f2016-05-10 14:52:33 -070066import java.util.Arrays;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070067import java.util.Collections;
Santos Cordonb6939982014-06-04 20:20:58 -070068import java.util.List;
Ihab Awad542e0ea2014-05-16 10:22:16 -070069import java.util.Set;
Jay Shrauner229e3822014-08-15 09:23:07 -070070import java.util.concurrent.ConcurrentHashMap;
Ihab Awad542e0ea2014-05-16 10:22:16 -070071
72/**
Santos Cordon895d4b82015-06-25 16:41:48 -070073 * Represents a phone call or connection to a remote endpoint that carries voice and/or video
74 * traffic.
Ihab Awad6107bab2014-08-18 09:23:25 -070075 * <p>
76 * Implementations create a custom subclass of {@code Connection} and return it to the framework
77 * as the return value of
78 * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)}
79 * or
80 * {@link ConnectionService#onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
81 * Implementations are then responsible for updating the state of the {@code Connection}, and
82 * must call {@link #destroy()} to signal to the framework that the {@code Connection} is no
83 * longer used and associated resources may be recovered.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -070084 * <p>
85 * Subclasses of {@code Connection} override the {@code on*} methods to provide the the
86 * {@link ConnectionService}'s implementation of calling functionality. The {@code on*} methods are
87 * called by Telecom to inform an instance of a {@code Connection} of actions specific to that
88 * {@code Connection} instance.
89 * <p>
90 * Basic call support requires overriding the following methods: {@link #onAnswer()},
91 * {@link #onDisconnect()}, {@link #onReject()}, {@link #onAbort()}
92 * <p>
93 * Where a {@code Connection} has {@link #CAPABILITY_SUPPORT_HOLD}, the {@link #onHold()} and
94 * {@link #onUnhold()} methods should be overridden to provide hold support for the
95 * {@code Connection}.
96 * <p>
97 * Where a {@code Connection} supports a variation of video calling (e.g. the
98 * {@code CAPABILITY_SUPPORTS_VT_*} capability bits), {@link #onAnswer(int)} should be overridden
99 * to support answering a call as a video call.
100 * <p>
101 * Where a {@code Connection} has {@link #PROPERTY_IS_EXTERNAL_CALL} and
102 * {@link #CAPABILITY_CAN_PULL_CALL}, {@link #onPullExternalCall()} should be overridden to provide
103 * support for pulling the external call.
104 * <p>
105 * Where a {@code Connection} supports conference calling {@link #onSeparate()} should be
106 * overridden.
107 * <p>
108 * There are a number of other {@code on*} methods which a {@code Connection} can choose to
109 * implement, depending on whether it is concerned with the associated calls from Telecom. If,
110 * for example, call events from a {@link InCallService} are handled,
111 * {@link #onCallEvent(String, Bundle)} should be overridden. Another example is
112 * {@link #onExtrasChanged(Bundle)}, which should be overridden if the {@code Connection} wishes to
113 * make use of extra information provided via the {@link Call#putExtras(Bundle)} and
114 * {@link Call#removeExtras(String...)} methods.
Ihab Awad542e0ea2014-05-16 10:22:16 -0700115 */
Yorke Leeabfcfdc2015-05-13 18:55:18 -0700116public abstract class Connection extends Conferenceable {
Ihab Awad542e0ea2014-05-16 10:22:16 -0700117
Tyler Gunn50d437f2021-01-12 16:34:59 -0800118 /**@hide*/
119 @Retention(RetentionPolicy.SOURCE)
120 @IntDef(prefix = "STATE_", value = {
121 STATE_INITIALIZING,
122 STATE_NEW,
123 STATE_RINGING,
124 STATE_DIALING,
125 STATE_ACTIVE,
126 STATE_HOLDING,
127 STATE_DISCONNECTED,
128 STATE_PULLING_CALL
129 })
130 public @interface ConnectionState {}
131
Santos Cordon895d4b82015-06-25 16:41:48 -0700132 /**
133 * The connection is initializing. This is generally the first state for a {@code Connection}
134 * returned by a {@link ConnectionService}.
135 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700136 public static final int STATE_INITIALIZING = 0;
137
Santos Cordon895d4b82015-06-25 16:41:48 -0700138 /**
139 * The connection is new and not connected.
140 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700141 public static final int STATE_NEW = 1;
142
Santos Cordon895d4b82015-06-25 16:41:48 -0700143 /**
144 * An incoming connection is in the ringing state. During this state, the user's ringer or
145 * vibration feature will be activated.
146 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700147 public static final int STATE_RINGING = 2;
148
Santos Cordon895d4b82015-06-25 16:41:48 -0700149 /**
150 * An outgoing connection is in the dialing state. In this state the other party has not yet
151 * answered the call and the user traditionally hears a ringback tone.
152 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700153 public static final int STATE_DIALING = 3;
154
Santos Cordon895d4b82015-06-25 16:41:48 -0700155 /**
156 * A connection is active. Both parties are connected to the call and can actively communicate.
157 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700158 public static final int STATE_ACTIVE = 4;
159
Santos Cordon895d4b82015-06-25 16:41:48 -0700160 /**
161 * A connection is on hold.
162 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700163 public static final int STATE_HOLDING = 5;
164
Santos Cordon895d4b82015-06-25 16:41:48 -0700165 /**
166 * A connection has been disconnected. This is the final state once the user has been
167 * disconnected from a call either locally, remotely or by an error in the service.
168 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700169 public static final int STATE_DISCONNECTED = 6;
170
Santos Cordon895d4b82015-06-25 16:41:48 -0700171 /**
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700172 * The state of an external connection which is in the process of being pulled from a remote
173 * device to the local device.
174 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -0700175 * A connection can only be in this state if the {@link #PROPERTY_IS_EXTERNAL_CALL} property and
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700176 * {@link #CAPABILITY_CAN_PULL_CALL} capability bits are set on the connection.
177 */
178 public static final int STATE_PULLING_CALL = 7;
179
180 /**
Tyler Gunnd57d76c2019-09-24 14:53:23 -0700181 * Indicates that the network could not perform verification.
182 */
183 public static final int VERIFICATION_STATUS_NOT_VERIFIED = 0;
184
185 /**
186 * Indicates that verification by the network passed. This indicates there is a high likelihood
187 * that the call originated from a valid source.
188 */
189 public static final int VERIFICATION_STATUS_PASSED = 1;
190
191 /**
192 * Indicates that verification by the network failed. This indicates there is a high likelihood
193 * that the call did not originate from a valid source.
194 */
195 public static final int VERIFICATION_STATUS_FAILED = 2;
196
197 /**@hide*/
198 @Retention(RetentionPolicy.SOURCE)
199 @IntDef(prefix = "VERIFICATION_STATUS_", value = {
200 VERIFICATION_STATUS_NOT_VERIFIED,
201 VERIFICATION_STATUS_PASSED,
202 VERIFICATION_STATUS_FAILED
203 })
204 public @interface VerificationStatus {}
205
206 /**
Santos Cordon895d4b82015-06-25 16:41:48 -0700207 * Connection can currently be put on hold or unheld. This is distinct from
208 * {@link #CAPABILITY_SUPPORT_HOLD} in that although a connection may support 'hold' most times,
209 * it does not at the moment support the function. This can be true while the call is in the
210 * state {@link #STATE_DIALING}, for example. During this condition, an in-call UI may
211 * display a disabled 'hold' button.
212 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800213 public static final int CAPABILITY_HOLD = 0x00000001;
214
215 /** Connection supports the hold feature. */
216 public static final int CAPABILITY_SUPPORT_HOLD = 0x00000002;
217
218 /**
219 * Connections within a conference can be merged. A {@link ConnectionService} has the option to
220 * add a {@link Conference} before the child {@link Connection}s are merged. This is how
221 * CDMA-based {@link Connection}s are implemented. For these unmerged {@link Conference}s, this
222 * capability allows a merge button to be shown while the conference is in the foreground
223 * of the in-call UI.
224 * <p>
225 * This is only intended for use by a {@link Conference}.
226 */
227 public static final int CAPABILITY_MERGE_CONFERENCE = 0x00000004;
228
229 /**
230 * Connections within a conference can be swapped between foreground and background.
231 * See {@link #CAPABILITY_MERGE_CONFERENCE} for additional information.
232 * <p>
233 * This is only intended for use by a {@link Conference}.
234 */
235 public static final int CAPABILITY_SWAP_CONFERENCE = 0x00000008;
236
237 /**
238 * @hide
239 */
240 public static final int CAPABILITY_UNUSED = 0x00000010;
241
242 /** Connection supports responding via text option. */
243 public static final int CAPABILITY_RESPOND_VIA_TEXT = 0x00000020;
244
245 /** Connection can be muted. */
246 public static final int CAPABILITY_MUTE = 0x00000040;
247
248 /**
249 * Connection supports conference management. This capability only applies to
250 * {@link Conference}s which can have {@link Connection}s as children.
251 */
252 public static final int CAPABILITY_MANAGE_CONFERENCE = 0x00000080;
253
254 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700255 * Local device supports receiving video.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800256 */
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700257 public static final int CAPABILITY_SUPPORTS_VT_LOCAL_RX = 0x00000100;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800258
259 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700260 * Local device supports transmitting video.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800261 */
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700262 public static final int CAPABILITY_SUPPORTS_VT_LOCAL_TX = 0x00000200;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800263
264 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700265 * Local device supports bidirectional video calling.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800266 */
Andrew Lee9a8f9ce2015-04-10 18:09:46 -0700267 public static final int CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL =
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700268 CAPABILITY_SUPPORTS_VT_LOCAL_RX | CAPABILITY_SUPPORTS_VT_LOCAL_TX;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800269
270 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700271 * Remote device supports receiving video.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800272 */
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700273 public static final int CAPABILITY_SUPPORTS_VT_REMOTE_RX = 0x00000400;
274
275 /**
276 * Remote device supports transmitting video.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700277 */
278 public static final int CAPABILITY_SUPPORTS_VT_REMOTE_TX = 0x00000800;
279
280 /**
281 * Remote device supports bidirectional video calling.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700282 */
Andrew Lee9a8f9ce2015-04-10 18:09:46 -0700283 public static final int CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL =
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700284 CAPABILITY_SUPPORTS_VT_REMOTE_RX | CAPABILITY_SUPPORTS_VT_REMOTE_TX;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800285
286 /**
287 * Connection is able to be separated from its parent {@code Conference}, if any.
288 */
289 public static final int CAPABILITY_SEPARATE_FROM_CONFERENCE = 0x00001000;
290
291 /**
292 * Connection is able to be individually disconnected when in a {@code Conference}.
293 */
294 public static final int CAPABILITY_DISCONNECT_FROM_CONFERENCE = 0x00002000;
295
296 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700297 * Un-used.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800298 * @hide
299 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700300 public static final int CAPABILITY_UNUSED_2 = 0x00004000;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800301
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700302 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700303 * Un-used.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700304 * @hide
305 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700306 public static final int CAPABILITY_UNUSED_3 = 0x00008000;
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700307
308 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700309 * Un-used.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700310 * @hide
311 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700312 public static final int CAPABILITY_UNUSED_4 = 0x00010000;
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700313
Tyler Gunn068085b2015-02-06 13:56:52 -0800314 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700315 * Un-used.
Tyler Gunn068085b2015-02-06 13:56:52 -0800316 * @hide
317 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700318 public static final int CAPABILITY_UNUSED_5 = 0x00020000;
Tyler Gunn068085b2015-02-06 13:56:52 -0800319
Tyler Gunn96d6c402015-03-18 12:39:23 -0700320 /**
Dong Zhou89f41eb2015-03-15 11:59:49 -0500321 * Speed up audio setup for MT call.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700322 * <p>
323 * Used for IMS calls to indicate that mobile-terminated (incoming) call audio setup should take
324 * place as soon as the device answers the call, but prior to it being connected. This is an
325 * optimization some IMS stacks depend on to ensure prompt setup of call audio.
Dong Zhou89f41eb2015-03-15 11:59:49 -0500326 * @hide
Tyler Gunn96d6c402015-03-18 12:39:23 -0700327 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700328 @SystemApi
Tyler Gunn96d6c402015-03-18 12:39:23 -0700329 public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00040000;
Tyler Gunn068085b2015-02-06 13:56:52 -0800330
Rekha Kumar07366812015-03-24 16:42:31 -0700331 /**
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700332 * Call can be upgraded to a video call.
Tyler Gunn6e3ecc42018-11-12 11:30:56 -0800333 * @deprecated Use {@link #CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL} and
334 * {@link #CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL} to indicate for a call whether or not
335 * video calling is supported.
Rekha Kumar07366812015-03-24 16:42:31 -0700336 */
337 public static final int CAPABILITY_CAN_UPGRADE_TO_VIDEO = 0x00080000;
338
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700339 /**
340 * For video calls, indicates whether the outgoing video for the call can be paused using
Yorke Lee32f24732015-05-12 16:18:03 -0700341 * the {@link android.telecom.VideoProfile#STATE_PAUSED} VideoState.
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700342 */
343 public static final int CAPABILITY_CAN_PAUSE_VIDEO = 0x00100000;
344
Tyler Gunnd4091732015-06-29 09:15:37 -0700345 /**
346 * For a conference, indicates the conference will not have child connections.
347 * <p>
348 * An example of a conference with child connections is a GSM conference call, where the radio
349 * retains connections to the individual participants of the conference. Another example is an
350 * IMS conference call where conference event package functionality is supported; in this case
351 * the conference server ensures the radio is aware of the participants in the conference, which
352 * are represented by child connections.
353 * <p>
354 * An example of a conference with no child connections is an IMS conference call with no
355 * conference event package support. Such a conference is represented by the radio as a single
356 * connection to the IMS conference server.
357 * <p>
358 * Indicating whether a conference has children or not is important to help user interfaces
359 * visually represent a conference. A conference with no children, for example, will have the
360 * conference connection shown in the list of calls on a Bluetooth device, where if the
361 * conference has children, only the children will be shown in the list of calls on a Bluetooth
362 * device.
363 * @hide
364 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700365 @SystemApi
Tyler Gunnd4091732015-06-29 09:15:37 -0700366 public static final int CAPABILITY_CONFERENCE_HAS_NO_CHILDREN = 0x00200000;
367
Bryce Lee81901682015-08-28 16:38:02 -0700368 /**
369 * Indicates that the connection itself wants to handle any sort of reply response, rather than
370 * relying on SMS.
Bryce Lee81901682015-08-28 16:38:02 -0700371 */
372 public static final int CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION = 0x00400000;
373
Tyler Gunnf97a0092016-01-19 15:59:34 -0800374 /**
375 * When set, prevents a video call from being downgraded to an audio-only call.
376 * <p>
377 * Should be set when the VideoState has the {@link VideoProfile#STATE_TX_ENABLED} or
378 * {@link VideoProfile#STATE_RX_ENABLED} bits set to indicate that the connection cannot be
379 * downgraded from a video call back to a VideoState of
380 * {@link VideoProfile#STATE_AUDIO_ONLY}.
381 * <p>
382 * Intuitively, a call which can be downgraded to audio should also have local and remote
383 * video
384 * capabilities (see {@link #CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL} and
385 * {@link #CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL}).
386 */
387 public static final int CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO = 0x00800000;
388
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700389 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700390 * When set for an external connection, indicates that this {@code Connection} can be pulled
391 * from a remote device to the current device.
392 * <p>
393 * Should only be set on a {@code Connection} where {@link #PROPERTY_IS_EXTERNAL_CALL}
394 * is set.
395 */
396 public static final int CAPABILITY_CAN_PULL_CALL = 0x01000000;
397
Pooja Jaind34698d2017-12-28 14:15:31 +0530398 /** Call supports the deflect feature. */
399 public static final int CAPABILITY_SUPPORT_DEFLECT = 0x02000000;
400
Ravi Paluri404babb2020-01-23 19:02:44 +0530401 /**
402 * When set, indicates that this {@link Connection} supports initiation of a conference call
Grace Jia8587ee52020-07-10 15:42:32 -0700403 * by directly adding participants using {@link #onAddConferenceParticipants(List)}. When
404 * participants are added to a {@link Connection}, it will be replaced by a {@link Conference}
405 * instance with {@link #PROPERTY_IS_ADHOC_CONFERENCE} set to indicate that it is an adhoc
406 * conference call.
Ravi Paluri404babb2020-01-23 19:02:44 +0530407 */
408 public static final int CAPABILITY_ADD_PARTICIPANT = 0x04000000;
Ravi Palurif4b38e72020-02-05 12:35:41 +0530409
410 /**
411 * Indicates that this {@code Connection} can be transferred to another
412 * number.
Tyler Gunn460360d2020-07-29 10:21:45 -0700413 * Connection supports the confirmed and unconfirmed call transfer feature.
Ravi Palurif4b38e72020-02-05 12:35:41 +0530414 * @hide
415 */
416 public static final int CAPABILITY_TRANSFER = 0x08000000;
417
418 /**
419 * Indicates that this {@code Connection} can be transferred to another
420 * ongoing {@code Connection}.
421 * Connection supports the consultative call transfer feature.
422 * @hide
423 */
424 public static final int CAPABILITY_TRANSFER_CONSULTATIVE = 0x10000000;
425
Alvin Dey2f37d772018-05-18 23:16:10 +0530426 /**
427 * Indicates whether the remote party supports RTT or not to the UI.
428 */
429
430 public static final int CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT = 0x20000000;
431
Tyler Gunn720c6642016-03-22 09:02:47 -0700432 //**********************************************************************************************
Alvin Dey2f37d772018-05-18 23:16:10 +0530433 // Next CAPABILITY value: 0x40000000
Tyler Gunn720c6642016-03-22 09:02:47 -0700434 //**********************************************************************************************
435
436 /**
437 * Indicates that the current device callback number should be shown.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700438 * <p>
439 * Supports Telephony calls where CDMA emergency callback mode is active.
Tyler Gunn720c6642016-03-22 09:02:47 -0700440 * @hide
441 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700442 @SystemApi
Hall Liu25c7c4d2016-08-30 13:41:02 -0700443 public static final int PROPERTY_EMERGENCY_CALLBACK_MODE = 1<<0;
Tyler Gunn720c6642016-03-22 09:02:47 -0700444
445 /**
446 * Whether the call is a generic conference, where we do not know the precise state of
447 * participants in the conference (eg. on CDMA).
Tyler Gunnc63f9082019-10-15 13:19:26 -0700448 * <p>
449 * Supports legacy telephony CDMA calls.
Tyler Gunn720c6642016-03-22 09:02:47 -0700450 * @hide
451 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700452 @SystemApi
Tyler Gunn720c6642016-03-22 09:02:47 -0700453 public static final int PROPERTY_GENERIC_CONFERENCE = 1<<1;
454
455 /**
456 * Connection is using high definition audio.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700457 * <p>
458 * Indicates that the {@link Connection} is using a "high definition" audio codec. This usually
459 * implies something like AMR wideband, but the interpretation of when a call is considered high
460 * definition is left to the {@link ConnectionService} to decide.
461 * <p>
462 * Translates to {@link android.telecom.Call.Details#PROPERTY_HIGH_DEF_AUDIO}.
Tyler Gunn720c6642016-03-22 09:02:47 -0700463 */
464 public static final int PROPERTY_HIGH_DEF_AUDIO = 1<<2;
465
466 /**
467 * Connection is using WIFI.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700468 * <p>
469 * Used to indicate that a call is taking place over WIFI versus a carrier network.
470 * <p>
471 * Translates to {@link android.telecom.Call.Details#PROPERTY_WIFI}.
Tyler Gunn720c6642016-03-22 09:02:47 -0700472 */
473 public static final int PROPERTY_WIFI = 1<<3;
474
475 /**
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700476 * When set, indicates that the {@code Connection} does not actually exist locally for the
477 * {@link ConnectionService}.
478 * <p>
479 * Consider, for example, a scenario where a user has two devices with the same phone number.
480 * When a user places a call on one devices, the telephony stack can represent that call on the
481 * other device by adding is to the {@link ConnectionService} with the
Tyler Gunn720c6642016-03-22 09:02:47 -0700482 * {@link #PROPERTY_IS_EXTERNAL_CALL} capability set.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700483 * <p>
484 * An {@link ConnectionService} should not assume that all {@link InCallService}s will handle
485 * external connections. Only those {@link InCallService}s which have the
486 * {@link TelecomManager#METADATA_INCLUDE_EXTERNAL_CALLS} metadata set to {@code true} in its
487 * manifest will see external connections.
488 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700489 public static final int PROPERTY_IS_EXTERNAL_CALL = 1<<4;
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700490
Brad Ebinger15847072016-05-18 11:08:36 -0700491 /**
492 * Indicates that the connection has CDMA Enhanced Voice Privacy enabled.
493 */
494 public static final int PROPERTY_HAS_CDMA_VOICE_PRIVACY = 1<<5;
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700495
Hall Liu9f332c72016-07-14 15:37:37 -0700496 /**
497 * Indicates that the connection represents a downgraded IMS conference.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700498 * <p>
499 * This property is set when an IMS conference undergoes SRVCC and is re-added to Telecom as a
500 * new entity to indicate that the new connection was a conference.
Hall Liu9f332c72016-07-14 15:37:37 -0700501 * @hide
502 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700503 @SystemApi
Hall Liu9f332c72016-07-14 15:37:37 -0700504 public static final int PROPERTY_IS_DOWNGRADED_CONFERENCE = 1<<6;
505
Tyler Gunnf5035432017-01-09 09:43:12 -0800506 /**
507 * Set by the framework to indicate that the {@link Connection} originated from a self-managed
508 * {@link ConnectionService}.
509 * <p>
510 * See {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.
511 */
512 public static final int PROPERTY_SELF_MANAGED = 1<<7;
513
Hall Liu95d55872017-01-25 17:12:49 -0800514 /**
Hall Liuffa4a812017-03-02 16:11:00 -0800515 * Set by the framework to indicate that a connection has an active RTT session associated with
516 * it.
Hall Liu95d55872017-01-25 17:12:49 -0800517 */
518 public static final int PROPERTY_IS_RTT = 1 << 8;
519
Eric Erfanian62706c52017-12-06 16:27:53 -0800520 /**
521 * Set by the framework to indicate that a connection is using assisted dialing.
Tyler Gunn5567d742019-10-31 13:04:37 -0700522 * <p>
523 * This is used for outgoing calls.
524 *
525 * @see TelecomManager#EXTRA_USE_ASSISTED_DIALING
Eric Erfanian62706c52017-12-06 16:27:53 -0800526 */
Tyler Gunnc9503d62020-01-27 10:30:51 -0800527 public static final int PROPERTY_ASSISTED_DIALING = 1 << 9;
Eric Erfanian62706c52017-12-06 16:27:53 -0800528
Tyler Gunn5bd90852018-09-21 09:37:07 -0700529 /**
530 * Set by the framework to indicate that the network has identified a Connection as an emergency
531 * call.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700532 * <p>
533 * This is used for incoming (mobile-terminated) calls to indicate the call is from emergency
534 * services.
Tyler Gunn5bd90852018-09-21 09:37:07 -0700535 */
536 public static final int PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL = 1 << 10;
537
Tyler Gunnac60f952019-05-31 07:23:16 -0700538 /**
539 * Set by the framework to indicate that a Conference or Connection is hosted by a device other
540 * than the current one. Used in scenarios where the conference originator is the remote device
541 * and the current device is a participant of that conference.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700542 * <p>
543 * This property is specific to IMS conference calls originating in Telephony.
Tyler Gunnac60f952019-05-31 07:23:16 -0700544 * @hide
545 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700546 @SystemApi
Tyler Gunnac60f952019-05-31 07:23:16 -0700547 public static final int PROPERTY_REMOTELY_HOSTED = 1 << 11;
548
Ravi Paluri80aa2142019-12-02 11:57:37 +0530549 /**
Grace Jia8587ee52020-07-10 15:42:32 -0700550 * Set by the framework to indicate that a call is an adhoc conference call.
Ravi Paluri80aa2142019-12-02 11:57:37 +0530551 * <p>
Grace Jia8587ee52020-07-10 15:42:32 -0700552 * This is used for outgoing and incoming conference calls.
Ravi Paluri80aa2142019-12-02 11:57:37 +0530553 */
554 public static final int PROPERTY_IS_ADHOC_CONFERENCE = 1 << 12;
555
Sooraj Sasindran64f05b12020-11-18 12:07:10 -0800556 /**
557 * Connection is using cross sim technology.
558 * <p>
559 * Indicates that the {@link Connection} is using a cross sim technology which would
560 * register IMS over internet APN of default data subscription.
561 * <p>
562 */
563 public static final int PROPERTY_CROSS_SIM = 1 << 13;
Ravi Paluri80aa2142019-12-02 11:57:37 +0530564
Grace Jiae04723f2022-01-26 16:24:48 +0000565 /**
566 * Connection is a tethered external call.
567 * <p>
568 * Indicates that the {@link Connection} is fixed on this device but the audio streams are
569 * re-routed to another device.
570 * <p>
571 */
572 public static final int PROPERTY_TETHERED_CALL = 1 << 14;
573
Tyler Gunn96d6c402015-03-18 12:39:23 -0700574 //**********************************************************************************************
Sooraj Sasindran64f05b12020-11-18 12:07:10 -0800575 // Next PROPERTY value: 1<<14
Tyler Gunn96d6c402015-03-18 12:39:23 -0700576 //**********************************************************************************************
Tyler Gunn068085b2015-02-06 13:56:52 -0800577
Tyler Gunn335ff2e2015-07-30 14:18:33 -0700578 /**
Tyler Gunn1c687622019-12-20 11:08:13 -0800579 * Indicates that the audio codec is currently not specified or is unknown.
allenwtsu2aca9892019-11-25 14:38:21 +0800580 */
allenwtsu2aca9892019-11-25 14:38:21 +0800581 public static final int AUDIO_CODEC_NONE = ImsStreamMediaProfile.AUDIO_QUALITY_NONE; // 0
Tyler Gunn1c687622019-12-20 11:08:13 -0800582 /**
583 * Adaptive Multi-rate audio codec.
584 */
allenwtsu2aca9892019-11-25 14:38:21 +0800585 public static final int AUDIO_CODEC_AMR = ImsStreamMediaProfile.AUDIO_QUALITY_AMR; // 1
Tyler Gunn1c687622019-12-20 11:08:13 -0800586 /**
587 * Adaptive Multi-rate wideband audio codec.
588 */
allenwtsu2aca9892019-11-25 14:38:21 +0800589 public static final int AUDIO_CODEC_AMR_WB = ImsStreamMediaProfile.AUDIO_QUALITY_AMR_WB; // 2
Tyler Gunn1c687622019-12-20 11:08:13 -0800590 /**
591 * Qualcomm code-excited linear prediction 13 kilobit audio codec.
592 */
allenwtsu2aca9892019-11-25 14:38:21 +0800593 public static final int AUDIO_CODEC_QCELP13K = ImsStreamMediaProfile.AUDIO_QUALITY_QCELP13K; //3
Tyler Gunn1c687622019-12-20 11:08:13 -0800594 /**
595 * Enhanced Variable Rate Codec. See 3GPP2 C.S0014-A.
596 */
allenwtsu2aca9892019-11-25 14:38:21 +0800597 public static final int AUDIO_CODEC_EVRC = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC; // 4
Tyler Gunn1c687622019-12-20 11:08:13 -0800598 /**
599 * Enhanced Variable Rate Codec B. Commonly used on CDMA networks.
600 */
allenwtsu2aca9892019-11-25 14:38:21 +0800601 public static final int AUDIO_CODEC_EVRC_B = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_B; // 5
Tyler Gunn1c687622019-12-20 11:08:13 -0800602 /**
603 * Enhanced Variable Rate Wideband Codec. See RFC5188.
604 */
allenwtsu2aca9892019-11-25 14:38:21 +0800605 public static final int AUDIO_CODEC_EVRC_WB = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_WB; // 6
Tyler Gunn1c687622019-12-20 11:08:13 -0800606 /**
607 * Enhanced Variable Rate Narrowband-Wideband Codec.
608 */
allenwtsu2aca9892019-11-25 14:38:21 +0800609 public static final int AUDIO_CODEC_EVRC_NW = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_NW; // 7
Tyler Gunn1c687622019-12-20 11:08:13 -0800610 /**
611 * GSM Enhanced Full-Rate audio codec, also known as GSM-EFR, GSM 06.60, or simply EFR.
612 */
allenwtsu2aca9892019-11-25 14:38:21 +0800613 public static final int AUDIO_CODEC_GSM_EFR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_EFR; // 8
Tyler Gunn1c687622019-12-20 11:08:13 -0800614 /**
615 * GSM Full-Rate audio codec, also known as GSM-FR, GSM 06.10, GSM, or simply FR.
616 */
allenwtsu2aca9892019-11-25 14:38:21 +0800617 public static final int AUDIO_CODEC_GSM_FR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_FR; // 9
Tyler Gunn1c687622019-12-20 11:08:13 -0800618 /**
619 * GSM Half Rate audio codec.
620 */
allenwtsu2aca9892019-11-25 14:38:21 +0800621 public static final int AUDIO_CODEC_GSM_HR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_HR; // 10
Tyler Gunn1c687622019-12-20 11:08:13 -0800622 /**
623 * ITU-T G711U audio codec.
624 */
allenwtsu2aca9892019-11-25 14:38:21 +0800625 public static final int AUDIO_CODEC_G711U = ImsStreamMediaProfile.AUDIO_QUALITY_G711U; // 11
Tyler Gunn1c687622019-12-20 11:08:13 -0800626 /**
627 * ITU-T G723 audio codec.
628 */
allenwtsu2aca9892019-11-25 14:38:21 +0800629 public static final int AUDIO_CODEC_G723 = ImsStreamMediaProfile.AUDIO_QUALITY_G723; // 12
Tyler Gunn1c687622019-12-20 11:08:13 -0800630 /**
631 * ITU-T G711A audio codec.
632 */
allenwtsu2aca9892019-11-25 14:38:21 +0800633 public static final int AUDIO_CODEC_G711A = ImsStreamMediaProfile.AUDIO_QUALITY_G711A; // 13
Tyler Gunn1c687622019-12-20 11:08:13 -0800634 /**
635 * ITU-T G722 audio codec.
636 */
allenwtsu2aca9892019-11-25 14:38:21 +0800637 public static final int AUDIO_CODEC_G722 = ImsStreamMediaProfile.AUDIO_QUALITY_G722; // 14
Tyler Gunn1c687622019-12-20 11:08:13 -0800638 /**
639 * ITU-T G711AB audio codec.
640 */
allenwtsu2aca9892019-11-25 14:38:21 +0800641 public static final int AUDIO_CODEC_G711AB = ImsStreamMediaProfile.AUDIO_QUALITY_G711AB; // 15
Tyler Gunn1c687622019-12-20 11:08:13 -0800642 /**
643 * ITU-T G729 audio codec.
644 */
allenwtsu2aca9892019-11-25 14:38:21 +0800645 public static final int AUDIO_CODEC_G729 = ImsStreamMediaProfile.AUDIO_QUALITY_G729; // 16
Tyler Gunn1c687622019-12-20 11:08:13 -0800646 /**
647 * Enhanced Voice Services Narrowband audio codec. See 3GPP TS 26.441.
648 */
allenwtsu2aca9892019-11-25 14:38:21 +0800649 public static final int AUDIO_CODEC_EVS_NB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_NB; // 17
Tyler Gunn1c687622019-12-20 11:08:13 -0800650 /**
651 * Enhanced Voice Services Wideband audio codec. See 3GPP TS 26.441.
652 */
allenwtsu2aca9892019-11-25 14:38:21 +0800653 public static final int AUDIO_CODEC_EVS_WB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_WB; // 18
Tyler Gunn1c687622019-12-20 11:08:13 -0800654 /**
655 * Enhanced Voice Services Super-Wideband audio codec. See 3GPP TS 26.441.
656 */
allenwtsu2aca9892019-11-25 14:38:21 +0800657 public static final int AUDIO_CODEC_EVS_SWB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_SWB; // 19
Tyler Gunn1c687622019-12-20 11:08:13 -0800658 /**
659 * Enhanced Voice Services Fullband audio codec. See 3GPP TS 26.441.
660 */
allenwtsu2aca9892019-11-25 14:38:21 +0800661 public static final int AUDIO_CODEC_EVS_FB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_FB; // 20
662
Tyler Gunn1c687622019-12-20 11:08:13 -0800663 /**@hide*/
664 @Retention(RetentionPolicy.SOURCE)
665 @IntDef(prefix = "AUDIO_CODEC_", value = {
666 AUDIO_CODEC_NONE,
667 AUDIO_CODEC_AMR,
668 AUDIO_CODEC_AMR_WB,
669 AUDIO_CODEC_QCELP13K,
670 AUDIO_CODEC_EVRC,
671 AUDIO_CODEC_EVRC_B,
672 AUDIO_CODEC_EVRC_WB,
673 AUDIO_CODEC_EVRC_NW,
674 AUDIO_CODEC_GSM_EFR,
675 AUDIO_CODEC_GSM_FR,
676 AUDIO_CODEC_GSM_HR,
677 AUDIO_CODEC_G711U,
678 AUDIO_CODEC_G723,
679 AUDIO_CODEC_G711A,
680 AUDIO_CODEC_G722,
681 AUDIO_CODEC_G711AB,
682 AUDIO_CODEC_G729,
683 AUDIO_CODEC_EVS_NB,
684 AUDIO_CODEC_EVS_SWB,
685 AUDIO_CODEC_EVS_FB
686 })
687 public @interface AudioCodec {}
688
allenwtsu2aca9892019-11-25 14:38:21 +0800689 /**
Tyler Gunn60e5eb62021-07-01 16:55:32 -0700690 * Contains the same value as {@link #getCallerNumberVerificationStatus()}, except will be
691 * present in the {@link #getExtras()} using this key.
692 * @hide
693 */
694 public static final String EXTRA_CALLER_NUMBER_VERIFICATION_STATUS =
695 "android.telecom.extra.CALLER_NUMBER_VERIFICATION_STATUS";
696
697 /**
Tyler Gunn335ff2e2015-07-30 14:18:33 -0700698 * Connection extra key used to store the last forwarded number associated with the current
699 * connection. Used to communicate to the user interface that the connection was forwarded via
700 * the specified number.
701 */
702 public static final String EXTRA_LAST_FORWARDED_NUMBER =
703 "android.telecom.extra.LAST_FORWARDED_NUMBER";
704
705 /**
706 * Connection extra key used to store a child number associated with the current connection.
707 * Used to communicate to the user interface that the connection was received via
708 * a child address (i.e. phone number) associated with the {@link PhoneAccount}'s primary
709 * address.
710 */
711 public static final String EXTRA_CHILD_ADDRESS = "android.telecom.extra.CHILD_ADDRESS";
712
713 /**
714 * Connection extra key used to store the subject for an incoming call. The user interface can
715 * query this extra and display its contents for incoming calls. Will only be used if the
716 * {@link PhoneAccount} supports the capability {@link PhoneAccount#CAPABILITY_CALL_SUBJECT}.
717 */
718 public static final String EXTRA_CALL_SUBJECT = "android.telecom.extra.CALL_SUBJECT";
719
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800720 /**
Tyler Gunn4b6614e2016-06-22 10:35:13 -0700721 * Boolean connection extra key set on a {@link Connection} in
722 * {@link Connection#STATE_RINGING} state to indicate that answering the call will cause the
723 * current active foreground call to be dropped.
724 */
725 public static final String EXTRA_ANSWERING_DROPS_FG_CALL =
726 "android.telecom.extra.ANSWERING_DROPS_FG_CALL";
727
728 /**
Tyler Gunn37653562017-03-13 18:15:15 -0700729 * String connection extra key set on a {@link Connection} in {@link Connection#STATE_RINGING}
730 * state to indicate the name of the third-party app which is responsible for the current
731 * foreground call.
732 * <p>
733 * Used when {@link #EXTRA_ANSWERING_DROPS_FG_CALL} is true to ensure that the default Phone app
734 * is able to inform the user that answering the new incoming call will cause a call owned by
735 * another app to be dropped when the incoming call is answered.
736 */
737 public static final String EXTRA_ANSWERING_DROPS_FG_CALL_APP_NAME =
738 "android.telecom.extra.ANSWERING_DROPS_FG_CALL_APP_NAME";
739
740 /**
Hall Liu10208662016-06-15 17:55:00 -0700741 * Boolean connection extra key on a {@link Connection} which indicates that adding an
Hall Liuee6e86b2016-07-06 16:32:43 -0700742 * additional call is disallowed.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700743 * <p>
744 * Used for mobile-network calls to identify scenarios where carrier requirements preclude
745 * adding another call at the current time.
Hall Liu10208662016-06-15 17:55:00 -0700746 * @hide
747 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700748 @SystemApi
Hall Liuee6e86b2016-07-06 16:32:43 -0700749 public static final String EXTRA_DISABLE_ADD_CALL =
750 "android.telecom.extra.DISABLE_ADD_CALL";
Hall Liu10208662016-06-15 17:55:00 -0700751
752 /**
Tyler Gunncd6ccfd2016-10-17 15:48:19 -0700753 * String connection extra key on a {@link Connection} or {@link Conference} which contains the
754 * original Connection ID associated with the connection. Used in
755 * {@link RemoteConnectionService} to track the Connection ID which was originally assigned to a
756 * connection/conference added via
757 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)} and
758 * {@link ConnectionService#addConference(Conference)} APIs. This is important to pass to
759 * Telecom for when it deals with RemoteConnections. When the ConnectionManager wraps the
760 * {@link RemoteConnection} and {@link RemoteConference} and adds it to Telecom, there needs to
761 * be a way to ensure that we don't add the connection again as a duplicate.
762 * <p>
763 * For example, the TelephonyCS calls addExistingConnection for a Connection with ID
764 * {@code TelephonyCS@1}. The ConnectionManager learns of this via
765 * {@link ConnectionService#onRemoteExistingConnectionAdded(RemoteConnection)}, and wraps this
766 * in a new {@link Connection} which it adds to Telecom via
767 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)}. As part of
768 * this process, the wrapped RemoteConnection gets assigned a new ID (e.g. {@code ConnMan@1}).
769 * The TelephonyCS will ALSO try to add the existing connection to Telecom, except with the
770 * ID it originally referred to the connection as. Thus Telecom needs to know that the
771 * Connection with ID {@code ConnMan@1} is really the same as {@code TelephonyCS@1}.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700772 * <p>
773 * This is an internal Telecom framework concept and is not exposed outside of the Telecom
774 * framework.
Tyler Gunncd6ccfd2016-10-17 15:48:19 -0700775 * @hide
776 */
777 public static final String EXTRA_ORIGINAL_CONNECTION_ID =
778 "android.telecom.extra.ORIGINAL_CONNECTION_ID";
779
780 /**
Tyler Gunnc59fd0c2020-04-17 14:03:35 -0700781 * Extra key set on a {@link Connection} when it was created via a remote connection service.
782 * For example, if a connection manager requests a remote connection service to create a call
783 * using one of the remote connection service's phone account handle, this extra will be set so
784 * that Telecom knows that the wrapped remote connection originated in a remote connection
785 * service. We stash this in the extras since connection managers will typically copy the
786 * extras from a {@link RemoteConnection} to a {@link Connection} (there is ultimately not
787 * other way to relate a {@link RemoteConnection} to a {@link Connection}.
788 * @hide
789 */
790 public static final String EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE =
791 "android.telecom.extra.REMOTE_PHONE_ACCOUNT_HANDLE";
792
793 /**
Tyler Gunnfdc4bff2021-06-24 11:25:07 -0700794 * The Telecom call ID of the conference an existing connection should be added to. This is
795 * required when {@link com.android.services.telephony.TelephonyConnectionService} adds a
796 * {@link Conference} to Telecom using the
797 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection, Conference)}
798 * API. That API specifies a parent conference associated with the new existing connection
799 * being added, and there is no equivalent as part of the {@link RemoteConnectionService} API.
800 * This extra key is used to stack the ID of the conference to which the existing connection
801 * will be added so that Telecom can link it up correctly when the {@link RemoteConference}
802 * is added to Telecom by the connection manager.
803 * @hide
804 */
805 public static final String EXTRA_ADD_TO_CONFERENCE_ID =
806 "android.telecom.extra.ADD_TO_CONFERENCE_ID";
807
808 /**
Tyler Gunnc59fd0c2020-04-17 14:03:35 -0700809 * Extra key set from a {@link ConnectionService} when using the remote connection APIs
810 * (e.g. {@link RemoteConnectionService#createRemoteConnection(PhoneAccountHandle,
811 * ConnectionRequest, boolean)}) to create a remote connection. Provides the receiving
812 * {@link ConnectionService} with a means to know the package name of the requesting
813 * {@link ConnectionService} so that {@link #EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE} can be set for
814 * better visibility in Telecom of where a connection ultimately originated.
815 * @hide
816 */
817 public static final String EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME =
818 "android.telecom.extra.REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME";
819
820 /**
Wileen Chiuf2ec2982018-07-01 14:21:50 -0700821 * Boolean connection extra key set on the extras passed to
822 * {@link Connection#sendConnectionEvent} which indicates that audio is present
823 * on the RTT call when the extra value is true.
824 */
825 public static final String EXTRA_IS_RTT_AUDIO_PRESENT =
826 "android.telecom.extra.IS_RTT_AUDIO_PRESENT";
827
828 /**
Tyler Gunn1c687622019-12-20 11:08:13 -0800829 * The audio codec in use for the current {@link Connection}, if known. Examples of valid
830 * values include {@link #AUDIO_CODEC_AMR_WB} and {@link #AUDIO_CODEC_EVS_WB}.
allenwtsu2aca9892019-11-25 14:38:21 +0800831 */
Tyler Gunn1c687622019-12-20 11:08:13 -0800832 public static final @AudioCodec String EXTRA_AUDIO_CODEC =
allenwtsu2aca9892019-11-25 14:38:21 +0800833 "android.telecom.extra.AUDIO_CODEC";
834
835 /**
allenwtsu6ec972a2020-11-10 17:32:46 +0800836 * Float connection extra key used to store the audio codec bitrate in kbps for the current
837 * {@link Connection}.
838 */
839 public static final String EXTRA_AUDIO_CODEC_BITRATE_KBPS =
840 "android.telecom.extra.AUDIO_CODEC_BITRATE_KBPS";
841
842 /**
843 * Float connection extra key used to store the audio codec bandwidth in khz for the current
844 * {@link Connection}.
845 */
846 public static final String EXTRA_AUDIO_CODEC_BANDWIDTH_KHZ =
847 "android.telecom.extra.AUDIO_CODEC_BANDWIDTH_KHZ";
Tyler Gunn78a59ff2021-05-07 16:41:19 -0700848
849 /**
Sooraj Sasindran065b77d2022-02-24 00:14:51 -0800850 * Last known cell identity key {@link CellIdentity} to be used to fill geo location header
851 * in case of an emergency call. This entry will not be filled if call is not identified as
852 * an emergency call. Only provided to the {@link ConnectionService} for the purpose of
853 * placing an emergency call; will not be present in the {@link InCallService} layer.
Sooraj Sasindran81be0822021-10-26 02:03:37 -0700854 * The {@link ConnectionService}'s implementation will be logged for fine location access
855 * when an outgoing call is placed in this case.
856 */
857 public static final String EXTRA_LAST_KNOWN_CELL_IDENTITY =
858 "android.telecom.extra.LAST_KNOWN_CELL_IDENTITY";
859
860 /**
Tyler Gunn78a59ff2021-05-07 16:41:19 -0700861 * Boolean connection extra key used to indicate whether device to device communication is
862 * available for the current call.
863 * @hide
864 */
865 public static final String EXTRA_IS_DEVICE_TO_DEVICE_COMMUNICATION_AVAILABLE =
866 "android.telecom.extra.IS_DEVICE_TO_DEVICE_COMMUNICATION_AVAILABLE";
867
allenwtsu6ec972a2020-11-10 17:32:46 +0800868 /**
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800869 * Connection event used to inform Telecom that it should play the on hold tone. This is used
870 * to play a tone when the peer puts the current call on hold. Sent to Telecom via
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700871 * {@link #sendConnectionEvent(String, Bundle)}.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800872 */
873 public static final String EVENT_ON_HOLD_TONE_START =
874 "android.telecom.event.ON_HOLD_TONE_START";
875
876 /**
877 * Connection event used to inform Telecom that it should stop the on hold tone. This is used
878 * to stop a tone when the peer puts the current call on hold. Sent to Telecom via
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700879 * {@link #sendConnectionEvent(String, Bundle)}.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800880 */
881 public static final String EVENT_ON_HOLD_TONE_END =
882 "android.telecom.event.ON_HOLD_TONE_END";
883
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700884 /**
885 * Connection event used to inform {@link InCallService}s when pulling of an external call has
886 * failed. The user interface should inform the user of the error.
887 * <p>
888 * Expected to be used by the {@link ConnectionService} when the {@link Call#pullExternalCall()}
889 * API is called on a {@link Call} with the properties
890 * {@link Call.Details#PROPERTY_IS_EXTERNAL_CALL} and
891 * {@link Call.Details#CAPABILITY_CAN_PULL_CALL}, but the {@link ConnectionService} could not
892 * pull the external call due to an error condition.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700893 * <p>
894 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
895 * expected to be null when this connection event is used.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700896 */
897 public static final String EVENT_CALL_PULL_FAILED = "android.telecom.event.CALL_PULL_FAILED";
898
Brad Ebinger2c1c16452016-05-27 15:58:10 -0700899 /**
900 * Connection event used to inform {@link InCallService}s when the merging of two calls has
901 * failed. The User Interface should use this message to inform the user of the error.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700902 * <p>
903 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
904 * expected to be null when this connection event is used.
Brad Ebinger2c1c16452016-05-27 15:58:10 -0700905 */
906 public static final String EVENT_CALL_MERGE_FAILED = "android.telecom.event.CALL_MERGE_FAILED";
907
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700908 /**
Hall Liu06ae75b2019-03-11 19:11:35 -0700909 * Connection event used to inform Telecom when a hold operation on a call has failed.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700910 * <p>
Hall Liu06ae75b2019-03-11 19:11:35 -0700911 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
912 * expected to be null when this connection event is used.
Hall Liu06ae75b2019-03-11 19:11:35 -0700913 */
914 public static final String EVENT_CALL_HOLD_FAILED = "android.telecom.event.CALL_HOLD_FAILED";
915
916 /**
Masaho Nishikawacb8fa742019-11-07 14:41:21 +0900917 * Connection event used to inform Telecom when a switch operation on a call has failed.
918 * <p>
919 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
920 * expected to be null when this connection event is used.
921 */
922 public static final String EVENT_CALL_SWITCH_FAILED =
923 "android.telecom.event.CALL_SWITCH_FAILED";
924
925 /**
Tyler Gunn78da7812017-05-09 14:34:57 -0700926 * Connection event used to inform {@link InCallService}s when the process of merging a
927 * Connection into a conference has begun.
928 * <p>
929 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
930 * expected to be null when this connection event is used.
Tyler Gunn78da7812017-05-09 14:34:57 -0700931 */
932 public static final String EVENT_MERGE_START = "android.telecom.event.MERGE_START";
933
934 /**
935 * Connection event used to inform {@link InCallService}s when the process of merging a
936 * Connection into a conference has completed.
937 * <p>
938 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
939 * expected to be null when this connection event is used.
Tyler Gunn78da7812017-05-09 14:34:57 -0700940 */
941 public static final String EVENT_MERGE_COMPLETE = "android.telecom.event.MERGE_COMPLETE";
942
943 /**
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700944 * Connection event used to inform {@link InCallService}s when a call has been put on hold by
945 * the remote party.
946 * <p>
947 * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the
948 * call is being held locally on the device. When a capable {@link ConnectionService} receives
949 * signalling to indicate that the remote party has put the call on hold, it can send this
950 * connection event.
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700951 */
952 public static final String EVENT_CALL_REMOTELY_HELD =
953 "android.telecom.event.CALL_REMOTELY_HELD";
954
955 /**
956 * Connection event used to inform {@link InCallService}s when a call which was remotely held
957 * (see {@link #EVENT_CALL_REMOTELY_HELD}) has been un-held by the remote party.
958 * <p>
959 * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the
960 * call is being held locally on the device. When a capable {@link ConnectionService} receives
961 * signalling to indicate that the remote party has taken the call off hold, it can send this
962 * connection event.
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700963 */
964 public static final String EVENT_CALL_REMOTELY_UNHELD =
965 "android.telecom.event.CALL_REMOTELY_UNHELD";
966
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700967 /**
968 * Connection event used to inform an {@link InCallService} which initiated a call handover via
969 * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has
970 * successfully completed.
971 * @hide
Tyler Gunn1a505fa2018-09-14 13:36:38 -0700972 * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated
973 * APIs instead.
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700974 */
975 public static final String EVENT_HANDOVER_COMPLETE =
976 "android.telecom.event.HANDOVER_COMPLETE";
977
978 /**
979 * Connection event used to inform an {@link InCallService} which initiated a call handover via
980 * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has failed
981 * to complete.
982 * @hide
Tyler Gunn1a505fa2018-09-14 13:36:38 -0700983 * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated
984 * APIs instead.
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700985 */
986 public static final String EVENT_HANDOVER_FAILED =
987 "android.telecom.event.HANDOVER_FAILED";
988
shilub7ec9a02018-11-09 15:52:04 -0800989 /**
Shi Lu528eb5b2019-02-08 05:09:11 +0000990 * String Connection extra key used to store SIP invite fields for an incoming call for IMS call
shilub7ec9a02018-11-09 15:52:04 -0800991 */
992 public static final String EXTRA_SIP_INVITE = "android.telecom.extra.SIP_INVITE";
993
Wileen Chiuf2ec2982018-07-01 14:21:50 -0700994 /**
995 * Connection event used to inform an {@link InCallService} that the RTT audio indication
996 * has changed.
997 */
998 public static final String EVENT_RTT_AUDIO_INDICATION_CHANGED =
999 "android.telecom.event.RTT_AUDIO_INDICATION_CHANGED";
1000
Tyler Gunnd5821842021-02-05 11:12:57 -08001001 /**
1002 * Connection event used to signal between the telephony {@link ConnectionService} and Telecom
1003 * when device to device messages are sent/received.
1004 * <p>
1005 * Device to device messages originating from the network are sent by telephony using
1006 * {@link Connection#sendConnectionEvent(String, Bundle)} and are routed up to any active
1007 * {@link CallDiagnosticService} implementation which is active.
1008 * <p>
1009 * Likewise, if a {@link CallDiagnosticService} sends a message using
Tyler Gunn066de602021-03-16 09:58:07 -07001010 * {@link CallDiagnostics#sendDeviceToDeviceMessage(int, int)}, it will be routed to telephony
Tyler Gunnd5821842021-02-05 11:12:57 -08001011 * via {@link Connection#onCallEvent(String, Bundle)}. The telephony stack will relay the
1012 * message to the other device.
1013 * @hide
1014 */
1015 @SystemApi
1016 public static final String EVENT_DEVICE_TO_DEVICE_MESSAGE =
1017 "android.telecom.event.DEVICE_TO_DEVICE_MESSAGE";
1018
1019 /**
1020 * Sent along with {@link #EVENT_DEVICE_TO_DEVICE_MESSAGE} to indicate the device to device
1021 * message type.
1022 *
Tyler Gunn066de602021-03-16 09:58:07 -07001023 * See {@link CallDiagnostics} for more information.
Tyler Gunnd5821842021-02-05 11:12:57 -08001024 * @hide
1025 */
1026 @SystemApi
1027 public static final String EXTRA_DEVICE_TO_DEVICE_MESSAGE_TYPE =
1028 "android.telecom.extra.DEVICE_TO_DEVICE_MESSAGE_TYPE";
1029
1030 /**
1031 * Sent along with {@link #EVENT_DEVICE_TO_DEVICE_MESSAGE} to indicate the device to device
1032 * message value.
1033 * <p>
Tyler Gunn066de602021-03-16 09:58:07 -07001034 * See {@link CallDiagnostics} for more information.
Tyler Gunnd5821842021-02-05 11:12:57 -08001035 * @hide
1036 */
1037 @SystemApi
1038 public static final String EXTRA_DEVICE_TO_DEVICE_MESSAGE_VALUE =
1039 "android.telecom.extra.DEVICE_TO_DEVICE_MESSAGE_VALUE";
1040
Tyler Gunn0a1c6d12021-03-12 15:44:08 -08001041 /**
1042 * Connection event used to communicate a {@link android.telephony.CallQuality} report from
1043 * telephony to Telecom for relaying to
1044 * {@link DiagnosticCall#onCallQualityReceived(CallQuality)}.
1045 * @hide
1046 */
1047 public static final String EVENT_CALL_QUALITY_REPORT =
1048 "android.telecom.event.CALL_QUALITY_REPORT";
1049
1050 /**
1051 * Extra sent with {@link #EVENT_CALL_QUALITY_REPORT} containing the
1052 * {@link android.telephony.CallQuality} data.
1053 * @hide
1054 */
1055 public static final String EXTRA_CALL_QUALITY_REPORT =
1056 "android.telecom.extra.CALL_QUALITY_REPORT";
1057
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001058 // Flag controlling whether PII is emitted into the logs
1059 private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG);
1060
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001061 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07001062 * Renders a set of capability bits ({@code CAPABILITY_*}) as a human readable string.
1063 *
1064 * @param capabilities A capability bit field.
1065 * @return A human readable string representation.
1066 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001067 public static String capabilitiesToString(int capabilities) {
Santos Cordon1a749302016-07-26 16:08:53 -07001068 return capabilitiesToStringInternal(capabilities, true /* isLong */);
1069 }
1070
1071 /**
1072 * Renders a set of capability bits ({@code CAPABILITY_*}) as a *short* human readable
1073 * string.
1074 *
1075 * @param capabilities A capability bit field.
1076 * @return A human readable string representation.
1077 * @hide
1078 */
1079 public static String capabilitiesToStringShort(int capabilities) {
1080 return capabilitiesToStringInternal(capabilities, false /* isLong */);
1081 }
1082
1083 private static String capabilitiesToStringInternal(int capabilities, boolean isLong) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001084 StringBuilder builder = new StringBuilder();
Santos Cordon1a749302016-07-26 16:08:53 -07001085 builder.append("[");
1086 if (isLong) {
1087 builder.append("Capabilities:");
1088 }
1089
Tyler Gunnc63f9082019-10-15 13:19:26 -07001090 if ((capabilities & CAPABILITY_HOLD) == CAPABILITY_HOLD) {
Santos Cordon1a749302016-07-26 16:08:53 -07001091 builder.append(isLong ? " CAPABILITY_HOLD" : " hld");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001092 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001093 if ((capabilities & CAPABILITY_SUPPORT_HOLD) == CAPABILITY_SUPPORT_HOLD) {
Santos Cordon1a749302016-07-26 16:08:53 -07001094 builder.append(isLong ? " CAPABILITY_SUPPORT_HOLD" : " sup_hld");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001095 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001096 if ((capabilities & CAPABILITY_MERGE_CONFERENCE) == CAPABILITY_MERGE_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001097 builder.append(isLong ? " CAPABILITY_MERGE_CONFERENCE" : " mrg_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001098 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001099 if ((capabilities & CAPABILITY_SWAP_CONFERENCE) == CAPABILITY_SWAP_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001100 builder.append(isLong ? " CAPABILITY_SWAP_CONFERENCE" : " swp_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001101 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001102 if ((capabilities & CAPABILITY_RESPOND_VIA_TEXT) == CAPABILITY_RESPOND_VIA_TEXT) {
Santos Cordon1a749302016-07-26 16:08:53 -07001103 builder.append(isLong ? " CAPABILITY_RESPOND_VIA_TEXT" : " txt");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001104 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001105 if ((capabilities & CAPABILITY_MUTE) == CAPABILITY_MUTE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001106 builder.append(isLong ? " CAPABILITY_MUTE" : " mut");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001107 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001108 if ((capabilities & CAPABILITY_MANAGE_CONFERENCE) == CAPABILITY_MANAGE_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001109 builder.append(isLong ? " CAPABILITY_MANAGE_CONFERENCE" : " mng_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001110 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001111 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_RX) == CAPABILITY_SUPPORTS_VT_LOCAL_RX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001112 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_RX" : " VTlrx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001113 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001114 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_TX) == CAPABILITY_SUPPORTS_VT_LOCAL_TX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001115 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_TX" : " VTltx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001116 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001117 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL)
1118 == CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001119 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL" : " VTlbi");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001120 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001121 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_RX) == CAPABILITY_SUPPORTS_VT_REMOTE_RX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001122 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_RX" : " VTrrx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001123 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001124 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_TX) == CAPABILITY_SUPPORTS_VT_REMOTE_TX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001125 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_TX" : " VTrtx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001126 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001127 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL)
1128 == CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001129 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL" : " VTrbi");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001130 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001131 if ((capabilities & CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO)
1132 == CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001133 builder.append(isLong ? " CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO" : " !v2a");
Tyler Gunnf97a0092016-01-19 15:59:34 -08001134 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001135 if ((capabilities & CAPABILITY_SPEED_UP_MT_AUDIO) == CAPABILITY_SPEED_UP_MT_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001136 builder.append(isLong ? " CAPABILITY_SPEED_UP_MT_AUDIO" : " spd_aud");
Dong Zhou89f41eb2015-03-15 11:59:49 -05001137 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001138 if ((capabilities & CAPABILITY_CAN_UPGRADE_TO_VIDEO) == CAPABILITY_CAN_UPGRADE_TO_VIDEO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001139 builder.append(isLong ? " CAPABILITY_CAN_UPGRADE_TO_VIDEO" : " a2v");
Rekha Kumar07366812015-03-24 16:42:31 -07001140 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001141 if ((capabilities & CAPABILITY_CAN_PAUSE_VIDEO) == CAPABILITY_CAN_PAUSE_VIDEO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001142 builder.append(isLong ? " CAPABILITY_CAN_PAUSE_VIDEO" : " paus_VT");
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -07001143 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001144 if ((capabilities & CAPABILITY_CONFERENCE_HAS_NO_CHILDREN)
1145 == CAPABILITY_CONFERENCE_HAS_NO_CHILDREN) {
Santos Cordon1a749302016-07-26 16:08:53 -07001146 builder.append(isLong ? " CAPABILITY_SINGLE_PARTY_CONFERENCE" : " 1p_cnf");
Tyler Gunnd4091732015-06-29 09:15:37 -07001147 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001148 if ((capabilities & CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION)
1149 == CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION) {
Santos Cordon1a749302016-07-26 16:08:53 -07001150 builder.append(isLong ? " CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION" : " rsp_by_con");
Bryce Lee81901682015-08-28 16:38:02 -07001151 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001152 if ((capabilities & CAPABILITY_CAN_PULL_CALL) == CAPABILITY_CAN_PULL_CALL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001153 builder.append(isLong ? " CAPABILITY_CAN_PULL_CALL" : " pull");
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001154 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001155 if ((capabilities & CAPABILITY_SUPPORT_DEFLECT) == CAPABILITY_SUPPORT_DEFLECT) {
Pooja Jaind34698d2017-12-28 14:15:31 +05301156 builder.append(isLong ? " CAPABILITY_SUPPORT_DEFLECT" : " sup_def");
1157 }
Ravi Paluri404babb2020-01-23 19:02:44 +05301158 if ((capabilities & CAPABILITY_ADD_PARTICIPANT) == CAPABILITY_ADD_PARTICIPANT) {
1159 builder.append(isLong ? " CAPABILITY_ADD_PARTICIPANT" : " add_participant");
1160 }
Ravi Palurif4b38e72020-02-05 12:35:41 +05301161 if ((capabilities & CAPABILITY_TRANSFER) == CAPABILITY_TRANSFER) {
1162 builder.append(isLong ? " CAPABILITY_TRANSFER" : " sup_trans");
1163 }
1164 if ((capabilities & CAPABILITY_TRANSFER_CONSULTATIVE)
1165 == CAPABILITY_TRANSFER_CONSULTATIVE) {
1166 builder.append(isLong ? " CAPABILITY_TRANSFER_CONSULTATIVE" : " sup_cTrans");
1167 }
Alvin Dey2f37d772018-05-18 23:16:10 +05301168 if ((capabilities & CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT)
1169 == CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT) {
1170 builder.append(isLong ? " CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT" : " sup_rtt");
1171 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001172 builder.append("]");
1173 return builder.toString();
1174 }
1175
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07001176 /**
1177 * Renders a set of property bits ({@code PROPERTY_*}) as a human readable string.
1178 *
1179 * @param properties A property bit field.
1180 * @return A human readable string representation.
1181 */
Tyler Gunn720c6642016-03-22 09:02:47 -07001182 public static String propertiesToString(int properties) {
Santos Cordon1a749302016-07-26 16:08:53 -07001183 return propertiesToStringInternal(properties, true /* isLong */);
1184 }
1185
1186 /**
1187 * Renders a set of property bits ({@code PROPERTY_*}) as a *short* human readable string.
1188 *
1189 * @param properties A property bit field.
1190 * @return A human readable string representation.
1191 * @hide
1192 */
1193 public static String propertiesToStringShort(int properties) {
1194 return propertiesToStringInternal(properties, false /* isLong */);
1195 }
1196
1197 private static String propertiesToStringInternal(int properties, boolean isLong) {
Tyler Gunn720c6642016-03-22 09:02:47 -07001198 StringBuilder builder = new StringBuilder();
Santos Cordon1a749302016-07-26 16:08:53 -07001199 builder.append("[");
1200 if (isLong) {
1201 builder.append("Properties:");
1202 }
Tyler Gunn720c6642016-03-22 09:02:47 -07001203
Tyler Gunnc63f9082019-10-15 13:19:26 -07001204 if ((properties & PROPERTY_SELF_MANAGED) == PROPERTY_SELF_MANAGED) {
Tyler Gunnf5035432017-01-09 09:43:12 -08001205 builder.append(isLong ? " PROPERTY_SELF_MANAGED" : " self_mng");
1206 }
1207
Tyler Gunnc63f9082019-10-15 13:19:26 -07001208 if ((properties & PROPERTY_EMERGENCY_CALLBACK_MODE) == PROPERTY_EMERGENCY_CALLBACK_MODE) {
Hall Liu25c7c4d2016-08-30 13:41:02 -07001209 builder.append(isLong ? " PROPERTY_EMERGENCY_CALLBACK_MODE" : " ecbm");
Tyler Gunn720c6642016-03-22 09:02:47 -07001210 }
1211
Tyler Gunnc63f9082019-10-15 13:19:26 -07001212 if ((properties & PROPERTY_HIGH_DEF_AUDIO) == PROPERTY_HIGH_DEF_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001213 builder.append(isLong ? " PROPERTY_HIGH_DEF_AUDIO" : " HD");
Tyler Gunn720c6642016-03-22 09:02:47 -07001214 }
1215
Tyler Gunnc63f9082019-10-15 13:19:26 -07001216 if ((properties & PROPERTY_WIFI) == PROPERTY_WIFI) {
Santos Cordon1a749302016-07-26 16:08:53 -07001217 builder.append(isLong ? " PROPERTY_WIFI" : " wifi");
Tyler Gunn720c6642016-03-22 09:02:47 -07001218 }
1219
Tyler Gunnc63f9082019-10-15 13:19:26 -07001220 if ((properties & PROPERTY_GENERIC_CONFERENCE) == PROPERTY_GENERIC_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001221 builder.append(isLong ? " PROPERTY_GENERIC_CONFERENCE" : " gen_conf");
Tyler Gunn720c6642016-03-22 09:02:47 -07001222 }
1223
Tyler Gunnc63f9082019-10-15 13:19:26 -07001224 if ((properties & PROPERTY_IS_EXTERNAL_CALL) == PROPERTY_IS_EXTERNAL_CALL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001225 builder.append(isLong ? " PROPERTY_IS_EXTERNAL_CALL" : " xtrnl");
Tyler Gunn720c6642016-03-22 09:02:47 -07001226 }
1227
Tyler Gunnc63f9082019-10-15 13:19:26 -07001228 if ((properties & PROPERTY_HAS_CDMA_VOICE_PRIVACY) == PROPERTY_HAS_CDMA_VOICE_PRIVACY) {
Santos Cordon1a749302016-07-26 16:08:53 -07001229 builder.append(isLong ? " PROPERTY_HAS_CDMA_VOICE_PRIVACY" : " priv");
Brad Ebinger15847072016-05-18 11:08:36 -07001230 }
1231
Tyler Gunnc63f9082019-10-15 13:19:26 -07001232 if ((properties & PROPERTY_IS_RTT) == PROPERTY_IS_RTT) {
Hall Liud4d2a8a2018-01-29 17:22:02 -08001233 builder.append(isLong ? " PROPERTY_IS_RTT" : " rtt");
1234 }
1235
Tyler Gunnc63f9082019-10-15 13:19:26 -07001236 if ((properties & PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL)
1237 == PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL) {
Tyler Gunn5bd90852018-09-21 09:37:07 -07001238 builder.append(isLong ? " PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL" : " ecall");
1239 }
1240
Tyler Gunnc63f9082019-10-15 13:19:26 -07001241 if ((properties & PROPERTY_REMOTELY_HOSTED) == PROPERTY_REMOTELY_HOSTED) {
Tyler Gunnac60f952019-05-31 07:23:16 -07001242 builder.append(isLong ? " PROPERTY_REMOTELY_HOSTED" : " remote_hst");
1243 }
1244
Ravi Paluri80aa2142019-12-02 11:57:37 +05301245 if ((properties & PROPERTY_IS_ADHOC_CONFERENCE) == PROPERTY_IS_ADHOC_CONFERENCE) {
1246 builder.append(isLong ? " PROPERTY_IS_ADHOC_CONFERENCE" : " adhoc_conf");
1247 }
1248
Hall Liue0f787c2020-07-08 11:25:56 -07001249 if ((properties & PROPERTY_IS_DOWNGRADED_CONFERENCE) == PROPERTY_IS_DOWNGRADED_CONFERENCE) {
1250 builder.append(isLong ? " PROPERTY_IS_DOWNGRADED_CONFERENCE" : " dngrd_conf");
1251 }
1252
Tyler Gunn720c6642016-03-22 09:02:47 -07001253 builder.append("]");
1254 return builder.toString();
1255 }
1256
Sailesh Nepal091768c2014-06-30 15:15:23 -07001257 /** @hide */
Tyler Gunn633e4c32019-10-24 15:40:48 -07001258 abstract static class Listener {
Ihab Awad542e0ea2014-05-16 10:22:16 -07001259 public void onStateChanged(Connection c, int state) {}
Andrew Lee100e2932014-09-08 15:34:24 -07001260 public void onAddressChanged(Connection c, Uri newAddress, int presentation) {}
Sailesh Nepal61203862014-07-11 14:50:13 -07001261 public void onCallerDisplayNameChanged(
1262 Connection c, String callerDisplayName, int presentation) {}
Tyler Gunnaa07df82014-07-17 07:50:22 -07001263 public void onVideoStateChanged(Connection c, int videoState) {}
Andrew Lee7f3d41f2014-09-11 17:33:16 -07001264 public void onDisconnected(Connection c, DisconnectCause disconnectCause) {}
Sailesh Nepal091768c2014-06-30 15:15:23 -07001265 public void onPostDialWait(Connection c, String remaining) {}
Nancy Chen27d1c2d2014-12-15 16:12:50 -08001266 public void onPostDialChar(Connection c, char nextChar) {}
Andrew Lee100e2932014-09-08 15:34:24 -07001267 public void onRingbackRequested(Connection c, boolean ringback) {}
Sailesh Nepal61203862014-07-11 14:50:13 -07001268 public void onDestroyed(Connection c) {}
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001269 public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {}
Tyler Gunn720c6642016-03-22 09:02:47 -07001270 public void onConnectionPropertiesChanged(Connection c, int properties) {}
Christine Hallstrom2830ce92016-11-30 16:06:42 -08001271 public void onSupportedAudioRoutesChanged(Connection c, int supportedAudioRoutes) {}
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001272 public void onVideoProviderChanged(
1273 Connection c, VideoProvider videoProvider) {}
Sailesh Nepal001bbbb2014-07-15 14:40:39 -07001274 public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {}
1275 public void onStatusHintsChanged(Connection c, StatusHints statusHints) {}
Tyler Gunn6d76ca02014-11-17 15:49:51 -08001276 public void onConferenceablesChanged(
Tyler Gunndf2cbc82015-04-20 09:13:01 -07001277 Connection c, List<Conferenceable> conferenceables) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -07001278 public void onConferenceChanged(Connection c, Conference conference) {}
Anthony Lee17455a32015-04-24 15:25:29 -07001279 public void onConferenceMergeFailed(Connection c) {}
Santos Cordon6b7f9552015-05-27 17:21:45 -07001280 public void onExtrasChanged(Connection c, Bundle extras) {}
Tyler Gunndee56a82016-03-23 16:06:34 -07001281 public void onExtrasRemoved(Connection c, List<String> keys) {}
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001282 public void onConnectionEvent(Connection c, String event, Bundle extras) {}
Hall Liua98f58b52017-11-07 17:59:28 -08001283 public void onAudioRouteChanged(Connection c, int audioRoute, String bluetoothAddress) {}
Hall Liub64ac4c2017-02-06 10:49:48 -08001284 public void onRttInitiationSuccess(Connection c) {}
1285 public void onRttInitiationFailure(Connection c, int reason) {}
1286 public void onRttSessionRemotelyTerminated(Connection c) {}
1287 public void onRemoteRttRequest(Connection c) {}
Srikanth Chintalafcb15012017-05-04 20:58:34 +05301288 /** @hide */
1289 public void onPhoneAccountChanged(Connection c, PhoneAccountHandle pHandle) {}
Mengjun Leng25707742017-07-04 11:10:37 +08001290 public void onConnectionTimeReset(Connection c) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07001291 }
1292
Tyler Gunnb702ef82015-05-29 11:51:53 -07001293 /**
Hall Liu95d55872017-01-25 17:12:49 -08001294 * Provides methods to read and write RTT data to/from the in-call app.
Hall Liu95d55872017-01-25 17:12:49 -08001295 */
1296 public static final class RttTextStream {
1297 private static final int READ_BUFFER_SIZE = 1000;
1298 private final InputStreamReader mPipeFromInCall;
1299 private final OutputStreamWriter mPipeToInCall;
Hall Liub64ac4c2017-02-06 10:49:48 -08001300 private final ParcelFileDescriptor mFdFromInCall;
1301 private final ParcelFileDescriptor mFdToInCall;
Hall Liu17eb1bd2018-07-03 15:17:41 -07001302
1303 private final FileInputStream mFromInCallFileInputStream;
Hall Liu95d55872017-01-25 17:12:49 -08001304 private char[] mReadBuffer = new char[READ_BUFFER_SIZE];
1305
1306 /**
1307 * @hide
1308 */
1309 public RttTextStream(ParcelFileDescriptor toInCall, ParcelFileDescriptor fromInCall) {
Hall Liub64ac4c2017-02-06 10:49:48 -08001310 mFdFromInCall = fromInCall;
1311 mFdToInCall = toInCall;
Hall Liu17eb1bd2018-07-03 15:17:41 -07001312 mFromInCallFileInputStream = new FileInputStream(fromInCall.getFileDescriptor());
Hall Liu730a2592018-06-25 19:48:33 -07001313
1314 // Wrap the FileInputStream in a Channel so that it's interruptible.
Hall Liu95d55872017-01-25 17:12:49 -08001315 mPipeFromInCall = new InputStreamReader(
Hall Liu17eb1bd2018-07-03 15:17:41 -07001316 Channels.newInputStream(Channels.newChannel(mFromInCallFileInputStream)));
Hall Liu95d55872017-01-25 17:12:49 -08001317 mPipeToInCall = new OutputStreamWriter(
Hall Liua549fed2018-02-09 16:40:03 -08001318 new FileOutputStream(toInCall.getFileDescriptor()));
Hall Liu95d55872017-01-25 17:12:49 -08001319 }
1320
1321 /**
1322 * Writes the string {@param input} into the text stream to the UI for this RTT call. Since
1323 * RTT transmits text in real-time, this method should be called as often as text snippets
1324 * are received from the remote user, even if it is only one character.
Hall Liua549fed2018-02-09 16:40:03 -08001325 * <p>
Hall Liu95d55872017-01-25 17:12:49 -08001326 * This method is not thread-safe -- calling it from multiple threads simultaneously may
1327 * lead to interleaved text.
Hall Liua549fed2018-02-09 16:40:03 -08001328 *
Hall Liu95d55872017-01-25 17:12:49 -08001329 * @param input The message to send to the in-call app.
1330 */
1331 public void write(String input) throws IOException {
1332 mPipeToInCall.write(input);
1333 mPipeToInCall.flush();
1334 }
1335
1336
1337 /**
1338 * Reads a string from the in-call app, blocking if there is no data available. Returns
1339 * {@code null} if the RTT conversation has been terminated and there is no further data
1340 * to read.
Hall Liua549fed2018-02-09 16:40:03 -08001341 * <p>
Hall Liu95d55872017-01-25 17:12:49 -08001342 * This method is not thread-safe -- calling it from multiple threads simultaneously may
1343 * lead to interleaved text.
Hall Liua549fed2018-02-09 16:40:03 -08001344 *
Hall Liu95d55872017-01-25 17:12:49 -08001345 * @return A string containing text entered by the user, or {@code null} if the
1346 * conversation has been terminated or if there was an error while reading.
1347 */
Hall Liuffa4a812017-03-02 16:11:00 -08001348 public String read() throws IOException {
1349 int numRead = mPipeFromInCall.read(mReadBuffer, 0, READ_BUFFER_SIZE);
1350 if (numRead < 0) {
1351 return null;
1352 }
1353 return new String(mReadBuffer, 0, numRead);
1354 }
1355
1356 /**
1357 * Non-blocking version of {@link #read()}. Returns {@code null} if there is nothing to
1358 * be read.
Hall Liua549fed2018-02-09 16:40:03 -08001359 *
Hall Liuffa4a812017-03-02 16:11:00 -08001360 * @return A string containing text entered by the user, or {@code null} if the user has
1361 * not entered any new text yet.
1362 */
1363 public String readImmediately() throws IOException {
Hall Liu17eb1bd2018-07-03 15:17:41 -07001364 if (mFromInCallFileInputStream.available() > 0) {
Hall Liuffa4a812017-03-02 16:11:00 -08001365 return read();
1366 } else {
Hall Liu95d55872017-01-25 17:12:49 -08001367 return null;
1368 }
1369 }
Hall Liub64ac4c2017-02-06 10:49:48 -08001370
1371 /** @hide */
1372 public ParcelFileDescriptor getFdFromInCall() {
1373 return mFdFromInCall;
1374 }
1375
1376 /** @hide */
1377 public ParcelFileDescriptor getFdToInCall() {
1378 return mFdToInCall;
1379 }
1380 }
1381
1382 /**
1383 * Provides constants to represent the results of responses to session modify requests sent via
1384 * {@link Call#sendRttRequest()}
1385 */
1386 public static final class RttModifyStatus {
Hall Liu8dd49082017-04-21 14:33:12 -07001387 private RttModifyStatus() {}
Hall Liub64ac4c2017-02-06 10:49:48 -08001388 /**
1389 * Session modify request was successful.
1390 */
1391 public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1;
1392
1393 /**
1394 * Session modify request failed.
1395 */
1396 public static final int SESSION_MODIFY_REQUEST_FAIL = 2;
1397
1398 /**
1399 * Session modify request ignored due to invalid parameters.
1400 */
1401 public static final int SESSION_MODIFY_REQUEST_INVALID = 3;
1402
1403 /**
1404 * Session modify request timed out.
1405 */
1406 public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4;
1407
1408 /**
1409 * Session modify request rejected by remote user.
1410 */
1411 public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5;
Hall Liu95d55872017-01-25 17:12:49 -08001412 }
1413
1414 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001415 * Provides a means of controlling the video session associated with a {@link Connection}.
1416 * <p>
1417 * Implementations create a custom subclass of {@link VideoProvider} and the
1418 * {@link ConnectionService} creates an instance sets it on the {@link Connection} using
1419 * {@link Connection#setVideoProvider(VideoProvider)}. Any connection which supports video
1420 * should set the {@link VideoProvider}.
1421 * <p>
1422 * The {@link VideoProvider} serves two primary purposes: it provides a means for Telecom and
1423 * {@link InCallService} implementations to issue requests related to the video session;
1424 * it provides a means for the {@link ConnectionService} to report events and information
1425 * related to the video session to Telecom and the {@link InCallService} implementations.
1426 * <p>
1427 * {@link InCallService} implementations interact with the {@link VideoProvider} via
1428 * {@link android.telecom.InCallService.VideoCall}.
1429 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001430 public static abstract class VideoProvider {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001431 /**
1432 * Video is not being received (no protocol pause was issued).
Tyler Gunnb702ef82015-05-29 11:51:53 -07001433 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001434 */
1435 public static final int SESSION_EVENT_RX_PAUSE = 1;
Evan Charltonbf11f982014-07-20 22:06:28 -07001436
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001437 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001438 * Video reception has resumed after a {@link #SESSION_EVENT_RX_PAUSE}.
1439 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001440 */
1441 public static final int SESSION_EVENT_RX_RESUME = 2;
1442
1443 /**
1444 * Video transmission has begun. This occurs after a negotiated start of video transmission
1445 * when the underlying protocol has actually begun transmitting video to the remote party.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001446 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001447 */
1448 public static final int SESSION_EVENT_TX_START = 3;
1449
1450 /**
1451 * Video transmission has stopped. This occurs after a negotiated stop of video transmission
1452 * when the underlying protocol has actually stopped transmitting video to the remote party.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001453 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001454 */
1455 public static final int SESSION_EVENT_TX_STOP = 4;
1456
1457 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001458 * A camera failure has occurred for the selected camera. The {@link VideoProvider} can use
Tyler Gunnb702ef82015-05-29 11:51:53 -07001459 * this as a cue to inform the user the camera is not available.
1460 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001461 */
1462 public static final int SESSION_EVENT_CAMERA_FAILURE = 5;
1463
1464 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001465 * Issued after {@link #SESSION_EVENT_CAMERA_FAILURE} when the camera is once again ready
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001466 * for operation. The {@link VideoProvider} can use this as a cue to inform the user that
Tyler Gunnb702ef82015-05-29 11:51:53 -07001467 * the camera has become available again.
1468 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001469 */
1470 public static final int SESSION_EVENT_CAMERA_READY = 6;
1471
1472 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001473 * Session event raised by Telecom when
1474 * {@link android.telecom.InCallService.VideoCall#setCamera(String)} is called and the
1475 * caller does not have the necessary {@link android.Manifest.permission#CAMERA} permission.
1476 * @see #handleCallSessionEvent(int)
1477 */
1478 public static final int SESSION_EVENT_CAMERA_PERMISSION_ERROR = 7;
1479
1480 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001481 * Session modify request was successful.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001482 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001483 */
1484 public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1;
1485
1486 /**
1487 * Session modify request failed.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001488 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001489 */
1490 public static final int SESSION_MODIFY_REQUEST_FAIL = 2;
1491
1492 /**
1493 * Session modify request ignored due to invalid parameters.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001494 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001495 */
1496 public static final int SESSION_MODIFY_REQUEST_INVALID = 3;
1497
Rekha Kumar07366812015-03-24 16:42:31 -07001498 /**
1499 * Session modify request timed out.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001500 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Rekha Kumar07366812015-03-24 16:42:31 -07001501 */
1502 public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4;
1503
1504 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001505 * Session modify request rejected by remote user.
1506 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Rekha Kumar07366812015-03-24 16:42:31 -07001507 */
1508 public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5;
1509
Tyler Gunn75958422015-04-15 14:23:42 -07001510 private static final int MSG_ADD_VIDEO_CALLBACK = 1;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001511 private static final int MSG_SET_CAMERA = 2;
1512 private static final int MSG_SET_PREVIEW_SURFACE = 3;
1513 private static final int MSG_SET_DISPLAY_SURFACE = 4;
1514 private static final int MSG_SET_DEVICE_ORIENTATION = 5;
1515 private static final int MSG_SET_ZOOM = 6;
1516 private static final int MSG_SEND_SESSION_MODIFY_REQUEST = 7;
1517 private static final int MSG_SEND_SESSION_MODIFY_RESPONSE = 8;
1518 private static final int MSG_REQUEST_CAMERA_CAPABILITIES = 9;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001519 private static final int MSG_REQUEST_CONNECTION_DATA_USAGE = 10;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001520 private static final int MSG_SET_PAUSE_IMAGE = 11;
Tyler Gunn75958422015-04-15 14:23:42 -07001521 private static final int MSG_REMOVE_VIDEO_CALLBACK = 12;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001522
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001523 private static final String SESSION_EVENT_RX_PAUSE_STR = "RX_PAUSE";
1524 private static final String SESSION_EVENT_RX_RESUME_STR = "RX_RESUME";
1525 private static final String SESSION_EVENT_TX_START_STR = "TX_START";
1526 private static final String SESSION_EVENT_TX_STOP_STR = "TX_STOP";
1527 private static final String SESSION_EVENT_CAMERA_FAILURE_STR = "CAMERA_FAIL";
1528 private static final String SESSION_EVENT_CAMERA_READY_STR = "CAMERA_READY";
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001529 private static final String SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR =
1530 "CAMERA_PERMISSION_ERROR";
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001531 private static final String SESSION_EVENT_UNKNOWN_STR = "UNKNOWN";
1532
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001533 private VideoProvider.VideoProviderHandler mMessageHandler;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001534 private final VideoProvider.VideoProviderBinder mBinder;
Tyler Gunn75958422015-04-15 14:23:42 -07001535
1536 /**
1537 * Stores a list of the video callbacks, keyed by IBinder.
Tyler Gunn84f381b2015-06-12 09:26:45 -07001538 *
1539 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
1540 * load factor before resizing, 1 means we only expect a single thread to
1541 * access the map so make only a single shard
Tyler Gunn75958422015-04-15 14:23:42 -07001542 */
Tyler Gunn84f381b2015-06-12 09:26:45 -07001543 private ConcurrentHashMap<IBinder, IVideoCallback> mVideoCallbacks =
1544 new ConcurrentHashMap<IBinder, IVideoCallback>(8, 0.9f, 1);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001545
1546 /**
1547 * Default handler used to consolidate binder method calls onto a single thread.
1548 */
1549 private final class VideoProviderHandler extends Handler {
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001550 public VideoProviderHandler() {
1551 super();
1552 }
1553
1554 public VideoProviderHandler(Looper looper) {
1555 super(looper);
1556 }
1557
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001558 @Override
1559 public void handleMessage(Message msg) {
1560 switch (msg.what) {
Tyler Gunn75958422015-04-15 14:23:42 -07001561 case MSG_ADD_VIDEO_CALLBACK: {
1562 IBinder binder = (IBinder) msg.obj;
1563 IVideoCallback callback = IVideoCallback.Stub
1564 .asInterface((IBinder) msg.obj);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001565 if (callback == null) {
1566 Log.w(this, "addVideoProvider - skipped; callback is null.");
1567 break;
1568 }
1569
Tyler Gunn75958422015-04-15 14:23:42 -07001570 if (mVideoCallbacks.containsKey(binder)) {
1571 Log.i(this, "addVideoProvider - skipped; already present.");
1572 break;
1573 }
1574 mVideoCallbacks.put(binder, callback);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001575 break;
Tyler Gunn75958422015-04-15 14:23:42 -07001576 }
1577 case MSG_REMOVE_VIDEO_CALLBACK: {
1578 IBinder binder = (IBinder) msg.obj;
1579 IVideoCallback callback = IVideoCallback.Stub
1580 .asInterface((IBinder) msg.obj);
1581 if (!mVideoCallbacks.containsKey(binder)) {
1582 Log.i(this, "removeVideoProvider - skipped; not present.");
1583 break;
1584 }
1585 mVideoCallbacks.remove(binder);
1586 break;
1587 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001588 case MSG_SET_CAMERA:
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001589 {
1590 SomeArgs args = (SomeArgs) msg.obj;
1591 try {
1592 onSetCamera((String) args.arg1);
1593 onSetCamera((String) args.arg1, (String) args.arg2, args.argi1,
Tyler Gunn159f35c2017-03-02 09:28:37 -08001594 args.argi2, args.argi3);
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001595 } finally {
1596 args.recycle();
1597 }
1598 }
1599 break;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001600 case MSG_SET_PREVIEW_SURFACE:
1601 onSetPreviewSurface((Surface) msg.obj);
1602 break;
1603 case MSG_SET_DISPLAY_SURFACE:
1604 onSetDisplaySurface((Surface) msg.obj);
1605 break;
1606 case MSG_SET_DEVICE_ORIENTATION:
1607 onSetDeviceOrientation(msg.arg1);
1608 break;
1609 case MSG_SET_ZOOM:
1610 onSetZoom((Float) msg.obj);
1611 break;
Tyler Gunn45382162015-05-06 08:52:27 -07001612 case MSG_SEND_SESSION_MODIFY_REQUEST: {
1613 SomeArgs args = (SomeArgs) msg.obj;
1614 try {
1615 onSendSessionModifyRequest((VideoProfile) args.arg1,
1616 (VideoProfile) args.arg2);
1617 } finally {
1618 args.recycle();
1619 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001620 break;
Tyler Gunn45382162015-05-06 08:52:27 -07001621 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001622 case MSG_SEND_SESSION_MODIFY_RESPONSE:
1623 onSendSessionModifyResponse((VideoProfile) msg.obj);
1624 break;
1625 case MSG_REQUEST_CAMERA_CAPABILITIES:
1626 onRequestCameraCapabilities();
1627 break;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001628 case MSG_REQUEST_CONNECTION_DATA_USAGE:
1629 onRequestConnectionDataUsage();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001630 break;
1631 case MSG_SET_PAUSE_IMAGE:
Yorke Lee32f24732015-05-12 16:18:03 -07001632 onSetPauseImage((Uri) msg.obj);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001633 break;
1634 default:
1635 break;
1636 }
1637 }
1638 }
1639
1640 /**
1641 * IVideoProvider stub implementation.
1642 */
1643 private final class VideoProviderBinder extends IVideoProvider.Stub {
Tyler Gunn75958422015-04-15 14:23:42 -07001644 public void addVideoCallback(IBinder videoCallbackBinder) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001645 mMessageHandler.obtainMessage(
Tyler Gunn75958422015-04-15 14:23:42 -07001646 MSG_ADD_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget();
1647 }
1648
1649 public void removeVideoCallback(IBinder videoCallbackBinder) {
1650 mMessageHandler.obtainMessage(
1651 MSG_REMOVE_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001652 }
1653
Tyler Gunn159f35c2017-03-02 09:28:37 -08001654 public void setCamera(String cameraId, String callingPackageName,
1655 int targetSdkVersion) {
1656
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001657 SomeArgs args = SomeArgs.obtain();
1658 args.arg1 = cameraId;
1659 // Propagate the calling package; originally determined in
1660 // android.telecom.InCallService.VideoCall#setCamera(String) from the calling
1661 // process.
1662 args.arg2 = callingPackageName;
1663 // Pass along the uid and pid of the calling app; this gets lost when we put the
1664 // message onto the handler. These are required for Telecom to perform a permission
1665 // check to see if the calling app is able to use the camera.
1666 args.argi1 = Binder.getCallingUid();
1667 args.argi2 = Binder.getCallingPid();
Tyler Gunn159f35c2017-03-02 09:28:37 -08001668 // Pass along the target SDK version of the calling InCallService. This is used to
1669 // maintain backwards compatibility of the API for older callers.
1670 args.argi3 = targetSdkVersion;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001671 mMessageHandler.obtainMessage(MSG_SET_CAMERA, args).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001672 }
1673
1674 public void setPreviewSurface(Surface surface) {
1675 mMessageHandler.obtainMessage(MSG_SET_PREVIEW_SURFACE, surface).sendToTarget();
1676 }
1677
1678 public void setDisplaySurface(Surface surface) {
1679 mMessageHandler.obtainMessage(MSG_SET_DISPLAY_SURFACE, surface).sendToTarget();
1680 }
1681
1682 public void setDeviceOrientation(int rotation) {
Rekha Kumar07366812015-03-24 16:42:31 -07001683 mMessageHandler.obtainMessage(
1684 MSG_SET_DEVICE_ORIENTATION, rotation, 0).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001685 }
1686
1687 public void setZoom(float value) {
1688 mMessageHandler.obtainMessage(MSG_SET_ZOOM, value).sendToTarget();
1689 }
1690
Tyler Gunn45382162015-05-06 08:52:27 -07001691 public void sendSessionModifyRequest(VideoProfile fromProfile, VideoProfile toProfile) {
1692 SomeArgs args = SomeArgs.obtain();
1693 args.arg1 = fromProfile;
1694 args.arg2 = toProfile;
1695 mMessageHandler.obtainMessage(MSG_SEND_SESSION_MODIFY_REQUEST, args).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001696 }
1697
1698 public void sendSessionModifyResponse(VideoProfile responseProfile) {
1699 mMessageHandler.obtainMessage(
1700 MSG_SEND_SESSION_MODIFY_RESPONSE, responseProfile).sendToTarget();
1701 }
1702
1703 public void requestCameraCapabilities() {
1704 mMessageHandler.obtainMessage(MSG_REQUEST_CAMERA_CAPABILITIES).sendToTarget();
1705 }
1706
1707 public void requestCallDataUsage() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001708 mMessageHandler.obtainMessage(MSG_REQUEST_CONNECTION_DATA_USAGE).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001709 }
1710
Yorke Lee32f24732015-05-12 16:18:03 -07001711 public void setPauseImage(Uri uri) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001712 mMessageHandler.obtainMessage(MSG_SET_PAUSE_IMAGE, uri).sendToTarget();
1713 }
1714 }
1715
1716 public VideoProvider() {
1717 mBinder = new VideoProvider.VideoProviderBinder();
Tyler Gunn84f381b2015-06-12 09:26:45 -07001718 mMessageHandler = new VideoProvider.VideoProviderHandler(Looper.getMainLooper());
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001719 }
1720
1721 /**
1722 * Creates an instance of the {@link VideoProvider}, specifying the looper to use.
1723 *
1724 * @param looper The looper.
1725 * @hide
1726 */
Mathew Inwood42346d12018-08-01 11:33:05 +01001727 @UnsupportedAppUsage
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001728 public VideoProvider(Looper looper) {
1729 mBinder = new VideoProvider.VideoProviderBinder();
1730 mMessageHandler = new VideoProvider.VideoProviderHandler(looper);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001731 }
1732
1733 /**
1734 * Returns binder object which can be used across IPC methods.
1735 * @hide
1736 */
1737 public final IVideoProvider getInterface() {
1738 return mBinder;
1739 }
1740
1741 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001742 * Sets the camera to be used for the outgoing video.
1743 * <p>
1744 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1745 * camera via
1746 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1747 * <p>
1748 * Sent from the {@link InCallService} via
1749 * {@link InCallService.VideoCall#setCamera(String)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001750 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001751 * @param cameraId The id of the camera (use ids as reported by
1752 * {@link CameraManager#getCameraIdList()}).
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001753 */
1754 public abstract void onSetCamera(String cameraId);
1755
1756 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001757 * Sets the camera to be used for the outgoing video.
1758 * <p>
1759 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1760 * camera via
1761 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1762 * <p>
1763 * This prototype is used internally to ensure that the calling package name, UID and PID
1764 * are sent to Telecom so that can perform a camera permission check on the caller.
1765 * <p>
1766 * Sent from the {@link InCallService} via
1767 * {@link InCallService.VideoCall#setCamera(String)}.
1768 *
1769 * @param cameraId The id of the camera (use ids as reported by
1770 * {@link CameraManager#getCameraIdList()}).
1771 * @param callingPackageName The AppOpps package name of the caller.
1772 * @param callingUid The UID of the caller.
1773 * @param callingPid The PID of the caller.
Tyler Gunn159f35c2017-03-02 09:28:37 -08001774 * @param targetSdkVersion The target SDK version of the caller.
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001775 * @hide
1776 */
1777 public void onSetCamera(String cameraId, String callingPackageName, int callingUid,
Tyler Gunn159f35c2017-03-02 09:28:37 -08001778 int callingPid, int targetSdkVersion) {}
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001779
1780 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001781 * Sets the surface to be used for displaying a preview of what the user's camera is
1782 * currently capturing. When video transmission is enabled, this is the video signal which
1783 * is sent to the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001784 * <p>
1785 * Sent from the {@link InCallService} via
1786 * {@link InCallService.VideoCall#setPreviewSurface(Surface)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001787 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001788 * @param surface The {@link Surface}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001789 */
1790 public abstract void onSetPreviewSurface(Surface surface);
1791
1792 /**
1793 * Sets the surface to be used for displaying the video received from the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001794 * <p>
1795 * Sent from the {@link InCallService} via
1796 * {@link InCallService.VideoCall#setDisplaySurface(Surface)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001797 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001798 * @param surface The {@link Surface}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001799 */
1800 public abstract void onSetDisplaySurface(Surface surface);
1801
1802 /**
1803 * Sets the device orientation, in degrees. Assumes that a standard portrait orientation of
1804 * the device is 0 degrees.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001805 * <p>
1806 * Sent from the {@link InCallService} via
1807 * {@link InCallService.VideoCall#setDeviceOrientation(int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001808 *
1809 * @param rotation The device orientation, in degrees.
1810 */
1811 public abstract void onSetDeviceOrientation(int rotation);
1812
1813 /**
Tyler Gunnc603b462021-06-14 17:24:40 -07001814 * Sets the camera zoom ratio.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001815 * <p>
1816 * Sent from the {@link InCallService} via {@link InCallService.VideoCall#setZoom(float)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001817 *
Tyler Gunnc603b462021-06-14 17:24:40 -07001818 * @param value The camera zoom ratio; for the current camera, should be a value in the
1819 * range defined by
1820 * {@link android.hardware.camera2.CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001821 */
1822 public abstract void onSetZoom(float value);
1823
1824 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001825 * Issues a request to modify the properties of the current video session.
1826 * <p>
1827 * Example scenarios include: requesting an audio-only call to be upgraded to a
1828 * bi-directional video call, turning on or off the user's camera, sending a pause signal
1829 * when the {@link InCallService} is no longer the foreground application.
1830 * <p>
1831 * If the {@link VideoProvider} determines a request to be invalid, it should call
1832 * {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)} to report the
1833 * invalid request back to the {@link InCallService}.
1834 * <p>
1835 * Where a request requires confirmation from the user of the peer device, the
1836 * {@link VideoProvider} must communicate the request to the peer device and handle the
1837 * user's response. {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)}
1838 * is used to inform the {@link InCallService} of the result of the request.
1839 * <p>
1840 * Sent from the {@link InCallService} via
1841 * {@link InCallService.VideoCall#sendSessionModifyRequest(VideoProfile)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001842 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001843 * @param fromProfile The video profile prior to the request.
1844 * @param toProfile The video profile with the requested changes made.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001845 */
Tyler Gunn45382162015-05-06 08:52:27 -07001846 public abstract void onSendSessionModifyRequest(VideoProfile fromProfile,
1847 VideoProfile toProfile);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001848
Tyler Gunnb702ef82015-05-29 11:51:53 -07001849 /**
1850 * Provides a response to a request to change the current video session properties.
1851 * <p>
1852 * For example, if the peer requests and upgrade from an audio-only call to a bi-directional
1853 * video call, could decline the request and keep the call as audio-only.
1854 * In such a scenario, the {@code responseProfile} would have a video state of
1855 * {@link VideoProfile#STATE_AUDIO_ONLY}. If the user had decided to accept the request,
1856 * the video state would be {@link VideoProfile#STATE_BIDIRECTIONAL}.
1857 * <p>
1858 * Sent from the {@link InCallService} via
1859 * {@link InCallService.VideoCall#sendSessionModifyResponse(VideoProfile)} in response to
1860 * a {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)}
1861 * callback.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001862 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001863 * @param responseProfile The response video profile.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001864 */
1865 public abstract void onSendSessionModifyResponse(VideoProfile responseProfile);
1866
1867 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001868 * Issues a request to the {@link VideoProvider} to retrieve the camera capabilities.
1869 * <p>
1870 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1871 * camera via
1872 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1873 * <p>
1874 * Sent from the {@link InCallService} via
1875 * {@link InCallService.VideoCall#requestCameraCapabilities()}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001876 */
1877 public abstract void onRequestCameraCapabilities();
1878
1879 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001880 * Issues a request to the {@link VideoProvider} to retrieve the current data usage for the
1881 * video component of the current {@link Connection}.
1882 * <p>
1883 * The {@link VideoProvider} should respond by communicating current data usage, in bytes,
1884 * via {@link VideoProvider#setCallDataUsage(long)}.
1885 * <p>
1886 * Sent from the {@link InCallService} via
1887 * {@link InCallService.VideoCall#requestCallDataUsage()}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001888 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001889 public abstract void onRequestConnectionDataUsage();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001890
1891 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001892 * Provides the {@link VideoProvider} with the {@link Uri} of an image to be displayed to
1893 * the peer device when the video signal is paused.
1894 * <p>
1895 * Sent from the {@link InCallService} via
1896 * {@link InCallService.VideoCall#setPauseImage(Uri)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001897 *
1898 * @param uri URI of image to display.
1899 */
Yorke Lee32f24732015-05-12 16:18:03 -07001900 public abstract void onSetPauseImage(Uri uri);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001901
1902 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001903 * Used to inform listening {@link InCallService} implementations when the
1904 * {@link VideoProvider} receives a session modification request.
1905 * <p>
1906 * Received by the {@link InCallService} via
1907 * {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)},
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001908 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001909 * @param videoProfile The requested video profile.
1910 * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001911 */
1912 public void receiveSessionModifyRequest(VideoProfile videoProfile) {
Tyler Gunn75958422015-04-15 14:23:42 -07001913 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001914 for (IVideoCallback callback : mVideoCallbacks.values()) {
1915 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001916 callback.receiveSessionModifyRequest(videoProfile);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001917 } catch (RemoteException ignored) {
1918 Log.w(this, "receiveSessionModifyRequest callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001919 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001920 }
1921 }
1922 }
1923
1924 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001925 * Used to inform listening {@link InCallService} implementations when the
1926 * {@link VideoProvider} receives a response to a session modification request.
1927 * <p>
1928 * Received by the {@link InCallService} via
1929 * {@link InCallService.VideoCall.Callback#onSessionModifyResponseReceived(int,
1930 * VideoProfile, VideoProfile)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001931 *
1932 * @param status Status of the session modify request. Valid values are
1933 * {@link VideoProvider#SESSION_MODIFY_REQUEST_SUCCESS},
1934 * {@link VideoProvider#SESSION_MODIFY_REQUEST_FAIL},
Tyler Gunnb702ef82015-05-29 11:51:53 -07001935 * {@link VideoProvider#SESSION_MODIFY_REQUEST_INVALID},
1936 * {@link VideoProvider#SESSION_MODIFY_REQUEST_TIMED_OUT},
1937 * {@link VideoProvider#SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE}
1938 * @param requestedProfile The original request which was sent to the peer device.
1939 * @param responseProfile The actual profile changes agreed to by the peer device.
1940 * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001941 */
1942 public void receiveSessionModifyResponse(int status,
1943 VideoProfile requestedProfile, VideoProfile responseProfile) {
Tyler Gunn75958422015-04-15 14:23:42 -07001944 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001945 for (IVideoCallback callback : mVideoCallbacks.values()) {
1946 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001947 callback.receiveSessionModifyResponse(status, requestedProfile,
1948 responseProfile);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001949 } catch (RemoteException ignored) {
1950 Log.w(this, "receiveSessionModifyResponse callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001951 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001952 }
1953 }
1954 }
1955
1956 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001957 * Used to inform listening {@link InCallService} implementations when the
1958 * {@link VideoProvider} reports a call session event.
1959 * <p>
1960 * Received by the {@link InCallService} via
1961 * {@link InCallService.VideoCall.Callback#onCallSessionEvent(int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001962 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001963 * @param event The event. Valid values are: {@link VideoProvider#SESSION_EVENT_RX_PAUSE},
1964 * {@link VideoProvider#SESSION_EVENT_RX_RESUME},
1965 * {@link VideoProvider#SESSION_EVENT_TX_START},
1966 * {@link VideoProvider#SESSION_EVENT_TX_STOP},
1967 * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE},
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001968 * {@link VideoProvider#SESSION_EVENT_CAMERA_READY},
1969 * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001970 */
1971 public void handleCallSessionEvent(int event) {
Tyler Gunn75958422015-04-15 14:23:42 -07001972 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001973 for (IVideoCallback callback : mVideoCallbacks.values()) {
1974 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001975 callback.handleCallSessionEvent(event);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001976 } catch (RemoteException ignored) {
1977 Log.w(this, "handleCallSessionEvent callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001978 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001979 }
1980 }
1981 }
1982
1983 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001984 * Used to inform listening {@link InCallService} implementations when the dimensions of the
1985 * peer's video have changed.
1986 * <p>
1987 * This could occur if, for example, the peer rotates their device, changing the aspect
1988 * ratio of the video, or if the user switches between the back and front cameras.
1989 * <p>
1990 * Received by the {@link InCallService} via
1991 * {@link InCallService.VideoCall.Callback#onPeerDimensionsChanged(int, int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001992 *
1993 * @param width The updated peer video width.
1994 * @param height The updated peer video height.
1995 */
1996 public void changePeerDimensions(int width, int height) {
Tyler Gunn75958422015-04-15 14:23:42 -07001997 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001998 for (IVideoCallback callback : mVideoCallbacks.values()) {
1999 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002000 callback.changePeerDimensions(width, height);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002001 } catch (RemoteException ignored) {
2002 Log.w(this, "changePeerDimensions callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002003 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002004 }
2005 }
2006 }
2007
2008 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002009 * Used to inform listening {@link InCallService} implementations when the data usage of the
2010 * video associated with the current {@link Connection} has changed.
2011 * <p>
2012 * This could be in response to a preview request via
2013 * {@link #onRequestConnectionDataUsage()}, or as a periodic update by the
Tyler Gunn295f5d72015-06-04 11:08:54 -07002014 * {@link VideoProvider}. Where periodic updates of data usage are provided, they should be
2015 * 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 -07002016 * <p>
2017 * Received by the {@link InCallService} via
2018 * {@link InCallService.VideoCall.Callback#onCallDataUsageChanged(long)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002019 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002020 * @param dataUsage The updated data usage (in bytes). Reported as the cumulative bytes
2021 * used since the start of the call.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002022 */
Yorke Lee32f24732015-05-12 16:18:03 -07002023 public void setCallDataUsage(long dataUsage) {
Tyler Gunn75958422015-04-15 14:23:42 -07002024 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002025 for (IVideoCallback callback : mVideoCallbacks.values()) {
2026 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002027 callback.changeCallDataUsage(dataUsage);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002028 } catch (RemoteException ignored) {
2029 Log.w(this, "setCallDataUsage callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002030 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002031 }
2032 }
2033 }
2034
2035 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002036 * @see #setCallDataUsage(long)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002037 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002038 * @param dataUsage The updated data usage (in byes).
Yorke Lee32f24732015-05-12 16:18:03 -07002039 * @deprecated - Use {@link #setCallDataUsage(long)} instead.
2040 * @hide
2041 */
2042 public void changeCallDataUsage(long dataUsage) {
2043 setCallDataUsage(dataUsage);
2044 }
2045
2046 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002047 * Used to inform listening {@link InCallService} implementations when the capabilities of
2048 * the current camera have changed.
2049 * <p>
2050 * The {@link VideoProvider} should call this in response to
2051 * {@link VideoProvider#onRequestCameraCapabilities()}, or when the current camera is
2052 * changed via {@link VideoProvider#onSetCamera(String)}.
2053 * <p>
2054 * Received by the {@link InCallService} via
2055 * {@link InCallService.VideoCall.Callback#onCameraCapabilitiesChanged(
2056 * VideoProfile.CameraCapabilities)}.
Yorke Lee32f24732015-05-12 16:18:03 -07002057 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002058 * @param cameraCapabilities The new camera capabilities.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002059 */
Yorke Lee400470f2015-05-12 13:31:25 -07002060 public void changeCameraCapabilities(VideoProfile.CameraCapabilities cameraCapabilities) {
Tyler Gunn75958422015-04-15 14:23:42 -07002061 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002062 for (IVideoCallback callback : mVideoCallbacks.values()) {
2063 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002064 callback.changeCameraCapabilities(cameraCapabilities);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002065 } catch (RemoteException ignored) {
2066 Log.w(this, "changeCameraCapabilities callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002067 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002068 }
2069 }
2070 }
Rekha Kumar07366812015-03-24 16:42:31 -07002071
2072 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002073 * Used to inform listening {@link InCallService} implementations when the video quality
2074 * of the call has changed.
2075 * <p>
2076 * Received by the {@link InCallService} via
2077 * {@link InCallService.VideoCall.Callback#onVideoQualityChanged(int)}.
Rekha Kumar07366812015-03-24 16:42:31 -07002078 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002079 * @param videoQuality The updated video quality. Valid values:
2080 * {@link VideoProfile#QUALITY_HIGH},
2081 * {@link VideoProfile#QUALITY_MEDIUM},
2082 * {@link VideoProfile#QUALITY_LOW},
2083 * {@link VideoProfile#QUALITY_DEFAULT}.
Rekha Kumar07366812015-03-24 16:42:31 -07002084 */
2085 public void changeVideoQuality(int videoQuality) {
Tyler Gunn75958422015-04-15 14:23:42 -07002086 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002087 for (IVideoCallback callback : mVideoCallbacks.values()) {
2088 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002089 callback.changeVideoQuality(videoQuality);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002090 } catch (RemoteException ignored) {
2091 Log.w(this, "changeVideoQuality callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002092 }
Rekha Kumar07366812015-03-24 16:42:31 -07002093 }
2094 }
2095 }
Tyler Gunn6f657ee2016-09-02 09:55:25 -07002096
2097 /**
2098 * Returns a string representation of a call session event.
2099 *
2100 * @param event A call session event passed to {@link #handleCallSessionEvent(int)}.
2101 * @return String representation of the call session event.
2102 * @hide
2103 */
2104 public static String sessionEventToString(int event) {
2105 switch (event) {
2106 case SESSION_EVENT_CAMERA_FAILURE:
2107 return SESSION_EVENT_CAMERA_FAILURE_STR;
2108 case SESSION_EVENT_CAMERA_READY:
2109 return SESSION_EVENT_CAMERA_READY_STR;
2110 case SESSION_EVENT_RX_PAUSE:
2111 return SESSION_EVENT_RX_PAUSE_STR;
2112 case SESSION_EVENT_RX_RESUME:
2113 return SESSION_EVENT_RX_RESUME_STR;
2114 case SESSION_EVENT_TX_START:
2115 return SESSION_EVENT_TX_START_STR;
2116 case SESSION_EVENT_TX_STOP:
2117 return SESSION_EVENT_TX_STOP_STR;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08002118 case SESSION_EVENT_CAMERA_PERMISSION_ERROR:
2119 return SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR;
Tyler Gunn6f657ee2016-09-02 09:55:25 -07002120 default:
2121 return SESSION_EVENT_UNKNOWN_STR + " " + event;
2122 }
2123 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002124 }
2125
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002126 private final Listener mConnectionDeathListener = new Listener() {
2127 @Override
2128 public void onDestroyed(Connection c) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002129 if (mConferenceables.remove(c)) {
2130 fireOnConferenceableConnectionsChanged();
2131 }
2132 }
2133 };
2134
2135 private final Conference.Listener mConferenceDeathListener = new Conference.Listener() {
2136 @Override
2137 public void onDestroyed(Conference c) {
2138 if (mConferenceables.remove(c)) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002139 fireOnConferenceableConnectionsChanged();
2140 }
2141 }
2142 };
2143
Jay Shrauner229e3822014-08-15 09:23:07 -07002144 /**
2145 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
2146 * load factor before resizing, 1 means we only expect a single thread to
2147 * access the map so make only a single shard
2148 */
2149 private final Set<Listener> mListeners = Collections.newSetFromMap(
2150 new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1));
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002151 private final List<Conferenceable> mConferenceables = new ArrayList<>();
2152 private final List<Conferenceable> mUnmodifiableConferenceables =
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002153 Collections.unmodifiableList(mConferenceables);
Santos Cordonb6939982014-06-04 20:20:58 -07002154
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002155 // The internal telecom call ID associated with this connection.
2156 private String mTelecomCallId;
Pengquan Meng70c9885332017-10-02 18:09:03 -07002157 // The PhoneAccountHandle associated with this connection.
2158 private PhoneAccountHandle mPhoneAccountHandle;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002159 private int mState = STATE_NEW;
Yorke Lee4af59352015-05-13 14:14:54 -07002160 private CallAudioState mCallAudioState;
Andrew Lee100e2932014-09-08 15:34:24 -07002161 private Uri mAddress;
2162 private int mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -07002163 private String mCallerDisplayName;
2164 private int mCallerDisplayNamePresentation;
Andrew Lee100e2932014-09-08 15:34:24 -07002165 private boolean mRingbackRequested = false;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002166 private int mConnectionCapabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -07002167 private int mConnectionProperties;
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002168 private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002169 private VideoProvider mVideoProvider;
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002170 private boolean mAudioModeIsVoip;
Roshan Piuse927ec02015-07-15 15:47:21 -07002171 private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002172 private long mConnectElapsedTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002173 private StatusHints mStatusHints;
Tyler Gunnaa07df82014-07-17 07:50:22 -07002174 private int mVideoState;
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002175 private DisconnectCause mDisconnectCause;
Santos Cordon823fd3c2014-08-07 18:35:18 -07002176 private Conference mConference;
2177 private ConnectionService mConnectionService;
Santos Cordon6b7f9552015-05-27 17:21:45 -07002178 private Bundle mExtras;
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002179 private final Object mExtrasLock = new Object();
Tyler Gunn6986a632019-06-25 13:45:32 -07002180 /**
2181 * The direction of the connection; used where an existing connection is created and we need to
2182 * communicate to Telecom whether its incoming or outgoing.
2183 */
2184 private @Call.Details.CallDirection int mCallDirection = Call.Details.DIRECTION_UNKNOWN;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002185
2186 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002187 * Tracks the key set for the extras bundle provided on the last invocation of
2188 * {@link #setExtras(Bundle)}. Used so that on subsequent invocations we can remove any extras
2189 * keys which were set previously but are no longer present in the replacement Bundle.
2190 */
2191 private Set<String> mPreviousExtraKeys;
2192
2193 /**
Tyler Gunnd57d76c2019-09-24 14:53:23 -07002194 * The verification status for an incoming call's phone number.
2195 */
2196 private @VerificationStatus int mCallerNumberVerificationStatus;
2197
2198
2199 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002200 * Create a new Connection.
2201 */
Santos Cordonf2951102014-07-20 19:06:29 -07002202 public Connection() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002203
2204 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002205 * Returns the Telecom internal call ID associated with this connection. Should only be used
2206 * for debugging and tracing purposes.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002207 * <p>
2208 * Note: Access to the Telecom internal call ID is used for logging purposes only; this API is
2209 * provided to facilitate debugging of the Telephony stack only.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002210 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07002211 * @return The Telecom call ID, or {@code null} if it was not set.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002212 * @hide
2213 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002214 @SystemApi
2215 public final @Nullable String getTelecomCallId() {
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002216 return mTelecomCallId;
2217 }
2218
2219 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002220 * @return The address (e.g., phone number) to which this Connection is currently communicating.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002221 */
Andrew Lee100e2932014-09-08 15:34:24 -07002222 public final Uri getAddress() {
2223 return mAddress;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002224 }
2225
2226 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002227 * @return The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002228 * See {@link TelecomManager} for valid values.
Sailesh Nepal61203862014-07-11 14:50:13 -07002229 */
Andrew Lee100e2932014-09-08 15:34:24 -07002230 public final int getAddressPresentation() {
2231 return mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -07002232 }
2233
2234 /**
2235 * @return The caller display name (CNAP).
2236 */
2237 public final String getCallerDisplayName() {
2238 return mCallerDisplayName;
2239 }
2240
2241 /**
Nancy Chen9d568c02014-09-08 14:17:59 -07002242 * @return The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002243 * See {@link TelecomManager} for valid values.
Sailesh Nepal61203862014-07-11 14:50:13 -07002244 */
2245 public final int getCallerDisplayNamePresentation() {
2246 return mCallerDisplayNamePresentation;
2247 }
2248
2249 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002250 * @return The state of this Connection.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002251 */
2252 public final int getState() {
2253 return mState;
2254 }
2255
2256 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002257 * Returns the video state of the connection.
Yorke Lee32f24732015-05-12 16:18:03 -07002258 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
2259 * {@link VideoProfile#STATE_BIDIRECTIONAL},
2260 * {@link VideoProfile#STATE_TX_ENABLED},
2261 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002262 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002263 * @return The video state of the connection.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002264 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002265 public final @VideoProfile.VideoState int getVideoState() {
Tyler Gunnaa07df82014-07-17 07:50:22 -07002266 return mVideoState;
2267 }
2268
2269 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002270 * @return The audio state of the connection, describing how its audio is currently
Ihab Awad542e0ea2014-05-16 10:22:16 -07002271 * being routed by the system. This is {@code null} if this Connection
2272 * does not directly know about its audio state.
Yorke Lee4af59352015-05-13 14:14:54 -07002273 * @deprecated Use {@link #getCallAudioState()} instead.
2274 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -07002275 */
Yorke Lee4af59352015-05-13 14:14:54 -07002276 @SystemApi
2277 @Deprecated
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002278 public final AudioState getAudioState() {
Sailesh Nepal000d38a2015-06-21 10:25:13 -07002279 if (mCallAudioState == null) {
2280 return null;
2281 }
Yorke Lee4af59352015-05-13 14:14:54 -07002282 return new AudioState(mCallAudioState);
2283 }
2284
2285 /**
2286 * @return The audio state of the connection, describing how its audio is currently
2287 * being routed by the system. This is {@code null} if this Connection
2288 * does not directly know about its audio state.
2289 */
2290 public final CallAudioState getCallAudioState() {
2291 return mCallAudioState;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002292 }
2293
2294 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002295 * @return The conference that this connection is a part of. Null if it is not part of any
2296 * conference.
2297 */
2298 public final Conference getConference() {
2299 return mConference;
2300 }
2301
2302 /**
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002303 * Returns whether this connection is requesting that the system play a ringback tone
2304 * on its behalf.
2305 */
Andrew Lee100e2932014-09-08 15:34:24 -07002306 public final boolean isRingbackRequested() {
2307 return mRingbackRequested;
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002308 }
2309
2310 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002311 * @return True if the connection's audio mode is VOIP.
2312 */
2313 public final boolean getAudioModeIsVoip() {
2314 return mAudioModeIsVoip;
2315 }
2316
2317 /**
Roshan Piuse927ec02015-07-15 15:47:21 -07002318 * Retrieves the connection start time of the {@code Connnection}, if specified. A value of
2319 * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
2320 * start time of the conference.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002321 * <p>
2322 * Note: This is an implementation detail specific to IMS conference calls over a mobile
2323 * network.
Roshan Piuse927ec02015-07-15 15:47:21 -07002324 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07002325 * @return The time at which the {@code Connnection} was connected. Will be a value as retrieved
2326 * from {@link System#currentTimeMillis()}.
Roshan Piuse927ec02015-07-15 15:47:21 -07002327 *
2328 * @hide
2329 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002330 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002331 public final @IntRange(from = 0) long getConnectTimeMillis() {
Roshan Piuse927ec02015-07-15 15:47:21 -07002332 return mConnectTimeMillis;
2333 }
2334
2335 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002336 * Retrieves the connection start time of the {@link Connection}, if specified. A value of
2337 * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
Tyler Gunnc9503d62020-01-27 10:30:51 -08002338 * start time of the connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002339 * <p>
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002340 * Based on the value of {@link SystemClock#elapsedRealtime()}, which ensures that wall-clock
2341 * changes do not impact the call duration.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002342 * <p>
2343 * Used internally in Telephony when migrating conference participant data for IMS conferences.
Tyler Gunnc9503d62020-01-27 10:30:51 -08002344 * <p>
2345 * The value returned is the same one set using
2346 * {@link #setConnectionStartElapsedRealtimeMillis(long)}. This value is never updated from
2347 * the Telecom framework, so no permission enforcement occurs when retrieving the value with
2348 * this method.
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002349 *
2350 * @return The time at which the {@link Connection} was connected.
2351 *
2352 * @hide
2353 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002354 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002355 public final @ElapsedRealtimeLong long getConnectionStartElapsedRealtimeMillis() {
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002356 return mConnectElapsedTimeMillis;
2357 }
2358
2359 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002360 * @return The status hints for this connection.
2361 */
2362 public final StatusHints getStatusHints() {
2363 return mStatusHints;
2364 }
2365
2366 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002367 * Returns the extras associated with this connection.
Tyler Gunn2cbe2b52016-05-04 15:48:10 +00002368 * <p>
2369 * Extras should be updated using {@link #putExtras(Bundle)}.
2370 * <p>
2371 * Telecom or an {@link InCallService} can also update the extras via
2372 * {@link android.telecom.Call#putExtras(Bundle)}, and
2373 * {@link Call#removeExtras(List)}.
2374 * <p>
2375 * The connection is notified of changes to the extras made by Telecom or an
2376 * {@link InCallService} by {@link #onExtrasChanged(Bundle)}.
Tyler Gunndee56a82016-03-23 16:06:34 -07002377 *
Santos Cordon6b7f9552015-05-27 17:21:45 -07002378 * @return The extras associated with this connection.
2379 */
2380 public final Bundle getExtras() {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002381 Bundle extras = null;
2382 synchronized (mExtrasLock) {
2383 if (mExtras != null) {
2384 extras = new Bundle(mExtras);
2385 }
2386 }
2387 return extras;
Santos Cordon6b7f9552015-05-27 17:21:45 -07002388 }
2389
2390 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002391 * Assign a listener to be notified of state changes.
2392 *
2393 * @param l A listener.
2394 * @return This Connection.
2395 *
2396 * @hide
2397 */
Tyler Gunn633e4c32019-10-24 15:40:48 -07002398 final Connection addConnectionListener(Listener l) {
Santos Cordond34e5712014-08-05 18:54:03 +00002399 mListeners.add(l);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002400 return this;
2401 }
2402
2403 /**
2404 * Remove a previously assigned listener that was being notified of state changes.
2405 *
2406 * @param l A Listener.
2407 * @return This Connection.
2408 *
2409 * @hide
2410 */
Tyler Gunn633e4c32019-10-24 15:40:48 -07002411 final Connection removeConnectionListener(Listener l) {
Jay Shrauner229e3822014-08-15 09:23:07 -07002412 if (l != null) {
2413 mListeners.remove(l);
2414 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002415 return this;
2416 }
2417
2418 /**
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002419 * @return The {@link DisconnectCause} for this connection.
Evan Charltonbf11f982014-07-20 22:06:28 -07002420 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002421 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002422 return mDisconnectCause;
Evan Charltonbf11f982014-07-20 22:06:28 -07002423 }
2424
2425 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002426 * Sets the telecom call ID associated with this Connection. The Telecom Call ID should be used
2427 * ONLY for debugging purposes.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002428 * <p>
2429 * Note: Access to the Telecom internal call ID is used for logging purposes only; this API is
2430 * provided to facilitate debugging of the Telephony stack only. Changing the ID via this
2431 * method does NOT change any functionality in Telephony or Telecom and impacts only logging.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002432 *
2433 * @param callId The telecom call ID.
2434 * @hide
2435 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002436 @SystemApi
2437 public void setTelecomCallId(@NonNull String callId) {
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002438 mTelecomCallId = callId;
2439 }
2440
2441 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002442 * Inform this Connection that the state of its audio output has been changed externally.
2443 *
2444 * @param state The new audio state.
Sailesh Nepal400cc482014-06-26 12:04:00 -07002445 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -07002446 */
Yorke Lee4af59352015-05-13 14:14:54 -07002447 final void setCallAudioState(CallAudioState state) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002448 checkImmutable();
Ihab Awad60ac30b2014-05-20 22:32:12 -07002449 Log.d(this, "setAudioState %s", state);
Yorke Lee4af59352015-05-13 14:14:54 -07002450 mCallAudioState = state;
2451 onAudioStateChanged(getAudioState());
2452 onCallAudioStateChanged(state);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002453 }
2454
2455 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002456 * @param state An integer value of a {@code STATE_*} constant.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002457 * @return A string representation of the value.
2458 */
2459 public static String stateToString(int state) {
2460 switch (state) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002461 case STATE_INITIALIZING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002462 return "INITIALIZING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002463 case STATE_NEW:
Yorke Leee911c8d2015-07-14 11:39:36 -07002464 return "NEW";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002465 case STATE_RINGING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002466 return "RINGING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002467 case STATE_DIALING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002468 return "DIALING";
Tyler Gunnc96b5e02016-07-07 22:53:57 -07002469 case STATE_PULLING_CALL:
2470 return "PULLING_CALL";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002471 case STATE_ACTIVE:
Yorke Leee911c8d2015-07-14 11:39:36 -07002472 return "ACTIVE";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002473 case STATE_HOLDING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002474 return "HOLDING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002475 case STATE_DISCONNECTED:
Ihab Awad542e0ea2014-05-16 10:22:16 -07002476 return "DISCONNECTED";
2477 default:
Ihab Awad60ac30b2014-05-20 22:32:12 -07002478 Log.wtf(Connection.class, "Unknown state %d", state);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002479 return "UNKNOWN";
2480 }
2481 }
2482
2483 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002484 * Returns the connection's capabilities, as a bit mask of the {@code CAPABILITY_*} constants.
Ihab Awad52a28f62014-06-18 10:26:34 -07002485 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002486 public final int getConnectionCapabilities() {
2487 return mConnectionCapabilities;
Ihab Awad52a28f62014-06-18 10:26:34 -07002488 }
2489
2490 /**
Tyler Gunn720c6642016-03-22 09:02:47 -07002491 * Returns the connection's properties, as a bit mask of the {@code PROPERTY_*} constants.
2492 */
2493 public final int getConnectionProperties() {
2494 return mConnectionProperties;
2495 }
2496
2497 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002498 * Returns the connection's supported audio routes.
2499 *
2500 * @hide
2501 */
2502 public final int getSupportedAudioRoutes() {
2503 return mSupportedAudioRoutes;
2504 }
2505
2506 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002507 * Sets the value of the {@link #getAddress()} property.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002508 *
Andrew Lee100e2932014-09-08 15:34:24 -07002509 * @param address The new address.
2510 * @param presentation The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002511 * See {@link TelecomManager} for valid values.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002512 */
Andrew Lee100e2932014-09-08 15:34:24 -07002513 public final void setAddress(Uri address, int presentation) {
2514 Log.d(this, "setAddress %s", address);
2515 mAddress = address;
2516 mAddressPresentation = presentation;
Santos Cordond34e5712014-08-05 18:54:03 +00002517 for (Listener l : mListeners) {
Andrew Lee100e2932014-09-08 15:34:24 -07002518 l.onAddressChanged(this, address, presentation);
Santos Cordond34e5712014-08-05 18:54:03 +00002519 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002520 }
2521
2522 /**
Sailesh Nepal61203862014-07-11 14:50:13 -07002523 * Sets the caller display name (CNAP).
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002524 *
Sailesh Nepal61203862014-07-11 14:50:13 -07002525 * @param callerDisplayName The new display name.
Nancy Chen9d568c02014-09-08 14:17:59 -07002526 * @param presentation The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002527 * See {@link TelecomManager} for valid values.
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002528 */
Sailesh Nepal61203862014-07-11 14:50:13 -07002529 public final void setCallerDisplayName(String callerDisplayName, int presentation) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002530 checkImmutable();
Sailesh Nepal61203862014-07-11 14:50:13 -07002531 Log.d(this, "setCallerDisplayName %s", callerDisplayName);
Santos Cordond34e5712014-08-05 18:54:03 +00002532 mCallerDisplayName = callerDisplayName;
2533 mCallerDisplayNamePresentation = presentation;
2534 for (Listener l : mListeners) {
2535 l.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
2536 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002537 }
2538
2539 /**
Tyler Gunnaa07df82014-07-17 07:50:22 -07002540 * Set the video state for the connection.
Yorke Lee32f24732015-05-12 16:18:03 -07002541 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
2542 * {@link VideoProfile#STATE_BIDIRECTIONAL},
2543 * {@link VideoProfile#STATE_TX_ENABLED},
2544 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002545 *
2546 * @param videoState The new video state.
2547 */
2548 public final void setVideoState(int videoState) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002549 checkImmutable();
Tyler Gunnaa07df82014-07-17 07:50:22 -07002550 Log.d(this, "setVideoState %d", videoState);
Santos Cordond34e5712014-08-05 18:54:03 +00002551 mVideoState = videoState;
2552 for (Listener l : mListeners) {
2553 l.onVideoStateChanged(this, mVideoState);
2554 }
Tyler Gunnaa07df82014-07-17 07:50:22 -07002555 }
2556
2557 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002558 * Sets state to active (e.g., an ongoing connection where two or more parties can actively
Ihab Awad542e0ea2014-05-16 10:22:16 -07002559 * communicate).
2560 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002561 public final void setActive() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002562 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002563 setRingbackRequested(false);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002564 setState(STATE_ACTIVE);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002565 }
2566
2567 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002568 * Sets state to ringing (e.g., an inbound ringing connection).
Ihab Awad542e0ea2014-05-16 10:22:16 -07002569 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002570 public final void setRinging() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002571 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002572 setState(STATE_RINGING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002573 }
2574
2575 /**
Evan Charltonbf11f982014-07-20 22:06:28 -07002576 * Sets state to initializing (this Connection is not yet ready to be used).
2577 */
2578 public final void setInitializing() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002579 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002580 setState(STATE_INITIALIZING);
Evan Charltonbf11f982014-07-20 22:06:28 -07002581 }
2582
2583 /**
2584 * Sets state to initialized (the Connection has been set up and is now ready to be used).
2585 */
2586 public final void setInitialized() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002587 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002588 setState(STATE_NEW);
Evan Charltonbf11f982014-07-20 22:06:28 -07002589 }
2590
2591 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002592 * Sets state to dialing (e.g., dialing an outbound connection).
Ihab Awad542e0ea2014-05-16 10:22:16 -07002593 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002594 public final void setDialing() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002595 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002596 setState(STATE_DIALING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002597 }
2598
2599 /**
Tyler Gunnc242ceb2016-06-29 22:35:45 -07002600 * Sets state to pulling (e.g. the connection is being pulled to the local device from another
2601 * device). Only applicable for {@link Connection}s with
2602 * {@link Connection#PROPERTY_IS_EXTERNAL_CALL} and {@link Connection#CAPABILITY_CAN_PULL_CALL}.
2603 */
2604 public final void setPulling() {
2605 checkImmutable();
2606 setState(STATE_PULLING_CALL);
2607 }
2608
2609 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002610 * Sets state to be on hold.
2611 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002612 public final void setOnHold() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002613 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002614 setState(STATE_HOLDING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002615 }
2616
2617 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002618 * Sets the video connection provider.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002619 * @param videoProvider The video provider.
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002620 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002621 public final void setVideoProvider(VideoProvider videoProvider) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002622 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002623 mVideoProvider = videoProvider;
Santos Cordond34e5712014-08-05 18:54:03 +00002624 for (Listener l : mListeners) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002625 l.onVideoProviderChanged(this, videoProvider);
Santos Cordond34e5712014-08-05 18:54:03 +00002626 }
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002627 }
2628
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002629 public final VideoProvider getVideoProvider() {
2630 return mVideoProvider;
Andrew Leea27a1932014-07-09 17:07:13 -07002631 }
2632
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002633 /**
Sailesh Nepal091768c2014-06-30 15:15:23 -07002634 * Sets state to disconnected.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002635 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002636 * @param disconnectCause The reason for the disconnection, as specified by
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002637 * {@link DisconnectCause}.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002638 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002639 public final void setDisconnected(DisconnectCause disconnectCause) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002640 checkImmutable();
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002641 mDisconnectCause = disconnectCause;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002642 setState(STATE_DISCONNECTED);
mike dooleyf34519b2014-09-16 17:33:40 -07002643 Log.d(this, "Disconnected with cause %s", disconnectCause);
Santos Cordond34e5712014-08-05 18:54:03 +00002644 for (Listener l : mListeners) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002645 l.onDisconnected(this, disconnectCause);
Santos Cordond34e5712014-08-05 18:54:03 +00002646 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002647 }
2648
2649 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002650 * Informs listeners that this {@code Connection} is in a post-dial wait state. This is done
2651 * when (a) the {@code Connection} is issuing a DTMF sequence; (b) it has encountered a "wait"
2652 * character; and (c) it wishes to inform the In-Call app that it is waiting for the end-user
2653 * to send an {@link #onPostDialContinue(boolean)} signal.
2654 *
2655 * @param remaining The DTMF character sequence remaining to be emitted once the
2656 * {@link #onPostDialContinue(boolean)} is received, including any "wait" characters
2657 * that remaining sequence may contain.
Sailesh Nepal091768c2014-06-30 15:15:23 -07002658 */
2659 public final void setPostDialWait(String remaining) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002660 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002661 for (Listener l : mListeners) {
2662 l.onPostDialWait(this, remaining);
2663 }
Sailesh Nepal091768c2014-06-30 15:15:23 -07002664 }
2665
2666 /**
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002667 * Informs listeners that this {@code Connection} has processed a character in the post-dial
2668 * started state. This is done when (a) the {@code Connection} is issuing a DTMF sequence;
Sailesh Nepal1ed85612015-01-31 15:17:19 -08002669 * and (b) it wishes to signal Telecom to play the corresponding DTMF tone locally.
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002670 *
2671 * @param nextChar The DTMF character that was just processed by the {@code Connection}.
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002672 */
Sailesh Nepal1ed85612015-01-31 15:17:19 -08002673 public final void setNextPostDialChar(char nextChar) {
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002674 checkImmutable();
2675 for (Listener l : mListeners) {
2676 l.onPostDialChar(this, nextChar);
2677 }
2678 }
2679
2680 /**
Ihab Awadf8358972014-05-28 16:46:42 -07002681 * Requests that the framework play a ringback tone. This is to be invoked by implementations
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002682 * that do not play a ringback tone themselves in the connection's audio stream.
Ihab Awadf8358972014-05-28 16:46:42 -07002683 *
2684 * @param ringback Whether the ringback tone is to be played.
2685 */
Andrew Lee100e2932014-09-08 15:34:24 -07002686 public final void setRingbackRequested(boolean ringback) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002687 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002688 if (mRingbackRequested != ringback) {
2689 mRingbackRequested = ringback;
Santos Cordond34e5712014-08-05 18:54:03 +00002690 for (Listener l : mListeners) {
Andrew Lee100e2932014-09-08 15:34:24 -07002691 l.onRingbackRequested(this, ringback);
Santos Cordond34e5712014-08-05 18:54:03 +00002692 }
2693 }
Ihab Awadf8358972014-05-28 16:46:42 -07002694 }
2695
2696 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002697 * Sets the connection's capabilities as a bit mask of the {@code CAPABILITY_*} constants.
Sailesh Nepal1a7061b2014-07-09 21:03:20 -07002698 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002699 * @param connectionCapabilities The new connection capabilities.
Santos Cordonb6939982014-06-04 20:20:58 -07002700 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002701 public final void setConnectionCapabilities(int connectionCapabilities) {
2702 checkImmutable();
2703 if (mConnectionCapabilities != connectionCapabilities) {
2704 mConnectionCapabilities = connectionCapabilities;
Santos Cordond34e5712014-08-05 18:54:03 +00002705 for (Listener l : mListeners) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002706 l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities);
Santos Cordond34e5712014-08-05 18:54:03 +00002707 }
2708 }
Santos Cordonb6939982014-06-04 20:20:58 -07002709 }
2710
2711 /**
Tyler Gunn720c6642016-03-22 09:02:47 -07002712 * Sets the connection's properties as a bit mask of the {@code PROPERTY_*} constants.
2713 *
2714 * @param connectionProperties The new connection properties.
2715 */
2716 public final void setConnectionProperties(int connectionProperties) {
2717 checkImmutable();
2718 if (mConnectionProperties != connectionProperties) {
2719 mConnectionProperties = connectionProperties;
2720 for (Listener l : mListeners) {
2721 l.onConnectionPropertiesChanged(this, mConnectionProperties);
2722 }
2723 }
2724 }
2725
2726 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002727 * Sets the supported audio routes.
2728 *
2729 * @param supportedAudioRoutes the supported audio routes as a bitmask.
2730 * See {@link CallAudioState}
2731 * @hide
2732 */
2733 public final void setSupportedAudioRoutes(int supportedAudioRoutes) {
2734 if ((supportedAudioRoutes
2735 & (CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_SPEAKER)) == 0) {
2736 throw new IllegalArgumentException(
2737 "supported audio routes must include either speaker or earpiece");
2738 }
2739
2740 if (mSupportedAudioRoutes != supportedAudioRoutes) {
2741 mSupportedAudioRoutes = supportedAudioRoutes;
2742 for (Listener l : mListeners) {
2743 l.onSupportedAudioRoutesChanged(this, mSupportedAudioRoutes);
2744 }
2745 }
2746 }
2747
2748 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002749 * Tears down the Connection object.
Santos Cordonb6939982014-06-04 20:20:58 -07002750 */
Evan Charlton36a71342014-07-19 16:31:02 -07002751 public final void destroy() {
Jay Shrauner229e3822014-08-15 09:23:07 -07002752 for (Listener l : mListeners) {
2753 l.onDestroyed(this);
Santos Cordond34e5712014-08-05 18:54:03 +00002754 }
Santos Cordonb6939982014-06-04 20:20:58 -07002755 }
2756
2757 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002758 * Requests that the framework use VOIP audio mode for this connection.
2759 *
2760 * @param isVoip True if the audio mode is VOIP.
2761 */
2762 public final void setAudioModeIsVoip(boolean isVoip) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002763 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002764 mAudioModeIsVoip = isVoip;
2765 for (Listener l : mListeners) {
2766 l.onAudioModeIsVoipChanged(this, isVoip);
2767 }
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002768 }
2769
2770 /**
Roshan Piuse927ec02015-07-15 15:47:21 -07002771 * Sets the time at which a call became active on this Connection. This is set only
2772 * when a conference call becomes active on this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002773 * <p>
Tyler Gunnc9503d62020-01-27 10:30:51 -08002774 * This time corresponds to the date/time of connection and is stored in the call log in
2775 * {@link android.provider.CallLog.Calls#DATE}.
2776 * <p>
Tyler Gunnc63f9082019-10-15 13:19:26 -07002777 * Used by telephony to maintain calls associated with an IMS Conference.
Roshan Piuse927ec02015-07-15 15:47:21 -07002778 *
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002779 * @param connectTimeMillis The connection time, in milliseconds. Should be set using a value
2780 * obtained from {@link System#currentTimeMillis()}.
Roshan Piuse927ec02015-07-15 15:47:21 -07002781 *
2782 * @hide
2783 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002784 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002785 @RequiresPermission(MODIFY_PHONE_STATE)
2786 public final void setConnectTimeMillis(@IntRange(from = 0) long connectTimeMillis) {
Roshan Piuse927ec02015-07-15 15:47:21 -07002787 mConnectTimeMillis = connectTimeMillis;
2788 }
2789
2790 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002791 * Sets the time at which a call became active on this Connection. This is set only
2792 * when a conference call becomes active on this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002793 * <p>
Tyler Gunnc9503d62020-01-27 10:30:51 -08002794 * This time is used to establish the duration of a call. It uses
2795 * {@link SystemClock#elapsedRealtime()} to ensure that the call duration is not impacted by
2796 * time zone changes during a call. The difference between the current
2797 * {@link SystemClock#elapsedRealtime()} and the value set at the connection start time is used
2798 * to populate {@link android.provider.CallLog.Calls#DURATION} in the call log.
2799 * <p>
Tyler Gunnc63f9082019-10-15 13:19:26 -07002800 * Used by telephony to maintain calls associated with an IMS Conference.
Tyler Gunnc9503d62020-01-27 10:30:51 -08002801 *
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002802 * @param connectElapsedTimeMillis The connection time, in milliseconds. Stored in the format
2803 * {@link SystemClock#elapsedRealtime()}.
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002804 * @hide
2805 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002806 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002807 @RequiresPermission(MODIFY_PHONE_STATE)
2808 public final void setConnectionStartElapsedRealtimeMillis(
2809 @ElapsedRealtimeLong long connectElapsedTimeMillis) {
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002810 mConnectElapsedTimeMillis = connectElapsedTimeMillis;
2811 }
2812
2813 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002814 * Sets the label and icon status to display in the in-call UI.
2815 *
2816 * @param statusHints The status label and icon to set.
2817 */
2818 public final void setStatusHints(StatusHints statusHints) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002819 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002820 mStatusHints = statusHints;
2821 for (Listener l : mListeners) {
2822 l.onStatusHintsChanged(this, statusHints);
2823 }
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002824 }
2825
2826 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002827 * Sets the connections with which this connection can be conferenced.
2828 *
2829 * @param conferenceableConnections The set of connections this connection can conference with.
2830 */
2831 public final void setConferenceableConnections(List<Connection> conferenceableConnections) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002832 checkImmutable();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002833 clearConferenceableList();
2834 for (Connection c : conferenceableConnections) {
2835 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
2836 // small amount of items here.
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002837 if (!mConferenceables.contains(c)) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002838 c.addConnectionListener(mConnectionDeathListener);
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002839 mConferenceables.add(c);
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002840 }
2841 }
2842 fireOnConferenceableConnectionsChanged();
2843 }
2844
2845 /**
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002846 * Similar to {@link #setConferenceableConnections(java.util.List)}, sets a list of connections
2847 * or conferences with which this connection can be conferenced.
2848 *
2849 * @param conferenceables The conferenceables.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002850 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002851 public final void setConferenceables(List<Conferenceable> conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002852 clearConferenceableList();
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002853 for (Conferenceable c : conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002854 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
2855 // small amount of items here.
2856 if (!mConferenceables.contains(c)) {
2857 if (c instanceof Connection) {
2858 Connection connection = (Connection) c;
2859 connection.addConnectionListener(mConnectionDeathListener);
2860 } else if (c instanceof Conference) {
2861 Conference conference = (Conference) c;
2862 conference.addListener(mConferenceDeathListener);
2863 }
2864 mConferenceables.add(c);
2865 }
2866 }
2867 fireOnConferenceableConnectionsChanged();
2868 }
2869
2870 /**
Tyler Gunnc63f9082019-10-15 13:19:26 -07002871 * Resets the CDMA connection time.
2872 * <p>
2873 * This is an implementation detail specific to legacy CDMA calls on mobile networks.
Mengjun Leng25707742017-07-04 11:10:37 +08002874 * @hide
Mengjun Leng25707742017-07-04 11:10:37 +08002875 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002876 @SystemApi
Mengjun Leng25707742017-07-04 11:10:37 +08002877 public final void resetConnectionTime() {
2878 for (Listener l : mListeners) {
2879 l.onConnectionTimeReset(this);
2880 }
2881 }
2882
2883 /**
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002884 * Returns the connections or conferences with which this connection can be conferenced.
2885 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002886 public final List<Conferenceable> getConferenceables() {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002887 return mUnmodifiableConferenceables;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002888 }
2889
Yorke Lee53463962015-08-04 16:07:19 -07002890 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002891 * @hide
2892 */
2893 public final void setConnectionService(ConnectionService connectionService) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002894 checkImmutable();
Santos Cordon823fd3c2014-08-07 18:35:18 -07002895 if (mConnectionService != null) {
2896 Log.e(this, new Exception(), "Trying to set ConnectionService on a connection " +
2897 "which is already associated with another ConnectionService.");
2898 } else {
2899 mConnectionService = connectionService;
2900 }
2901 }
2902
2903 /**
2904 * @hide
2905 */
2906 public final void unsetConnectionService(ConnectionService connectionService) {
2907 if (mConnectionService != connectionService) {
2908 Log.e(this, new Exception(), "Trying to remove ConnectionService from a Connection " +
2909 "that does not belong to the ConnectionService.");
2910 } else {
2911 mConnectionService = null;
2912 }
2913 }
2914
2915 /**
2916 * Sets the conference that this connection is a part of. This will fail if the connection is
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002917 * already part of a conference. {@link #resetConference} to un-set the conference first.
Santos Cordon823fd3c2014-08-07 18:35:18 -07002918 *
2919 * @param conference The conference.
2920 * @return {@code true} if the conference was successfully set.
2921 * @hide
2922 */
2923 public final boolean setConference(Conference conference) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002924 checkImmutable();
Santos Cordon823fd3c2014-08-07 18:35:18 -07002925 // We check to see if it is already part of another conference.
Santos Cordon0159ac02014-08-21 14:28:11 -07002926 if (mConference == null) {
Santos Cordon823fd3c2014-08-07 18:35:18 -07002927 mConference = conference;
Santos Cordon0159ac02014-08-21 14:28:11 -07002928 if (mConnectionService != null && mConnectionService.containsConference(conference)) {
2929 fireConferenceChanged();
2930 }
Santos Cordon823fd3c2014-08-07 18:35:18 -07002931 return true;
2932 }
2933 return false;
2934 }
2935
2936 /**
2937 * Resets the conference that this connection is a part of.
2938 * @hide
2939 */
2940 public final void resetConference() {
2941 if (mConference != null) {
Santos Cordon0159ac02014-08-21 14:28:11 -07002942 Log.d(this, "Conference reset");
Santos Cordon823fd3c2014-08-07 18:35:18 -07002943 mConference = null;
2944 fireConferenceChanged();
2945 }
2946 }
2947
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002948 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002949 * Set some extras that can be associated with this {@code Connection}.
2950 * <p>
2951 * New or existing keys are replaced in the {@code Connection} extras. Keys which are no longer
2952 * in the new extras, but were present the last time {@code setExtras} was called are removed.
2953 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07002954 * Alternatively you may use the {@link #putExtras(Bundle)}, and
2955 * {@link #removeExtras(String...)} methods to modify the extras.
2956 * <p>
Tyler Gunndee56a82016-03-23 16:06:34 -07002957 * 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 -07002958 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
2959 *
2960 * @param extras The extras associated with this {@code Connection}.
2961 */
2962 public final void setExtras(@Nullable Bundle extras) {
2963 checkImmutable();
Tyler Gunndee56a82016-03-23 16:06:34 -07002964
2965 // Add/replace any new or changed extras values.
2966 putExtras(extras);
2967
2968 // If we have used "setExtras" in the past, compare the key set from the last invocation to
2969 // the current one and remove any keys that went away.
2970 if (mPreviousExtraKeys != null) {
2971 List<String> toRemove = new ArrayList<String>();
2972 for (String oldKey : mPreviousExtraKeys) {
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07002973 if (extras == null || !extras.containsKey(oldKey)) {
Tyler Gunndee56a82016-03-23 16:06:34 -07002974 toRemove.add(oldKey);
2975 }
2976 }
2977 if (!toRemove.isEmpty()) {
2978 removeExtras(toRemove);
2979 }
2980 }
2981
2982 // Track the keys the last time set called setExtras. This way, the next time setExtras is
2983 // called we can see if the caller has removed any extras values.
2984 if (mPreviousExtraKeys == null) {
2985 mPreviousExtraKeys = new ArraySet<String>();
2986 }
2987 mPreviousExtraKeys.clear();
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07002988 if (extras != null) {
2989 mPreviousExtraKeys.addAll(extras.keySet());
2990 }
Tyler Gunndee56a82016-03-23 16:06:34 -07002991 }
2992
2993 /**
2994 * Adds some extras to this {@code Connection}. Existing keys are replaced and new ones are
2995 * added.
2996 * <p>
2997 * No assumptions should be made as to how an In-Call UI or service will handle these extras.
2998 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
2999 *
3000 * @param extras The extras to add.
3001 */
3002 public final void putExtras(@NonNull Bundle extras) {
3003 checkImmutable();
3004 if (extras == null) {
3005 return;
3006 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003007 // Creating a duplicate bundle so we don't have to synchronize on mExtrasLock while calling
3008 // the listeners.
3009 Bundle listenerExtras;
3010 synchronized (mExtrasLock) {
3011 if (mExtras == null) {
3012 mExtras = new Bundle();
3013 }
3014 mExtras.putAll(extras);
3015 listenerExtras = new Bundle(mExtras);
Tyler Gunndee56a82016-03-23 16:06:34 -07003016 }
Santos Cordon6b7f9552015-05-27 17:21:45 -07003017 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003018 // Create a new clone of the extras for each listener so that they don't clobber
3019 // each other
3020 l.onExtrasChanged(this, new Bundle(listenerExtras));
Santos Cordon6b7f9552015-05-27 17:21:45 -07003021 }
3022 }
3023
3024 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -07003025 * Removes extras from this {@code Connection}.
Tyler Gunndee56a82016-03-23 16:06:34 -07003026 *
Tyler Gunn071be6f2016-05-10 14:52:33 -07003027 * @param keys The keys of the extras to remove.
Tyler Gunndee56a82016-03-23 16:06:34 -07003028 */
3029 public final void removeExtras(List<String> keys) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003030 synchronized (mExtrasLock) {
3031 if (mExtras != null) {
3032 for (String key : keys) {
3033 mExtras.remove(key);
3034 }
Tyler Gunndee56a82016-03-23 16:06:34 -07003035 }
3036 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003037 List<String> unmodifiableKeys = Collections.unmodifiableList(keys);
Tyler Gunndee56a82016-03-23 16:06:34 -07003038 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003039 l.onExtrasRemoved(this, unmodifiableKeys);
Tyler Gunndee56a82016-03-23 16:06:34 -07003040 }
3041 }
3042
3043 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -07003044 * Removes extras from this {@code Connection}.
3045 *
3046 * @param keys The keys of the extras to remove.
3047 */
3048 public final void removeExtras(String ... keys) {
3049 removeExtras(Arrays.asList(keys));
3050 }
3051
3052 /**
Tyler Gunnf5035432017-01-09 09:43:12 -08003053 * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will
3054 * be change to the {@link #getCallAudioState()}.
3055 * <p>
3056 * Used by self-managed {@link ConnectionService}s which wish to change the audio route for a
3057 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
3058 * <p>
3059 * See also {@link InCallService#setAudioRoute(int)}.
3060 *
3061 * @param route The audio route to use (one of {@link CallAudioState#ROUTE_BLUETOOTH},
3062 * {@link CallAudioState#ROUTE_EARPIECE}, {@link CallAudioState#ROUTE_SPEAKER}, or
3063 * {@link CallAudioState#ROUTE_WIRED_HEADSET}).
3064 */
3065 public final void setAudioRoute(int route) {
3066 for (Listener l : mListeners) {
Hall Liua98f58b52017-11-07 17:59:28 -08003067 l.onAudioRouteChanged(this, route, null);
3068 }
3069 }
3070
3071 /**
Hall Liua98f58b52017-11-07 17:59:28 -08003072 * Request audio routing to a specific bluetooth device. Calling this method may result in
3073 * the device routing audio to a different bluetooth device than the one specified if the
3074 * bluetooth stack is unable to route audio to the requested device.
3075 * A list of available devices can be obtained via
3076 * {@link CallAudioState#getSupportedBluetoothDevices()}
3077 *
3078 * <p>
3079 * Used by self-managed {@link ConnectionService}s which wish to use bluetooth audio for a
3080 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
3081 * <p>
Hall Liu2b6a6a32018-04-02 13:52:57 -07003082 * See also {@link InCallService#requestBluetoothAudio(BluetoothDevice)}
3083 * @param bluetoothDevice The bluetooth device to connect to.
Hall Liua98f58b52017-11-07 17:59:28 -08003084 */
Hall Liu2b6a6a32018-04-02 13:52:57 -07003085 public void requestBluetoothAudio(@NonNull BluetoothDevice bluetoothDevice) {
Hall Liua98f58b52017-11-07 17:59:28 -08003086 for (Listener l : mListeners) {
Hall Liu2b6a6a32018-04-02 13:52:57 -07003087 l.onAudioRouteChanged(this, CallAudioState.ROUTE_BLUETOOTH,
3088 bluetoothDevice.getAddress());
Tyler Gunnf5035432017-01-09 09:43:12 -08003089 }
3090 }
3091
3092 /**
Hall Liub64ac4c2017-02-06 10:49:48 -08003093 * Informs listeners that a previously requested RTT session via
3094 * {@link ConnectionRequest#isRequestingRtt()} or
Hall Liu37dfdb02017-12-04 14:19:30 -08003095 * {@link #onStartRtt(RttTextStream)} has succeeded.
Hall Liub64ac4c2017-02-06 10:49:48 -08003096 */
3097 public final void sendRttInitiationSuccess() {
3098 mListeners.forEach((l) -> l.onRttInitiationSuccess(Connection.this));
3099 }
3100
3101 /**
3102 * Informs listeners that a previously requested RTT session via
Hall Liu37dfdb02017-12-04 14:19:30 -08003103 * {@link ConnectionRequest#isRequestingRtt()} or {@link #onStartRtt(RttTextStream)}
Hall Liub64ac4c2017-02-06 10:49:48 -08003104 * has failed.
3105 * @param reason One of the reason codes defined in {@link RttModifyStatus}, with the
3106 * exception of {@link RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}.
Hall Liub64ac4c2017-02-06 10:49:48 -08003107 */
3108 public final void sendRttInitiationFailure(int reason) {
3109 mListeners.forEach((l) -> l.onRttInitiationFailure(Connection.this, reason));
3110 }
3111
3112 /**
3113 * Informs listeners that a currently active RTT session has been terminated by the remote
3114 * side of the coll.
Hall Liub64ac4c2017-02-06 10:49:48 -08003115 */
3116 public final void sendRttSessionRemotelyTerminated() {
3117 mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this));
3118 }
3119
3120 /**
3121 * Informs listeners that the remote side of the call has requested an upgrade to include an
3122 * RTT session in the call.
Hall Liub64ac4c2017-02-06 10:49:48 -08003123 */
3124 public final void sendRemoteRttRequest() {
3125 mListeners.forEach((l) -> l.onRemoteRttRequest(Connection.this));
3126 }
3127
3128 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003129 * Notifies this Connection that the {@link #getAudioState()} property has a new value.
Sailesh Nepal400cc482014-06-26 12:04:00 -07003130 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003131 * @param state The new connection audio state.
Yorke Lee4af59352015-05-13 14:14:54 -07003132 * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead.
3133 * @hide
Sailesh Nepal400cc482014-06-26 12:04:00 -07003134 */
Yorke Lee4af59352015-05-13 14:14:54 -07003135 @SystemApi
3136 @Deprecated
Nancy Chen354b2bd2014-09-08 18:27:26 -07003137 public void onAudioStateChanged(AudioState state) {}
Sailesh Nepal400cc482014-06-26 12:04:00 -07003138
3139 /**
Yorke Lee4af59352015-05-13 14:14:54 -07003140 * Notifies this Connection that the {@link #getCallAudioState()} property has a new value.
3141 *
3142 * @param state The new connection audio state.
3143 */
3144 public void onCallAudioStateChanged(CallAudioState state) {}
3145
3146 /**
Grace Jiae99fde92021-01-19 14:58:01 -08003147 * Inform this Connection when it will or will not be tracked by an {@link InCallService} which
3148 * can provide an InCall UI.
3149 * This is primarily intended for use by Connections reported by self-managed
3150 * {@link ConnectionService} which typically maintain their own UI.
3151 *
3152 * @param isUsingAlternativeUi Indicates whether an InCallService that can provide InCall UI is
3153 * currently tracking the self-managed call.
3154 */
3155 public void onUsingAlternativeUi(boolean isUsingAlternativeUi) {}
3156
3157 /**
3158 * Inform this Conenection when it will or will not be tracked by an non-UI
3159 * {@link InCallService}.
3160 *
3161 * @param isTracked Indicates whether an non-UI InCallService is currently tracking the
3162 * self-managed call.
3163 */
3164 public void onTrackedByNonUiService(boolean isTracked) {}
3165
3166 /**
Evan Charltonbf11f982014-07-20 22:06:28 -07003167 * Notifies this Connection of an internal state change. This method is called after the
3168 * state is changed.
Ihab Awadf8358972014-05-28 16:46:42 -07003169 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003170 * @param state The new state, one of the {@code STATE_*} constants.
Ihab Awadf8358972014-05-28 16:46:42 -07003171 */
Nancy Chen354b2bd2014-09-08 18:27:26 -07003172 public void onStateChanged(int state) {}
Ihab Awadf8358972014-05-28 16:46:42 -07003173
3174 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07003175 * Notifies this Connection of a request to play a DTMF tone.
3176 *
3177 * @param c A DTMF character.
3178 */
Santos Cordonf2951102014-07-20 19:06:29 -07003179 public void onPlayDtmfTone(char c) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003180
3181 /**
3182 * Notifies this Connection of a request to stop any currently playing DTMF tones.
3183 */
Santos Cordonf2951102014-07-20 19:06:29 -07003184 public void onStopDtmfTone() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003185
3186 /**
3187 * Notifies this Connection of a request to disconnect.
3188 */
Santos Cordonf2951102014-07-20 19:06:29 -07003189 public void onDisconnect() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003190
3191 /**
Tyler Gunn3b4b1dc2014-11-04 14:53:37 -08003192 * Notifies this Connection of a request to disconnect a participant of the conference managed
3193 * by the connection.
3194 *
3195 * @param endpoint the {@link Uri} of the participant to disconnect.
3196 * @hide
3197 */
3198 public void onDisconnectConferenceParticipant(Uri endpoint) {}
3199
3200 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003201 * Notifies this Connection of a request to separate from its parent conference.
Santos Cordonb6939982014-06-04 20:20:58 -07003202 */
Santos Cordonf2951102014-07-20 19:06:29 -07003203 public void onSeparate() {}
Santos Cordonb6939982014-06-04 20:20:58 -07003204
3205 /**
Tyler Gunn0c62ef02020-02-11 14:39:43 -08003206 * Supports initiation of a conference call by directly adding participants to an ongoing call.
Ravi Paluri404babb2020-01-23 19:02:44 +05303207 *
3208 * @param participants with which conference call will be formed.
3209 */
3210 public void onAddConferenceParticipants(@NonNull List<Uri> participants) {}
3211
3212 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07003213 * Notifies this Connection of a request to abort.
3214 */
Santos Cordonf2951102014-07-20 19:06:29 -07003215 public void onAbort() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003216
3217 /**
3218 * Notifies this Connection of a request to hold.
3219 */
Santos Cordonf2951102014-07-20 19:06:29 -07003220 public void onHold() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003221
3222 /**
3223 * Notifies this Connection of a request to exit a hold state.
3224 */
Santos Cordonf2951102014-07-20 19:06:29 -07003225 public void onUnhold() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003226
3227 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003228 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Santos Cordond34e5712014-08-05 18:54:03 +00003229 * a request to accept.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003230 * <p>
3231 * For managed {@link ConnectionService}s, this will be called when the user answers a call via
3232 * the default dialer's {@link InCallService}.
3233 * <p>
3234 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3235 * Telecom framework may request that the call is answered in the following circumstances:
3236 * <ul>
3237 * <li>The user chooses to answer an incoming call via a Bluetooth device.</li>
3238 * <li>A car mode {@link InCallService} is in use which has declared
3239 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3240 * {@link InCallService} will be able to see calls from self-managed
3241 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3242 * behalf.</li>
3243 * </ul>
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003244 * @param videoState The video state in which to answer the connection.
Ihab Awad542e0ea2014-05-16 10:22:16 -07003245 */
Santos Cordonf2951102014-07-20 19:06:29 -07003246 public void onAnswer(int videoState) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003247
3248 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003249 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Tyler Gunnbe74de02014-08-29 14:51:48 -07003250 * a request to accept.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003251 * <p>
3252 * For managed {@link ConnectionService}s, this will be called when the user answers a call via
3253 * the default dialer's {@link InCallService}.
3254 * <p>
3255 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3256 * Telecom framework may request that the call is answered in the following circumstances:
3257 * <ul>
3258 * <li>The user chooses to answer an incoming call via a Bluetooth device.</li>
3259 * <li>A car mode {@link InCallService} is in use which has declared
3260 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3261 * {@link InCallService} will be able to see calls from self-managed
3262 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3263 * behalf.</li>
3264 * </ul>
Tyler Gunnbe74de02014-08-29 14:51:48 -07003265 */
3266 public void onAnswer() {
Tyler Gunn87b73f32015-06-03 10:09:59 -07003267 onAnswer(VideoProfile.STATE_AUDIO_ONLY);
Tyler Gunnbe74de02014-08-29 14:51:48 -07003268 }
3269
3270 /**
3271 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Pooja Jaind34698d2017-12-28 14:15:31 +05303272 * a request to deflect.
3273 */
3274 public void onDeflect(Uri address) {}
3275
3276 /**
3277 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Santos Cordond34e5712014-08-05 18:54:03 +00003278 * a request to reject.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003279 * <p>
3280 * For managed {@link ConnectionService}s, this will be called when the user rejects a call via
3281 * the default dialer's {@link InCallService}.
3282 * <p>
3283 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3284 * Telecom framework may request that the call is rejected in the following circumstances:
3285 * <ul>
3286 * <li>The user chooses to reject an incoming call via a Bluetooth device.</li>
3287 * <li>A car mode {@link InCallService} is in use which has declared
3288 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3289 * {@link InCallService} will be able to see calls from self-managed
3290 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3291 * behalf.</li>
3292 * </ul>
Ihab Awad542e0ea2014-05-16 10:22:16 -07003293 */
Santos Cordonf2951102014-07-20 19:06:29 -07003294 public void onReject() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003295
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003296 /**
Tyler Gunnfacfdee2020-01-23 13:10:37 -08003297 * Notifies this Connection, which is in {@link #STATE_RINGING}, of a request to reject.
3298 * <p>
3299 * For managed {@link ConnectionService}s, this will be called when the user rejects a call via
3300 * the default dialer's {@link InCallService} using {@link Call#reject(int)}.
3301 * @param rejectReason the reason the user provided for rejecting the call.
3302 */
3303 public void onReject(@android.telecom.Call.RejectReason int rejectReason) {
3304 // to be implemented by ConnectionService.
3305 }
3306
3307 /**
Hall Liu712acbe2016-03-14 16:38:56 -07003308 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
3309 * a request to reject with a message.
Bryce Lee81901682015-08-28 16:38:02 -07003310 */
3311 public void onReject(String replyMessage) {}
3312
3313 /**
Ravi Palurif4b38e72020-02-05 12:35:41 +05303314 * Notifies this Connection, a request to transfer to a target number.
3315 * @param number the number to transfer this {@link Connection} to.
3316 * @param isConfirmationRequired when {@code true}, the {@link ConnectionService}
3317 * should wait until the transfer has successfully completed before disconnecting
3318 * the current {@link Connection}.
3319 * When {@code false}, the {@link ConnectionService} should signal the network to
3320 * perform the transfer, but should immediately disconnect the call regardless of
3321 * the outcome of the transfer.
3322 * @hide
3323 */
3324 public void onTransfer(@NonNull Uri number, boolean isConfirmationRequired) {}
3325
3326 /**
3327 * Notifies this Connection, a request to transfer to another Connection.
3328 * @param otherConnection the {@link Connection} to transfer this call to.
3329 * @hide
3330 */
3331 public void onTransfer(@NonNull Connection otherConnection) {}
3332
3333 /**
Tyler Gunn06f06162018-06-18 11:24:15 -07003334 * Notifies this Connection of a request to silence the ringer.
3335 * <p>
3336 * The ringer may be silenced by any of the following methods:
3337 * <ul>
3338 * <li>{@link TelecomManager#silenceRinger()}</li>
3339 * <li>The user presses the volume-down button while a call is ringing.</li>
3340 * </ul>
3341 * <p>
3342 * Self-managed {@link ConnectionService} implementations should override this method in their
3343 * {@link Connection} implementation and implement logic to silence their app's ringtone. If
3344 * your app set the ringtone as part of the incoming call {@link Notification} (see
3345 * {@link #onShowIncomingCallUi()}), it should re-post the notification now, except call
3346 * {@link android.app.Notification.Builder#setOnlyAlertOnce(boolean)} with {@code true}. This
3347 * will ensure the ringtone sound associated with your {@link android.app.NotificationChannel}
3348 * stops playing.
Bryce Leecac50772015-11-17 15:13:29 -08003349 */
3350 public void onSilence() {}
3351
3352 /**
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003353 * Notifies this Connection whether the user wishes to proceed with the post-dial DTMF codes.
3354 */
Santos Cordonf2951102014-07-20 19:06:29 -07003355 public void onPostDialContinue(boolean proceed) {}
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003356
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003357 /**
3358 * Notifies this Connection of a request to pull an external call to the local device.
3359 * <p>
3360 * The {@link InCallService} issues a request to pull an external call to the local device via
3361 * {@link Call#pullExternalCall()}.
3362 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -07003363 * For a Connection to be pulled, both the {@link Connection#CAPABILITY_CAN_PULL_CALL}
3364 * capability and {@link Connection#PROPERTY_IS_EXTERNAL_CALL} property bits must be set.
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003365 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -07003366 * For more information on external calls, see {@link Connection#PROPERTY_IS_EXTERNAL_CALL}.
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003367 */
3368 public void onPullExternalCall() {}
3369
3370 /**
3371 * Notifies this Connection of a {@link Call} event initiated from an {@link InCallService}.
3372 * <p>
3373 * The {@link InCallService} issues a Call event via {@link Call#sendCallEvent(String, Bundle)}.
3374 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003375 * Where possible, the Connection should make an attempt to handle {@link Call} events which
3376 * are part of the {@code android.telecom.*} namespace. The Connection should ignore any events
3377 * it does not wish to handle. Unexpected events should be handled gracefully, as it is
3378 * possible that a {@link InCallService} has defined its own Call events which a Connection is
3379 * not aware of.
3380 * <p>
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003381 * See also {@link Call#sendCallEvent(String, Bundle)}.
3382 *
3383 * @param event The call event.
3384 * @param extras Extras associated with the call event.
3385 */
3386 public void onCallEvent(String event, Bundle extras) {}
3387
Tyler Gunndee56a82016-03-23 16:06:34 -07003388 /**
Tyler Gunn79bc1ec2018-01-22 15:17:54 -08003389 * Notifies this {@link Connection} that a handover has completed.
3390 * <p>
3391 * A handover is initiated with {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int,
3392 * Bundle)} on the initiating side of the handover, and
3393 * {@link TelecomManager#acceptHandover(Uri, int, PhoneAccountHandle)}.
3394 */
3395 public void onHandoverComplete() {}
3396
3397 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07003398 * Notifies this {@link Connection} of a change to the extras made outside the
3399 * {@link ConnectionService}.
3400 * <p>
3401 * These extras changes can originate from Telecom itself, or from an {@link InCallService} via
3402 * the {@link android.telecom.Call#putExtras(Bundle)} and
3403 * {@link Call#removeExtras(List)}.
3404 *
3405 * @param extras The new extras bundle.
3406 */
3407 public void onExtrasChanged(Bundle extras) {}
3408
Tyler Gunnf5035432017-01-09 09:43:12 -08003409 /**
3410 * Notifies this {@link Connection} that its {@link ConnectionService} is responsible for
3411 * displaying its incoming call user interface for the {@link Connection}.
3412 * <p>
3413 * Will only be called for incoming calls added via a self-managed {@link ConnectionService}
3414 * (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}), where the {@link ConnectionService}
3415 * should show its own incoming call user interface.
3416 * <p>
3417 * Where there are ongoing calls in other self-managed {@link ConnectionService}s, or in a
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003418 * regular {@link ConnectionService}, and it is not possible to hold these other calls, the
3419 * Telecom framework will display its own incoming call user interface to allow the user to
3420 * choose whether to answer the new incoming call and disconnect other ongoing calls, or to
3421 * reject the new incoming call.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003422 * <p>
3423 * You should trigger the display of the incoming call user interface for your application by
3424 * showing a {@link Notification} with a full-screen {@link Intent} specified.
Tyler Gunn06f06162018-06-18 11:24:15 -07003425 *
3426 * In your application code, you should create a {@link android.app.NotificationChannel} for
3427 * incoming call notifications from your app:
3428 * <pre><code>
3429 * NotificationChannel channel = new NotificationChannel(YOUR_CHANNEL_ID, "Incoming Calls",
3430 * NotificationManager.IMPORTANCE_MAX);
3431 * // other channel setup stuff goes here.
3432 *
3433 * // We'll use the default system ringtone for our incoming call notification channel. You can
3434 * // use your own audio resource here.
3435 * Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
3436 * channel.setSound(ringtoneUri, new AudioAttributes.Builder()
3437 * // Setting the AudioAttributes is important as it identifies the purpose of your
3438 * // notification sound.
3439 * .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
3440 * .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
3441 * .build());
3442 *
3443 * NotificationManager mgr = getSystemService(NotificationManager.class);
3444 * mgr.createNotificationChannel(channel);
3445 * </code></pre>
3446 * When it comes time to post a notification for your incoming call, ensure it uses your
3447 * incoming call {@link android.app.NotificationChannel}.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003448 * <pre><code>
3449 * // Create an intent which triggers your fullscreen incoming call user interface.
3450 * Intent intent = new Intent(Intent.ACTION_MAIN, null);
3451 * intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_ACTIVITY_NEW_TASK);
3452 * intent.setClass(context, YourIncomingCallActivity.class);
Ashwini Orugantif8191e82021-01-07 12:04:25 -08003453 * PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_MUTABLE_UNAUDITED);
Tyler Gunn159f35c2017-03-02 09:28:37 -08003454 *
3455 * // Build the notification as an ongoing high priority item; this ensures it will show as
3456 * // a heads up notification which slides down over top of the current content.
3457 * final Notification.Builder builder = new Notification.Builder(context);
3458 * builder.setOngoing(true);
3459 * builder.setPriority(Notification.PRIORITY_HIGH);
3460 *
3461 * // Set notification content intent to take user to fullscreen UI if user taps on the
3462 * // notification body.
3463 * builder.setContentIntent(pendingIntent);
3464 * // Set full screen intent to trigger display of the fullscreen UI when the notification
3465 * // manager deems it appropriate.
3466 * builder.setFullScreenIntent(pendingIntent, true);
3467 *
3468 * // Setup notification content.
3469 * builder.setSmallIcon( yourIconResourceId );
3470 * builder.setContentTitle("Your notification title");
3471 * builder.setContentText("Your notification content.");
3472 *
Tyler Gunn06f06162018-06-18 11:24:15 -07003473 * // Set notification as insistent to cause your ringtone to loop.
3474 * Notification notification = builder.build();
3475 * notification.flags |= Notification.FLAG_INSISTENT;
Tyler Gunn159f35c2017-03-02 09:28:37 -08003476 *
Tyler Gunn06f06162018-06-18 11:24:15 -07003477 * // Use builder.addAction(..) to add buttons to answer or reject the call.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003478 * NotificationManager notificationManager = mContext.getSystemService(
3479 * NotificationManager.class);
Tyler Gunn06f06162018-06-18 11:24:15 -07003480 * notificationManager.notify(YOUR_CHANNEL_ID, YOUR_TAG, YOUR_ID, notification);
Tyler Gunn159f35c2017-03-02 09:28:37 -08003481 * </code></pre>
Tyler Gunnf5035432017-01-09 09:43:12 -08003482 */
3483 public void onShowIncomingCallUi() {}
3484
Hall Liub64ac4c2017-02-06 10:49:48 -08003485 /**
3486 * Notifies this {@link Connection} that the user has requested an RTT session.
3487 * The connection service should call {@link #sendRttInitiationSuccess} or
3488 * {@link #sendRttInitiationFailure} to inform Telecom of the success or failure of the
3489 * request, respectively.
3490 * @param rttTextStream The object that should be used to send text to or receive text from
3491 * the in-call app.
Hall Liub64ac4c2017-02-06 10:49:48 -08003492 */
3493 public void onStartRtt(@NonNull RttTextStream rttTextStream) {}
3494
3495 /**
3496 * Notifies this {@link Connection} that it should terminate any existing RTT communication
3497 * channel. No response to Telecom is needed for this method.
Hall Liub64ac4c2017-02-06 10:49:48 -08003498 */
3499 public void onStopRtt() {}
3500
3501 /**
3502 * Notifies this connection of a response to a previous remotely-initiated RTT upgrade
3503 * request sent via {@link #sendRemoteRttRequest}. Acceptance of the request is
3504 * indicated by the supplied {@link RttTextStream} being non-null, and rejection is
3505 * indicated by {@code rttTextStream} being {@code null}
Hall Liub64ac4c2017-02-06 10:49:48 -08003506 * @param rttTextStream The object that should be used to send text to or receive text from
3507 * the in-call app.
3508 */
3509 public void handleRttUpgradeResponse(@Nullable RttTextStream rttTextStream) {}
3510
Hall Liu49cabcc2021-01-15 11:41:48 -08003511 /**
Hall Liu73903142021-02-18 18:41:41 -08003512 * Information provided to a {@link Connection} upon completion of call filtering in Telecom.
3513 *
3514 * @hide
3515 */
3516 @SystemApi
3517 public static final class CallFilteringCompletionInfo implements Parcelable {
3518 private final boolean mIsBlocked;
3519 private final boolean mIsInContacts;
3520 private final CallScreeningService.CallResponse mCallResponse;
3521 private final ComponentName mCallScreeningComponent;
3522
3523 /**
3524 * Constructor for {@link CallFilteringCompletionInfo}
3525 *
3526 * @param isBlocked Whether any part of the call filtering process indicated that this call
3527 * should be blocked.
3528 * @param isInContacts Whether the caller is in the user's contacts.
3529 * @param callResponse The instance of {@link CallScreeningService.CallResponse} provided
3530 * by the {@link CallScreeningService} that processed this call, or
3531 * {@code null} if no call screening service ran.
3532 * @param callScreeningComponent The component of the {@link CallScreeningService}
3533 * that processed this call, or {@link null} if no
3534 * call screening service ran.
3535 */
3536 public CallFilteringCompletionInfo(boolean isBlocked, boolean isInContacts,
3537 @Nullable CallScreeningService.CallResponse callResponse,
3538 @Nullable ComponentName callScreeningComponent) {
3539 mIsBlocked = isBlocked;
3540 mIsInContacts = isInContacts;
3541 mCallResponse = callResponse;
3542 mCallScreeningComponent = callScreeningComponent;
3543 }
3544
3545 /** @hide */
3546 protected CallFilteringCompletionInfo(Parcel in) {
3547 mIsBlocked = in.readByte() != 0;
3548 mIsInContacts = in.readByte() != 0;
3549 CallScreeningService.ParcelableCallResponse response
Bernardo Rufino90bb3702021-12-07 20:01:45 +00003550 = in.readParcelable(CallScreeningService.class.getClassLoader(), android.telecom.CallScreeningService.ParcelableCallResponse.class);
Hall Liu73903142021-02-18 18:41:41 -08003551 mCallResponse = response == null ? null : response.toCallResponse();
Bernardo Rufino90bb3702021-12-07 20:01:45 +00003552 mCallScreeningComponent = in.readParcelable(ComponentName.class.getClassLoader(), android.content.ComponentName.class);
Hall Liu73903142021-02-18 18:41:41 -08003553 }
3554
3555 @NonNull
3556 public static final Creator<CallFilteringCompletionInfo> CREATOR =
3557 new Creator<CallFilteringCompletionInfo>() {
3558 @Override
3559 public CallFilteringCompletionInfo createFromParcel(Parcel in) {
3560 return new CallFilteringCompletionInfo(in);
3561 }
3562
3563 @Override
3564 public CallFilteringCompletionInfo[] newArray(int size) {
3565 return new CallFilteringCompletionInfo[size];
3566 }
3567 };
3568
3569 /**
3570 * @return Whether any part of the call filtering process indicated that this call should be
3571 * blocked.
3572 */
3573 public boolean isBlocked() {
3574 return mIsBlocked;
3575 }
3576
3577 /**
3578 * @return Whether the caller is in the user's contacts.
3579 */
3580 public boolean isInContacts() {
3581 return mIsInContacts;
3582 }
3583
3584 /**
3585 * @return The instance of {@link CallScreeningService.CallResponse} provided
3586 * by the {@link CallScreeningService} that processed this
3587 * call, or {@code null} if no call screening service ran.
3588 */
3589 public @Nullable CallScreeningService.CallResponse getCallResponse() {
3590 return mCallResponse;
3591 }
3592
3593 /**
3594 * @return The component of the {@link CallScreeningService}
3595 * that processed this call, or {@code null} if no call screening service ran.
3596 */
3597 public @Nullable ComponentName getCallScreeningComponent() {
3598 return mCallScreeningComponent;
3599 }
3600
3601 @Override
3602 public int describeContents() {
3603 return 0;
3604 }
3605
3606 @Override
3607 public String toString() {
3608 return "CallFilteringCompletionInfo{" +
3609 "mIsBlocked=" + mIsBlocked +
3610 ", mIsInContacts=" + mIsInContacts +
3611 ", mCallResponse=" + mCallResponse +
3612 ", mCallScreeningPackageName='" + mCallScreeningComponent + '\'' +
3613 '}';
3614 }
3615
3616 /** @hide */
3617 @Override
3618 public void writeToParcel(Parcel dest, int flags) {
3619 dest.writeByte((byte) (mIsBlocked ? 1 : 0));
3620 dest.writeByte((byte) (mIsInContacts ? 1 : 0));
3621 dest.writeParcelable(mCallResponse == null ? null : mCallResponse.toParcelable(), 0);
3622 dest.writeParcelable(mCallScreeningComponent, 0);
3623 }
3624 }
3625
3626 /**
Hall Liu49cabcc2021-01-15 11:41:48 -08003627 * Indicates that call filtering in Telecom is complete
3628 *
3629 * This method is called for a connection created via
3630 * {@link ConnectionService#onCreateIncomingConnection} when call filtering completes in
3631 * Telecom, including checking the blocked number db, per-contact settings, and custom call
3632 * filtering apps.
3633 *
Hall Liu73903142021-02-18 18:41:41 -08003634 * @param callFilteringCompletionInfo Info provided by Telecom on the results of call filtering.
Hall Liu49cabcc2021-01-15 11:41:48 -08003635 * @hide
3636 */
3637 @SystemApi
3638 @RequiresPermission(Manifest.permission.READ_CONTACTS)
Hall Liu73903142021-02-18 18:41:41 -08003639 public void onCallFilteringCompleted(
3640 @NonNull CallFilteringCompletionInfo callFilteringCompletionInfo) { }
Hall Liu49cabcc2021-01-15 11:41:48 -08003641
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003642 static String toLogSafePhoneNumber(String number) {
3643 // For unknown number, log empty string.
3644 if (number == null) {
3645 return "";
3646 }
3647
3648 if (PII_DEBUG) {
3649 // When PII_DEBUG is true we emit PII.
3650 return number;
3651 }
3652
3653 // Do exactly same thing as Uri#toSafeString() does, which will enable us to compare
3654 // sanitized phone numbers.
3655 StringBuilder builder = new StringBuilder();
3656 for (int i = 0; i < number.length(); i++) {
3657 char c = number.charAt(i);
3658 if (c == '-' || c == '@' || c == '.') {
3659 builder.append(c);
3660 } else {
3661 builder.append('x');
3662 }
3663 }
3664 return builder.toString();
3665 }
3666
Ihab Awad542e0ea2014-05-16 10:22:16 -07003667 private void setState(int state) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003668 checkImmutable();
Ihab Awad6107bab2014-08-18 09:23:25 -07003669 if (mState == STATE_DISCONNECTED && mState != state) {
3670 Log.d(this, "Connection already DISCONNECTED; cannot transition out of this state.");
Evan Charltonbf11f982014-07-20 22:06:28 -07003671 return;
Sailesh Nepal400cc482014-06-26 12:04:00 -07003672 }
Evan Charltonbf11f982014-07-20 22:06:28 -07003673 if (mState != state) {
3674 Log.d(this, "setState: %s", stateToString(state));
3675 mState = state;
Nancy Chen354b2bd2014-09-08 18:27:26 -07003676 onStateChanged(state);
Evan Charltonbf11f982014-07-20 22:06:28 -07003677 for (Listener l : mListeners) {
3678 l.onStateChanged(this, state);
3679 }
Evan Charltonbf11f982014-07-20 22:06:28 -07003680 }
3681 }
3682
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07003683 private static class FailureSignalingConnection extends Connection {
Ihab Awad90e34e32014-12-01 16:23:17 -08003684 private boolean mImmutable = false;
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003685 public FailureSignalingConnection(DisconnectCause disconnectCause) {
3686 setDisconnected(disconnectCause);
Tyler Gunn2915af72020-03-06 11:36:21 -08003687 mImmutable = true;
Ihab Awad6107bab2014-08-18 09:23:25 -07003688 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003689
3690 public void checkImmutable() {
Ihab Awad90e34e32014-12-01 16:23:17 -08003691 if (mImmutable) {
3692 throw new UnsupportedOperationException("Connection is immutable");
3693 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003694 }
Ihab Awad6107bab2014-08-18 09:23:25 -07003695 }
3696
Evan Charltonbf11f982014-07-20 22:06:28 -07003697 /**
Ihab Awad6107bab2014-08-18 09:23:25 -07003698 * Return a {@code Connection} which represents a failed connection attempt. The returned
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003699 * {@code Connection} will have a {@link android.telecom.DisconnectCause} and as specified,
3700 * and a {@link #getState()} of {@link #STATE_DISCONNECTED}.
Ihab Awad6107bab2014-08-18 09:23:25 -07003701 * <p>
3702 * The returned {@code Connection} can be assumed to {@link #destroy()} itself when appropriate,
3703 * so users of this method need not maintain a reference to its return value to destroy it.
Evan Charltonbf11f982014-07-20 22:06:28 -07003704 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003705 * @param disconnectCause The disconnect cause, ({@see android.telecomm.DisconnectCause}).
Ihab Awad6107bab2014-08-18 09:23:25 -07003706 * @return A {@code Connection} which indicates failure.
Evan Charltonbf11f982014-07-20 22:06:28 -07003707 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003708 public static Connection createFailedConnection(DisconnectCause disconnectCause) {
3709 return new FailureSignalingConnection(disconnectCause);
Evan Charltonbf11f982014-07-20 22:06:28 -07003710 }
3711
Evan Charltonbf11f982014-07-20 22:06:28 -07003712 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003713 * Override to throw an {@link UnsupportedOperationException} if this {@code Connection} is
3714 * not intended to be mutated, e.g., if it is a marker for failure. Only for framework use;
3715 * this should never be un-@hide-den.
3716 *
3717 * @hide
3718 */
3719 public void checkImmutable() {}
3720
3721 /**
Ihab Awad6107bab2014-08-18 09:23:25 -07003722 * Return a {@code Connection} which represents a canceled connection attempt. The returned
3723 * {@code Connection} will have state {@link #STATE_DISCONNECTED}, and cannot be moved out of
3724 * that state. This connection should not be used for anything, and no other
3725 * {@code Connection}s should be attempted.
3726 * <p>
Ihab Awad6107bab2014-08-18 09:23:25 -07003727 * so users of this method need not maintain a reference to its return value to destroy it.
Evan Charltonbf11f982014-07-20 22:06:28 -07003728 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003729 * @return A {@code Connection} which indicates that the underlying connection should
3730 * be canceled.
Evan Charltonbf11f982014-07-20 22:06:28 -07003731 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003732 public static Connection createCanceledConnection() {
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003733 return new FailureSignalingConnection(new DisconnectCause(DisconnectCause.CANCELED));
Ihab Awad542e0ea2014-05-16 10:22:16 -07003734 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003735
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003736 private final void fireOnConferenceableConnectionsChanged() {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003737 for (Listener l : mListeners) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003738 l.onConferenceablesChanged(this, getConferenceables());
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003739 }
3740 }
3741
Santos Cordon823fd3c2014-08-07 18:35:18 -07003742 private final void fireConferenceChanged() {
3743 for (Listener l : mListeners) {
3744 l.onConferenceChanged(this, mConference);
3745 }
3746 }
3747
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003748 private final void clearConferenceableList() {
Tyler Gunndf2cbc82015-04-20 09:13:01 -07003749 for (Conferenceable c : mConferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003750 if (c instanceof Connection) {
3751 Connection connection = (Connection) c;
3752 connection.removeConnectionListener(mConnectionDeathListener);
3753 } else if (c instanceof Conference) {
3754 Conference conference = (Conference) c;
3755 conference.removeListener(mConferenceDeathListener);
3756 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003757 }
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003758 mConferenceables.clear();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003759 }
Tyler Gunn3bffcf72014-10-28 13:51:27 -07003760
3761 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07003762 * Handles a change to extras received from Telecom.
3763 *
3764 * @param extras The new extras.
3765 * @hide
3766 */
3767 final void handleExtrasChanged(Bundle extras) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003768 Bundle b = null;
3769 synchronized (mExtrasLock) {
3770 mExtras = extras;
3771 if (mExtras != null) {
3772 b = new Bundle(mExtras);
3773 }
3774 }
3775 onExtrasChanged(b);
Tyler Gunndee56a82016-03-23 16:06:34 -07003776 }
3777
3778 /**
Tyler Gunnc63f9082019-10-15 13:19:26 -07003779 * Called by a {@link ConnectionService} to notify Telecom that a {@link Conference#onMerge()}
3780 * request failed.
Anthony Lee17455a32015-04-24 15:25:29 -07003781 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003782 public final void notifyConferenceMergeFailed() {
Anthony Lee17455a32015-04-24 15:25:29 -07003783 for (Listener l : mListeners) {
3784 l.onConferenceMergeFailed(this);
3785 }
3786 }
3787
3788 /**
Srikanth Chintalafcb15012017-05-04 20:58:34 +05303789 * Notifies listeners when phone account is changed. For example, when the PhoneAccount is
3790 * changed due to an emergency call being redialed.
3791 * @param pHandle The new PhoneAccountHandle for this connection.
3792 * @hide
3793 */
3794 public void notifyPhoneAccountChanged(PhoneAccountHandle pHandle) {
3795 for (Listener l : mListeners) {
3796 l.onPhoneAccountChanged(this, pHandle);
3797 }
3798 }
3799
3800 /**
Pengquan Meng70c9885332017-10-02 18:09:03 -07003801 * Sets the {@link PhoneAccountHandle} associated with this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003802 * <p>
3803 * Used by the Telephony {@link ConnectionService} to handle changes to the {@link PhoneAccount}
3804 * which take place after call initiation (important for emergency calling scenarios).
Pengquan Meng70c9885332017-10-02 18:09:03 -07003805 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07003806 * @param phoneAccountHandle the phone account handle to set.
Pengquan Meng70c9885332017-10-02 18:09:03 -07003807 * @hide
3808 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003809 @SystemApi
3810 public void setPhoneAccountHandle(@NonNull PhoneAccountHandle phoneAccountHandle) {
Pengquan Meng70c9885332017-10-02 18:09:03 -07003811 if (mPhoneAccountHandle != phoneAccountHandle) {
3812 mPhoneAccountHandle = phoneAccountHandle;
3813 notifyPhoneAccountChanged(phoneAccountHandle);
3814 }
3815 }
3816
3817 /**
3818 * Returns the {@link PhoneAccountHandle} associated with this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003819 * <p>
3820 * Used by the Telephony {@link ConnectionService} to handle changes to the {@link PhoneAccount}
3821 * which take place after call initiation (important for emergency calling scenarios).
Pengquan Meng70c9885332017-10-02 18:09:03 -07003822 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07003823 * @return the phone account handle specified via
3824 * {@link #setPhoneAccountHandle(PhoneAccountHandle)}, or {@code null} if none was set.
Pengquan Meng70c9885332017-10-02 18:09:03 -07003825 * @hide
3826 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003827 @SystemApi
3828 public @Nullable PhoneAccountHandle getPhoneAccountHandle() {
Pengquan Meng70c9885332017-10-02 18:09:03 -07003829 return mPhoneAccountHandle;
3830 }
3831
3832 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003833 * Sends an event associated with this {@code Connection} with associated event extras to the
3834 * {@link InCallService}.
3835 * <p>
3836 * Connection events are used to communicate point in time information from a
3837 * {@link ConnectionService} to a {@link InCallService} implementations. An example of a
3838 * custom connection event includes notifying the UI when a WIFI call has been handed over to
3839 * LTE, which the InCall UI might use to inform the user that billing charges may apply. The
3840 * Android Telephony framework will send the {@link #EVENT_CALL_MERGE_FAILED} connection event
3841 * when a call to {@link Call#mergeConference()} has failed to complete successfully. A
3842 * connection event could also be used to trigger UI in the {@link InCallService} which prompts
3843 * the user to make a choice (e.g. whether they want to incur roaming costs for making a call),
3844 * which is communicated back via {@link Call#sendCallEvent(String, Bundle)}.
3845 * <p>
3846 * Events are exposed to {@link InCallService} implementations via
3847 * {@link Call.Callback#onConnectionEvent(Call, String, Bundle)}.
3848 * <p>
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003849 * 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 -07003850 * The {@link ConnectionService} must assume that the In-Call UI could even chose to ignore
3851 * some events altogether.
3852 * <p>
3853 * Events should be fully qualified (e.g. {@code com.example.event.MY_EVENT}) to avoid
3854 * conflicts between {@link ConnectionService} implementations. Further, custom
3855 * {@link ConnectionService} implementations shall not re-purpose events in the
3856 * {@code android.*} namespace, nor shall they define new event types in this namespace. When
3857 * defining a custom event type, ensure the contents of the extras {@link Bundle} is clearly
3858 * defined. Extra keys for this bundle should be named similar to the event type (e.g.
3859 * {@code com.example.extra.MY_EXTRA}).
3860 * <p>
3861 * When defining events and the associated extras, it is important to keep their behavior
3862 * consistent when the associated {@link ConnectionService} is updated. Support for deprecated
3863 * events/extras should me maintained to ensure backwards compatibility with older
3864 * {@link InCallService} implementations which were built to support the older behavior.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003865 *
3866 * @param event The connection event.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003867 * @param extras Optional bundle containing extra information associated with the event.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003868 */
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003869 public void sendConnectionEvent(String event, Bundle extras) {
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003870 for (Listener l : mListeners) {
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07003871 l.onConnectionEvent(this, event, extras);
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003872 }
3873 }
Tyler Gunn6986a632019-06-25 13:45:32 -07003874
3875 /**
3876 * @return The direction of the call.
3877 * @hide
3878 */
3879 public final @Call.Details.CallDirection int getCallDirection() {
3880 return mCallDirection;
3881 }
3882
3883 /**
3884 * Sets the direction of this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003885 * <p>
3886 * Used when calling {@link ConnectionService#addExistingConnection} to specify the existing
3887 * call direction.
3888 *
Tyler Gunn6986a632019-06-25 13:45:32 -07003889 * @param callDirection The direction of this connection.
3890 * @hide
3891 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003892 @SystemApi
Tyler Gunn6986a632019-06-25 13:45:32 -07003893 public void setCallDirection(@Call.Details.CallDirection int callDirection) {
3894 mCallDirection = callDirection;
3895 }
Tyler Gunnd57d76c2019-09-24 14:53:23 -07003896
3897 /**
3898 * Gets the verification status for the phone number of an incoming call as identified in
3899 * ATIS-1000082.
3900 * @return the verification status.
3901 */
Tyler Gunna131d6e2020-02-13 14:53:28 -08003902 public final @VerificationStatus int getCallerNumberVerificationStatus() {
Tyler Gunnd57d76c2019-09-24 14:53:23 -07003903 return mCallerNumberVerificationStatus;
3904 }
3905
3906 /**
3907 * Sets the verification status for the phone number of an incoming call as identified in
3908 * ATIS-1000082.
3909 * <p>
3910 * This property can only be set at the time of creation of a {@link Connection} being returned
3911 * by
3912 * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)}.
3913 */
Tyler Gunna131d6e2020-02-13 14:53:28 -08003914 public final void setCallerNumberVerificationStatus(
Tyler Gunnd57d76c2019-09-24 14:53:23 -07003915 @VerificationStatus int callerNumberVerificationStatus) {
3916 mCallerNumberVerificationStatus = callerNumberVerificationStatus;
3917 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07003918}