blob: 465622658f7d42ad9df00ee765b65db8d15a641d [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;
Junhoedf3d822022-11-24 09:26:37 +000022import android.annotation.CallbackExecutor;
Tyler Gunnc9503d62020-01-27 10:30:51 -080023import android.annotation.ElapsedRealtimeLong;
Tyler Gunnd57d76c2019-09-24 14:53:23 -070024import android.annotation.IntDef;
Tyler Gunnc9503d62020-01-27 10:30:51 -080025import android.annotation.IntRange;
Tyler Gunndee56a82016-03-23 16:06:34 -070026import android.annotation.NonNull;
Santos Cordon6b7f9552015-05-27 17:21:45 -070027import android.annotation.Nullable;
Tyler Gunnc9503d62020-01-27 10:30:51 -080028import android.annotation.RequiresPermission;
Yorke Lee4af59352015-05-13 14:14:54 -070029import android.annotation.SystemApi;
Tyler Gunn159f35c2017-03-02 09:28:37 -080030import android.app.Notification;
Hall Liua98f58b52017-11-07 17:59:28 -080031import android.bluetooth.BluetoothDevice;
Artur Satayev53ada2a2019-12-10 17:47:56 +000032import android.compat.annotation.UnsupportedAppUsage;
Hall Liu73903142021-02-18 18:41:41 -080033import android.content.ComponentName;
Tyler Gunn159f35c2017-03-02 09:28:37 -080034import android.content.Intent;
Tyler Gunnb702ef82015-05-29 11:51:53 -070035import android.hardware.camera2.CameraManager;
Ihab Awad542e0ea2014-05-16 10:22:16 -070036import android.net.Uri;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -080037import android.os.Binder;
Santos Cordon6b7f9552015-05-27 17:21:45 -070038import android.os.Bundle;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070039import android.os.Handler;
40import android.os.IBinder;
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -070041import android.os.Looper;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070042import android.os.Message;
Junhoedf3d822022-11-24 09:26:37 +000043import android.os.OutcomeReceiver;
Hall Liu73903142021-02-18 18:41:41 -080044import android.os.Parcel;
Hall Liu95d55872017-01-25 17:12:49 -080045import android.os.ParcelFileDescriptor;
Hall Liu73903142021-02-18 18:41:41 -080046import android.os.Parcelable;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070047import android.os.RemoteException;
Tyler Gunn3fa819c2017-08-04 09:27:26 -070048import android.os.SystemClock;
Tyler Gunn0a1c6d12021-03-12 15:44:08 -080049import android.telephony.CallQuality;
Sooraj Sasindran065b77d2022-02-24 00:14:51 -080050import android.telephony.CellIdentity;
allenwtsu2aca9892019-11-25 14:38:21 +080051import android.telephony.ims.ImsStreamMediaProfile;
Tyler Gunndee56a82016-03-23 16:06:34 -070052import android.util.ArraySet;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070053import android.view.Surface;
Ihab Awad542e0ea2014-05-16 10:22:16 -070054
Youming Yed6de26e2019-01-30 11:20:35 -080055import com.android.internal.os.SomeArgs;
56import com.android.internal.telecom.IVideoCallback;
57import com.android.internal.telecom.IVideoProvider;
58
Hall Liua549fed2018-02-09 16:40:03 -080059import java.io.FileInputStream;
60import java.io.FileOutputStream;
Hall Liu95d55872017-01-25 17:12:49 -080061import java.io.IOException;
62import java.io.InputStreamReader;
63import java.io.OutputStreamWriter;
Tyler Gunnd57d76c2019-09-24 14:53:23 -070064import java.lang.annotation.Retention;
65import java.lang.annotation.RetentionPolicy;
Hall Liu730a2592018-06-25 19:48:33 -070066import java.nio.channels.Channels;
Santos Cordonb6939982014-06-04 20:20:58 -070067import java.util.ArrayList;
Tyler Gunn071be6f2016-05-10 14:52:33 -070068import java.util.Arrays;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070069import java.util.Collections;
Santos Cordonb6939982014-06-04 20:20:58 -070070import java.util.List;
Edgar Arriaga2db19d22022-10-14 14:25:14 -070071import java.util.Objects;
Ihab Awad542e0ea2014-05-16 10:22:16 -070072import java.util.Set;
Jay Shrauner229e3822014-08-15 09:23:07 -070073import java.util.concurrent.ConcurrentHashMap;
Junhoedf3d822022-11-24 09:26:37 +000074import java.util.concurrent.Executor;
Ihab Awad542e0ea2014-05-16 10:22:16 -070075
76/**
Santos Cordon895d4b82015-06-25 16:41:48 -070077 * Represents a phone call or connection to a remote endpoint that carries voice and/or video
78 * traffic.
Ihab Awad6107bab2014-08-18 09:23:25 -070079 * <p>
80 * Implementations create a custom subclass of {@code Connection} and return it to the framework
81 * as the return value of
82 * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)}
83 * or
84 * {@link ConnectionService#onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
85 * Implementations are then responsible for updating the state of the {@code Connection}, and
86 * must call {@link #destroy()} to signal to the framework that the {@code Connection} is no
87 * longer used and associated resources may be recovered.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -070088 * <p>
89 * Subclasses of {@code Connection} override the {@code on*} methods to provide the the
90 * {@link ConnectionService}'s implementation of calling functionality. The {@code on*} methods are
91 * called by Telecom to inform an instance of a {@code Connection} of actions specific to that
92 * {@code Connection} instance.
93 * <p>
94 * Basic call support requires overriding the following methods: {@link #onAnswer()},
95 * {@link #onDisconnect()}, {@link #onReject()}, {@link #onAbort()}
96 * <p>
97 * Where a {@code Connection} has {@link #CAPABILITY_SUPPORT_HOLD}, the {@link #onHold()} and
98 * {@link #onUnhold()} methods should be overridden to provide hold support for the
99 * {@code Connection}.
100 * <p>
101 * Where a {@code Connection} supports a variation of video calling (e.g. the
102 * {@code CAPABILITY_SUPPORTS_VT_*} capability bits), {@link #onAnswer(int)} should be overridden
103 * to support answering a call as a video call.
104 * <p>
105 * Where a {@code Connection} has {@link #PROPERTY_IS_EXTERNAL_CALL} and
106 * {@link #CAPABILITY_CAN_PULL_CALL}, {@link #onPullExternalCall()} should be overridden to provide
107 * support for pulling the external call.
108 * <p>
109 * Where a {@code Connection} supports conference calling {@link #onSeparate()} should be
110 * overridden.
111 * <p>
112 * There are a number of other {@code on*} methods which a {@code Connection} can choose to
113 * implement, depending on whether it is concerned with the associated calls from Telecom. If,
114 * for example, call events from a {@link InCallService} are handled,
115 * {@link #onCallEvent(String, Bundle)} should be overridden. Another example is
116 * {@link #onExtrasChanged(Bundle)}, which should be overridden if the {@code Connection} wishes to
117 * make use of extra information provided via the {@link Call#putExtras(Bundle)} and
118 * {@link Call#removeExtras(String...)} methods.
Ihab Awad542e0ea2014-05-16 10:22:16 -0700119 */
Yorke Leeabfcfdc2015-05-13 18:55:18 -0700120public abstract class Connection extends Conferenceable {
Ihab Awad542e0ea2014-05-16 10:22:16 -0700121
Tyler Gunn50d437f2021-01-12 16:34:59 -0800122 /**@hide*/
123 @Retention(RetentionPolicy.SOURCE)
124 @IntDef(prefix = "STATE_", value = {
125 STATE_INITIALIZING,
126 STATE_NEW,
127 STATE_RINGING,
128 STATE_DIALING,
129 STATE_ACTIVE,
130 STATE_HOLDING,
131 STATE_DISCONNECTED,
132 STATE_PULLING_CALL
133 })
134 public @interface ConnectionState {}
135
Santos Cordon895d4b82015-06-25 16:41:48 -0700136 /**
137 * The connection is initializing. This is generally the first state for a {@code Connection}
138 * returned by a {@link ConnectionService}.
139 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700140 public static final int STATE_INITIALIZING = 0;
141
Santos Cordon895d4b82015-06-25 16:41:48 -0700142 /**
143 * The connection is new and not connected.
144 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700145 public static final int STATE_NEW = 1;
146
Santos Cordon895d4b82015-06-25 16:41:48 -0700147 /**
148 * An incoming connection is in the ringing state. During this state, the user's ringer or
149 * vibration feature will be activated.
150 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700151 public static final int STATE_RINGING = 2;
152
Santos Cordon895d4b82015-06-25 16:41:48 -0700153 /**
154 * An outgoing connection is in the dialing state. In this state the other party has not yet
155 * answered the call and the user traditionally hears a ringback tone.
156 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700157 public static final int STATE_DIALING = 3;
158
Santos Cordon895d4b82015-06-25 16:41:48 -0700159 /**
160 * A connection is active. Both parties are connected to the call and can actively communicate.
161 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700162 public static final int STATE_ACTIVE = 4;
163
Santos Cordon895d4b82015-06-25 16:41:48 -0700164 /**
165 * A connection is on hold.
166 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700167 public static final int STATE_HOLDING = 5;
168
Santos Cordon895d4b82015-06-25 16:41:48 -0700169 /**
170 * A connection has been disconnected. This is the final state once the user has been
171 * disconnected from a call either locally, remotely or by an error in the service.
172 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700173 public static final int STATE_DISCONNECTED = 6;
174
Santos Cordon895d4b82015-06-25 16:41:48 -0700175 /**
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700176 * The state of an external connection which is in the process of being pulled from a remote
177 * device to the local device.
178 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -0700179 * A connection can only be in this state if the {@link #PROPERTY_IS_EXTERNAL_CALL} property and
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700180 * {@link #CAPABILITY_CAN_PULL_CALL} capability bits are set on the connection.
181 */
182 public static final int STATE_PULLING_CALL = 7;
183
184 /**
Tyler Gunnd57d76c2019-09-24 14:53:23 -0700185 * Indicates that the network could not perform verification.
186 */
187 public static final int VERIFICATION_STATUS_NOT_VERIFIED = 0;
188
189 /**
190 * Indicates that verification by the network passed. This indicates there is a high likelihood
191 * that the call originated from a valid source.
192 */
193 public static final int VERIFICATION_STATUS_PASSED = 1;
194
195 /**
196 * Indicates that verification by the network failed. This indicates there is a high likelihood
197 * that the call did not originate from a valid source.
198 */
199 public static final int VERIFICATION_STATUS_FAILED = 2;
200
201 /**@hide*/
202 @Retention(RetentionPolicy.SOURCE)
203 @IntDef(prefix = "VERIFICATION_STATUS_", value = {
204 VERIFICATION_STATUS_NOT_VERIFIED,
205 VERIFICATION_STATUS_PASSED,
206 VERIFICATION_STATUS_FAILED
207 })
208 public @interface VerificationStatus {}
209
210 /**
Santos Cordon895d4b82015-06-25 16:41:48 -0700211 * Connection can currently be put on hold or unheld. This is distinct from
212 * {@link #CAPABILITY_SUPPORT_HOLD} in that although a connection may support 'hold' most times,
213 * it does not at the moment support the function. This can be true while the call is in the
214 * state {@link #STATE_DIALING}, for example. During this condition, an in-call UI may
215 * display a disabled 'hold' button.
216 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800217 public static final int CAPABILITY_HOLD = 0x00000001;
218
219 /** Connection supports the hold feature. */
220 public static final int CAPABILITY_SUPPORT_HOLD = 0x00000002;
221
222 /**
223 * Connections within a conference can be merged. A {@link ConnectionService} has the option to
224 * add a {@link Conference} before the child {@link Connection}s are merged. This is how
225 * CDMA-based {@link Connection}s are implemented. For these unmerged {@link Conference}s, this
226 * capability allows a merge button to be shown while the conference is in the foreground
227 * of the in-call UI.
228 * <p>
229 * This is only intended for use by a {@link Conference}.
230 */
231 public static final int CAPABILITY_MERGE_CONFERENCE = 0x00000004;
232
233 /**
234 * Connections within a conference can be swapped between foreground and background.
235 * See {@link #CAPABILITY_MERGE_CONFERENCE} for additional information.
236 * <p>
237 * This is only intended for use by a {@link Conference}.
238 */
239 public static final int CAPABILITY_SWAP_CONFERENCE = 0x00000008;
240
241 /**
242 * @hide
243 */
244 public static final int CAPABILITY_UNUSED = 0x00000010;
245
246 /** Connection supports responding via text option. */
247 public static final int CAPABILITY_RESPOND_VIA_TEXT = 0x00000020;
248
249 /** Connection can be muted. */
250 public static final int CAPABILITY_MUTE = 0x00000040;
251
252 /**
253 * Connection supports conference management. This capability only applies to
254 * {@link Conference}s which can have {@link Connection}s as children.
255 */
256 public static final int CAPABILITY_MANAGE_CONFERENCE = 0x00000080;
257
258 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700259 * Local device supports receiving video.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800260 */
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700261 public static final int CAPABILITY_SUPPORTS_VT_LOCAL_RX = 0x00000100;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800262
263 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700264 * Local device supports transmitting video.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800265 */
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700266 public static final int CAPABILITY_SUPPORTS_VT_LOCAL_TX = 0x00000200;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800267
268 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700269 * Local device supports bidirectional video calling.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800270 */
Andrew Lee9a8f9ce2015-04-10 18:09:46 -0700271 public static final int CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL =
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700272 CAPABILITY_SUPPORTS_VT_LOCAL_RX | CAPABILITY_SUPPORTS_VT_LOCAL_TX;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800273
274 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700275 * Remote device supports receiving video.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800276 */
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700277 public static final int CAPABILITY_SUPPORTS_VT_REMOTE_RX = 0x00000400;
278
279 /**
280 * Remote device supports transmitting video.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700281 */
282 public static final int CAPABILITY_SUPPORTS_VT_REMOTE_TX = 0x00000800;
283
284 /**
285 * Remote device supports bidirectional video calling.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700286 */
Andrew Lee9a8f9ce2015-04-10 18:09:46 -0700287 public static final int CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL =
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700288 CAPABILITY_SUPPORTS_VT_REMOTE_RX | CAPABILITY_SUPPORTS_VT_REMOTE_TX;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800289
290 /**
291 * Connection is able to be separated from its parent {@code Conference}, if any.
292 */
293 public static final int CAPABILITY_SEPARATE_FROM_CONFERENCE = 0x00001000;
294
295 /**
296 * Connection is able to be individually disconnected when in a {@code Conference}.
297 */
298 public static final int CAPABILITY_DISCONNECT_FROM_CONFERENCE = 0x00002000;
299
300 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700301 * Un-used.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800302 * @hide
303 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700304 public static final int CAPABILITY_UNUSED_2 = 0x00004000;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800305
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700306 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700307 * Un-used.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700308 * @hide
309 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700310 public static final int CAPABILITY_UNUSED_3 = 0x00008000;
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700311
312 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700313 * Un-used.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700314 * @hide
315 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700316 public static final int CAPABILITY_UNUSED_4 = 0x00010000;
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700317
Tyler Gunn068085b2015-02-06 13:56:52 -0800318 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700319 * Un-used.
Tyler Gunn068085b2015-02-06 13:56:52 -0800320 * @hide
321 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700322 public static final int CAPABILITY_UNUSED_5 = 0x00020000;
Tyler Gunn068085b2015-02-06 13:56:52 -0800323
Tyler Gunn96d6c402015-03-18 12:39:23 -0700324 /**
Dong Zhou89f41eb2015-03-15 11:59:49 -0500325 * Speed up audio setup for MT call.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700326 * <p>
327 * Used for IMS calls to indicate that mobile-terminated (incoming) call audio setup should take
328 * place as soon as the device answers the call, but prior to it being connected. This is an
329 * optimization some IMS stacks depend on to ensure prompt setup of call audio.
Dong Zhou89f41eb2015-03-15 11:59:49 -0500330 * @hide
Tyler Gunn96d6c402015-03-18 12:39:23 -0700331 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700332 @SystemApi
Tyler Gunn96d6c402015-03-18 12:39:23 -0700333 public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00040000;
Tyler Gunn068085b2015-02-06 13:56:52 -0800334
Rekha Kumar07366812015-03-24 16:42:31 -0700335 /**
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700336 * Call can be upgraded to a video call.
Tyler Gunn6e3ecc42018-11-12 11:30:56 -0800337 * @deprecated Use {@link #CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL} and
338 * {@link #CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL} to indicate for a call whether or not
339 * video calling is supported.
Rekha Kumar07366812015-03-24 16:42:31 -0700340 */
341 public static final int CAPABILITY_CAN_UPGRADE_TO_VIDEO = 0x00080000;
342
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700343 /**
344 * For video calls, indicates whether the outgoing video for the call can be paused using
Yorke Lee32f24732015-05-12 16:18:03 -0700345 * the {@link android.telecom.VideoProfile#STATE_PAUSED} VideoState.
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700346 */
347 public static final int CAPABILITY_CAN_PAUSE_VIDEO = 0x00100000;
348
Tyler Gunnd4091732015-06-29 09:15:37 -0700349 /**
350 * For a conference, indicates the conference will not have child connections.
351 * <p>
352 * An example of a conference with child connections is a GSM conference call, where the radio
353 * retains connections to the individual participants of the conference. Another example is an
354 * IMS conference call where conference event package functionality is supported; in this case
355 * the conference server ensures the radio is aware of the participants in the conference, which
356 * are represented by child connections.
357 * <p>
358 * An example of a conference with no child connections is an IMS conference call with no
359 * conference event package support. Such a conference is represented by the radio as a single
360 * connection to the IMS conference server.
361 * <p>
362 * Indicating whether a conference has children or not is important to help user interfaces
363 * visually represent a conference. A conference with no children, for example, will have the
364 * conference connection shown in the list of calls on a Bluetooth device, where if the
365 * conference has children, only the children will be shown in the list of calls on a Bluetooth
366 * device.
367 * @hide
368 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700369 @SystemApi
Tyler Gunnd4091732015-06-29 09:15:37 -0700370 public static final int CAPABILITY_CONFERENCE_HAS_NO_CHILDREN = 0x00200000;
371
Bryce Lee81901682015-08-28 16:38:02 -0700372 /**
373 * Indicates that the connection itself wants to handle any sort of reply response, rather than
374 * relying on SMS.
Bryce Lee81901682015-08-28 16:38:02 -0700375 */
376 public static final int CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION = 0x00400000;
377
Tyler Gunnf97a0092016-01-19 15:59:34 -0800378 /**
379 * When set, prevents a video call from being downgraded to an audio-only call.
380 * <p>
381 * Should be set when the VideoState has the {@link VideoProfile#STATE_TX_ENABLED} or
382 * {@link VideoProfile#STATE_RX_ENABLED} bits set to indicate that the connection cannot be
383 * downgraded from a video call back to a VideoState of
384 * {@link VideoProfile#STATE_AUDIO_ONLY}.
385 * <p>
386 * Intuitively, a call which can be downgraded to audio should also have local and remote
387 * video
388 * capabilities (see {@link #CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL} and
389 * {@link #CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL}).
390 */
391 public static final int CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO = 0x00800000;
392
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700393 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700394 * When set for an external connection, indicates that this {@code Connection} can be pulled
395 * from a remote device to the current device.
396 * <p>
397 * Should only be set on a {@code Connection} where {@link #PROPERTY_IS_EXTERNAL_CALL}
398 * is set.
399 */
400 public static final int CAPABILITY_CAN_PULL_CALL = 0x01000000;
401
Pooja Jaind34698d2017-12-28 14:15:31 +0530402 /** Call supports the deflect feature. */
403 public static final int CAPABILITY_SUPPORT_DEFLECT = 0x02000000;
404
Ravi Paluri404babb2020-01-23 19:02:44 +0530405 /**
406 * When set, indicates that this {@link Connection} supports initiation of a conference call
Grace Jia8587ee52020-07-10 15:42:32 -0700407 * by directly adding participants using {@link #onAddConferenceParticipants(List)}. When
408 * participants are added to a {@link Connection}, it will be replaced by a {@link Conference}
409 * instance with {@link #PROPERTY_IS_ADHOC_CONFERENCE} set to indicate that it is an adhoc
410 * conference call.
Ravi Paluri404babb2020-01-23 19:02:44 +0530411 */
412 public static final int CAPABILITY_ADD_PARTICIPANT = 0x04000000;
Ravi Palurif4b38e72020-02-05 12:35:41 +0530413
414 /**
415 * Indicates that this {@code Connection} can be transferred to another
416 * number.
Tyler Gunn460360d2020-07-29 10:21:45 -0700417 * Connection supports the confirmed and unconfirmed call transfer feature.
Ravi Palurif4b38e72020-02-05 12:35:41 +0530418 * @hide
419 */
420 public static final int CAPABILITY_TRANSFER = 0x08000000;
421
422 /**
423 * Indicates that this {@code Connection} can be transferred to another
424 * ongoing {@code Connection}.
425 * Connection supports the consultative call transfer feature.
426 * @hide
427 */
428 public static final int CAPABILITY_TRANSFER_CONSULTATIVE = 0x10000000;
429
Alvin Dey2f37d772018-05-18 23:16:10 +0530430 /**
431 * Indicates whether the remote party supports RTT or not to the UI.
432 */
433
434 public static final int CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT = 0x20000000;
435
Tyler Gunn720c6642016-03-22 09:02:47 -0700436 //**********************************************************************************************
Alvin Dey2f37d772018-05-18 23:16:10 +0530437 // Next CAPABILITY value: 0x40000000
Tyler Gunn720c6642016-03-22 09:02:47 -0700438 //**********************************************************************************************
439
440 /**
441 * Indicates that the current device callback number should be shown.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700442 * <p>
443 * Supports Telephony calls where CDMA emergency callback mode is active.
Tyler Gunn720c6642016-03-22 09:02:47 -0700444 * @hide
445 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700446 @SystemApi
Hall Liu25c7c4d2016-08-30 13:41:02 -0700447 public static final int PROPERTY_EMERGENCY_CALLBACK_MODE = 1<<0;
Tyler Gunn720c6642016-03-22 09:02:47 -0700448
449 /**
450 * Whether the call is a generic conference, where we do not know the precise state of
451 * participants in the conference (eg. on CDMA).
Tyler Gunnc63f9082019-10-15 13:19:26 -0700452 * <p>
453 * Supports legacy telephony CDMA calls.
Tyler Gunn720c6642016-03-22 09:02:47 -0700454 * @hide
455 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700456 @SystemApi
Tyler Gunn720c6642016-03-22 09:02:47 -0700457 public static final int PROPERTY_GENERIC_CONFERENCE = 1<<1;
458
459 /**
460 * Connection is using high definition audio.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700461 * <p>
462 * Indicates that the {@link Connection} is using a "high definition" audio codec. This usually
463 * implies something like AMR wideband, but the interpretation of when a call is considered high
464 * definition is left to the {@link ConnectionService} to decide.
465 * <p>
466 * Translates to {@link android.telecom.Call.Details#PROPERTY_HIGH_DEF_AUDIO}.
Tyler Gunn720c6642016-03-22 09:02:47 -0700467 */
468 public static final int PROPERTY_HIGH_DEF_AUDIO = 1<<2;
469
470 /**
471 * Connection is using WIFI.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700472 * <p>
473 * Used to indicate that a call is taking place over WIFI versus a carrier network.
474 * <p>
475 * Translates to {@link android.telecom.Call.Details#PROPERTY_WIFI}.
Tyler Gunn720c6642016-03-22 09:02:47 -0700476 */
477 public static final int PROPERTY_WIFI = 1<<3;
478
479 /**
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700480 * When set, indicates that the {@code Connection} does not actually exist locally for the
481 * {@link ConnectionService}.
482 * <p>
483 * Consider, for example, a scenario where a user has two devices with the same phone number.
484 * When a user places a call on one devices, the telephony stack can represent that call on the
485 * other device by adding is to the {@link ConnectionService} with the
Tyler Gunn720c6642016-03-22 09:02:47 -0700486 * {@link #PROPERTY_IS_EXTERNAL_CALL} capability set.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700487 * <p>
488 * An {@link ConnectionService} should not assume that all {@link InCallService}s will handle
489 * external connections. Only those {@link InCallService}s which have the
490 * {@link TelecomManager#METADATA_INCLUDE_EXTERNAL_CALLS} metadata set to {@code true} in its
491 * manifest will see external connections.
492 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700493 public static final int PROPERTY_IS_EXTERNAL_CALL = 1<<4;
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700494
Brad Ebinger15847072016-05-18 11:08:36 -0700495 /**
496 * Indicates that the connection has CDMA Enhanced Voice Privacy enabled.
497 */
498 public static final int PROPERTY_HAS_CDMA_VOICE_PRIVACY = 1<<5;
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700499
Hall Liu9f332c72016-07-14 15:37:37 -0700500 /**
501 * Indicates that the connection represents a downgraded IMS conference.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700502 * <p>
503 * This property is set when an IMS conference undergoes SRVCC and is re-added to Telecom as a
504 * new entity to indicate that the new connection was a conference.
Hall Liu9f332c72016-07-14 15:37:37 -0700505 * @hide
506 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700507 @SystemApi
Hall Liu9f332c72016-07-14 15:37:37 -0700508 public static final int PROPERTY_IS_DOWNGRADED_CONFERENCE = 1<<6;
509
Tyler Gunnf5035432017-01-09 09:43:12 -0800510 /**
511 * Set by the framework to indicate that the {@link Connection} originated from a self-managed
512 * {@link ConnectionService}.
513 * <p>
514 * See {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.
515 */
516 public static final int PROPERTY_SELF_MANAGED = 1<<7;
517
Hall Liu95d55872017-01-25 17:12:49 -0800518 /**
Hall Liuffa4a812017-03-02 16:11:00 -0800519 * Set by the framework to indicate that a connection has an active RTT session associated with
520 * it.
Hall Liu95d55872017-01-25 17:12:49 -0800521 */
522 public static final int PROPERTY_IS_RTT = 1 << 8;
523
Eric Erfanian62706c52017-12-06 16:27:53 -0800524 /**
525 * Set by the framework to indicate that a connection is using assisted dialing.
Tyler Gunn5567d742019-10-31 13:04:37 -0700526 * <p>
527 * This is used for outgoing calls.
528 *
529 * @see TelecomManager#EXTRA_USE_ASSISTED_DIALING
Eric Erfanian62706c52017-12-06 16:27:53 -0800530 */
Tyler Gunnc9503d62020-01-27 10:30:51 -0800531 public static final int PROPERTY_ASSISTED_DIALING = 1 << 9;
Eric Erfanian62706c52017-12-06 16:27:53 -0800532
Tyler Gunn5bd90852018-09-21 09:37:07 -0700533 /**
534 * Set by the framework to indicate that the network has identified a Connection as an emergency
535 * call.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700536 * <p>
537 * This is used for incoming (mobile-terminated) calls to indicate the call is from emergency
538 * services.
Tyler Gunn5bd90852018-09-21 09:37:07 -0700539 */
540 public static final int PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL = 1 << 10;
541
Tyler Gunnac60f952019-05-31 07:23:16 -0700542 /**
543 * Set by the framework to indicate that a Conference or Connection is hosted by a device other
544 * than the current one. Used in scenarios where the conference originator is the remote device
545 * and the current device is a participant of that conference.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700546 * <p>
547 * This property is specific to IMS conference calls originating in Telephony.
Tyler Gunnac60f952019-05-31 07:23:16 -0700548 * @hide
549 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700550 @SystemApi
Tyler Gunnac60f952019-05-31 07:23:16 -0700551 public static final int PROPERTY_REMOTELY_HOSTED = 1 << 11;
552
Ravi Paluri80aa2142019-12-02 11:57:37 +0530553 /**
Grace Jia8587ee52020-07-10 15:42:32 -0700554 * Set by the framework to indicate that a call is an adhoc conference call.
Ravi Paluri80aa2142019-12-02 11:57:37 +0530555 * <p>
Grace Jia8587ee52020-07-10 15:42:32 -0700556 * This is used for outgoing and incoming conference calls.
Ravi Paluri80aa2142019-12-02 11:57:37 +0530557 */
558 public static final int PROPERTY_IS_ADHOC_CONFERENCE = 1 << 12;
559
Sooraj Sasindran64f05b12020-11-18 12:07:10 -0800560 /**
561 * Connection is using cross sim technology.
562 * <p>
563 * Indicates that the {@link Connection} is using a cross sim technology which would
564 * register IMS over internet APN of default data subscription.
565 * <p>
566 */
567 public static final int PROPERTY_CROSS_SIM = 1 << 13;
Ravi Paluri80aa2142019-12-02 11:57:37 +0530568
Tyler Gunn96d6c402015-03-18 12:39:23 -0700569 //**********************************************************************************************
Sooraj Sasindran64f05b12020-11-18 12:07:10 -0800570 // Next PROPERTY value: 1<<14
Tyler Gunn96d6c402015-03-18 12:39:23 -0700571 //**********************************************************************************************
Tyler Gunn068085b2015-02-06 13:56:52 -0800572
Tyler Gunn335ff2e2015-07-30 14:18:33 -0700573 /**
Tyler Gunn1c687622019-12-20 11:08:13 -0800574 * Indicates that the audio codec is currently not specified or is unknown.
allenwtsu2aca9892019-11-25 14:38:21 +0800575 */
allenwtsu2aca9892019-11-25 14:38:21 +0800576 public static final int AUDIO_CODEC_NONE = ImsStreamMediaProfile.AUDIO_QUALITY_NONE; // 0
Tyler Gunn1c687622019-12-20 11:08:13 -0800577 /**
578 * Adaptive Multi-rate audio codec.
579 */
allenwtsu2aca9892019-11-25 14:38:21 +0800580 public static final int AUDIO_CODEC_AMR = ImsStreamMediaProfile.AUDIO_QUALITY_AMR; // 1
Tyler Gunn1c687622019-12-20 11:08:13 -0800581 /**
582 * Adaptive Multi-rate wideband audio codec.
583 */
allenwtsu2aca9892019-11-25 14:38:21 +0800584 public static final int AUDIO_CODEC_AMR_WB = ImsStreamMediaProfile.AUDIO_QUALITY_AMR_WB; // 2
Tyler Gunn1c687622019-12-20 11:08:13 -0800585 /**
586 * Qualcomm code-excited linear prediction 13 kilobit audio codec.
587 */
allenwtsu2aca9892019-11-25 14:38:21 +0800588 public static final int AUDIO_CODEC_QCELP13K = ImsStreamMediaProfile.AUDIO_QUALITY_QCELP13K; //3
Tyler Gunn1c687622019-12-20 11:08:13 -0800589 /**
590 * Enhanced Variable Rate Codec. See 3GPP2 C.S0014-A.
591 */
allenwtsu2aca9892019-11-25 14:38:21 +0800592 public static final int AUDIO_CODEC_EVRC = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC; // 4
Tyler Gunn1c687622019-12-20 11:08:13 -0800593 /**
594 * Enhanced Variable Rate Codec B. Commonly used on CDMA networks.
595 */
allenwtsu2aca9892019-11-25 14:38:21 +0800596 public static final int AUDIO_CODEC_EVRC_B = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_B; // 5
Tyler Gunn1c687622019-12-20 11:08:13 -0800597 /**
598 * Enhanced Variable Rate Wideband Codec. See RFC5188.
599 */
allenwtsu2aca9892019-11-25 14:38:21 +0800600 public static final int AUDIO_CODEC_EVRC_WB = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_WB; // 6
Tyler Gunn1c687622019-12-20 11:08:13 -0800601 /**
602 * Enhanced Variable Rate Narrowband-Wideband Codec.
603 */
allenwtsu2aca9892019-11-25 14:38:21 +0800604 public static final int AUDIO_CODEC_EVRC_NW = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_NW; // 7
Tyler Gunn1c687622019-12-20 11:08:13 -0800605 /**
606 * GSM Enhanced Full-Rate audio codec, also known as GSM-EFR, GSM 06.60, or simply EFR.
607 */
allenwtsu2aca9892019-11-25 14:38:21 +0800608 public static final int AUDIO_CODEC_GSM_EFR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_EFR; // 8
Tyler Gunn1c687622019-12-20 11:08:13 -0800609 /**
610 * GSM Full-Rate audio codec, also known as GSM-FR, GSM 06.10, GSM, or simply FR.
611 */
allenwtsu2aca9892019-11-25 14:38:21 +0800612 public static final int AUDIO_CODEC_GSM_FR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_FR; // 9
Tyler Gunn1c687622019-12-20 11:08:13 -0800613 /**
614 * GSM Half Rate audio codec.
615 */
allenwtsu2aca9892019-11-25 14:38:21 +0800616 public static final int AUDIO_CODEC_GSM_HR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_HR; // 10
Tyler Gunn1c687622019-12-20 11:08:13 -0800617 /**
618 * ITU-T G711U audio codec.
619 */
allenwtsu2aca9892019-11-25 14:38:21 +0800620 public static final int AUDIO_CODEC_G711U = ImsStreamMediaProfile.AUDIO_QUALITY_G711U; // 11
Tyler Gunn1c687622019-12-20 11:08:13 -0800621 /**
622 * ITU-T G723 audio codec.
623 */
allenwtsu2aca9892019-11-25 14:38:21 +0800624 public static final int AUDIO_CODEC_G723 = ImsStreamMediaProfile.AUDIO_QUALITY_G723; // 12
Tyler Gunn1c687622019-12-20 11:08:13 -0800625 /**
626 * ITU-T G711A audio codec.
627 */
allenwtsu2aca9892019-11-25 14:38:21 +0800628 public static final int AUDIO_CODEC_G711A = ImsStreamMediaProfile.AUDIO_QUALITY_G711A; // 13
Tyler Gunn1c687622019-12-20 11:08:13 -0800629 /**
630 * ITU-T G722 audio codec.
631 */
allenwtsu2aca9892019-11-25 14:38:21 +0800632 public static final int AUDIO_CODEC_G722 = ImsStreamMediaProfile.AUDIO_QUALITY_G722; // 14
Tyler Gunn1c687622019-12-20 11:08:13 -0800633 /**
634 * ITU-T G711AB audio codec.
635 */
allenwtsu2aca9892019-11-25 14:38:21 +0800636 public static final int AUDIO_CODEC_G711AB = ImsStreamMediaProfile.AUDIO_QUALITY_G711AB; // 15
Tyler Gunn1c687622019-12-20 11:08:13 -0800637 /**
638 * ITU-T G729 audio codec.
639 */
allenwtsu2aca9892019-11-25 14:38:21 +0800640 public static final int AUDIO_CODEC_G729 = ImsStreamMediaProfile.AUDIO_QUALITY_G729; // 16
Tyler Gunn1c687622019-12-20 11:08:13 -0800641 /**
642 * Enhanced Voice Services Narrowband audio codec. See 3GPP TS 26.441.
643 */
allenwtsu2aca9892019-11-25 14:38:21 +0800644 public static final int AUDIO_CODEC_EVS_NB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_NB; // 17
Tyler Gunn1c687622019-12-20 11:08:13 -0800645 /**
646 * Enhanced Voice Services Wideband audio codec. See 3GPP TS 26.441.
647 */
allenwtsu2aca9892019-11-25 14:38:21 +0800648 public static final int AUDIO_CODEC_EVS_WB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_WB; // 18
Tyler Gunn1c687622019-12-20 11:08:13 -0800649 /**
650 * Enhanced Voice Services Super-Wideband audio codec. See 3GPP TS 26.441.
651 */
allenwtsu2aca9892019-11-25 14:38:21 +0800652 public static final int AUDIO_CODEC_EVS_SWB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_SWB; // 19
Tyler Gunn1c687622019-12-20 11:08:13 -0800653 /**
654 * Enhanced Voice Services Fullband audio codec. See 3GPP TS 26.441.
655 */
allenwtsu2aca9892019-11-25 14:38:21 +0800656 public static final int AUDIO_CODEC_EVS_FB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_FB; // 20
657
Tyler Gunn1c687622019-12-20 11:08:13 -0800658 /**@hide*/
659 @Retention(RetentionPolicy.SOURCE)
660 @IntDef(prefix = "AUDIO_CODEC_", value = {
661 AUDIO_CODEC_NONE,
662 AUDIO_CODEC_AMR,
663 AUDIO_CODEC_AMR_WB,
664 AUDIO_CODEC_QCELP13K,
665 AUDIO_CODEC_EVRC,
666 AUDIO_CODEC_EVRC_B,
667 AUDIO_CODEC_EVRC_WB,
668 AUDIO_CODEC_EVRC_NW,
669 AUDIO_CODEC_GSM_EFR,
670 AUDIO_CODEC_GSM_FR,
671 AUDIO_CODEC_GSM_HR,
672 AUDIO_CODEC_G711U,
673 AUDIO_CODEC_G723,
674 AUDIO_CODEC_G711A,
675 AUDIO_CODEC_G722,
676 AUDIO_CODEC_G711AB,
677 AUDIO_CODEC_G729,
678 AUDIO_CODEC_EVS_NB,
679 AUDIO_CODEC_EVS_SWB,
680 AUDIO_CODEC_EVS_FB
681 })
682 public @interface AudioCodec {}
683
allenwtsu2aca9892019-11-25 14:38:21 +0800684 /**
Tyler Gunn60e5eb62021-07-01 16:55:32 -0700685 * Contains the same value as {@link #getCallerNumberVerificationStatus()}, except will be
686 * present in the {@link #getExtras()} using this key.
687 * @hide
688 */
689 public static final String EXTRA_CALLER_NUMBER_VERIFICATION_STATUS =
690 "android.telecom.extra.CALLER_NUMBER_VERIFICATION_STATUS";
691
692 /**
Tyler Gunn335ff2e2015-07-30 14:18:33 -0700693 * Connection extra key used to store the last forwarded number associated with the current
694 * connection. Used to communicate to the user interface that the connection was forwarded via
695 * the specified number.
696 */
697 public static final String EXTRA_LAST_FORWARDED_NUMBER =
698 "android.telecom.extra.LAST_FORWARDED_NUMBER";
699
700 /**
701 * Connection extra key used to store a child number associated with the current connection.
702 * Used to communicate to the user interface that the connection was received via
703 * a child address (i.e. phone number) associated with the {@link PhoneAccount}'s primary
704 * address.
705 */
706 public static final String EXTRA_CHILD_ADDRESS = "android.telecom.extra.CHILD_ADDRESS";
707
708 /**
709 * Connection extra key used to store the subject for an incoming call. The user interface can
710 * query this extra and display its contents for incoming calls. Will only be used if the
711 * {@link PhoneAccount} supports the capability {@link PhoneAccount#CAPABILITY_CALL_SUBJECT}.
712 */
713 public static final String EXTRA_CALL_SUBJECT = "android.telecom.extra.CALL_SUBJECT";
714
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800715 /**
Tyler Gunn4b6614e2016-06-22 10:35:13 -0700716 * Boolean connection extra key set on a {@link Connection} in
717 * {@link Connection#STATE_RINGING} state to indicate that answering the call will cause the
718 * current active foreground call to be dropped.
719 */
720 public static final String EXTRA_ANSWERING_DROPS_FG_CALL =
721 "android.telecom.extra.ANSWERING_DROPS_FG_CALL";
722
723 /**
Tyler Gunn37653562017-03-13 18:15:15 -0700724 * String connection extra key set on a {@link Connection} in {@link Connection#STATE_RINGING}
725 * state to indicate the name of the third-party app which is responsible for the current
726 * foreground call.
727 * <p>
728 * Used when {@link #EXTRA_ANSWERING_DROPS_FG_CALL} is true to ensure that the default Phone app
729 * is able to inform the user that answering the new incoming call will cause a call owned by
730 * another app to be dropped when the incoming call is answered.
731 */
732 public static final String EXTRA_ANSWERING_DROPS_FG_CALL_APP_NAME =
733 "android.telecom.extra.ANSWERING_DROPS_FG_CALL_APP_NAME";
734
735 /**
Hall Liu10208662016-06-15 17:55:00 -0700736 * Boolean connection extra key on a {@link Connection} which indicates that adding an
Hall Liuee6e86b2016-07-06 16:32:43 -0700737 * additional call is disallowed.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700738 * <p>
739 * Used for mobile-network calls to identify scenarios where carrier requirements preclude
740 * adding another call at the current time.
Hall Liu10208662016-06-15 17:55:00 -0700741 * @hide
742 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700743 @SystemApi
Hall Liuee6e86b2016-07-06 16:32:43 -0700744 public static final String EXTRA_DISABLE_ADD_CALL =
745 "android.telecom.extra.DISABLE_ADD_CALL";
Hall Liu10208662016-06-15 17:55:00 -0700746
747 /**
Tyler Gunncd6ccfd2016-10-17 15:48:19 -0700748 * String connection extra key on a {@link Connection} or {@link Conference} which contains the
749 * original Connection ID associated with the connection. Used in
750 * {@link RemoteConnectionService} to track the Connection ID which was originally assigned to a
751 * connection/conference added via
752 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)} and
753 * {@link ConnectionService#addConference(Conference)} APIs. This is important to pass to
754 * Telecom for when it deals with RemoteConnections. When the ConnectionManager wraps the
755 * {@link RemoteConnection} and {@link RemoteConference} and adds it to Telecom, there needs to
756 * be a way to ensure that we don't add the connection again as a duplicate.
757 * <p>
758 * For example, the TelephonyCS calls addExistingConnection for a Connection with ID
759 * {@code TelephonyCS@1}. The ConnectionManager learns of this via
760 * {@link ConnectionService#onRemoteExistingConnectionAdded(RemoteConnection)}, and wraps this
761 * in a new {@link Connection} which it adds to Telecom via
762 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)}. As part of
763 * this process, the wrapped RemoteConnection gets assigned a new ID (e.g. {@code ConnMan@1}).
764 * The TelephonyCS will ALSO try to add the existing connection to Telecom, except with the
765 * ID it originally referred to the connection as. Thus Telecom needs to know that the
766 * Connection with ID {@code ConnMan@1} is really the same as {@code TelephonyCS@1}.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700767 * <p>
768 * This is an internal Telecom framework concept and is not exposed outside of the Telecom
769 * framework.
Tyler Gunncd6ccfd2016-10-17 15:48:19 -0700770 * @hide
771 */
772 public static final String EXTRA_ORIGINAL_CONNECTION_ID =
773 "android.telecom.extra.ORIGINAL_CONNECTION_ID";
774
775 /**
Tyler Gunnc59fd0c2020-04-17 14:03:35 -0700776 * Extra key set on a {@link Connection} when it was created via a remote connection service.
777 * For example, if a connection manager requests a remote connection service to create a call
778 * using one of the remote connection service's phone account handle, this extra will be set so
779 * that Telecom knows that the wrapped remote connection originated in a remote connection
780 * service. We stash this in the extras since connection managers will typically copy the
781 * extras from a {@link RemoteConnection} to a {@link Connection} (there is ultimately not
782 * other way to relate a {@link RemoteConnection} to a {@link Connection}.
783 * @hide
784 */
785 public static final String EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE =
786 "android.telecom.extra.REMOTE_PHONE_ACCOUNT_HANDLE";
787
788 /**
Tyler Gunnfdc4bff2021-06-24 11:25:07 -0700789 * The Telecom call ID of the conference an existing connection should be added to. This is
790 * required when {@link com.android.services.telephony.TelephonyConnectionService} adds a
791 * {@link Conference} to Telecom using the
792 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection, Conference)}
793 * API. That API specifies a parent conference associated with the new existing connection
794 * being added, and there is no equivalent as part of the {@link RemoteConnectionService} API.
795 * This extra key is used to stack the ID of the conference to which the existing connection
796 * will be added so that Telecom can link it up correctly when the {@link RemoteConference}
797 * is added to Telecom by the connection manager.
798 * @hide
799 */
800 public static final String EXTRA_ADD_TO_CONFERENCE_ID =
801 "android.telecom.extra.ADD_TO_CONFERENCE_ID";
802
803 /**
Tyler Gunnc59fd0c2020-04-17 14:03:35 -0700804 * Extra key set from a {@link ConnectionService} when using the remote connection APIs
805 * (e.g. {@link RemoteConnectionService#createRemoteConnection(PhoneAccountHandle,
806 * ConnectionRequest, boolean)}) to create a remote connection. Provides the receiving
807 * {@link ConnectionService} with a means to know the package name of the requesting
808 * {@link ConnectionService} so that {@link #EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE} can be set for
809 * better visibility in Telecom of where a connection ultimately originated.
810 * @hide
811 */
812 public static final String EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME =
813 "android.telecom.extra.REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME";
814
815 /**
Wileen Chiuf2ec2982018-07-01 14:21:50 -0700816 * Boolean connection extra key set on the extras passed to
817 * {@link Connection#sendConnectionEvent} which indicates that audio is present
818 * on the RTT call when the extra value is true.
819 */
820 public static final String EXTRA_IS_RTT_AUDIO_PRESENT =
821 "android.telecom.extra.IS_RTT_AUDIO_PRESENT";
822
823 /**
Tyler Gunn1c687622019-12-20 11:08:13 -0800824 * The audio codec in use for the current {@link Connection}, if known. Examples of valid
825 * values include {@link #AUDIO_CODEC_AMR_WB} and {@link #AUDIO_CODEC_EVS_WB}.
allenwtsu2aca9892019-11-25 14:38:21 +0800826 */
Tyler Gunn1c687622019-12-20 11:08:13 -0800827 public static final @AudioCodec String EXTRA_AUDIO_CODEC =
allenwtsu2aca9892019-11-25 14:38:21 +0800828 "android.telecom.extra.AUDIO_CODEC";
829
830 /**
allenwtsu6ec972a2020-11-10 17:32:46 +0800831 * Float connection extra key used to store the audio codec bitrate in kbps for the current
832 * {@link Connection}.
833 */
834 public static final String EXTRA_AUDIO_CODEC_BITRATE_KBPS =
835 "android.telecom.extra.AUDIO_CODEC_BITRATE_KBPS";
836
837 /**
838 * Float connection extra key used to store the audio codec bandwidth in khz for the current
839 * {@link Connection}.
840 */
841 public static final String EXTRA_AUDIO_CODEC_BANDWIDTH_KHZ =
842 "android.telecom.extra.AUDIO_CODEC_BANDWIDTH_KHZ";
Tyler Gunn78a59ff2021-05-07 16:41:19 -0700843
844 /**
Sooraj Sasindran065b77d2022-02-24 00:14:51 -0800845 * Last known cell identity key {@link CellIdentity} to be used to fill geo location header
846 * in case of an emergency call. This entry will not be filled if call is not identified as
847 * an emergency call. Only provided to the {@link ConnectionService} for the purpose of
848 * placing an emergency call; will not be present in the {@link InCallService} layer.
Sooraj Sasindran81be0822021-10-26 02:03:37 -0700849 * The {@link ConnectionService}'s implementation will be logged for fine location access
850 * when an outgoing call is placed in this case.
851 */
852 public static final String EXTRA_LAST_KNOWN_CELL_IDENTITY =
853 "android.telecom.extra.LAST_KNOWN_CELL_IDENTITY";
854
855 /**
Tyler Gunn78a59ff2021-05-07 16:41:19 -0700856 * Boolean connection extra key used to indicate whether device to device communication is
857 * available for the current call.
858 * @hide
859 */
860 public static final String EXTRA_IS_DEVICE_TO_DEVICE_COMMUNICATION_AVAILABLE =
861 "android.telecom.extra.IS_DEVICE_TO_DEVICE_COMMUNICATION_AVAILABLE";
862
allenwtsu6ec972a2020-11-10 17:32:46 +0800863 /**
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800864 * Connection event used to inform Telecom that it should play the on hold tone. This is used
865 * to play a tone when the peer puts the current call on hold. Sent to Telecom via
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700866 * {@link #sendConnectionEvent(String, Bundle)}.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800867 */
868 public static final String EVENT_ON_HOLD_TONE_START =
869 "android.telecom.event.ON_HOLD_TONE_START";
870
871 /**
872 * Connection event used to inform Telecom that it should stop the on hold tone. This is used
873 * to stop a tone when the peer puts the current call on hold. Sent to Telecom via
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700874 * {@link #sendConnectionEvent(String, Bundle)}.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800875 */
876 public static final String EVENT_ON_HOLD_TONE_END =
877 "android.telecom.event.ON_HOLD_TONE_END";
878
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700879 /**
880 * Connection event used to inform {@link InCallService}s when pulling of an external call has
881 * failed. The user interface should inform the user of the error.
882 * <p>
883 * Expected to be used by the {@link ConnectionService} when the {@link Call#pullExternalCall()}
884 * API is called on a {@link Call} with the properties
885 * {@link Call.Details#PROPERTY_IS_EXTERNAL_CALL} and
886 * {@link Call.Details#CAPABILITY_CAN_PULL_CALL}, but the {@link ConnectionService} could not
887 * pull the external call due to an error condition.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700888 * <p>
889 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
890 * expected to be null when this connection event is used.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700891 */
892 public static final String EVENT_CALL_PULL_FAILED = "android.telecom.event.CALL_PULL_FAILED";
893
Brad Ebinger2c1c16452016-05-27 15:58:10 -0700894 /**
895 * Connection event used to inform {@link InCallService}s when the merging of two calls has
896 * failed. The User Interface should use this message to inform the user of the error.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700897 * <p>
898 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
899 * expected to be null when this connection event is used.
Brad Ebinger2c1c16452016-05-27 15:58:10 -0700900 */
901 public static final String EVENT_CALL_MERGE_FAILED = "android.telecom.event.CALL_MERGE_FAILED";
902
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700903 /**
Hall Liu06ae75b2019-03-11 19:11:35 -0700904 * Connection event used to inform Telecom when a hold operation on a call has failed.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700905 * <p>
Hall Liu06ae75b2019-03-11 19:11:35 -0700906 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
907 * expected to be null when this connection event is used.
Hall Liu06ae75b2019-03-11 19:11:35 -0700908 */
909 public static final String EVENT_CALL_HOLD_FAILED = "android.telecom.event.CALL_HOLD_FAILED";
910
911 /**
Masaho Nishikawacb8fa742019-11-07 14:41:21 +0900912 * Connection event used to inform Telecom when a switch operation on a call has failed.
913 * <p>
914 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
915 * expected to be null when this connection event is used.
916 */
917 public static final String EVENT_CALL_SWITCH_FAILED =
918 "android.telecom.event.CALL_SWITCH_FAILED";
919
920 /**
Tyler Gunn78da7812017-05-09 14:34:57 -0700921 * Connection event used to inform {@link InCallService}s when the process of merging a
922 * Connection into a conference has begun.
923 * <p>
924 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
925 * expected to be null when this connection event is used.
Tyler Gunn78da7812017-05-09 14:34:57 -0700926 */
927 public static final String EVENT_MERGE_START = "android.telecom.event.MERGE_START";
928
929 /**
930 * Connection event used to inform {@link InCallService}s when the process of merging a
931 * Connection into a conference has completed.
932 * <p>
933 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
934 * expected to be null when this connection event is used.
Tyler Gunn78da7812017-05-09 14:34:57 -0700935 */
936 public static final String EVENT_MERGE_COMPLETE = "android.telecom.event.MERGE_COMPLETE";
937
938 /**
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700939 * Connection event used to inform {@link InCallService}s when a call has been put on hold by
940 * the remote party.
941 * <p>
942 * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the
943 * call is being held locally on the device. When a capable {@link ConnectionService} receives
944 * signalling to indicate that the remote party has put the call on hold, it can send this
945 * connection event.
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700946 */
947 public static final String EVENT_CALL_REMOTELY_HELD =
948 "android.telecom.event.CALL_REMOTELY_HELD";
949
950 /**
951 * Connection event used to inform {@link InCallService}s when a call which was remotely held
952 * (see {@link #EVENT_CALL_REMOTELY_HELD}) has been un-held by the remote party.
953 * <p>
954 * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the
955 * call is being held locally on the device. When a capable {@link ConnectionService} receives
956 * signalling to indicate that the remote party has taken the call off hold, it can send this
957 * connection event.
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700958 */
959 public static final String EVENT_CALL_REMOTELY_UNHELD =
960 "android.telecom.event.CALL_REMOTELY_UNHELD";
961
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700962 /**
963 * Connection event used to inform an {@link InCallService} which initiated a call handover via
964 * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has
965 * successfully completed.
966 * @hide
Tyler Gunn1a505fa2018-09-14 13:36:38 -0700967 * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated
968 * APIs instead.
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700969 */
970 public static final String EVENT_HANDOVER_COMPLETE =
971 "android.telecom.event.HANDOVER_COMPLETE";
972
973 /**
974 * Connection event used to inform an {@link InCallService} which initiated a call handover via
975 * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has failed
976 * to complete.
977 * @hide
Tyler Gunn1a505fa2018-09-14 13:36:38 -0700978 * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated
979 * APIs instead.
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700980 */
981 public static final String EVENT_HANDOVER_FAILED =
982 "android.telecom.event.HANDOVER_FAILED";
983
shilub7ec9a02018-11-09 15:52:04 -0800984 /**
Shi Lu528eb5b2019-02-08 05:09:11 +0000985 * String Connection extra key used to store SIP invite fields for an incoming call for IMS call
shilub7ec9a02018-11-09 15:52:04 -0800986 */
987 public static final String EXTRA_SIP_INVITE = "android.telecom.extra.SIP_INVITE";
988
Wileen Chiuf2ec2982018-07-01 14:21:50 -0700989 /**
990 * Connection event used to inform an {@link InCallService} that the RTT audio indication
991 * has changed.
992 */
993 public static final String EVENT_RTT_AUDIO_INDICATION_CHANGED =
994 "android.telecom.event.RTT_AUDIO_INDICATION_CHANGED";
995
Tyler Gunnd5821842021-02-05 11:12:57 -0800996 /**
997 * Connection event used to signal between the telephony {@link ConnectionService} and Telecom
998 * when device to device messages are sent/received.
999 * <p>
1000 * Device to device messages originating from the network are sent by telephony using
1001 * {@link Connection#sendConnectionEvent(String, Bundle)} and are routed up to any active
1002 * {@link CallDiagnosticService} implementation which is active.
1003 * <p>
1004 * Likewise, if a {@link CallDiagnosticService} sends a message using
Tyler Gunn066de602021-03-16 09:58:07 -07001005 * {@link CallDiagnostics#sendDeviceToDeviceMessage(int, int)}, it will be routed to telephony
Tyler Gunnd5821842021-02-05 11:12:57 -08001006 * via {@link Connection#onCallEvent(String, Bundle)}. The telephony stack will relay the
1007 * message to the other device.
1008 * @hide
1009 */
1010 @SystemApi
1011 public static final String EVENT_DEVICE_TO_DEVICE_MESSAGE =
1012 "android.telecom.event.DEVICE_TO_DEVICE_MESSAGE";
1013
1014 /**
1015 * Sent along with {@link #EVENT_DEVICE_TO_DEVICE_MESSAGE} to indicate the device to device
1016 * message type.
1017 *
Tyler Gunn066de602021-03-16 09:58:07 -07001018 * See {@link CallDiagnostics} for more information.
Tyler Gunnd5821842021-02-05 11:12:57 -08001019 * @hide
1020 */
1021 @SystemApi
1022 public static final String EXTRA_DEVICE_TO_DEVICE_MESSAGE_TYPE =
1023 "android.telecom.extra.DEVICE_TO_DEVICE_MESSAGE_TYPE";
1024
1025 /**
1026 * Sent along with {@link #EVENT_DEVICE_TO_DEVICE_MESSAGE} to indicate the device to device
1027 * message value.
1028 * <p>
Tyler Gunn066de602021-03-16 09:58:07 -07001029 * See {@link CallDiagnostics} for more information.
Tyler Gunnd5821842021-02-05 11:12:57 -08001030 * @hide
1031 */
1032 @SystemApi
1033 public static final String EXTRA_DEVICE_TO_DEVICE_MESSAGE_VALUE =
1034 "android.telecom.extra.DEVICE_TO_DEVICE_MESSAGE_VALUE";
1035
Tyler Gunn0a1c6d12021-03-12 15:44:08 -08001036 /**
1037 * Connection event used to communicate a {@link android.telephony.CallQuality} report from
1038 * telephony to Telecom for relaying to
1039 * {@link DiagnosticCall#onCallQualityReceived(CallQuality)}.
1040 * @hide
1041 */
1042 public static final String EVENT_CALL_QUALITY_REPORT =
1043 "android.telecom.event.CALL_QUALITY_REPORT";
1044
1045 /**
1046 * Extra sent with {@link #EVENT_CALL_QUALITY_REPORT} containing the
1047 * {@link android.telephony.CallQuality} data.
1048 * @hide
1049 */
1050 public static final String EXTRA_CALL_QUALITY_REPORT =
1051 "android.telecom.extra.CALL_QUALITY_REPORT";
1052
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001053 // Flag controlling whether PII is emitted into the logs
1054 private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG);
1055
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001056 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07001057 * Renders a set of capability bits ({@code CAPABILITY_*}) as a human readable string.
1058 *
1059 * @param capabilities A capability bit field.
1060 * @return A human readable string representation.
1061 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001062 public static String capabilitiesToString(int capabilities) {
Santos Cordon1a749302016-07-26 16:08:53 -07001063 return capabilitiesToStringInternal(capabilities, true /* isLong */);
1064 }
1065
1066 /**
1067 * Renders a set of capability bits ({@code CAPABILITY_*}) as a *short* human readable
1068 * string.
1069 *
1070 * @param capabilities A capability bit field.
1071 * @return A human readable string representation.
1072 * @hide
1073 */
1074 public static String capabilitiesToStringShort(int capabilities) {
1075 return capabilitiesToStringInternal(capabilities, false /* isLong */);
1076 }
1077
1078 private static String capabilitiesToStringInternal(int capabilities, boolean isLong) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001079 StringBuilder builder = new StringBuilder();
Santos Cordon1a749302016-07-26 16:08:53 -07001080 builder.append("[");
1081 if (isLong) {
1082 builder.append("Capabilities:");
1083 }
1084
Tyler Gunnc63f9082019-10-15 13:19:26 -07001085 if ((capabilities & CAPABILITY_HOLD) == CAPABILITY_HOLD) {
Santos Cordon1a749302016-07-26 16:08:53 -07001086 builder.append(isLong ? " CAPABILITY_HOLD" : " hld");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001087 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001088 if ((capabilities & CAPABILITY_SUPPORT_HOLD) == CAPABILITY_SUPPORT_HOLD) {
Santos Cordon1a749302016-07-26 16:08:53 -07001089 builder.append(isLong ? " CAPABILITY_SUPPORT_HOLD" : " sup_hld");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001090 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001091 if ((capabilities & CAPABILITY_MERGE_CONFERENCE) == CAPABILITY_MERGE_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001092 builder.append(isLong ? " CAPABILITY_MERGE_CONFERENCE" : " mrg_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001093 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001094 if ((capabilities & CAPABILITY_SWAP_CONFERENCE) == CAPABILITY_SWAP_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001095 builder.append(isLong ? " CAPABILITY_SWAP_CONFERENCE" : " swp_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001096 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001097 if ((capabilities & CAPABILITY_RESPOND_VIA_TEXT) == CAPABILITY_RESPOND_VIA_TEXT) {
Santos Cordon1a749302016-07-26 16:08:53 -07001098 builder.append(isLong ? " CAPABILITY_RESPOND_VIA_TEXT" : " txt");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001099 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001100 if ((capabilities & CAPABILITY_MUTE) == CAPABILITY_MUTE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001101 builder.append(isLong ? " CAPABILITY_MUTE" : " mut");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001102 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001103 if ((capabilities & CAPABILITY_MANAGE_CONFERENCE) == CAPABILITY_MANAGE_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001104 builder.append(isLong ? " CAPABILITY_MANAGE_CONFERENCE" : " mng_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001105 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001106 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_RX) == CAPABILITY_SUPPORTS_VT_LOCAL_RX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001107 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_RX" : " VTlrx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001108 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001109 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_TX) == CAPABILITY_SUPPORTS_VT_LOCAL_TX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001110 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_TX" : " VTltx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001111 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001112 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL)
1113 == CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001114 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL" : " VTlbi");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001115 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001116 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_RX) == CAPABILITY_SUPPORTS_VT_REMOTE_RX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001117 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_RX" : " VTrrx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001118 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001119 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_TX) == CAPABILITY_SUPPORTS_VT_REMOTE_TX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001120 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_TX" : " VTrtx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001121 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001122 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL)
1123 == CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001124 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL" : " VTrbi");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001125 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001126 if ((capabilities & CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO)
1127 == CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001128 builder.append(isLong ? " CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO" : " !v2a");
Tyler Gunnf97a0092016-01-19 15:59:34 -08001129 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001130 if ((capabilities & CAPABILITY_SPEED_UP_MT_AUDIO) == CAPABILITY_SPEED_UP_MT_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001131 builder.append(isLong ? " CAPABILITY_SPEED_UP_MT_AUDIO" : " spd_aud");
Dong Zhou89f41eb2015-03-15 11:59:49 -05001132 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001133 if ((capabilities & CAPABILITY_CAN_UPGRADE_TO_VIDEO) == CAPABILITY_CAN_UPGRADE_TO_VIDEO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001134 builder.append(isLong ? " CAPABILITY_CAN_UPGRADE_TO_VIDEO" : " a2v");
Rekha Kumar07366812015-03-24 16:42:31 -07001135 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001136 if ((capabilities & CAPABILITY_CAN_PAUSE_VIDEO) == CAPABILITY_CAN_PAUSE_VIDEO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001137 builder.append(isLong ? " CAPABILITY_CAN_PAUSE_VIDEO" : " paus_VT");
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -07001138 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001139 if ((capabilities & CAPABILITY_CONFERENCE_HAS_NO_CHILDREN)
1140 == CAPABILITY_CONFERENCE_HAS_NO_CHILDREN) {
Santos Cordon1a749302016-07-26 16:08:53 -07001141 builder.append(isLong ? " CAPABILITY_SINGLE_PARTY_CONFERENCE" : " 1p_cnf");
Tyler Gunnd4091732015-06-29 09:15:37 -07001142 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001143 if ((capabilities & CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION)
1144 == CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION) {
Santos Cordon1a749302016-07-26 16:08:53 -07001145 builder.append(isLong ? " CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION" : " rsp_by_con");
Bryce Lee81901682015-08-28 16:38:02 -07001146 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001147 if ((capabilities & CAPABILITY_CAN_PULL_CALL) == CAPABILITY_CAN_PULL_CALL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001148 builder.append(isLong ? " CAPABILITY_CAN_PULL_CALL" : " pull");
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001149 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001150 if ((capabilities & CAPABILITY_SUPPORT_DEFLECT) == CAPABILITY_SUPPORT_DEFLECT) {
Pooja Jaind34698d2017-12-28 14:15:31 +05301151 builder.append(isLong ? " CAPABILITY_SUPPORT_DEFLECT" : " sup_def");
1152 }
Ravi Paluri404babb2020-01-23 19:02:44 +05301153 if ((capabilities & CAPABILITY_ADD_PARTICIPANT) == CAPABILITY_ADD_PARTICIPANT) {
1154 builder.append(isLong ? " CAPABILITY_ADD_PARTICIPANT" : " add_participant");
1155 }
Ravi Palurif4b38e72020-02-05 12:35:41 +05301156 if ((capabilities & CAPABILITY_TRANSFER) == CAPABILITY_TRANSFER) {
1157 builder.append(isLong ? " CAPABILITY_TRANSFER" : " sup_trans");
1158 }
1159 if ((capabilities & CAPABILITY_TRANSFER_CONSULTATIVE)
1160 == CAPABILITY_TRANSFER_CONSULTATIVE) {
1161 builder.append(isLong ? " CAPABILITY_TRANSFER_CONSULTATIVE" : " sup_cTrans");
1162 }
Alvin Dey2f37d772018-05-18 23:16:10 +05301163 if ((capabilities & CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT)
1164 == CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT) {
1165 builder.append(isLong ? " CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT" : " sup_rtt");
1166 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001167 builder.append("]");
1168 return builder.toString();
1169 }
1170
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07001171 /**
1172 * Renders a set of property bits ({@code PROPERTY_*}) as a human readable string.
1173 *
1174 * @param properties A property bit field.
1175 * @return A human readable string representation.
1176 */
Tyler Gunn720c6642016-03-22 09:02:47 -07001177 public static String propertiesToString(int properties) {
Santos Cordon1a749302016-07-26 16:08:53 -07001178 return propertiesToStringInternal(properties, true /* isLong */);
1179 }
1180
1181 /**
1182 * Renders a set of property bits ({@code PROPERTY_*}) as a *short* human readable string.
1183 *
1184 * @param properties A property bit field.
1185 * @return A human readable string representation.
1186 * @hide
1187 */
1188 public static String propertiesToStringShort(int properties) {
1189 return propertiesToStringInternal(properties, false /* isLong */);
1190 }
1191
1192 private static String propertiesToStringInternal(int properties, boolean isLong) {
Tyler Gunn720c6642016-03-22 09:02:47 -07001193 StringBuilder builder = new StringBuilder();
Santos Cordon1a749302016-07-26 16:08:53 -07001194 builder.append("[");
1195 if (isLong) {
1196 builder.append("Properties:");
1197 }
Tyler Gunn720c6642016-03-22 09:02:47 -07001198
Tyler Gunnc63f9082019-10-15 13:19:26 -07001199 if ((properties & PROPERTY_SELF_MANAGED) == PROPERTY_SELF_MANAGED) {
Tyler Gunnf5035432017-01-09 09:43:12 -08001200 builder.append(isLong ? " PROPERTY_SELF_MANAGED" : " self_mng");
1201 }
1202
Tyler Gunnc63f9082019-10-15 13:19:26 -07001203 if ((properties & PROPERTY_EMERGENCY_CALLBACK_MODE) == PROPERTY_EMERGENCY_CALLBACK_MODE) {
Hall Liu25c7c4d2016-08-30 13:41:02 -07001204 builder.append(isLong ? " PROPERTY_EMERGENCY_CALLBACK_MODE" : " ecbm");
Tyler Gunn720c6642016-03-22 09:02:47 -07001205 }
1206
Tyler Gunnc63f9082019-10-15 13:19:26 -07001207 if ((properties & PROPERTY_HIGH_DEF_AUDIO) == PROPERTY_HIGH_DEF_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001208 builder.append(isLong ? " PROPERTY_HIGH_DEF_AUDIO" : " HD");
Tyler Gunn720c6642016-03-22 09:02:47 -07001209 }
1210
Tyler Gunnc63f9082019-10-15 13:19:26 -07001211 if ((properties & PROPERTY_WIFI) == PROPERTY_WIFI) {
Santos Cordon1a749302016-07-26 16:08:53 -07001212 builder.append(isLong ? " PROPERTY_WIFI" : " wifi");
Tyler Gunn720c6642016-03-22 09:02:47 -07001213 }
1214
Tyler Gunnc63f9082019-10-15 13:19:26 -07001215 if ((properties & PROPERTY_GENERIC_CONFERENCE) == PROPERTY_GENERIC_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001216 builder.append(isLong ? " PROPERTY_GENERIC_CONFERENCE" : " gen_conf");
Tyler Gunn720c6642016-03-22 09:02:47 -07001217 }
1218
Tyler Gunnc63f9082019-10-15 13:19:26 -07001219 if ((properties & PROPERTY_IS_EXTERNAL_CALL) == PROPERTY_IS_EXTERNAL_CALL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001220 builder.append(isLong ? " PROPERTY_IS_EXTERNAL_CALL" : " xtrnl");
Tyler Gunn720c6642016-03-22 09:02:47 -07001221 }
1222
Tyler Gunnc63f9082019-10-15 13:19:26 -07001223 if ((properties & PROPERTY_HAS_CDMA_VOICE_PRIVACY) == PROPERTY_HAS_CDMA_VOICE_PRIVACY) {
Santos Cordon1a749302016-07-26 16:08:53 -07001224 builder.append(isLong ? " PROPERTY_HAS_CDMA_VOICE_PRIVACY" : " priv");
Brad Ebinger15847072016-05-18 11:08:36 -07001225 }
1226
Tyler Gunnc63f9082019-10-15 13:19:26 -07001227 if ((properties & PROPERTY_IS_RTT) == PROPERTY_IS_RTT) {
Hall Liud4d2a8a2018-01-29 17:22:02 -08001228 builder.append(isLong ? " PROPERTY_IS_RTT" : " rtt");
1229 }
1230
Tyler Gunnc63f9082019-10-15 13:19:26 -07001231 if ((properties & PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL)
1232 == PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL) {
Tyler Gunn5bd90852018-09-21 09:37:07 -07001233 builder.append(isLong ? " PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL" : " ecall");
1234 }
1235
Tyler Gunnc63f9082019-10-15 13:19:26 -07001236 if ((properties & PROPERTY_REMOTELY_HOSTED) == PROPERTY_REMOTELY_HOSTED) {
Tyler Gunnac60f952019-05-31 07:23:16 -07001237 builder.append(isLong ? " PROPERTY_REMOTELY_HOSTED" : " remote_hst");
1238 }
1239
Ravi Paluri80aa2142019-12-02 11:57:37 +05301240 if ((properties & PROPERTY_IS_ADHOC_CONFERENCE) == PROPERTY_IS_ADHOC_CONFERENCE) {
1241 builder.append(isLong ? " PROPERTY_IS_ADHOC_CONFERENCE" : " adhoc_conf");
1242 }
1243
Hall Liue0f787c2020-07-08 11:25:56 -07001244 if ((properties & PROPERTY_IS_DOWNGRADED_CONFERENCE) == PROPERTY_IS_DOWNGRADED_CONFERENCE) {
1245 builder.append(isLong ? " PROPERTY_IS_DOWNGRADED_CONFERENCE" : " dngrd_conf");
1246 }
1247
Tyler Gunn720c6642016-03-22 09:02:47 -07001248 builder.append("]");
1249 return builder.toString();
1250 }
1251
Sailesh Nepal091768c2014-06-30 15:15:23 -07001252 /** @hide */
Tyler Gunn633e4c32019-10-24 15:40:48 -07001253 abstract static class Listener {
Ihab Awad542e0ea2014-05-16 10:22:16 -07001254 public void onStateChanged(Connection c, int state) {}
Andrew Lee100e2932014-09-08 15:34:24 -07001255 public void onAddressChanged(Connection c, Uri newAddress, int presentation) {}
Sailesh Nepal61203862014-07-11 14:50:13 -07001256 public void onCallerDisplayNameChanged(
1257 Connection c, String callerDisplayName, int presentation) {}
Tyler Gunnaa07df82014-07-17 07:50:22 -07001258 public void onVideoStateChanged(Connection c, int videoState) {}
Andrew Lee7f3d41f2014-09-11 17:33:16 -07001259 public void onDisconnected(Connection c, DisconnectCause disconnectCause) {}
Sailesh Nepal091768c2014-06-30 15:15:23 -07001260 public void onPostDialWait(Connection c, String remaining) {}
Nancy Chen27d1c2d2014-12-15 16:12:50 -08001261 public void onPostDialChar(Connection c, char nextChar) {}
Andrew Lee100e2932014-09-08 15:34:24 -07001262 public void onRingbackRequested(Connection c, boolean ringback) {}
Sailesh Nepal61203862014-07-11 14:50:13 -07001263 public void onDestroyed(Connection c) {}
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001264 public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {}
Tyler Gunn720c6642016-03-22 09:02:47 -07001265 public void onConnectionPropertiesChanged(Connection c, int properties) {}
Christine Hallstrom2830ce92016-11-30 16:06:42 -08001266 public void onSupportedAudioRoutesChanged(Connection c, int supportedAudioRoutes) {}
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001267 public void onVideoProviderChanged(
1268 Connection c, VideoProvider videoProvider) {}
Sailesh Nepal001bbbb2014-07-15 14:40:39 -07001269 public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {}
1270 public void onStatusHintsChanged(Connection c, StatusHints statusHints) {}
Tyler Gunn6d76ca02014-11-17 15:49:51 -08001271 public void onConferenceablesChanged(
Tyler Gunndf2cbc82015-04-20 09:13:01 -07001272 Connection c, List<Conferenceable> conferenceables) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -07001273 public void onConferenceChanged(Connection c, Conference conference) {}
Anthony Lee17455a32015-04-24 15:25:29 -07001274 public void onConferenceMergeFailed(Connection c) {}
Santos Cordon6b7f9552015-05-27 17:21:45 -07001275 public void onExtrasChanged(Connection c, Bundle extras) {}
Tyler Gunndee56a82016-03-23 16:06:34 -07001276 public void onExtrasRemoved(Connection c, List<String> keys) {}
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001277 public void onConnectionEvent(Connection c, String event, Bundle extras) {}
Hall Liua98f58b52017-11-07 17:59:28 -08001278 public void onAudioRouteChanged(Connection c, int audioRoute, String bluetoothAddress) {}
Hall Liub64ac4c2017-02-06 10:49:48 -08001279 public void onRttInitiationSuccess(Connection c) {}
1280 public void onRttInitiationFailure(Connection c, int reason) {}
1281 public void onRttSessionRemotelyTerminated(Connection c) {}
1282 public void onRemoteRttRequest(Connection c) {}
Srikanth Chintalafcb15012017-05-04 20:58:34 +05301283 /** @hide */
1284 public void onPhoneAccountChanged(Connection c, PhoneAccountHandle pHandle) {}
Mengjun Leng25707742017-07-04 11:10:37 +08001285 public void onConnectionTimeReset(Connection c) {}
Junhoedf3d822022-11-24 09:26:37 +00001286 public void onEndpointChanged(Connection c, CallEndpoint endpoint, Executor executor,
1287 OutcomeReceiver<Void, CallEndpointException> callback) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07001288 }
1289
Tyler Gunnb702ef82015-05-29 11:51:53 -07001290 /**
Hall Liu95d55872017-01-25 17:12:49 -08001291 * Provides methods to read and write RTT data to/from the in-call app.
Hall Liu95d55872017-01-25 17:12:49 -08001292 */
1293 public static final class RttTextStream {
1294 private static final int READ_BUFFER_SIZE = 1000;
1295 private final InputStreamReader mPipeFromInCall;
1296 private final OutputStreamWriter mPipeToInCall;
Hall Liub64ac4c2017-02-06 10:49:48 -08001297 private final ParcelFileDescriptor mFdFromInCall;
1298 private final ParcelFileDescriptor mFdToInCall;
Hall Liu17eb1bd2018-07-03 15:17:41 -07001299
1300 private final FileInputStream mFromInCallFileInputStream;
Hall Liu95d55872017-01-25 17:12:49 -08001301 private char[] mReadBuffer = new char[READ_BUFFER_SIZE];
1302
1303 /**
1304 * @hide
1305 */
1306 public RttTextStream(ParcelFileDescriptor toInCall, ParcelFileDescriptor fromInCall) {
Hall Liub64ac4c2017-02-06 10:49:48 -08001307 mFdFromInCall = fromInCall;
1308 mFdToInCall = toInCall;
Hall Liu17eb1bd2018-07-03 15:17:41 -07001309 mFromInCallFileInputStream = new FileInputStream(fromInCall.getFileDescriptor());
Hall Liu730a2592018-06-25 19:48:33 -07001310
1311 // Wrap the FileInputStream in a Channel so that it's interruptible.
Hall Liu95d55872017-01-25 17:12:49 -08001312 mPipeFromInCall = new InputStreamReader(
Hall Liu17eb1bd2018-07-03 15:17:41 -07001313 Channels.newInputStream(Channels.newChannel(mFromInCallFileInputStream)));
Hall Liu95d55872017-01-25 17:12:49 -08001314 mPipeToInCall = new OutputStreamWriter(
Hall Liua549fed2018-02-09 16:40:03 -08001315 new FileOutputStream(toInCall.getFileDescriptor()));
Hall Liu95d55872017-01-25 17:12:49 -08001316 }
1317
1318 /**
1319 * Writes the string {@param input} into the text stream to the UI for this RTT call. Since
1320 * RTT transmits text in real-time, this method should be called as often as text snippets
1321 * are received from the remote user, even if it is only one character.
Hall Liua549fed2018-02-09 16:40:03 -08001322 * <p>
Hall Liu95d55872017-01-25 17:12:49 -08001323 * This method is not thread-safe -- calling it from multiple threads simultaneously may
1324 * lead to interleaved text.
Hall Liua549fed2018-02-09 16:40:03 -08001325 *
Hall Liu95d55872017-01-25 17:12:49 -08001326 * @param input The message to send to the in-call app.
1327 */
1328 public void write(String input) throws IOException {
1329 mPipeToInCall.write(input);
1330 mPipeToInCall.flush();
1331 }
1332
1333
1334 /**
1335 * Reads a string from the in-call app, blocking if there is no data available. Returns
1336 * {@code null} if the RTT conversation has been terminated and there is no further data
1337 * to read.
Hall Liua549fed2018-02-09 16:40:03 -08001338 * <p>
Hall Liu95d55872017-01-25 17:12:49 -08001339 * This method is not thread-safe -- calling it from multiple threads simultaneously may
1340 * lead to interleaved text.
Hall Liua549fed2018-02-09 16:40:03 -08001341 *
Hall Liu95d55872017-01-25 17:12:49 -08001342 * @return A string containing text entered by the user, or {@code null} if the
1343 * conversation has been terminated or if there was an error while reading.
1344 */
Hall Liuffa4a812017-03-02 16:11:00 -08001345 public String read() throws IOException {
1346 int numRead = mPipeFromInCall.read(mReadBuffer, 0, READ_BUFFER_SIZE);
1347 if (numRead < 0) {
1348 return null;
1349 }
1350 return new String(mReadBuffer, 0, numRead);
1351 }
1352
1353 /**
1354 * Non-blocking version of {@link #read()}. Returns {@code null} if there is nothing to
1355 * be read.
Hall Liua549fed2018-02-09 16:40:03 -08001356 *
Hall Liuffa4a812017-03-02 16:11:00 -08001357 * @return A string containing text entered by the user, or {@code null} if the user has
1358 * not entered any new text yet.
1359 */
1360 public String readImmediately() throws IOException {
Hall Liu17eb1bd2018-07-03 15:17:41 -07001361 if (mFromInCallFileInputStream.available() > 0) {
Hall Liuffa4a812017-03-02 16:11:00 -08001362 return read();
1363 } else {
Hall Liu95d55872017-01-25 17:12:49 -08001364 return null;
1365 }
1366 }
Hall Liub64ac4c2017-02-06 10:49:48 -08001367
1368 /** @hide */
1369 public ParcelFileDescriptor getFdFromInCall() {
1370 return mFdFromInCall;
1371 }
1372
1373 /** @hide */
1374 public ParcelFileDescriptor getFdToInCall() {
1375 return mFdToInCall;
1376 }
1377 }
1378
1379 /**
1380 * Provides constants to represent the results of responses to session modify requests sent via
1381 * {@link Call#sendRttRequest()}
1382 */
1383 public static final class RttModifyStatus {
Hall Liu8dd49082017-04-21 14:33:12 -07001384 private RttModifyStatus() {}
Hall Liub64ac4c2017-02-06 10:49:48 -08001385 /**
1386 * Session modify request was successful.
1387 */
1388 public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1;
1389
1390 /**
1391 * Session modify request failed.
1392 */
1393 public static final int SESSION_MODIFY_REQUEST_FAIL = 2;
1394
1395 /**
1396 * Session modify request ignored due to invalid parameters.
1397 */
1398 public static final int SESSION_MODIFY_REQUEST_INVALID = 3;
1399
1400 /**
1401 * Session modify request timed out.
1402 */
1403 public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4;
1404
1405 /**
1406 * Session modify request rejected by remote user.
1407 */
1408 public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5;
Tyler Gunnb9a04962022-02-17 08:23:54 -08001409
1410
1411 /**@hide*/
1412 @Retention(RetentionPolicy.SOURCE)
1413 @IntDef(prefix = "SESSION_MODIFY_REQUEST_", value = {
1414 SESSION_MODIFY_REQUEST_SUCCESS,
1415 SESSION_MODIFY_REQUEST_FAIL,
1416 SESSION_MODIFY_REQUEST_INVALID,
1417 SESSION_MODIFY_REQUEST_TIMED_OUT,
1418 SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE
1419 })
1420 public @interface RttSessionModifyStatus {}
Hall Liu95d55872017-01-25 17:12:49 -08001421 }
1422
1423 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001424 * Provides a means of controlling the video session associated with a {@link Connection}.
1425 * <p>
1426 * Implementations create a custom subclass of {@link VideoProvider} and the
1427 * {@link ConnectionService} creates an instance sets it on the {@link Connection} using
1428 * {@link Connection#setVideoProvider(VideoProvider)}. Any connection which supports video
1429 * should set the {@link VideoProvider}.
1430 * <p>
1431 * The {@link VideoProvider} serves two primary purposes: it provides a means for Telecom and
1432 * {@link InCallService} implementations to issue requests related to the video session;
1433 * it provides a means for the {@link ConnectionService} to report events and information
1434 * related to the video session to Telecom and the {@link InCallService} implementations.
1435 * <p>
1436 * {@link InCallService} implementations interact with the {@link VideoProvider} via
1437 * {@link android.telecom.InCallService.VideoCall}.
1438 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001439 public static abstract class VideoProvider {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001440 /**
1441 * Video is not being received (no protocol pause was issued).
Tyler Gunnb702ef82015-05-29 11:51:53 -07001442 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001443 */
1444 public static final int SESSION_EVENT_RX_PAUSE = 1;
Evan Charltonbf11f982014-07-20 22:06:28 -07001445
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001446 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001447 * Video reception has resumed after a {@link #SESSION_EVENT_RX_PAUSE}.
1448 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001449 */
1450 public static final int SESSION_EVENT_RX_RESUME = 2;
1451
1452 /**
1453 * Video transmission has begun. This occurs after a negotiated start of video transmission
1454 * when the underlying protocol has actually begun transmitting video to the remote party.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001455 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001456 */
1457 public static final int SESSION_EVENT_TX_START = 3;
1458
1459 /**
1460 * Video transmission has stopped. This occurs after a negotiated stop of video transmission
1461 * when the underlying protocol has actually stopped transmitting video to the remote party.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001462 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001463 */
1464 public static final int SESSION_EVENT_TX_STOP = 4;
1465
1466 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001467 * A camera failure has occurred for the selected camera. The {@link VideoProvider} can use
Tyler Gunnb702ef82015-05-29 11:51:53 -07001468 * this as a cue to inform the user the camera is not available.
1469 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001470 */
1471 public static final int SESSION_EVENT_CAMERA_FAILURE = 5;
1472
1473 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001474 * Issued after {@link #SESSION_EVENT_CAMERA_FAILURE} when the camera is once again ready
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001475 * for operation. The {@link VideoProvider} can use this as a cue to inform the user that
Tyler Gunnb702ef82015-05-29 11:51:53 -07001476 * the camera has become available again.
1477 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001478 */
1479 public static final int SESSION_EVENT_CAMERA_READY = 6;
1480
1481 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001482 * Session event raised by Telecom when
1483 * {@link android.telecom.InCallService.VideoCall#setCamera(String)} is called and the
1484 * caller does not have the necessary {@link android.Manifest.permission#CAMERA} permission.
1485 * @see #handleCallSessionEvent(int)
1486 */
1487 public static final int SESSION_EVENT_CAMERA_PERMISSION_ERROR = 7;
1488
1489 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001490 * Session modify request was successful.
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_SUCCESS = 1;
1494
1495 /**
1496 * Session modify request failed.
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_FAIL = 2;
1500
1501 /**
1502 * Session modify request ignored due to invalid parameters.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001503 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001504 */
1505 public static final int SESSION_MODIFY_REQUEST_INVALID = 3;
1506
Rekha Kumar07366812015-03-24 16:42:31 -07001507 /**
1508 * Session modify request timed out.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001509 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Rekha Kumar07366812015-03-24 16:42:31 -07001510 */
1511 public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4;
1512
1513 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001514 * Session modify request rejected by remote user.
1515 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Rekha Kumar07366812015-03-24 16:42:31 -07001516 */
1517 public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5;
1518
Tyler Gunn75958422015-04-15 14:23:42 -07001519 private static final int MSG_ADD_VIDEO_CALLBACK = 1;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001520 private static final int MSG_SET_CAMERA = 2;
1521 private static final int MSG_SET_PREVIEW_SURFACE = 3;
1522 private static final int MSG_SET_DISPLAY_SURFACE = 4;
1523 private static final int MSG_SET_DEVICE_ORIENTATION = 5;
1524 private static final int MSG_SET_ZOOM = 6;
1525 private static final int MSG_SEND_SESSION_MODIFY_REQUEST = 7;
1526 private static final int MSG_SEND_SESSION_MODIFY_RESPONSE = 8;
1527 private static final int MSG_REQUEST_CAMERA_CAPABILITIES = 9;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001528 private static final int MSG_REQUEST_CONNECTION_DATA_USAGE = 10;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001529 private static final int MSG_SET_PAUSE_IMAGE = 11;
Tyler Gunn75958422015-04-15 14:23:42 -07001530 private static final int MSG_REMOVE_VIDEO_CALLBACK = 12;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001531
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001532 private static final String SESSION_EVENT_RX_PAUSE_STR = "RX_PAUSE";
1533 private static final String SESSION_EVENT_RX_RESUME_STR = "RX_RESUME";
1534 private static final String SESSION_EVENT_TX_START_STR = "TX_START";
1535 private static final String SESSION_EVENT_TX_STOP_STR = "TX_STOP";
1536 private static final String SESSION_EVENT_CAMERA_FAILURE_STR = "CAMERA_FAIL";
1537 private static final String SESSION_EVENT_CAMERA_READY_STR = "CAMERA_READY";
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001538 private static final String SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR =
1539 "CAMERA_PERMISSION_ERROR";
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001540 private static final String SESSION_EVENT_UNKNOWN_STR = "UNKNOWN";
1541
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001542 private VideoProvider.VideoProviderHandler mMessageHandler;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001543 private final VideoProvider.VideoProviderBinder mBinder;
Tyler Gunn75958422015-04-15 14:23:42 -07001544
1545 /**
1546 * Stores a list of the video callbacks, keyed by IBinder.
Tyler Gunn84f381b2015-06-12 09:26:45 -07001547 *
1548 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
1549 * load factor before resizing, 1 means we only expect a single thread to
1550 * access the map so make only a single shard
Tyler Gunn75958422015-04-15 14:23:42 -07001551 */
Tyler Gunn84f381b2015-06-12 09:26:45 -07001552 private ConcurrentHashMap<IBinder, IVideoCallback> mVideoCallbacks =
1553 new ConcurrentHashMap<IBinder, IVideoCallback>(8, 0.9f, 1);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001554
1555 /**
1556 * Default handler used to consolidate binder method calls onto a single thread.
1557 */
1558 private final class VideoProviderHandler extends Handler {
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001559 public VideoProviderHandler() {
1560 super();
1561 }
1562
1563 public VideoProviderHandler(Looper looper) {
1564 super(looper);
1565 }
1566
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001567 @Override
1568 public void handleMessage(Message msg) {
1569 switch (msg.what) {
Tyler Gunn75958422015-04-15 14:23:42 -07001570 case MSG_ADD_VIDEO_CALLBACK: {
1571 IBinder binder = (IBinder) msg.obj;
1572 IVideoCallback callback = IVideoCallback.Stub
1573 .asInterface((IBinder) msg.obj);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001574 if (callback == null) {
1575 Log.w(this, "addVideoProvider - skipped; callback is null.");
1576 break;
1577 }
1578
Tyler Gunn75958422015-04-15 14:23:42 -07001579 if (mVideoCallbacks.containsKey(binder)) {
1580 Log.i(this, "addVideoProvider - skipped; already present.");
1581 break;
1582 }
1583 mVideoCallbacks.put(binder, callback);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001584 break;
Tyler Gunn75958422015-04-15 14:23:42 -07001585 }
1586 case MSG_REMOVE_VIDEO_CALLBACK: {
1587 IBinder binder = (IBinder) msg.obj;
1588 IVideoCallback callback = IVideoCallback.Stub
1589 .asInterface((IBinder) msg.obj);
1590 if (!mVideoCallbacks.containsKey(binder)) {
1591 Log.i(this, "removeVideoProvider - skipped; not present.");
1592 break;
1593 }
1594 mVideoCallbacks.remove(binder);
1595 break;
1596 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001597 case MSG_SET_CAMERA:
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001598 {
1599 SomeArgs args = (SomeArgs) msg.obj;
1600 try {
1601 onSetCamera((String) args.arg1);
1602 onSetCamera((String) args.arg1, (String) args.arg2, args.argi1,
Tyler Gunn159f35c2017-03-02 09:28:37 -08001603 args.argi2, args.argi3);
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001604 } finally {
1605 args.recycle();
1606 }
1607 }
1608 break;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001609 case MSG_SET_PREVIEW_SURFACE:
1610 onSetPreviewSurface((Surface) msg.obj);
1611 break;
1612 case MSG_SET_DISPLAY_SURFACE:
1613 onSetDisplaySurface((Surface) msg.obj);
1614 break;
1615 case MSG_SET_DEVICE_ORIENTATION:
1616 onSetDeviceOrientation(msg.arg1);
1617 break;
1618 case MSG_SET_ZOOM:
1619 onSetZoom((Float) msg.obj);
1620 break;
Tyler Gunn45382162015-05-06 08:52:27 -07001621 case MSG_SEND_SESSION_MODIFY_REQUEST: {
1622 SomeArgs args = (SomeArgs) msg.obj;
1623 try {
1624 onSendSessionModifyRequest((VideoProfile) args.arg1,
1625 (VideoProfile) args.arg2);
1626 } finally {
1627 args.recycle();
1628 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001629 break;
Tyler Gunn45382162015-05-06 08:52:27 -07001630 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001631 case MSG_SEND_SESSION_MODIFY_RESPONSE:
1632 onSendSessionModifyResponse((VideoProfile) msg.obj);
1633 break;
1634 case MSG_REQUEST_CAMERA_CAPABILITIES:
1635 onRequestCameraCapabilities();
1636 break;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001637 case MSG_REQUEST_CONNECTION_DATA_USAGE:
1638 onRequestConnectionDataUsage();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001639 break;
1640 case MSG_SET_PAUSE_IMAGE:
Yorke Lee32f24732015-05-12 16:18:03 -07001641 onSetPauseImage((Uri) msg.obj);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001642 break;
1643 default:
1644 break;
1645 }
1646 }
1647 }
1648
1649 /**
1650 * IVideoProvider stub implementation.
1651 */
1652 private final class VideoProviderBinder extends IVideoProvider.Stub {
Tyler Gunn75958422015-04-15 14:23:42 -07001653 public void addVideoCallback(IBinder videoCallbackBinder) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001654 mMessageHandler.obtainMessage(
Tyler Gunn75958422015-04-15 14:23:42 -07001655 MSG_ADD_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget();
1656 }
1657
1658 public void removeVideoCallback(IBinder videoCallbackBinder) {
1659 mMessageHandler.obtainMessage(
1660 MSG_REMOVE_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001661 }
1662
Tyler Gunn159f35c2017-03-02 09:28:37 -08001663 public void setCamera(String cameraId, String callingPackageName,
1664 int targetSdkVersion) {
1665
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001666 SomeArgs args = SomeArgs.obtain();
1667 args.arg1 = cameraId;
1668 // Propagate the calling package; originally determined in
1669 // android.telecom.InCallService.VideoCall#setCamera(String) from the calling
1670 // process.
1671 args.arg2 = callingPackageName;
1672 // Pass along the uid and pid of the calling app; this gets lost when we put the
1673 // message onto the handler. These are required for Telecom to perform a permission
1674 // check to see if the calling app is able to use the camera.
1675 args.argi1 = Binder.getCallingUid();
1676 args.argi2 = Binder.getCallingPid();
Tyler Gunn159f35c2017-03-02 09:28:37 -08001677 // Pass along the target SDK version of the calling InCallService. This is used to
1678 // maintain backwards compatibility of the API for older callers.
1679 args.argi3 = targetSdkVersion;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001680 mMessageHandler.obtainMessage(MSG_SET_CAMERA, args).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001681 }
1682
1683 public void setPreviewSurface(Surface surface) {
1684 mMessageHandler.obtainMessage(MSG_SET_PREVIEW_SURFACE, surface).sendToTarget();
1685 }
1686
1687 public void setDisplaySurface(Surface surface) {
1688 mMessageHandler.obtainMessage(MSG_SET_DISPLAY_SURFACE, surface).sendToTarget();
1689 }
1690
1691 public void setDeviceOrientation(int rotation) {
Rekha Kumar07366812015-03-24 16:42:31 -07001692 mMessageHandler.obtainMessage(
1693 MSG_SET_DEVICE_ORIENTATION, rotation, 0).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001694 }
1695
1696 public void setZoom(float value) {
1697 mMessageHandler.obtainMessage(MSG_SET_ZOOM, value).sendToTarget();
1698 }
1699
Tyler Gunn45382162015-05-06 08:52:27 -07001700 public void sendSessionModifyRequest(VideoProfile fromProfile, VideoProfile toProfile) {
1701 SomeArgs args = SomeArgs.obtain();
1702 args.arg1 = fromProfile;
1703 args.arg2 = toProfile;
1704 mMessageHandler.obtainMessage(MSG_SEND_SESSION_MODIFY_REQUEST, args).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001705 }
1706
1707 public void sendSessionModifyResponse(VideoProfile responseProfile) {
1708 mMessageHandler.obtainMessage(
1709 MSG_SEND_SESSION_MODIFY_RESPONSE, responseProfile).sendToTarget();
1710 }
1711
1712 public void requestCameraCapabilities() {
1713 mMessageHandler.obtainMessage(MSG_REQUEST_CAMERA_CAPABILITIES).sendToTarget();
1714 }
1715
1716 public void requestCallDataUsage() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001717 mMessageHandler.obtainMessage(MSG_REQUEST_CONNECTION_DATA_USAGE).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001718 }
1719
Yorke Lee32f24732015-05-12 16:18:03 -07001720 public void setPauseImage(Uri uri) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001721 mMessageHandler.obtainMessage(MSG_SET_PAUSE_IMAGE, uri).sendToTarget();
1722 }
1723 }
1724
1725 public VideoProvider() {
1726 mBinder = new VideoProvider.VideoProviderBinder();
Tyler Gunn84f381b2015-06-12 09:26:45 -07001727 mMessageHandler = new VideoProvider.VideoProviderHandler(Looper.getMainLooper());
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001728 }
1729
1730 /**
1731 * Creates an instance of the {@link VideoProvider}, specifying the looper to use.
1732 *
1733 * @param looper The looper.
1734 * @hide
1735 */
Mathew Inwood42346d12018-08-01 11:33:05 +01001736 @UnsupportedAppUsage
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001737 public VideoProvider(Looper looper) {
1738 mBinder = new VideoProvider.VideoProviderBinder();
1739 mMessageHandler = new VideoProvider.VideoProviderHandler(looper);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001740 }
1741
1742 /**
1743 * Returns binder object which can be used across IPC methods.
1744 * @hide
1745 */
1746 public final IVideoProvider getInterface() {
1747 return mBinder;
1748 }
1749
1750 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001751 * Sets the camera to be used for the outgoing video.
1752 * <p>
1753 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1754 * camera via
1755 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1756 * <p>
1757 * Sent from the {@link InCallService} via
1758 * {@link InCallService.VideoCall#setCamera(String)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001759 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001760 * @param cameraId The id of the camera (use ids as reported by
1761 * {@link CameraManager#getCameraIdList()}).
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001762 */
1763 public abstract void onSetCamera(String cameraId);
1764
1765 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001766 * Sets the camera to be used for the outgoing video.
1767 * <p>
1768 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1769 * camera via
1770 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1771 * <p>
1772 * This prototype is used internally to ensure that the calling package name, UID and PID
1773 * are sent to Telecom so that can perform a camera permission check on the caller.
1774 * <p>
1775 * Sent from the {@link InCallService} via
1776 * {@link InCallService.VideoCall#setCamera(String)}.
1777 *
1778 * @param cameraId The id of the camera (use ids as reported by
1779 * {@link CameraManager#getCameraIdList()}).
1780 * @param callingPackageName The AppOpps package name of the caller.
1781 * @param callingUid The UID of the caller.
1782 * @param callingPid The PID of the caller.
Tyler Gunn159f35c2017-03-02 09:28:37 -08001783 * @param targetSdkVersion The target SDK version of the caller.
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001784 * @hide
1785 */
1786 public void onSetCamera(String cameraId, String callingPackageName, int callingUid,
Tyler Gunn159f35c2017-03-02 09:28:37 -08001787 int callingPid, int targetSdkVersion) {}
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001788
1789 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001790 * Sets the surface to be used for displaying a preview of what the user's camera is
1791 * currently capturing. When video transmission is enabled, this is the video signal which
1792 * is sent to the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001793 * <p>
1794 * Sent from the {@link InCallService} via
1795 * {@link InCallService.VideoCall#setPreviewSurface(Surface)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001796 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001797 * @param surface The {@link Surface}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001798 */
1799 public abstract void onSetPreviewSurface(Surface surface);
1800
1801 /**
1802 * Sets the surface to be used for displaying the video received from the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001803 * <p>
1804 * Sent from the {@link InCallService} via
1805 * {@link InCallService.VideoCall#setDisplaySurface(Surface)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001806 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001807 * @param surface The {@link Surface}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001808 */
1809 public abstract void onSetDisplaySurface(Surface surface);
1810
1811 /**
1812 * Sets the device orientation, in degrees. Assumes that a standard portrait orientation of
1813 * the device is 0 degrees.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001814 * <p>
1815 * Sent from the {@link InCallService} via
1816 * {@link InCallService.VideoCall#setDeviceOrientation(int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001817 *
1818 * @param rotation The device orientation, in degrees.
1819 */
1820 public abstract void onSetDeviceOrientation(int rotation);
1821
1822 /**
Tyler Gunnc603b462021-06-14 17:24:40 -07001823 * Sets the camera zoom ratio.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001824 * <p>
1825 * Sent from the {@link InCallService} via {@link InCallService.VideoCall#setZoom(float)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001826 *
Tyler Gunnc603b462021-06-14 17:24:40 -07001827 * @param value The camera zoom ratio; for the current camera, should be a value in the
1828 * range defined by
1829 * {@link android.hardware.camera2.CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001830 */
1831 public abstract void onSetZoom(float value);
1832
1833 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001834 * Issues a request to modify the properties of the current video session.
1835 * <p>
1836 * Example scenarios include: requesting an audio-only call to be upgraded to a
1837 * bi-directional video call, turning on or off the user's camera, sending a pause signal
1838 * when the {@link InCallService} is no longer the foreground application.
1839 * <p>
1840 * If the {@link VideoProvider} determines a request to be invalid, it should call
1841 * {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)} to report the
1842 * invalid request back to the {@link InCallService}.
1843 * <p>
1844 * Where a request requires confirmation from the user of the peer device, the
1845 * {@link VideoProvider} must communicate the request to the peer device and handle the
1846 * user's response. {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)}
1847 * is used to inform the {@link InCallService} of the result of the request.
1848 * <p>
1849 * Sent from the {@link InCallService} via
1850 * {@link InCallService.VideoCall#sendSessionModifyRequest(VideoProfile)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001851 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001852 * @param fromProfile The video profile prior to the request.
1853 * @param toProfile The video profile with the requested changes made.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001854 */
Tyler Gunn45382162015-05-06 08:52:27 -07001855 public abstract void onSendSessionModifyRequest(VideoProfile fromProfile,
1856 VideoProfile toProfile);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001857
Tyler Gunnb702ef82015-05-29 11:51:53 -07001858 /**
1859 * Provides a response to a request to change the current video session properties.
1860 * <p>
1861 * For example, if the peer requests and upgrade from an audio-only call to a bi-directional
1862 * video call, could decline the request and keep the call as audio-only.
1863 * In such a scenario, the {@code responseProfile} would have a video state of
1864 * {@link VideoProfile#STATE_AUDIO_ONLY}. If the user had decided to accept the request,
1865 * the video state would be {@link VideoProfile#STATE_BIDIRECTIONAL}.
1866 * <p>
1867 * Sent from the {@link InCallService} via
1868 * {@link InCallService.VideoCall#sendSessionModifyResponse(VideoProfile)} in response to
1869 * a {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)}
1870 * callback.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001871 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001872 * @param responseProfile The response video profile.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001873 */
1874 public abstract void onSendSessionModifyResponse(VideoProfile responseProfile);
1875
1876 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001877 * Issues a request to the {@link VideoProvider} to retrieve the camera capabilities.
1878 * <p>
1879 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1880 * camera via
1881 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1882 * <p>
1883 * Sent from the {@link InCallService} via
1884 * {@link InCallService.VideoCall#requestCameraCapabilities()}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001885 */
1886 public abstract void onRequestCameraCapabilities();
1887
1888 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001889 * Issues a request to the {@link VideoProvider} to retrieve the current data usage for the
1890 * video component of the current {@link Connection}.
1891 * <p>
1892 * The {@link VideoProvider} should respond by communicating current data usage, in bytes,
1893 * via {@link VideoProvider#setCallDataUsage(long)}.
1894 * <p>
1895 * Sent from the {@link InCallService} via
1896 * {@link InCallService.VideoCall#requestCallDataUsage()}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001897 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001898 public abstract void onRequestConnectionDataUsage();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001899
1900 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001901 * Provides the {@link VideoProvider} with the {@link Uri} of an image to be displayed to
1902 * the peer device when the video signal is paused.
1903 * <p>
1904 * Sent from the {@link InCallService} via
1905 * {@link InCallService.VideoCall#setPauseImage(Uri)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001906 *
1907 * @param uri URI of image to display.
1908 */
Yorke Lee32f24732015-05-12 16:18:03 -07001909 public abstract void onSetPauseImage(Uri uri);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001910
1911 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001912 * Used to inform listening {@link InCallService} implementations when the
1913 * {@link VideoProvider} receives a session modification request.
1914 * <p>
1915 * Received by the {@link InCallService} via
1916 * {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)},
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001917 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001918 * @param videoProfile The requested video profile.
1919 * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001920 */
1921 public void receiveSessionModifyRequest(VideoProfile videoProfile) {
Tyler Gunn75958422015-04-15 14:23:42 -07001922 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001923 for (IVideoCallback callback : mVideoCallbacks.values()) {
1924 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001925 callback.receiveSessionModifyRequest(videoProfile);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001926 } catch (RemoteException ignored) {
1927 Log.w(this, "receiveSessionModifyRequest callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001928 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001929 }
1930 }
1931 }
1932
1933 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001934 * Used to inform listening {@link InCallService} implementations when the
1935 * {@link VideoProvider} receives a response to a session modification request.
1936 * <p>
1937 * Received by the {@link InCallService} via
1938 * {@link InCallService.VideoCall.Callback#onSessionModifyResponseReceived(int,
1939 * VideoProfile, VideoProfile)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001940 *
1941 * @param status Status of the session modify request. Valid values are
1942 * {@link VideoProvider#SESSION_MODIFY_REQUEST_SUCCESS},
1943 * {@link VideoProvider#SESSION_MODIFY_REQUEST_FAIL},
Tyler Gunnb702ef82015-05-29 11:51:53 -07001944 * {@link VideoProvider#SESSION_MODIFY_REQUEST_INVALID},
1945 * {@link VideoProvider#SESSION_MODIFY_REQUEST_TIMED_OUT},
1946 * {@link VideoProvider#SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE}
1947 * @param requestedProfile The original request which was sent to the peer device.
1948 * @param responseProfile The actual profile changes agreed to by the peer device.
1949 * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001950 */
1951 public void receiveSessionModifyResponse(int status,
1952 VideoProfile requestedProfile, VideoProfile responseProfile) {
Tyler Gunn75958422015-04-15 14:23:42 -07001953 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001954 for (IVideoCallback callback : mVideoCallbacks.values()) {
1955 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001956 callback.receiveSessionModifyResponse(status, requestedProfile,
1957 responseProfile);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001958 } catch (RemoteException ignored) {
1959 Log.w(this, "receiveSessionModifyResponse callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001960 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001961 }
1962 }
1963 }
1964
1965 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001966 * Used to inform listening {@link InCallService} implementations when the
1967 * {@link VideoProvider} reports a call session event.
1968 * <p>
1969 * Received by the {@link InCallService} via
1970 * {@link InCallService.VideoCall.Callback#onCallSessionEvent(int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001971 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001972 * @param event The event. Valid values are: {@link VideoProvider#SESSION_EVENT_RX_PAUSE},
1973 * {@link VideoProvider#SESSION_EVENT_RX_RESUME},
1974 * {@link VideoProvider#SESSION_EVENT_TX_START},
1975 * {@link VideoProvider#SESSION_EVENT_TX_STOP},
1976 * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE},
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001977 * {@link VideoProvider#SESSION_EVENT_CAMERA_READY},
1978 * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001979 */
1980 public void handleCallSessionEvent(int event) {
Tyler Gunn75958422015-04-15 14:23:42 -07001981 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001982 for (IVideoCallback callback : mVideoCallbacks.values()) {
1983 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001984 callback.handleCallSessionEvent(event);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001985 } catch (RemoteException ignored) {
1986 Log.w(this, "handleCallSessionEvent callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001987 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001988 }
1989 }
1990 }
1991
1992 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001993 * Used to inform listening {@link InCallService} implementations when the dimensions of the
1994 * peer's video have changed.
1995 * <p>
1996 * This could occur if, for example, the peer rotates their device, changing the aspect
1997 * ratio of the video, or if the user switches between the back and front cameras.
1998 * <p>
1999 * Received by the {@link InCallService} via
2000 * {@link InCallService.VideoCall.Callback#onPeerDimensionsChanged(int, int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002001 *
2002 * @param width The updated peer video width.
2003 * @param height The updated peer video height.
2004 */
2005 public void changePeerDimensions(int width, int height) {
Tyler Gunn75958422015-04-15 14:23:42 -07002006 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002007 for (IVideoCallback callback : mVideoCallbacks.values()) {
2008 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002009 callback.changePeerDimensions(width, height);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002010 } catch (RemoteException ignored) {
2011 Log.w(this, "changePeerDimensions callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002012 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002013 }
2014 }
2015 }
2016
2017 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002018 * Used to inform listening {@link InCallService} implementations when the data usage of the
2019 * video associated with the current {@link Connection} has changed.
2020 * <p>
2021 * This could be in response to a preview request via
2022 * {@link #onRequestConnectionDataUsage()}, or as a periodic update by the
Tyler Gunn295f5d72015-06-04 11:08:54 -07002023 * {@link VideoProvider}. Where periodic updates of data usage are provided, they should be
2024 * 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 -07002025 * <p>
2026 * Received by the {@link InCallService} via
2027 * {@link InCallService.VideoCall.Callback#onCallDataUsageChanged(long)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002028 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002029 * @param dataUsage The updated data usage (in bytes). Reported as the cumulative bytes
2030 * used since the start of the call.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002031 */
Yorke Lee32f24732015-05-12 16:18:03 -07002032 public void setCallDataUsage(long dataUsage) {
Tyler Gunn75958422015-04-15 14:23:42 -07002033 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002034 for (IVideoCallback callback : mVideoCallbacks.values()) {
2035 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002036 callback.changeCallDataUsage(dataUsage);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002037 } catch (RemoteException ignored) {
2038 Log.w(this, "setCallDataUsage callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002039 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002040 }
2041 }
2042 }
2043
2044 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002045 * @see #setCallDataUsage(long)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002046 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002047 * @param dataUsage The updated data usage (in byes).
Yorke Lee32f24732015-05-12 16:18:03 -07002048 * @deprecated - Use {@link #setCallDataUsage(long)} instead.
2049 * @hide
2050 */
2051 public void changeCallDataUsage(long dataUsage) {
2052 setCallDataUsage(dataUsage);
2053 }
2054
2055 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002056 * Used to inform listening {@link InCallService} implementations when the capabilities of
2057 * the current camera have changed.
2058 * <p>
2059 * The {@link VideoProvider} should call this in response to
2060 * {@link VideoProvider#onRequestCameraCapabilities()}, or when the current camera is
2061 * changed via {@link VideoProvider#onSetCamera(String)}.
2062 * <p>
2063 * Received by the {@link InCallService} via
2064 * {@link InCallService.VideoCall.Callback#onCameraCapabilitiesChanged(
2065 * VideoProfile.CameraCapabilities)}.
Yorke Lee32f24732015-05-12 16:18:03 -07002066 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002067 * @param cameraCapabilities The new camera capabilities.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002068 */
Yorke Lee400470f2015-05-12 13:31:25 -07002069 public void changeCameraCapabilities(VideoProfile.CameraCapabilities cameraCapabilities) {
Tyler Gunn75958422015-04-15 14:23:42 -07002070 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002071 for (IVideoCallback callback : mVideoCallbacks.values()) {
2072 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002073 callback.changeCameraCapabilities(cameraCapabilities);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002074 } catch (RemoteException ignored) {
2075 Log.w(this, "changeCameraCapabilities callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002076 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002077 }
2078 }
2079 }
Rekha Kumar07366812015-03-24 16:42:31 -07002080
2081 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002082 * Used to inform listening {@link InCallService} implementations when the video quality
2083 * of the call has changed.
2084 * <p>
2085 * Received by the {@link InCallService} via
2086 * {@link InCallService.VideoCall.Callback#onVideoQualityChanged(int)}.
Rekha Kumar07366812015-03-24 16:42:31 -07002087 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002088 * @param videoQuality The updated video quality. Valid values:
2089 * {@link VideoProfile#QUALITY_HIGH},
2090 * {@link VideoProfile#QUALITY_MEDIUM},
2091 * {@link VideoProfile#QUALITY_LOW},
2092 * {@link VideoProfile#QUALITY_DEFAULT}.
Rekha Kumar07366812015-03-24 16:42:31 -07002093 */
2094 public void changeVideoQuality(int videoQuality) {
Tyler Gunn75958422015-04-15 14:23:42 -07002095 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002096 for (IVideoCallback callback : mVideoCallbacks.values()) {
2097 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002098 callback.changeVideoQuality(videoQuality);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002099 } catch (RemoteException ignored) {
2100 Log.w(this, "changeVideoQuality callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002101 }
Rekha Kumar07366812015-03-24 16:42:31 -07002102 }
2103 }
2104 }
Tyler Gunn6f657ee2016-09-02 09:55:25 -07002105
2106 /**
2107 * Returns a string representation of a call session event.
2108 *
2109 * @param event A call session event passed to {@link #handleCallSessionEvent(int)}.
2110 * @return String representation of the call session event.
2111 * @hide
2112 */
2113 public static String sessionEventToString(int event) {
2114 switch (event) {
2115 case SESSION_EVENT_CAMERA_FAILURE:
2116 return SESSION_EVENT_CAMERA_FAILURE_STR;
2117 case SESSION_EVENT_CAMERA_READY:
2118 return SESSION_EVENT_CAMERA_READY_STR;
2119 case SESSION_EVENT_RX_PAUSE:
2120 return SESSION_EVENT_RX_PAUSE_STR;
2121 case SESSION_EVENT_RX_RESUME:
2122 return SESSION_EVENT_RX_RESUME_STR;
2123 case SESSION_EVENT_TX_START:
2124 return SESSION_EVENT_TX_START_STR;
2125 case SESSION_EVENT_TX_STOP:
2126 return SESSION_EVENT_TX_STOP_STR;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08002127 case SESSION_EVENT_CAMERA_PERMISSION_ERROR:
2128 return SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR;
Tyler Gunn6f657ee2016-09-02 09:55:25 -07002129 default:
2130 return SESSION_EVENT_UNKNOWN_STR + " " + event;
2131 }
2132 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002133 }
2134
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002135 private final Listener mConnectionDeathListener = new Listener() {
2136 @Override
2137 public void onDestroyed(Connection c) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002138 if (mConferenceables.remove(c)) {
2139 fireOnConferenceableConnectionsChanged();
2140 }
2141 }
2142 };
2143
2144 private final Conference.Listener mConferenceDeathListener = new Conference.Listener() {
2145 @Override
2146 public void onDestroyed(Conference c) {
2147 if (mConferenceables.remove(c)) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002148 fireOnConferenceableConnectionsChanged();
2149 }
2150 }
2151 };
2152
Jay Shrauner229e3822014-08-15 09:23:07 -07002153 /**
2154 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
2155 * load factor before resizing, 1 means we only expect a single thread to
2156 * access the map so make only a single shard
2157 */
2158 private final Set<Listener> mListeners = Collections.newSetFromMap(
2159 new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1));
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002160 private final List<Conferenceable> mConferenceables = new ArrayList<>();
2161 private final List<Conferenceable> mUnmodifiableConferenceables =
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002162 Collections.unmodifiableList(mConferenceables);
Santos Cordonb6939982014-06-04 20:20:58 -07002163
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002164 // The internal telecom call ID associated with this connection.
2165 private String mTelecomCallId;
Pengquan Meng70c9885332017-10-02 18:09:03 -07002166 // The PhoneAccountHandle associated with this connection.
2167 private PhoneAccountHandle mPhoneAccountHandle;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002168 private int mState = STATE_NEW;
Yorke Lee4af59352015-05-13 14:14:54 -07002169 private CallAudioState mCallAudioState;
Junhoedf3d822022-11-24 09:26:37 +00002170 private CallEndpoint mCallEndpoint;
Andrew Lee100e2932014-09-08 15:34:24 -07002171 private Uri mAddress;
2172 private int mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -07002173 private String mCallerDisplayName;
2174 private int mCallerDisplayNamePresentation;
Andrew Lee100e2932014-09-08 15:34:24 -07002175 private boolean mRingbackRequested = false;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002176 private int mConnectionCapabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -07002177 private int mConnectionProperties;
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002178 private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002179 private VideoProvider mVideoProvider;
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002180 private boolean mAudioModeIsVoip;
Roshan Piuse927ec02015-07-15 15:47:21 -07002181 private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002182 private long mConnectElapsedTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002183 private StatusHints mStatusHints;
Tyler Gunnaa07df82014-07-17 07:50:22 -07002184 private int mVideoState;
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002185 private DisconnectCause mDisconnectCause;
Santos Cordon823fd3c2014-08-07 18:35:18 -07002186 private Conference mConference;
2187 private ConnectionService mConnectionService;
Santos Cordon6b7f9552015-05-27 17:21:45 -07002188 private Bundle mExtras;
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002189 private final Object mExtrasLock = new Object();
Tyler Gunn6986a632019-06-25 13:45:32 -07002190 /**
2191 * The direction of the connection; used where an existing connection is created and we need to
2192 * communicate to Telecom whether its incoming or outgoing.
2193 */
2194 private @Call.Details.CallDirection int mCallDirection = Call.Details.DIRECTION_UNKNOWN;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002195
2196 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002197 * Tracks the key set for the extras bundle provided on the last invocation of
2198 * {@link #setExtras(Bundle)}. Used so that on subsequent invocations we can remove any extras
2199 * keys which were set previously but are no longer present in the replacement Bundle.
2200 */
2201 private Set<String> mPreviousExtraKeys;
2202
2203 /**
Tyler Gunnd57d76c2019-09-24 14:53:23 -07002204 * The verification status for an incoming call's phone number.
2205 */
2206 private @VerificationStatus int mCallerNumberVerificationStatus;
2207
2208
2209 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002210 * Create a new Connection.
2211 */
Santos Cordonf2951102014-07-20 19:06:29 -07002212 public Connection() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002213
2214 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002215 * Returns the Telecom internal call ID associated with this connection. Should only be used
2216 * for debugging and tracing purposes.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002217 * <p>
2218 * Note: Access to the Telecom internal call ID is used for logging purposes only; this API is
2219 * provided to facilitate debugging of the Telephony stack only.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002220 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07002221 * @return The Telecom call ID, or {@code null} if it was not set.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002222 * @hide
2223 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002224 @SystemApi
2225 public final @Nullable String getTelecomCallId() {
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002226 return mTelecomCallId;
2227 }
2228
2229 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002230 * @return The address (e.g., phone number) to which this Connection is currently communicating.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002231 */
Andrew Lee100e2932014-09-08 15:34:24 -07002232 public final Uri getAddress() {
2233 return mAddress;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002234 }
2235
2236 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002237 * @return The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002238 * See {@link TelecomManager} for valid values.
Sailesh Nepal61203862014-07-11 14:50:13 -07002239 */
Andrew Lee100e2932014-09-08 15:34:24 -07002240 public final int getAddressPresentation() {
2241 return mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -07002242 }
2243
2244 /**
2245 * @return The caller display name (CNAP).
2246 */
2247 public final String getCallerDisplayName() {
2248 return mCallerDisplayName;
2249 }
2250
2251 /**
Nancy Chen9d568c02014-09-08 14:17:59 -07002252 * @return The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002253 * See {@link TelecomManager} for valid values.
Sailesh Nepal61203862014-07-11 14:50:13 -07002254 */
2255 public final int getCallerDisplayNamePresentation() {
2256 return mCallerDisplayNamePresentation;
2257 }
2258
2259 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002260 * @return The state of this Connection.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002261 */
2262 public final int getState() {
2263 return mState;
2264 }
2265
2266 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002267 * Returns the video state of the connection.
Yorke Lee32f24732015-05-12 16:18:03 -07002268 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
2269 * {@link VideoProfile#STATE_BIDIRECTIONAL},
2270 * {@link VideoProfile#STATE_TX_ENABLED},
2271 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002272 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002273 * @return The video state of the connection.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002274 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002275 public final @VideoProfile.VideoState int getVideoState() {
Tyler Gunnaa07df82014-07-17 07:50:22 -07002276 return mVideoState;
2277 }
2278
2279 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002280 * @return The audio state of the connection, describing how its audio is currently
Ihab Awad542e0ea2014-05-16 10:22:16 -07002281 * being routed by the system. This is {@code null} if this Connection
2282 * does not directly know about its audio state.
Yorke Lee4af59352015-05-13 14:14:54 -07002283 * @deprecated Use {@link #getCallAudioState()} instead.
2284 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -07002285 */
Yorke Lee4af59352015-05-13 14:14:54 -07002286 @SystemApi
2287 @Deprecated
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002288 public final AudioState getAudioState() {
Sailesh Nepal000d38a2015-06-21 10:25:13 -07002289 if (mCallAudioState == null) {
2290 return null;
2291 }
Yorke Lee4af59352015-05-13 14:14:54 -07002292 return new AudioState(mCallAudioState);
2293 }
2294
2295 /**
2296 * @return The audio state of the connection, describing how its audio is currently
2297 * being routed by the system. This is {@code null} if this Connection
2298 * does not directly know about its audio state.
Junhoedf3d822022-11-24 09:26:37 +00002299 * @deprecated Use {@link #getCurrentCallEndpoint()},
2300 * {@link #onAvailableCallEndpointsChanged(List)} and
2301 * {@link #onMuteStateChanged(boolean)} instead.
Yorke Lee4af59352015-05-13 14:14:54 -07002302 */
Junhoedf3d822022-11-24 09:26:37 +00002303 @Deprecated
Yorke Lee4af59352015-05-13 14:14:54 -07002304 public final CallAudioState getCallAudioState() {
2305 return mCallAudioState;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002306 }
2307
2308 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002309 * @return The conference that this connection is a part of. Null if it is not part of any
2310 * conference.
2311 */
2312 public final Conference getConference() {
2313 return mConference;
2314 }
2315
2316 /**
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002317 * Returns whether this connection is requesting that the system play a ringback tone
2318 * on its behalf.
2319 */
Andrew Lee100e2932014-09-08 15:34:24 -07002320 public final boolean isRingbackRequested() {
2321 return mRingbackRequested;
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002322 }
2323
2324 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002325 * @return True if the connection's audio mode is VOIP.
2326 */
2327 public final boolean getAudioModeIsVoip() {
2328 return mAudioModeIsVoip;
2329 }
2330
2331 /**
Roshan Piuse927ec02015-07-15 15:47:21 -07002332 * Retrieves the connection start time of the {@code Connnection}, if specified. A value of
2333 * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
2334 * start time of the conference.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002335 * <p>
2336 * Note: This is an implementation detail specific to IMS conference calls over a mobile
2337 * network.
Roshan Piuse927ec02015-07-15 15:47:21 -07002338 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07002339 * @return The time at which the {@code Connnection} was connected. Will be a value as retrieved
2340 * from {@link System#currentTimeMillis()}.
Roshan Piuse927ec02015-07-15 15:47:21 -07002341 *
2342 * @hide
2343 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002344 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002345 public final @IntRange(from = 0) long getConnectTimeMillis() {
Roshan Piuse927ec02015-07-15 15:47:21 -07002346 return mConnectTimeMillis;
2347 }
2348
2349 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002350 * Retrieves the connection start time of the {@link Connection}, if specified. A value of
2351 * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
Tyler Gunnc9503d62020-01-27 10:30:51 -08002352 * start time of the connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002353 * <p>
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002354 * Based on the value of {@link SystemClock#elapsedRealtime()}, which ensures that wall-clock
2355 * changes do not impact the call duration.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002356 * <p>
2357 * Used internally in Telephony when migrating conference participant data for IMS conferences.
Tyler Gunnc9503d62020-01-27 10:30:51 -08002358 * <p>
2359 * The value returned is the same one set using
2360 * {@link #setConnectionStartElapsedRealtimeMillis(long)}. This value is never updated from
2361 * the Telecom framework, so no permission enforcement occurs when retrieving the value with
2362 * this method.
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002363 *
2364 * @return The time at which the {@link Connection} was connected.
2365 *
2366 * @hide
2367 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002368 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002369 public final @ElapsedRealtimeLong long getConnectionStartElapsedRealtimeMillis() {
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002370 return mConnectElapsedTimeMillis;
2371 }
2372
2373 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002374 * @return The status hints for this connection.
2375 */
2376 public final StatusHints getStatusHints() {
2377 return mStatusHints;
2378 }
2379
2380 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002381 * Returns the extras associated with this connection.
Tyler Gunn2cbe2b52016-05-04 15:48:10 +00002382 * <p>
2383 * Extras should be updated using {@link #putExtras(Bundle)}.
2384 * <p>
2385 * Telecom or an {@link InCallService} can also update the extras via
2386 * {@link android.telecom.Call#putExtras(Bundle)}, and
2387 * {@link Call#removeExtras(List)}.
2388 * <p>
2389 * The connection is notified of changes to the extras made by Telecom or an
2390 * {@link InCallService} by {@link #onExtrasChanged(Bundle)}.
Tyler Gunndee56a82016-03-23 16:06:34 -07002391 *
Santos Cordon6b7f9552015-05-27 17:21:45 -07002392 * @return The extras associated with this connection.
2393 */
2394 public final Bundle getExtras() {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002395 Bundle extras = null;
2396 synchronized (mExtrasLock) {
2397 if (mExtras != null) {
2398 extras = new Bundle(mExtras);
2399 }
2400 }
2401 return extras;
Santos Cordon6b7f9552015-05-27 17:21:45 -07002402 }
2403
2404 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002405 * Assign a listener to be notified of state changes.
2406 *
2407 * @param l A listener.
2408 * @return This Connection.
2409 *
2410 * @hide
2411 */
Tyler Gunn633e4c32019-10-24 15:40:48 -07002412 final Connection addConnectionListener(Listener l) {
Santos Cordond34e5712014-08-05 18:54:03 +00002413 mListeners.add(l);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002414 return this;
2415 }
2416
2417 /**
2418 * Remove a previously assigned listener that was being notified of state changes.
2419 *
2420 * @param l A Listener.
2421 * @return This Connection.
2422 *
2423 * @hide
2424 */
Tyler Gunn633e4c32019-10-24 15:40:48 -07002425 final Connection removeConnectionListener(Listener l) {
Jay Shrauner229e3822014-08-15 09:23:07 -07002426 if (l != null) {
2427 mListeners.remove(l);
2428 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002429 return this;
2430 }
2431
2432 /**
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002433 * @return The {@link DisconnectCause} for this connection.
Evan Charltonbf11f982014-07-20 22:06:28 -07002434 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002435 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002436 return mDisconnectCause;
Evan Charltonbf11f982014-07-20 22:06:28 -07002437 }
2438
2439 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002440 * Sets the telecom call ID associated with this Connection. The Telecom Call ID should be used
2441 * ONLY for debugging purposes.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002442 * <p>
2443 * Note: Access to the Telecom internal call ID is used for logging purposes only; this API is
2444 * provided to facilitate debugging of the Telephony stack only. Changing the ID via this
2445 * method does NOT change any functionality in Telephony or Telecom and impacts only logging.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002446 *
2447 * @param callId The telecom call ID.
2448 * @hide
2449 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002450 @SystemApi
2451 public void setTelecomCallId(@NonNull String callId) {
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002452 mTelecomCallId = callId;
2453 }
2454
2455 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002456 * Inform this Connection that the state of its audio output has been changed externally.
2457 *
2458 * @param state The new audio state.
Sailesh Nepal400cc482014-06-26 12:04:00 -07002459 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -07002460 */
Yorke Lee4af59352015-05-13 14:14:54 -07002461 final void setCallAudioState(CallAudioState state) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002462 checkImmutable();
Ihab Awad60ac30b2014-05-20 22:32:12 -07002463 Log.d(this, "setAudioState %s", state);
Yorke Lee4af59352015-05-13 14:14:54 -07002464 mCallAudioState = state;
2465 onAudioStateChanged(getAudioState());
2466 onCallAudioStateChanged(state);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002467 }
2468
2469 /**
Junhoedf3d822022-11-24 09:26:37 +00002470 * Inform this Connection that the audio endpoint has been changed.
2471 *
2472 * @param endpoint The new call endpoint.
2473 * @hide
2474 */
2475 final void setCallEndpoint(CallEndpoint endpoint) {
2476 checkImmutable();
2477 Log.d(this, "setCallEndpoint %s", endpoint);
2478 mCallEndpoint = endpoint;
2479 onCallEndpointChanged(endpoint);
2480 }
2481
2482 /**
2483 * Inform this Connection that the available call endpoints have been changed.
2484 *
2485 * @param availableEndpoints The available call endpoints.
2486 * @hide
2487 */
2488 final void setAvailableCallEndpoints(List<CallEndpoint> availableEndpoints) {
2489 checkImmutable();
2490 Log.d(this, "setAvailableCallEndpoints");
2491 onAvailableCallEndpointsChanged(availableEndpoints);
2492 }
2493
2494 /**
2495 * Inform this Connection that its audio mute state has been changed.
2496 *
2497 * @param isMuted The new mute state.
2498 * @hide
2499 */
2500 final void setMuteState(boolean isMuted) {
2501 checkImmutable();
2502 Log.d(this, "setMuteState %s", isMuted);
2503 onMuteStateChanged(isMuted);
2504 }
2505
2506 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002507 * @param state An integer value of a {@code STATE_*} constant.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002508 * @return A string representation of the value.
2509 */
2510 public static String stateToString(int state) {
2511 switch (state) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002512 case STATE_INITIALIZING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002513 return "INITIALIZING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002514 case STATE_NEW:
Yorke Leee911c8d2015-07-14 11:39:36 -07002515 return "NEW";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002516 case STATE_RINGING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002517 return "RINGING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002518 case STATE_DIALING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002519 return "DIALING";
Tyler Gunnc96b5e02016-07-07 22:53:57 -07002520 case STATE_PULLING_CALL:
2521 return "PULLING_CALL";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002522 case STATE_ACTIVE:
Yorke Leee911c8d2015-07-14 11:39:36 -07002523 return "ACTIVE";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002524 case STATE_HOLDING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002525 return "HOLDING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002526 case STATE_DISCONNECTED:
Ihab Awad542e0ea2014-05-16 10:22:16 -07002527 return "DISCONNECTED";
2528 default:
Ihab Awad60ac30b2014-05-20 22:32:12 -07002529 Log.wtf(Connection.class, "Unknown state %d", state);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002530 return "UNKNOWN";
2531 }
2532 }
2533
2534 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002535 * Returns the connection's capabilities, as a bit mask of the {@code CAPABILITY_*} constants.
Ihab Awad52a28f62014-06-18 10:26:34 -07002536 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002537 public final int getConnectionCapabilities() {
2538 return mConnectionCapabilities;
Ihab Awad52a28f62014-06-18 10:26:34 -07002539 }
2540
2541 /**
Tyler Gunn720c6642016-03-22 09:02:47 -07002542 * Returns the connection's properties, as a bit mask of the {@code PROPERTY_*} constants.
2543 */
2544 public final int getConnectionProperties() {
2545 return mConnectionProperties;
2546 }
2547
2548 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002549 * Returns the connection's supported audio routes.
2550 *
2551 * @hide
2552 */
2553 public final int getSupportedAudioRoutes() {
2554 return mSupportedAudioRoutes;
2555 }
2556
2557 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002558 * Sets the value of the {@link #getAddress()} property.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002559 *
Andrew Lee100e2932014-09-08 15:34:24 -07002560 * @param address The new address.
2561 * @param presentation The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002562 * See {@link TelecomManager} for valid values.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002563 */
Andrew Lee100e2932014-09-08 15:34:24 -07002564 public final void setAddress(Uri address, int presentation) {
2565 Log.d(this, "setAddress %s", address);
2566 mAddress = address;
2567 mAddressPresentation = presentation;
Santos Cordond34e5712014-08-05 18:54:03 +00002568 for (Listener l : mListeners) {
Andrew Lee100e2932014-09-08 15:34:24 -07002569 l.onAddressChanged(this, address, presentation);
Santos Cordond34e5712014-08-05 18:54:03 +00002570 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002571 }
2572
2573 /**
Sailesh Nepal61203862014-07-11 14:50:13 -07002574 * Sets the caller display name (CNAP).
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002575 *
Sailesh Nepal61203862014-07-11 14:50:13 -07002576 * @param callerDisplayName The new display name.
Nancy Chen9d568c02014-09-08 14:17:59 -07002577 * @param presentation The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002578 * See {@link TelecomManager} for valid values.
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002579 */
Sailesh Nepal61203862014-07-11 14:50:13 -07002580 public final void setCallerDisplayName(String callerDisplayName, int presentation) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002581 checkImmutable();
Edgar Arriaga2db19d22022-10-14 14:25:14 -07002582 boolean nameChanged = !Objects.equals(mCallerDisplayName, callerDisplayName);
2583 boolean presentationChanged = mCallerDisplayNamePresentation != presentation;
2584 if (nameChanged) {
2585 // Ensure the new name is not clobbering the old one with a null value due to the caller
2586 // wanting to only set the presentation and not knowing the display name.
2587 mCallerDisplayName = callerDisplayName;
2588 }
2589 if (presentationChanged) {
2590 mCallerDisplayNamePresentation = presentation;
2591 }
2592 if (nameChanged || presentationChanged) {
2593 for (Listener l : mListeners) {
2594 l.onCallerDisplayNameChanged(this, mCallerDisplayName,
2595 mCallerDisplayNamePresentation);
2596 }
Santos Cordond34e5712014-08-05 18:54:03 +00002597 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002598 }
2599
2600 /**
Tyler Gunnaa07df82014-07-17 07:50:22 -07002601 * Set the video state for the connection.
Yorke Lee32f24732015-05-12 16:18:03 -07002602 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
2603 * {@link VideoProfile#STATE_BIDIRECTIONAL},
2604 * {@link VideoProfile#STATE_TX_ENABLED},
2605 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002606 *
2607 * @param videoState The new video state.
2608 */
2609 public final void setVideoState(int videoState) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002610 checkImmutable();
Tyler Gunnaa07df82014-07-17 07:50:22 -07002611 Log.d(this, "setVideoState %d", videoState);
Santos Cordond34e5712014-08-05 18:54:03 +00002612 mVideoState = videoState;
2613 for (Listener l : mListeners) {
2614 l.onVideoStateChanged(this, mVideoState);
2615 }
Tyler Gunnaa07df82014-07-17 07:50:22 -07002616 }
2617
2618 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002619 * Sets state to active (e.g., an ongoing connection where two or more parties can actively
Ihab Awad542e0ea2014-05-16 10:22:16 -07002620 * communicate).
2621 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002622 public final void setActive() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002623 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002624 setRingbackRequested(false);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002625 setState(STATE_ACTIVE);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002626 }
2627
2628 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002629 * Sets state to ringing (e.g., an inbound ringing connection).
Ihab Awad542e0ea2014-05-16 10:22:16 -07002630 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002631 public final void setRinging() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002632 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002633 setState(STATE_RINGING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002634 }
2635
2636 /**
Evan Charltonbf11f982014-07-20 22:06:28 -07002637 * Sets state to initializing (this Connection is not yet ready to be used).
2638 */
2639 public final void setInitializing() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002640 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002641 setState(STATE_INITIALIZING);
Evan Charltonbf11f982014-07-20 22:06:28 -07002642 }
2643
2644 /**
2645 * Sets state to initialized (the Connection has been set up and is now ready to be used).
2646 */
2647 public final void setInitialized() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002648 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002649 setState(STATE_NEW);
Evan Charltonbf11f982014-07-20 22:06:28 -07002650 }
2651
2652 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002653 * Sets state to dialing (e.g., dialing an outbound connection).
Ihab Awad542e0ea2014-05-16 10:22:16 -07002654 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002655 public final void setDialing() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002656 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002657 setState(STATE_DIALING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002658 }
2659
2660 /**
Tyler Gunnc242ceb2016-06-29 22:35:45 -07002661 * Sets state to pulling (e.g. the connection is being pulled to the local device from another
2662 * device). Only applicable for {@link Connection}s with
2663 * {@link Connection#PROPERTY_IS_EXTERNAL_CALL} and {@link Connection#CAPABILITY_CAN_PULL_CALL}.
2664 */
2665 public final void setPulling() {
2666 checkImmutable();
2667 setState(STATE_PULLING_CALL);
2668 }
2669
2670 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002671 * Sets state to be on hold.
2672 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002673 public final void setOnHold() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002674 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002675 setState(STATE_HOLDING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002676 }
2677
2678 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002679 * Sets the video connection provider.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002680 * @param videoProvider The video provider.
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002681 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002682 public final void setVideoProvider(VideoProvider videoProvider) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002683 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002684 mVideoProvider = videoProvider;
Santos Cordond34e5712014-08-05 18:54:03 +00002685 for (Listener l : mListeners) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002686 l.onVideoProviderChanged(this, videoProvider);
Santos Cordond34e5712014-08-05 18:54:03 +00002687 }
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002688 }
2689
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002690 public final VideoProvider getVideoProvider() {
2691 return mVideoProvider;
Andrew Leea27a1932014-07-09 17:07:13 -07002692 }
2693
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002694 /**
Sailesh Nepal091768c2014-06-30 15:15:23 -07002695 * Sets state to disconnected.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002696 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002697 * @param disconnectCause The reason for the disconnection, as specified by
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002698 * {@link DisconnectCause}.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002699 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002700 public final void setDisconnected(DisconnectCause disconnectCause) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002701 checkImmutable();
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002702 mDisconnectCause = disconnectCause;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002703 setState(STATE_DISCONNECTED);
mike dooleyf34519b2014-09-16 17:33:40 -07002704 Log.d(this, "Disconnected with cause %s", disconnectCause);
Santos Cordond34e5712014-08-05 18:54:03 +00002705 for (Listener l : mListeners) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002706 l.onDisconnected(this, disconnectCause);
Santos Cordond34e5712014-08-05 18:54:03 +00002707 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002708 }
2709
2710 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002711 * Informs listeners that this {@code Connection} is in a post-dial wait state. This is done
2712 * when (a) the {@code Connection} is issuing a DTMF sequence; (b) it has encountered a "wait"
2713 * character; and (c) it wishes to inform the In-Call app that it is waiting for the end-user
2714 * to send an {@link #onPostDialContinue(boolean)} signal.
2715 *
2716 * @param remaining The DTMF character sequence remaining to be emitted once the
2717 * {@link #onPostDialContinue(boolean)} is received, including any "wait" characters
2718 * that remaining sequence may contain.
Sailesh Nepal091768c2014-06-30 15:15:23 -07002719 */
2720 public final void setPostDialWait(String remaining) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002721 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002722 for (Listener l : mListeners) {
2723 l.onPostDialWait(this, remaining);
2724 }
Sailesh Nepal091768c2014-06-30 15:15:23 -07002725 }
2726
2727 /**
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002728 * Informs listeners that this {@code Connection} has processed a character in the post-dial
2729 * started state. This is done when (a) the {@code Connection} is issuing a DTMF sequence;
Sailesh Nepal1ed85612015-01-31 15:17:19 -08002730 * and (b) it wishes to signal Telecom to play the corresponding DTMF tone locally.
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002731 *
2732 * @param nextChar The DTMF character that was just processed by the {@code Connection}.
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002733 */
Sailesh Nepal1ed85612015-01-31 15:17:19 -08002734 public final void setNextPostDialChar(char nextChar) {
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002735 checkImmutable();
2736 for (Listener l : mListeners) {
2737 l.onPostDialChar(this, nextChar);
2738 }
2739 }
2740
2741 /**
Ihab Awadf8358972014-05-28 16:46:42 -07002742 * Requests that the framework play a ringback tone. This is to be invoked by implementations
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002743 * that do not play a ringback tone themselves in the connection's audio stream.
Ihab Awadf8358972014-05-28 16:46:42 -07002744 *
2745 * @param ringback Whether the ringback tone is to be played.
2746 */
Andrew Lee100e2932014-09-08 15:34:24 -07002747 public final void setRingbackRequested(boolean ringback) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002748 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002749 if (mRingbackRequested != ringback) {
2750 mRingbackRequested = ringback;
Santos Cordond34e5712014-08-05 18:54:03 +00002751 for (Listener l : mListeners) {
Andrew Lee100e2932014-09-08 15:34:24 -07002752 l.onRingbackRequested(this, ringback);
Santos Cordond34e5712014-08-05 18:54:03 +00002753 }
2754 }
Ihab Awadf8358972014-05-28 16:46:42 -07002755 }
2756
2757 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002758 * Sets the connection's capabilities as a bit mask of the {@code CAPABILITY_*} constants.
Sailesh Nepal1a7061b2014-07-09 21:03:20 -07002759 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002760 * @param connectionCapabilities The new connection capabilities.
Santos Cordonb6939982014-06-04 20:20:58 -07002761 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002762 public final void setConnectionCapabilities(int connectionCapabilities) {
2763 checkImmutable();
2764 if (mConnectionCapabilities != connectionCapabilities) {
2765 mConnectionCapabilities = connectionCapabilities;
Santos Cordond34e5712014-08-05 18:54:03 +00002766 for (Listener l : mListeners) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002767 l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities);
Santos Cordond34e5712014-08-05 18:54:03 +00002768 }
2769 }
Santos Cordonb6939982014-06-04 20:20:58 -07002770 }
2771
2772 /**
Tyler Gunn720c6642016-03-22 09:02:47 -07002773 * Sets the connection's properties as a bit mask of the {@code PROPERTY_*} constants.
2774 *
2775 * @param connectionProperties The new connection properties.
2776 */
2777 public final void setConnectionProperties(int connectionProperties) {
2778 checkImmutable();
2779 if (mConnectionProperties != connectionProperties) {
2780 mConnectionProperties = connectionProperties;
2781 for (Listener l : mListeners) {
2782 l.onConnectionPropertiesChanged(this, mConnectionProperties);
2783 }
2784 }
2785 }
2786
2787 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002788 * Sets the supported audio routes.
2789 *
2790 * @param supportedAudioRoutes the supported audio routes as a bitmask.
2791 * See {@link CallAudioState}
2792 * @hide
2793 */
2794 public final void setSupportedAudioRoutes(int supportedAudioRoutes) {
2795 if ((supportedAudioRoutes
2796 & (CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_SPEAKER)) == 0) {
2797 throw new IllegalArgumentException(
2798 "supported audio routes must include either speaker or earpiece");
2799 }
2800
2801 if (mSupportedAudioRoutes != supportedAudioRoutes) {
2802 mSupportedAudioRoutes = supportedAudioRoutes;
2803 for (Listener l : mListeners) {
2804 l.onSupportedAudioRoutesChanged(this, mSupportedAudioRoutes);
2805 }
2806 }
2807 }
2808
2809 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002810 * Tears down the Connection object.
Santos Cordonb6939982014-06-04 20:20:58 -07002811 */
Evan Charlton36a71342014-07-19 16:31:02 -07002812 public final void destroy() {
Jay Shrauner229e3822014-08-15 09:23:07 -07002813 for (Listener l : mListeners) {
2814 l.onDestroyed(this);
Santos Cordond34e5712014-08-05 18:54:03 +00002815 }
Santos Cordonb6939982014-06-04 20:20:58 -07002816 }
2817
2818 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002819 * Requests that the framework use VOIP audio mode for this connection.
2820 *
2821 * @param isVoip True if the audio mode is VOIP.
2822 */
2823 public final void setAudioModeIsVoip(boolean isVoip) {
Thomas Stuartb83cc192022-07-06 10:59:41 -07002824 if (!isVoip && (mConnectionProperties & PROPERTY_SELF_MANAGED) == PROPERTY_SELF_MANAGED) {
2825 Log.i(this,
2826 "setAudioModeIsVoip: Ignored request to set a self-managed connection's"
2827 + " audioModeIsVoip to false. Doing so can cause unwanted behavior.");
2828 return;
2829 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002830 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002831 mAudioModeIsVoip = isVoip;
2832 for (Listener l : mListeners) {
2833 l.onAudioModeIsVoipChanged(this, isVoip);
2834 }
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002835 }
2836
2837 /**
Roshan Piuse927ec02015-07-15 15:47:21 -07002838 * Sets the time at which a call became active on this Connection. This is set only
2839 * when a conference call becomes active on this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002840 * <p>
Tyler Gunnc9503d62020-01-27 10:30:51 -08002841 * This time corresponds to the date/time of connection and is stored in the call log in
2842 * {@link android.provider.CallLog.Calls#DATE}.
2843 * <p>
Tyler Gunnc63f9082019-10-15 13:19:26 -07002844 * Used by telephony to maintain calls associated with an IMS Conference.
Roshan Piuse927ec02015-07-15 15:47:21 -07002845 *
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002846 * @param connectTimeMillis The connection time, in milliseconds. Should be set using a value
2847 * obtained from {@link System#currentTimeMillis()}.
Roshan Piuse927ec02015-07-15 15:47:21 -07002848 *
2849 * @hide
2850 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002851 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002852 @RequiresPermission(MODIFY_PHONE_STATE)
2853 public final void setConnectTimeMillis(@IntRange(from = 0) long connectTimeMillis) {
Roshan Piuse927ec02015-07-15 15:47:21 -07002854 mConnectTimeMillis = connectTimeMillis;
2855 }
2856
2857 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002858 * Sets the time at which a call became active on this Connection. This is set only
2859 * when a conference call becomes active on this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002860 * <p>
Tyler Gunnc9503d62020-01-27 10:30:51 -08002861 * This time is used to establish the duration of a call. It uses
2862 * {@link SystemClock#elapsedRealtime()} to ensure that the call duration is not impacted by
2863 * time zone changes during a call. The difference between the current
2864 * {@link SystemClock#elapsedRealtime()} and the value set at the connection start time is used
2865 * to populate {@link android.provider.CallLog.Calls#DURATION} in the call log.
2866 * <p>
Tyler Gunnc63f9082019-10-15 13:19:26 -07002867 * Used by telephony to maintain calls associated with an IMS Conference.
Tyler Gunnc9503d62020-01-27 10:30:51 -08002868 *
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002869 * @param connectElapsedTimeMillis The connection time, in milliseconds. Stored in the format
2870 * {@link SystemClock#elapsedRealtime()}.
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002871 * @hide
2872 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002873 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002874 @RequiresPermission(MODIFY_PHONE_STATE)
2875 public final void setConnectionStartElapsedRealtimeMillis(
2876 @ElapsedRealtimeLong long connectElapsedTimeMillis) {
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002877 mConnectElapsedTimeMillis = connectElapsedTimeMillis;
2878 }
2879
2880 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002881 * Sets the label and icon status to display in the in-call UI.
2882 *
2883 * @param statusHints The status label and icon to set.
2884 */
2885 public final void setStatusHints(StatusHints statusHints) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002886 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002887 mStatusHints = statusHints;
2888 for (Listener l : mListeners) {
2889 l.onStatusHintsChanged(this, statusHints);
2890 }
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002891 }
2892
2893 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002894 * Sets the connections with which this connection can be conferenced.
2895 *
2896 * @param conferenceableConnections The set of connections this connection can conference with.
2897 */
2898 public final void setConferenceableConnections(List<Connection> conferenceableConnections) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002899 checkImmutable();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002900 clearConferenceableList();
2901 for (Connection c : conferenceableConnections) {
2902 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
2903 // small amount of items here.
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002904 if (!mConferenceables.contains(c)) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002905 c.addConnectionListener(mConnectionDeathListener);
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002906 mConferenceables.add(c);
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002907 }
2908 }
2909 fireOnConferenceableConnectionsChanged();
2910 }
2911
2912 /**
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002913 * Similar to {@link #setConferenceableConnections(java.util.List)}, sets a list of connections
2914 * or conferences with which this connection can be conferenced.
2915 *
2916 * @param conferenceables The conferenceables.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002917 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002918 public final void setConferenceables(List<Conferenceable> conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002919 clearConferenceableList();
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002920 for (Conferenceable c : conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002921 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
2922 // small amount of items here.
2923 if (!mConferenceables.contains(c)) {
2924 if (c instanceof Connection) {
2925 Connection connection = (Connection) c;
2926 connection.addConnectionListener(mConnectionDeathListener);
2927 } else if (c instanceof Conference) {
2928 Conference conference = (Conference) c;
2929 conference.addListener(mConferenceDeathListener);
2930 }
2931 mConferenceables.add(c);
2932 }
2933 }
2934 fireOnConferenceableConnectionsChanged();
2935 }
2936
2937 /**
Tyler Gunnc63f9082019-10-15 13:19:26 -07002938 * Resets the CDMA connection time.
2939 * <p>
2940 * This is an implementation detail specific to legacy CDMA calls on mobile networks.
Mengjun Leng25707742017-07-04 11:10:37 +08002941 * @hide
Mengjun Leng25707742017-07-04 11:10:37 +08002942 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002943 @SystemApi
Mengjun Leng25707742017-07-04 11:10:37 +08002944 public final void resetConnectionTime() {
2945 for (Listener l : mListeners) {
2946 l.onConnectionTimeReset(this);
2947 }
2948 }
2949
2950 /**
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002951 * Returns the connections or conferences with which this connection can be conferenced.
2952 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002953 public final List<Conferenceable> getConferenceables() {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002954 return mUnmodifiableConferenceables;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002955 }
2956
Yorke Lee53463962015-08-04 16:07:19 -07002957 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002958 * @hide
2959 */
2960 public final void setConnectionService(ConnectionService connectionService) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002961 checkImmutable();
Santos Cordon823fd3c2014-08-07 18:35:18 -07002962 if (mConnectionService != null) {
2963 Log.e(this, new Exception(), "Trying to set ConnectionService on a connection " +
2964 "which is already associated with another ConnectionService.");
2965 } else {
2966 mConnectionService = connectionService;
2967 }
2968 }
2969
2970 /**
2971 * @hide
2972 */
2973 public final void unsetConnectionService(ConnectionService connectionService) {
2974 if (mConnectionService != connectionService) {
2975 Log.e(this, new Exception(), "Trying to remove ConnectionService from a Connection " +
2976 "that does not belong to the ConnectionService.");
2977 } else {
2978 mConnectionService = null;
2979 }
2980 }
2981
2982 /**
2983 * Sets the conference that this connection is a part of. This will fail if the connection is
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002984 * already part of a conference. {@link #resetConference} to un-set the conference first.
Santos Cordon823fd3c2014-08-07 18:35:18 -07002985 *
2986 * @param conference The conference.
2987 * @return {@code true} if the conference was successfully set.
2988 * @hide
2989 */
2990 public final boolean setConference(Conference conference) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002991 checkImmutable();
Santos Cordon823fd3c2014-08-07 18:35:18 -07002992 // We check to see if it is already part of another conference.
Santos Cordon0159ac02014-08-21 14:28:11 -07002993 if (mConference == null) {
Santos Cordon823fd3c2014-08-07 18:35:18 -07002994 mConference = conference;
Santos Cordon0159ac02014-08-21 14:28:11 -07002995 if (mConnectionService != null && mConnectionService.containsConference(conference)) {
2996 fireConferenceChanged();
2997 }
Santos Cordon823fd3c2014-08-07 18:35:18 -07002998 return true;
2999 }
3000 return false;
3001 }
3002
3003 /**
3004 * Resets the conference that this connection is a part of.
3005 * @hide
3006 */
3007 public final void resetConference() {
3008 if (mConference != null) {
Santos Cordon0159ac02014-08-21 14:28:11 -07003009 Log.d(this, "Conference reset");
Santos Cordon823fd3c2014-08-07 18:35:18 -07003010 mConference = null;
3011 fireConferenceChanged();
3012 }
3013 }
3014
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003015 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07003016 * Set some extras that can be associated with this {@code Connection}.
3017 * <p>
3018 * New or existing keys are replaced in the {@code Connection} extras. Keys which are no longer
3019 * in the new extras, but were present the last time {@code setExtras} was called are removed.
3020 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003021 * Alternatively you may use the {@link #putExtras(Bundle)}, and
3022 * {@link #removeExtras(String...)} methods to modify the extras.
3023 * <p>
Tyler Gunndee56a82016-03-23 16:06:34 -07003024 * 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 -07003025 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
3026 *
3027 * @param extras The extras associated with this {@code Connection}.
3028 */
3029 public final void setExtras(@Nullable Bundle extras) {
3030 checkImmutable();
Tyler Gunndee56a82016-03-23 16:06:34 -07003031
3032 // Add/replace any new or changed extras values.
3033 putExtras(extras);
3034
3035 // If we have used "setExtras" in the past, compare the key set from the last invocation to
3036 // the current one and remove any keys that went away.
3037 if (mPreviousExtraKeys != null) {
3038 List<String> toRemove = new ArrayList<String>();
3039 for (String oldKey : mPreviousExtraKeys) {
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07003040 if (extras == null || !extras.containsKey(oldKey)) {
Tyler Gunndee56a82016-03-23 16:06:34 -07003041 toRemove.add(oldKey);
3042 }
3043 }
3044 if (!toRemove.isEmpty()) {
3045 removeExtras(toRemove);
3046 }
3047 }
3048
3049 // Track the keys the last time set called setExtras. This way, the next time setExtras is
3050 // called we can see if the caller has removed any extras values.
3051 if (mPreviousExtraKeys == null) {
3052 mPreviousExtraKeys = new ArraySet<String>();
3053 }
3054 mPreviousExtraKeys.clear();
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07003055 if (extras != null) {
3056 mPreviousExtraKeys.addAll(extras.keySet());
3057 }
Tyler Gunndee56a82016-03-23 16:06:34 -07003058 }
3059
3060 /**
3061 * Adds some extras to this {@code Connection}. Existing keys are replaced and new ones are
3062 * added.
3063 * <p>
3064 * No assumptions should be made as to how an In-Call UI or service will handle these extras.
3065 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
3066 *
3067 * @param extras The extras to add.
3068 */
3069 public final void putExtras(@NonNull Bundle extras) {
3070 checkImmutable();
3071 if (extras == null) {
3072 return;
3073 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003074 // Creating a duplicate bundle so we don't have to synchronize on mExtrasLock while calling
3075 // the listeners.
3076 Bundle listenerExtras;
3077 synchronized (mExtrasLock) {
3078 if (mExtras == null) {
3079 mExtras = new Bundle();
3080 }
3081 mExtras.putAll(extras);
3082 listenerExtras = new Bundle(mExtras);
Tyler Gunndee56a82016-03-23 16:06:34 -07003083 }
Santos Cordon6b7f9552015-05-27 17:21:45 -07003084 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003085 // Create a new clone of the extras for each listener so that they don't clobber
3086 // each other
3087 l.onExtrasChanged(this, new Bundle(listenerExtras));
Santos Cordon6b7f9552015-05-27 17:21:45 -07003088 }
3089 }
3090
3091 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -07003092 * Removes extras from this {@code Connection}.
Tyler Gunndee56a82016-03-23 16:06:34 -07003093 *
Tyler Gunn071be6f2016-05-10 14:52:33 -07003094 * @param keys The keys of the extras to remove.
Tyler Gunndee56a82016-03-23 16:06:34 -07003095 */
3096 public final void removeExtras(List<String> keys) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003097 synchronized (mExtrasLock) {
3098 if (mExtras != null) {
3099 for (String key : keys) {
3100 mExtras.remove(key);
3101 }
Tyler Gunndee56a82016-03-23 16:06:34 -07003102 }
3103 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003104 List<String> unmodifiableKeys = Collections.unmodifiableList(keys);
Tyler Gunndee56a82016-03-23 16:06:34 -07003105 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003106 l.onExtrasRemoved(this, unmodifiableKeys);
Tyler Gunndee56a82016-03-23 16:06:34 -07003107 }
3108 }
3109
3110 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -07003111 * Removes extras from this {@code Connection}.
3112 *
3113 * @param keys The keys of the extras to remove.
3114 */
3115 public final void removeExtras(String ... keys) {
3116 removeExtras(Arrays.asList(keys));
3117 }
3118
3119 /**
Tyler Gunnf5035432017-01-09 09:43:12 -08003120 * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will
3121 * be change to the {@link #getCallAudioState()}.
3122 * <p>
3123 * Used by self-managed {@link ConnectionService}s which wish to change the audio route for a
3124 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
3125 * <p>
3126 * See also {@link InCallService#setAudioRoute(int)}.
3127 *
3128 * @param route The audio route to use (one of {@link CallAudioState#ROUTE_BLUETOOTH},
3129 * {@link CallAudioState#ROUTE_EARPIECE}, {@link CallAudioState#ROUTE_SPEAKER}, or
3130 * {@link CallAudioState#ROUTE_WIRED_HEADSET}).
Junhoedf3d822022-11-24 09:26:37 +00003131 * @deprecated Use {@link #requestCallEndpointChange(CallEndpoint, Executor, OutcomeReceiver)}
3132 * instead.
Tyler Gunnf5035432017-01-09 09:43:12 -08003133 */
Junhoedf3d822022-11-24 09:26:37 +00003134 @Deprecated
Tyler Gunnf5035432017-01-09 09:43:12 -08003135 public final void setAudioRoute(int route) {
3136 for (Listener l : mListeners) {
Hall Liua98f58b52017-11-07 17:59:28 -08003137 l.onAudioRouteChanged(this, route, null);
3138 }
3139 }
3140
3141 /**
Hall Liua98f58b52017-11-07 17:59:28 -08003142 * Request audio routing to a specific bluetooth device. Calling this method may result in
3143 * the device routing audio to a different bluetooth device than the one specified if the
3144 * bluetooth stack is unable to route audio to the requested device.
3145 * A list of available devices can be obtained via
3146 * {@link CallAudioState#getSupportedBluetoothDevices()}
3147 *
3148 * <p>
3149 * Used by self-managed {@link ConnectionService}s which wish to use bluetooth audio for a
3150 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
3151 * <p>
Hall Liu2b6a6a32018-04-02 13:52:57 -07003152 * See also {@link InCallService#requestBluetoothAudio(BluetoothDevice)}
3153 * @param bluetoothDevice The bluetooth device to connect to.
Junhoedf3d822022-11-24 09:26:37 +00003154 * @deprecated Use {@link #requestCallEndpointChange(CallEndpoint, Executor, OutcomeReceiver)}
3155 * instead.
Hall Liua98f58b52017-11-07 17:59:28 -08003156 */
Junhoedf3d822022-11-24 09:26:37 +00003157 @Deprecated
Hall Liu2b6a6a32018-04-02 13:52:57 -07003158 public void requestBluetoothAudio(@NonNull BluetoothDevice bluetoothDevice) {
Hall Liua98f58b52017-11-07 17:59:28 -08003159 for (Listener l : mListeners) {
Hall Liu2b6a6a32018-04-02 13:52:57 -07003160 l.onAudioRouteChanged(this, CallAudioState.ROUTE_BLUETOOTH,
3161 bluetoothDevice.getAddress());
Tyler Gunnf5035432017-01-09 09:43:12 -08003162 }
3163 }
3164
3165 /**
Junhoedf3d822022-11-24 09:26:37 +00003166 * Request audio routing to a specific CallEndpoint. Clients should not define their own
3167 * CallEndpoint when requesting a change. Instead, the new endpoint should be one of the valid
3168 * endpoints provided by {@link #onAvailableCallEndpointsChanged(List)}.
3169 * When this request is honored, there will be change to the {@link #getCurrentCallEndpoint()}.
3170 * <p>
3171 * Used by self-managed {@link ConnectionService}s which wish to change the CallEndpoint for a
3172 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
3173 * <p>
3174 * See also
3175 * {@link InCallService#requestCallEndpointChange(CallEndpoint, Executor, OutcomeReceiver)}.
3176 *
3177 * @param endpoint The call endpoint to use.
3178 * @param executor The executor of where the callback will execute.
3179 * @param callback The callback to notify the result of the endpoint change.
3180 */
3181 public final void requestCallEndpointChange(@NonNull CallEndpoint endpoint,
3182 @NonNull @CallbackExecutor Executor executor,
3183 @NonNull OutcomeReceiver<Void, CallEndpointException> callback) {
3184 for (Listener l : mListeners) {
3185 l.onEndpointChanged(this, endpoint, executor, callback);
3186 }
3187 }
3188
3189 /**
3190 * Obtains the current CallEndpoint.
3191 *
3192 * @return An object encapsulating the CallEndpoint.
3193 */
3194 @NonNull
3195 public final CallEndpoint getCurrentCallEndpoint() {
3196 return mCallEndpoint;
3197 }
3198
3199 /**
Hall Liub64ac4c2017-02-06 10:49:48 -08003200 * Informs listeners that a previously requested RTT session via
3201 * {@link ConnectionRequest#isRequestingRtt()} or
Hall Liu37dfdb02017-12-04 14:19:30 -08003202 * {@link #onStartRtt(RttTextStream)} has succeeded.
Hall Liub64ac4c2017-02-06 10:49:48 -08003203 */
3204 public final void sendRttInitiationSuccess() {
3205 mListeners.forEach((l) -> l.onRttInitiationSuccess(Connection.this));
3206 }
3207
3208 /**
3209 * Informs listeners that a previously requested RTT session via
Hall Liu37dfdb02017-12-04 14:19:30 -08003210 * {@link ConnectionRequest#isRequestingRtt()} or {@link #onStartRtt(RttTextStream)}
Hall Liub64ac4c2017-02-06 10:49:48 -08003211 * has failed.
3212 * @param reason One of the reason codes defined in {@link RttModifyStatus}, with the
3213 * exception of {@link RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}.
Hall Liub64ac4c2017-02-06 10:49:48 -08003214 */
3215 public final void sendRttInitiationFailure(int reason) {
3216 mListeners.forEach((l) -> l.onRttInitiationFailure(Connection.this, reason));
3217 }
3218
3219 /**
3220 * Informs listeners that a currently active RTT session has been terminated by the remote
3221 * side of the coll.
Hall Liub64ac4c2017-02-06 10:49:48 -08003222 */
3223 public final void sendRttSessionRemotelyTerminated() {
3224 mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this));
3225 }
3226
3227 /**
3228 * Informs listeners that the remote side of the call has requested an upgrade to include an
3229 * RTT session in the call.
Hall Liub64ac4c2017-02-06 10:49:48 -08003230 */
3231 public final void sendRemoteRttRequest() {
3232 mListeners.forEach((l) -> l.onRemoteRttRequest(Connection.this));
3233 }
3234
3235 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003236 * Notifies this Connection that the {@link #getAudioState()} property has a new value.
Sailesh Nepal400cc482014-06-26 12:04:00 -07003237 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003238 * @param state The new connection audio state.
Yorke Lee4af59352015-05-13 14:14:54 -07003239 * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead.
3240 * @hide
Sailesh Nepal400cc482014-06-26 12:04:00 -07003241 */
Yorke Lee4af59352015-05-13 14:14:54 -07003242 @SystemApi
3243 @Deprecated
Nancy Chen354b2bd2014-09-08 18:27:26 -07003244 public void onAudioStateChanged(AudioState state) {}
Sailesh Nepal400cc482014-06-26 12:04:00 -07003245
3246 /**
Yorke Lee4af59352015-05-13 14:14:54 -07003247 * Notifies this Connection that the {@link #getCallAudioState()} property has a new value.
3248 *
3249 * @param state The new connection audio state.
Junhoedf3d822022-11-24 09:26:37 +00003250 * @deprecated Use {@link #onCallEndpointChanged(CallEndpoint)},
3251 * {@link #onAvailableCallEndpointsChanged(List)} and
3252 * {@link #onMuteStateChanged(boolean)} instead.
Yorke Lee4af59352015-05-13 14:14:54 -07003253 */
Junhoedf3d822022-11-24 09:26:37 +00003254 @Deprecated
Yorke Lee4af59352015-05-13 14:14:54 -07003255 public void onCallAudioStateChanged(CallAudioState state) {}
3256
3257 /**
Junhoedf3d822022-11-24 09:26:37 +00003258 * Notifies this Connection that the audio endpoint has been changed.
3259 *
3260 * @param callEndpoint The current CallEndpoint.
3261 */
3262 public void onCallEndpointChanged(@NonNull CallEndpoint callEndpoint) {}
3263
3264 /**
3265 * Notifies this Connection that the available call endpoints have been changed.
3266 *
3267 * @param availableEndpoints The set of available CallEndpoint.
3268 */
3269 public void onAvailableCallEndpointsChanged(@NonNull List<CallEndpoint> availableEndpoints) {}
3270
3271 /**
3272 * Notifies this Connection that its audio mute state has been changed.
3273 *
3274 * @param isMuted The current mute state.
3275 */
3276 public void onMuteStateChanged(boolean isMuted) {}
3277
3278 /**
Grace Jiae99fde92021-01-19 14:58:01 -08003279 * Inform this Connection when it will or will not be tracked by an {@link InCallService} which
3280 * can provide an InCall UI.
3281 * This is primarily intended for use by Connections reported by self-managed
3282 * {@link ConnectionService} which typically maintain their own UI.
3283 *
3284 * @param isUsingAlternativeUi Indicates whether an InCallService that can provide InCall UI is
3285 * currently tracking the self-managed call.
3286 */
3287 public void onUsingAlternativeUi(boolean isUsingAlternativeUi) {}
3288
3289 /**
3290 * Inform this Conenection when it will or will not be tracked by an non-UI
3291 * {@link InCallService}.
3292 *
3293 * @param isTracked Indicates whether an non-UI InCallService is currently tracking the
3294 * self-managed call.
3295 */
3296 public void onTrackedByNonUiService(boolean isTracked) {}
3297
3298 /**
Evan Charltonbf11f982014-07-20 22:06:28 -07003299 * Notifies this Connection of an internal state change. This method is called after the
3300 * state is changed.
Ihab Awadf8358972014-05-28 16:46:42 -07003301 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003302 * @param state The new state, one of the {@code STATE_*} constants.
Ihab Awadf8358972014-05-28 16:46:42 -07003303 */
Nancy Chen354b2bd2014-09-08 18:27:26 -07003304 public void onStateChanged(int state) {}
Ihab Awadf8358972014-05-28 16:46:42 -07003305
3306 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07003307 * Notifies this Connection of a request to play a DTMF tone.
3308 *
3309 * @param c A DTMF character.
3310 */
Santos Cordonf2951102014-07-20 19:06:29 -07003311 public void onPlayDtmfTone(char c) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003312
3313 /**
3314 * Notifies this Connection of a request to stop any currently playing DTMF tones.
3315 */
Santos Cordonf2951102014-07-20 19:06:29 -07003316 public void onStopDtmfTone() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003317
3318 /**
3319 * Notifies this Connection of a request to disconnect.
3320 */
Santos Cordonf2951102014-07-20 19:06:29 -07003321 public void onDisconnect() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003322
3323 /**
Tyler Gunn3b4b1dc2014-11-04 14:53:37 -08003324 * Notifies this Connection of a request to disconnect a participant of the conference managed
3325 * by the connection.
3326 *
3327 * @param endpoint the {@link Uri} of the participant to disconnect.
3328 * @hide
3329 */
3330 public void onDisconnectConferenceParticipant(Uri endpoint) {}
3331
3332 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003333 * Notifies this Connection of a request to separate from its parent conference.
Santos Cordonb6939982014-06-04 20:20:58 -07003334 */
Santos Cordonf2951102014-07-20 19:06:29 -07003335 public void onSeparate() {}
Santos Cordonb6939982014-06-04 20:20:58 -07003336
3337 /**
Tyler Gunn0c62ef02020-02-11 14:39:43 -08003338 * Supports initiation of a conference call by directly adding participants to an ongoing call.
Ravi Paluri404babb2020-01-23 19:02:44 +05303339 *
3340 * @param participants with which conference call will be formed.
3341 */
3342 public void onAddConferenceParticipants(@NonNull List<Uri> participants) {}
3343
3344 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07003345 * Notifies this Connection of a request to abort.
3346 */
Santos Cordonf2951102014-07-20 19:06:29 -07003347 public void onAbort() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003348
3349 /**
3350 * Notifies this Connection of a request to hold.
3351 */
Santos Cordonf2951102014-07-20 19:06:29 -07003352 public void onHold() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003353
3354 /**
3355 * Notifies this Connection of a request to exit a hold state.
3356 */
Santos Cordonf2951102014-07-20 19:06:29 -07003357 public void onUnhold() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003358
3359 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003360 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Santos Cordond34e5712014-08-05 18:54:03 +00003361 * a request to accept.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003362 * <p>
3363 * For managed {@link ConnectionService}s, this will be called when the user answers a call via
3364 * the default dialer's {@link InCallService}.
3365 * <p>
3366 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3367 * Telecom framework may request that the call is answered in the following circumstances:
3368 * <ul>
3369 * <li>The user chooses to answer an incoming call via a Bluetooth device.</li>
3370 * <li>A car mode {@link InCallService} is in use which has declared
3371 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3372 * {@link InCallService} will be able to see calls from self-managed
3373 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3374 * behalf.</li>
3375 * </ul>
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003376 * @param videoState The video state in which to answer the connection.
Ihab Awad542e0ea2014-05-16 10:22:16 -07003377 */
Santos Cordonf2951102014-07-20 19:06:29 -07003378 public void onAnswer(int videoState) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003379
3380 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003381 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Tyler Gunnbe74de02014-08-29 14:51:48 -07003382 * a request to accept.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003383 * <p>
3384 * For managed {@link ConnectionService}s, this will be called when the user answers a call via
3385 * the default dialer's {@link InCallService}.
3386 * <p>
3387 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3388 * Telecom framework may request that the call is answered in the following circumstances:
3389 * <ul>
3390 * <li>The user chooses to answer an incoming call via a Bluetooth device.</li>
3391 * <li>A car mode {@link InCallService} is in use which has declared
3392 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3393 * {@link InCallService} will be able to see calls from self-managed
3394 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3395 * behalf.</li>
3396 * </ul>
Tyler Gunnbe74de02014-08-29 14:51:48 -07003397 */
3398 public void onAnswer() {
Tyler Gunn87b73f32015-06-03 10:09:59 -07003399 onAnswer(VideoProfile.STATE_AUDIO_ONLY);
Tyler Gunnbe74de02014-08-29 14:51:48 -07003400 }
3401
3402 /**
3403 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Pooja Jaind34698d2017-12-28 14:15:31 +05303404 * a request to deflect.
3405 */
3406 public void onDeflect(Uri address) {}
3407
3408 /**
3409 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Santos Cordond34e5712014-08-05 18:54:03 +00003410 * a request to reject.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003411 * <p>
3412 * For managed {@link ConnectionService}s, this will be called when the user rejects a call via
3413 * the default dialer's {@link InCallService}.
3414 * <p>
3415 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3416 * Telecom framework may request that the call is rejected in the following circumstances:
3417 * <ul>
3418 * <li>The user chooses to reject an incoming call via a Bluetooth device.</li>
3419 * <li>A car mode {@link InCallService} is in use which has declared
3420 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3421 * {@link InCallService} will be able to see calls from self-managed
3422 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3423 * behalf.</li>
3424 * </ul>
Ihab Awad542e0ea2014-05-16 10:22:16 -07003425 */
Santos Cordonf2951102014-07-20 19:06:29 -07003426 public void onReject() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003427
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003428 /**
Tyler Gunnfacfdee2020-01-23 13:10:37 -08003429 * Notifies this Connection, which is in {@link #STATE_RINGING}, of a request to reject.
3430 * <p>
3431 * For managed {@link ConnectionService}s, this will be called when the user rejects a call via
3432 * the default dialer's {@link InCallService} using {@link Call#reject(int)}.
3433 * @param rejectReason the reason the user provided for rejecting the call.
3434 */
3435 public void onReject(@android.telecom.Call.RejectReason int rejectReason) {
3436 // to be implemented by ConnectionService.
3437 }
3438
3439 /**
Hall Liu712acbe2016-03-14 16:38:56 -07003440 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
3441 * a request to reject with a message.
Bryce Lee81901682015-08-28 16:38:02 -07003442 */
3443 public void onReject(String replyMessage) {}
3444
3445 /**
Ravi Palurif4b38e72020-02-05 12:35:41 +05303446 * Notifies this Connection, a request to transfer to a target number.
3447 * @param number the number to transfer this {@link Connection} to.
3448 * @param isConfirmationRequired when {@code true}, the {@link ConnectionService}
3449 * should wait until the transfer has successfully completed before disconnecting
3450 * the current {@link Connection}.
3451 * When {@code false}, the {@link ConnectionService} should signal the network to
3452 * perform the transfer, but should immediately disconnect the call regardless of
3453 * the outcome of the transfer.
3454 * @hide
3455 */
3456 public void onTransfer(@NonNull Uri number, boolean isConfirmationRequired) {}
3457
3458 /**
3459 * Notifies this Connection, a request to transfer to another Connection.
3460 * @param otherConnection the {@link Connection} to transfer this call to.
3461 * @hide
3462 */
3463 public void onTransfer(@NonNull Connection otherConnection) {}
3464
3465 /**
Tyler Gunn06f06162018-06-18 11:24:15 -07003466 * Notifies this Connection of a request to silence the ringer.
3467 * <p>
3468 * The ringer may be silenced by any of the following methods:
3469 * <ul>
3470 * <li>{@link TelecomManager#silenceRinger()}</li>
3471 * <li>The user presses the volume-down button while a call is ringing.</li>
3472 * </ul>
3473 * <p>
3474 * Self-managed {@link ConnectionService} implementations should override this method in their
3475 * {@link Connection} implementation and implement logic to silence their app's ringtone. If
3476 * your app set the ringtone as part of the incoming call {@link Notification} (see
3477 * {@link #onShowIncomingCallUi()}), it should re-post the notification now, except call
3478 * {@link android.app.Notification.Builder#setOnlyAlertOnce(boolean)} with {@code true}. This
3479 * will ensure the ringtone sound associated with your {@link android.app.NotificationChannel}
3480 * stops playing.
Bryce Leecac50772015-11-17 15:13:29 -08003481 */
3482 public void onSilence() {}
3483
3484 /**
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003485 * Notifies this Connection whether the user wishes to proceed with the post-dial DTMF codes.
3486 */
Santos Cordonf2951102014-07-20 19:06:29 -07003487 public void onPostDialContinue(boolean proceed) {}
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003488
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003489 /**
3490 * Notifies this Connection of a request to pull an external call to the local device.
3491 * <p>
3492 * The {@link InCallService} issues a request to pull an external call to the local device via
3493 * {@link Call#pullExternalCall()}.
3494 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -07003495 * For a Connection to be pulled, both the {@link Connection#CAPABILITY_CAN_PULL_CALL}
3496 * capability and {@link Connection#PROPERTY_IS_EXTERNAL_CALL} property bits must be set.
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003497 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -07003498 * For more information on external calls, see {@link Connection#PROPERTY_IS_EXTERNAL_CALL}.
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003499 */
3500 public void onPullExternalCall() {}
3501
3502 /**
3503 * Notifies this Connection of a {@link Call} event initiated from an {@link InCallService}.
3504 * <p>
3505 * The {@link InCallService} issues a Call event via {@link Call#sendCallEvent(String, Bundle)}.
3506 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003507 * Where possible, the Connection should make an attempt to handle {@link Call} events which
3508 * are part of the {@code android.telecom.*} namespace. The Connection should ignore any events
3509 * it does not wish to handle. Unexpected events should be handled gracefully, as it is
3510 * possible that a {@link InCallService} has defined its own Call events which a Connection is
3511 * not aware of.
3512 * <p>
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003513 * See also {@link Call#sendCallEvent(String, Bundle)}.
3514 *
3515 * @param event The call event.
3516 * @param extras Extras associated with the call event.
3517 */
3518 public void onCallEvent(String event, Bundle extras) {}
3519
Tyler Gunndee56a82016-03-23 16:06:34 -07003520 /**
Tyler Gunn79bc1ec2018-01-22 15:17:54 -08003521 * Notifies this {@link Connection} that a handover has completed.
3522 * <p>
3523 * A handover is initiated with {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int,
3524 * Bundle)} on the initiating side of the handover, and
3525 * {@link TelecomManager#acceptHandover(Uri, int, PhoneAccountHandle)}.
3526 */
3527 public void onHandoverComplete() {}
3528
3529 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07003530 * Notifies this {@link Connection} of a change to the extras made outside the
3531 * {@link ConnectionService}.
3532 * <p>
3533 * These extras changes can originate from Telecom itself, or from an {@link InCallService} via
3534 * the {@link android.telecom.Call#putExtras(Bundle)} and
3535 * {@link Call#removeExtras(List)}.
3536 *
3537 * @param extras The new extras bundle.
3538 */
3539 public void onExtrasChanged(Bundle extras) {}
3540
Tyler Gunnf5035432017-01-09 09:43:12 -08003541 /**
3542 * Notifies this {@link Connection} that its {@link ConnectionService} is responsible for
3543 * displaying its incoming call user interface for the {@link Connection}.
3544 * <p>
3545 * Will only be called for incoming calls added via a self-managed {@link ConnectionService}
3546 * (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}), where the {@link ConnectionService}
3547 * should show its own incoming call user interface.
3548 * <p>
3549 * Where there are ongoing calls in other self-managed {@link ConnectionService}s, or in a
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003550 * regular {@link ConnectionService}, and it is not possible to hold these other calls, the
3551 * Telecom framework will display its own incoming call user interface to allow the user to
3552 * choose whether to answer the new incoming call and disconnect other ongoing calls, or to
3553 * reject the new incoming call.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003554 * <p>
3555 * You should trigger the display of the incoming call user interface for your application by
3556 * showing a {@link Notification} with a full-screen {@link Intent} specified.
Tyler Gunn06f06162018-06-18 11:24:15 -07003557 *
3558 * In your application code, you should create a {@link android.app.NotificationChannel} for
3559 * incoming call notifications from your app:
3560 * <pre><code>
3561 * NotificationChannel channel = new NotificationChannel(YOUR_CHANNEL_ID, "Incoming Calls",
3562 * NotificationManager.IMPORTANCE_MAX);
3563 * // other channel setup stuff goes here.
3564 *
3565 * // We'll use the default system ringtone for our incoming call notification channel. You can
3566 * // use your own audio resource here.
3567 * Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
3568 * channel.setSound(ringtoneUri, new AudioAttributes.Builder()
3569 * // Setting the AudioAttributes is important as it identifies the purpose of your
3570 * // notification sound.
3571 * .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
3572 * .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
3573 * .build());
3574 *
3575 * NotificationManager mgr = getSystemService(NotificationManager.class);
3576 * mgr.createNotificationChannel(channel);
3577 * </code></pre>
3578 * When it comes time to post a notification for your incoming call, ensure it uses your
3579 * incoming call {@link android.app.NotificationChannel}.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003580 * <pre><code>
3581 * // Create an intent which triggers your fullscreen incoming call user interface.
3582 * Intent intent = new Intent(Intent.ACTION_MAIN, null);
3583 * intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_ACTIVITY_NEW_TASK);
3584 * intent.setClass(context, YourIncomingCallActivity.class);
Ashwini Orugantif8191e82021-01-07 12:04:25 -08003585 * PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_MUTABLE_UNAUDITED);
Tyler Gunn159f35c2017-03-02 09:28:37 -08003586 *
3587 * // Build the notification as an ongoing high priority item; this ensures it will show as
3588 * // a heads up notification which slides down over top of the current content.
3589 * final Notification.Builder builder = new Notification.Builder(context);
3590 * builder.setOngoing(true);
3591 * builder.setPriority(Notification.PRIORITY_HIGH);
3592 *
3593 * // Set notification content intent to take user to fullscreen UI if user taps on the
3594 * // notification body.
3595 * builder.setContentIntent(pendingIntent);
3596 * // Set full screen intent to trigger display of the fullscreen UI when the notification
3597 * // manager deems it appropriate.
3598 * builder.setFullScreenIntent(pendingIntent, true);
3599 *
3600 * // Setup notification content.
3601 * builder.setSmallIcon( yourIconResourceId );
3602 * builder.setContentTitle("Your notification title");
3603 * builder.setContentText("Your notification content.");
3604 *
Tyler Gunn06f06162018-06-18 11:24:15 -07003605 * // Set notification as insistent to cause your ringtone to loop.
3606 * Notification notification = builder.build();
3607 * notification.flags |= Notification.FLAG_INSISTENT;
Tyler Gunn159f35c2017-03-02 09:28:37 -08003608 *
Tyler Gunn06f06162018-06-18 11:24:15 -07003609 * // Use builder.addAction(..) to add buttons to answer or reject the call.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003610 * NotificationManager notificationManager = mContext.getSystemService(
3611 * NotificationManager.class);
Tyler Gunn06f06162018-06-18 11:24:15 -07003612 * notificationManager.notify(YOUR_CHANNEL_ID, YOUR_TAG, YOUR_ID, notification);
Tyler Gunn159f35c2017-03-02 09:28:37 -08003613 * </code></pre>
Tyler Gunnf5035432017-01-09 09:43:12 -08003614 */
3615 public void onShowIncomingCallUi() {}
3616
Hall Liub64ac4c2017-02-06 10:49:48 -08003617 /**
3618 * Notifies this {@link Connection} that the user has requested an RTT session.
3619 * The connection service should call {@link #sendRttInitiationSuccess} or
3620 * {@link #sendRttInitiationFailure} to inform Telecom of the success or failure of the
3621 * request, respectively.
3622 * @param rttTextStream The object that should be used to send text to or receive text from
3623 * the in-call app.
Hall Liub64ac4c2017-02-06 10:49:48 -08003624 */
3625 public void onStartRtt(@NonNull RttTextStream rttTextStream) {}
3626
3627 /**
3628 * Notifies this {@link Connection} that it should terminate any existing RTT communication
3629 * channel. No response to Telecom is needed for this method.
Hall Liub64ac4c2017-02-06 10:49:48 -08003630 */
3631 public void onStopRtt() {}
3632
3633 /**
3634 * Notifies this connection of a response to a previous remotely-initiated RTT upgrade
3635 * request sent via {@link #sendRemoteRttRequest}. Acceptance of the request is
3636 * indicated by the supplied {@link RttTextStream} being non-null, and rejection is
3637 * indicated by {@code rttTextStream} being {@code null}
Hall Liub64ac4c2017-02-06 10:49:48 -08003638 * @param rttTextStream The object that should be used to send text to or receive text from
3639 * the in-call app.
3640 */
3641 public void handleRttUpgradeResponse(@Nullable RttTextStream rttTextStream) {}
3642
Hall Liu49cabcc2021-01-15 11:41:48 -08003643 /**
Hall Liu73903142021-02-18 18:41:41 -08003644 * Information provided to a {@link Connection} upon completion of call filtering in Telecom.
3645 *
3646 * @hide
3647 */
3648 @SystemApi
3649 public static final class CallFilteringCompletionInfo implements Parcelable {
3650 private final boolean mIsBlocked;
3651 private final boolean mIsInContacts;
3652 private final CallScreeningService.CallResponse mCallResponse;
3653 private final ComponentName mCallScreeningComponent;
3654
3655 /**
3656 * Constructor for {@link CallFilteringCompletionInfo}
3657 *
3658 * @param isBlocked Whether any part of the call filtering process indicated that this call
3659 * should be blocked.
3660 * @param isInContacts Whether the caller is in the user's contacts.
3661 * @param callResponse The instance of {@link CallScreeningService.CallResponse} provided
3662 * by the {@link CallScreeningService} that processed this call, or
3663 * {@code null} if no call screening service ran.
3664 * @param callScreeningComponent The component of the {@link CallScreeningService}
3665 * that processed this call, or {@link null} if no
3666 * call screening service ran.
3667 */
3668 public CallFilteringCompletionInfo(boolean isBlocked, boolean isInContacts,
3669 @Nullable CallScreeningService.CallResponse callResponse,
3670 @Nullable ComponentName callScreeningComponent) {
3671 mIsBlocked = isBlocked;
3672 mIsInContacts = isInContacts;
3673 mCallResponse = callResponse;
3674 mCallScreeningComponent = callScreeningComponent;
3675 }
3676
3677 /** @hide */
3678 protected CallFilteringCompletionInfo(Parcel in) {
3679 mIsBlocked = in.readByte() != 0;
3680 mIsInContacts = in.readByte() != 0;
3681 CallScreeningService.ParcelableCallResponse response
Bernardo Rufino90bb3702021-12-07 20:01:45 +00003682 = in.readParcelable(CallScreeningService.class.getClassLoader(), android.telecom.CallScreeningService.ParcelableCallResponse.class);
Hall Liu73903142021-02-18 18:41:41 -08003683 mCallResponse = response == null ? null : response.toCallResponse();
Bernardo Rufino90bb3702021-12-07 20:01:45 +00003684 mCallScreeningComponent = in.readParcelable(ComponentName.class.getClassLoader(), android.content.ComponentName.class);
Hall Liu73903142021-02-18 18:41:41 -08003685 }
3686
3687 @NonNull
3688 public static final Creator<CallFilteringCompletionInfo> CREATOR =
3689 new Creator<CallFilteringCompletionInfo>() {
3690 @Override
3691 public CallFilteringCompletionInfo createFromParcel(Parcel in) {
3692 return new CallFilteringCompletionInfo(in);
3693 }
3694
3695 @Override
3696 public CallFilteringCompletionInfo[] newArray(int size) {
3697 return new CallFilteringCompletionInfo[size];
3698 }
3699 };
3700
3701 /**
3702 * @return Whether any part of the call filtering process indicated that this call should be
3703 * blocked.
3704 */
3705 public boolean isBlocked() {
3706 return mIsBlocked;
3707 }
3708
3709 /**
3710 * @return Whether the caller is in the user's contacts.
3711 */
3712 public boolean isInContacts() {
3713 return mIsInContacts;
3714 }
3715
3716 /**
3717 * @return The instance of {@link CallScreeningService.CallResponse} provided
3718 * by the {@link CallScreeningService} that processed this
3719 * call, or {@code null} if no call screening service ran.
3720 */
3721 public @Nullable CallScreeningService.CallResponse getCallResponse() {
3722 return mCallResponse;
3723 }
3724
3725 /**
3726 * @return The component of the {@link CallScreeningService}
3727 * that processed this call, or {@code null} if no call screening service ran.
3728 */
3729 public @Nullable ComponentName getCallScreeningComponent() {
3730 return mCallScreeningComponent;
3731 }
3732
3733 @Override
3734 public int describeContents() {
3735 return 0;
3736 }
3737
3738 @Override
3739 public String toString() {
3740 return "CallFilteringCompletionInfo{" +
3741 "mIsBlocked=" + mIsBlocked +
3742 ", mIsInContacts=" + mIsInContacts +
3743 ", mCallResponse=" + mCallResponse +
3744 ", mCallScreeningPackageName='" + mCallScreeningComponent + '\'' +
3745 '}';
3746 }
3747
3748 /** @hide */
3749 @Override
3750 public void writeToParcel(Parcel dest, int flags) {
3751 dest.writeByte((byte) (mIsBlocked ? 1 : 0));
3752 dest.writeByte((byte) (mIsInContacts ? 1 : 0));
3753 dest.writeParcelable(mCallResponse == null ? null : mCallResponse.toParcelable(), 0);
3754 dest.writeParcelable(mCallScreeningComponent, 0);
3755 }
3756 }
3757
3758 /**
Hall Liu49cabcc2021-01-15 11:41:48 -08003759 * Indicates that call filtering in Telecom is complete
3760 *
3761 * This method is called for a connection created via
3762 * {@link ConnectionService#onCreateIncomingConnection} when call filtering completes in
3763 * Telecom, including checking the blocked number db, per-contact settings, and custom call
3764 * filtering apps.
3765 *
Hall Liu73903142021-02-18 18:41:41 -08003766 * @param callFilteringCompletionInfo Info provided by Telecom on the results of call filtering.
Hall Liu49cabcc2021-01-15 11:41:48 -08003767 * @hide
3768 */
3769 @SystemApi
3770 @RequiresPermission(Manifest.permission.READ_CONTACTS)
Hall Liu73903142021-02-18 18:41:41 -08003771 public void onCallFilteringCompleted(
3772 @NonNull CallFilteringCompletionInfo callFilteringCompletionInfo) { }
Hall Liu49cabcc2021-01-15 11:41:48 -08003773
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003774 static String toLogSafePhoneNumber(String number) {
3775 // For unknown number, log empty string.
3776 if (number == null) {
3777 return "";
3778 }
3779
3780 if (PII_DEBUG) {
3781 // When PII_DEBUG is true we emit PII.
3782 return number;
3783 }
3784
3785 // Do exactly same thing as Uri#toSafeString() does, which will enable us to compare
3786 // sanitized phone numbers.
3787 StringBuilder builder = new StringBuilder();
3788 for (int i = 0; i < number.length(); i++) {
3789 char c = number.charAt(i);
3790 if (c == '-' || c == '@' || c == '.') {
3791 builder.append(c);
3792 } else {
3793 builder.append('x');
3794 }
3795 }
3796 return builder.toString();
3797 }
3798
Ihab Awad542e0ea2014-05-16 10:22:16 -07003799 private void setState(int state) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003800 checkImmutable();
Ihab Awad6107bab2014-08-18 09:23:25 -07003801 if (mState == STATE_DISCONNECTED && mState != state) {
3802 Log.d(this, "Connection already DISCONNECTED; cannot transition out of this state.");
Evan Charltonbf11f982014-07-20 22:06:28 -07003803 return;
Sailesh Nepal400cc482014-06-26 12:04:00 -07003804 }
Evan Charltonbf11f982014-07-20 22:06:28 -07003805 if (mState != state) {
3806 Log.d(this, "setState: %s", stateToString(state));
3807 mState = state;
Nancy Chen354b2bd2014-09-08 18:27:26 -07003808 onStateChanged(state);
Evan Charltonbf11f982014-07-20 22:06:28 -07003809 for (Listener l : mListeners) {
3810 l.onStateChanged(this, state);
3811 }
Evan Charltonbf11f982014-07-20 22:06:28 -07003812 }
3813 }
3814
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07003815 private static class FailureSignalingConnection extends Connection {
Ihab Awad90e34e32014-12-01 16:23:17 -08003816 private boolean mImmutable = false;
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003817 public FailureSignalingConnection(DisconnectCause disconnectCause) {
3818 setDisconnected(disconnectCause);
Tyler Gunn2915af72020-03-06 11:36:21 -08003819 mImmutable = true;
Ihab Awad6107bab2014-08-18 09:23:25 -07003820 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003821
3822 public void checkImmutable() {
Ihab Awad90e34e32014-12-01 16:23:17 -08003823 if (mImmutable) {
3824 throw new UnsupportedOperationException("Connection is immutable");
3825 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003826 }
Ihab Awad6107bab2014-08-18 09:23:25 -07003827 }
3828
Evan Charltonbf11f982014-07-20 22:06:28 -07003829 /**
Ihab Awad6107bab2014-08-18 09:23:25 -07003830 * Return a {@code Connection} which represents a failed connection attempt. The returned
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003831 * {@code Connection} will have a {@link android.telecom.DisconnectCause} and as specified,
3832 * and a {@link #getState()} of {@link #STATE_DISCONNECTED}.
Ihab Awad6107bab2014-08-18 09:23:25 -07003833 * <p>
3834 * The returned {@code Connection} can be assumed to {@link #destroy()} itself when appropriate,
3835 * so users of this method need not maintain a reference to its return value to destroy it.
Evan Charltonbf11f982014-07-20 22:06:28 -07003836 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003837 * @param disconnectCause The disconnect cause, ({@see android.telecomm.DisconnectCause}).
Ihab Awad6107bab2014-08-18 09:23:25 -07003838 * @return A {@code Connection} which indicates failure.
Evan Charltonbf11f982014-07-20 22:06:28 -07003839 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003840 public static Connection createFailedConnection(DisconnectCause disconnectCause) {
3841 return new FailureSignalingConnection(disconnectCause);
Evan Charltonbf11f982014-07-20 22:06:28 -07003842 }
3843
Evan Charltonbf11f982014-07-20 22:06:28 -07003844 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003845 * Override to throw an {@link UnsupportedOperationException} if this {@code Connection} is
3846 * not intended to be mutated, e.g., if it is a marker for failure. Only for framework use;
3847 * this should never be un-@hide-den.
3848 *
3849 * @hide
3850 */
3851 public void checkImmutable() {}
3852
3853 /**
Ihab Awad6107bab2014-08-18 09:23:25 -07003854 * Return a {@code Connection} which represents a canceled connection attempt. The returned
3855 * {@code Connection} will have state {@link #STATE_DISCONNECTED}, and cannot be moved out of
3856 * that state. This connection should not be used for anything, and no other
3857 * {@code Connection}s should be attempted.
3858 * <p>
Ihab Awad6107bab2014-08-18 09:23:25 -07003859 * so users of this method need not maintain a reference to its return value to destroy it.
Evan Charltonbf11f982014-07-20 22:06:28 -07003860 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003861 * @return A {@code Connection} which indicates that the underlying connection should
3862 * be canceled.
Evan Charltonbf11f982014-07-20 22:06:28 -07003863 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003864 public static Connection createCanceledConnection() {
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003865 return new FailureSignalingConnection(new DisconnectCause(DisconnectCause.CANCELED));
Ihab Awad542e0ea2014-05-16 10:22:16 -07003866 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003867
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003868 private final void fireOnConferenceableConnectionsChanged() {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003869 for (Listener l : mListeners) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003870 l.onConferenceablesChanged(this, getConferenceables());
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003871 }
3872 }
3873
Santos Cordon823fd3c2014-08-07 18:35:18 -07003874 private final void fireConferenceChanged() {
3875 for (Listener l : mListeners) {
3876 l.onConferenceChanged(this, mConference);
3877 }
3878 }
3879
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003880 private final void clearConferenceableList() {
Tyler Gunndf2cbc82015-04-20 09:13:01 -07003881 for (Conferenceable c : mConferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003882 if (c instanceof Connection) {
3883 Connection connection = (Connection) c;
3884 connection.removeConnectionListener(mConnectionDeathListener);
3885 } else if (c instanceof Conference) {
3886 Conference conference = (Conference) c;
3887 conference.removeListener(mConferenceDeathListener);
3888 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003889 }
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003890 mConferenceables.clear();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003891 }
Tyler Gunn3bffcf72014-10-28 13:51:27 -07003892
3893 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07003894 * Handles a change to extras received from Telecom.
3895 *
3896 * @param extras The new extras.
3897 * @hide
3898 */
3899 final void handleExtrasChanged(Bundle extras) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003900 Bundle b = null;
3901 synchronized (mExtrasLock) {
3902 mExtras = extras;
3903 if (mExtras != null) {
3904 b = new Bundle(mExtras);
3905 }
3906 }
3907 onExtrasChanged(b);
Tyler Gunndee56a82016-03-23 16:06:34 -07003908 }
3909
3910 /**
Tyler Gunnc63f9082019-10-15 13:19:26 -07003911 * Called by a {@link ConnectionService} to notify Telecom that a {@link Conference#onMerge()}
3912 * request failed.
Anthony Lee17455a32015-04-24 15:25:29 -07003913 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003914 public final void notifyConferenceMergeFailed() {
Anthony Lee17455a32015-04-24 15:25:29 -07003915 for (Listener l : mListeners) {
3916 l.onConferenceMergeFailed(this);
3917 }
3918 }
3919
3920 /**
Srikanth Chintalafcb15012017-05-04 20:58:34 +05303921 * Notifies listeners when phone account is changed. For example, when the PhoneAccount is
3922 * changed due to an emergency call being redialed.
3923 * @param pHandle The new PhoneAccountHandle for this connection.
3924 * @hide
3925 */
3926 public void notifyPhoneAccountChanged(PhoneAccountHandle pHandle) {
3927 for (Listener l : mListeners) {
3928 l.onPhoneAccountChanged(this, pHandle);
3929 }
3930 }
3931
3932 /**
Pengquan Meng70c9885332017-10-02 18:09:03 -07003933 * Sets the {@link PhoneAccountHandle} associated with this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003934 * <p>
3935 * Used by the Telephony {@link ConnectionService} to handle changes to the {@link PhoneAccount}
3936 * which take place after call initiation (important for emergency calling scenarios).
Pengquan Meng70c9885332017-10-02 18:09:03 -07003937 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07003938 * @param phoneAccountHandle the phone account handle to set.
Pengquan Meng70c9885332017-10-02 18:09:03 -07003939 * @hide
3940 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003941 @SystemApi
3942 public void setPhoneAccountHandle(@NonNull PhoneAccountHandle phoneAccountHandle) {
Pengquan Meng70c9885332017-10-02 18:09:03 -07003943 if (mPhoneAccountHandle != phoneAccountHandle) {
3944 mPhoneAccountHandle = phoneAccountHandle;
3945 notifyPhoneAccountChanged(phoneAccountHandle);
3946 }
3947 }
3948
3949 /**
3950 * Returns the {@link PhoneAccountHandle} associated with this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003951 * <p>
3952 * Used by the Telephony {@link ConnectionService} to handle changes to the {@link PhoneAccount}
3953 * which take place after call initiation (important for emergency calling scenarios).
Pengquan Meng70c9885332017-10-02 18:09:03 -07003954 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07003955 * @return the phone account handle specified via
3956 * {@link #setPhoneAccountHandle(PhoneAccountHandle)}, or {@code null} if none was set.
Pengquan Meng70c9885332017-10-02 18:09:03 -07003957 * @hide
3958 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003959 @SystemApi
3960 public @Nullable PhoneAccountHandle getPhoneAccountHandle() {
Pengquan Meng70c9885332017-10-02 18:09:03 -07003961 return mPhoneAccountHandle;
3962 }
3963
3964 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003965 * Sends an event associated with this {@code Connection} with associated event extras to the
3966 * {@link InCallService}.
3967 * <p>
3968 * Connection events are used to communicate point in time information from a
3969 * {@link ConnectionService} to a {@link InCallService} implementations. An example of a
3970 * custom connection event includes notifying the UI when a WIFI call has been handed over to
3971 * LTE, which the InCall UI might use to inform the user that billing charges may apply. The
3972 * Android Telephony framework will send the {@link #EVENT_CALL_MERGE_FAILED} connection event
3973 * when a call to {@link Call#mergeConference()} has failed to complete successfully. A
3974 * connection event could also be used to trigger UI in the {@link InCallService} which prompts
3975 * the user to make a choice (e.g. whether they want to incur roaming costs for making a call),
3976 * which is communicated back via {@link Call#sendCallEvent(String, Bundle)}.
3977 * <p>
3978 * Events are exposed to {@link InCallService} implementations via
3979 * {@link Call.Callback#onConnectionEvent(Call, String, Bundle)}.
3980 * <p>
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003981 * 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 -07003982 * The {@link ConnectionService} must assume that the In-Call UI could even chose to ignore
3983 * some events altogether.
3984 * <p>
3985 * Events should be fully qualified (e.g. {@code com.example.event.MY_EVENT}) to avoid
3986 * conflicts between {@link ConnectionService} implementations. Further, custom
3987 * {@link ConnectionService} implementations shall not re-purpose events in the
3988 * {@code android.*} namespace, nor shall they define new event types in this namespace. When
3989 * defining a custom event type, ensure the contents of the extras {@link Bundle} is clearly
3990 * defined. Extra keys for this bundle should be named similar to the event type (e.g.
3991 * {@code com.example.extra.MY_EXTRA}).
3992 * <p>
3993 * When defining events and the associated extras, it is important to keep their behavior
3994 * consistent when the associated {@link ConnectionService} is updated. Support for deprecated
3995 * events/extras should me maintained to ensure backwards compatibility with older
3996 * {@link InCallService} implementations which were built to support the older behavior.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003997 *
3998 * @param event The connection event.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003999 * @param extras Optional bundle containing extra information associated with the event.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08004000 */
Tyler Gunn876dbfb2016-03-14 15:18:07 -07004001 public void sendConnectionEvent(String event, Bundle extras) {
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08004002 for (Listener l : mListeners) {
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07004003 l.onConnectionEvent(this, event, extras);
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08004004 }
4005 }
Tyler Gunn6986a632019-06-25 13:45:32 -07004006
4007 /**
4008 * @return The direction of the call.
4009 * @hide
4010 */
4011 public final @Call.Details.CallDirection int getCallDirection() {
4012 return mCallDirection;
4013 }
4014
4015 /**
4016 * Sets the direction of this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07004017 * <p>
4018 * Used when calling {@link ConnectionService#addExistingConnection} to specify the existing
4019 * call direction.
4020 *
Tyler Gunn6986a632019-06-25 13:45:32 -07004021 * @param callDirection The direction of this connection.
4022 * @hide
4023 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07004024 @SystemApi
Tyler Gunn6986a632019-06-25 13:45:32 -07004025 public void setCallDirection(@Call.Details.CallDirection int callDirection) {
4026 mCallDirection = callDirection;
4027 }
Tyler Gunnd57d76c2019-09-24 14:53:23 -07004028
4029 /**
4030 * Gets the verification status for the phone number of an incoming call as identified in
4031 * ATIS-1000082.
4032 * @return the verification status.
4033 */
Tyler Gunna131d6e2020-02-13 14:53:28 -08004034 public final @VerificationStatus int getCallerNumberVerificationStatus() {
Tyler Gunnd57d76c2019-09-24 14:53:23 -07004035 return mCallerNumberVerificationStatus;
4036 }
4037
4038 /**
4039 * Sets the verification status for the phone number of an incoming call as identified in
4040 * ATIS-1000082.
4041 * <p>
4042 * This property can only be set at the time of creation of a {@link Connection} being returned
4043 * by
4044 * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)}.
4045 */
Tyler Gunna131d6e2020-02-13 14:53:28 -08004046 public final void setCallerNumberVerificationStatus(
Tyler Gunnd57d76c2019-09-24 14:53:23 -07004047 @VerificationStatus int callerNumberVerificationStatus) {
4048 mCallerNumberVerificationStatus = callerNumberVerificationStatus;
4049 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07004050}