blob: 49ad58550db8f738c13891d6921fc382b53ad227 [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 Sasindrand91b8122022-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
Tyler Gunn96d6c402015-03-18 12:39:23 -0700565 //**********************************************************************************************
Sooraj Sasindran64f05b12020-11-18 12:07:10 -0800566 // Next PROPERTY value: 1<<14
Tyler Gunn96d6c402015-03-18 12:39:23 -0700567 //**********************************************************************************************
Tyler Gunn068085b2015-02-06 13:56:52 -0800568
Tyler Gunn335ff2e2015-07-30 14:18:33 -0700569 /**
Tyler Gunn1c687622019-12-20 11:08:13 -0800570 * Indicates that the audio codec is currently not specified or is unknown.
allenwtsu2aca9892019-11-25 14:38:21 +0800571 */
allenwtsu2aca9892019-11-25 14:38:21 +0800572 public static final int AUDIO_CODEC_NONE = ImsStreamMediaProfile.AUDIO_QUALITY_NONE; // 0
Tyler Gunn1c687622019-12-20 11:08:13 -0800573 /**
574 * Adaptive Multi-rate audio codec.
575 */
allenwtsu2aca9892019-11-25 14:38:21 +0800576 public static final int AUDIO_CODEC_AMR = ImsStreamMediaProfile.AUDIO_QUALITY_AMR; // 1
Tyler Gunn1c687622019-12-20 11:08:13 -0800577 /**
578 * Adaptive Multi-rate wideband audio codec.
579 */
allenwtsu2aca9892019-11-25 14:38:21 +0800580 public static final int AUDIO_CODEC_AMR_WB = ImsStreamMediaProfile.AUDIO_QUALITY_AMR_WB; // 2
Tyler Gunn1c687622019-12-20 11:08:13 -0800581 /**
582 * Qualcomm code-excited linear prediction 13 kilobit audio codec.
583 */
allenwtsu2aca9892019-11-25 14:38:21 +0800584 public static final int AUDIO_CODEC_QCELP13K = ImsStreamMediaProfile.AUDIO_QUALITY_QCELP13K; //3
Tyler Gunn1c687622019-12-20 11:08:13 -0800585 /**
586 * Enhanced Variable Rate Codec. See 3GPP2 C.S0014-A.
587 */
allenwtsu2aca9892019-11-25 14:38:21 +0800588 public static final int AUDIO_CODEC_EVRC = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC; // 4
Tyler Gunn1c687622019-12-20 11:08:13 -0800589 /**
590 * Enhanced Variable Rate Codec B. Commonly used on CDMA networks.
591 */
allenwtsu2aca9892019-11-25 14:38:21 +0800592 public static final int AUDIO_CODEC_EVRC_B = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_B; // 5
Tyler Gunn1c687622019-12-20 11:08:13 -0800593 /**
594 * Enhanced Variable Rate Wideband Codec. See RFC5188.
595 */
allenwtsu2aca9892019-11-25 14:38:21 +0800596 public static final int AUDIO_CODEC_EVRC_WB = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_WB; // 6
Tyler Gunn1c687622019-12-20 11:08:13 -0800597 /**
598 * Enhanced Variable Rate Narrowband-Wideband Codec.
599 */
allenwtsu2aca9892019-11-25 14:38:21 +0800600 public static final int AUDIO_CODEC_EVRC_NW = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_NW; // 7
Tyler Gunn1c687622019-12-20 11:08:13 -0800601 /**
602 * GSM Enhanced Full-Rate audio codec, also known as GSM-EFR, GSM 06.60, or simply EFR.
603 */
allenwtsu2aca9892019-11-25 14:38:21 +0800604 public static final int AUDIO_CODEC_GSM_EFR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_EFR; // 8
Tyler Gunn1c687622019-12-20 11:08:13 -0800605 /**
606 * GSM Full-Rate audio codec, also known as GSM-FR, GSM 06.10, GSM, or simply FR.
607 */
allenwtsu2aca9892019-11-25 14:38:21 +0800608 public static final int AUDIO_CODEC_GSM_FR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_FR; // 9
Tyler Gunn1c687622019-12-20 11:08:13 -0800609 /**
610 * GSM Half Rate audio codec.
611 */
allenwtsu2aca9892019-11-25 14:38:21 +0800612 public static final int AUDIO_CODEC_GSM_HR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_HR; // 10
Tyler Gunn1c687622019-12-20 11:08:13 -0800613 /**
614 * ITU-T G711U audio codec.
615 */
allenwtsu2aca9892019-11-25 14:38:21 +0800616 public static final int AUDIO_CODEC_G711U = ImsStreamMediaProfile.AUDIO_QUALITY_G711U; // 11
Tyler Gunn1c687622019-12-20 11:08:13 -0800617 /**
618 * ITU-T G723 audio codec.
619 */
allenwtsu2aca9892019-11-25 14:38:21 +0800620 public static final int AUDIO_CODEC_G723 = ImsStreamMediaProfile.AUDIO_QUALITY_G723; // 12
Tyler Gunn1c687622019-12-20 11:08:13 -0800621 /**
622 * ITU-T G711A audio codec.
623 */
allenwtsu2aca9892019-11-25 14:38:21 +0800624 public static final int AUDIO_CODEC_G711A = ImsStreamMediaProfile.AUDIO_QUALITY_G711A; // 13
Tyler Gunn1c687622019-12-20 11:08:13 -0800625 /**
626 * ITU-T G722 audio codec.
627 */
allenwtsu2aca9892019-11-25 14:38:21 +0800628 public static final int AUDIO_CODEC_G722 = ImsStreamMediaProfile.AUDIO_QUALITY_G722; // 14
Tyler Gunn1c687622019-12-20 11:08:13 -0800629 /**
630 * ITU-T G711AB audio codec.
631 */
allenwtsu2aca9892019-11-25 14:38:21 +0800632 public static final int AUDIO_CODEC_G711AB = ImsStreamMediaProfile.AUDIO_QUALITY_G711AB; // 15
Tyler Gunn1c687622019-12-20 11:08:13 -0800633 /**
634 * ITU-T G729 audio codec.
635 */
allenwtsu2aca9892019-11-25 14:38:21 +0800636 public static final int AUDIO_CODEC_G729 = ImsStreamMediaProfile.AUDIO_QUALITY_G729; // 16
Tyler Gunn1c687622019-12-20 11:08:13 -0800637 /**
638 * Enhanced Voice Services Narrowband audio codec. See 3GPP TS 26.441.
639 */
allenwtsu2aca9892019-11-25 14:38:21 +0800640 public static final int AUDIO_CODEC_EVS_NB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_NB; // 17
Tyler Gunn1c687622019-12-20 11:08:13 -0800641 /**
642 * Enhanced Voice Services Wideband audio codec. See 3GPP TS 26.441.
643 */
allenwtsu2aca9892019-11-25 14:38:21 +0800644 public static final int AUDIO_CODEC_EVS_WB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_WB; // 18
Tyler Gunn1c687622019-12-20 11:08:13 -0800645 /**
646 * Enhanced Voice Services Super-Wideband audio codec. See 3GPP TS 26.441.
647 */
allenwtsu2aca9892019-11-25 14:38:21 +0800648 public static final int AUDIO_CODEC_EVS_SWB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_SWB; // 19
Tyler Gunn1c687622019-12-20 11:08:13 -0800649 /**
650 * Enhanced Voice Services Fullband audio codec. See 3GPP TS 26.441.
651 */
allenwtsu2aca9892019-11-25 14:38:21 +0800652 public static final int AUDIO_CODEC_EVS_FB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_FB; // 20
653
Tyler Gunn1c687622019-12-20 11:08:13 -0800654 /**@hide*/
655 @Retention(RetentionPolicy.SOURCE)
656 @IntDef(prefix = "AUDIO_CODEC_", value = {
657 AUDIO_CODEC_NONE,
658 AUDIO_CODEC_AMR,
659 AUDIO_CODEC_AMR_WB,
660 AUDIO_CODEC_QCELP13K,
661 AUDIO_CODEC_EVRC,
662 AUDIO_CODEC_EVRC_B,
663 AUDIO_CODEC_EVRC_WB,
664 AUDIO_CODEC_EVRC_NW,
665 AUDIO_CODEC_GSM_EFR,
666 AUDIO_CODEC_GSM_FR,
667 AUDIO_CODEC_GSM_HR,
668 AUDIO_CODEC_G711U,
669 AUDIO_CODEC_G723,
670 AUDIO_CODEC_G711A,
671 AUDIO_CODEC_G722,
672 AUDIO_CODEC_G711AB,
673 AUDIO_CODEC_G729,
674 AUDIO_CODEC_EVS_NB,
675 AUDIO_CODEC_EVS_SWB,
676 AUDIO_CODEC_EVS_FB
677 })
678 public @interface AudioCodec {}
679
allenwtsu2aca9892019-11-25 14:38:21 +0800680 /**
Tyler Gunn60e5eb62021-07-01 16:55:32 -0700681 * Contains the same value as {@link #getCallerNumberVerificationStatus()}, except will be
682 * present in the {@link #getExtras()} using this key.
683 * @hide
684 */
685 public static final String EXTRA_CALLER_NUMBER_VERIFICATION_STATUS =
686 "android.telecom.extra.CALLER_NUMBER_VERIFICATION_STATUS";
687
688 /**
Tyler Gunn335ff2e2015-07-30 14:18:33 -0700689 * Connection extra key used to store the last forwarded number associated with the current
690 * connection. Used to communicate to the user interface that the connection was forwarded via
691 * the specified number.
692 */
693 public static final String EXTRA_LAST_FORWARDED_NUMBER =
694 "android.telecom.extra.LAST_FORWARDED_NUMBER";
695
696 /**
697 * Connection extra key used to store a child number associated with the current connection.
698 * Used to communicate to the user interface that the connection was received via
699 * a child address (i.e. phone number) associated with the {@link PhoneAccount}'s primary
700 * address.
701 */
702 public static final String EXTRA_CHILD_ADDRESS = "android.telecom.extra.CHILD_ADDRESS";
703
704 /**
705 * Connection extra key used to store the subject for an incoming call. The user interface can
706 * query this extra and display its contents for incoming calls. Will only be used if the
707 * {@link PhoneAccount} supports the capability {@link PhoneAccount#CAPABILITY_CALL_SUBJECT}.
708 */
709 public static final String EXTRA_CALL_SUBJECT = "android.telecom.extra.CALL_SUBJECT";
710
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800711 /**
Tyler Gunn4b6614e2016-06-22 10:35:13 -0700712 * Boolean connection extra key set on a {@link Connection} in
713 * {@link Connection#STATE_RINGING} state to indicate that answering the call will cause the
714 * current active foreground call to be dropped.
715 */
716 public static final String EXTRA_ANSWERING_DROPS_FG_CALL =
717 "android.telecom.extra.ANSWERING_DROPS_FG_CALL";
718
719 /**
Tyler Gunn37653562017-03-13 18:15:15 -0700720 * String connection extra key set on a {@link Connection} in {@link Connection#STATE_RINGING}
721 * state to indicate the name of the third-party app which is responsible for the current
722 * foreground call.
723 * <p>
724 * Used when {@link #EXTRA_ANSWERING_DROPS_FG_CALL} is true to ensure that the default Phone app
725 * is able to inform the user that answering the new incoming call will cause a call owned by
726 * another app to be dropped when the incoming call is answered.
727 */
728 public static final String EXTRA_ANSWERING_DROPS_FG_CALL_APP_NAME =
729 "android.telecom.extra.ANSWERING_DROPS_FG_CALL_APP_NAME";
730
731 /**
Hall Liu10208662016-06-15 17:55:00 -0700732 * Boolean connection extra key on a {@link Connection} which indicates that adding an
Hall Liuee6e86b2016-07-06 16:32:43 -0700733 * additional call is disallowed.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700734 * <p>
735 * Used for mobile-network calls to identify scenarios where carrier requirements preclude
736 * adding another call at the current time.
Hall Liu10208662016-06-15 17:55:00 -0700737 * @hide
738 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700739 @SystemApi
Hall Liuee6e86b2016-07-06 16:32:43 -0700740 public static final String EXTRA_DISABLE_ADD_CALL =
741 "android.telecom.extra.DISABLE_ADD_CALL";
Hall Liu10208662016-06-15 17:55:00 -0700742
743 /**
Tyler Gunncd6ccfd2016-10-17 15:48:19 -0700744 * String connection extra key on a {@link Connection} or {@link Conference} which contains the
745 * original Connection ID associated with the connection. Used in
746 * {@link RemoteConnectionService} to track the Connection ID which was originally assigned to a
747 * connection/conference added via
748 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)} and
749 * {@link ConnectionService#addConference(Conference)} APIs. This is important to pass to
750 * Telecom for when it deals with RemoteConnections. When the ConnectionManager wraps the
751 * {@link RemoteConnection} and {@link RemoteConference} and adds it to Telecom, there needs to
752 * be a way to ensure that we don't add the connection again as a duplicate.
753 * <p>
754 * For example, the TelephonyCS calls addExistingConnection for a Connection with ID
755 * {@code TelephonyCS@1}. The ConnectionManager learns of this via
756 * {@link ConnectionService#onRemoteExistingConnectionAdded(RemoteConnection)}, and wraps this
757 * in a new {@link Connection} which it adds to Telecom via
758 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)}. As part of
759 * this process, the wrapped RemoteConnection gets assigned a new ID (e.g. {@code ConnMan@1}).
760 * The TelephonyCS will ALSO try to add the existing connection to Telecom, except with the
761 * ID it originally referred to the connection as. Thus Telecom needs to know that the
762 * Connection with ID {@code ConnMan@1} is really the same as {@code TelephonyCS@1}.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700763 * <p>
764 * This is an internal Telecom framework concept and is not exposed outside of the Telecom
765 * framework.
Tyler Gunncd6ccfd2016-10-17 15:48:19 -0700766 * @hide
767 */
768 public static final String EXTRA_ORIGINAL_CONNECTION_ID =
769 "android.telecom.extra.ORIGINAL_CONNECTION_ID";
770
771 /**
Tyler Gunnc59fd0c2020-04-17 14:03:35 -0700772 * Extra key set on a {@link Connection} when it was created via a remote connection service.
773 * For example, if a connection manager requests a remote connection service to create a call
774 * using one of the remote connection service's phone account handle, this extra will be set so
775 * that Telecom knows that the wrapped remote connection originated in a remote connection
776 * service. We stash this in the extras since connection managers will typically copy the
777 * extras from a {@link RemoteConnection} to a {@link Connection} (there is ultimately not
778 * other way to relate a {@link RemoteConnection} to a {@link Connection}.
779 * @hide
780 */
781 public static final String EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE =
782 "android.telecom.extra.REMOTE_PHONE_ACCOUNT_HANDLE";
783
784 /**
Tyler Gunnfdc4bff2021-06-24 11:25:07 -0700785 * The Telecom call ID of the conference an existing connection should be added to. This is
786 * required when {@link com.android.services.telephony.TelephonyConnectionService} adds a
787 * {@link Conference} to Telecom using the
788 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection, Conference)}
789 * API. That API specifies a parent conference associated with the new existing connection
790 * being added, and there is no equivalent as part of the {@link RemoteConnectionService} API.
791 * This extra key is used to stack the ID of the conference to which the existing connection
792 * will be added so that Telecom can link it up correctly when the {@link RemoteConference}
793 * is added to Telecom by the connection manager.
794 * @hide
795 */
796 public static final String EXTRA_ADD_TO_CONFERENCE_ID =
797 "android.telecom.extra.ADD_TO_CONFERENCE_ID";
798
799 /**
Tyler Gunnc59fd0c2020-04-17 14:03:35 -0700800 * Extra key set from a {@link ConnectionService} when using the remote connection APIs
801 * (e.g. {@link RemoteConnectionService#createRemoteConnection(PhoneAccountHandle,
802 * ConnectionRequest, boolean)}) to create a remote connection. Provides the receiving
803 * {@link ConnectionService} with a means to know the package name of the requesting
804 * {@link ConnectionService} so that {@link #EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE} can be set for
805 * better visibility in Telecom of where a connection ultimately originated.
806 * @hide
807 */
808 public static final String EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME =
809 "android.telecom.extra.REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME";
810
811 /**
Wileen Chiuf2ec2982018-07-01 14:21:50 -0700812 * Boolean connection extra key set on the extras passed to
813 * {@link Connection#sendConnectionEvent} which indicates that audio is present
814 * on the RTT call when the extra value is true.
815 */
816 public static final String EXTRA_IS_RTT_AUDIO_PRESENT =
817 "android.telecom.extra.IS_RTT_AUDIO_PRESENT";
818
819 /**
Tyler Gunn1c687622019-12-20 11:08:13 -0800820 * The audio codec in use for the current {@link Connection}, if known. Examples of valid
821 * values include {@link #AUDIO_CODEC_AMR_WB} and {@link #AUDIO_CODEC_EVS_WB}.
allenwtsu2aca9892019-11-25 14:38:21 +0800822 */
Tyler Gunn1c687622019-12-20 11:08:13 -0800823 public static final @AudioCodec String EXTRA_AUDIO_CODEC =
allenwtsu2aca9892019-11-25 14:38:21 +0800824 "android.telecom.extra.AUDIO_CODEC";
825
826 /**
allenwtsu6ec972a2020-11-10 17:32:46 +0800827 * Float connection extra key used to store the audio codec bitrate in kbps for the current
828 * {@link Connection}.
829 */
830 public static final String EXTRA_AUDIO_CODEC_BITRATE_KBPS =
831 "android.telecom.extra.AUDIO_CODEC_BITRATE_KBPS";
832
833 /**
834 * Float connection extra key used to store the audio codec bandwidth in khz for the current
835 * {@link Connection}.
836 */
837 public static final String EXTRA_AUDIO_CODEC_BANDWIDTH_KHZ =
838 "android.telecom.extra.AUDIO_CODEC_BANDWIDTH_KHZ";
Tyler Gunn78a59ff2021-05-07 16:41:19 -0700839
840 /**
Sooraj Sasindrand91b8122022-02-24 00:14:51 -0800841 * Last known cell identity key {@link CellIdentity} to be used to fill geo location header
842 * in case of an emergency call. This entry will not be filled if call is not identified as
843 * an emergency call. Only provided to the {@link ConnectionService} for the purpose of
844 * placing an emergency call; will not be present in the {@link InCallService} layer.
Sooraj Sasindran81be0822021-10-26 02:03:37 -0700845 * The {@link ConnectionService}'s implementation will be logged for fine location access
846 * when an outgoing call is placed in this case.
847 */
848 public static final String EXTRA_LAST_KNOWN_CELL_IDENTITY =
849 "android.telecom.extra.LAST_KNOWN_CELL_IDENTITY";
850
851 /**
Tyler Gunn78a59ff2021-05-07 16:41:19 -0700852 * Boolean connection extra key used to indicate whether device to device communication is
853 * available for the current call.
854 * @hide
855 */
856 public static final String EXTRA_IS_DEVICE_TO_DEVICE_COMMUNICATION_AVAILABLE =
857 "android.telecom.extra.IS_DEVICE_TO_DEVICE_COMMUNICATION_AVAILABLE";
858
allenwtsu6ec972a2020-11-10 17:32:46 +0800859 /**
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800860 * Connection event used to inform Telecom that it should play the on hold tone. This is used
861 * to play a tone when the peer puts the current call on hold. Sent to Telecom via
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700862 * {@link #sendConnectionEvent(String, Bundle)}.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800863 */
864 public static final String EVENT_ON_HOLD_TONE_START =
865 "android.telecom.event.ON_HOLD_TONE_START";
866
867 /**
868 * Connection event used to inform Telecom that it should stop the on hold tone. This is used
869 * to stop a tone when the peer puts the current call on hold. Sent to Telecom via
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700870 * {@link #sendConnectionEvent(String, Bundle)}.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800871 */
872 public static final String EVENT_ON_HOLD_TONE_END =
873 "android.telecom.event.ON_HOLD_TONE_END";
874
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700875 /**
876 * Connection event used to inform {@link InCallService}s when pulling of an external call has
877 * failed. The user interface should inform the user of the error.
878 * <p>
879 * Expected to be used by the {@link ConnectionService} when the {@link Call#pullExternalCall()}
880 * API is called on a {@link Call} with the properties
881 * {@link Call.Details#PROPERTY_IS_EXTERNAL_CALL} and
882 * {@link Call.Details#CAPABILITY_CAN_PULL_CALL}, but the {@link ConnectionService} could not
883 * pull the external call due to an error condition.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700884 * <p>
885 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
886 * expected to be null when this connection event is used.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700887 */
888 public static final String EVENT_CALL_PULL_FAILED = "android.telecom.event.CALL_PULL_FAILED";
889
Brad Ebinger2c1c16452016-05-27 15:58:10 -0700890 /**
891 * Connection event used to inform {@link InCallService}s when the merging of two calls has
892 * failed. The User Interface should use this message to inform the user of the error.
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.
Brad Ebinger2c1c16452016-05-27 15:58:10 -0700896 */
897 public static final String EVENT_CALL_MERGE_FAILED = "android.telecom.event.CALL_MERGE_FAILED";
898
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700899 /**
Hall Liu06ae75b2019-03-11 19:11:35 -0700900 * Connection event used to inform Telecom when a hold operation on a call has failed.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700901 * <p>
Hall Liu06ae75b2019-03-11 19:11:35 -0700902 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
903 * expected to be null when this connection event is used.
Hall Liu06ae75b2019-03-11 19:11:35 -0700904 */
905 public static final String EVENT_CALL_HOLD_FAILED = "android.telecom.event.CALL_HOLD_FAILED";
906
907 /**
Masaho Nishikawacb8fa742019-11-07 14:41:21 +0900908 * Connection event used to inform Telecom when a switch operation on a call has failed.
909 * <p>
910 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
911 * expected to be null when this connection event is used.
912 */
913 public static final String EVENT_CALL_SWITCH_FAILED =
914 "android.telecom.event.CALL_SWITCH_FAILED";
915
916 /**
Tyler Gunn78da7812017-05-09 14:34:57 -0700917 * Connection event used to inform {@link InCallService}s when the process of merging a
918 * Connection into a conference has begun.
919 * <p>
920 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
921 * expected to be null when this connection event is used.
Tyler Gunn78da7812017-05-09 14:34:57 -0700922 */
923 public static final String EVENT_MERGE_START = "android.telecom.event.MERGE_START";
924
925 /**
926 * Connection event used to inform {@link InCallService}s when the process of merging a
927 * Connection into a conference has completed.
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_COMPLETE = "android.telecom.event.MERGE_COMPLETE";
933
934 /**
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700935 * Connection event used to inform {@link InCallService}s when a call has been put on hold by
936 * the remote party.
937 * <p>
938 * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the
939 * call is being held locally on the device. When a capable {@link ConnectionService} receives
940 * signalling to indicate that the remote party has put the call on hold, it can send this
941 * connection event.
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700942 */
943 public static final String EVENT_CALL_REMOTELY_HELD =
944 "android.telecom.event.CALL_REMOTELY_HELD";
945
946 /**
947 * Connection event used to inform {@link InCallService}s when a call which was remotely held
948 * (see {@link #EVENT_CALL_REMOTELY_HELD}) has been un-held by the remote party.
949 * <p>
950 * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the
951 * call is being held locally on the device. When a capable {@link ConnectionService} receives
952 * signalling to indicate that the remote party has taken the call off hold, it can send this
953 * connection event.
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700954 */
955 public static final String EVENT_CALL_REMOTELY_UNHELD =
956 "android.telecom.event.CALL_REMOTELY_UNHELD";
957
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700958 /**
959 * Connection event used to inform an {@link InCallService} which initiated a call handover via
960 * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has
961 * successfully completed.
962 * @hide
Tyler Gunn1a505fa2018-09-14 13:36:38 -0700963 * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated
964 * APIs instead.
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700965 */
966 public static final String EVENT_HANDOVER_COMPLETE =
967 "android.telecom.event.HANDOVER_COMPLETE";
968
969 /**
970 * Connection event used to inform an {@link InCallService} which initiated a call handover via
971 * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has failed
972 * to complete.
973 * @hide
Tyler Gunn1a505fa2018-09-14 13:36:38 -0700974 * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated
975 * APIs instead.
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700976 */
977 public static final String EVENT_HANDOVER_FAILED =
978 "android.telecom.event.HANDOVER_FAILED";
979
shilub7ec9a02018-11-09 15:52:04 -0800980 /**
Shi Lu528eb5b2019-02-08 05:09:11 +0000981 * String Connection extra key used to store SIP invite fields for an incoming call for IMS call
shilub7ec9a02018-11-09 15:52:04 -0800982 */
983 public static final String EXTRA_SIP_INVITE = "android.telecom.extra.SIP_INVITE";
984
Wileen Chiuf2ec2982018-07-01 14:21:50 -0700985 /**
986 * Connection event used to inform an {@link InCallService} that the RTT audio indication
987 * has changed.
988 */
989 public static final String EVENT_RTT_AUDIO_INDICATION_CHANGED =
990 "android.telecom.event.RTT_AUDIO_INDICATION_CHANGED";
991
Tyler Gunnd5821842021-02-05 11:12:57 -0800992 /**
993 * Connection event used to signal between the telephony {@link ConnectionService} and Telecom
994 * when device to device messages are sent/received.
995 * <p>
996 * Device to device messages originating from the network are sent by telephony using
997 * {@link Connection#sendConnectionEvent(String, Bundle)} and are routed up to any active
998 * {@link CallDiagnosticService} implementation which is active.
999 * <p>
1000 * Likewise, if a {@link CallDiagnosticService} sends a message using
Tyler Gunn066de602021-03-16 09:58:07 -07001001 * {@link CallDiagnostics#sendDeviceToDeviceMessage(int, int)}, it will be routed to telephony
Tyler Gunnd5821842021-02-05 11:12:57 -08001002 * via {@link Connection#onCallEvent(String, Bundle)}. The telephony stack will relay the
1003 * message to the other device.
1004 * @hide
1005 */
1006 @SystemApi
1007 public static final String EVENT_DEVICE_TO_DEVICE_MESSAGE =
1008 "android.telecom.event.DEVICE_TO_DEVICE_MESSAGE";
1009
1010 /**
1011 * Sent along with {@link #EVENT_DEVICE_TO_DEVICE_MESSAGE} to indicate the device to device
1012 * message type.
1013 *
Tyler Gunn066de602021-03-16 09:58:07 -07001014 * See {@link CallDiagnostics} for more information.
Tyler Gunnd5821842021-02-05 11:12:57 -08001015 * @hide
1016 */
1017 @SystemApi
1018 public static final String EXTRA_DEVICE_TO_DEVICE_MESSAGE_TYPE =
1019 "android.telecom.extra.DEVICE_TO_DEVICE_MESSAGE_TYPE";
1020
1021 /**
1022 * Sent along with {@link #EVENT_DEVICE_TO_DEVICE_MESSAGE} to indicate the device to device
1023 * message value.
1024 * <p>
Tyler Gunn066de602021-03-16 09:58:07 -07001025 * See {@link CallDiagnostics} for more information.
Tyler Gunnd5821842021-02-05 11:12:57 -08001026 * @hide
1027 */
1028 @SystemApi
1029 public static final String EXTRA_DEVICE_TO_DEVICE_MESSAGE_VALUE =
1030 "android.telecom.extra.DEVICE_TO_DEVICE_MESSAGE_VALUE";
1031
Tyler Gunn0a1c6d12021-03-12 15:44:08 -08001032 /**
1033 * Connection event used to communicate a {@link android.telephony.CallQuality} report from
1034 * telephony to Telecom for relaying to
1035 * {@link DiagnosticCall#onCallQualityReceived(CallQuality)}.
1036 * @hide
1037 */
1038 public static final String EVENT_CALL_QUALITY_REPORT =
1039 "android.telecom.event.CALL_QUALITY_REPORT";
1040
1041 /**
1042 * Extra sent with {@link #EVENT_CALL_QUALITY_REPORT} containing the
1043 * {@link android.telephony.CallQuality} data.
1044 * @hide
1045 */
1046 public static final String EXTRA_CALL_QUALITY_REPORT =
1047 "android.telecom.extra.CALL_QUALITY_REPORT";
1048
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001049 // Flag controlling whether PII is emitted into the logs
1050 private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG);
1051
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001052 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07001053 * Renders a set of capability bits ({@code CAPABILITY_*}) as a human readable string.
1054 *
1055 * @param capabilities A capability bit field.
1056 * @return A human readable string representation.
1057 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001058 public static String capabilitiesToString(int capabilities) {
Santos Cordon1a749302016-07-26 16:08:53 -07001059 return capabilitiesToStringInternal(capabilities, true /* isLong */);
1060 }
1061
1062 /**
1063 * Renders a set of capability bits ({@code CAPABILITY_*}) as a *short* human readable
1064 * string.
1065 *
1066 * @param capabilities A capability bit field.
1067 * @return A human readable string representation.
1068 * @hide
1069 */
1070 public static String capabilitiesToStringShort(int capabilities) {
1071 return capabilitiesToStringInternal(capabilities, false /* isLong */);
1072 }
1073
1074 private static String capabilitiesToStringInternal(int capabilities, boolean isLong) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001075 StringBuilder builder = new StringBuilder();
Santos Cordon1a749302016-07-26 16:08:53 -07001076 builder.append("[");
1077 if (isLong) {
1078 builder.append("Capabilities:");
1079 }
1080
Tyler Gunnc63f9082019-10-15 13:19:26 -07001081 if ((capabilities & CAPABILITY_HOLD) == CAPABILITY_HOLD) {
Santos Cordon1a749302016-07-26 16:08:53 -07001082 builder.append(isLong ? " CAPABILITY_HOLD" : " hld");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001083 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001084 if ((capabilities & CAPABILITY_SUPPORT_HOLD) == CAPABILITY_SUPPORT_HOLD) {
Santos Cordon1a749302016-07-26 16:08:53 -07001085 builder.append(isLong ? " CAPABILITY_SUPPORT_HOLD" : " sup_hld");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001086 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001087 if ((capabilities & CAPABILITY_MERGE_CONFERENCE) == CAPABILITY_MERGE_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001088 builder.append(isLong ? " CAPABILITY_MERGE_CONFERENCE" : " mrg_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001089 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001090 if ((capabilities & CAPABILITY_SWAP_CONFERENCE) == CAPABILITY_SWAP_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001091 builder.append(isLong ? " CAPABILITY_SWAP_CONFERENCE" : " swp_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001092 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001093 if ((capabilities & CAPABILITY_RESPOND_VIA_TEXT) == CAPABILITY_RESPOND_VIA_TEXT) {
Santos Cordon1a749302016-07-26 16:08:53 -07001094 builder.append(isLong ? " CAPABILITY_RESPOND_VIA_TEXT" : " txt");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001095 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001096 if ((capabilities & CAPABILITY_MUTE) == CAPABILITY_MUTE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001097 builder.append(isLong ? " CAPABILITY_MUTE" : " mut");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001098 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001099 if ((capabilities & CAPABILITY_MANAGE_CONFERENCE) == CAPABILITY_MANAGE_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001100 builder.append(isLong ? " CAPABILITY_MANAGE_CONFERENCE" : " mng_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001101 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001102 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_RX) == CAPABILITY_SUPPORTS_VT_LOCAL_RX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001103 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_RX" : " VTlrx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001104 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001105 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_TX) == CAPABILITY_SUPPORTS_VT_LOCAL_TX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001106 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_TX" : " VTltx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001107 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001108 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL)
1109 == CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001110 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL" : " VTlbi");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001111 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001112 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_RX) == CAPABILITY_SUPPORTS_VT_REMOTE_RX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001113 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_RX" : " VTrrx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001114 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001115 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_TX) == CAPABILITY_SUPPORTS_VT_REMOTE_TX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001116 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_TX" : " VTrtx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001117 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001118 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL)
1119 == CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001120 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL" : " VTrbi");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001121 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001122 if ((capabilities & CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO)
1123 == CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001124 builder.append(isLong ? " CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO" : " !v2a");
Tyler Gunnf97a0092016-01-19 15:59:34 -08001125 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001126 if ((capabilities & CAPABILITY_SPEED_UP_MT_AUDIO) == CAPABILITY_SPEED_UP_MT_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001127 builder.append(isLong ? " CAPABILITY_SPEED_UP_MT_AUDIO" : " spd_aud");
Dong Zhou89f41eb2015-03-15 11:59:49 -05001128 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001129 if ((capabilities & CAPABILITY_CAN_UPGRADE_TO_VIDEO) == CAPABILITY_CAN_UPGRADE_TO_VIDEO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001130 builder.append(isLong ? " CAPABILITY_CAN_UPGRADE_TO_VIDEO" : " a2v");
Rekha Kumar07366812015-03-24 16:42:31 -07001131 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001132 if ((capabilities & CAPABILITY_CAN_PAUSE_VIDEO) == CAPABILITY_CAN_PAUSE_VIDEO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001133 builder.append(isLong ? " CAPABILITY_CAN_PAUSE_VIDEO" : " paus_VT");
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -07001134 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001135 if ((capabilities & CAPABILITY_CONFERENCE_HAS_NO_CHILDREN)
1136 == CAPABILITY_CONFERENCE_HAS_NO_CHILDREN) {
Santos Cordon1a749302016-07-26 16:08:53 -07001137 builder.append(isLong ? " CAPABILITY_SINGLE_PARTY_CONFERENCE" : " 1p_cnf");
Tyler Gunnd4091732015-06-29 09:15:37 -07001138 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001139 if ((capabilities & CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION)
1140 == CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION) {
Santos Cordon1a749302016-07-26 16:08:53 -07001141 builder.append(isLong ? " CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION" : " rsp_by_con");
Bryce Lee81901682015-08-28 16:38:02 -07001142 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001143 if ((capabilities & CAPABILITY_CAN_PULL_CALL) == CAPABILITY_CAN_PULL_CALL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001144 builder.append(isLong ? " CAPABILITY_CAN_PULL_CALL" : " pull");
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001145 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001146 if ((capabilities & CAPABILITY_SUPPORT_DEFLECT) == CAPABILITY_SUPPORT_DEFLECT) {
Pooja Jaind34698d2017-12-28 14:15:31 +05301147 builder.append(isLong ? " CAPABILITY_SUPPORT_DEFLECT" : " sup_def");
1148 }
Ravi Paluri404babb2020-01-23 19:02:44 +05301149 if ((capabilities & CAPABILITY_ADD_PARTICIPANT) == CAPABILITY_ADD_PARTICIPANT) {
1150 builder.append(isLong ? " CAPABILITY_ADD_PARTICIPANT" : " add_participant");
1151 }
Ravi Palurif4b38e72020-02-05 12:35:41 +05301152 if ((capabilities & CAPABILITY_TRANSFER) == CAPABILITY_TRANSFER) {
1153 builder.append(isLong ? " CAPABILITY_TRANSFER" : " sup_trans");
1154 }
1155 if ((capabilities & CAPABILITY_TRANSFER_CONSULTATIVE)
1156 == CAPABILITY_TRANSFER_CONSULTATIVE) {
1157 builder.append(isLong ? " CAPABILITY_TRANSFER_CONSULTATIVE" : " sup_cTrans");
1158 }
Alvin Dey2f37d772018-05-18 23:16:10 +05301159 if ((capabilities & CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT)
1160 == CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT) {
1161 builder.append(isLong ? " CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT" : " sup_rtt");
1162 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001163 builder.append("]");
1164 return builder.toString();
1165 }
1166
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07001167 /**
1168 * Renders a set of property bits ({@code PROPERTY_*}) as a human readable string.
1169 *
1170 * @param properties A property bit field.
1171 * @return A human readable string representation.
1172 */
Tyler Gunn720c6642016-03-22 09:02:47 -07001173 public static String propertiesToString(int properties) {
Santos Cordon1a749302016-07-26 16:08:53 -07001174 return propertiesToStringInternal(properties, true /* isLong */);
1175 }
1176
1177 /**
1178 * Renders a set of property bits ({@code PROPERTY_*}) as a *short* human readable string.
1179 *
1180 * @param properties A property bit field.
1181 * @return A human readable string representation.
1182 * @hide
1183 */
1184 public static String propertiesToStringShort(int properties) {
1185 return propertiesToStringInternal(properties, false /* isLong */);
1186 }
1187
1188 private static String propertiesToStringInternal(int properties, boolean isLong) {
Tyler Gunn720c6642016-03-22 09:02:47 -07001189 StringBuilder builder = new StringBuilder();
Santos Cordon1a749302016-07-26 16:08:53 -07001190 builder.append("[");
1191 if (isLong) {
1192 builder.append("Properties:");
1193 }
Tyler Gunn720c6642016-03-22 09:02:47 -07001194
Tyler Gunnc63f9082019-10-15 13:19:26 -07001195 if ((properties & PROPERTY_SELF_MANAGED) == PROPERTY_SELF_MANAGED) {
Tyler Gunnf5035432017-01-09 09:43:12 -08001196 builder.append(isLong ? " PROPERTY_SELF_MANAGED" : " self_mng");
1197 }
1198
Tyler Gunnc63f9082019-10-15 13:19:26 -07001199 if ((properties & PROPERTY_EMERGENCY_CALLBACK_MODE) == PROPERTY_EMERGENCY_CALLBACK_MODE) {
Hall Liu25c7c4d2016-08-30 13:41:02 -07001200 builder.append(isLong ? " PROPERTY_EMERGENCY_CALLBACK_MODE" : " ecbm");
Tyler Gunn720c6642016-03-22 09:02:47 -07001201 }
1202
Tyler Gunnc63f9082019-10-15 13:19:26 -07001203 if ((properties & PROPERTY_HIGH_DEF_AUDIO) == PROPERTY_HIGH_DEF_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001204 builder.append(isLong ? " PROPERTY_HIGH_DEF_AUDIO" : " HD");
Tyler Gunn720c6642016-03-22 09:02:47 -07001205 }
1206
Tyler Gunnc63f9082019-10-15 13:19:26 -07001207 if ((properties & PROPERTY_WIFI) == PROPERTY_WIFI) {
Santos Cordon1a749302016-07-26 16:08:53 -07001208 builder.append(isLong ? " PROPERTY_WIFI" : " wifi");
Tyler Gunn720c6642016-03-22 09:02:47 -07001209 }
1210
Tyler Gunnc63f9082019-10-15 13:19:26 -07001211 if ((properties & PROPERTY_GENERIC_CONFERENCE) == PROPERTY_GENERIC_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001212 builder.append(isLong ? " PROPERTY_GENERIC_CONFERENCE" : " gen_conf");
Tyler Gunn720c6642016-03-22 09:02:47 -07001213 }
1214
Tyler Gunnc63f9082019-10-15 13:19:26 -07001215 if ((properties & PROPERTY_IS_EXTERNAL_CALL) == PROPERTY_IS_EXTERNAL_CALL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001216 builder.append(isLong ? " PROPERTY_IS_EXTERNAL_CALL" : " xtrnl");
Tyler Gunn720c6642016-03-22 09:02:47 -07001217 }
1218
Tyler Gunnc63f9082019-10-15 13:19:26 -07001219 if ((properties & PROPERTY_HAS_CDMA_VOICE_PRIVACY) == PROPERTY_HAS_CDMA_VOICE_PRIVACY) {
Santos Cordon1a749302016-07-26 16:08:53 -07001220 builder.append(isLong ? " PROPERTY_HAS_CDMA_VOICE_PRIVACY" : " priv");
Brad Ebinger15847072016-05-18 11:08:36 -07001221 }
1222
Tyler Gunnc63f9082019-10-15 13:19:26 -07001223 if ((properties & PROPERTY_IS_RTT) == PROPERTY_IS_RTT) {
Hall Liud4d2a8a2018-01-29 17:22:02 -08001224 builder.append(isLong ? " PROPERTY_IS_RTT" : " rtt");
1225 }
1226
Tyler Gunnc63f9082019-10-15 13:19:26 -07001227 if ((properties & PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL)
1228 == PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL) {
Tyler Gunn5bd90852018-09-21 09:37:07 -07001229 builder.append(isLong ? " PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL" : " ecall");
1230 }
1231
Tyler Gunnc63f9082019-10-15 13:19:26 -07001232 if ((properties & PROPERTY_REMOTELY_HOSTED) == PROPERTY_REMOTELY_HOSTED) {
Tyler Gunnac60f952019-05-31 07:23:16 -07001233 builder.append(isLong ? " PROPERTY_REMOTELY_HOSTED" : " remote_hst");
1234 }
1235
Ravi Paluri80aa2142019-12-02 11:57:37 +05301236 if ((properties & PROPERTY_IS_ADHOC_CONFERENCE) == PROPERTY_IS_ADHOC_CONFERENCE) {
1237 builder.append(isLong ? " PROPERTY_IS_ADHOC_CONFERENCE" : " adhoc_conf");
1238 }
1239
Hall Liue0f787c2020-07-08 11:25:56 -07001240 if ((properties & PROPERTY_IS_DOWNGRADED_CONFERENCE) == PROPERTY_IS_DOWNGRADED_CONFERENCE) {
1241 builder.append(isLong ? " PROPERTY_IS_DOWNGRADED_CONFERENCE" : " dngrd_conf");
1242 }
1243
Tyler Gunn720c6642016-03-22 09:02:47 -07001244 builder.append("]");
1245 return builder.toString();
1246 }
1247
Sailesh Nepal091768c2014-06-30 15:15:23 -07001248 /** @hide */
Tyler Gunn633e4c32019-10-24 15:40:48 -07001249 abstract static class Listener {
Ihab Awad542e0ea2014-05-16 10:22:16 -07001250 public void onStateChanged(Connection c, int state) {}
Andrew Lee100e2932014-09-08 15:34:24 -07001251 public void onAddressChanged(Connection c, Uri newAddress, int presentation) {}
Sailesh Nepal61203862014-07-11 14:50:13 -07001252 public void onCallerDisplayNameChanged(
1253 Connection c, String callerDisplayName, int presentation) {}
Tyler Gunnaa07df82014-07-17 07:50:22 -07001254 public void onVideoStateChanged(Connection c, int videoState) {}
Andrew Lee7f3d41f2014-09-11 17:33:16 -07001255 public void onDisconnected(Connection c, DisconnectCause disconnectCause) {}
Sailesh Nepal091768c2014-06-30 15:15:23 -07001256 public void onPostDialWait(Connection c, String remaining) {}
Nancy Chen27d1c2d2014-12-15 16:12:50 -08001257 public void onPostDialChar(Connection c, char nextChar) {}
Andrew Lee100e2932014-09-08 15:34:24 -07001258 public void onRingbackRequested(Connection c, boolean ringback) {}
Sailesh Nepal61203862014-07-11 14:50:13 -07001259 public void onDestroyed(Connection c) {}
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001260 public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {}
Tyler Gunn720c6642016-03-22 09:02:47 -07001261 public void onConnectionPropertiesChanged(Connection c, int properties) {}
Christine Hallstrom2830ce92016-11-30 16:06:42 -08001262 public void onSupportedAudioRoutesChanged(Connection c, int supportedAudioRoutes) {}
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001263 public void onVideoProviderChanged(
1264 Connection c, VideoProvider videoProvider) {}
Sailesh Nepal001bbbb2014-07-15 14:40:39 -07001265 public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {}
1266 public void onStatusHintsChanged(Connection c, StatusHints statusHints) {}
Tyler Gunn6d76ca02014-11-17 15:49:51 -08001267 public void onConferenceablesChanged(
Tyler Gunndf2cbc82015-04-20 09:13:01 -07001268 Connection c, List<Conferenceable> conferenceables) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -07001269 public void onConferenceChanged(Connection c, Conference conference) {}
Anthony Lee17455a32015-04-24 15:25:29 -07001270 public void onConferenceMergeFailed(Connection c) {}
Santos Cordon6b7f9552015-05-27 17:21:45 -07001271 public void onExtrasChanged(Connection c, Bundle extras) {}
Tyler Gunndee56a82016-03-23 16:06:34 -07001272 public void onExtrasRemoved(Connection c, List<String> keys) {}
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001273 public void onConnectionEvent(Connection c, String event, Bundle extras) {}
Hall Liua98f58b52017-11-07 17:59:28 -08001274 public void onAudioRouteChanged(Connection c, int audioRoute, String bluetoothAddress) {}
Hall Liub64ac4c2017-02-06 10:49:48 -08001275 public void onRttInitiationSuccess(Connection c) {}
1276 public void onRttInitiationFailure(Connection c, int reason) {}
1277 public void onRttSessionRemotelyTerminated(Connection c) {}
1278 public void onRemoteRttRequest(Connection c) {}
Srikanth Chintalafcb15012017-05-04 20:58:34 +05301279 /** @hide */
1280 public void onPhoneAccountChanged(Connection c, PhoneAccountHandle pHandle) {}
Mengjun Leng25707742017-07-04 11:10:37 +08001281 public void onConnectionTimeReset(Connection c) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07001282 }
1283
Tyler Gunnb702ef82015-05-29 11:51:53 -07001284 /**
Hall Liu95d55872017-01-25 17:12:49 -08001285 * Provides methods to read and write RTT data to/from the in-call app.
Hall Liu95d55872017-01-25 17:12:49 -08001286 */
1287 public static final class RttTextStream {
1288 private static final int READ_BUFFER_SIZE = 1000;
1289 private final InputStreamReader mPipeFromInCall;
1290 private final OutputStreamWriter mPipeToInCall;
Hall Liub64ac4c2017-02-06 10:49:48 -08001291 private final ParcelFileDescriptor mFdFromInCall;
1292 private final ParcelFileDescriptor mFdToInCall;
Hall Liu17eb1bd2018-07-03 15:17:41 -07001293
1294 private final FileInputStream mFromInCallFileInputStream;
Hall Liu95d55872017-01-25 17:12:49 -08001295 private char[] mReadBuffer = new char[READ_BUFFER_SIZE];
1296
1297 /**
1298 * @hide
1299 */
1300 public RttTextStream(ParcelFileDescriptor toInCall, ParcelFileDescriptor fromInCall) {
Hall Liub64ac4c2017-02-06 10:49:48 -08001301 mFdFromInCall = fromInCall;
1302 mFdToInCall = toInCall;
Hall Liu17eb1bd2018-07-03 15:17:41 -07001303 mFromInCallFileInputStream = new FileInputStream(fromInCall.getFileDescriptor());
Hall Liu730a2592018-06-25 19:48:33 -07001304
1305 // Wrap the FileInputStream in a Channel so that it's interruptible.
Hall Liu95d55872017-01-25 17:12:49 -08001306 mPipeFromInCall = new InputStreamReader(
Hall Liu17eb1bd2018-07-03 15:17:41 -07001307 Channels.newInputStream(Channels.newChannel(mFromInCallFileInputStream)));
Hall Liu95d55872017-01-25 17:12:49 -08001308 mPipeToInCall = new OutputStreamWriter(
Hall Liua549fed2018-02-09 16:40:03 -08001309 new FileOutputStream(toInCall.getFileDescriptor()));
Hall Liu95d55872017-01-25 17:12:49 -08001310 }
1311
1312 /**
1313 * Writes the string {@param input} into the text stream to the UI for this RTT call. Since
1314 * RTT transmits text in real-time, this method should be called as often as text snippets
1315 * are received from the remote user, even if it is only one character.
Hall Liua549fed2018-02-09 16:40:03 -08001316 * <p>
Hall Liu95d55872017-01-25 17:12:49 -08001317 * This method is not thread-safe -- calling it from multiple threads simultaneously may
1318 * lead to interleaved text.
Hall Liua549fed2018-02-09 16:40:03 -08001319 *
Hall Liu95d55872017-01-25 17:12:49 -08001320 * @param input The message to send to the in-call app.
1321 */
1322 public void write(String input) throws IOException {
1323 mPipeToInCall.write(input);
1324 mPipeToInCall.flush();
1325 }
1326
1327
1328 /**
1329 * Reads a string from the in-call app, blocking if there is no data available. Returns
1330 * {@code null} if the RTT conversation has been terminated and there is no further data
1331 * to read.
Hall Liua549fed2018-02-09 16:40:03 -08001332 * <p>
Hall Liu95d55872017-01-25 17:12:49 -08001333 * This method is not thread-safe -- calling it from multiple threads simultaneously may
1334 * lead to interleaved text.
Hall Liua549fed2018-02-09 16:40:03 -08001335 *
Hall Liu95d55872017-01-25 17:12:49 -08001336 * @return A string containing text entered by the user, or {@code null} if the
1337 * conversation has been terminated or if there was an error while reading.
1338 */
Hall Liuffa4a812017-03-02 16:11:00 -08001339 public String read() throws IOException {
1340 int numRead = mPipeFromInCall.read(mReadBuffer, 0, READ_BUFFER_SIZE);
1341 if (numRead < 0) {
1342 return null;
1343 }
1344 return new String(mReadBuffer, 0, numRead);
1345 }
1346
1347 /**
1348 * Non-blocking version of {@link #read()}. Returns {@code null} if there is nothing to
1349 * be read.
Hall Liua549fed2018-02-09 16:40:03 -08001350 *
Hall Liuffa4a812017-03-02 16:11:00 -08001351 * @return A string containing text entered by the user, or {@code null} if the user has
1352 * not entered any new text yet.
1353 */
1354 public String readImmediately() throws IOException {
Hall Liu17eb1bd2018-07-03 15:17:41 -07001355 if (mFromInCallFileInputStream.available() > 0) {
Hall Liuffa4a812017-03-02 16:11:00 -08001356 return read();
1357 } else {
Hall Liu95d55872017-01-25 17:12:49 -08001358 return null;
1359 }
1360 }
Hall Liub64ac4c2017-02-06 10:49:48 -08001361
1362 /** @hide */
1363 public ParcelFileDescriptor getFdFromInCall() {
1364 return mFdFromInCall;
1365 }
1366
1367 /** @hide */
1368 public ParcelFileDescriptor getFdToInCall() {
1369 return mFdToInCall;
1370 }
1371 }
1372
1373 /**
1374 * Provides constants to represent the results of responses to session modify requests sent via
1375 * {@link Call#sendRttRequest()}
1376 */
1377 public static final class RttModifyStatus {
Hall Liu8dd49082017-04-21 14:33:12 -07001378 private RttModifyStatus() {}
Hall Liub64ac4c2017-02-06 10:49:48 -08001379 /**
1380 * Session modify request was successful.
1381 */
1382 public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1;
1383
1384 /**
1385 * Session modify request failed.
1386 */
1387 public static final int SESSION_MODIFY_REQUEST_FAIL = 2;
1388
1389 /**
1390 * Session modify request ignored due to invalid parameters.
1391 */
1392 public static final int SESSION_MODIFY_REQUEST_INVALID = 3;
1393
1394 /**
1395 * Session modify request timed out.
1396 */
1397 public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4;
1398
1399 /**
1400 * Session modify request rejected by remote user.
1401 */
1402 public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5;
Tyler Gunnb9a04962022-02-17 08:23:54 -08001403
1404
1405 /**@hide*/
1406 @Retention(RetentionPolicy.SOURCE)
1407 @IntDef(prefix = "SESSION_MODIFY_REQUEST_", value = {
1408 SESSION_MODIFY_REQUEST_SUCCESS,
1409 SESSION_MODIFY_REQUEST_FAIL,
1410 SESSION_MODIFY_REQUEST_INVALID,
1411 SESSION_MODIFY_REQUEST_TIMED_OUT,
1412 SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE
1413 })
1414 public @interface RttSessionModifyStatus {}
Hall Liu95d55872017-01-25 17:12:49 -08001415 }
1416
1417 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001418 * Provides a means of controlling the video session associated with a {@link Connection}.
1419 * <p>
1420 * Implementations create a custom subclass of {@link VideoProvider} and the
1421 * {@link ConnectionService} creates an instance sets it on the {@link Connection} using
1422 * {@link Connection#setVideoProvider(VideoProvider)}. Any connection which supports video
1423 * should set the {@link VideoProvider}.
1424 * <p>
1425 * The {@link VideoProvider} serves two primary purposes: it provides a means for Telecom and
1426 * {@link InCallService} implementations to issue requests related to the video session;
1427 * it provides a means for the {@link ConnectionService} to report events and information
1428 * related to the video session to Telecom and the {@link InCallService} implementations.
1429 * <p>
1430 * {@link InCallService} implementations interact with the {@link VideoProvider} via
1431 * {@link android.telecom.InCallService.VideoCall}.
1432 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001433 public static abstract class VideoProvider {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001434 /**
1435 * Video is not being received (no protocol pause was issued).
Tyler Gunnb702ef82015-05-29 11:51:53 -07001436 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001437 */
1438 public static final int SESSION_EVENT_RX_PAUSE = 1;
Evan Charltonbf11f982014-07-20 22:06:28 -07001439
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001440 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001441 * Video reception has resumed after a {@link #SESSION_EVENT_RX_PAUSE}.
1442 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001443 */
1444 public static final int SESSION_EVENT_RX_RESUME = 2;
1445
1446 /**
1447 * Video transmission has begun. This occurs after a negotiated start of video transmission
1448 * when the underlying protocol has actually begun transmitting video to the remote party.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001449 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001450 */
1451 public static final int SESSION_EVENT_TX_START = 3;
1452
1453 /**
1454 * Video transmission has stopped. This occurs after a negotiated stop of video transmission
1455 * when the underlying protocol has actually stopped transmitting video to the remote party.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001456 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001457 */
1458 public static final int SESSION_EVENT_TX_STOP = 4;
1459
1460 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001461 * A camera failure has occurred for the selected camera. The {@link VideoProvider} can use
Tyler Gunnb702ef82015-05-29 11:51:53 -07001462 * this as a cue to inform the user the camera is not available.
1463 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001464 */
1465 public static final int SESSION_EVENT_CAMERA_FAILURE = 5;
1466
1467 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001468 * Issued after {@link #SESSION_EVENT_CAMERA_FAILURE} when the camera is once again ready
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001469 * for operation. The {@link VideoProvider} can use this as a cue to inform the user that
Tyler Gunnb702ef82015-05-29 11:51:53 -07001470 * the camera has become available again.
1471 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001472 */
1473 public static final int SESSION_EVENT_CAMERA_READY = 6;
1474
1475 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001476 * Session event raised by Telecom when
1477 * {@link android.telecom.InCallService.VideoCall#setCamera(String)} is called and the
1478 * caller does not have the necessary {@link android.Manifest.permission#CAMERA} permission.
1479 * @see #handleCallSessionEvent(int)
1480 */
1481 public static final int SESSION_EVENT_CAMERA_PERMISSION_ERROR = 7;
1482
1483 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001484 * Session modify request was successful.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001485 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001486 */
1487 public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1;
1488
1489 /**
1490 * Session modify request failed.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001491 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001492 */
1493 public static final int SESSION_MODIFY_REQUEST_FAIL = 2;
1494
1495 /**
1496 * Session modify request ignored due to invalid parameters.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001497 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001498 */
1499 public static final int SESSION_MODIFY_REQUEST_INVALID = 3;
1500
Rekha Kumar07366812015-03-24 16:42:31 -07001501 /**
1502 * Session modify request timed out.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001503 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Rekha Kumar07366812015-03-24 16:42:31 -07001504 */
1505 public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4;
1506
1507 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001508 * Session modify request rejected by remote user.
1509 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Rekha Kumar07366812015-03-24 16:42:31 -07001510 */
1511 public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5;
1512
Tyler Gunn75958422015-04-15 14:23:42 -07001513 private static final int MSG_ADD_VIDEO_CALLBACK = 1;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001514 private static final int MSG_SET_CAMERA = 2;
1515 private static final int MSG_SET_PREVIEW_SURFACE = 3;
1516 private static final int MSG_SET_DISPLAY_SURFACE = 4;
1517 private static final int MSG_SET_DEVICE_ORIENTATION = 5;
1518 private static final int MSG_SET_ZOOM = 6;
1519 private static final int MSG_SEND_SESSION_MODIFY_REQUEST = 7;
1520 private static final int MSG_SEND_SESSION_MODIFY_RESPONSE = 8;
1521 private static final int MSG_REQUEST_CAMERA_CAPABILITIES = 9;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001522 private static final int MSG_REQUEST_CONNECTION_DATA_USAGE = 10;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001523 private static final int MSG_SET_PAUSE_IMAGE = 11;
Tyler Gunn75958422015-04-15 14:23:42 -07001524 private static final int MSG_REMOVE_VIDEO_CALLBACK = 12;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001525
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001526 private static final String SESSION_EVENT_RX_PAUSE_STR = "RX_PAUSE";
1527 private static final String SESSION_EVENT_RX_RESUME_STR = "RX_RESUME";
1528 private static final String SESSION_EVENT_TX_START_STR = "TX_START";
1529 private static final String SESSION_EVENT_TX_STOP_STR = "TX_STOP";
1530 private static final String SESSION_EVENT_CAMERA_FAILURE_STR = "CAMERA_FAIL";
1531 private static final String SESSION_EVENT_CAMERA_READY_STR = "CAMERA_READY";
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001532 private static final String SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR =
1533 "CAMERA_PERMISSION_ERROR";
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001534 private static final String SESSION_EVENT_UNKNOWN_STR = "UNKNOWN";
1535
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001536 private VideoProvider.VideoProviderHandler mMessageHandler;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001537 private final VideoProvider.VideoProviderBinder mBinder;
Tyler Gunn75958422015-04-15 14:23:42 -07001538
1539 /**
1540 * Stores a list of the video callbacks, keyed by IBinder.
Tyler Gunn84f381b2015-06-12 09:26:45 -07001541 *
1542 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
1543 * load factor before resizing, 1 means we only expect a single thread to
1544 * access the map so make only a single shard
Tyler Gunn75958422015-04-15 14:23:42 -07001545 */
Tyler Gunn84f381b2015-06-12 09:26:45 -07001546 private ConcurrentHashMap<IBinder, IVideoCallback> mVideoCallbacks =
1547 new ConcurrentHashMap<IBinder, IVideoCallback>(8, 0.9f, 1);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001548
1549 /**
1550 * Default handler used to consolidate binder method calls onto a single thread.
1551 */
1552 private final class VideoProviderHandler extends Handler {
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001553 public VideoProviderHandler() {
1554 super();
1555 }
1556
1557 public VideoProviderHandler(Looper looper) {
1558 super(looper);
1559 }
1560
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001561 @Override
1562 public void handleMessage(Message msg) {
1563 switch (msg.what) {
Tyler Gunn75958422015-04-15 14:23:42 -07001564 case MSG_ADD_VIDEO_CALLBACK: {
1565 IBinder binder = (IBinder) msg.obj;
1566 IVideoCallback callback = IVideoCallback.Stub
1567 .asInterface((IBinder) msg.obj);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001568 if (callback == null) {
1569 Log.w(this, "addVideoProvider - skipped; callback is null.");
1570 break;
1571 }
1572
Tyler Gunn75958422015-04-15 14:23:42 -07001573 if (mVideoCallbacks.containsKey(binder)) {
1574 Log.i(this, "addVideoProvider - skipped; already present.");
1575 break;
1576 }
1577 mVideoCallbacks.put(binder, callback);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001578 break;
Tyler Gunn75958422015-04-15 14:23:42 -07001579 }
1580 case MSG_REMOVE_VIDEO_CALLBACK: {
1581 IBinder binder = (IBinder) msg.obj;
1582 IVideoCallback callback = IVideoCallback.Stub
1583 .asInterface((IBinder) msg.obj);
1584 if (!mVideoCallbacks.containsKey(binder)) {
1585 Log.i(this, "removeVideoProvider - skipped; not present.");
1586 break;
1587 }
1588 mVideoCallbacks.remove(binder);
1589 break;
1590 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001591 case MSG_SET_CAMERA:
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001592 {
1593 SomeArgs args = (SomeArgs) msg.obj;
1594 try {
1595 onSetCamera((String) args.arg1);
1596 onSetCamera((String) args.arg1, (String) args.arg2, args.argi1,
Tyler Gunn159f35c2017-03-02 09:28:37 -08001597 args.argi2, args.argi3);
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001598 } finally {
1599 args.recycle();
1600 }
1601 }
1602 break;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001603 case MSG_SET_PREVIEW_SURFACE:
1604 onSetPreviewSurface((Surface) msg.obj);
1605 break;
1606 case MSG_SET_DISPLAY_SURFACE:
1607 onSetDisplaySurface((Surface) msg.obj);
1608 break;
1609 case MSG_SET_DEVICE_ORIENTATION:
1610 onSetDeviceOrientation(msg.arg1);
1611 break;
1612 case MSG_SET_ZOOM:
1613 onSetZoom((Float) msg.obj);
1614 break;
Tyler Gunn45382162015-05-06 08:52:27 -07001615 case MSG_SEND_SESSION_MODIFY_REQUEST: {
1616 SomeArgs args = (SomeArgs) msg.obj;
1617 try {
1618 onSendSessionModifyRequest((VideoProfile) args.arg1,
1619 (VideoProfile) args.arg2);
1620 } finally {
1621 args.recycle();
1622 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001623 break;
Tyler Gunn45382162015-05-06 08:52:27 -07001624 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001625 case MSG_SEND_SESSION_MODIFY_RESPONSE:
1626 onSendSessionModifyResponse((VideoProfile) msg.obj);
1627 break;
1628 case MSG_REQUEST_CAMERA_CAPABILITIES:
1629 onRequestCameraCapabilities();
1630 break;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001631 case MSG_REQUEST_CONNECTION_DATA_USAGE:
1632 onRequestConnectionDataUsage();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001633 break;
1634 case MSG_SET_PAUSE_IMAGE:
Yorke Lee32f24732015-05-12 16:18:03 -07001635 onSetPauseImage((Uri) msg.obj);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001636 break;
1637 default:
1638 break;
1639 }
1640 }
1641 }
1642
1643 /**
1644 * IVideoProvider stub implementation.
1645 */
1646 private final class VideoProviderBinder extends IVideoProvider.Stub {
Tyler Gunn75958422015-04-15 14:23:42 -07001647 public void addVideoCallback(IBinder videoCallbackBinder) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001648 mMessageHandler.obtainMessage(
Tyler Gunn75958422015-04-15 14:23:42 -07001649 MSG_ADD_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget();
1650 }
1651
1652 public void removeVideoCallback(IBinder videoCallbackBinder) {
1653 mMessageHandler.obtainMessage(
1654 MSG_REMOVE_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001655 }
1656
Tyler Gunn159f35c2017-03-02 09:28:37 -08001657 public void setCamera(String cameraId, String callingPackageName,
1658 int targetSdkVersion) {
1659
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001660 SomeArgs args = SomeArgs.obtain();
1661 args.arg1 = cameraId;
1662 // Propagate the calling package; originally determined in
1663 // android.telecom.InCallService.VideoCall#setCamera(String) from the calling
1664 // process.
1665 args.arg2 = callingPackageName;
1666 // Pass along the uid and pid of the calling app; this gets lost when we put the
1667 // message onto the handler. These are required for Telecom to perform a permission
1668 // check to see if the calling app is able to use the camera.
1669 args.argi1 = Binder.getCallingUid();
1670 args.argi2 = Binder.getCallingPid();
Tyler Gunn159f35c2017-03-02 09:28:37 -08001671 // Pass along the target SDK version of the calling InCallService. This is used to
1672 // maintain backwards compatibility of the API for older callers.
1673 args.argi3 = targetSdkVersion;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001674 mMessageHandler.obtainMessage(MSG_SET_CAMERA, args).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001675 }
1676
1677 public void setPreviewSurface(Surface surface) {
1678 mMessageHandler.obtainMessage(MSG_SET_PREVIEW_SURFACE, surface).sendToTarget();
1679 }
1680
1681 public void setDisplaySurface(Surface surface) {
1682 mMessageHandler.obtainMessage(MSG_SET_DISPLAY_SURFACE, surface).sendToTarget();
1683 }
1684
1685 public void setDeviceOrientation(int rotation) {
Rekha Kumar07366812015-03-24 16:42:31 -07001686 mMessageHandler.obtainMessage(
1687 MSG_SET_DEVICE_ORIENTATION, rotation, 0).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001688 }
1689
1690 public void setZoom(float value) {
1691 mMessageHandler.obtainMessage(MSG_SET_ZOOM, value).sendToTarget();
1692 }
1693
Tyler Gunn45382162015-05-06 08:52:27 -07001694 public void sendSessionModifyRequest(VideoProfile fromProfile, VideoProfile toProfile) {
1695 SomeArgs args = SomeArgs.obtain();
1696 args.arg1 = fromProfile;
1697 args.arg2 = toProfile;
1698 mMessageHandler.obtainMessage(MSG_SEND_SESSION_MODIFY_REQUEST, args).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001699 }
1700
1701 public void sendSessionModifyResponse(VideoProfile responseProfile) {
1702 mMessageHandler.obtainMessage(
1703 MSG_SEND_SESSION_MODIFY_RESPONSE, responseProfile).sendToTarget();
1704 }
1705
1706 public void requestCameraCapabilities() {
1707 mMessageHandler.obtainMessage(MSG_REQUEST_CAMERA_CAPABILITIES).sendToTarget();
1708 }
1709
1710 public void requestCallDataUsage() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001711 mMessageHandler.obtainMessage(MSG_REQUEST_CONNECTION_DATA_USAGE).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001712 }
1713
Yorke Lee32f24732015-05-12 16:18:03 -07001714 public void setPauseImage(Uri uri) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001715 mMessageHandler.obtainMessage(MSG_SET_PAUSE_IMAGE, uri).sendToTarget();
1716 }
1717 }
1718
1719 public VideoProvider() {
1720 mBinder = new VideoProvider.VideoProviderBinder();
Tyler Gunn84f381b2015-06-12 09:26:45 -07001721 mMessageHandler = new VideoProvider.VideoProviderHandler(Looper.getMainLooper());
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001722 }
1723
1724 /**
1725 * Creates an instance of the {@link VideoProvider}, specifying the looper to use.
1726 *
1727 * @param looper The looper.
1728 * @hide
1729 */
Mathew Inwood42346d12018-08-01 11:33:05 +01001730 @UnsupportedAppUsage
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001731 public VideoProvider(Looper looper) {
1732 mBinder = new VideoProvider.VideoProviderBinder();
1733 mMessageHandler = new VideoProvider.VideoProviderHandler(looper);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001734 }
1735
1736 /**
1737 * Returns binder object which can be used across IPC methods.
1738 * @hide
1739 */
1740 public final IVideoProvider getInterface() {
1741 return mBinder;
1742 }
1743
1744 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001745 * Sets the camera to be used for the outgoing video.
1746 * <p>
1747 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1748 * camera via
1749 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1750 * <p>
1751 * Sent from the {@link InCallService} via
1752 * {@link InCallService.VideoCall#setCamera(String)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001753 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001754 * @param cameraId The id of the camera (use ids as reported by
1755 * {@link CameraManager#getCameraIdList()}).
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001756 */
1757 public abstract void onSetCamera(String cameraId);
1758
1759 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001760 * Sets the camera to be used for the outgoing video.
1761 * <p>
1762 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1763 * camera via
1764 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1765 * <p>
1766 * This prototype is used internally to ensure that the calling package name, UID and PID
1767 * are sent to Telecom so that can perform a camera permission check on the caller.
1768 * <p>
1769 * Sent from the {@link InCallService} via
1770 * {@link InCallService.VideoCall#setCamera(String)}.
1771 *
1772 * @param cameraId The id of the camera (use ids as reported by
1773 * {@link CameraManager#getCameraIdList()}).
1774 * @param callingPackageName The AppOpps package name of the caller.
1775 * @param callingUid The UID of the caller.
1776 * @param callingPid The PID of the caller.
Tyler Gunn159f35c2017-03-02 09:28:37 -08001777 * @param targetSdkVersion The target SDK version of the caller.
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001778 * @hide
1779 */
1780 public void onSetCamera(String cameraId, String callingPackageName, int callingUid,
Tyler Gunn159f35c2017-03-02 09:28:37 -08001781 int callingPid, int targetSdkVersion) {}
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001782
1783 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001784 * Sets the surface to be used for displaying a preview of what the user's camera is
1785 * currently capturing. When video transmission is enabled, this is the video signal which
1786 * is sent to the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001787 * <p>
1788 * Sent from the {@link InCallService} via
1789 * {@link InCallService.VideoCall#setPreviewSurface(Surface)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001790 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001791 * @param surface The {@link Surface}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001792 */
1793 public abstract void onSetPreviewSurface(Surface surface);
1794
1795 /**
1796 * Sets the surface to be used for displaying the video received from the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001797 * <p>
1798 * Sent from the {@link InCallService} via
1799 * {@link InCallService.VideoCall#setDisplaySurface(Surface)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001800 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001801 * @param surface The {@link Surface}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001802 */
1803 public abstract void onSetDisplaySurface(Surface surface);
1804
1805 /**
1806 * Sets the device orientation, in degrees. Assumes that a standard portrait orientation of
1807 * the device is 0 degrees.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001808 * <p>
1809 * Sent from the {@link InCallService} via
1810 * {@link InCallService.VideoCall#setDeviceOrientation(int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001811 *
1812 * @param rotation The device orientation, in degrees.
1813 */
1814 public abstract void onSetDeviceOrientation(int rotation);
1815
1816 /**
Tyler Gunnc603b462021-06-14 17:24:40 -07001817 * Sets the camera zoom ratio.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001818 * <p>
1819 * Sent from the {@link InCallService} via {@link InCallService.VideoCall#setZoom(float)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001820 *
Tyler Gunnc603b462021-06-14 17:24:40 -07001821 * @param value The camera zoom ratio; for the current camera, should be a value in the
1822 * range defined by
1823 * {@link android.hardware.camera2.CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001824 */
1825 public abstract void onSetZoom(float value);
1826
1827 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001828 * Issues a request to modify the properties of the current video session.
1829 * <p>
1830 * Example scenarios include: requesting an audio-only call to be upgraded to a
1831 * bi-directional video call, turning on or off the user's camera, sending a pause signal
1832 * when the {@link InCallService} is no longer the foreground application.
1833 * <p>
1834 * If the {@link VideoProvider} determines a request to be invalid, it should call
1835 * {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)} to report the
1836 * invalid request back to the {@link InCallService}.
1837 * <p>
1838 * Where a request requires confirmation from the user of the peer device, the
1839 * {@link VideoProvider} must communicate the request to the peer device and handle the
1840 * user's response. {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)}
1841 * is used to inform the {@link InCallService} of the result of the request.
1842 * <p>
1843 * Sent from the {@link InCallService} via
1844 * {@link InCallService.VideoCall#sendSessionModifyRequest(VideoProfile)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001845 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001846 * @param fromProfile The video profile prior to the request.
1847 * @param toProfile The video profile with the requested changes made.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001848 */
Tyler Gunn45382162015-05-06 08:52:27 -07001849 public abstract void onSendSessionModifyRequest(VideoProfile fromProfile,
1850 VideoProfile toProfile);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001851
Tyler Gunnb702ef82015-05-29 11:51:53 -07001852 /**
1853 * Provides a response to a request to change the current video session properties.
1854 * <p>
1855 * For example, if the peer requests and upgrade from an audio-only call to a bi-directional
1856 * video call, could decline the request and keep the call as audio-only.
1857 * In such a scenario, the {@code responseProfile} would have a video state of
1858 * {@link VideoProfile#STATE_AUDIO_ONLY}. If the user had decided to accept the request,
1859 * the video state would be {@link VideoProfile#STATE_BIDIRECTIONAL}.
1860 * <p>
1861 * Sent from the {@link InCallService} via
1862 * {@link InCallService.VideoCall#sendSessionModifyResponse(VideoProfile)} in response to
1863 * a {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)}
1864 * callback.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001865 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001866 * @param responseProfile The response video profile.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001867 */
1868 public abstract void onSendSessionModifyResponse(VideoProfile responseProfile);
1869
1870 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001871 * Issues a request to the {@link VideoProvider} to retrieve the camera capabilities.
1872 * <p>
1873 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1874 * camera via
1875 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1876 * <p>
1877 * Sent from the {@link InCallService} via
1878 * {@link InCallService.VideoCall#requestCameraCapabilities()}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001879 */
1880 public abstract void onRequestCameraCapabilities();
1881
1882 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001883 * Issues a request to the {@link VideoProvider} to retrieve the current data usage for the
1884 * video component of the current {@link Connection}.
1885 * <p>
1886 * The {@link VideoProvider} should respond by communicating current data usage, in bytes,
1887 * via {@link VideoProvider#setCallDataUsage(long)}.
1888 * <p>
1889 * Sent from the {@link InCallService} via
1890 * {@link InCallService.VideoCall#requestCallDataUsage()}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001891 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001892 public abstract void onRequestConnectionDataUsage();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001893
1894 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001895 * Provides the {@link VideoProvider} with the {@link Uri} of an image to be displayed to
1896 * the peer device when the video signal is paused.
1897 * <p>
1898 * Sent from the {@link InCallService} via
1899 * {@link InCallService.VideoCall#setPauseImage(Uri)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001900 *
1901 * @param uri URI of image to display.
1902 */
Yorke Lee32f24732015-05-12 16:18:03 -07001903 public abstract void onSetPauseImage(Uri uri);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001904
1905 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001906 * Used to inform listening {@link InCallService} implementations when the
1907 * {@link VideoProvider} receives a session modification request.
1908 * <p>
1909 * Received by the {@link InCallService} via
1910 * {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)},
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001911 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001912 * @param videoProfile The requested video profile.
1913 * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001914 */
1915 public void receiveSessionModifyRequest(VideoProfile videoProfile) {
Tyler Gunn75958422015-04-15 14:23:42 -07001916 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001917 for (IVideoCallback callback : mVideoCallbacks.values()) {
1918 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001919 callback.receiveSessionModifyRequest(videoProfile);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001920 } catch (RemoteException ignored) {
1921 Log.w(this, "receiveSessionModifyRequest callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001922 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001923 }
1924 }
1925 }
1926
1927 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001928 * Used to inform listening {@link InCallService} implementations when the
1929 * {@link VideoProvider} receives a response to a session modification request.
1930 * <p>
1931 * Received by the {@link InCallService} via
1932 * {@link InCallService.VideoCall.Callback#onSessionModifyResponseReceived(int,
1933 * VideoProfile, VideoProfile)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001934 *
1935 * @param status Status of the session modify request. Valid values are
1936 * {@link VideoProvider#SESSION_MODIFY_REQUEST_SUCCESS},
1937 * {@link VideoProvider#SESSION_MODIFY_REQUEST_FAIL},
Tyler Gunnb702ef82015-05-29 11:51:53 -07001938 * {@link VideoProvider#SESSION_MODIFY_REQUEST_INVALID},
1939 * {@link VideoProvider#SESSION_MODIFY_REQUEST_TIMED_OUT},
1940 * {@link VideoProvider#SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE}
1941 * @param requestedProfile The original request which was sent to the peer device.
1942 * @param responseProfile The actual profile changes agreed to by the peer device.
1943 * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001944 */
1945 public void receiveSessionModifyResponse(int status,
1946 VideoProfile requestedProfile, VideoProfile responseProfile) {
Tyler Gunn75958422015-04-15 14:23:42 -07001947 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001948 for (IVideoCallback callback : mVideoCallbacks.values()) {
1949 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001950 callback.receiveSessionModifyResponse(status, requestedProfile,
1951 responseProfile);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001952 } catch (RemoteException ignored) {
1953 Log.w(this, "receiveSessionModifyResponse callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001954 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001955 }
1956 }
1957 }
1958
1959 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001960 * Used to inform listening {@link InCallService} implementations when the
1961 * {@link VideoProvider} reports a call session event.
1962 * <p>
1963 * Received by the {@link InCallService} via
1964 * {@link InCallService.VideoCall.Callback#onCallSessionEvent(int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001965 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001966 * @param event The event. Valid values are: {@link VideoProvider#SESSION_EVENT_RX_PAUSE},
1967 * {@link VideoProvider#SESSION_EVENT_RX_RESUME},
1968 * {@link VideoProvider#SESSION_EVENT_TX_START},
1969 * {@link VideoProvider#SESSION_EVENT_TX_STOP},
1970 * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE},
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001971 * {@link VideoProvider#SESSION_EVENT_CAMERA_READY},
1972 * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001973 */
1974 public void handleCallSessionEvent(int event) {
Tyler Gunn75958422015-04-15 14:23:42 -07001975 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001976 for (IVideoCallback callback : mVideoCallbacks.values()) {
1977 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001978 callback.handleCallSessionEvent(event);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001979 } catch (RemoteException ignored) {
1980 Log.w(this, "handleCallSessionEvent callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001981 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001982 }
1983 }
1984 }
1985
1986 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001987 * Used to inform listening {@link InCallService} implementations when the dimensions of the
1988 * peer's video have changed.
1989 * <p>
1990 * This could occur if, for example, the peer rotates their device, changing the aspect
1991 * ratio of the video, or if the user switches between the back and front cameras.
1992 * <p>
1993 * Received by the {@link InCallService} via
1994 * {@link InCallService.VideoCall.Callback#onPeerDimensionsChanged(int, int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001995 *
1996 * @param width The updated peer video width.
1997 * @param height The updated peer video height.
1998 */
1999 public void changePeerDimensions(int width, int height) {
Tyler Gunn75958422015-04-15 14:23:42 -07002000 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002001 for (IVideoCallback callback : mVideoCallbacks.values()) {
2002 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002003 callback.changePeerDimensions(width, height);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002004 } catch (RemoteException ignored) {
2005 Log.w(this, "changePeerDimensions callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002006 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002007 }
2008 }
2009 }
2010
2011 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002012 * Used to inform listening {@link InCallService} implementations when the data usage of the
2013 * video associated with the current {@link Connection} has changed.
2014 * <p>
2015 * This could be in response to a preview request via
2016 * {@link #onRequestConnectionDataUsage()}, or as a periodic update by the
Tyler Gunn295f5d72015-06-04 11:08:54 -07002017 * {@link VideoProvider}. Where periodic updates of data usage are provided, they should be
2018 * 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 -07002019 * <p>
2020 * Received by the {@link InCallService} via
2021 * {@link InCallService.VideoCall.Callback#onCallDataUsageChanged(long)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002022 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002023 * @param dataUsage The updated data usage (in bytes). Reported as the cumulative bytes
2024 * used since the start of the call.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002025 */
Yorke Lee32f24732015-05-12 16:18:03 -07002026 public void setCallDataUsage(long dataUsage) {
Tyler Gunn75958422015-04-15 14:23:42 -07002027 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002028 for (IVideoCallback callback : mVideoCallbacks.values()) {
2029 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002030 callback.changeCallDataUsage(dataUsage);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002031 } catch (RemoteException ignored) {
2032 Log.w(this, "setCallDataUsage callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002033 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002034 }
2035 }
2036 }
2037
2038 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002039 * @see #setCallDataUsage(long)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002040 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002041 * @param dataUsage The updated data usage (in byes).
Yorke Lee32f24732015-05-12 16:18:03 -07002042 * @deprecated - Use {@link #setCallDataUsage(long)} instead.
2043 * @hide
2044 */
2045 public void changeCallDataUsage(long dataUsage) {
2046 setCallDataUsage(dataUsage);
2047 }
2048
2049 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002050 * Used to inform listening {@link InCallService} implementations when the capabilities of
2051 * the current camera have changed.
2052 * <p>
2053 * The {@link VideoProvider} should call this in response to
2054 * {@link VideoProvider#onRequestCameraCapabilities()}, or when the current camera is
2055 * changed via {@link VideoProvider#onSetCamera(String)}.
2056 * <p>
2057 * Received by the {@link InCallService} via
2058 * {@link InCallService.VideoCall.Callback#onCameraCapabilitiesChanged(
2059 * VideoProfile.CameraCapabilities)}.
Yorke Lee32f24732015-05-12 16:18:03 -07002060 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002061 * @param cameraCapabilities The new camera capabilities.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002062 */
Yorke Lee400470f2015-05-12 13:31:25 -07002063 public void changeCameraCapabilities(VideoProfile.CameraCapabilities cameraCapabilities) {
Tyler Gunn75958422015-04-15 14:23:42 -07002064 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002065 for (IVideoCallback callback : mVideoCallbacks.values()) {
2066 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002067 callback.changeCameraCapabilities(cameraCapabilities);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002068 } catch (RemoteException ignored) {
2069 Log.w(this, "changeCameraCapabilities callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002070 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002071 }
2072 }
2073 }
Rekha Kumar07366812015-03-24 16:42:31 -07002074
2075 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002076 * Used to inform listening {@link InCallService} implementations when the video quality
2077 * of the call has changed.
2078 * <p>
2079 * Received by the {@link InCallService} via
2080 * {@link InCallService.VideoCall.Callback#onVideoQualityChanged(int)}.
Rekha Kumar07366812015-03-24 16:42:31 -07002081 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002082 * @param videoQuality The updated video quality. Valid values:
2083 * {@link VideoProfile#QUALITY_HIGH},
2084 * {@link VideoProfile#QUALITY_MEDIUM},
2085 * {@link VideoProfile#QUALITY_LOW},
2086 * {@link VideoProfile#QUALITY_DEFAULT}.
Rekha Kumar07366812015-03-24 16:42:31 -07002087 */
2088 public void changeVideoQuality(int videoQuality) {
Tyler Gunn75958422015-04-15 14:23:42 -07002089 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002090 for (IVideoCallback callback : mVideoCallbacks.values()) {
2091 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002092 callback.changeVideoQuality(videoQuality);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002093 } catch (RemoteException ignored) {
2094 Log.w(this, "changeVideoQuality callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002095 }
Rekha Kumar07366812015-03-24 16:42:31 -07002096 }
2097 }
2098 }
Tyler Gunn6f657ee2016-09-02 09:55:25 -07002099
2100 /**
2101 * Returns a string representation of a call session event.
2102 *
2103 * @param event A call session event passed to {@link #handleCallSessionEvent(int)}.
2104 * @return String representation of the call session event.
2105 * @hide
2106 */
2107 public static String sessionEventToString(int event) {
2108 switch (event) {
2109 case SESSION_EVENT_CAMERA_FAILURE:
2110 return SESSION_EVENT_CAMERA_FAILURE_STR;
2111 case SESSION_EVENT_CAMERA_READY:
2112 return SESSION_EVENT_CAMERA_READY_STR;
2113 case SESSION_EVENT_RX_PAUSE:
2114 return SESSION_EVENT_RX_PAUSE_STR;
2115 case SESSION_EVENT_RX_RESUME:
2116 return SESSION_EVENT_RX_RESUME_STR;
2117 case SESSION_EVENT_TX_START:
2118 return SESSION_EVENT_TX_START_STR;
2119 case SESSION_EVENT_TX_STOP:
2120 return SESSION_EVENT_TX_STOP_STR;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08002121 case SESSION_EVENT_CAMERA_PERMISSION_ERROR:
2122 return SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR;
Tyler Gunn6f657ee2016-09-02 09:55:25 -07002123 default:
2124 return SESSION_EVENT_UNKNOWN_STR + " " + event;
2125 }
2126 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002127 }
2128
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002129 private final Listener mConnectionDeathListener = new Listener() {
2130 @Override
2131 public void onDestroyed(Connection c) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002132 if (mConferenceables.remove(c)) {
2133 fireOnConferenceableConnectionsChanged();
2134 }
2135 }
2136 };
2137
2138 private final Conference.Listener mConferenceDeathListener = new Conference.Listener() {
2139 @Override
2140 public void onDestroyed(Conference c) {
2141 if (mConferenceables.remove(c)) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002142 fireOnConferenceableConnectionsChanged();
2143 }
2144 }
2145 };
2146
Jay Shrauner229e3822014-08-15 09:23:07 -07002147 /**
2148 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
2149 * load factor before resizing, 1 means we only expect a single thread to
2150 * access the map so make only a single shard
2151 */
2152 private final Set<Listener> mListeners = Collections.newSetFromMap(
2153 new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1));
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002154 private final List<Conferenceable> mConferenceables = new ArrayList<>();
2155 private final List<Conferenceable> mUnmodifiableConferenceables =
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002156 Collections.unmodifiableList(mConferenceables);
Santos Cordonb6939982014-06-04 20:20:58 -07002157
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002158 // The internal telecom call ID associated with this connection.
2159 private String mTelecomCallId;
Pengquan Meng70c9885332017-10-02 18:09:03 -07002160 // The PhoneAccountHandle associated with this connection.
2161 private PhoneAccountHandle mPhoneAccountHandle;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002162 private int mState = STATE_NEW;
Yorke Lee4af59352015-05-13 14:14:54 -07002163 private CallAudioState mCallAudioState;
Andrew Lee100e2932014-09-08 15:34:24 -07002164 private Uri mAddress;
2165 private int mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -07002166 private String mCallerDisplayName;
2167 private int mCallerDisplayNamePresentation;
Andrew Lee100e2932014-09-08 15:34:24 -07002168 private boolean mRingbackRequested = false;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002169 private int mConnectionCapabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -07002170 private int mConnectionProperties;
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002171 private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002172 private VideoProvider mVideoProvider;
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002173 private boolean mAudioModeIsVoip;
Roshan Piuse927ec02015-07-15 15:47:21 -07002174 private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002175 private long mConnectElapsedTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002176 private StatusHints mStatusHints;
Tyler Gunnaa07df82014-07-17 07:50:22 -07002177 private int mVideoState;
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002178 private DisconnectCause mDisconnectCause;
Santos Cordon823fd3c2014-08-07 18:35:18 -07002179 private Conference mConference;
2180 private ConnectionService mConnectionService;
Santos Cordon6b7f9552015-05-27 17:21:45 -07002181 private Bundle mExtras;
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002182 private final Object mExtrasLock = new Object();
Tyler Gunn6986a632019-06-25 13:45:32 -07002183 /**
2184 * The direction of the connection; used where an existing connection is created and we need to
2185 * communicate to Telecom whether its incoming or outgoing.
2186 */
2187 private @Call.Details.CallDirection int mCallDirection = Call.Details.DIRECTION_UNKNOWN;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002188
2189 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002190 * Tracks the key set for the extras bundle provided on the last invocation of
2191 * {@link #setExtras(Bundle)}. Used so that on subsequent invocations we can remove any extras
2192 * keys which were set previously but are no longer present in the replacement Bundle.
2193 */
2194 private Set<String> mPreviousExtraKeys;
2195
2196 /**
Tyler Gunnd57d76c2019-09-24 14:53:23 -07002197 * The verification status for an incoming call's phone number.
2198 */
2199 private @VerificationStatus int mCallerNumberVerificationStatus;
2200
2201
2202 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002203 * Create a new Connection.
2204 */
Santos Cordonf2951102014-07-20 19:06:29 -07002205 public Connection() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002206
2207 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002208 * Returns the Telecom internal call ID associated with this connection. Should only be used
2209 * for debugging and tracing purposes.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002210 * <p>
2211 * Note: Access to the Telecom internal call ID is used for logging purposes only; this API is
2212 * provided to facilitate debugging of the Telephony stack only.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002213 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07002214 * @return The Telecom call ID, or {@code null} if it was not set.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002215 * @hide
2216 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002217 @SystemApi
2218 public final @Nullable String getTelecomCallId() {
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002219 return mTelecomCallId;
2220 }
2221
2222 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002223 * @return The address (e.g., phone number) to which this Connection is currently communicating.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002224 */
Andrew Lee100e2932014-09-08 15:34:24 -07002225 public final Uri getAddress() {
2226 return mAddress;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002227 }
2228
2229 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002230 * @return The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002231 * See {@link TelecomManager} for valid values.
Sailesh Nepal61203862014-07-11 14:50:13 -07002232 */
Andrew Lee100e2932014-09-08 15:34:24 -07002233 public final int getAddressPresentation() {
2234 return mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -07002235 }
2236
2237 /**
2238 * @return The caller display name (CNAP).
2239 */
2240 public final String getCallerDisplayName() {
2241 return mCallerDisplayName;
2242 }
2243
2244 /**
Nancy Chen9d568c02014-09-08 14:17:59 -07002245 * @return The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002246 * See {@link TelecomManager} for valid values.
Sailesh Nepal61203862014-07-11 14:50:13 -07002247 */
2248 public final int getCallerDisplayNamePresentation() {
2249 return mCallerDisplayNamePresentation;
2250 }
2251
2252 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002253 * @return The state of this Connection.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002254 */
2255 public final int getState() {
2256 return mState;
2257 }
2258
2259 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002260 * Returns the video state of the connection.
Yorke Lee32f24732015-05-12 16:18:03 -07002261 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
2262 * {@link VideoProfile#STATE_BIDIRECTIONAL},
2263 * {@link VideoProfile#STATE_TX_ENABLED},
2264 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002265 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002266 * @return The video state of the connection.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002267 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002268 public final @VideoProfile.VideoState int getVideoState() {
Tyler Gunnaa07df82014-07-17 07:50:22 -07002269 return mVideoState;
2270 }
2271
2272 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002273 * @return The audio state of the connection, describing how its audio is currently
Ihab Awad542e0ea2014-05-16 10:22:16 -07002274 * being routed by the system. This is {@code null} if this Connection
2275 * does not directly know about its audio state.
Yorke Lee4af59352015-05-13 14:14:54 -07002276 * @deprecated Use {@link #getCallAudioState()} instead.
2277 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -07002278 */
Yorke Lee4af59352015-05-13 14:14:54 -07002279 @SystemApi
2280 @Deprecated
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002281 public final AudioState getAudioState() {
Sailesh Nepal000d38a2015-06-21 10:25:13 -07002282 if (mCallAudioState == null) {
2283 return null;
2284 }
Yorke Lee4af59352015-05-13 14:14:54 -07002285 return new AudioState(mCallAudioState);
2286 }
2287
2288 /**
2289 * @return The audio state of the connection, describing how its audio is currently
2290 * being routed by the system. This is {@code null} if this Connection
2291 * does not directly know about its audio state.
2292 */
2293 public final CallAudioState getCallAudioState() {
2294 return mCallAudioState;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002295 }
2296
2297 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002298 * @return The conference that this connection is a part of. Null if it is not part of any
2299 * conference.
2300 */
2301 public final Conference getConference() {
2302 return mConference;
2303 }
2304
2305 /**
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002306 * Returns whether this connection is requesting that the system play a ringback tone
2307 * on its behalf.
2308 */
Andrew Lee100e2932014-09-08 15:34:24 -07002309 public final boolean isRingbackRequested() {
2310 return mRingbackRequested;
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002311 }
2312
2313 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002314 * @return True if the connection's audio mode is VOIP.
2315 */
2316 public final boolean getAudioModeIsVoip() {
2317 return mAudioModeIsVoip;
2318 }
2319
2320 /**
Roshan Piuse927ec02015-07-15 15:47:21 -07002321 * Retrieves the connection start time of the {@code Connnection}, if specified. A value of
2322 * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
2323 * start time of the conference.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002324 * <p>
2325 * Note: This is an implementation detail specific to IMS conference calls over a mobile
2326 * network.
Roshan Piuse927ec02015-07-15 15:47:21 -07002327 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07002328 * @return The time at which the {@code Connnection} was connected. Will be a value as retrieved
2329 * from {@link System#currentTimeMillis()}.
Roshan Piuse927ec02015-07-15 15:47:21 -07002330 *
2331 * @hide
2332 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002333 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002334 public final @IntRange(from = 0) long getConnectTimeMillis() {
Roshan Piuse927ec02015-07-15 15:47:21 -07002335 return mConnectTimeMillis;
2336 }
2337
2338 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002339 * Retrieves the connection start time of the {@link Connection}, if specified. A value of
2340 * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
Tyler Gunnc9503d62020-01-27 10:30:51 -08002341 * start time of the connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002342 * <p>
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002343 * Based on the value of {@link SystemClock#elapsedRealtime()}, which ensures that wall-clock
2344 * changes do not impact the call duration.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002345 * <p>
2346 * Used internally in Telephony when migrating conference participant data for IMS conferences.
Tyler Gunnc9503d62020-01-27 10:30:51 -08002347 * <p>
2348 * The value returned is the same one set using
2349 * {@link #setConnectionStartElapsedRealtimeMillis(long)}. This value is never updated from
2350 * the Telecom framework, so no permission enforcement occurs when retrieving the value with
2351 * this method.
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002352 *
2353 * @return The time at which the {@link Connection} was connected.
2354 *
2355 * @hide
2356 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002357 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002358 public final @ElapsedRealtimeLong long getConnectionStartElapsedRealtimeMillis() {
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002359 return mConnectElapsedTimeMillis;
2360 }
2361
2362 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002363 * @return The status hints for this connection.
2364 */
2365 public final StatusHints getStatusHints() {
2366 return mStatusHints;
2367 }
2368
2369 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002370 * Returns the extras associated with this connection.
Tyler Gunn2cbe2b52016-05-04 15:48:10 +00002371 * <p>
2372 * Extras should be updated using {@link #putExtras(Bundle)}.
2373 * <p>
2374 * Telecom or an {@link InCallService} can also update the extras via
2375 * {@link android.telecom.Call#putExtras(Bundle)}, and
2376 * {@link Call#removeExtras(List)}.
2377 * <p>
2378 * The connection is notified of changes to the extras made by Telecom or an
2379 * {@link InCallService} by {@link #onExtrasChanged(Bundle)}.
Tyler Gunndee56a82016-03-23 16:06:34 -07002380 *
Santos Cordon6b7f9552015-05-27 17:21:45 -07002381 * @return The extras associated with this connection.
2382 */
2383 public final Bundle getExtras() {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002384 Bundle extras = null;
2385 synchronized (mExtrasLock) {
2386 if (mExtras != null) {
2387 extras = new Bundle(mExtras);
2388 }
2389 }
2390 return extras;
Santos Cordon6b7f9552015-05-27 17:21:45 -07002391 }
2392
2393 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002394 * Assign a listener to be notified of state changes.
2395 *
2396 * @param l A listener.
2397 * @return This Connection.
2398 *
2399 * @hide
2400 */
Tyler Gunn633e4c32019-10-24 15:40:48 -07002401 final Connection addConnectionListener(Listener l) {
Santos Cordond34e5712014-08-05 18:54:03 +00002402 mListeners.add(l);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002403 return this;
2404 }
2405
2406 /**
2407 * Remove a previously assigned listener that was being notified of state changes.
2408 *
2409 * @param l A Listener.
2410 * @return This Connection.
2411 *
2412 * @hide
2413 */
Tyler Gunn633e4c32019-10-24 15:40:48 -07002414 final Connection removeConnectionListener(Listener l) {
Jay Shrauner229e3822014-08-15 09:23:07 -07002415 if (l != null) {
2416 mListeners.remove(l);
2417 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002418 return this;
2419 }
2420
2421 /**
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002422 * @return The {@link DisconnectCause} for this connection.
Evan Charltonbf11f982014-07-20 22:06:28 -07002423 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002424 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002425 return mDisconnectCause;
Evan Charltonbf11f982014-07-20 22:06:28 -07002426 }
2427
2428 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002429 * Sets the telecom call ID associated with this Connection. The Telecom Call ID should be used
2430 * ONLY for debugging purposes.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002431 * <p>
2432 * Note: Access to the Telecom internal call ID is used for logging purposes only; this API is
2433 * provided to facilitate debugging of the Telephony stack only. Changing the ID via this
2434 * method does NOT change any functionality in Telephony or Telecom and impacts only logging.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002435 *
2436 * @param callId The telecom call ID.
2437 * @hide
2438 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002439 @SystemApi
2440 public void setTelecomCallId(@NonNull String callId) {
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002441 mTelecomCallId = callId;
2442 }
2443
2444 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002445 * Inform this Connection that the state of its audio output has been changed externally.
2446 *
2447 * @param state The new audio state.
Sailesh Nepal400cc482014-06-26 12:04:00 -07002448 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -07002449 */
Yorke Lee4af59352015-05-13 14:14:54 -07002450 final void setCallAudioState(CallAudioState state) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002451 checkImmutable();
Ihab Awad60ac30b2014-05-20 22:32:12 -07002452 Log.d(this, "setAudioState %s", state);
Yorke Lee4af59352015-05-13 14:14:54 -07002453 mCallAudioState = state;
2454 onAudioStateChanged(getAudioState());
2455 onCallAudioStateChanged(state);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002456 }
2457
2458 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002459 * @param state An integer value of a {@code STATE_*} constant.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002460 * @return A string representation of the value.
2461 */
2462 public static String stateToString(int state) {
2463 switch (state) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002464 case STATE_INITIALIZING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002465 return "INITIALIZING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002466 case STATE_NEW:
Yorke Leee911c8d2015-07-14 11:39:36 -07002467 return "NEW";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002468 case STATE_RINGING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002469 return "RINGING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002470 case STATE_DIALING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002471 return "DIALING";
Tyler Gunnc96b5e02016-07-07 22:53:57 -07002472 case STATE_PULLING_CALL:
2473 return "PULLING_CALL";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002474 case STATE_ACTIVE:
Yorke Leee911c8d2015-07-14 11:39:36 -07002475 return "ACTIVE";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002476 case STATE_HOLDING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002477 return "HOLDING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002478 case STATE_DISCONNECTED:
Ihab Awad542e0ea2014-05-16 10:22:16 -07002479 return "DISCONNECTED";
2480 default:
Ihab Awad60ac30b2014-05-20 22:32:12 -07002481 Log.wtf(Connection.class, "Unknown state %d", state);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002482 return "UNKNOWN";
2483 }
2484 }
2485
2486 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002487 * Returns the connection's capabilities, as a bit mask of the {@code CAPABILITY_*} constants.
Ihab Awad52a28f62014-06-18 10:26:34 -07002488 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002489 public final int getConnectionCapabilities() {
2490 return mConnectionCapabilities;
Ihab Awad52a28f62014-06-18 10:26:34 -07002491 }
2492
2493 /**
Tyler Gunn720c6642016-03-22 09:02:47 -07002494 * Returns the connection's properties, as a bit mask of the {@code PROPERTY_*} constants.
2495 */
2496 public final int getConnectionProperties() {
2497 return mConnectionProperties;
2498 }
2499
2500 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002501 * Returns the connection's supported audio routes.
2502 *
2503 * @hide
2504 */
2505 public final int getSupportedAudioRoutes() {
2506 return mSupportedAudioRoutes;
2507 }
2508
2509 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002510 * Sets the value of the {@link #getAddress()} property.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002511 *
Andrew Lee100e2932014-09-08 15:34:24 -07002512 * @param address The new address.
2513 * @param presentation The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002514 * See {@link TelecomManager} for valid values.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002515 */
Andrew Lee100e2932014-09-08 15:34:24 -07002516 public final void setAddress(Uri address, int presentation) {
2517 Log.d(this, "setAddress %s", address);
2518 mAddress = address;
2519 mAddressPresentation = presentation;
Santos Cordond34e5712014-08-05 18:54:03 +00002520 for (Listener l : mListeners) {
Andrew Lee100e2932014-09-08 15:34:24 -07002521 l.onAddressChanged(this, address, presentation);
Santos Cordond34e5712014-08-05 18:54:03 +00002522 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002523 }
2524
2525 /**
Sailesh Nepal61203862014-07-11 14:50:13 -07002526 * Sets the caller display name (CNAP).
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002527 *
Sailesh Nepal61203862014-07-11 14:50:13 -07002528 * @param callerDisplayName The new display name.
Nancy Chen9d568c02014-09-08 14:17:59 -07002529 * @param presentation The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002530 * See {@link TelecomManager} for valid values.
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002531 */
Sailesh Nepal61203862014-07-11 14:50:13 -07002532 public final void setCallerDisplayName(String callerDisplayName, int presentation) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002533 checkImmutable();
Sailesh Nepal61203862014-07-11 14:50:13 -07002534 Log.d(this, "setCallerDisplayName %s", callerDisplayName);
Santos Cordond34e5712014-08-05 18:54:03 +00002535 mCallerDisplayName = callerDisplayName;
2536 mCallerDisplayNamePresentation = presentation;
2537 for (Listener l : mListeners) {
2538 l.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
2539 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002540 }
2541
2542 /**
Tyler Gunnaa07df82014-07-17 07:50:22 -07002543 * Set the video state for the connection.
Yorke Lee32f24732015-05-12 16:18:03 -07002544 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
2545 * {@link VideoProfile#STATE_BIDIRECTIONAL},
2546 * {@link VideoProfile#STATE_TX_ENABLED},
2547 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002548 *
2549 * @param videoState The new video state.
2550 */
2551 public final void setVideoState(int videoState) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002552 checkImmutable();
Tyler Gunnaa07df82014-07-17 07:50:22 -07002553 Log.d(this, "setVideoState %d", videoState);
Santos Cordond34e5712014-08-05 18:54:03 +00002554 mVideoState = videoState;
2555 for (Listener l : mListeners) {
2556 l.onVideoStateChanged(this, mVideoState);
2557 }
Tyler Gunnaa07df82014-07-17 07:50:22 -07002558 }
2559
2560 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002561 * Sets state to active (e.g., an ongoing connection where two or more parties can actively
Ihab Awad542e0ea2014-05-16 10:22:16 -07002562 * communicate).
2563 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002564 public final void setActive() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002565 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002566 setRingbackRequested(false);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002567 setState(STATE_ACTIVE);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002568 }
2569
2570 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002571 * Sets state to ringing (e.g., an inbound ringing connection).
Ihab Awad542e0ea2014-05-16 10:22:16 -07002572 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002573 public final void setRinging() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002574 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002575 setState(STATE_RINGING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002576 }
2577
2578 /**
Evan Charltonbf11f982014-07-20 22:06:28 -07002579 * Sets state to initializing (this Connection is not yet ready to be used).
2580 */
2581 public final void setInitializing() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002582 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002583 setState(STATE_INITIALIZING);
Evan Charltonbf11f982014-07-20 22:06:28 -07002584 }
2585
2586 /**
2587 * Sets state to initialized (the Connection has been set up and is now ready to be used).
2588 */
2589 public final void setInitialized() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002590 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002591 setState(STATE_NEW);
Evan Charltonbf11f982014-07-20 22:06:28 -07002592 }
2593
2594 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002595 * Sets state to dialing (e.g., dialing an outbound connection).
Ihab Awad542e0ea2014-05-16 10:22:16 -07002596 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002597 public final void setDialing() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002598 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002599 setState(STATE_DIALING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002600 }
2601
2602 /**
Tyler Gunnc242ceb2016-06-29 22:35:45 -07002603 * Sets state to pulling (e.g. the connection is being pulled to the local device from another
2604 * device). Only applicable for {@link Connection}s with
2605 * {@link Connection#PROPERTY_IS_EXTERNAL_CALL} and {@link Connection#CAPABILITY_CAN_PULL_CALL}.
2606 */
2607 public final void setPulling() {
2608 checkImmutable();
2609 setState(STATE_PULLING_CALL);
2610 }
2611
2612 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002613 * Sets state to be on hold.
2614 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002615 public final void setOnHold() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002616 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002617 setState(STATE_HOLDING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002618 }
2619
2620 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002621 * Sets the video connection provider.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002622 * @param videoProvider The video provider.
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002623 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002624 public final void setVideoProvider(VideoProvider videoProvider) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002625 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002626 mVideoProvider = videoProvider;
Santos Cordond34e5712014-08-05 18:54:03 +00002627 for (Listener l : mListeners) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002628 l.onVideoProviderChanged(this, videoProvider);
Santos Cordond34e5712014-08-05 18:54:03 +00002629 }
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002630 }
2631
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002632 public final VideoProvider getVideoProvider() {
2633 return mVideoProvider;
Andrew Leea27a1932014-07-09 17:07:13 -07002634 }
2635
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002636 /**
Sailesh Nepal091768c2014-06-30 15:15:23 -07002637 * Sets state to disconnected.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002638 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002639 * @param disconnectCause The reason for the disconnection, as specified by
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002640 * {@link DisconnectCause}.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002641 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002642 public final void setDisconnected(DisconnectCause disconnectCause) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002643 checkImmutable();
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002644 mDisconnectCause = disconnectCause;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002645 setState(STATE_DISCONNECTED);
mike dooleyf34519b2014-09-16 17:33:40 -07002646 Log.d(this, "Disconnected with cause %s", disconnectCause);
Santos Cordond34e5712014-08-05 18:54:03 +00002647 for (Listener l : mListeners) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002648 l.onDisconnected(this, disconnectCause);
Santos Cordond34e5712014-08-05 18:54:03 +00002649 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002650 }
2651
2652 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002653 * Informs listeners that this {@code Connection} is in a post-dial wait state. This is done
2654 * when (a) the {@code Connection} is issuing a DTMF sequence; (b) it has encountered a "wait"
2655 * character; and (c) it wishes to inform the In-Call app that it is waiting for the end-user
2656 * to send an {@link #onPostDialContinue(boolean)} signal.
2657 *
2658 * @param remaining The DTMF character sequence remaining to be emitted once the
2659 * {@link #onPostDialContinue(boolean)} is received, including any "wait" characters
2660 * that remaining sequence may contain.
Sailesh Nepal091768c2014-06-30 15:15:23 -07002661 */
2662 public final void setPostDialWait(String remaining) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002663 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002664 for (Listener l : mListeners) {
2665 l.onPostDialWait(this, remaining);
2666 }
Sailesh Nepal091768c2014-06-30 15:15:23 -07002667 }
2668
2669 /**
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002670 * Informs listeners that this {@code Connection} has processed a character in the post-dial
2671 * started state. This is done when (a) the {@code Connection} is issuing a DTMF sequence;
Sailesh Nepal1ed85612015-01-31 15:17:19 -08002672 * and (b) it wishes to signal Telecom to play the corresponding DTMF tone locally.
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002673 *
2674 * @param nextChar The DTMF character that was just processed by the {@code Connection}.
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002675 */
Sailesh Nepal1ed85612015-01-31 15:17:19 -08002676 public final void setNextPostDialChar(char nextChar) {
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002677 checkImmutable();
2678 for (Listener l : mListeners) {
2679 l.onPostDialChar(this, nextChar);
2680 }
2681 }
2682
2683 /**
Ihab Awadf8358972014-05-28 16:46:42 -07002684 * Requests that the framework play a ringback tone. This is to be invoked by implementations
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002685 * that do not play a ringback tone themselves in the connection's audio stream.
Ihab Awadf8358972014-05-28 16:46:42 -07002686 *
2687 * @param ringback Whether the ringback tone is to be played.
2688 */
Andrew Lee100e2932014-09-08 15:34:24 -07002689 public final void setRingbackRequested(boolean ringback) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002690 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002691 if (mRingbackRequested != ringback) {
2692 mRingbackRequested = ringback;
Santos Cordond34e5712014-08-05 18:54:03 +00002693 for (Listener l : mListeners) {
Andrew Lee100e2932014-09-08 15:34:24 -07002694 l.onRingbackRequested(this, ringback);
Santos Cordond34e5712014-08-05 18:54:03 +00002695 }
2696 }
Ihab Awadf8358972014-05-28 16:46:42 -07002697 }
2698
2699 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002700 * Sets the connection's capabilities as a bit mask of the {@code CAPABILITY_*} constants.
Sailesh Nepal1a7061b2014-07-09 21:03:20 -07002701 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002702 * @param connectionCapabilities The new connection capabilities.
Santos Cordonb6939982014-06-04 20:20:58 -07002703 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002704 public final void setConnectionCapabilities(int connectionCapabilities) {
2705 checkImmutable();
2706 if (mConnectionCapabilities != connectionCapabilities) {
2707 mConnectionCapabilities = connectionCapabilities;
Santos Cordond34e5712014-08-05 18:54:03 +00002708 for (Listener l : mListeners) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002709 l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities);
Santos Cordond34e5712014-08-05 18:54:03 +00002710 }
2711 }
Santos Cordonb6939982014-06-04 20:20:58 -07002712 }
2713
2714 /**
Tyler Gunn720c6642016-03-22 09:02:47 -07002715 * Sets the connection's properties as a bit mask of the {@code PROPERTY_*} constants.
2716 *
2717 * @param connectionProperties The new connection properties.
2718 */
2719 public final void setConnectionProperties(int connectionProperties) {
2720 checkImmutable();
2721 if (mConnectionProperties != connectionProperties) {
2722 mConnectionProperties = connectionProperties;
2723 for (Listener l : mListeners) {
2724 l.onConnectionPropertiesChanged(this, mConnectionProperties);
2725 }
2726 }
2727 }
2728
2729 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002730 * Sets the supported audio routes.
2731 *
2732 * @param supportedAudioRoutes the supported audio routes as a bitmask.
2733 * See {@link CallAudioState}
2734 * @hide
2735 */
2736 public final void setSupportedAudioRoutes(int supportedAudioRoutes) {
2737 if ((supportedAudioRoutes
2738 & (CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_SPEAKER)) == 0) {
2739 throw new IllegalArgumentException(
2740 "supported audio routes must include either speaker or earpiece");
2741 }
2742
2743 if (mSupportedAudioRoutes != supportedAudioRoutes) {
2744 mSupportedAudioRoutes = supportedAudioRoutes;
2745 for (Listener l : mListeners) {
2746 l.onSupportedAudioRoutesChanged(this, mSupportedAudioRoutes);
2747 }
2748 }
2749 }
2750
2751 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002752 * Tears down the Connection object.
Santos Cordonb6939982014-06-04 20:20:58 -07002753 */
Evan Charlton36a71342014-07-19 16:31:02 -07002754 public final void destroy() {
Jay Shrauner229e3822014-08-15 09:23:07 -07002755 for (Listener l : mListeners) {
2756 l.onDestroyed(this);
Santos Cordond34e5712014-08-05 18:54:03 +00002757 }
Santos Cordonb6939982014-06-04 20:20:58 -07002758 }
2759
2760 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002761 * Requests that the framework use VOIP audio mode for this connection.
2762 *
2763 * @param isVoip True if the audio mode is VOIP.
2764 */
2765 public final void setAudioModeIsVoip(boolean isVoip) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002766 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002767 mAudioModeIsVoip = isVoip;
2768 for (Listener l : mListeners) {
2769 l.onAudioModeIsVoipChanged(this, isVoip);
2770 }
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002771 }
2772
2773 /**
Roshan Piuse927ec02015-07-15 15:47:21 -07002774 * Sets the time at which a call became active on this Connection. This is set only
2775 * when a conference call becomes active on this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002776 * <p>
Tyler Gunnc9503d62020-01-27 10:30:51 -08002777 * This time corresponds to the date/time of connection and is stored in the call log in
2778 * {@link android.provider.CallLog.Calls#DATE}.
2779 * <p>
Tyler Gunnc63f9082019-10-15 13:19:26 -07002780 * Used by telephony to maintain calls associated with an IMS Conference.
Roshan Piuse927ec02015-07-15 15:47:21 -07002781 *
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002782 * @param connectTimeMillis The connection time, in milliseconds. Should be set using a value
2783 * obtained from {@link System#currentTimeMillis()}.
Roshan Piuse927ec02015-07-15 15:47:21 -07002784 *
2785 * @hide
2786 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002787 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002788 @RequiresPermission(MODIFY_PHONE_STATE)
2789 public final void setConnectTimeMillis(@IntRange(from = 0) long connectTimeMillis) {
Roshan Piuse927ec02015-07-15 15:47:21 -07002790 mConnectTimeMillis = connectTimeMillis;
2791 }
2792
2793 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002794 * Sets the time at which a call became active on this Connection. This is set only
2795 * when a conference call becomes active on this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002796 * <p>
Tyler Gunnc9503d62020-01-27 10:30:51 -08002797 * This time is used to establish the duration of a call. It uses
2798 * {@link SystemClock#elapsedRealtime()} to ensure that the call duration is not impacted by
2799 * time zone changes during a call. The difference between the current
2800 * {@link SystemClock#elapsedRealtime()} and the value set at the connection start time is used
2801 * to populate {@link android.provider.CallLog.Calls#DURATION} in the call log.
2802 * <p>
Tyler Gunnc63f9082019-10-15 13:19:26 -07002803 * Used by telephony to maintain calls associated with an IMS Conference.
Tyler Gunnc9503d62020-01-27 10:30:51 -08002804 *
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002805 * @param connectElapsedTimeMillis The connection time, in milliseconds. Stored in the format
2806 * {@link SystemClock#elapsedRealtime()}.
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002807 * @hide
2808 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002809 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002810 @RequiresPermission(MODIFY_PHONE_STATE)
2811 public final void setConnectionStartElapsedRealtimeMillis(
2812 @ElapsedRealtimeLong long connectElapsedTimeMillis) {
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002813 mConnectElapsedTimeMillis = connectElapsedTimeMillis;
2814 }
2815
2816 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002817 * Sets the label and icon status to display in the in-call UI.
2818 *
2819 * @param statusHints The status label and icon to set.
2820 */
2821 public final void setStatusHints(StatusHints statusHints) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002822 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002823 mStatusHints = statusHints;
2824 for (Listener l : mListeners) {
2825 l.onStatusHintsChanged(this, statusHints);
2826 }
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002827 }
2828
2829 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002830 * Sets the connections with which this connection can be conferenced.
2831 *
2832 * @param conferenceableConnections The set of connections this connection can conference with.
2833 */
2834 public final void setConferenceableConnections(List<Connection> conferenceableConnections) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002835 checkImmutable();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002836 clearConferenceableList();
2837 for (Connection c : conferenceableConnections) {
2838 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
2839 // small amount of items here.
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002840 if (!mConferenceables.contains(c)) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002841 c.addConnectionListener(mConnectionDeathListener);
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002842 mConferenceables.add(c);
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002843 }
2844 }
2845 fireOnConferenceableConnectionsChanged();
2846 }
2847
2848 /**
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002849 * Similar to {@link #setConferenceableConnections(java.util.List)}, sets a list of connections
2850 * or conferences with which this connection can be conferenced.
2851 *
2852 * @param conferenceables The conferenceables.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002853 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002854 public final void setConferenceables(List<Conferenceable> conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002855 clearConferenceableList();
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002856 for (Conferenceable c : conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002857 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
2858 // small amount of items here.
2859 if (!mConferenceables.contains(c)) {
2860 if (c instanceof Connection) {
2861 Connection connection = (Connection) c;
2862 connection.addConnectionListener(mConnectionDeathListener);
2863 } else if (c instanceof Conference) {
2864 Conference conference = (Conference) c;
2865 conference.addListener(mConferenceDeathListener);
2866 }
2867 mConferenceables.add(c);
2868 }
2869 }
2870 fireOnConferenceableConnectionsChanged();
2871 }
2872
2873 /**
Tyler Gunnc63f9082019-10-15 13:19:26 -07002874 * Resets the CDMA connection time.
2875 * <p>
2876 * This is an implementation detail specific to legacy CDMA calls on mobile networks.
Mengjun Leng25707742017-07-04 11:10:37 +08002877 * @hide
Mengjun Leng25707742017-07-04 11:10:37 +08002878 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002879 @SystemApi
Mengjun Leng25707742017-07-04 11:10:37 +08002880 public final void resetConnectionTime() {
2881 for (Listener l : mListeners) {
2882 l.onConnectionTimeReset(this);
2883 }
2884 }
2885
2886 /**
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002887 * Returns the connections or conferences with which this connection can be conferenced.
2888 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002889 public final List<Conferenceable> getConferenceables() {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002890 return mUnmodifiableConferenceables;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002891 }
2892
Yorke Lee53463962015-08-04 16:07:19 -07002893 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002894 * @hide
2895 */
2896 public final void setConnectionService(ConnectionService connectionService) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002897 checkImmutable();
Santos Cordon823fd3c2014-08-07 18:35:18 -07002898 if (mConnectionService != null) {
2899 Log.e(this, new Exception(), "Trying to set ConnectionService on a connection " +
2900 "which is already associated with another ConnectionService.");
2901 } else {
2902 mConnectionService = connectionService;
2903 }
2904 }
2905
2906 /**
2907 * @hide
2908 */
2909 public final void unsetConnectionService(ConnectionService connectionService) {
2910 if (mConnectionService != connectionService) {
2911 Log.e(this, new Exception(), "Trying to remove ConnectionService from a Connection " +
2912 "that does not belong to the ConnectionService.");
2913 } else {
2914 mConnectionService = null;
2915 }
2916 }
2917
2918 /**
2919 * Sets the conference that this connection is a part of. This will fail if the connection is
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002920 * already part of a conference. {@link #resetConference} to un-set the conference first.
Santos Cordon823fd3c2014-08-07 18:35:18 -07002921 *
2922 * @param conference The conference.
2923 * @return {@code true} if the conference was successfully set.
2924 * @hide
2925 */
2926 public final boolean setConference(Conference conference) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002927 checkImmutable();
Santos Cordon823fd3c2014-08-07 18:35:18 -07002928 // We check to see if it is already part of another conference.
Santos Cordon0159ac02014-08-21 14:28:11 -07002929 if (mConference == null) {
Santos Cordon823fd3c2014-08-07 18:35:18 -07002930 mConference = conference;
Santos Cordon0159ac02014-08-21 14:28:11 -07002931 if (mConnectionService != null && mConnectionService.containsConference(conference)) {
2932 fireConferenceChanged();
2933 }
Santos Cordon823fd3c2014-08-07 18:35:18 -07002934 return true;
2935 }
2936 return false;
2937 }
2938
2939 /**
2940 * Resets the conference that this connection is a part of.
2941 * @hide
2942 */
2943 public final void resetConference() {
2944 if (mConference != null) {
Santos Cordon0159ac02014-08-21 14:28:11 -07002945 Log.d(this, "Conference reset");
Santos Cordon823fd3c2014-08-07 18:35:18 -07002946 mConference = null;
2947 fireConferenceChanged();
2948 }
2949 }
2950
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002951 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002952 * Set some extras that can be associated with this {@code Connection}.
2953 * <p>
2954 * New or existing keys are replaced in the {@code Connection} extras. Keys which are no longer
2955 * in the new extras, but were present the last time {@code setExtras} was called are removed.
2956 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07002957 * Alternatively you may use the {@link #putExtras(Bundle)}, and
2958 * {@link #removeExtras(String...)} methods to modify the extras.
2959 * <p>
Tyler Gunndee56a82016-03-23 16:06:34 -07002960 * 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 -07002961 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
2962 *
2963 * @param extras The extras associated with this {@code Connection}.
2964 */
2965 public final void setExtras(@Nullable Bundle extras) {
2966 checkImmutable();
Tyler Gunndee56a82016-03-23 16:06:34 -07002967
2968 // Add/replace any new or changed extras values.
2969 putExtras(extras);
2970
2971 // If we have used "setExtras" in the past, compare the key set from the last invocation to
2972 // the current one and remove any keys that went away.
2973 if (mPreviousExtraKeys != null) {
2974 List<String> toRemove = new ArrayList<String>();
2975 for (String oldKey : mPreviousExtraKeys) {
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07002976 if (extras == null || !extras.containsKey(oldKey)) {
Tyler Gunndee56a82016-03-23 16:06:34 -07002977 toRemove.add(oldKey);
2978 }
2979 }
2980 if (!toRemove.isEmpty()) {
2981 removeExtras(toRemove);
2982 }
2983 }
2984
2985 // Track the keys the last time set called setExtras. This way, the next time setExtras is
2986 // called we can see if the caller has removed any extras values.
2987 if (mPreviousExtraKeys == null) {
2988 mPreviousExtraKeys = new ArraySet<String>();
2989 }
2990 mPreviousExtraKeys.clear();
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07002991 if (extras != null) {
2992 mPreviousExtraKeys.addAll(extras.keySet());
2993 }
Tyler Gunndee56a82016-03-23 16:06:34 -07002994 }
2995
2996 /**
2997 * Adds some extras to this {@code Connection}. Existing keys are replaced and new ones are
2998 * added.
2999 * <p>
3000 * No assumptions should be made as to how an In-Call UI or service will handle these extras.
3001 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
3002 *
3003 * @param extras The extras to add.
3004 */
3005 public final void putExtras(@NonNull Bundle extras) {
3006 checkImmutable();
3007 if (extras == null) {
3008 return;
3009 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003010 // Creating a duplicate bundle so we don't have to synchronize on mExtrasLock while calling
3011 // the listeners.
3012 Bundle listenerExtras;
3013 synchronized (mExtrasLock) {
3014 if (mExtras == null) {
3015 mExtras = new Bundle();
3016 }
3017 mExtras.putAll(extras);
3018 listenerExtras = new Bundle(mExtras);
Tyler Gunndee56a82016-03-23 16:06:34 -07003019 }
Santos Cordon6b7f9552015-05-27 17:21:45 -07003020 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003021 // Create a new clone of the extras for each listener so that they don't clobber
3022 // each other
3023 l.onExtrasChanged(this, new Bundle(listenerExtras));
Santos Cordon6b7f9552015-05-27 17:21:45 -07003024 }
3025 }
3026
3027 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -07003028 * Removes extras from this {@code Connection}.
Tyler Gunndee56a82016-03-23 16:06:34 -07003029 *
Tyler Gunn071be6f2016-05-10 14:52:33 -07003030 * @param keys The keys of the extras to remove.
Tyler Gunndee56a82016-03-23 16:06:34 -07003031 */
3032 public final void removeExtras(List<String> keys) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003033 synchronized (mExtrasLock) {
3034 if (mExtras != null) {
3035 for (String key : keys) {
3036 mExtras.remove(key);
3037 }
Tyler Gunndee56a82016-03-23 16:06:34 -07003038 }
3039 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003040 List<String> unmodifiableKeys = Collections.unmodifiableList(keys);
Tyler Gunndee56a82016-03-23 16:06:34 -07003041 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003042 l.onExtrasRemoved(this, unmodifiableKeys);
Tyler Gunndee56a82016-03-23 16:06:34 -07003043 }
3044 }
3045
3046 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -07003047 * Removes extras from this {@code Connection}.
3048 *
3049 * @param keys The keys of the extras to remove.
3050 */
3051 public final void removeExtras(String ... keys) {
3052 removeExtras(Arrays.asList(keys));
3053 }
3054
3055 /**
Tyler Gunnf5035432017-01-09 09:43:12 -08003056 * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will
3057 * be change to the {@link #getCallAudioState()}.
3058 * <p>
3059 * Used by self-managed {@link ConnectionService}s which wish to change the audio route for a
3060 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
3061 * <p>
3062 * See also {@link InCallService#setAudioRoute(int)}.
3063 *
3064 * @param route The audio route to use (one of {@link CallAudioState#ROUTE_BLUETOOTH},
3065 * {@link CallAudioState#ROUTE_EARPIECE}, {@link CallAudioState#ROUTE_SPEAKER}, or
3066 * {@link CallAudioState#ROUTE_WIRED_HEADSET}).
3067 */
3068 public final void setAudioRoute(int route) {
3069 for (Listener l : mListeners) {
Hall Liua98f58b52017-11-07 17:59:28 -08003070 l.onAudioRouteChanged(this, route, null);
3071 }
3072 }
3073
3074 /**
Hall Liua98f58b52017-11-07 17:59:28 -08003075 * Request audio routing to a specific bluetooth device. Calling this method may result in
3076 * the device routing audio to a different bluetooth device than the one specified if the
3077 * bluetooth stack is unable to route audio to the requested device.
3078 * A list of available devices can be obtained via
3079 * {@link CallAudioState#getSupportedBluetoothDevices()}
3080 *
3081 * <p>
3082 * Used by self-managed {@link ConnectionService}s which wish to use bluetooth audio for a
3083 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
3084 * <p>
Hall Liu2b6a6a32018-04-02 13:52:57 -07003085 * See also {@link InCallService#requestBluetoothAudio(BluetoothDevice)}
3086 * @param bluetoothDevice The bluetooth device to connect to.
Hall Liua98f58b52017-11-07 17:59:28 -08003087 */
Hall Liu2b6a6a32018-04-02 13:52:57 -07003088 public void requestBluetoothAudio(@NonNull BluetoothDevice bluetoothDevice) {
Hall Liua98f58b52017-11-07 17:59:28 -08003089 for (Listener l : mListeners) {
Hall Liu2b6a6a32018-04-02 13:52:57 -07003090 l.onAudioRouteChanged(this, CallAudioState.ROUTE_BLUETOOTH,
3091 bluetoothDevice.getAddress());
Tyler Gunnf5035432017-01-09 09:43:12 -08003092 }
3093 }
3094
3095 /**
Hall Liub64ac4c2017-02-06 10:49:48 -08003096 * Informs listeners that a previously requested RTT session via
3097 * {@link ConnectionRequest#isRequestingRtt()} or
Hall Liu37dfdb02017-12-04 14:19:30 -08003098 * {@link #onStartRtt(RttTextStream)} has succeeded.
Hall Liub64ac4c2017-02-06 10:49:48 -08003099 */
3100 public final void sendRttInitiationSuccess() {
3101 mListeners.forEach((l) -> l.onRttInitiationSuccess(Connection.this));
3102 }
3103
3104 /**
3105 * Informs listeners that a previously requested RTT session via
Hall Liu37dfdb02017-12-04 14:19:30 -08003106 * {@link ConnectionRequest#isRequestingRtt()} or {@link #onStartRtt(RttTextStream)}
Hall Liub64ac4c2017-02-06 10:49:48 -08003107 * has failed.
3108 * @param reason One of the reason codes defined in {@link RttModifyStatus}, with the
3109 * exception of {@link RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}.
Hall Liub64ac4c2017-02-06 10:49:48 -08003110 */
3111 public final void sendRttInitiationFailure(int reason) {
3112 mListeners.forEach((l) -> l.onRttInitiationFailure(Connection.this, reason));
3113 }
3114
3115 /**
3116 * Informs listeners that a currently active RTT session has been terminated by the remote
3117 * side of the coll.
Hall Liub64ac4c2017-02-06 10:49:48 -08003118 */
3119 public final void sendRttSessionRemotelyTerminated() {
3120 mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this));
3121 }
3122
3123 /**
3124 * Informs listeners that the remote side of the call has requested an upgrade to include an
3125 * RTT session in the call.
Hall Liub64ac4c2017-02-06 10:49:48 -08003126 */
3127 public final void sendRemoteRttRequest() {
3128 mListeners.forEach((l) -> l.onRemoteRttRequest(Connection.this));
3129 }
3130
3131 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003132 * Notifies this Connection that the {@link #getAudioState()} property has a new value.
Sailesh Nepal400cc482014-06-26 12:04:00 -07003133 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003134 * @param state The new connection audio state.
Yorke Lee4af59352015-05-13 14:14:54 -07003135 * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead.
3136 * @hide
Sailesh Nepal400cc482014-06-26 12:04:00 -07003137 */
Yorke Lee4af59352015-05-13 14:14:54 -07003138 @SystemApi
3139 @Deprecated
Nancy Chen354b2bd2014-09-08 18:27:26 -07003140 public void onAudioStateChanged(AudioState state) {}
Sailesh Nepal400cc482014-06-26 12:04:00 -07003141
3142 /**
Yorke Lee4af59352015-05-13 14:14:54 -07003143 * Notifies this Connection that the {@link #getCallAudioState()} property has a new value.
3144 *
3145 * @param state The new connection audio state.
3146 */
3147 public void onCallAudioStateChanged(CallAudioState state) {}
3148
3149 /**
Grace Jiae99fde92021-01-19 14:58:01 -08003150 * Inform this Connection when it will or will not be tracked by an {@link InCallService} which
3151 * can provide an InCall UI.
3152 * This is primarily intended for use by Connections reported by self-managed
3153 * {@link ConnectionService} which typically maintain their own UI.
3154 *
3155 * @param isUsingAlternativeUi Indicates whether an InCallService that can provide InCall UI is
3156 * currently tracking the self-managed call.
3157 */
3158 public void onUsingAlternativeUi(boolean isUsingAlternativeUi) {}
3159
3160 /**
3161 * Inform this Conenection when it will or will not be tracked by an non-UI
3162 * {@link InCallService}.
3163 *
3164 * @param isTracked Indicates whether an non-UI InCallService is currently tracking the
3165 * self-managed call.
3166 */
3167 public void onTrackedByNonUiService(boolean isTracked) {}
3168
3169 /**
Evan Charltonbf11f982014-07-20 22:06:28 -07003170 * Notifies this Connection of an internal state change. This method is called after the
3171 * state is changed.
Ihab Awadf8358972014-05-28 16:46:42 -07003172 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003173 * @param state The new state, one of the {@code STATE_*} constants.
Ihab Awadf8358972014-05-28 16:46:42 -07003174 */
Nancy Chen354b2bd2014-09-08 18:27:26 -07003175 public void onStateChanged(int state) {}
Ihab Awadf8358972014-05-28 16:46:42 -07003176
3177 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07003178 * Notifies this Connection of a request to play a DTMF tone.
3179 *
3180 * @param c A DTMF character.
3181 */
Santos Cordonf2951102014-07-20 19:06:29 -07003182 public void onPlayDtmfTone(char c) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003183
3184 /**
3185 * Notifies this Connection of a request to stop any currently playing DTMF tones.
3186 */
Santos Cordonf2951102014-07-20 19:06:29 -07003187 public void onStopDtmfTone() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003188
3189 /**
3190 * Notifies this Connection of a request to disconnect.
3191 */
Santos Cordonf2951102014-07-20 19:06:29 -07003192 public void onDisconnect() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003193
3194 /**
Tyler Gunn3b4b1dc2014-11-04 14:53:37 -08003195 * Notifies this Connection of a request to disconnect a participant of the conference managed
3196 * by the connection.
3197 *
3198 * @param endpoint the {@link Uri} of the participant to disconnect.
3199 * @hide
3200 */
3201 public void onDisconnectConferenceParticipant(Uri endpoint) {}
3202
3203 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003204 * Notifies this Connection of a request to separate from its parent conference.
Santos Cordonb6939982014-06-04 20:20:58 -07003205 */
Santos Cordonf2951102014-07-20 19:06:29 -07003206 public void onSeparate() {}
Santos Cordonb6939982014-06-04 20:20:58 -07003207
3208 /**
Tyler Gunn0c62ef02020-02-11 14:39:43 -08003209 * Supports initiation of a conference call by directly adding participants to an ongoing call.
Ravi Paluri404babb2020-01-23 19:02:44 +05303210 *
3211 * @param participants with which conference call will be formed.
3212 */
3213 public void onAddConferenceParticipants(@NonNull List<Uri> participants) {}
3214
3215 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07003216 * Notifies this Connection of a request to abort.
3217 */
Santos Cordonf2951102014-07-20 19:06:29 -07003218 public void onAbort() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003219
3220 /**
3221 * Notifies this Connection of a request to hold.
3222 */
Santos Cordonf2951102014-07-20 19:06:29 -07003223 public void onHold() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003224
3225 /**
3226 * Notifies this Connection of a request to exit a hold state.
3227 */
Santos Cordonf2951102014-07-20 19:06:29 -07003228 public void onUnhold() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003229
3230 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003231 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Santos Cordond34e5712014-08-05 18:54:03 +00003232 * a request to accept.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003233 * <p>
3234 * For managed {@link ConnectionService}s, this will be called when the user answers a call via
3235 * the default dialer's {@link InCallService}.
3236 * <p>
3237 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3238 * Telecom framework may request that the call is answered in the following circumstances:
3239 * <ul>
3240 * <li>The user chooses to answer an incoming call via a Bluetooth device.</li>
3241 * <li>A car mode {@link InCallService} is in use which has declared
3242 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3243 * {@link InCallService} will be able to see calls from self-managed
3244 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3245 * behalf.</li>
3246 * </ul>
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003247 * @param videoState The video state in which to answer the connection.
Ihab Awad542e0ea2014-05-16 10:22:16 -07003248 */
Santos Cordonf2951102014-07-20 19:06:29 -07003249 public void onAnswer(int videoState) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003250
3251 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003252 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Tyler Gunnbe74de02014-08-29 14:51:48 -07003253 * a request to accept.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003254 * <p>
3255 * For managed {@link ConnectionService}s, this will be called when the user answers a call via
3256 * the default dialer's {@link InCallService}.
3257 * <p>
3258 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3259 * Telecom framework may request that the call is answered in the following circumstances:
3260 * <ul>
3261 * <li>The user chooses to answer an incoming call via a Bluetooth device.</li>
3262 * <li>A car mode {@link InCallService} is in use which has declared
3263 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3264 * {@link InCallService} will be able to see calls from self-managed
3265 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3266 * behalf.</li>
3267 * </ul>
Tyler Gunnbe74de02014-08-29 14:51:48 -07003268 */
3269 public void onAnswer() {
Tyler Gunn87b73f32015-06-03 10:09:59 -07003270 onAnswer(VideoProfile.STATE_AUDIO_ONLY);
Tyler Gunnbe74de02014-08-29 14:51:48 -07003271 }
3272
3273 /**
3274 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Pooja Jaind34698d2017-12-28 14:15:31 +05303275 * a request to deflect.
3276 */
3277 public void onDeflect(Uri address) {}
3278
3279 /**
3280 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Santos Cordond34e5712014-08-05 18:54:03 +00003281 * a request to reject.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003282 * <p>
3283 * For managed {@link ConnectionService}s, this will be called when the user rejects a call via
3284 * the default dialer's {@link InCallService}.
3285 * <p>
3286 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3287 * Telecom framework may request that the call is rejected in the following circumstances:
3288 * <ul>
3289 * <li>The user chooses to reject an incoming call via a Bluetooth device.</li>
3290 * <li>A car mode {@link InCallService} is in use which has declared
3291 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3292 * {@link InCallService} will be able to see calls from self-managed
3293 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3294 * behalf.</li>
3295 * </ul>
Ihab Awad542e0ea2014-05-16 10:22:16 -07003296 */
Santos Cordonf2951102014-07-20 19:06:29 -07003297 public void onReject() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003298
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003299 /**
Tyler Gunnfacfdee2020-01-23 13:10:37 -08003300 * Notifies this Connection, which is in {@link #STATE_RINGING}, of a request to reject.
3301 * <p>
3302 * For managed {@link ConnectionService}s, this will be called when the user rejects a call via
3303 * the default dialer's {@link InCallService} using {@link Call#reject(int)}.
3304 * @param rejectReason the reason the user provided for rejecting the call.
3305 */
3306 public void onReject(@android.telecom.Call.RejectReason int rejectReason) {
3307 // to be implemented by ConnectionService.
3308 }
3309
3310 /**
Hall Liu712acbe2016-03-14 16:38:56 -07003311 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
3312 * a request to reject with a message.
Bryce Lee81901682015-08-28 16:38:02 -07003313 */
3314 public void onReject(String replyMessage) {}
3315
3316 /**
Ravi Palurif4b38e72020-02-05 12:35:41 +05303317 * Notifies this Connection, a request to transfer to a target number.
3318 * @param number the number to transfer this {@link Connection} to.
3319 * @param isConfirmationRequired when {@code true}, the {@link ConnectionService}
3320 * should wait until the transfer has successfully completed before disconnecting
3321 * the current {@link Connection}.
3322 * When {@code false}, the {@link ConnectionService} should signal the network to
3323 * perform the transfer, but should immediately disconnect the call regardless of
3324 * the outcome of the transfer.
3325 * @hide
3326 */
3327 public void onTransfer(@NonNull Uri number, boolean isConfirmationRequired) {}
3328
3329 /**
3330 * Notifies this Connection, a request to transfer to another Connection.
3331 * @param otherConnection the {@link Connection} to transfer this call to.
3332 * @hide
3333 */
3334 public void onTransfer(@NonNull Connection otherConnection) {}
3335
3336 /**
Tyler Gunn06f06162018-06-18 11:24:15 -07003337 * Notifies this Connection of a request to silence the ringer.
3338 * <p>
3339 * The ringer may be silenced by any of the following methods:
3340 * <ul>
3341 * <li>{@link TelecomManager#silenceRinger()}</li>
3342 * <li>The user presses the volume-down button while a call is ringing.</li>
3343 * </ul>
3344 * <p>
3345 * Self-managed {@link ConnectionService} implementations should override this method in their
3346 * {@link Connection} implementation and implement logic to silence their app's ringtone. If
3347 * your app set the ringtone as part of the incoming call {@link Notification} (see
3348 * {@link #onShowIncomingCallUi()}), it should re-post the notification now, except call
3349 * {@link android.app.Notification.Builder#setOnlyAlertOnce(boolean)} with {@code true}. This
3350 * will ensure the ringtone sound associated with your {@link android.app.NotificationChannel}
3351 * stops playing.
Bryce Leecac50772015-11-17 15:13:29 -08003352 */
3353 public void onSilence() {}
3354
3355 /**
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003356 * Notifies this Connection whether the user wishes to proceed with the post-dial DTMF codes.
3357 */
Santos Cordonf2951102014-07-20 19:06:29 -07003358 public void onPostDialContinue(boolean proceed) {}
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003359
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003360 /**
3361 * Notifies this Connection of a request to pull an external call to the local device.
3362 * <p>
3363 * The {@link InCallService} issues a request to pull an external call to the local device via
3364 * {@link Call#pullExternalCall()}.
3365 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -07003366 * For a Connection to be pulled, both the {@link Connection#CAPABILITY_CAN_PULL_CALL}
3367 * capability and {@link Connection#PROPERTY_IS_EXTERNAL_CALL} property bits must be set.
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003368 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -07003369 * For more information on external calls, see {@link Connection#PROPERTY_IS_EXTERNAL_CALL}.
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003370 */
3371 public void onPullExternalCall() {}
3372
3373 /**
3374 * Notifies this Connection of a {@link Call} event initiated from an {@link InCallService}.
3375 * <p>
3376 * The {@link InCallService} issues a Call event via {@link Call#sendCallEvent(String, Bundle)}.
3377 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003378 * Where possible, the Connection should make an attempt to handle {@link Call} events which
3379 * are part of the {@code android.telecom.*} namespace. The Connection should ignore any events
3380 * it does not wish to handle. Unexpected events should be handled gracefully, as it is
3381 * possible that a {@link InCallService} has defined its own Call events which a Connection is
3382 * not aware of.
3383 * <p>
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003384 * See also {@link Call#sendCallEvent(String, Bundle)}.
3385 *
3386 * @param event The call event.
3387 * @param extras Extras associated with the call event.
3388 */
3389 public void onCallEvent(String event, Bundle extras) {}
3390
Tyler Gunndee56a82016-03-23 16:06:34 -07003391 /**
Tyler Gunn79bc1ec2018-01-22 15:17:54 -08003392 * Notifies this {@link Connection} that a handover has completed.
3393 * <p>
3394 * A handover is initiated with {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int,
3395 * Bundle)} on the initiating side of the handover, and
3396 * {@link TelecomManager#acceptHandover(Uri, int, PhoneAccountHandle)}.
3397 */
3398 public void onHandoverComplete() {}
3399
3400 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07003401 * Notifies this {@link Connection} of a change to the extras made outside the
3402 * {@link ConnectionService}.
3403 * <p>
3404 * These extras changes can originate from Telecom itself, or from an {@link InCallService} via
3405 * the {@link android.telecom.Call#putExtras(Bundle)} and
3406 * {@link Call#removeExtras(List)}.
3407 *
3408 * @param extras The new extras bundle.
3409 */
3410 public void onExtrasChanged(Bundle extras) {}
3411
Tyler Gunnf5035432017-01-09 09:43:12 -08003412 /**
3413 * Notifies this {@link Connection} that its {@link ConnectionService} is responsible for
3414 * displaying its incoming call user interface for the {@link Connection}.
3415 * <p>
3416 * Will only be called for incoming calls added via a self-managed {@link ConnectionService}
3417 * (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}), where the {@link ConnectionService}
3418 * should show its own incoming call user interface.
3419 * <p>
3420 * Where there are ongoing calls in other self-managed {@link ConnectionService}s, or in a
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003421 * regular {@link ConnectionService}, and it is not possible to hold these other calls, the
3422 * Telecom framework will display its own incoming call user interface to allow the user to
3423 * choose whether to answer the new incoming call and disconnect other ongoing calls, or to
3424 * reject the new incoming call.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003425 * <p>
3426 * You should trigger the display of the incoming call user interface for your application by
3427 * showing a {@link Notification} with a full-screen {@link Intent} specified.
Tyler Gunn06f06162018-06-18 11:24:15 -07003428 *
3429 * In your application code, you should create a {@link android.app.NotificationChannel} for
3430 * incoming call notifications from your app:
3431 * <pre><code>
3432 * NotificationChannel channel = new NotificationChannel(YOUR_CHANNEL_ID, "Incoming Calls",
3433 * NotificationManager.IMPORTANCE_MAX);
3434 * // other channel setup stuff goes here.
3435 *
3436 * // We'll use the default system ringtone for our incoming call notification channel. You can
3437 * // use your own audio resource here.
3438 * Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
3439 * channel.setSound(ringtoneUri, new AudioAttributes.Builder()
3440 * // Setting the AudioAttributes is important as it identifies the purpose of your
3441 * // notification sound.
3442 * .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
3443 * .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
3444 * .build());
3445 *
3446 * NotificationManager mgr = getSystemService(NotificationManager.class);
3447 * mgr.createNotificationChannel(channel);
3448 * </code></pre>
3449 * When it comes time to post a notification for your incoming call, ensure it uses your
3450 * incoming call {@link android.app.NotificationChannel}.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003451 * <pre><code>
3452 * // Create an intent which triggers your fullscreen incoming call user interface.
3453 * Intent intent = new Intent(Intent.ACTION_MAIN, null);
3454 * intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_ACTIVITY_NEW_TASK);
3455 * intent.setClass(context, YourIncomingCallActivity.class);
Ashwini Orugantif8191e82021-01-07 12:04:25 -08003456 * PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_MUTABLE_UNAUDITED);
Tyler Gunn159f35c2017-03-02 09:28:37 -08003457 *
3458 * // Build the notification as an ongoing high priority item; this ensures it will show as
3459 * // a heads up notification which slides down over top of the current content.
3460 * final Notification.Builder builder = new Notification.Builder(context);
3461 * builder.setOngoing(true);
3462 * builder.setPriority(Notification.PRIORITY_HIGH);
3463 *
3464 * // Set notification content intent to take user to fullscreen UI if user taps on the
3465 * // notification body.
3466 * builder.setContentIntent(pendingIntent);
3467 * // Set full screen intent to trigger display of the fullscreen UI when the notification
3468 * // manager deems it appropriate.
3469 * builder.setFullScreenIntent(pendingIntent, true);
3470 *
3471 * // Setup notification content.
3472 * builder.setSmallIcon( yourIconResourceId );
3473 * builder.setContentTitle("Your notification title");
3474 * builder.setContentText("Your notification content.");
3475 *
Tyler Gunn06f06162018-06-18 11:24:15 -07003476 * // Set notification as insistent to cause your ringtone to loop.
3477 * Notification notification = builder.build();
3478 * notification.flags |= Notification.FLAG_INSISTENT;
Tyler Gunn159f35c2017-03-02 09:28:37 -08003479 *
Tyler Gunn06f06162018-06-18 11:24:15 -07003480 * // Use builder.addAction(..) to add buttons to answer or reject the call.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003481 * NotificationManager notificationManager = mContext.getSystemService(
3482 * NotificationManager.class);
Tyler Gunn06f06162018-06-18 11:24:15 -07003483 * notificationManager.notify(YOUR_CHANNEL_ID, YOUR_TAG, YOUR_ID, notification);
Tyler Gunn159f35c2017-03-02 09:28:37 -08003484 * </code></pre>
Tyler Gunnf5035432017-01-09 09:43:12 -08003485 */
3486 public void onShowIncomingCallUi() {}
3487
Hall Liub64ac4c2017-02-06 10:49:48 -08003488 /**
3489 * Notifies this {@link Connection} that the user has requested an RTT session.
3490 * The connection service should call {@link #sendRttInitiationSuccess} or
3491 * {@link #sendRttInitiationFailure} to inform Telecom of the success or failure of the
3492 * request, respectively.
3493 * @param rttTextStream The object that should be used to send text to or receive text from
3494 * the in-call app.
Hall Liub64ac4c2017-02-06 10:49:48 -08003495 */
3496 public void onStartRtt(@NonNull RttTextStream rttTextStream) {}
3497
3498 /**
3499 * Notifies this {@link Connection} that it should terminate any existing RTT communication
3500 * channel. No response to Telecom is needed for this method.
Hall Liub64ac4c2017-02-06 10:49:48 -08003501 */
3502 public void onStopRtt() {}
3503
3504 /**
3505 * Notifies this connection of a response to a previous remotely-initiated RTT upgrade
3506 * request sent via {@link #sendRemoteRttRequest}. Acceptance of the request is
3507 * indicated by the supplied {@link RttTextStream} being non-null, and rejection is
3508 * indicated by {@code rttTextStream} being {@code null}
Hall Liub64ac4c2017-02-06 10:49:48 -08003509 * @param rttTextStream The object that should be used to send text to or receive text from
3510 * the in-call app.
3511 */
3512 public void handleRttUpgradeResponse(@Nullable RttTextStream rttTextStream) {}
3513
Hall Liu49cabcc2021-01-15 11:41:48 -08003514 /**
Hall Liu73903142021-02-18 18:41:41 -08003515 * Information provided to a {@link Connection} upon completion of call filtering in Telecom.
3516 *
3517 * @hide
3518 */
3519 @SystemApi
3520 public static final class CallFilteringCompletionInfo implements Parcelable {
3521 private final boolean mIsBlocked;
3522 private final boolean mIsInContacts;
3523 private final CallScreeningService.CallResponse mCallResponse;
3524 private final ComponentName mCallScreeningComponent;
3525
3526 /**
3527 * Constructor for {@link CallFilteringCompletionInfo}
3528 *
3529 * @param isBlocked Whether any part of the call filtering process indicated that this call
3530 * should be blocked.
3531 * @param isInContacts Whether the caller is in the user's contacts.
3532 * @param callResponse The instance of {@link CallScreeningService.CallResponse} provided
3533 * by the {@link CallScreeningService} that processed this call, or
3534 * {@code null} if no call screening service ran.
3535 * @param callScreeningComponent The component of the {@link CallScreeningService}
3536 * that processed this call, or {@link null} if no
3537 * call screening service ran.
3538 */
3539 public CallFilteringCompletionInfo(boolean isBlocked, boolean isInContacts,
3540 @Nullable CallScreeningService.CallResponse callResponse,
3541 @Nullable ComponentName callScreeningComponent) {
3542 mIsBlocked = isBlocked;
3543 mIsInContacts = isInContacts;
3544 mCallResponse = callResponse;
3545 mCallScreeningComponent = callScreeningComponent;
3546 }
3547
3548 /** @hide */
3549 protected CallFilteringCompletionInfo(Parcel in) {
3550 mIsBlocked = in.readByte() != 0;
3551 mIsInContacts = in.readByte() != 0;
3552 CallScreeningService.ParcelableCallResponse response
Bernardo Rufino90bb3702021-12-07 20:01:45 +00003553 = in.readParcelable(CallScreeningService.class.getClassLoader(), android.telecom.CallScreeningService.ParcelableCallResponse.class);
Hall Liu73903142021-02-18 18:41:41 -08003554 mCallResponse = response == null ? null : response.toCallResponse();
Bernardo Rufino90bb3702021-12-07 20:01:45 +00003555 mCallScreeningComponent = in.readParcelable(ComponentName.class.getClassLoader(), android.content.ComponentName.class);
Hall Liu73903142021-02-18 18:41:41 -08003556 }
3557
3558 @NonNull
3559 public static final Creator<CallFilteringCompletionInfo> CREATOR =
3560 new Creator<CallFilteringCompletionInfo>() {
3561 @Override
3562 public CallFilteringCompletionInfo createFromParcel(Parcel in) {
3563 return new CallFilteringCompletionInfo(in);
3564 }
3565
3566 @Override
3567 public CallFilteringCompletionInfo[] newArray(int size) {
3568 return new CallFilteringCompletionInfo[size];
3569 }
3570 };
3571
3572 /**
3573 * @return Whether any part of the call filtering process indicated that this call should be
3574 * blocked.
3575 */
3576 public boolean isBlocked() {
3577 return mIsBlocked;
3578 }
3579
3580 /**
3581 * @return Whether the caller is in the user's contacts.
3582 */
3583 public boolean isInContacts() {
3584 return mIsInContacts;
3585 }
3586
3587 /**
3588 * @return The instance of {@link CallScreeningService.CallResponse} provided
3589 * by the {@link CallScreeningService} that processed this
3590 * call, or {@code null} if no call screening service ran.
3591 */
3592 public @Nullable CallScreeningService.CallResponse getCallResponse() {
3593 return mCallResponse;
3594 }
3595
3596 /**
3597 * @return The component of the {@link CallScreeningService}
3598 * that processed this call, or {@code null} if no call screening service ran.
3599 */
3600 public @Nullable ComponentName getCallScreeningComponent() {
3601 return mCallScreeningComponent;
3602 }
3603
3604 @Override
3605 public int describeContents() {
3606 return 0;
3607 }
3608
3609 @Override
3610 public String toString() {
3611 return "CallFilteringCompletionInfo{" +
3612 "mIsBlocked=" + mIsBlocked +
3613 ", mIsInContacts=" + mIsInContacts +
3614 ", mCallResponse=" + mCallResponse +
3615 ", mCallScreeningPackageName='" + mCallScreeningComponent + '\'' +
3616 '}';
3617 }
3618
3619 /** @hide */
3620 @Override
3621 public void writeToParcel(Parcel dest, int flags) {
3622 dest.writeByte((byte) (mIsBlocked ? 1 : 0));
3623 dest.writeByte((byte) (mIsInContacts ? 1 : 0));
3624 dest.writeParcelable(mCallResponse == null ? null : mCallResponse.toParcelable(), 0);
3625 dest.writeParcelable(mCallScreeningComponent, 0);
3626 }
3627 }
3628
3629 /**
Hall Liu49cabcc2021-01-15 11:41:48 -08003630 * Indicates that call filtering in Telecom is complete
3631 *
3632 * This method is called for a connection created via
3633 * {@link ConnectionService#onCreateIncomingConnection} when call filtering completes in
3634 * Telecom, including checking the blocked number db, per-contact settings, and custom call
3635 * filtering apps.
3636 *
Hall Liu73903142021-02-18 18:41:41 -08003637 * @param callFilteringCompletionInfo Info provided by Telecom on the results of call filtering.
Hall Liu49cabcc2021-01-15 11:41:48 -08003638 * @hide
3639 */
3640 @SystemApi
3641 @RequiresPermission(Manifest.permission.READ_CONTACTS)
Hall Liu73903142021-02-18 18:41:41 -08003642 public void onCallFilteringCompleted(
3643 @NonNull CallFilteringCompletionInfo callFilteringCompletionInfo) { }
Hall Liu49cabcc2021-01-15 11:41:48 -08003644
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003645 static String toLogSafePhoneNumber(String number) {
3646 // For unknown number, log empty string.
3647 if (number == null) {
3648 return "";
3649 }
3650
3651 if (PII_DEBUG) {
3652 // When PII_DEBUG is true we emit PII.
3653 return number;
3654 }
3655
3656 // Do exactly same thing as Uri#toSafeString() does, which will enable us to compare
3657 // sanitized phone numbers.
3658 StringBuilder builder = new StringBuilder();
3659 for (int i = 0; i < number.length(); i++) {
3660 char c = number.charAt(i);
3661 if (c == '-' || c == '@' || c == '.') {
3662 builder.append(c);
3663 } else {
3664 builder.append('x');
3665 }
3666 }
3667 return builder.toString();
3668 }
3669
Ihab Awad542e0ea2014-05-16 10:22:16 -07003670 private void setState(int state) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003671 checkImmutable();
Ihab Awad6107bab2014-08-18 09:23:25 -07003672 if (mState == STATE_DISCONNECTED && mState != state) {
3673 Log.d(this, "Connection already DISCONNECTED; cannot transition out of this state.");
Evan Charltonbf11f982014-07-20 22:06:28 -07003674 return;
Sailesh Nepal400cc482014-06-26 12:04:00 -07003675 }
Evan Charltonbf11f982014-07-20 22:06:28 -07003676 if (mState != state) {
3677 Log.d(this, "setState: %s", stateToString(state));
3678 mState = state;
Nancy Chen354b2bd2014-09-08 18:27:26 -07003679 onStateChanged(state);
Evan Charltonbf11f982014-07-20 22:06:28 -07003680 for (Listener l : mListeners) {
3681 l.onStateChanged(this, state);
3682 }
Evan Charltonbf11f982014-07-20 22:06:28 -07003683 }
3684 }
3685
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07003686 private static class FailureSignalingConnection extends Connection {
Ihab Awad90e34e32014-12-01 16:23:17 -08003687 private boolean mImmutable = false;
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003688 public FailureSignalingConnection(DisconnectCause disconnectCause) {
3689 setDisconnected(disconnectCause);
Tyler Gunn2915af72020-03-06 11:36:21 -08003690 mImmutable = true;
Ihab Awad6107bab2014-08-18 09:23:25 -07003691 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003692
3693 public void checkImmutable() {
Ihab Awad90e34e32014-12-01 16:23:17 -08003694 if (mImmutable) {
3695 throw new UnsupportedOperationException("Connection is immutable");
3696 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003697 }
Ihab Awad6107bab2014-08-18 09:23:25 -07003698 }
3699
Evan Charltonbf11f982014-07-20 22:06:28 -07003700 /**
Ihab Awad6107bab2014-08-18 09:23:25 -07003701 * Return a {@code Connection} which represents a failed connection attempt. The returned
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003702 * {@code Connection} will have a {@link android.telecom.DisconnectCause} and as specified,
3703 * and a {@link #getState()} of {@link #STATE_DISCONNECTED}.
Ihab Awad6107bab2014-08-18 09:23:25 -07003704 * <p>
3705 * The returned {@code Connection} can be assumed to {@link #destroy()} itself when appropriate,
3706 * so users of this method need not maintain a reference to its return value to destroy it.
Evan Charltonbf11f982014-07-20 22:06:28 -07003707 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003708 * @param disconnectCause The disconnect cause, ({@see android.telecomm.DisconnectCause}).
Ihab Awad6107bab2014-08-18 09:23:25 -07003709 * @return A {@code Connection} which indicates failure.
Evan Charltonbf11f982014-07-20 22:06:28 -07003710 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003711 public static Connection createFailedConnection(DisconnectCause disconnectCause) {
3712 return new FailureSignalingConnection(disconnectCause);
Evan Charltonbf11f982014-07-20 22:06:28 -07003713 }
3714
Evan Charltonbf11f982014-07-20 22:06:28 -07003715 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003716 * Override to throw an {@link UnsupportedOperationException} if this {@code Connection} is
3717 * not intended to be mutated, e.g., if it is a marker for failure. Only for framework use;
3718 * this should never be un-@hide-den.
3719 *
3720 * @hide
3721 */
3722 public void checkImmutable() {}
3723
3724 /**
Ihab Awad6107bab2014-08-18 09:23:25 -07003725 * Return a {@code Connection} which represents a canceled connection attempt. The returned
3726 * {@code Connection} will have state {@link #STATE_DISCONNECTED}, and cannot be moved out of
3727 * that state. This connection should not be used for anything, and no other
3728 * {@code Connection}s should be attempted.
3729 * <p>
Ihab Awad6107bab2014-08-18 09:23:25 -07003730 * so users of this method need not maintain a reference to its return value to destroy it.
Evan Charltonbf11f982014-07-20 22:06:28 -07003731 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003732 * @return A {@code Connection} which indicates that the underlying connection should
3733 * be canceled.
Evan Charltonbf11f982014-07-20 22:06:28 -07003734 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003735 public static Connection createCanceledConnection() {
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003736 return new FailureSignalingConnection(new DisconnectCause(DisconnectCause.CANCELED));
Ihab Awad542e0ea2014-05-16 10:22:16 -07003737 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003738
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003739 private final void fireOnConferenceableConnectionsChanged() {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003740 for (Listener l : mListeners) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003741 l.onConferenceablesChanged(this, getConferenceables());
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003742 }
3743 }
3744
Santos Cordon823fd3c2014-08-07 18:35:18 -07003745 private final void fireConferenceChanged() {
3746 for (Listener l : mListeners) {
3747 l.onConferenceChanged(this, mConference);
3748 }
3749 }
3750
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003751 private final void clearConferenceableList() {
Tyler Gunndf2cbc82015-04-20 09:13:01 -07003752 for (Conferenceable c : mConferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003753 if (c instanceof Connection) {
3754 Connection connection = (Connection) c;
3755 connection.removeConnectionListener(mConnectionDeathListener);
3756 } else if (c instanceof Conference) {
3757 Conference conference = (Conference) c;
3758 conference.removeListener(mConferenceDeathListener);
3759 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003760 }
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003761 mConferenceables.clear();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003762 }
Tyler Gunn3bffcf72014-10-28 13:51:27 -07003763
3764 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07003765 * Handles a change to extras received from Telecom.
3766 *
3767 * @param extras The new extras.
3768 * @hide
3769 */
3770 final void handleExtrasChanged(Bundle extras) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003771 Bundle b = null;
3772 synchronized (mExtrasLock) {
3773 mExtras = extras;
3774 if (mExtras != null) {
3775 b = new Bundle(mExtras);
3776 }
3777 }
3778 onExtrasChanged(b);
Tyler Gunndee56a82016-03-23 16:06:34 -07003779 }
3780
3781 /**
Tyler Gunnc63f9082019-10-15 13:19:26 -07003782 * Called by a {@link ConnectionService} to notify Telecom that a {@link Conference#onMerge()}
3783 * request failed.
Anthony Lee17455a32015-04-24 15:25:29 -07003784 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003785 public final void notifyConferenceMergeFailed() {
Anthony Lee17455a32015-04-24 15:25:29 -07003786 for (Listener l : mListeners) {
3787 l.onConferenceMergeFailed(this);
3788 }
3789 }
3790
3791 /**
Srikanth Chintalafcb15012017-05-04 20:58:34 +05303792 * Notifies listeners when phone account is changed. For example, when the PhoneAccount is
3793 * changed due to an emergency call being redialed.
3794 * @param pHandle The new PhoneAccountHandle for this connection.
3795 * @hide
3796 */
3797 public void notifyPhoneAccountChanged(PhoneAccountHandle pHandle) {
3798 for (Listener l : mListeners) {
3799 l.onPhoneAccountChanged(this, pHandle);
3800 }
3801 }
3802
3803 /**
Pengquan Meng70c9885332017-10-02 18:09:03 -07003804 * Sets the {@link PhoneAccountHandle} associated with this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003805 * <p>
3806 * Used by the Telephony {@link ConnectionService} to handle changes to the {@link PhoneAccount}
3807 * which take place after call initiation (important for emergency calling scenarios).
Pengquan Meng70c9885332017-10-02 18:09:03 -07003808 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07003809 * @param phoneAccountHandle the phone account handle to set.
Pengquan Meng70c9885332017-10-02 18:09:03 -07003810 * @hide
3811 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003812 @SystemApi
3813 public void setPhoneAccountHandle(@NonNull PhoneAccountHandle phoneAccountHandle) {
Pengquan Meng70c9885332017-10-02 18:09:03 -07003814 if (mPhoneAccountHandle != phoneAccountHandle) {
3815 mPhoneAccountHandle = phoneAccountHandle;
3816 notifyPhoneAccountChanged(phoneAccountHandle);
3817 }
3818 }
3819
3820 /**
3821 * Returns the {@link PhoneAccountHandle} associated with this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003822 * <p>
3823 * Used by the Telephony {@link ConnectionService} to handle changes to the {@link PhoneAccount}
3824 * which take place after call initiation (important for emergency calling scenarios).
Pengquan Meng70c9885332017-10-02 18:09:03 -07003825 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07003826 * @return the phone account handle specified via
3827 * {@link #setPhoneAccountHandle(PhoneAccountHandle)}, or {@code null} if none was set.
Pengquan Meng70c9885332017-10-02 18:09:03 -07003828 * @hide
3829 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003830 @SystemApi
3831 public @Nullable PhoneAccountHandle getPhoneAccountHandle() {
Pengquan Meng70c9885332017-10-02 18:09:03 -07003832 return mPhoneAccountHandle;
3833 }
3834
3835 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003836 * Sends an event associated with this {@code Connection} with associated event extras to the
3837 * {@link InCallService}.
3838 * <p>
3839 * Connection events are used to communicate point in time information from a
3840 * {@link ConnectionService} to a {@link InCallService} implementations. An example of a
3841 * custom connection event includes notifying the UI when a WIFI call has been handed over to
3842 * LTE, which the InCall UI might use to inform the user that billing charges may apply. The
3843 * Android Telephony framework will send the {@link #EVENT_CALL_MERGE_FAILED} connection event
3844 * when a call to {@link Call#mergeConference()} has failed to complete successfully. A
3845 * connection event could also be used to trigger UI in the {@link InCallService} which prompts
3846 * the user to make a choice (e.g. whether they want to incur roaming costs for making a call),
3847 * which is communicated back via {@link Call#sendCallEvent(String, Bundle)}.
3848 * <p>
3849 * Events are exposed to {@link InCallService} implementations via
3850 * {@link Call.Callback#onConnectionEvent(Call, String, Bundle)}.
3851 * <p>
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003852 * 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 -07003853 * The {@link ConnectionService} must assume that the In-Call UI could even chose to ignore
3854 * some events altogether.
3855 * <p>
3856 * Events should be fully qualified (e.g. {@code com.example.event.MY_EVENT}) to avoid
3857 * conflicts between {@link ConnectionService} implementations. Further, custom
3858 * {@link ConnectionService} implementations shall not re-purpose events in the
3859 * {@code android.*} namespace, nor shall they define new event types in this namespace. When
3860 * defining a custom event type, ensure the contents of the extras {@link Bundle} is clearly
3861 * defined. Extra keys for this bundle should be named similar to the event type (e.g.
3862 * {@code com.example.extra.MY_EXTRA}).
3863 * <p>
3864 * When defining events and the associated extras, it is important to keep their behavior
3865 * consistent when the associated {@link ConnectionService} is updated. Support for deprecated
3866 * events/extras should me maintained to ensure backwards compatibility with older
3867 * {@link InCallService} implementations which were built to support the older behavior.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003868 *
3869 * @param event The connection event.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003870 * @param extras Optional bundle containing extra information associated with the event.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003871 */
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003872 public void sendConnectionEvent(String event, Bundle extras) {
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003873 for (Listener l : mListeners) {
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07003874 l.onConnectionEvent(this, event, extras);
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003875 }
3876 }
Tyler Gunn6986a632019-06-25 13:45:32 -07003877
3878 /**
3879 * @return The direction of the call.
3880 * @hide
3881 */
3882 public final @Call.Details.CallDirection int getCallDirection() {
3883 return mCallDirection;
3884 }
3885
3886 /**
3887 * Sets the direction of this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003888 * <p>
3889 * Used when calling {@link ConnectionService#addExistingConnection} to specify the existing
3890 * call direction.
3891 *
Tyler Gunn6986a632019-06-25 13:45:32 -07003892 * @param callDirection The direction of this connection.
3893 * @hide
3894 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003895 @SystemApi
Tyler Gunn6986a632019-06-25 13:45:32 -07003896 public void setCallDirection(@Call.Details.CallDirection int callDirection) {
3897 mCallDirection = callDirection;
3898 }
Tyler Gunnd57d76c2019-09-24 14:53:23 -07003899
3900 /**
3901 * Gets the verification status for the phone number of an incoming call as identified in
3902 * ATIS-1000082.
3903 * @return the verification status.
3904 */
Tyler Gunna131d6e2020-02-13 14:53:28 -08003905 public final @VerificationStatus int getCallerNumberVerificationStatus() {
Tyler Gunnd57d76c2019-09-24 14:53:23 -07003906 return mCallerNumberVerificationStatus;
3907 }
3908
3909 /**
3910 * Sets the verification status for the phone number of an incoming call as identified in
3911 * ATIS-1000082.
3912 * <p>
3913 * This property can only be set at the time of creation of a {@link Connection} being returned
3914 * by
3915 * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)}.
3916 */
Tyler Gunna131d6e2020-02-13 14:53:28 -08003917 public final void setCallerNumberVerificationStatus(
Tyler Gunnd57d76c2019-09-24 14:53:23 -07003918 @VerificationStatus int callerNumberVerificationStatus) {
3919 mCallerNumberVerificationStatus = callerNumberVerificationStatus;
3920 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07003921}