blob: 22a37d050cf4358a5fbb937e89bed065e9bd2242 [file] [log] [blame]
Ihab Awad542e0ea2014-05-16 10:22:16 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Tyler Gunnef9f6f92014-09-12 22:16:17 -070017package android.telecom;
Ihab Awad542e0ea2014-05-16 10:22:16 -070018
Tyler Gunnc9503d62020-01-27 10:30:51 -080019import static android.Manifest.permission.MODIFY_PHONE_STATE;
20
Hall Liu49cabcc2021-01-15 11:41:48 -080021import android.Manifest;
Tyler Gunnc9503d62020-01-27 10:30:51 -080022import android.annotation.ElapsedRealtimeLong;
Tyler Gunnd57d76c2019-09-24 14:53:23 -070023import android.annotation.IntDef;
Tyler Gunnc9503d62020-01-27 10:30:51 -080024import android.annotation.IntRange;
Tyler Gunndee56a82016-03-23 16:06:34 -070025import android.annotation.NonNull;
Santos Cordon6b7f9552015-05-27 17:21:45 -070026import android.annotation.Nullable;
Tyler Gunnc9503d62020-01-27 10:30:51 -080027import android.annotation.RequiresPermission;
Yorke Lee4af59352015-05-13 14:14:54 -070028import android.annotation.SystemApi;
Tyler Gunn159f35c2017-03-02 09:28:37 -080029import android.app.Notification;
Hall Liua98f58b52017-11-07 17:59:28 -080030import android.bluetooth.BluetoothDevice;
Artur Satayev53ada2a2019-12-10 17:47:56 +000031import android.compat.annotation.UnsupportedAppUsage;
Hall Liu73903142021-02-18 18:41:41 -080032import android.content.ComponentName;
Tyler Gunn159f35c2017-03-02 09:28:37 -080033import android.content.Intent;
Tyler Gunnb702ef82015-05-29 11:51:53 -070034import android.hardware.camera2.CameraManager;
Ihab Awad542e0ea2014-05-16 10:22:16 -070035import android.net.Uri;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -080036import android.os.Binder;
Santos Cordon6b7f9552015-05-27 17:21:45 -070037import android.os.Bundle;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070038import android.os.Handler;
39import android.os.IBinder;
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -070040import android.os.Looper;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070041import android.os.Message;
Hall Liu73903142021-02-18 18:41:41 -080042import android.os.Parcel;
Hall Liu95d55872017-01-25 17:12:49 -080043import android.os.ParcelFileDescriptor;
Hall Liu73903142021-02-18 18:41:41 -080044import android.os.Parcelable;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070045import android.os.RemoteException;
Tyler Gunn3fa819c2017-08-04 09:27:26 -070046import android.os.SystemClock;
Tyler Gunn0a1c6d12021-03-12 15:44:08 -080047import android.telephony.CallQuality;
allenwtsu2aca9892019-11-25 14:38:21 +080048import android.telephony.ims.ImsStreamMediaProfile;
Tyler Gunndee56a82016-03-23 16:06:34 -070049import android.util.ArraySet;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070050import android.view.Surface;
Ihab Awad542e0ea2014-05-16 10:22:16 -070051
Youming Yed6de26e2019-01-30 11:20:35 -080052import com.android.internal.os.SomeArgs;
53import com.android.internal.telecom.IVideoCallback;
54import com.android.internal.telecom.IVideoProvider;
55
Hall Liua549fed2018-02-09 16:40:03 -080056import java.io.FileInputStream;
57import java.io.FileOutputStream;
Hall Liu95d55872017-01-25 17:12:49 -080058import java.io.IOException;
59import java.io.InputStreamReader;
60import java.io.OutputStreamWriter;
Tyler Gunnd57d76c2019-09-24 14:53:23 -070061import java.lang.annotation.Retention;
62import java.lang.annotation.RetentionPolicy;
Hall Liu730a2592018-06-25 19:48:33 -070063import java.nio.channels.Channels;
Santos Cordonb6939982014-06-04 20:20:58 -070064import java.util.ArrayList;
Tyler Gunn071be6f2016-05-10 14:52:33 -070065import java.util.Arrays;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070066import java.util.Collections;
Santos Cordonb6939982014-06-04 20:20:58 -070067import java.util.List;
Ihab Awad542e0ea2014-05-16 10:22:16 -070068import java.util.Set;
Jay Shrauner229e3822014-08-15 09:23:07 -070069import java.util.concurrent.ConcurrentHashMap;
Ihab Awad542e0ea2014-05-16 10:22:16 -070070
71/**
Santos Cordon895d4b82015-06-25 16:41:48 -070072 * Represents a phone call or connection to a remote endpoint that carries voice and/or video
73 * traffic.
Ihab Awad6107bab2014-08-18 09:23:25 -070074 * <p>
75 * Implementations create a custom subclass of {@code Connection} and return it to the framework
76 * as the return value of
77 * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)}
78 * or
79 * {@link ConnectionService#onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
80 * Implementations are then responsible for updating the state of the {@code Connection}, and
81 * must call {@link #destroy()} to signal to the framework that the {@code Connection} is no
82 * longer used and associated resources may be recovered.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -070083 * <p>
84 * Subclasses of {@code Connection} override the {@code on*} methods to provide the the
85 * {@link ConnectionService}'s implementation of calling functionality. The {@code on*} methods are
86 * called by Telecom to inform an instance of a {@code Connection} of actions specific to that
87 * {@code Connection} instance.
88 * <p>
89 * Basic call support requires overriding the following methods: {@link #onAnswer()},
90 * {@link #onDisconnect()}, {@link #onReject()}, {@link #onAbort()}
91 * <p>
92 * Where a {@code Connection} has {@link #CAPABILITY_SUPPORT_HOLD}, the {@link #onHold()} and
93 * {@link #onUnhold()} methods should be overridden to provide hold support for the
94 * {@code Connection}.
95 * <p>
96 * Where a {@code Connection} supports a variation of video calling (e.g. the
97 * {@code CAPABILITY_SUPPORTS_VT_*} capability bits), {@link #onAnswer(int)} should be overridden
98 * to support answering a call as a video call.
99 * <p>
100 * Where a {@code Connection} has {@link #PROPERTY_IS_EXTERNAL_CALL} and
101 * {@link #CAPABILITY_CAN_PULL_CALL}, {@link #onPullExternalCall()} should be overridden to provide
102 * support for pulling the external call.
103 * <p>
104 * Where a {@code Connection} supports conference calling {@link #onSeparate()} should be
105 * overridden.
106 * <p>
107 * There are a number of other {@code on*} methods which a {@code Connection} can choose to
108 * implement, depending on whether it is concerned with the associated calls from Telecom. If,
109 * for example, call events from a {@link InCallService} are handled,
110 * {@link #onCallEvent(String, Bundle)} should be overridden. Another example is
111 * {@link #onExtrasChanged(Bundle)}, which should be overridden if the {@code Connection} wishes to
112 * make use of extra information provided via the {@link Call#putExtras(Bundle)} and
113 * {@link Call#removeExtras(String...)} methods.
Ihab Awad542e0ea2014-05-16 10:22:16 -0700114 */
Yorke Leeabfcfdc2015-05-13 18:55:18 -0700115public abstract class Connection extends Conferenceable {
Ihab Awad542e0ea2014-05-16 10:22:16 -0700116
Tyler Gunn50d437f2021-01-12 16:34:59 -0800117 /**@hide*/
118 @Retention(RetentionPolicy.SOURCE)
119 @IntDef(prefix = "STATE_", value = {
120 STATE_INITIALIZING,
121 STATE_NEW,
122 STATE_RINGING,
123 STATE_DIALING,
124 STATE_ACTIVE,
125 STATE_HOLDING,
126 STATE_DISCONNECTED,
127 STATE_PULLING_CALL
128 })
129 public @interface ConnectionState {}
130
Santos Cordon895d4b82015-06-25 16:41:48 -0700131 /**
132 * The connection is initializing. This is generally the first state for a {@code Connection}
133 * returned by a {@link ConnectionService}.
134 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700135 public static final int STATE_INITIALIZING = 0;
136
Santos Cordon895d4b82015-06-25 16:41:48 -0700137 /**
138 * The connection is new and not connected.
139 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700140 public static final int STATE_NEW = 1;
141
Santos Cordon895d4b82015-06-25 16:41:48 -0700142 /**
143 * An incoming connection is in the ringing state. During this state, the user's ringer or
144 * vibration feature will be activated.
145 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700146 public static final int STATE_RINGING = 2;
147
Santos Cordon895d4b82015-06-25 16:41:48 -0700148 /**
149 * An outgoing connection is in the dialing state. In this state the other party has not yet
150 * answered the call and the user traditionally hears a ringback tone.
151 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700152 public static final int STATE_DIALING = 3;
153
Santos Cordon895d4b82015-06-25 16:41:48 -0700154 /**
155 * A connection is active. Both parties are connected to the call and can actively communicate.
156 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700157 public static final int STATE_ACTIVE = 4;
158
Santos Cordon895d4b82015-06-25 16:41:48 -0700159 /**
160 * A connection is on hold.
161 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700162 public static final int STATE_HOLDING = 5;
163
Santos Cordon895d4b82015-06-25 16:41:48 -0700164 /**
165 * A connection has been disconnected. This is the final state once the user has been
166 * disconnected from a call either locally, remotely or by an error in the service.
167 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700168 public static final int STATE_DISCONNECTED = 6;
169
Santos Cordon895d4b82015-06-25 16:41:48 -0700170 /**
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700171 * The state of an external connection which is in the process of being pulled from a remote
172 * device to the local device.
173 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -0700174 * A connection can only be in this state if the {@link #PROPERTY_IS_EXTERNAL_CALL} property and
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700175 * {@link #CAPABILITY_CAN_PULL_CALL} capability bits are set on the connection.
176 */
177 public static final int STATE_PULLING_CALL = 7;
178
179 /**
Tyler Gunnd57d76c2019-09-24 14:53:23 -0700180 * Indicates that the network could not perform verification.
181 */
182 public static final int VERIFICATION_STATUS_NOT_VERIFIED = 0;
183
184 /**
185 * Indicates that verification by the network passed. This indicates there is a high likelihood
186 * that the call originated from a valid source.
187 */
188 public static final int VERIFICATION_STATUS_PASSED = 1;
189
190 /**
191 * Indicates that verification by the network failed. This indicates there is a high likelihood
192 * that the call did not originate from a valid source.
193 */
194 public static final int VERIFICATION_STATUS_FAILED = 2;
195
196 /**@hide*/
197 @Retention(RetentionPolicy.SOURCE)
198 @IntDef(prefix = "VERIFICATION_STATUS_", value = {
199 VERIFICATION_STATUS_NOT_VERIFIED,
200 VERIFICATION_STATUS_PASSED,
201 VERIFICATION_STATUS_FAILED
202 })
203 public @interface VerificationStatus {}
204
205 /**
Santos Cordon895d4b82015-06-25 16:41:48 -0700206 * Connection can currently be put on hold or unheld. This is distinct from
207 * {@link #CAPABILITY_SUPPORT_HOLD} in that although a connection may support 'hold' most times,
208 * it does not at the moment support the function. This can be true while the call is in the
209 * state {@link #STATE_DIALING}, for example. During this condition, an in-call UI may
210 * display a disabled 'hold' button.
211 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800212 public static final int CAPABILITY_HOLD = 0x00000001;
213
214 /** Connection supports the hold feature. */
215 public static final int CAPABILITY_SUPPORT_HOLD = 0x00000002;
216
217 /**
218 * Connections within a conference can be merged. A {@link ConnectionService} has the option to
219 * add a {@link Conference} before the child {@link Connection}s are merged. This is how
220 * CDMA-based {@link Connection}s are implemented. For these unmerged {@link Conference}s, this
221 * capability allows a merge button to be shown while the conference is in the foreground
222 * of the in-call UI.
223 * <p>
224 * This is only intended for use by a {@link Conference}.
225 */
226 public static final int CAPABILITY_MERGE_CONFERENCE = 0x00000004;
227
228 /**
229 * Connections within a conference can be swapped between foreground and background.
230 * See {@link #CAPABILITY_MERGE_CONFERENCE} for additional information.
231 * <p>
232 * This is only intended for use by a {@link Conference}.
233 */
234 public static final int CAPABILITY_SWAP_CONFERENCE = 0x00000008;
235
236 /**
237 * @hide
238 */
239 public static final int CAPABILITY_UNUSED = 0x00000010;
240
241 /** Connection supports responding via text option. */
242 public static final int CAPABILITY_RESPOND_VIA_TEXT = 0x00000020;
243
244 /** Connection can be muted. */
245 public static final int CAPABILITY_MUTE = 0x00000040;
246
247 /**
248 * Connection supports conference management. This capability only applies to
249 * {@link Conference}s which can have {@link Connection}s as children.
250 */
251 public static final int CAPABILITY_MANAGE_CONFERENCE = 0x00000080;
252
253 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700254 * Local device supports receiving video.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800255 */
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700256 public static final int CAPABILITY_SUPPORTS_VT_LOCAL_RX = 0x00000100;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800257
258 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700259 * Local device supports transmitting 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_TX = 0x00000200;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800262
263 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700264 * Local device supports bidirectional video calling.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800265 */
Andrew Lee9a8f9ce2015-04-10 18:09:46 -0700266 public static final int CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL =
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700267 CAPABILITY_SUPPORTS_VT_LOCAL_RX | CAPABILITY_SUPPORTS_VT_LOCAL_TX;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800268
269 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700270 * Remote device supports receiving video.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800271 */
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700272 public static final int CAPABILITY_SUPPORTS_VT_REMOTE_RX = 0x00000400;
273
274 /**
275 * Remote device supports transmitting video.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700276 */
277 public static final int CAPABILITY_SUPPORTS_VT_REMOTE_TX = 0x00000800;
278
279 /**
280 * Remote device supports bidirectional video calling.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700281 */
Andrew Lee9a8f9ce2015-04-10 18:09:46 -0700282 public static final int CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL =
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700283 CAPABILITY_SUPPORTS_VT_REMOTE_RX | CAPABILITY_SUPPORTS_VT_REMOTE_TX;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800284
285 /**
286 * Connection is able to be separated from its parent {@code Conference}, if any.
287 */
288 public static final int CAPABILITY_SEPARATE_FROM_CONFERENCE = 0x00001000;
289
290 /**
291 * Connection is able to be individually disconnected when in a {@code Conference}.
292 */
293 public static final int CAPABILITY_DISCONNECT_FROM_CONFERENCE = 0x00002000;
294
295 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700296 * Un-used.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800297 * @hide
298 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700299 public static final int CAPABILITY_UNUSED_2 = 0x00004000;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800300
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700301 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700302 * Un-used.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700303 * @hide
304 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700305 public static final int CAPABILITY_UNUSED_3 = 0x00008000;
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700306
307 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700308 * Un-used.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700309 * @hide
310 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700311 public static final int CAPABILITY_UNUSED_4 = 0x00010000;
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700312
Tyler Gunn068085b2015-02-06 13:56:52 -0800313 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700314 * Un-used.
Tyler Gunn068085b2015-02-06 13:56:52 -0800315 * @hide
316 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700317 public static final int CAPABILITY_UNUSED_5 = 0x00020000;
Tyler Gunn068085b2015-02-06 13:56:52 -0800318
Tyler Gunn96d6c402015-03-18 12:39:23 -0700319 /**
Dong Zhou89f41eb2015-03-15 11:59:49 -0500320 * Speed up audio setup for MT call.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700321 * <p>
322 * Used for IMS calls to indicate that mobile-terminated (incoming) call audio setup should take
323 * place as soon as the device answers the call, but prior to it being connected. This is an
324 * optimization some IMS stacks depend on to ensure prompt setup of call audio.
Dong Zhou89f41eb2015-03-15 11:59:49 -0500325 * @hide
Tyler Gunn96d6c402015-03-18 12:39:23 -0700326 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700327 @SystemApi
Tyler Gunn96d6c402015-03-18 12:39:23 -0700328 public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00040000;
Tyler Gunn068085b2015-02-06 13:56:52 -0800329
Rekha Kumar07366812015-03-24 16:42:31 -0700330 /**
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700331 * Call can be upgraded to a video call.
Tyler Gunn6e3ecc42018-11-12 11:30:56 -0800332 * @deprecated Use {@link #CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL} and
333 * {@link #CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL} to indicate for a call whether or not
334 * video calling is supported.
Rekha Kumar07366812015-03-24 16:42:31 -0700335 */
336 public static final int CAPABILITY_CAN_UPGRADE_TO_VIDEO = 0x00080000;
337
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700338 /**
339 * For video calls, indicates whether the outgoing video for the call can be paused using
Yorke Lee32f24732015-05-12 16:18:03 -0700340 * the {@link android.telecom.VideoProfile#STATE_PAUSED} VideoState.
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700341 */
342 public static final int CAPABILITY_CAN_PAUSE_VIDEO = 0x00100000;
343
Tyler Gunnd4091732015-06-29 09:15:37 -0700344 /**
345 * For a conference, indicates the conference will not have child connections.
346 * <p>
347 * An example of a conference with child connections is a GSM conference call, where the radio
348 * retains connections to the individual participants of the conference. Another example is an
349 * IMS conference call where conference event package functionality is supported; in this case
350 * the conference server ensures the radio is aware of the participants in the conference, which
351 * are represented by child connections.
352 * <p>
353 * An example of a conference with no child connections is an IMS conference call with no
354 * conference event package support. Such a conference is represented by the radio as a single
355 * connection to the IMS conference server.
356 * <p>
357 * Indicating whether a conference has children or not is important to help user interfaces
358 * visually represent a conference. A conference with no children, for example, will have the
359 * conference connection shown in the list of calls on a Bluetooth device, where if the
360 * conference has children, only the children will be shown in the list of calls on a Bluetooth
361 * device.
362 * @hide
363 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700364 @SystemApi
Tyler Gunnd4091732015-06-29 09:15:37 -0700365 public static final int CAPABILITY_CONFERENCE_HAS_NO_CHILDREN = 0x00200000;
366
Bryce Lee81901682015-08-28 16:38:02 -0700367 /**
368 * Indicates that the connection itself wants to handle any sort of reply response, rather than
369 * relying on SMS.
Bryce Lee81901682015-08-28 16:38:02 -0700370 */
371 public static final int CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION = 0x00400000;
372
Tyler Gunnf97a0092016-01-19 15:59:34 -0800373 /**
374 * When set, prevents a video call from being downgraded to an audio-only call.
375 * <p>
376 * Should be set when the VideoState has the {@link VideoProfile#STATE_TX_ENABLED} or
377 * {@link VideoProfile#STATE_RX_ENABLED} bits set to indicate that the connection cannot be
378 * downgraded from a video call back to a VideoState of
379 * {@link VideoProfile#STATE_AUDIO_ONLY}.
380 * <p>
381 * Intuitively, a call which can be downgraded to audio should also have local and remote
382 * video
383 * capabilities (see {@link #CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL} and
384 * {@link #CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL}).
385 */
386 public static final int CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO = 0x00800000;
387
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700388 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700389 * When set for an external connection, indicates that this {@code Connection} can be pulled
390 * from a remote device to the current device.
391 * <p>
392 * Should only be set on a {@code Connection} where {@link #PROPERTY_IS_EXTERNAL_CALL}
393 * is set.
394 */
395 public static final int CAPABILITY_CAN_PULL_CALL = 0x01000000;
396
Pooja Jaind34698d2017-12-28 14:15:31 +0530397 /** Call supports the deflect feature. */
398 public static final int CAPABILITY_SUPPORT_DEFLECT = 0x02000000;
399
Ravi Paluri404babb2020-01-23 19:02:44 +0530400 /**
401 * When set, indicates that this {@link Connection} supports initiation of a conference call
Grace Jia8587ee52020-07-10 15:42:32 -0700402 * by directly adding participants using {@link #onAddConferenceParticipants(List)}. When
403 * participants are added to a {@link Connection}, it will be replaced by a {@link Conference}
404 * instance with {@link #PROPERTY_IS_ADHOC_CONFERENCE} set to indicate that it is an adhoc
405 * conference call.
Ravi Paluri404babb2020-01-23 19:02:44 +0530406 */
407 public static final int CAPABILITY_ADD_PARTICIPANT = 0x04000000;
Ravi Palurif4b38e72020-02-05 12:35:41 +0530408
409 /**
410 * Indicates that this {@code Connection} can be transferred to another
411 * number.
Tyler Gunn460360d2020-07-29 10:21:45 -0700412 * Connection supports the confirmed and unconfirmed call transfer feature.
Ravi Palurif4b38e72020-02-05 12:35:41 +0530413 * @hide
414 */
415 public static final int CAPABILITY_TRANSFER = 0x08000000;
416
417 /**
418 * Indicates that this {@code Connection} can be transferred to another
419 * ongoing {@code Connection}.
420 * Connection supports the consultative call transfer feature.
421 * @hide
422 */
423 public static final int CAPABILITY_TRANSFER_CONSULTATIVE = 0x10000000;
424
Alvin Dey2f37d772018-05-18 23:16:10 +0530425 /**
426 * Indicates whether the remote party supports RTT or not to the UI.
427 */
428
429 public static final int CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT = 0x20000000;
430
Tyler Gunn720c6642016-03-22 09:02:47 -0700431 //**********************************************************************************************
Alvin Dey2f37d772018-05-18 23:16:10 +0530432 // Next CAPABILITY value: 0x40000000
Tyler Gunn720c6642016-03-22 09:02:47 -0700433 //**********************************************************************************************
434
435 /**
436 * Indicates that the current device callback number should be shown.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700437 * <p>
438 * Supports Telephony calls where CDMA emergency callback mode is active.
Tyler Gunn720c6642016-03-22 09:02:47 -0700439 * @hide
440 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700441 @SystemApi
Hall Liu25c7c4d2016-08-30 13:41:02 -0700442 public static final int PROPERTY_EMERGENCY_CALLBACK_MODE = 1<<0;
Tyler Gunn720c6642016-03-22 09:02:47 -0700443
444 /**
445 * Whether the call is a generic conference, where we do not know the precise state of
446 * participants in the conference (eg. on CDMA).
Tyler Gunnc63f9082019-10-15 13:19:26 -0700447 * <p>
448 * Supports legacy telephony CDMA calls.
Tyler Gunn720c6642016-03-22 09:02:47 -0700449 * @hide
450 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700451 @SystemApi
Tyler Gunn720c6642016-03-22 09:02:47 -0700452 public static final int PROPERTY_GENERIC_CONFERENCE = 1<<1;
453
454 /**
455 * Connection is using high definition audio.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700456 * <p>
457 * Indicates that the {@link Connection} is using a "high definition" audio codec. This usually
458 * implies something like AMR wideband, but the interpretation of when a call is considered high
459 * definition is left to the {@link ConnectionService} to decide.
460 * <p>
461 * Translates to {@link android.telecom.Call.Details#PROPERTY_HIGH_DEF_AUDIO}.
Tyler Gunn720c6642016-03-22 09:02:47 -0700462 */
463 public static final int PROPERTY_HIGH_DEF_AUDIO = 1<<2;
464
465 /**
466 * Connection is using WIFI.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700467 * <p>
468 * Used to indicate that a call is taking place over WIFI versus a carrier network.
469 * <p>
470 * Translates to {@link android.telecom.Call.Details#PROPERTY_WIFI}.
Tyler Gunn720c6642016-03-22 09:02:47 -0700471 */
472 public static final int PROPERTY_WIFI = 1<<3;
473
474 /**
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700475 * When set, indicates that the {@code Connection} does not actually exist locally for the
476 * {@link ConnectionService}.
477 * <p>
478 * Consider, for example, a scenario where a user has two devices with the same phone number.
479 * When a user places a call on one devices, the telephony stack can represent that call on the
480 * other device by adding is to the {@link ConnectionService} with the
Tyler Gunn720c6642016-03-22 09:02:47 -0700481 * {@link #PROPERTY_IS_EXTERNAL_CALL} capability set.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700482 * <p>
483 * An {@link ConnectionService} should not assume that all {@link InCallService}s will handle
484 * external connections. Only those {@link InCallService}s which have the
485 * {@link TelecomManager#METADATA_INCLUDE_EXTERNAL_CALLS} metadata set to {@code true} in its
486 * manifest will see external connections.
487 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700488 public static final int PROPERTY_IS_EXTERNAL_CALL = 1<<4;
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700489
Brad Ebinger15847072016-05-18 11:08:36 -0700490 /**
491 * Indicates that the connection has CDMA Enhanced Voice Privacy enabled.
492 */
493 public static final int PROPERTY_HAS_CDMA_VOICE_PRIVACY = 1<<5;
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700494
Hall Liu9f332c72016-07-14 15:37:37 -0700495 /**
496 * Indicates that the connection represents a downgraded IMS conference.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700497 * <p>
498 * This property is set when an IMS conference undergoes SRVCC and is re-added to Telecom as a
499 * new entity to indicate that the new connection was a conference.
Hall Liu9f332c72016-07-14 15:37:37 -0700500 * @hide
501 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700502 @SystemApi
Hall Liu9f332c72016-07-14 15:37:37 -0700503 public static final int PROPERTY_IS_DOWNGRADED_CONFERENCE = 1<<6;
504
Tyler Gunnf5035432017-01-09 09:43:12 -0800505 /**
506 * Set by the framework to indicate that the {@link Connection} originated from a self-managed
507 * {@link ConnectionService}.
508 * <p>
509 * See {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.
510 */
511 public static final int PROPERTY_SELF_MANAGED = 1<<7;
512
Hall Liu95d55872017-01-25 17:12:49 -0800513 /**
Hall Liuffa4a812017-03-02 16:11:00 -0800514 * Set by the framework to indicate that a connection has an active RTT session associated with
515 * it.
Hall Liu95d55872017-01-25 17:12:49 -0800516 */
517 public static final int PROPERTY_IS_RTT = 1 << 8;
518
Eric Erfanian62706c52017-12-06 16:27:53 -0800519 /**
520 * Set by the framework to indicate that a connection is using assisted dialing.
Tyler Gunn5567d742019-10-31 13:04:37 -0700521 * <p>
522 * This is used for outgoing calls.
523 *
524 * @see TelecomManager#EXTRA_USE_ASSISTED_DIALING
Eric Erfanian62706c52017-12-06 16:27:53 -0800525 */
Tyler Gunnc9503d62020-01-27 10:30:51 -0800526 public static final int PROPERTY_ASSISTED_DIALING = 1 << 9;
Eric Erfanian62706c52017-12-06 16:27:53 -0800527
Tyler Gunn5bd90852018-09-21 09:37:07 -0700528 /**
529 * Set by the framework to indicate that the network has identified a Connection as an emergency
530 * call.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700531 * <p>
532 * This is used for incoming (mobile-terminated) calls to indicate the call is from emergency
533 * services.
Tyler Gunn5bd90852018-09-21 09:37:07 -0700534 */
535 public static final int PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL = 1 << 10;
536
Tyler Gunnac60f952019-05-31 07:23:16 -0700537 /**
538 * Set by the framework to indicate that a Conference or Connection is hosted by a device other
539 * than the current one. Used in scenarios where the conference originator is the remote device
540 * and the current device is a participant of that conference.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700541 * <p>
542 * This property is specific to IMS conference calls originating in Telephony.
Tyler Gunnac60f952019-05-31 07:23:16 -0700543 * @hide
544 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700545 @SystemApi
Tyler Gunnac60f952019-05-31 07:23:16 -0700546 public static final int PROPERTY_REMOTELY_HOSTED = 1 << 11;
547
Ravi Paluri80aa2142019-12-02 11:57:37 +0530548 /**
Grace Jia8587ee52020-07-10 15:42:32 -0700549 * Set by the framework to indicate that a call is an adhoc conference call.
Ravi Paluri80aa2142019-12-02 11:57:37 +0530550 * <p>
Grace Jia8587ee52020-07-10 15:42:32 -0700551 * This is used for outgoing and incoming conference calls.
Ravi Paluri80aa2142019-12-02 11:57:37 +0530552 */
553 public static final int PROPERTY_IS_ADHOC_CONFERENCE = 1 << 12;
554
Sooraj Sasindran64f05b12020-11-18 12:07:10 -0800555 /**
556 * Connection is using cross sim technology.
557 * <p>
558 * Indicates that the {@link Connection} is using a cross sim technology which would
559 * register IMS over internet APN of default data subscription.
560 * <p>
561 */
562 public static final int PROPERTY_CROSS_SIM = 1 << 13;
Ravi Paluri80aa2142019-12-02 11:57:37 +0530563
Grace Jia22c8b962021-10-28 17:04:29 -0700564 /**
565 * Connection is a tethered external call.
566 * <p>
567 * Indicates that the {@link Connection} is fixed on this device but the audio streams are
568 * re-routed to another device.
569 * <p>
570 */
571 public static final int PROPERTY_TETHERED_CALL = 1 << 14;
572
Tyler Gunn96d6c402015-03-18 12:39:23 -0700573 //**********************************************************************************************
Sooraj Sasindran64f05b12020-11-18 12:07:10 -0800574 // Next PROPERTY value: 1<<14
Tyler Gunn96d6c402015-03-18 12:39:23 -0700575 //**********************************************************************************************
Tyler Gunn068085b2015-02-06 13:56:52 -0800576
Tyler Gunn335ff2e2015-07-30 14:18:33 -0700577 /**
Tyler Gunn1c687622019-12-20 11:08:13 -0800578 * Indicates that the audio codec is currently not specified or is unknown.
allenwtsu2aca9892019-11-25 14:38:21 +0800579 */
allenwtsu2aca9892019-11-25 14:38:21 +0800580 public static final int AUDIO_CODEC_NONE = ImsStreamMediaProfile.AUDIO_QUALITY_NONE; // 0
Tyler Gunn1c687622019-12-20 11:08:13 -0800581 /**
582 * Adaptive Multi-rate audio codec.
583 */
allenwtsu2aca9892019-11-25 14:38:21 +0800584 public static final int AUDIO_CODEC_AMR = ImsStreamMediaProfile.AUDIO_QUALITY_AMR; // 1
Tyler Gunn1c687622019-12-20 11:08:13 -0800585 /**
586 * Adaptive Multi-rate wideband audio codec.
587 */
allenwtsu2aca9892019-11-25 14:38:21 +0800588 public static final int AUDIO_CODEC_AMR_WB = ImsStreamMediaProfile.AUDIO_QUALITY_AMR_WB; // 2
Tyler Gunn1c687622019-12-20 11:08:13 -0800589 /**
590 * Qualcomm code-excited linear prediction 13 kilobit audio codec.
591 */
allenwtsu2aca9892019-11-25 14:38:21 +0800592 public static final int AUDIO_CODEC_QCELP13K = ImsStreamMediaProfile.AUDIO_QUALITY_QCELP13K; //3
Tyler Gunn1c687622019-12-20 11:08:13 -0800593 /**
594 * Enhanced Variable Rate Codec. See 3GPP2 C.S0014-A.
595 */
allenwtsu2aca9892019-11-25 14:38:21 +0800596 public static final int AUDIO_CODEC_EVRC = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC; // 4
Tyler Gunn1c687622019-12-20 11:08:13 -0800597 /**
598 * Enhanced Variable Rate Codec B. Commonly used on CDMA networks.
599 */
allenwtsu2aca9892019-11-25 14:38:21 +0800600 public static final int AUDIO_CODEC_EVRC_B = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_B; // 5
Tyler Gunn1c687622019-12-20 11:08:13 -0800601 /**
602 * Enhanced Variable Rate Wideband Codec. See RFC5188.
603 */
allenwtsu2aca9892019-11-25 14:38:21 +0800604 public static final int AUDIO_CODEC_EVRC_WB = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_WB; // 6
Tyler Gunn1c687622019-12-20 11:08:13 -0800605 /**
606 * Enhanced Variable Rate Narrowband-Wideband Codec.
607 */
allenwtsu2aca9892019-11-25 14:38:21 +0800608 public static final int AUDIO_CODEC_EVRC_NW = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_NW; // 7
Tyler Gunn1c687622019-12-20 11:08:13 -0800609 /**
610 * GSM Enhanced Full-Rate audio codec, also known as GSM-EFR, GSM 06.60, or simply EFR.
611 */
allenwtsu2aca9892019-11-25 14:38:21 +0800612 public static final int AUDIO_CODEC_GSM_EFR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_EFR; // 8
Tyler Gunn1c687622019-12-20 11:08:13 -0800613 /**
614 * GSM Full-Rate audio codec, also known as GSM-FR, GSM 06.10, GSM, or simply FR.
615 */
allenwtsu2aca9892019-11-25 14:38:21 +0800616 public static final int AUDIO_CODEC_GSM_FR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_FR; // 9
Tyler Gunn1c687622019-12-20 11:08:13 -0800617 /**
618 * GSM Half Rate audio codec.
619 */
allenwtsu2aca9892019-11-25 14:38:21 +0800620 public static final int AUDIO_CODEC_GSM_HR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_HR; // 10
Tyler Gunn1c687622019-12-20 11:08:13 -0800621 /**
622 * ITU-T G711U audio codec.
623 */
allenwtsu2aca9892019-11-25 14:38:21 +0800624 public static final int AUDIO_CODEC_G711U = ImsStreamMediaProfile.AUDIO_QUALITY_G711U; // 11
Tyler Gunn1c687622019-12-20 11:08:13 -0800625 /**
626 * ITU-T G723 audio codec.
627 */
allenwtsu2aca9892019-11-25 14:38:21 +0800628 public static final int AUDIO_CODEC_G723 = ImsStreamMediaProfile.AUDIO_QUALITY_G723; // 12
Tyler Gunn1c687622019-12-20 11:08:13 -0800629 /**
630 * ITU-T G711A audio codec.
631 */
allenwtsu2aca9892019-11-25 14:38:21 +0800632 public static final int AUDIO_CODEC_G711A = ImsStreamMediaProfile.AUDIO_QUALITY_G711A; // 13
Tyler Gunn1c687622019-12-20 11:08:13 -0800633 /**
634 * ITU-T G722 audio codec.
635 */
allenwtsu2aca9892019-11-25 14:38:21 +0800636 public static final int AUDIO_CODEC_G722 = ImsStreamMediaProfile.AUDIO_QUALITY_G722; // 14
Tyler Gunn1c687622019-12-20 11:08:13 -0800637 /**
638 * ITU-T G711AB audio codec.
639 */
allenwtsu2aca9892019-11-25 14:38:21 +0800640 public static final int AUDIO_CODEC_G711AB = ImsStreamMediaProfile.AUDIO_QUALITY_G711AB; // 15
Tyler Gunn1c687622019-12-20 11:08:13 -0800641 /**
642 * ITU-T G729 audio codec.
643 */
allenwtsu2aca9892019-11-25 14:38:21 +0800644 public static final int AUDIO_CODEC_G729 = ImsStreamMediaProfile.AUDIO_QUALITY_G729; // 16
Tyler Gunn1c687622019-12-20 11:08:13 -0800645 /**
646 * Enhanced Voice Services Narrowband audio codec. See 3GPP TS 26.441.
647 */
allenwtsu2aca9892019-11-25 14:38:21 +0800648 public static final int AUDIO_CODEC_EVS_NB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_NB; // 17
Tyler Gunn1c687622019-12-20 11:08:13 -0800649 /**
650 * Enhanced Voice Services Wideband audio codec. See 3GPP TS 26.441.
651 */
allenwtsu2aca9892019-11-25 14:38:21 +0800652 public static final int AUDIO_CODEC_EVS_WB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_WB; // 18
Tyler Gunn1c687622019-12-20 11:08:13 -0800653 /**
654 * Enhanced Voice Services Super-Wideband audio codec. See 3GPP TS 26.441.
655 */
allenwtsu2aca9892019-11-25 14:38:21 +0800656 public static final int AUDIO_CODEC_EVS_SWB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_SWB; // 19
Tyler Gunn1c687622019-12-20 11:08:13 -0800657 /**
658 * Enhanced Voice Services Fullband audio codec. See 3GPP TS 26.441.
659 */
allenwtsu2aca9892019-11-25 14:38:21 +0800660 public static final int AUDIO_CODEC_EVS_FB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_FB; // 20
661
Tyler Gunn1c687622019-12-20 11:08:13 -0800662 /**@hide*/
663 @Retention(RetentionPolicy.SOURCE)
664 @IntDef(prefix = "AUDIO_CODEC_", value = {
665 AUDIO_CODEC_NONE,
666 AUDIO_CODEC_AMR,
667 AUDIO_CODEC_AMR_WB,
668 AUDIO_CODEC_QCELP13K,
669 AUDIO_CODEC_EVRC,
670 AUDIO_CODEC_EVRC_B,
671 AUDIO_CODEC_EVRC_WB,
672 AUDIO_CODEC_EVRC_NW,
673 AUDIO_CODEC_GSM_EFR,
674 AUDIO_CODEC_GSM_FR,
675 AUDIO_CODEC_GSM_HR,
676 AUDIO_CODEC_G711U,
677 AUDIO_CODEC_G723,
678 AUDIO_CODEC_G711A,
679 AUDIO_CODEC_G722,
680 AUDIO_CODEC_G711AB,
681 AUDIO_CODEC_G729,
682 AUDIO_CODEC_EVS_NB,
683 AUDIO_CODEC_EVS_SWB,
684 AUDIO_CODEC_EVS_FB
685 })
686 public @interface AudioCodec {}
687
allenwtsu2aca9892019-11-25 14:38:21 +0800688 /**
Tyler Gunn60e5eb62021-07-01 16:55:32 -0700689 * Contains the same value as {@link #getCallerNumberVerificationStatus()}, except will be
690 * present in the {@link #getExtras()} using this key.
691 * @hide
692 */
693 public static final String EXTRA_CALLER_NUMBER_VERIFICATION_STATUS =
694 "android.telecom.extra.CALLER_NUMBER_VERIFICATION_STATUS";
695
696 /**
Tyler Gunn335ff2e2015-07-30 14:18:33 -0700697 * Connection extra key used to store the last forwarded number associated with the current
698 * connection. Used to communicate to the user interface that the connection was forwarded via
699 * the specified number.
700 */
701 public static final String EXTRA_LAST_FORWARDED_NUMBER =
702 "android.telecom.extra.LAST_FORWARDED_NUMBER";
703
704 /**
705 * Connection extra key used to store a child number associated with the current connection.
706 * Used to communicate to the user interface that the connection was received via
707 * a child address (i.e. phone number) associated with the {@link PhoneAccount}'s primary
708 * address.
709 */
710 public static final String EXTRA_CHILD_ADDRESS = "android.telecom.extra.CHILD_ADDRESS";
711
712 /**
713 * Connection extra key used to store the subject for an incoming call. The user interface can
714 * query this extra and display its contents for incoming calls. Will only be used if the
715 * {@link PhoneAccount} supports the capability {@link PhoneAccount#CAPABILITY_CALL_SUBJECT}.
716 */
717 public static final String EXTRA_CALL_SUBJECT = "android.telecom.extra.CALL_SUBJECT";
718
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800719 /**
Tyler Gunn4b6614e2016-06-22 10:35:13 -0700720 * Boolean connection extra key set on a {@link Connection} in
721 * {@link Connection#STATE_RINGING} state to indicate that answering the call will cause the
722 * current active foreground call to be dropped.
723 */
724 public static final String EXTRA_ANSWERING_DROPS_FG_CALL =
725 "android.telecom.extra.ANSWERING_DROPS_FG_CALL";
726
727 /**
Tyler Gunn37653562017-03-13 18:15:15 -0700728 * String connection extra key set on a {@link Connection} in {@link Connection#STATE_RINGING}
729 * state to indicate the name of the third-party app which is responsible for the current
730 * foreground call.
731 * <p>
732 * Used when {@link #EXTRA_ANSWERING_DROPS_FG_CALL} is true to ensure that the default Phone app
733 * is able to inform the user that answering the new incoming call will cause a call owned by
734 * another app to be dropped when the incoming call is answered.
735 */
736 public static final String EXTRA_ANSWERING_DROPS_FG_CALL_APP_NAME =
737 "android.telecom.extra.ANSWERING_DROPS_FG_CALL_APP_NAME";
738
739 /**
Hall Liu10208662016-06-15 17:55:00 -0700740 * Boolean connection extra key on a {@link Connection} which indicates that adding an
Hall Liuee6e86b2016-07-06 16:32:43 -0700741 * additional call is disallowed.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700742 * <p>
743 * Used for mobile-network calls to identify scenarios where carrier requirements preclude
744 * adding another call at the current time.
Hall Liu10208662016-06-15 17:55:00 -0700745 * @hide
746 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700747 @SystemApi
Hall Liuee6e86b2016-07-06 16:32:43 -0700748 public static final String EXTRA_DISABLE_ADD_CALL =
749 "android.telecom.extra.DISABLE_ADD_CALL";
Hall Liu10208662016-06-15 17:55:00 -0700750
751 /**
Tyler Gunncd6ccfd2016-10-17 15:48:19 -0700752 * String connection extra key on a {@link Connection} or {@link Conference} which contains the
753 * original Connection ID associated with the connection. Used in
754 * {@link RemoteConnectionService} to track the Connection ID which was originally assigned to a
755 * connection/conference added via
756 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)} and
757 * {@link ConnectionService#addConference(Conference)} APIs. This is important to pass to
758 * Telecom for when it deals with RemoteConnections. When the ConnectionManager wraps the
759 * {@link RemoteConnection} and {@link RemoteConference} and adds it to Telecom, there needs to
760 * be a way to ensure that we don't add the connection again as a duplicate.
761 * <p>
762 * For example, the TelephonyCS calls addExistingConnection for a Connection with ID
763 * {@code TelephonyCS@1}. The ConnectionManager learns of this via
764 * {@link ConnectionService#onRemoteExistingConnectionAdded(RemoteConnection)}, and wraps this
765 * in a new {@link Connection} which it adds to Telecom via
766 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)}. As part of
767 * this process, the wrapped RemoteConnection gets assigned a new ID (e.g. {@code ConnMan@1}).
768 * The TelephonyCS will ALSO try to add the existing connection to Telecom, except with the
769 * ID it originally referred to the connection as. Thus Telecom needs to know that the
770 * Connection with ID {@code ConnMan@1} is really the same as {@code TelephonyCS@1}.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700771 * <p>
772 * This is an internal Telecom framework concept and is not exposed outside of the Telecom
773 * framework.
Tyler Gunncd6ccfd2016-10-17 15:48:19 -0700774 * @hide
775 */
776 public static final String EXTRA_ORIGINAL_CONNECTION_ID =
777 "android.telecom.extra.ORIGINAL_CONNECTION_ID";
778
779 /**
Tyler Gunnc59fd0c2020-04-17 14:03:35 -0700780 * Extra key set on a {@link Connection} when it was created via a remote connection service.
781 * For example, if a connection manager requests a remote connection service to create a call
782 * using one of the remote connection service's phone account handle, this extra will be set so
783 * that Telecom knows that the wrapped remote connection originated in a remote connection
784 * service. We stash this in the extras since connection managers will typically copy the
785 * extras from a {@link RemoteConnection} to a {@link Connection} (there is ultimately not
786 * other way to relate a {@link RemoteConnection} to a {@link Connection}.
787 * @hide
788 */
789 public static final String EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE =
790 "android.telecom.extra.REMOTE_PHONE_ACCOUNT_HANDLE";
791
792 /**
Tyler Gunnfdc4bff2021-06-24 11:25:07 -0700793 * The Telecom call ID of the conference an existing connection should be added to. This is
794 * required when {@link com.android.services.telephony.TelephonyConnectionService} adds a
795 * {@link Conference} to Telecom using the
796 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection, Conference)}
797 * API. That API specifies a parent conference associated with the new existing connection
798 * being added, and there is no equivalent as part of the {@link RemoteConnectionService} API.
799 * This extra key is used to stack the ID of the conference to which the existing connection
800 * will be added so that Telecom can link it up correctly when the {@link RemoteConference}
801 * is added to Telecom by the connection manager.
802 * @hide
803 */
804 public static final String EXTRA_ADD_TO_CONFERENCE_ID =
805 "android.telecom.extra.ADD_TO_CONFERENCE_ID";
806
807 /**
Tyler Gunnc59fd0c2020-04-17 14:03:35 -0700808 * Extra key set from a {@link ConnectionService} when using the remote connection APIs
809 * (e.g. {@link RemoteConnectionService#createRemoteConnection(PhoneAccountHandle,
810 * ConnectionRequest, boolean)}) to create a remote connection. Provides the receiving
811 * {@link ConnectionService} with a means to know the package name of the requesting
812 * {@link ConnectionService} so that {@link #EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE} can be set for
813 * better visibility in Telecom of where a connection ultimately originated.
814 * @hide
815 */
816 public static final String EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME =
817 "android.telecom.extra.REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME";
818
819 /**
Wileen Chiuf2ec2982018-07-01 14:21:50 -0700820 * Boolean connection extra key set on the extras passed to
821 * {@link Connection#sendConnectionEvent} which indicates that audio is present
822 * on the RTT call when the extra value is true.
823 */
824 public static final String EXTRA_IS_RTT_AUDIO_PRESENT =
825 "android.telecom.extra.IS_RTT_AUDIO_PRESENT";
826
827 /**
Tyler Gunn1c687622019-12-20 11:08:13 -0800828 * The audio codec in use for the current {@link Connection}, if known. Examples of valid
829 * values include {@link #AUDIO_CODEC_AMR_WB} and {@link #AUDIO_CODEC_EVS_WB}.
allenwtsu2aca9892019-11-25 14:38:21 +0800830 */
Tyler Gunn1c687622019-12-20 11:08:13 -0800831 public static final @AudioCodec String EXTRA_AUDIO_CODEC =
allenwtsu2aca9892019-11-25 14:38:21 +0800832 "android.telecom.extra.AUDIO_CODEC";
833
834 /**
allenwtsu6ec972a2020-11-10 17:32:46 +0800835 * Float connection extra key used to store the audio codec bitrate in kbps for the current
836 * {@link Connection}.
837 */
838 public static final String EXTRA_AUDIO_CODEC_BITRATE_KBPS =
839 "android.telecom.extra.AUDIO_CODEC_BITRATE_KBPS";
840
841 /**
842 * Float connection extra key used to store the audio codec bandwidth in khz for the current
843 * {@link Connection}.
844 */
845 public static final String EXTRA_AUDIO_CODEC_BANDWIDTH_KHZ =
846 "android.telecom.extra.AUDIO_CODEC_BANDWIDTH_KHZ";
Tyler Gunn78a59ff2021-05-07 16:41:19 -0700847
848 /**
849 * Boolean connection extra key used to indicate whether device to device communication is
850 * available for the current call.
851 * @hide
852 */
853 public static final String EXTRA_IS_DEVICE_TO_DEVICE_COMMUNICATION_AVAILABLE =
854 "android.telecom.extra.IS_DEVICE_TO_DEVICE_COMMUNICATION_AVAILABLE";
855
allenwtsu6ec972a2020-11-10 17:32:46 +0800856 /**
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800857 * Connection event used to inform Telecom that it should play the on hold tone. This is used
858 * to play a tone when the peer puts the current call on hold. Sent to Telecom via
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700859 * {@link #sendConnectionEvent(String, Bundle)}.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800860 */
861 public static final String EVENT_ON_HOLD_TONE_START =
862 "android.telecom.event.ON_HOLD_TONE_START";
863
864 /**
865 * Connection event used to inform Telecom that it should stop the on hold tone. This is used
866 * to stop a tone when the peer puts the current call on hold. Sent to Telecom via
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700867 * {@link #sendConnectionEvent(String, Bundle)}.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800868 */
869 public static final String EVENT_ON_HOLD_TONE_END =
870 "android.telecom.event.ON_HOLD_TONE_END";
871
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700872 /**
873 * Connection event used to inform {@link InCallService}s when pulling of an external call has
874 * failed. The user interface should inform the user of the error.
875 * <p>
876 * Expected to be used by the {@link ConnectionService} when the {@link Call#pullExternalCall()}
877 * API is called on a {@link Call} with the properties
878 * {@link Call.Details#PROPERTY_IS_EXTERNAL_CALL} and
879 * {@link Call.Details#CAPABILITY_CAN_PULL_CALL}, but the {@link ConnectionService} could not
880 * pull the external call due to an error condition.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700881 * <p>
882 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
883 * expected to be null when this connection event is used.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700884 */
885 public static final String EVENT_CALL_PULL_FAILED = "android.telecom.event.CALL_PULL_FAILED";
886
Brad Ebinger2c1c16452016-05-27 15:58:10 -0700887 /**
888 * Connection event used to inform {@link InCallService}s when the merging of two calls has
889 * failed. The User Interface should use this message to inform the user of the error.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700890 * <p>
891 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
892 * expected to be null when this connection event is used.
Brad Ebinger2c1c16452016-05-27 15:58:10 -0700893 */
894 public static final String EVENT_CALL_MERGE_FAILED = "android.telecom.event.CALL_MERGE_FAILED";
895
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700896 /**
Hall Liu06ae75b2019-03-11 19:11:35 -0700897 * Connection event used to inform Telecom when a hold operation on a call has failed.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700898 * <p>
Hall Liu06ae75b2019-03-11 19:11:35 -0700899 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
900 * expected to be null when this connection event is used.
Hall Liu06ae75b2019-03-11 19:11:35 -0700901 */
902 public static final String EVENT_CALL_HOLD_FAILED = "android.telecom.event.CALL_HOLD_FAILED";
903
904 /**
Masaho Nishikawacb8fa742019-11-07 14:41:21 +0900905 * Connection event used to inform Telecom when a switch operation on a call has failed.
906 * <p>
907 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
908 * expected to be null when this connection event is used.
909 */
910 public static final String EVENT_CALL_SWITCH_FAILED =
911 "android.telecom.event.CALL_SWITCH_FAILED";
912
913 /**
Tyler Gunn78da7812017-05-09 14:34:57 -0700914 * Connection event used to inform {@link InCallService}s when the process of merging a
915 * Connection into a conference has begun.
916 * <p>
917 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
918 * expected to be null when this connection event is used.
Tyler Gunn78da7812017-05-09 14:34:57 -0700919 */
920 public static final String EVENT_MERGE_START = "android.telecom.event.MERGE_START";
921
922 /**
923 * Connection event used to inform {@link InCallService}s when the process of merging a
924 * Connection into a conference has completed.
925 * <p>
926 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
927 * expected to be null when this connection event is used.
Tyler Gunn78da7812017-05-09 14:34:57 -0700928 */
929 public static final String EVENT_MERGE_COMPLETE = "android.telecom.event.MERGE_COMPLETE";
930
931 /**
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700932 * Connection event used to inform {@link InCallService}s when a call has been put on hold by
933 * the remote party.
934 * <p>
935 * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the
936 * call is being held locally on the device. When a capable {@link ConnectionService} receives
937 * signalling to indicate that the remote party has put the call on hold, it can send this
938 * connection event.
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700939 */
940 public static final String EVENT_CALL_REMOTELY_HELD =
941 "android.telecom.event.CALL_REMOTELY_HELD";
942
943 /**
944 * Connection event used to inform {@link InCallService}s when a call which was remotely held
945 * (see {@link #EVENT_CALL_REMOTELY_HELD}) has been un-held by the remote party.
946 * <p>
947 * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the
948 * call is being held locally on the device. When a capable {@link ConnectionService} receives
949 * signalling to indicate that the remote party has taken the call off hold, it can send this
950 * connection event.
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700951 */
952 public static final String EVENT_CALL_REMOTELY_UNHELD =
953 "android.telecom.event.CALL_REMOTELY_UNHELD";
954
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700955 /**
956 * Connection event used to inform an {@link InCallService} which initiated a call handover via
957 * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has
958 * successfully completed.
959 * @hide
Tyler Gunn1a505fa2018-09-14 13:36:38 -0700960 * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated
961 * APIs instead.
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700962 */
963 public static final String EVENT_HANDOVER_COMPLETE =
964 "android.telecom.event.HANDOVER_COMPLETE";
965
966 /**
967 * Connection event used to inform an {@link InCallService} which initiated a call handover via
968 * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has failed
969 * to complete.
970 * @hide
Tyler Gunn1a505fa2018-09-14 13:36:38 -0700971 * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated
972 * APIs instead.
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700973 */
974 public static final String EVENT_HANDOVER_FAILED =
975 "android.telecom.event.HANDOVER_FAILED";
976
shilub7ec9a02018-11-09 15:52:04 -0800977 /**
Shi Lu528eb5b2019-02-08 05:09:11 +0000978 * String Connection extra key used to store SIP invite fields for an incoming call for IMS call
shilub7ec9a02018-11-09 15:52:04 -0800979 */
980 public static final String EXTRA_SIP_INVITE = "android.telecom.extra.SIP_INVITE";
981
Wileen Chiuf2ec2982018-07-01 14:21:50 -0700982 /**
983 * Connection event used to inform an {@link InCallService} that the RTT audio indication
984 * has changed.
985 */
986 public static final String EVENT_RTT_AUDIO_INDICATION_CHANGED =
987 "android.telecom.event.RTT_AUDIO_INDICATION_CHANGED";
988
Tyler Gunnd5821842021-02-05 11:12:57 -0800989 /**
990 * Connection event used to signal between the telephony {@link ConnectionService} and Telecom
991 * when device to device messages are sent/received.
992 * <p>
993 * Device to device messages originating from the network are sent by telephony using
994 * {@link Connection#sendConnectionEvent(String, Bundle)} and are routed up to any active
995 * {@link CallDiagnosticService} implementation which is active.
996 * <p>
997 * Likewise, if a {@link CallDiagnosticService} sends a message using
Tyler Gunn066de602021-03-16 09:58:07 -0700998 * {@link CallDiagnostics#sendDeviceToDeviceMessage(int, int)}, it will be routed to telephony
Tyler Gunnd5821842021-02-05 11:12:57 -0800999 * via {@link Connection#onCallEvent(String, Bundle)}. The telephony stack will relay the
1000 * message to the other device.
1001 * @hide
1002 */
1003 @SystemApi
1004 public static final String EVENT_DEVICE_TO_DEVICE_MESSAGE =
1005 "android.telecom.event.DEVICE_TO_DEVICE_MESSAGE";
1006
1007 /**
1008 * Sent along with {@link #EVENT_DEVICE_TO_DEVICE_MESSAGE} to indicate the device to device
1009 * message type.
1010 *
Tyler Gunn066de602021-03-16 09:58:07 -07001011 * See {@link CallDiagnostics} for more information.
Tyler Gunnd5821842021-02-05 11:12:57 -08001012 * @hide
1013 */
1014 @SystemApi
1015 public static final String EXTRA_DEVICE_TO_DEVICE_MESSAGE_TYPE =
1016 "android.telecom.extra.DEVICE_TO_DEVICE_MESSAGE_TYPE";
1017
1018 /**
1019 * Sent along with {@link #EVENT_DEVICE_TO_DEVICE_MESSAGE} to indicate the device to device
1020 * message value.
1021 * <p>
Tyler Gunn066de602021-03-16 09:58:07 -07001022 * See {@link CallDiagnostics} for more information.
Tyler Gunnd5821842021-02-05 11:12:57 -08001023 * @hide
1024 */
1025 @SystemApi
1026 public static final String EXTRA_DEVICE_TO_DEVICE_MESSAGE_VALUE =
1027 "android.telecom.extra.DEVICE_TO_DEVICE_MESSAGE_VALUE";
1028
Tyler Gunn0a1c6d12021-03-12 15:44:08 -08001029 /**
1030 * Connection event used to communicate a {@link android.telephony.CallQuality} report from
1031 * telephony to Telecom for relaying to
1032 * {@link DiagnosticCall#onCallQualityReceived(CallQuality)}.
1033 * @hide
1034 */
1035 public static final String EVENT_CALL_QUALITY_REPORT =
1036 "android.telecom.event.CALL_QUALITY_REPORT";
1037
1038 /**
1039 * Extra sent with {@link #EVENT_CALL_QUALITY_REPORT} containing the
1040 * {@link android.telephony.CallQuality} data.
1041 * @hide
1042 */
1043 public static final String EXTRA_CALL_QUALITY_REPORT =
1044 "android.telecom.extra.CALL_QUALITY_REPORT";
1045
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001046 // Flag controlling whether PII is emitted into the logs
1047 private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG);
1048
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001049 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07001050 * Renders a set of capability bits ({@code CAPABILITY_*}) as a human readable string.
1051 *
1052 * @param capabilities A capability bit field.
1053 * @return A human readable string representation.
1054 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001055 public static String capabilitiesToString(int capabilities) {
Santos Cordon1a749302016-07-26 16:08:53 -07001056 return capabilitiesToStringInternal(capabilities, true /* isLong */);
1057 }
1058
1059 /**
1060 * Renders a set of capability bits ({@code CAPABILITY_*}) as a *short* human readable
1061 * string.
1062 *
1063 * @param capabilities A capability bit field.
1064 * @return A human readable string representation.
1065 * @hide
1066 */
1067 public static String capabilitiesToStringShort(int capabilities) {
1068 return capabilitiesToStringInternal(capabilities, false /* isLong */);
1069 }
1070
1071 private static String capabilitiesToStringInternal(int capabilities, boolean isLong) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001072 StringBuilder builder = new StringBuilder();
Santos Cordon1a749302016-07-26 16:08:53 -07001073 builder.append("[");
1074 if (isLong) {
1075 builder.append("Capabilities:");
1076 }
1077
Tyler Gunnc63f9082019-10-15 13:19:26 -07001078 if ((capabilities & CAPABILITY_HOLD) == CAPABILITY_HOLD) {
Santos Cordon1a749302016-07-26 16:08:53 -07001079 builder.append(isLong ? " CAPABILITY_HOLD" : " hld");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001080 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001081 if ((capabilities & CAPABILITY_SUPPORT_HOLD) == CAPABILITY_SUPPORT_HOLD) {
Santos Cordon1a749302016-07-26 16:08:53 -07001082 builder.append(isLong ? " CAPABILITY_SUPPORT_HOLD" : " sup_hld");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001083 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001084 if ((capabilities & CAPABILITY_MERGE_CONFERENCE) == CAPABILITY_MERGE_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001085 builder.append(isLong ? " CAPABILITY_MERGE_CONFERENCE" : " mrg_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001086 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001087 if ((capabilities & CAPABILITY_SWAP_CONFERENCE) == CAPABILITY_SWAP_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001088 builder.append(isLong ? " CAPABILITY_SWAP_CONFERENCE" : " swp_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001089 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001090 if ((capabilities & CAPABILITY_RESPOND_VIA_TEXT) == CAPABILITY_RESPOND_VIA_TEXT) {
Santos Cordon1a749302016-07-26 16:08:53 -07001091 builder.append(isLong ? " CAPABILITY_RESPOND_VIA_TEXT" : " txt");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001092 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001093 if ((capabilities & CAPABILITY_MUTE) == CAPABILITY_MUTE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001094 builder.append(isLong ? " CAPABILITY_MUTE" : " mut");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001095 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001096 if ((capabilities & CAPABILITY_MANAGE_CONFERENCE) == CAPABILITY_MANAGE_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001097 builder.append(isLong ? " CAPABILITY_MANAGE_CONFERENCE" : " mng_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001098 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001099 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_RX) == CAPABILITY_SUPPORTS_VT_LOCAL_RX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001100 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_RX" : " VTlrx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001101 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001102 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_TX) == CAPABILITY_SUPPORTS_VT_LOCAL_TX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001103 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_TX" : " VTltx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001104 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001105 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL)
1106 == CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001107 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL" : " VTlbi");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001108 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001109 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_RX) == CAPABILITY_SUPPORTS_VT_REMOTE_RX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001110 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_RX" : " VTrrx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001111 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001112 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_TX) == CAPABILITY_SUPPORTS_VT_REMOTE_TX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001113 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_TX" : " VTrtx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001114 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001115 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL)
1116 == CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001117 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL" : " VTrbi");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001118 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001119 if ((capabilities & CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO)
1120 == CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001121 builder.append(isLong ? " CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO" : " !v2a");
Tyler Gunnf97a0092016-01-19 15:59:34 -08001122 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001123 if ((capabilities & CAPABILITY_SPEED_UP_MT_AUDIO) == CAPABILITY_SPEED_UP_MT_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001124 builder.append(isLong ? " CAPABILITY_SPEED_UP_MT_AUDIO" : " spd_aud");
Dong Zhou89f41eb2015-03-15 11:59:49 -05001125 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001126 if ((capabilities & CAPABILITY_CAN_UPGRADE_TO_VIDEO) == CAPABILITY_CAN_UPGRADE_TO_VIDEO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001127 builder.append(isLong ? " CAPABILITY_CAN_UPGRADE_TO_VIDEO" : " a2v");
Rekha Kumar07366812015-03-24 16:42:31 -07001128 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001129 if ((capabilities & CAPABILITY_CAN_PAUSE_VIDEO) == CAPABILITY_CAN_PAUSE_VIDEO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001130 builder.append(isLong ? " CAPABILITY_CAN_PAUSE_VIDEO" : " paus_VT");
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -07001131 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001132 if ((capabilities & CAPABILITY_CONFERENCE_HAS_NO_CHILDREN)
1133 == CAPABILITY_CONFERENCE_HAS_NO_CHILDREN) {
Santos Cordon1a749302016-07-26 16:08:53 -07001134 builder.append(isLong ? " CAPABILITY_SINGLE_PARTY_CONFERENCE" : " 1p_cnf");
Tyler Gunnd4091732015-06-29 09:15:37 -07001135 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001136 if ((capabilities & CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION)
1137 == CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION) {
Santos Cordon1a749302016-07-26 16:08:53 -07001138 builder.append(isLong ? " CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION" : " rsp_by_con");
Bryce Lee81901682015-08-28 16:38:02 -07001139 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001140 if ((capabilities & CAPABILITY_CAN_PULL_CALL) == CAPABILITY_CAN_PULL_CALL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001141 builder.append(isLong ? " CAPABILITY_CAN_PULL_CALL" : " pull");
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001142 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001143 if ((capabilities & CAPABILITY_SUPPORT_DEFLECT) == CAPABILITY_SUPPORT_DEFLECT) {
Pooja Jaind34698d2017-12-28 14:15:31 +05301144 builder.append(isLong ? " CAPABILITY_SUPPORT_DEFLECT" : " sup_def");
1145 }
Ravi Paluri404babb2020-01-23 19:02:44 +05301146 if ((capabilities & CAPABILITY_ADD_PARTICIPANT) == CAPABILITY_ADD_PARTICIPANT) {
1147 builder.append(isLong ? " CAPABILITY_ADD_PARTICIPANT" : " add_participant");
1148 }
Ravi Palurif4b38e72020-02-05 12:35:41 +05301149 if ((capabilities & CAPABILITY_TRANSFER) == CAPABILITY_TRANSFER) {
1150 builder.append(isLong ? " CAPABILITY_TRANSFER" : " sup_trans");
1151 }
1152 if ((capabilities & CAPABILITY_TRANSFER_CONSULTATIVE)
1153 == CAPABILITY_TRANSFER_CONSULTATIVE) {
1154 builder.append(isLong ? " CAPABILITY_TRANSFER_CONSULTATIVE" : " sup_cTrans");
1155 }
Alvin Dey2f37d772018-05-18 23:16:10 +05301156 if ((capabilities & CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT)
1157 == CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT) {
1158 builder.append(isLong ? " CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT" : " sup_rtt");
1159 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001160 builder.append("]");
1161 return builder.toString();
1162 }
1163
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07001164 /**
1165 * Renders a set of property bits ({@code PROPERTY_*}) as a human readable string.
1166 *
1167 * @param properties A property bit field.
1168 * @return A human readable string representation.
1169 */
Tyler Gunn720c6642016-03-22 09:02:47 -07001170 public static String propertiesToString(int properties) {
Santos Cordon1a749302016-07-26 16:08:53 -07001171 return propertiesToStringInternal(properties, true /* isLong */);
1172 }
1173
1174 /**
1175 * Renders a set of property bits ({@code PROPERTY_*}) as a *short* human readable string.
1176 *
1177 * @param properties A property bit field.
1178 * @return A human readable string representation.
1179 * @hide
1180 */
1181 public static String propertiesToStringShort(int properties) {
1182 return propertiesToStringInternal(properties, false /* isLong */);
1183 }
1184
1185 private static String propertiesToStringInternal(int properties, boolean isLong) {
Tyler Gunn720c6642016-03-22 09:02:47 -07001186 StringBuilder builder = new StringBuilder();
Santos Cordon1a749302016-07-26 16:08:53 -07001187 builder.append("[");
1188 if (isLong) {
1189 builder.append("Properties:");
1190 }
Tyler Gunn720c6642016-03-22 09:02:47 -07001191
Tyler Gunnc63f9082019-10-15 13:19:26 -07001192 if ((properties & PROPERTY_SELF_MANAGED) == PROPERTY_SELF_MANAGED) {
Tyler Gunnf5035432017-01-09 09:43:12 -08001193 builder.append(isLong ? " PROPERTY_SELF_MANAGED" : " self_mng");
1194 }
1195
Tyler Gunnc63f9082019-10-15 13:19:26 -07001196 if ((properties & PROPERTY_EMERGENCY_CALLBACK_MODE) == PROPERTY_EMERGENCY_CALLBACK_MODE) {
Hall Liu25c7c4d2016-08-30 13:41:02 -07001197 builder.append(isLong ? " PROPERTY_EMERGENCY_CALLBACK_MODE" : " ecbm");
Tyler Gunn720c6642016-03-22 09:02:47 -07001198 }
1199
Tyler Gunnc63f9082019-10-15 13:19:26 -07001200 if ((properties & PROPERTY_HIGH_DEF_AUDIO) == PROPERTY_HIGH_DEF_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001201 builder.append(isLong ? " PROPERTY_HIGH_DEF_AUDIO" : " HD");
Tyler Gunn720c6642016-03-22 09:02:47 -07001202 }
1203
Tyler Gunnc63f9082019-10-15 13:19:26 -07001204 if ((properties & PROPERTY_WIFI) == PROPERTY_WIFI) {
Santos Cordon1a749302016-07-26 16:08:53 -07001205 builder.append(isLong ? " PROPERTY_WIFI" : " wifi");
Tyler Gunn720c6642016-03-22 09:02:47 -07001206 }
1207
Tyler Gunnc63f9082019-10-15 13:19:26 -07001208 if ((properties & PROPERTY_GENERIC_CONFERENCE) == PROPERTY_GENERIC_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001209 builder.append(isLong ? " PROPERTY_GENERIC_CONFERENCE" : " gen_conf");
Tyler Gunn720c6642016-03-22 09:02:47 -07001210 }
1211
Tyler Gunnc63f9082019-10-15 13:19:26 -07001212 if ((properties & PROPERTY_IS_EXTERNAL_CALL) == PROPERTY_IS_EXTERNAL_CALL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001213 builder.append(isLong ? " PROPERTY_IS_EXTERNAL_CALL" : " xtrnl");
Tyler Gunn720c6642016-03-22 09:02:47 -07001214 }
1215
Tyler Gunnc63f9082019-10-15 13:19:26 -07001216 if ((properties & PROPERTY_HAS_CDMA_VOICE_PRIVACY) == PROPERTY_HAS_CDMA_VOICE_PRIVACY) {
Santos Cordon1a749302016-07-26 16:08:53 -07001217 builder.append(isLong ? " PROPERTY_HAS_CDMA_VOICE_PRIVACY" : " priv");
Brad Ebinger15847072016-05-18 11:08:36 -07001218 }
1219
Tyler Gunnc63f9082019-10-15 13:19:26 -07001220 if ((properties & PROPERTY_IS_RTT) == PROPERTY_IS_RTT) {
Hall Liud4d2a8a2018-01-29 17:22:02 -08001221 builder.append(isLong ? " PROPERTY_IS_RTT" : " rtt");
1222 }
1223
Tyler Gunnc63f9082019-10-15 13:19:26 -07001224 if ((properties & PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL)
1225 == PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL) {
Tyler Gunn5bd90852018-09-21 09:37:07 -07001226 builder.append(isLong ? " PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL" : " ecall");
1227 }
1228
Tyler Gunnc63f9082019-10-15 13:19:26 -07001229 if ((properties & PROPERTY_REMOTELY_HOSTED) == PROPERTY_REMOTELY_HOSTED) {
Tyler Gunnac60f952019-05-31 07:23:16 -07001230 builder.append(isLong ? " PROPERTY_REMOTELY_HOSTED" : " remote_hst");
1231 }
1232
Ravi Paluri80aa2142019-12-02 11:57:37 +05301233 if ((properties & PROPERTY_IS_ADHOC_CONFERENCE) == PROPERTY_IS_ADHOC_CONFERENCE) {
1234 builder.append(isLong ? " PROPERTY_IS_ADHOC_CONFERENCE" : " adhoc_conf");
1235 }
1236
Hall Liue0f787c2020-07-08 11:25:56 -07001237 if ((properties & PROPERTY_IS_DOWNGRADED_CONFERENCE) == PROPERTY_IS_DOWNGRADED_CONFERENCE) {
1238 builder.append(isLong ? " PROPERTY_IS_DOWNGRADED_CONFERENCE" : " dngrd_conf");
1239 }
1240
Tyler Gunn720c6642016-03-22 09:02:47 -07001241 builder.append("]");
1242 return builder.toString();
1243 }
1244
Sailesh Nepal091768c2014-06-30 15:15:23 -07001245 /** @hide */
Tyler Gunn633e4c32019-10-24 15:40:48 -07001246 abstract static class Listener {
Ihab Awad542e0ea2014-05-16 10:22:16 -07001247 public void onStateChanged(Connection c, int state) {}
Andrew Lee100e2932014-09-08 15:34:24 -07001248 public void onAddressChanged(Connection c, Uri newAddress, int presentation) {}
Sailesh Nepal61203862014-07-11 14:50:13 -07001249 public void onCallerDisplayNameChanged(
1250 Connection c, String callerDisplayName, int presentation) {}
Tyler Gunnaa07df82014-07-17 07:50:22 -07001251 public void onVideoStateChanged(Connection c, int videoState) {}
Andrew Lee7f3d41f2014-09-11 17:33:16 -07001252 public void onDisconnected(Connection c, DisconnectCause disconnectCause) {}
Sailesh Nepal091768c2014-06-30 15:15:23 -07001253 public void onPostDialWait(Connection c, String remaining) {}
Nancy Chen27d1c2d2014-12-15 16:12:50 -08001254 public void onPostDialChar(Connection c, char nextChar) {}
Andrew Lee100e2932014-09-08 15:34:24 -07001255 public void onRingbackRequested(Connection c, boolean ringback) {}
Sailesh Nepal61203862014-07-11 14:50:13 -07001256 public void onDestroyed(Connection c) {}
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001257 public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {}
Tyler Gunn720c6642016-03-22 09:02:47 -07001258 public void onConnectionPropertiesChanged(Connection c, int properties) {}
Christine Hallstrom2830ce92016-11-30 16:06:42 -08001259 public void onSupportedAudioRoutesChanged(Connection c, int supportedAudioRoutes) {}
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001260 public void onVideoProviderChanged(
1261 Connection c, VideoProvider videoProvider) {}
Sailesh Nepal001bbbb2014-07-15 14:40:39 -07001262 public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {}
1263 public void onStatusHintsChanged(Connection c, StatusHints statusHints) {}
Tyler Gunn6d76ca02014-11-17 15:49:51 -08001264 public void onConferenceablesChanged(
Tyler Gunndf2cbc82015-04-20 09:13:01 -07001265 Connection c, List<Conferenceable> conferenceables) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -07001266 public void onConferenceChanged(Connection c, Conference conference) {}
Anthony Lee17455a32015-04-24 15:25:29 -07001267 public void onConferenceMergeFailed(Connection c) {}
Santos Cordon6b7f9552015-05-27 17:21:45 -07001268 public void onExtrasChanged(Connection c, Bundle extras) {}
Tyler Gunndee56a82016-03-23 16:06:34 -07001269 public void onExtrasRemoved(Connection c, List<String> keys) {}
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001270 public void onConnectionEvent(Connection c, String event, Bundle extras) {}
Hall Liua98f58b52017-11-07 17:59:28 -08001271 public void onAudioRouteChanged(Connection c, int audioRoute, String bluetoothAddress) {}
Hall Liub64ac4c2017-02-06 10:49:48 -08001272 public void onRttInitiationSuccess(Connection c) {}
1273 public void onRttInitiationFailure(Connection c, int reason) {}
1274 public void onRttSessionRemotelyTerminated(Connection c) {}
1275 public void onRemoteRttRequest(Connection c) {}
Srikanth Chintalafcb15012017-05-04 20:58:34 +05301276 /** @hide */
1277 public void onPhoneAccountChanged(Connection c, PhoneAccountHandle pHandle) {}
Mengjun Leng25707742017-07-04 11:10:37 +08001278 public void onConnectionTimeReset(Connection c) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07001279 }
1280
Tyler Gunnb702ef82015-05-29 11:51:53 -07001281 /**
Hall Liu95d55872017-01-25 17:12:49 -08001282 * Provides methods to read and write RTT data to/from the in-call app.
Hall Liu95d55872017-01-25 17:12:49 -08001283 */
1284 public static final class RttTextStream {
1285 private static final int READ_BUFFER_SIZE = 1000;
1286 private final InputStreamReader mPipeFromInCall;
1287 private final OutputStreamWriter mPipeToInCall;
Hall Liub64ac4c2017-02-06 10:49:48 -08001288 private final ParcelFileDescriptor mFdFromInCall;
1289 private final ParcelFileDescriptor mFdToInCall;
Hall Liu17eb1bd2018-07-03 15:17:41 -07001290
1291 private final FileInputStream mFromInCallFileInputStream;
Hall Liu95d55872017-01-25 17:12:49 -08001292 private char[] mReadBuffer = new char[READ_BUFFER_SIZE];
1293
1294 /**
1295 * @hide
1296 */
1297 public RttTextStream(ParcelFileDescriptor toInCall, ParcelFileDescriptor fromInCall) {
Hall Liub64ac4c2017-02-06 10:49:48 -08001298 mFdFromInCall = fromInCall;
1299 mFdToInCall = toInCall;
Hall Liu17eb1bd2018-07-03 15:17:41 -07001300 mFromInCallFileInputStream = new FileInputStream(fromInCall.getFileDescriptor());
Hall Liu730a2592018-06-25 19:48:33 -07001301
1302 // Wrap the FileInputStream in a Channel so that it's interruptible.
Hall Liu95d55872017-01-25 17:12:49 -08001303 mPipeFromInCall = new InputStreamReader(
Hall Liu17eb1bd2018-07-03 15:17:41 -07001304 Channels.newInputStream(Channels.newChannel(mFromInCallFileInputStream)));
Hall Liu95d55872017-01-25 17:12:49 -08001305 mPipeToInCall = new OutputStreamWriter(
Hall Liua549fed2018-02-09 16:40:03 -08001306 new FileOutputStream(toInCall.getFileDescriptor()));
Hall Liu95d55872017-01-25 17:12:49 -08001307 }
1308
1309 /**
1310 * Writes the string {@param input} into the text stream to the UI for this RTT call. Since
1311 * RTT transmits text in real-time, this method should be called as often as text snippets
1312 * are received from the remote user, even if it is only one character.
Hall Liua549fed2018-02-09 16:40:03 -08001313 * <p>
Hall Liu95d55872017-01-25 17:12:49 -08001314 * This method is not thread-safe -- calling it from multiple threads simultaneously may
1315 * lead to interleaved text.
Hall Liua549fed2018-02-09 16:40:03 -08001316 *
Hall Liu95d55872017-01-25 17:12:49 -08001317 * @param input The message to send to the in-call app.
1318 */
1319 public void write(String input) throws IOException {
1320 mPipeToInCall.write(input);
1321 mPipeToInCall.flush();
1322 }
1323
1324
1325 /**
1326 * Reads a string from the in-call app, blocking if there is no data available. Returns
1327 * {@code null} if the RTT conversation has been terminated and there is no further data
1328 * to read.
Hall Liua549fed2018-02-09 16:40:03 -08001329 * <p>
Hall Liu95d55872017-01-25 17:12:49 -08001330 * This method is not thread-safe -- calling it from multiple threads simultaneously may
1331 * lead to interleaved text.
Hall Liua549fed2018-02-09 16:40:03 -08001332 *
Hall Liu95d55872017-01-25 17:12:49 -08001333 * @return A string containing text entered by the user, or {@code null} if the
1334 * conversation has been terminated or if there was an error while reading.
1335 */
Hall Liuffa4a812017-03-02 16:11:00 -08001336 public String read() throws IOException {
1337 int numRead = mPipeFromInCall.read(mReadBuffer, 0, READ_BUFFER_SIZE);
1338 if (numRead < 0) {
1339 return null;
1340 }
1341 return new String(mReadBuffer, 0, numRead);
1342 }
1343
1344 /**
1345 * Non-blocking version of {@link #read()}. Returns {@code null} if there is nothing to
1346 * be read.
Hall Liua549fed2018-02-09 16:40:03 -08001347 *
Hall Liuffa4a812017-03-02 16:11:00 -08001348 * @return A string containing text entered by the user, or {@code null} if the user has
1349 * not entered any new text yet.
1350 */
1351 public String readImmediately() throws IOException {
Hall Liu17eb1bd2018-07-03 15:17:41 -07001352 if (mFromInCallFileInputStream.available() > 0) {
Hall Liuffa4a812017-03-02 16:11:00 -08001353 return read();
1354 } else {
Hall Liu95d55872017-01-25 17:12:49 -08001355 return null;
1356 }
1357 }
Hall Liub64ac4c2017-02-06 10:49:48 -08001358
1359 /** @hide */
1360 public ParcelFileDescriptor getFdFromInCall() {
1361 return mFdFromInCall;
1362 }
1363
1364 /** @hide */
1365 public ParcelFileDescriptor getFdToInCall() {
1366 return mFdToInCall;
1367 }
1368 }
1369
1370 /**
1371 * Provides constants to represent the results of responses to session modify requests sent via
1372 * {@link Call#sendRttRequest()}
1373 */
1374 public static final class RttModifyStatus {
Hall Liu8dd49082017-04-21 14:33:12 -07001375 private RttModifyStatus() {}
Hall Liub64ac4c2017-02-06 10:49:48 -08001376 /**
1377 * Session modify request was successful.
1378 */
1379 public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1;
1380
1381 /**
1382 * Session modify request failed.
1383 */
1384 public static final int SESSION_MODIFY_REQUEST_FAIL = 2;
1385
1386 /**
1387 * Session modify request ignored due to invalid parameters.
1388 */
1389 public static final int SESSION_MODIFY_REQUEST_INVALID = 3;
1390
1391 /**
1392 * Session modify request timed out.
1393 */
1394 public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4;
1395
1396 /**
1397 * Session modify request rejected by remote user.
1398 */
1399 public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5;
Hall Liu95d55872017-01-25 17:12:49 -08001400 }
1401
1402 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001403 * Provides a means of controlling the video session associated with a {@link Connection}.
1404 * <p>
1405 * Implementations create a custom subclass of {@link VideoProvider} and the
1406 * {@link ConnectionService} creates an instance sets it on the {@link Connection} using
1407 * {@link Connection#setVideoProvider(VideoProvider)}. Any connection which supports video
1408 * should set the {@link VideoProvider}.
1409 * <p>
1410 * The {@link VideoProvider} serves two primary purposes: it provides a means for Telecom and
1411 * {@link InCallService} implementations to issue requests related to the video session;
1412 * it provides a means for the {@link ConnectionService} to report events and information
1413 * related to the video session to Telecom and the {@link InCallService} implementations.
1414 * <p>
1415 * {@link InCallService} implementations interact with the {@link VideoProvider} via
1416 * {@link android.telecom.InCallService.VideoCall}.
1417 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001418 public static abstract class VideoProvider {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001419 /**
1420 * Video is not being received (no protocol pause was issued).
Tyler Gunnb702ef82015-05-29 11:51:53 -07001421 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001422 */
1423 public static final int SESSION_EVENT_RX_PAUSE = 1;
Evan Charltonbf11f982014-07-20 22:06:28 -07001424
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001425 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001426 * Video reception has resumed after a {@link #SESSION_EVENT_RX_PAUSE}.
1427 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001428 */
1429 public static final int SESSION_EVENT_RX_RESUME = 2;
1430
1431 /**
1432 * Video transmission has begun. This occurs after a negotiated start of video transmission
1433 * when the underlying protocol has actually begun transmitting video to the remote party.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001434 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001435 */
1436 public static final int SESSION_EVENT_TX_START = 3;
1437
1438 /**
1439 * Video transmission has stopped. This occurs after a negotiated stop of video transmission
1440 * when the underlying protocol has actually stopped transmitting video to the remote party.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001441 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001442 */
1443 public static final int SESSION_EVENT_TX_STOP = 4;
1444
1445 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001446 * A camera failure has occurred for the selected camera. The {@link VideoProvider} can use
Tyler Gunnb702ef82015-05-29 11:51:53 -07001447 * this as a cue to inform the user the camera is not available.
1448 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001449 */
1450 public static final int SESSION_EVENT_CAMERA_FAILURE = 5;
1451
1452 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001453 * Issued after {@link #SESSION_EVENT_CAMERA_FAILURE} when the camera is once again ready
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001454 * for operation. The {@link VideoProvider} can use this as a cue to inform the user that
Tyler Gunnb702ef82015-05-29 11:51:53 -07001455 * the camera has become available again.
1456 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001457 */
1458 public static final int SESSION_EVENT_CAMERA_READY = 6;
1459
1460 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001461 * Session event raised by Telecom when
1462 * {@link android.telecom.InCallService.VideoCall#setCamera(String)} is called and the
1463 * caller does not have the necessary {@link android.Manifest.permission#CAMERA} permission.
1464 * @see #handleCallSessionEvent(int)
1465 */
1466 public static final int SESSION_EVENT_CAMERA_PERMISSION_ERROR = 7;
1467
1468 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001469 * Session modify request was successful.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001470 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001471 */
1472 public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1;
1473
1474 /**
1475 * Session modify request failed.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001476 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001477 */
1478 public static final int SESSION_MODIFY_REQUEST_FAIL = 2;
1479
1480 /**
1481 * Session modify request ignored due to invalid parameters.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001482 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001483 */
1484 public static final int SESSION_MODIFY_REQUEST_INVALID = 3;
1485
Rekha Kumar07366812015-03-24 16:42:31 -07001486 /**
1487 * Session modify request timed out.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001488 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Rekha Kumar07366812015-03-24 16:42:31 -07001489 */
1490 public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4;
1491
1492 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001493 * Session modify request rejected by remote user.
1494 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Rekha Kumar07366812015-03-24 16:42:31 -07001495 */
1496 public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5;
1497
Tyler Gunn75958422015-04-15 14:23:42 -07001498 private static final int MSG_ADD_VIDEO_CALLBACK = 1;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001499 private static final int MSG_SET_CAMERA = 2;
1500 private static final int MSG_SET_PREVIEW_SURFACE = 3;
1501 private static final int MSG_SET_DISPLAY_SURFACE = 4;
1502 private static final int MSG_SET_DEVICE_ORIENTATION = 5;
1503 private static final int MSG_SET_ZOOM = 6;
1504 private static final int MSG_SEND_SESSION_MODIFY_REQUEST = 7;
1505 private static final int MSG_SEND_SESSION_MODIFY_RESPONSE = 8;
1506 private static final int MSG_REQUEST_CAMERA_CAPABILITIES = 9;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001507 private static final int MSG_REQUEST_CONNECTION_DATA_USAGE = 10;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001508 private static final int MSG_SET_PAUSE_IMAGE = 11;
Tyler Gunn75958422015-04-15 14:23:42 -07001509 private static final int MSG_REMOVE_VIDEO_CALLBACK = 12;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001510
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001511 private static final String SESSION_EVENT_RX_PAUSE_STR = "RX_PAUSE";
1512 private static final String SESSION_EVENT_RX_RESUME_STR = "RX_RESUME";
1513 private static final String SESSION_EVENT_TX_START_STR = "TX_START";
1514 private static final String SESSION_EVENT_TX_STOP_STR = "TX_STOP";
1515 private static final String SESSION_EVENT_CAMERA_FAILURE_STR = "CAMERA_FAIL";
1516 private static final String SESSION_EVENT_CAMERA_READY_STR = "CAMERA_READY";
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001517 private static final String SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR =
1518 "CAMERA_PERMISSION_ERROR";
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001519 private static final String SESSION_EVENT_UNKNOWN_STR = "UNKNOWN";
1520
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001521 private VideoProvider.VideoProviderHandler mMessageHandler;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001522 private final VideoProvider.VideoProviderBinder mBinder;
Tyler Gunn75958422015-04-15 14:23:42 -07001523
1524 /**
1525 * Stores a list of the video callbacks, keyed by IBinder.
Tyler Gunn84f381b2015-06-12 09:26:45 -07001526 *
1527 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
1528 * load factor before resizing, 1 means we only expect a single thread to
1529 * access the map so make only a single shard
Tyler Gunn75958422015-04-15 14:23:42 -07001530 */
Tyler Gunn84f381b2015-06-12 09:26:45 -07001531 private ConcurrentHashMap<IBinder, IVideoCallback> mVideoCallbacks =
1532 new ConcurrentHashMap<IBinder, IVideoCallback>(8, 0.9f, 1);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001533
1534 /**
1535 * Default handler used to consolidate binder method calls onto a single thread.
1536 */
1537 private final class VideoProviderHandler extends Handler {
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001538 public VideoProviderHandler() {
1539 super();
1540 }
1541
1542 public VideoProviderHandler(Looper looper) {
1543 super(looper);
1544 }
1545
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001546 @Override
1547 public void handleMessage(Message msg) {
1548 switch (msg.what) {
Tyler Gunn75958422015-04-15 14:23:42 -07001549 case MSG_ADD_VIDEO_CALLBACK: {
1550 IBinder binder = (IBinder) msg.obj;
1551 IVideoCallback callback = IVideoCallback.Stub
1552 .asInterface((IBinder) msg.obj);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001553 if (callback == null) {
1554 Log.w(this, "addVideoProvider - skipped; callback is null.");
1555 break;
1556 }
1557
Tyler Gunn75958422015-04-15 14:23:42 -07001558 if (mVideoCallbacks.containsKey(binder)) {
1559 Log.i(this, "addVideoProvider - skipped; already present.");
1560 break;
1561 }
1562 mVideoCallbacks.put(binder, callback);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001563 break;
Tyler Gunn75958422015-04-15 14:23:42 -07001564 }
1565 case MSG_REMOVE_VIDEO_CALLBACK: {
1566 IBinder binder = (IBinder) msg.obj;
1567 IVideoCallback callback = IVideoCallback.Stub
1568 .asInterface((IBinder) msg.obj);
1569 if (!mVideoCallbacks.containsKey(binder)) {
1570 Log.i(this, "removeVideoProvider - skipped; not present.");
1571 break;
1572 }
1573 mVideoCallbacks.remove(binder);
1574 break;
1575 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001576 case MSG_SET_CAMERA:
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001577 {
1578 SomeArgs args = (SomeArgs) msg.obj;
1579 try {
1580 onSetCamera((String) args.arg1);
1581 onSetCamera((String) args.arg1, (String) args.arg2, args.argi1,
Tyler Gunn159f35c2017-03-02 09:28:37 -08001582 args.argi2, args.argi3);
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001583 } finally {
1584 args.recycle();
1585 }
1586 }
1587 break;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001588 case MSG_SET_PREVIEW_SURFACE:
1589 onSetPreviewSurface((Surface) msg.obj);
1590 break;
1591 case MSG_SET_DISPLAY_SURFACE:
1592 onSetDisplaySurface((Surface) msg.obj);
1593 break;
1594 case MSG_SET_DEVICE_ORIENTATION:
1595 onSetDeviceOrientation(msg.arg1);
1596 break;
1597 case MSG_SET_ZOOM:
1598 onSetZoom((Float) msg.obj);
1599 break;
Tyler Gunn45382162015-05-06 08:52:27 -07001600 case MSG_SEND_SESSION_MODIFY_REQUEST: {
1601 SomeArgs args = (SomeArgs) msg.obj;
1602 try {
1603 onSendSessionModifyRequest((VideoProfile) args.arg1,
1604 (VideoProfile) args.arg2);
1605 } finally {
1606 args.recycle();
1607 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001608 break;
Tyler Gunn45382162015-05-06 08:52:27 -07001609 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001610 case MSG_SEND_SESSION_MODIFY_RESPONSE:
1611 onSendSessionModifyResponse((VideoProfile) msg.obj);
1612 break;
1613 case MSG_REQUEST_CAMERA_CAPABILITIES:
1614 onRequestCameraCapabilities();
1615 break;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001616 case MSG_REQUEST_CONNECTION_DATA_USAGE:
1617 onRequestConnectionDataUsage();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001618 break;
1619 case MSG_SET_PAUSE_IMAGE:
Yorke Lee32f24732015-05-12 16:18:03 -07001620 onSetPauseImage((Uri) msg.obj);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001621 break;
1622 default:
1623 break;
1624 }
1625 }
1626 }
1627
1628 /**
1629 * IVideoProvider stub implementation.
1630 */
1631 private final class VideoProviderBinder extends IVideoProvider.Stub {
Tyler Gunn75958422015-04-15 14:23:42 -07001632 public void addVideoCallback(IBinder videoCallbackBinder) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001633 mMessageHandler.obtainMessage(
Tyler Gunn75958422015-04-15 14:23:42 -07001634 MSG_ADD_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget();
1635 }
1636
1637 public void removeVideoCallback(IBinder videoCallbackBinder) {
1638 mMessageHandler.obtainMessage(
1639 MSG_REMOVE_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001640 }
1641
Tyler Gunn159f35c2017-03-02 09:28:37 -08001642 public void setCamera(String cameraId, String callingPackageName,
1643 int targetSdkVersion) {
1644
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001645 SomeArgs args = SomeArgs.obtain();
1646 args.arg1 = cameraId;
1647 // Propagate the calling package; originally determined in
1648 // android.telecom.InCallService.VideoCall#setCamera(String) from the calling
1649 // process.
1650 args.arg2 = callingPackageName;
1651 // Pass along the uid and pid of the calling app; this gets lost when we put the
1652 // message onto the handler. These are required for Telecom to perform a permission
1653 // check to see if the calling app is able to use the camera.
1654 args.argi1 = Binder.getCallingUid();
1655 args.argi2 = Binder.getCallingPid();
Tyler Gunn159f35c2017-03-02 09:28:37 -08001656 // Pass along the target SDK version of the calling InCallService. This is used to
1657 // maintain backwards compatibility of the API for older callers.
1658 args.argi3 = targetSdkVersion;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001659 mMessageHandler.obtainMessage(MSG_SET_CAMERA, args).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001660 }
1661
1662 public void setPreviewSurface(Surface surface) {
1663 mMessageHandler.obtainMessage(MSG_SET_PREVIEW_SURFACE, surface).sendToTarget();
1664 }
1665
1666 public void setDisplaySurface(Surface surface) {
1667 mMessageHandler.obtainMessage(MSG_SET_DISPLAY_SURFACE, surface).sendToTarget();
1668 }
1669
1670 public void setDeviceOrientation(int rotation) {
Rekha Kumar07366812015-03-24 16:42:31 -07001671 mMessageHandler.obtainMessage(
1672 MSG_SET_DEVICE_ORIENTATION, rotation, 0).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001673 }
1674
1675 public void setZoom(float value) {
1676 mMessageHandler.obtainMessage(MSG_SET_ZOOM, value).sendToTarget();
1677 }
1678
Tyler Gunn45382162015-05-06 08:52:27 -07001679 public void sendSessionModifyRequest(VideoProfile fromProfile, VideoProfile toProfile) {
1680 SomeArgs args = SomeArgs.obtain();
1681 args.arg1 = fromProfile;
1682 args.arg2 = toProfile;
1683 mMessageHandler.obtainMessage(MSG_SEND_SESSION_MODIFY_REQUEST, args).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001684 }
1685
1686 public void sendSessionModifyResponse(VideoProfile responseProfile) {
1687 mMessageHandler.obtainMessage(
1688 MSG_SEND_SESSION_MODIFY_RESPONSE, responseProfile).sendToTarget();
1689 }
1690
1691 public void requestCameraCapabilities() {
1692 mMessageHandler.obtainMessage(MSG_REQUEST_CAMERA_CAPABILITIES).sendToTarget();
1693 }
1694
1695 public void requestCallDataUsage() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001696 mMessageHandler.obtainMessage(MSG_REQUEST_CONNECTION_DATA_USAGE).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001697 }
1698
Yorke Lee32f24732015-05-12 16:18:03 -07001699 public void setPauseImage(Uri uri) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001700 mMessageHandler.obtainMessage(MSG_SET_PAUSE_IMAGE, uri).sendToTarget();
1701 }
1702 }
1703
1704 public VideoProvider() {
1705 mBinder = new VideoProvider.VideoProviderBinder();
Tyler Gunn84f381b2015-06-12 09:26:45 -07001706 mMessageHandler = new VideoProvider.VideoProviderHandler(Looper.getMainLooper());
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001707 }
1708
1709 /**
1710 * Creates an instance of the {@link VideoProvider}, specifying the looper to use.
1711 *
1712 * @param looper The looper.
1713 * @hide
1714 */
Mathew Inwood42346d12018-08-01 11:33:05 +01001715 @UnsupportedAppUsage
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001716 public VideoProvider(Looper looper) {
1717 mBinder = new VideoProvider.VideoProviderBinder();
1718 mMessageHandler = new VideoProvider.VideoProviderHandler(looper);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001719 }
1720
1721 /**
1722 * Returns binder object which can be used across IPC methods.
1723 * @hide
1724 */
1725 public final IVideoProvider getInterface() {
1726 return mBinder;
1727 }
1728
1729 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001730 * Sets the camera to be used for the outgoing video.
1731 * <p>
1732 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1733 * camera via
1734 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1735 * <p>
1736 * Sent from the {@link InCallService} via
1737 * {@link InCallService.VideoCall#setCamera(String)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001738 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001739 * @param cameraId The id of the camera (use ids as reported by
1740 * {@link CameraManager#getCameraIdList()}).
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001741 */
1742 public abstract void onSetCamera(String cameraId);
1743
1744 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001745 * Sets the camera to be used for the outgoing video.
1746 * <p>
1747 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1748 * camera via
1749 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1750 * <p>
1751 * This prototype is used internally to ensure that the calling package name, UID and PID
1752 * are sent to Telecom so that can perform a camera permission check on the caller.
1753 * <p>
1754 * Sent from the {@link InCallService} via
1755 * {@link InCallService.VideoCall#setCamera(String)}.
1756 *
1757 * @param cameraId The id of the camera (use ids as reported by
1758 * {@link CameraManager#getCameraIdList()}).
1759 * @param callingPackageName The AppOpps package name of the caller.
1760 * @param callingUid The UID of the caller.
1761 * @param callingPid The PID of the caller.
Tyler Gunn159f35c2017-03-02 09:28:37 -08001762 * @param targetSdkVersion The target SDK version of the caller.
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001763 * @hide
1764 */
1765 public void onSetCamera(String cameraId, String callingPackageName, int callingUid,
Tyler Gunn159f35c2017-03-02 09:28:37 -08001766 int callingPid, int targetSdkVersion) {}
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001767
1768 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001769 * Sets the surface to be used for displaying a preview of what the user's camera is
1770 * currently capturing. When video transmission is enabled, this is the video signal which
1771 * is sent to the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001772 * <p>
1773 * Sent from the {@link InCallService} via
1774 * {@link InCallService.VideoCall#setPreviewSurface(Surface)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001775 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001776 * @param surface The {@link Surface}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001777 */
1778 public abstract void onSetPreviewSurface(Surface surface);
1779
1780 /**
1781 * Sets the surface to be used for displaying the video received from the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001782 * <p>
1783 * Sent from the {@link InCallService} via
1784 * {@link InCallService.VideoCall#setDisplaySurface(Surface)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001785 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001786 * @param surface The {@link Surface}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001787 */
1788 public abstract void onSetDisplaySurface(Surface surface);
1789
1790 /**
1791 * Sets the device orientation, in degrees. Assumes that a standard portrait orientation of
1792 * the device is 0 degrees.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001793 * <p>
1794 * Sent from the {@link InCallService} via
1795 * {@link InCallService.VideoCall#setDeviceOrientation(int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001796 *
1797 * @param rotation The device orientation, in degrees.
1798 */
1799 public abstract void onSetDeviceOrientation(int rotation);
1800
1801 /**
Tyler Gunnc603b462021-06-14 17:24:40 -07001802 * Sets the camera zoom ratio.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001803 * <p>
1804 * Sent from the {@link InCallService} via {@link InCallService.VideoCall#setZoom(float)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001805 *
Tyler Gunnc603b462021-06-14 17:24:40 -07001806 * @param value The camera zoom ratio; for the current camera, should be a value in the
1807 * range defined by
1808 * {@link android.hardware.camera2.CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001809 */
1810 public abstract void onSetZoom(float value);
1811
1812 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001813 * Issues a request to modify the properties of the current video session.
1814 * <p>
1815 * Example scenarios include: requesting an audio-only call to be upgraded to a
1816 * bi-directional video call, turning on or off the user's camera, sending a pause signal
1817 * when the {@link InCallService} is no longer the foreground application.
1818 * <p>
1819 * If the {@link VideoProvider} determines a request to be invalid, it should call
1820 * {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)} to report the
1821 * invalid request back to the {@link InCallService}.
1822 * <p>
1823 * Where a request requires confirmation from the user of the peer device, the
1824 * {@link VideoProvider} must communicate the request to the peer device and handle the
1825 * user's response. {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)}
1826 * is used to inform the {@link InCallService} of the result of the request.
1827 * <p>
1828 * Sent from the {@link InCallService} via
1829 * {@link InCallService.VideoCall#sendSessionModifyRequest(VideoProfile)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001830 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001831 * @param fromProfile The video profile prior to the request.
1832 * @param toProfile The video profile with the requested changes made.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001833 */
Tyler Gunn45382162015-05-06 08:52:27 -07001834 public abstract void onSendSessionModifyRequest(VideoProfile fromProfile,
1835 VideoProfile toProfile);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001836
Tyler Gunnb702ef82015-05-29 11:51:53 -07001837 /**
1838 * Provides a response to a request to change the current video session properties.
1839 * <p>
1840 * For example, if the peer requests and upgrade from an audio-only call to a bi-directional
1841 * video call, could decline the request and keep the call as audio-only.
1842 * In such a scenario, the {@code responseProfile} would have a video state of
1843 * {@link VideoProfile#STATE_AUDIO_ONLY}. If the user had decided to accept the request,
1844 * the video state would be {@link VideoProfile#STATE_BIDIRECTIONAL}.
1845 * <p>
1846 * Sent from the {@link InCallService} via
1847 * {@link InCallService.VideoCall#sendSessionModifyResponse(VideoProfile)} in response to
1848 * a {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)}
1849 * callback.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001850 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001851 * @param responseProfile The response video profile.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001852 */
1853 public abstract void onSendSessionModifyResponse(VideoProfile responseProfile);
1854
1855 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001856 * Issues a request to the {@link VideoProvider} to retrieve the camera capabilities.
1857 * <p>
1858 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1859 * camera via
1860 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1861 * <p>
1862 * Sent from the {@link InCallService} via
1863 * {@link InCallService.VideoCall#requestCameraCapabilities()}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001864 */
1865 public abstract void onRequestCameraCapabilities();
1866
1867 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001868 * Issues a request to the {@link VideoProvider} to retrieve the current data usage for the
1869 * video component of the current {@link Connection}.
1870 * <p>
1871 * The {@link VideoProvider} should respond by communicating current data usage, in bytes,
1872 * via {@link VideoProvider#setCallDataUsage(long)}.
1873 * <p>
1874 * Sent from the {@link InCallService} via
1875 * {@link InCallService.VideoCall#requestCallDataUsage()}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001876 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001877 public abstract void onRequestConnectionDataUsage();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001878
1879 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001880 * Provides the {@link VideoProvider} with the {@link Uri} of an image to be displayed to
1881 * the peer device when the video signal is paused.
1882 * <p>
1883 * Sent from the {@link InCallService} via
1884 * {@link InCallService.VideoCall#setPauseImage(Uri)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001885 *
1886 * @param uri URI of image to display.
1887 */
Yorke Lee32f24732015-05-12 16:18:03 -07001888 public abstract void onSetPauseImage(Uri uri);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001889
1890 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001891 * Used to inform listening {@link InCallService} implementations when the
1892 * {@link VideoProvider} receives a session modification request.
1893 * <p>
1894 * Received by the {@link InCallService} via
1895 * {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)},
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001896 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001897 * @param videoProfile The requested video profile.
1898 * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001899 */
1900 public void receiveSessionModifyRequest(VideoProfile videoProfile) {
Tyler Gunn75958422015-04-15 14:23:42 -07001901 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001902 for (IVideoCallback callback : mVideoCallbacks.values()) {
1903 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001904 callback.receiveSessionModifyRequest(videoProfile);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001905 } catch (RemoteException ignored) {
1906 Log.w(this, "receiveSessionModifyRequest callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001907 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001908 }
1909 }
1910 }
1911
1912 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001913 * Used to inform listening {@link InCallService} implementations when the
1914 * {@link VideoProvider} receives a response to a session modification request.
1915 * <p>
1916 * Received by the {@link InCallService} via
1917 * {@link InCallService.VideoCall.Callback#onSessionModifyResponseReceived(int,
1918 * VideoProfile, VideoProfile)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001919 *
1920 * @param status Status of the session modify request. Valid values are
1921 * {@link VideoProvider#SESSION_MODIFY_REQUEST_SUCCESS},
1922 * {@link VideoProvider#SESSION_MODIFY_REQUEST_FAIL},
Tyler Gunnb702ef82015-05-29 11:51:53 -07001923 * {@link VideoProvider#SESSION_MODIFY_REQUEST_INVALID},
1924 * {@link VideoProvider#SESSION_MODIFY_REQUEST_TIMED_OUT},
1925 * {@link VideoProvider#SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE}
1926 * @param requestedProfile The original request which was sent to the peer device.
1927 * @param responseProfile The actual profile changes agreed to by the peer device.
1928 * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001929 */
1930 public void receiveSessionModifyResponse(int status,
1931 VideoProfile requestedProfile, VideoProfile responseProfile) {
Tyler Gunn75958422015-04-15 14:23:42 -07001932 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001933 for (IVideoCallback callback : mVideoCallbacks.values()) {
1934 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001935 callback.receiveSessionModifyResponse(status, requestedProfile,
1936 responseProfile);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001937 } catch (RemoteException ignored) {
1938 Log.w(this, "receiveSessionModifyResponse callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001939 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001940 }
1941 }
1942 }
1943
1944 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001945 * Used to inform listening {@link InCallService} implementations when the
1946 * {@link VideoProvider} reports a call session event.
1947 * <p>
1948 * Received by the {@link InCallService} via
1949 * {@link InCallService.VideoCall.Callback#onCallSessionEvent(int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001950 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001951 * @param event The event. Valid values are: {@link VideoProvider#SESSION_EVENT_RX_PAUSE},
1952 * {@link VideoProvider#SESSION_EVENT_RX_RESUME},
1953 * {@link VideoProvider#SESSION_EVENT_TX_START},
1954 * {@link VideoProvider#SESSION_EVENT_TX_STOP},
1955 * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE},
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001956 * {@link VideoProvider#SESSION_EVENT_CAMERA_READY},
1957 * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001958 */
1959 public void handleCallSessionEvent(int event) {
Tyler Gunn75958422015-04-15 14:23:42 -07001960 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001961 for (IVideoCallback callback : mVideoCallbacks.values()) {
1962 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001963 callback.handleCallSessionEvent(event);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001964 } catch (RemoteException ignored) {
1965 Log.w(this, "handleCallSessionEvent callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001966 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001967 }
1968 }
1969 }
1970
1971 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001972 * Used to inform listening {@link InCallService} implementations when the dimensions of the
1973 * peer's video have changed.
1974 * <p>
1975 * This could occur if, for example, the peer rotates their device, changing the aspect
1976 * ratio of the video, or if the user switches between the back and front cameras.
1977 * <p>
1978 * Received by the {@link InCallService} via
1979 * {@link InCallService.VideoCall.Callback#onPeerDimensionsChanged(int, int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001980 *
1981 * @param width The updated peer video width.
1982 * @param height The updated peer video height.
1983 */
1984 public void changePeerDimensions(int width, int height) {
Tyler Gunn75958422015-04-15 14:23:42 -07001985 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001986 for (IVideoCallback callback : mVideoCallbacks.values()) {
1987 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001988 callback.changePeerDimensions(width, height);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001989 } catch (RemoteException ignored) {
1990 Log.w(this, "changePeerDimensions callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001991 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001992 }
1993 }
1994 }
1995
1996 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001997 * Used to inform listening {@link InCallService} implementations when the data usage of the
1998 * video associated with the current {@link Connection} has changed.
1999 * <p>
2000 * This could be in response to a preview request via
2001 * {@link #onRequestConnectionDataUsage()}, or as a periodic update by the
Tyler Gunn295f5d72015-06-04 11:08:54 -07002002 * {@link VideoProvider}. Where periodic updates of data usage are provided, they should be
2003 * 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 -07002004 * <p>
2005 * Received by the {@link InCallService} via
2006 * {@link InCallService.VideoCall.Callback#onCallDataUsageChanged(long)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002007 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002008 * @param dataUsage The updated data usage (in bytes). Reported as the cumulative bytes
2009 * used since the start of the call.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002010 */
Yorke Lee32f24732015-05-12 16:18:03 -07002011 public void setCallDataUsage(long dataUsage) {
Tyler Gunn75958422015-04-15 14:23:42 -07002012 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002013 for (IVideoCallback callback : mVideoCallbacks.values()) {
2014 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002015 callback.changeCallDataUsage(dataUsage);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002016 } catch (RemoteException ignored) {
2017 Log.w(this, "setCallDataUsage callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002018 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002019 }
2020 }
2021 }
2022
2023 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002024 * @see #setCallDataUsage(long)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002025 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002026 * @param dataUsage The updated data usage (in byes).
Yorke Lee32f24732015-05-12 16:18:03 -07002027 * @deprecated - Use {@link #setCallDataUsage(long)} instead.
2028 * @hide
2029 */
2030 public void changeCallDataUsage(long dataUsage) {
2031 setCallDataUsage(dataUsage);
2032 }
2033
2034 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002035 * Used to inform listening {@link InCallService} implementations when the capabilities of
2036 * the current camera have changed.
2037 * <p>
2038 * The {@link VideoProvider} should call this in response to
2039 * {@link VideoProvider#onRequestCameraCapabilities()}, or when the current camera is
2040 * changed via {@link VideoProvider#onSetCamera(String)}.
2041 * <p>
2042 * Received by the {@link InCallService} via
2043 * {@link InCallService.VideoCall.Callback#onCameraCapabilitiesChanged(
2044 * VideoProfile.CameraCapabilities)}.
Yorke Lee32f24732015-05-12 16:18:03 -07002045 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002046 * @param cameraCapabilities The new camera capabilities.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002047 */
Yorke Lee400470f2015-05-12 13:31:25 -07002048 public void changeCameraCapabilities(VideoProfile.CameraCapabilities cameraCapabilities) {
Tyler Gunn75958422015-04-15 14:23:42 -07002049 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002050 for (IVideoCallback callback : mVideoCallbacks.values()) {
2051 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002052 callback.changeCameraCapabilities(cameraCapabilities);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002053 } catch (RemoteException ignored) {
2054 Log.w(this, "changeCameraCapabilities callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002055 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002056 }
2057 }
2058 }
Rekha Kumar07366812015-03-24 16:42:31 -07002059
2060 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002061 * Used to inform listening {@link InCallService} implementations when the video quality
2062 * of the call has changed.
2063 * <p>
2064 * Received by the {@link InCallService} via
2065 * {@link InCallService.VideoCall.Callback#onVideoQualityChanged(int)}.
Rekha Kumar07366812015-03-24 16:42:31 -07002066 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002067 * @param videoQuality The updated video quality. Valid values:
2068 * {@link VideoProfile#QUALITY_HIGH},
2069 * {@link VideoProfile#QUALITY_MEDIUM},
2070 * {@link VideoProfile#QUALITY_LOW},
2071 * {@link VideoProfile#QUALITY_DEFAULT}.
Rekha Kumar07366812015-03-24 16:42:31 -07002072 */
2073 public void changeVideoQuality(int videoQuality) {
Tyler Gunn75958422015-04-15 14:23:42 -07002074 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002075 for (IVideoCallback callback : mVideoCallbacks.values()) {
2076 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002077 callback.changeVideoQuality(videoQuality);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002078 } catch (RemoteException ignored) {
2079 Log.w(this, "changeVideoQuality callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002080 }
Rekha Kumar07366812015-03-24 16:42:31 -07002081 }
2082 }
2083 }
Tyler Gunn6f657ee2016-09-02 09:55:25 -07002084
2085 /**
2086 * Returns a string representation of a call session event.
2087 *
2088 * @param event A call session event passed to {@link #handleCallSessionEvent(int)}.
2089 * @return String representation of the call session event.
2090 * @hide
2091 */
2092 public static String sessionEventToString(int event) {
2093 switch (event) {
2094 case SESSION_EVENT_CAMERA_FAILURE:
2095 return SESSION_EVENT_CAMERA_FAILURE_STR;
2096 case SESSION_EVENT_CAMERA_READY:
2097 return SESSION_EVENT_CAMERA_READY_STR;
2098 case SESSION_EVENT_RX_PAUSE:
2099 return SESSION_EVENT_RX_PAUSE_STR;
2100 case SESSION_EVENT_RX_RESUME:
2101 return SESSION_EVENT_RX_RESUME_STR;
2102 case SESSION_EVENT_TX_START:
2103 return SESSION_EVENT_TX_START_STR;
2104 case SESSION_EVENT_TX_STOP:
2105 return SESSION_EVENT_TX_STOP_STR;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08002106 case SESSION_EVENT_CAMERA_PERMISSION_ERROR:
2107 return SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR;
Tyler Gunn6f657ee2016-09-02 09:55:25 -07002108 default:
2109 return SESSION_EVENT_UNKNOWN_STR + " " + event;
2110 }
2111 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002112 }
2113
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002114 private final Listener mConnectionDeathListener = new Listener() {
2115 @Override
2116 public void onDestroyed(Connection c) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002117 if (mConferenceables.remove(c)) {
2118 fireOnConferenceableConnectionsChanged();
2119 }
2120 }
2121 };
2122
2123 private final Conference.Listener mConferenceDeathListener = new Conference.Listener() {
2124 @Override
2125 public void onDestroyed(Conference c) {
2126 if (mConferenceables.remove(c)) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002127 fireOnConferenceableConnectionsChanged();
2128 }
2129 }
2130 };
2131
Jay Shrauner229e3822014-08-15 09:23:07 -07002132 /**
2133 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
2134 * load factor before resizing, 1 means we only expect a single thread to
2135 * access the map so make only a single shard
2136 */
2137 private final Set<Listener> mListeners = Collections.newSetFromMap(
2138 new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1));
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002139 private final List<Conferenceable> mConferenceables = new ArrayList<>();
2140 private final List<Conferenceable> mUnmodifiableConferenceables =
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002141 Collections.unmodifiableList(mConferenceables);
Santos Cordonb6939982014-06-04 20:20:58 -07002142
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002143 // The internal telecom call ID associated with this connection.
2144 private String mTelecomCallId;
Pengquan Meng70c9885332017-10-02 18:09:03 -07002145 // The PhoneAccountHandle associated with this connection.
2146 private PhoneAccountHandle mPhoneAccountHandle;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002147 private int mState = STATE_NEW;
Yorke Lee4af59352015-05-13 14:14:54 -07002148 private CallAudioState mCallAudioState;
Andrew Lee100e2932014-09-08 15:34:24 -07002149 private Uri mAddress;
2150 private int mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -07002151 private String mCallerDisplayName;
2152 private int mCallerDisplayNamePresentation;
Andrew Lee100e2932014-09-08 15:34:24 -07002153 private boolean mRingbackRequested = false;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002154 private int mConnectionCapabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -07002155 private int mConnectionProperties;
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002156 private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002157 private VideoProvider mVideoProvider;
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002158 private boolean mAudioModeIsVoip;
Roshan Piuse927ec02015-07-15 15:47:21 -07002159 private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002160 private long mConnectElapsedTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002161 private StatusHints mStatusHints;
Tyler Gunnaa07df82014-07-17 07:50:22 -07002162 private int mVideoState;
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002163 private DisconnectCause mDisconnectCause;
Santos Cordon823fd3c2014-08-07 18:35:18 -07002164 private Conference mConference;
2165 private ConnectionService mConnectionService;
Santos Cordon6b7f9552015-05-27 17:21:45 -07002166 private Bundle mExtras;
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002167 private final Object mExtrasLock = new Object();
Tyler Gunn6986a632019-06-25 13:45:32 -07002168 /**
2169 * The direction of the connection; used where an existing connection is created and we need to
2170 * communicate to Telecom whether its incoming or outgoing.
2171 */
2172 private @Call.Details.CallDirection int mCallDirection = Call.Details.DIRECTION_UNKNOWN;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002173
2174 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002175 * Tracks the key set for the extras bundle provided on the last invocation of
2176 * {@link #setExtras(Bundle)}. Used so that on subsequent invocations we can remove any extras
2177 * keys which were set previously but are no longer present in the replacement Bundle.
2178 */
2179 private Set<String> mPreviousExtraKeys;
2180
2181 /**
Tyler Gunnd57d76c2019-09-24 14:53:23 -07002182 * The verification status for an incoming call's phone number.
2183 */
2184 private @VerificationStatus int mCallerNumberVerificationStatus;
2185
2186
2187 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002188 * Create a new Connection.
2189 */
Santos Cordonf2951102014-07-20 19:06:29 -07002190 public Connection() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002191
2192 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002193 * Returns the Telecom internal call ID associated with this connection. Should only be used
2194 * for debugging and tracing purposes.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002195 * <p>
2196 * Note: Access to the Telecom internal call ID is used for logging purposes only; this API is
2197 * provided to facilitate debugging of the Telephony stack only.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002198 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07002199 * @return The Telecom call ID, or {@code null} if it was not set.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002200 * @hide
2201 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002202 @SystemApi
2203 public final @Nullable String getTelecomCallId() {
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002204 return mTelecomCallId;
2205 }
2206
2207 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002208 * @return The address (e.g., phone number) to which this Connection is currently communicating.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002209 */
Andrew Lee100e2932014-09-08 15:34:24 -07002210 public final Uri getAddress() {
2211 return mAddress;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002212 }
2213
2214 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002215 * @return The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002216 * See {@link TelecomManager} for valid values.
Sailesh Nepal61203862014-07-11 14:50:13 -07002217 */
Andrew Lee100e2932014-09-08 15:34:24 -07002218 public final int getAddressPresentation() {
2219 return mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -07002220 }
2221
2222 /**
2223 * @return The caller display name (CNAP).
2224 */
2225 public final String getCallerDisplayName() {
2226 return mCallerDisplayName;
2227 }
2228
2229 /**
Nancy Chen9d568c02014-09-08 14:17:59 -07002230 * @return The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002231 * See {@link TelecomManager} for valid values.
Sailesh Nepal61203862014-07-11 14:50:13 -07002232 */
2233 public final int getCallerDisplayNamePresentation() {
2234 return mCallerDisplayNamePresentation;
2235 }
2236
2237 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002238 * @return The state of this Connection.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002239 */
2240 public final int getState() {
2241 return mState;
2242 }
2243
2244 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002245 * Returns the video state of the connection.
Yorke Lee32f24732015-05-12 16:18:03 -07002246 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
2247 * {@link VideoProfile#STATE_BIDIRECTIONAL},
2248 * {@link VideoProfile#STATE_TX_ENABLED},
2249 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002250 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002251 * @return The video state of the connection.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002252 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002253 public final @VideoProfile.VideoState int getVideoState() {
Tyler Gunnaa07df82014-07-17 07:50:22 -07002254 return mVideoState;
2255 }
2256
2257 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002258 * @return The audio state of the connection, describing how its audio is currently
Ihab Awad542e0ea2014-05-16 10:22:16 -07002259 * being routed by the system. This is {@code null} if this Connection
2260 * does not directly know about its audio state.
Yorke Lee4af59352015-05-13 14:14:54 -07002261 * @deprecated Use {@link #getCallAudioState()} instead.
2262 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -07002263 */
Yorke Lee4af59352015-05-13 14:14:54 -07002264 @SystemApi
2265 @Deprecated
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002266 public final AudioState getAudioState() {
Sailesh Nepal000d38a2015-06-21 10:25:13 -07002267 if (mCallAudioState == null) {
2268 return null;
2269 }
Yorke Lee4af59352015-05-13 14:14:54 -07002270 return new AudioState(mCallAudioState);
2271 }
2272
2273 /**
2274 * @return The audio state of the connection, describing how its audio is currently
2275 * being routed by the system. This is {@code null} if this Connection
2276 * does not directly know about its audio state.
2277 */
2278 public final CallAudioState getCallAudioState() {
2279 return mCallAudioState;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002280 }
2281
2282 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002283 * @return The conference that this connection is a part of. Null if it is not part of any
2284 * conference.
2285 */
2286 public final Conference getConference() {
2287 return mConference;
2288 }
2289
2290 /**
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002291 * Returns whether this connection is requesting that the system play a ringback tone
2292 * on its behalf.
2293 */
Andrew Lee100e2932014-09-08 15:34:24 -07002294 public final boolean isRingbackRequested() {
2295 return mRingbackRequested;
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002296 }
2297
2298 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002299 * @return True if the connection's audio mode is VOIP.
2300 */
2301 public final boolean getAudioModeIsVoip() {
2302 return mAudioModeIsVoip;
2303 }
2304
2305 /**
Roshan Piuse927ec02015-07-15 15:47:21 -07002306 * Retrieves the connection start time of the {@code Connnection}, if specified. A value of
2307 * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
2308 * start time of the conference.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002309 * <p>
2310 * Note: This is an implementation detail specific to IMS conference calls over a mobile
2311 * network.
Roshan Piuse927ec02015-07-15 15:47:21 -07002312 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07002313 * @return The time at which the {@code Connnection} was connected. Will be a value as retrieved
2314 * from {@link System#currentTimeMillis()}.
Roshan Piuse927ec02015-07-15 15:47:21 -07002315 *
2316 * @hide
2317 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002318 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002319 public final @IntRange(from = 0) long getConnectTimeMillis() {
Roshan Piuse927ec02015-07-15 15:47:21 -07002320 return mConnectTimeMillis;
2321 }
2322
2323 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002324 * Retrieves the connection start time of the {@link Connection}, if specified. A value of
2325 * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
Tyler Gunnc9503d62020-01-27 10:30:51 -08002326 * start time of the connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002327 * <p>
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002328 * Based on the value of {@link SystemClock#elapsedRealtime()}, which ensures that wall-clock
2329 * changes do not impact the call duration.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002330 * <p>
2331 * Used internally in Telephony when migrating conference participant data for IMS conferences.
Tyler Gunnc9503d62020-01-27 10:30:51 -08002332 * <p>
2333 * The value returned is the same one set using
2334 * {@link #setConnectionStartElapsedRealtimeMillis(long)}. This value is never updated from
2335 * the Telecom framework, so no permission enforcement occurs when retrieving the value with
2336 * this method.
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002337 *
2338 * @return The time at which the {@link Connection} was connected.
2339 *
2340 * @hide
2341 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002342 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002343 public final @ElapsedRealtimeLong long getConnectionStartElapsedRealtimeMillis() {
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002344 return mConnectElapsedTimeMillis;
2345 }
2346
2347 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002348 * @return The status hints for this connection.
2349 */
2350 public final StatusHints getStatusHints() {
2351 return mStatusHints;
2352 }
2353
2354 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002355 * Returns the extras associated with this connection.
Tyler Gunn2cbe2b52016-05-04 15:48:10 +00002356 * <p>
2357 * Extras should be updated using {@link #putExtras(Bundle)}.
2358 * <p>
2359 * Telecom or an {@link InCallService} can also update the extras via
2360 * {@link android.telecom.Call#putExtras(Bundle)}, and
2361 * {@link Call#removeExtras(List)}.
2362 * <p>
2363 * The connection is notified of changes to the extras made by Telecom or an
2364 * {@link InCallService} by {@link #onExtrasChanged(Bundle)}.
Tyler Gunndee56a82016-03-23 16:06:34 -07002365 *
Santos Cordon6b7f9552015-05-27 17:21:45 -07002366 * @return The extras associated with this connection.
2367 */
2368 public final Bundle getExtras() {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002369 Bundle extras = null;
2370 synchronized (mExtrasLock) {
2371 if (mExtras != null) {
2372 extras = new Bundle(mExtras);
2373 }
2374 }
2375 return extras;
Santos Cordon6b7f9552015-05-27 17:21:45 -07002376 }
2377
2378 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002379 * Assign a listener to be notified of state changes.
2380 *
2381 * @param l A listener.
2382 * @return This Connection.
2383 *
2384 * @hide
2385 */
Tyler Gunn633e4c32019-10-24 15:40:48 -07002386 final Connection addConnectionListener(Listener l) {
Santos Cordond34e5712014-08-05 18:54:03 +00002387 mListeners.add(l);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002388 return this;
2389 }
2390
2391 /**
2392 * Remove a previously assigned listener that was being notified of state changes.
2393 *
2394 * @param l A Listener.
2395 * @return This Connection.
2396 *
2397 * @hide
2398 */
Tyler Gunn633e4c32019-10-24 15:40:48 -07002399 final Connection removeConnectionListener(Listener l) {
Jay Shrauner229e3822014-08-15 09:23:07 -07002400 if (l != null) {
2401 mListeners.remove(l);
2402 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002403 return this;
2404 }
2405
2406 /**
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002407 * @return The {@link DisconnectCause} for this connection.
Evan Charltonbf11f982014-07-20 22:06:28 -07002408 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002409 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002410 return mDisconnectCause;
Evan Charltonbf11f982014-07-20 22:06:28 -07002411 }
2412
2413 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002414 * Sets the telecom call ID associated with this Connection. The Telecom Call ID should be used
2415 * ONLY for debugging purposes.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002416 * <p>
2417 * Note: Access to the Telecom internal call ID is used for logging purposes only; this API is
2418 * provided to facilitate debugging of the Telephony stack only. Changing the ID via this
2419 * method does NOT change any functionality in Telephony or Telecom and impacts only logging.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002420 *
2421 * @param callId The telecom call ID.
2422 * @hide
2423 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002424 @SystemApi
2425 public void setTelecomCallId(@NonNull String callId) {
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002426 mTelecomCallId = callId;
2427 }
2428
2429 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002430 * Inform this Connection that the state of its audio output has been changed externally.
2431 *
2432 * @param state The new audio state.
Sailesh Nepal400cc482014-06-26 12:04:00 -07002433 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -07002434 */
Yorke Lee4af59352015-05-13 14:14:54 -07002435 final void setCallAudioState(CallAudioState state) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002436 checkImmutable();
Ihab Awad60ac30b2014-05-20 22:32:12 -07002437 Log.d(this, "setAudioState %s", state);
Yorke Lee4af59352015-05-13 14:14:54 -07002438 mCallAudioState = state;
2439 onAudioStateChanged(getAudioState());
2440 onCallAudioStateChanged(state);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002441 }
2442
2443 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002444 * @param state An integer value of a {@code STATE_*} constant.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002445 * @return A string representation of the value.
2446 */
2447 public static String stateToString(int state) {
2448 switch (state) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002449 case STATE_INITIALIZING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002450 return "INITIALIZING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002451 case STATE_NEW:
Yorke Leee911c8d2015-07-14 11:39:36 -07002452 return "NEW";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002453 case STATE_RINGING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002454 return "RINGING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002455 case STATE_DIALING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002456 return "DIALING";
Tyler Gunnc96b5e02016-07-07 22:53:57 -07002457 case STATE_PULLING_CALL:
2458 return "PULLING_CALL";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002459 case STATE_ACTIVE:
Yorke Leee911c8d2015-07-14 11:39:36 -07002460 return "ACTIVE";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002461 case STATE_HOLDING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002462 return "HOLDING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002463 case STATE_DISCONNECTED:
Ihab Awad542e0ea2014-05-16 10:22:16 -07002464 return "DISCONNECTED";
2465 default:
Ihab Awad60ac30b2014-05-20 22:32:12 -07002466 Log.wtf(Connection.class, "Unknown state %d", state);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002467 return "UNKNOWN";
2468 }
2469 }
2470
2471 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002472 * Returns the connection's capabilities, as a bit mask of the {@code CAPABILITY_*} constants.
Ihab Awad52a28f62014-06-18 10:26:34 -07002473 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002474 public final int getConnectionCapabilities() {
2475 return mConnectionCapabilities;
Ihab Awad52a28f62014-06-18 10:26:34 -07002476 }
2477
2478 /**
Tyler Gunn720c6642016-03-22 09:02:47 -07002479 * Returns the connection's properties, as a bit mask of the {@code PROPERTY_*} constants.
2480 */
2481 public final int getConnectionProperties() {
2482 return mConnectionProperties;
2483 }
2484
2485 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002486 * Returns the connection's supported audio routes.
2487 *
2488 * @hide
2489 */
2490 public final int getSupportedAudioRoutes() {
2491 return mSupportedAudioRoutes;
2492 }
2493
2494 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002495 * Sets the value of the {@link #getAddress()} property.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002496 *
Andrew Lee100e2932014-09-08 15:34:24 -07002497 * @param address The new address.
2498 * @param presentation The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002499 * See {@link TelecomManager} for valid values.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002500 */
Andrew Lee100e2932014-09-08 15:34:24 -07002501 public final void setAddress(Uri address, int presentation) {
2502 Log.d(this, "setAddress %s", address);
2503 mAddress = address;
2504 mAddressPresentation = presentation;
Santos Cordond34e5712014-08-05 18:54:03 +00002505 for (Listener l : mListeners) {
Andrew Lee100e2932014-09-08 15:34:24 -07002506 l.onAddressChanged(this, address, presentation);
Santos Cordond34e5712014-08-05 18:54:03 +00002507 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002508 }
2509
2510 /**
Sailesh Nepal61203862014-07-11 14:50:13 -07002511 * Sets the caller display name (CNAP).
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002512 *
Sailesh Nepal61203862014-07-11 14:50:13 -07002513 * @param callerDisplayName The new display name.
Nancy Chen9d568c02014-09-08 14:17:59 -07002514 * @param presentation The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002515 * See {@link TelecomManager} for valid values.
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002516 */
Sailesh Nepal61203862014-07-11 14:50:13 -07002517 public final void setCallerDisplayName(String callerDisplayName, int presentation) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002518 checkImmutable();
Sailesh Nepal61203862014-07-11 14:50:13 -07002519 Log.d(this, "setCallerDisplayName %s", callerDisplayName);
Santos Cordond34e5712014-08-05 18:54:03 +00002520 mCallerDisplayName = callerDisplayName;
2521 mCallerDisplayNamePresentation = presentation;
2522 for (Listener l : mListeners) {
2523 l.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
2524 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002525 }
2526
2527 /**
Tyler Gunnaa07df82014-07-17 07:50:22 -07002528 * Set the video state for the connection.
Yorke Lee32f24732015-05-12 16:18:03 -07002529 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
2530 * {@link VideoProfile#STATE_BIDIRECTIONAL},
2531 * {@link VideoProfile#STATE_TX_ENABLED},
2532 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002533 *
2534 * @param videoState The new video state.
2535 */
2536 public final void setVideoState(int videoState) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002537 checkImmutable();
Tyler Gunnaa07df82014-07-17 07:50:22 -07002538 Log.d(this, "setVideoState %d", videoState);
Santos Cordond34e5712014-08-05 18:54:03 +00002539 mVideoState = videoState;
2540 for (Listener l : mListeners) {
2541 l.onVideoStateChanged(this, mVideoState);
2542 }
Tyler Gunnaa07df82014-07-17 07:50:22 -07002543 }
2544
2545 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002546 * Sets state to active (e.g., an ongoing connection where two or more parties can actively
Ihab Awad542e0ea2014-05-16 10:22:16 -07002547 * communicate).
2548 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002549 public final void setActive() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002550 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002551 setRingbackRequested(false);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002552 setState(STATE_ACTIVE);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002553 }
2554
2555 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002556 * Sets state to ringing (e.g., an inbound ringing connection).
Ihab Awad542e0ea2014-05-16 10:22:16 -07002557 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002558 public final void setRinging() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002559 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002560 setState(STATE_RINGING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002561 }
2562
2563 /**
Evan Charltonbf11f982014-07-20 22:06:28 -07002564 * Sets state to initializing (this Connection is not yet ready to be used).
2565 */
2566 public final void setInitializing() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002567 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002568 setState(STATE_INITIALIZING);
Evan Charltonbf11f982014-07-20 22:06:28 -07002569 }
2570
2571 /**
2572 * Sets state to initialized (the Connection has been set up and is now ready to be used).
2573 */
2574 public final void setInitialized() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002575 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002576 setState(STATE_NEW);
Evan Charltonbf11f982014-07-20 22:06:28 -07002577 }
2578
2579 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002580 * Sets state to dialing (e.g., dialing an outbound connection).
Ihab Awad542e0ea2014-05-16 10:22:16 -07002581 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002582 public final void setDialing() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002583 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002584 setState(STATE_DIALING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002585 }
2586
2587 /**
Tyler Gunnc242ceb2016-06-29 22:35:45 -07002588 * Sets state to pulling (e.g. the connection is being pulled to the local device from another
2589 * device). Only applicable for {@link Connection}s with
2590 * {@link Connection#PROPERTY_IS_EXTERNAL_CALL} and {@link Connection#CAPABILITY_CAN_PULL_CALL}.
2591 */
2592 public final void setPulling() {
2593 checkImmutable();
2594 setState(STATE_PULLING_CALL);
2595 }
2596
2597 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002598 * Sets state to be on hold.
2599 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002600 public final void setOnHold() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002601 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002602 setState(STATE_HOLDING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002603 }
2604
2605 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002606 * Sets the video connection provider.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002607 * @param videoProvider The video provider.
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002608 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002609 public final void setVideoProvider(VideoProvider videoProvider) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002610 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002611 mVideoProvider = videoProvider;
Santos Cordond34e5712014-08-05 18:54:03 +00002612 for (Listener l : mListeners) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002613 l.onVideoProviderChanged(this, videoProvider);
Santos Cordond34e5712014-08-05 18:54:03 +00002614 }
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002615 }
2616
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002617 public final VideoProvider getVideoProvider() {
2618 return mVideoProvider;
Andrew Leea27a1932014-07-09 17:07:13 -07002619 }
2620
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002621 /**
Sailesh Nepal091768c2014-06-30 15:15:23 -07002622 * Sets state to disconnected.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002623 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002624 * @param disconnectCause The reason for the disconnection, as specified by
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002625 * {@link DisconnectCause}.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002626 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002627 public final void setDisconnected(DisconnectCause disconnectCause) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002628 checkImmutable();
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002629 mDisconnectCause = disconnectCause;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002630 setState(STATE_DISCONNECTED);
mike dooleyf34519b2014-09-16 17:33:40 -07002631 Log.d(this, "Disconnected with cause %s", disconnectCause);
Santos Cordond34e5712014-08-05 18:54:03 +00002632 for (Listener l : mListeners) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002633 l.onDisconnected(this, disconnectCause);
Santos Cordond34e5712014-08-05 18:54:03 +00002634 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002635 }
2636
2637 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002638 * Informs listeners that this {@code Connection} is in a post-dial wait state. This is done
2639 * when (a) the {@code Connection} is issuing a DTMF sequence; (b) it has encountered a "wait"
2640 * character; and (c) it wishes to inform the In-Call app that it is waiting for the end-user
2641 * to send an {@link #onPostDialContinue(boolean)} signal.
2642 *
2643 * @param remaining The DTMF character sequence remaining to be emitted once the
2644 * {@link #onPostDialContinue(boolean)} is received, including any "wait" characters
2645 * that remaining sequence may contain.
Sailesh Nepal091768c2014-06-30 15:15:23 -07002646 */
2647 public final void setPostDialWait(String remaining) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002648 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002649 for (Listener l : mListeners) {
2650 l.onPostDialWait(this, remaining);
2651 }
Sailesh Nepal091768c2014-06-30 15:15:23 -07002652 }
2653
2654 /**
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002655 * Informs listeners that this {@code Connection} has processed a character in the post-dial
2656 * started state. This is done when (a) the {@code Connection} is issuing a DTMF sequence;
Sailesh Nepal1ed85612015-01-31 15:17:19 -08002657 * and (b) it wishes to signal Telecom to play the corresponding DTMF tone locally.
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002658 *
2659 * @param nextChar The DTMF character that was just processed by the {@code Connection}.
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002660 */
Sailesh Nepal1ed85612015-01-31 15:17:19 -08002661 public final void setNextPostDialChar(char nextChar) {
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002662 checkImmutable();
2663 for (Listener l : mListeners) {
2664 l.onPostDialChar(this, nextChar);
2665 }
2666 }
2667
2668 /**
Ihab Awadf8358972014-05-28 16:46:42 -07002669 * Requests that the framework play a ringback tone. This is to be invoked by implementations
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002670 * that do not play a ringback tone themselves in the connection's audio stream.
Ihab Awadf8358972014-05-28 16:46:42 -07002671 *
2672 * @param ringback Whether the ringback tone is to be played.
2673 */
Andrew Lee100e2932014-09-08 15:34:24 -07002674 public final void setRingbackRequested(boolean ringback) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002675 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002676 if (mRingbackRequested != ringback) {
2677 mRingbackRequested = ringback;
Santos Cordond34e5712014-08-05 18:54:03 +00002678 for (Listener l : mListeners) {
Andrew Lee100e2932014-09-08 15:34:24 -07002679 l.onRingbackRequested(this, ringback);
Santos Cordond34e5712014-08-05 18:54:03 +00002680 }
2681 }
Ihab Awadf8358972014-05-28 16:46:42 -07002682 }
2683
2684 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002685 * Sets the connection's capabilities as a bit mask of the {@code CAPABILITY_*} constants.
Sailesh Nepal1a7061b2014-07-09 21:03:20 -07002686 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002687 * @param connectionCapabilities The new connection capabilities.
Santos Cordonb6939982014-06-04 20:20:58 -07002688 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002689 public final void setConnectionCapabilities(int connectionCapabilities) {
2690 checkImmutable();
2691 if (mConnectionCapabilities != connectionCapabilities) {
2692 mConnectionCapabilities = connectionCapabilities;
Santos Cordond34e5712014-08-05 18:54:03 +00002693 for (Listener l : mListeners) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002694 l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities);
Santos Cordond34e5712014-08-05 18:54:03 +00002695 }
2696 }
Santos Cordonb6939982014-06-04 20:20:58 -07002697 }
2698
2699 /**
Tyler Gunn720c6642016-03-22 09:02:47 -07002700 * Sets the connection's properties as a bit mask of the {@code PROPERTY_*} constants.
2701 *
2702 * @param connectionProperties The new connection properties.
2703 */
2704 public final void setConnectionProperties(int connectionProperties) {
2705 checkImmutable();
2706 if (mConnectionProperties != connectionProperties) {
2707 mConnectionProperties = connectionProperties;
2708 for (Listener l : mListeners) {
2709 l.onConnectionPropertiesChanged(this, mConnectionProperties);
2710 }
2711 }
2712 }
2713
2714 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002715 * Sets the supported audio routes.
2716 *
2717 * @param supportedAudioRoutes the supported audio routes as a bitmask.
2718 * See {@link CallAudioState}
2719 * @hide
2720 */
2721 public final void setSupportedAudioRoutes(int supportedAudioRoutes) {
2722 if ((supportedAudioRoutes
2723 & (CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_SPEAKER)) == 0) {
2724 throw new IllegalArgumentException(
2725 "supported audio routes must include either speaker or earpiece");
2726 }
2727
2728 if (mSupportedAudioRoutes != supportedAudioRoutes) {
2729 mSupportedAudioRoutes = supportedAudioRoutes;
2730 for (Listener l : mListeners) {
2731 l.onSupportedAudioRoutesChanged(this, mSupportedAudioRoutes);
2732 }
2733 }
2734 }
2735
2736 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002737 * Tears down the Connection object.
Santos Cordonb6939982014-06-04 20:20:58 -07002738 */
Evan Charlton36a71342014-07-19 16:31:02 -07002739 public final void destroy() {
Jay Shrauner229e3822014-08-15 09:23:07 -07002740 for (Listener l : mListeners) {
2741 l.onDestroyed(this);
Santos Cordond34e5712014-08-05 18:54:03 +00002742 }
Santos Cordonb6939982014-06-04 20:20:58 -07002743 }
2744
2745 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002746 * Requests that the framework use VOIP audio mode for this connection.
2747 *
2748 * @param isVoip True if the audio mode is VOIP.
2749 */
2750 public final void setAudioModeIsVoip(boolean isVoip) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002751 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002752 mAudioModeIsVoip = isVoip;
2753 for (Listener l : mListeners) {
2754 l.onAudioModeIsVoipChanged(this, isVoip);
2755 }
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002756 }
2757
2758 /**
Roshan Piuse927ec02015-07-15 15:47:21 -07002759 * Sets the time at which a call became active on this Connection. This is set only
2760 * when a conference call becomes active on this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002761 * <p>
Tyler Gunnc9503d62020-01-27 10:30:51 -08002762 * This time corresponds to the date/time of connection and is stored in the call log in
2763 * {@link android.provider.CallLog.Calls#DATE}.
2764 * <p>
Tyler Gunnc63f9082019-10-15 13:19:26 -07002765 * Used by telephony to maintain calls associated with an IMS Conference.
Roshan Piuse927ec02015-07-15 15:47:21 -07002766 *
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002767 * @param connectTimeMillis The connection time, in milliseconds. Should be set using a value
2768 * obtained from {@link System#currentTimeMillis()}.
Roshan Piuse927ec02015-07-15 15:47:21 -07002769 *
2770 * @hide
2771 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002772 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002773 @RequiresPermission(MODIFY_PHONE_STATE)
2774 public final void setConnectTimeMillis(@IntRange(from = 0) long connectTimeMillis) {
Roshan Piuse927ec02015-07-15 15:47:21 -07002775 mConnectTimeMillis = connectTimeMillis;
2776 }
2777
2778 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002779 * Sets the time at which a call became active on this Connection. This is set only
2780 * when a conference call becomes active on this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002781 * <p>
Tyler Gunnc9503d62020-01-27 10:30:51 -08002782 * This time is used to establish the duration of a call. It uses
2783 * {@link SystemClock#elapsedRealtime()} to ensure that the call duration is not impacted by
2784 * time zone changes during a call. The difference between the current
2785 * {@link SystemClock#elapsedRealtime()} and the value set at the connection start time is used
2786 * to populate {@link android.provider.CallLog.Calls#DURATION} in the call log.
2787 * <p>
Tyler Gunnc63f9082019-10-15 13:19:26 -07002788 * Used by telephony to maintain calls associated with an IMS Conference.
Tyler Gunnc9503d62020-01-27 10:30:51 -08002789 *
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002790 * @param connectElapsedTimeMillis The connection time, in milliseconds. Stored in the format
2791 * {@link SystemClock#elapsedRealtime()}.
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002792 * @hide
2793 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002794 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002795 @RequiresPermission(MODIFY_PHONE_STATE)
2796 public final void setConnectionStartElapsedRealtimeMillis(
2797 @ElapsedRealtimeLong long connectElapsedTimeMillis) {
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002798 mConnectElapsedTimeMillis = connectElapsedTimeMillis;
2799 }
2800
2801 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002802 * Sets the label and icon status to display in the in-call UI.
2803 *
2804 * @param statusHints The status label and icon to set.
2805 */
2806 public final void setStatusHints(StatusHints statusHints) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002807 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002808 mStatusHints = statusHints;
2809 for (Listener l : mListeners) {
2810 l.onStatusHintsChanged(this, statusHints);
2811 }
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002812 }
2813
2814 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002815 * Sets the connections with which this connection can be conferenced.
2816 *
2817 * @param conferenceableConnections The set of connections this connection can conference with.
2818 */
2819 public final void setConferenceableConnections(List<Connection> conferenceableConnections) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002820 checkImmutable();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002821 clearConferenceableList();
2822 for (Connection c : conferenceableConnections) {
2823 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
2824 // small amount of items here.
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002825 if (!mConferenceables.contains(c)) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002826 c.addConnectionListener(mConnectionDeathListener);
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002827 mConferenceables.add(c);
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002828 }
2829 }
2830 fireOnConferenceableConnectionsChanged();
2831 }
2832
2833 /**
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002834 * Similar to {@link #setConferenceableConnections(java.util.List)}, sets a list of connections
2835 * or conferences with which this connection can be conferenced.
2836 *
2837 * @param conferenceables The conferenceables.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002838 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002839 public final void setConferenceables(List<Conferenceable> conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002840 clearConferenceableList();
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002841 for (Conferenceable c : conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002842 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
2843 // small amount of items here.
2844 if (!mConferenceables.contains(c)) {
2845 if (c instanceof Connection) {
2846 Connection connection = (Connection) c;
2847 connection.addConnectionListener(mConnectionDeathListener);
2848 } else if (c instanceof Conference) {
2849 Conference conference = (Conference) c;
2850 conference.addListener(mConferenceDeathListener);
2851 }
2852 mConferenceables.add(c);
2853 }
2854 }
2855 fireOnConferenceableConnectionsChanged();
2856 }
2857
2858 /**
Tyler Gunnc63f9082019-10-15 13:19:26 -07002859 * Resets the CDMA connection time.
2860 * <p>
2861 * This is an implementation detail specific to legacy CDMA calls on mobile networks.
Mengjun Leng25707742017-07-04 11:10:37 +08002862 * @hide
Mengjun Leng25707742017-07-04 11:10:37 +08002863 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002864 @SystemApi
Mengjun Leng25707742017-07-04 11:10:37 +08002865 public final void resetConnectionTime() {
2866 for (Listener l : mListeners) {
2867 l.onConnectionTimeReset(this);
2868 }
2869 }
2870
2871 /**
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002872 * Returns the connections or conferences with which this connection can be conferenced.
2873 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002874 public final List<Conferenceable> getConferenceables() {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002875 return mUnmodifiableConferenceables;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002876 }
2877
Yorke Lee53463962015-08-04 16:07:19 -07002878 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002879 * @hide
2880 */
2881 public final void setConnectionService(ConnectionService connectionService) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002882 checkImmutable();
Santos Cordon823fd3c2014-08-07 18:35:18 -07002883 if (mConnectionService != null) {
2884 Log.e(this, new Exception(), "Trying to set ConnectionService on a connection " +
2885 "which is already associated with another ConnectionService.");
2886 } else {
2887 mConnectionService = connectionService;
2888 }
2889 }
2890
2891 /**
2892 * @hide
2893 */
2894 public final void unsetConnectionService(ConnectionService connectionService) {
2895 if (mConnectionService != connectionService) {
2896 Log.e(this, new Exception(), "Trying to remove ConnectionService from a Connection " +
2897 "that does not belong to the ConnectionService.");
2898 } else {
2899 mConnectionService = null;
2900 }
2901 }
2902
2903 /**
2904 * Sets the conference that this connection is a part of. This will fail if the connection is
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002905 * already part of a conference. {@link #resetConference} to un-set the conference first.
Santos Cordon823fd3c2014-08-07 18:35:18 -07002906 *
2907 * @param conference The conference.
2908 * @return {@code true} if the conference was successfully set.
2909 * @hide
2910 */
2911 public final boolean setConference(Conference conference) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002912 checkImmutable();
Santos Cordon823fd3c2014-08-07 18:35:18 -07002913 // We check to see if it is already part of another conference.
Santos Cordon0159ac02014-08-21 14:28:11 -07002914 if (mConference == null) {
Santos Cordon823fd3c2014-08-07 18:35:18 -07002915 mConference = conference;
Santos Cordon0159ac02014-08-21 14:28:11 -07002916 if (mConnectionService != null && mConnectionService.containsConference(conference)) {
2917 fireConferenceChanged();
2918 }
Santos Cordon823fd3c2014-08-07 18:35:18 -07002919 return true;
2920 }
2921 return false;
2922 }
2923
2924 /**
2925 * Resets the conference that this connection is a part of.
2926 * @hide
2927 */
2928 public final void resetConference() {
2929 if (mConference != null) {
Santos Cordon0159ac02014-08-21 14:28:11 -07002930 Log.d(this, "Conference reset");
Santos Cordon823fd3c2014-08-07 18:35:18 -07002931 mConference = null;
2932 fireConferenceChanged();
2933 }
2934 }
2935
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002936 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002937 * Set some extras that can be associated with this {@code Connection}.
2938 * <p>
2939 * New or existing keys are replaced in the {@code Connection} extras. Keys which are no longer
2940 * in the new extras, but were present the last time {@code setExtras} was called are removed.
2941 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07002942 * Alternatively you may use the {@link #putExtras(Bundle)}, and
2943 * {@link #removeExtras(String...)} methods to modify the extras.
2944 * <p>
Tyler Gunndee56a82016-03-23 16:06:34 -07002945 * 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 -07002946 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
2947 *
2948 * @param extras The extras associated with this {@code Connection}.
2949 */
2950 public final void setExtras(@Nullable Bundle extras) {
2951 checkImmutable();
Tyler Gunndee56a82016-03-23 16:06:34 -07002952
2953 // Add/replace any new or changed extras values.
2954 putExtras(extras);
2955
2956 // If we have used "setExtras" in the past, compare the key set from the last invocation to
2957 // the current one and remove any keys that went away.
2958 if (mPreviousExtraKeys != null) {
2959 List<String> toRemove = new ArrayList<String>();
2960 for (String oldKey : mPreviousExtraKeys) {
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07002961 if (extras == null || !extras.containsKey(oldKey)) {
Tyler Gunndee56a82016-03-23 16:06:34 -07002962 toRemove.add(oldKey);
2963 }
2964 }
2965 if (!toRemove.isEmpty()) {
2966 removeExtras(toRemove);
2967 }
2968 }
2969
2970 // Track the keys the last time set called setExtras. This way, the next time setExtras is
2971 // called we can see if the caller has removed any extras values.
2972 if (mPreviousExtraKeys == null) {
2973 mPreviousExtraKeys = new ArraySet<String>();
2974 }
2975 mPreviousExtraKeys.clear();
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07002976 if (extras != null) {
2977 mPreviousExtraKeys.addAll(extras.keySet());
2978 }
Tyler Gunndee56a82016-03-23 16:06:34 -07002979 }
2980
2981 /**
2982 * Adds some extras to this {@code Connection}. Existing keys are replaced and new ones are
2983 * added.
2984 * <p>
2985 * No assumptions should be made as to how an In-Call UI or service will handle these extras.
2986 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
2987 *
2988 * @param extras The extras to add.
2989 */
2990 public final void putExtras(@NonNull Bundle extras) {
2991 checkImmutable();
2992 if (extras == null) {
2993 return;
2994 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002995 // Creating a duplicate bundle so we don't have to synchronize on mExtrasLock while calling
2996 // the listeners.
2997 Bundle listenerExtras;
2998 synchronized (mExtrasLock) {
2999 if (mExtras == null) {
3000 mExtras = new Bundle();
3001 }
3002 mExtras.putAll(extras);
3003 listenerExtras = new Bundle(mExtras);
Tyler Gunndee56a82016-03-23 16:06:34 -07003004 }
Santos Cordon6b7f9552015-05-27 17:21:45 -07003005 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003006 // Create a new clone of the extras for each listener so that they don't clobber
3007 // each other
3008 l.onExtrasChanged(this, new Bundle(listenerExtras));
Santos Cordon6b7f9552015-05-27 17:21:45 -07003009 }
3010 }
3011
3012 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -07003013 * Removes extras from this {@code Connection}.
Tyler Gunndee56a82016-03-23 16:06:34 -07003014 *
Tyler Gunn071be6f2016-05-10 14:52:33 -07003015 * @param keys The keys of the extras to remove.
Tyler Gunndee56a82016-03-23 16:06:34 -07003016 */
3017 public final void removeExtras(List<String> keys) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003018 synchronized (mExtrasLock) {
3019 if (mExtras != null) {
3020 for (String key : keys) {
3021 mExtras.remove(key);
3022 }
Tyler Gunndee56a82016-03-23 16:06:34 -07003023 }
3024 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003025 List<String> unmodifiableKeys = Collections.unmodifiableList(keys);
Tyler Gunndee56a82016-03-23 16:06:34 -07003026 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003027 l.onExtrasRemoved(this, unmodifiableKeys);
Tyler Gunndee56a82016-03-23 16:06:34 -07003028 }
3029 }
3030
3031 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -07003032 * Removes extras from this {@code Connection}.
3033 *
3034 * @param keys The keys of the extras to remove.
3035 */
3036 public final void removeExtras(String ... keys) {
3037 removeExtras(Arrays.asList(keys));
3038 }
3039
3040 /**
Tyler Gunnf5035432017-01-09 09:43:12 -08003041 * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will
3042 * be change to the {@link #getCallAudioState()}.
3043 * <p>
3044 * Used by self-managed {@link ConnectionService}s which wish to change the audio route for a
3045 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
3046 * <p>
3047 * See also {@link InCallService#setAudioRoute(int)}.
3048 *
3049 * @param route The audio route to use (one of {@link CallAudioState#ROUTE_BLUETOOTH},
3050 * {@link CallAudioState#ROUTE_EARPIECE}, {@link CallAudioState#ROUTE_SPEAKER}, or
3051 * {@link CallAudioState#ROUTE_WIRED_HEADSET}).
3052 */
3053 public final void setAudioRoute(int route) {
3054 for (Listener l : mListeners) {
Hall Liua98f58b52017-11-07 17:59:28 -08003055 l.onAudioRouteChanged(this, route, null);
3056 }
3057 }
3058
3059 /**
Hall Liua98f58b52017-11-07 17:59:28 -08003060 * Request audio routing to a specific bluetooth device. Calling this method may result in
3061 * the device routing audio to a different bluetooth device than the one specified if the
3062 * bluetooth stack is unable to route audio to the requested device.
3063 * A list of available devices can be obtained via
3064 * {@link CallAudioState#getSupportedBluetoothDevices()}
3065 *
3066 * <p>
3067 * Used by self-managed {@link ConnectionService}s which wish to use bluetooth audio for a
3068 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
3069 * <p>
Hall Liu2b6a6a32018-04-02 13:52:57 -07003070 * See also {@link InCallService#requestBluetoothAudio(BluetoothDevice)}
3071 * @param bluetoothDevice The bluetooth device to connect to.
Hall Liua98f58b52017-11-07 17:59:28 -08003072 */
Hall Liu2b6a6a32018-04-02 13:52:57 -07003073 public void requestBluetoothAudio(@NonNull BluetoothDevice bluetoothDevice) {
Hall Liua98f58b52017-11-07 17:59:28 -08003074 for (Listener l : mListeners) {
Hall Liu2b6a6a32018-04-02 13:52:57 -07003075 l.onAudioRouteChanged(this, CallAudioState.ROUTE_BLUETOOTH,
3076 bluetoothDevice.getAddress());
Tyler Gunnf5035432017-01-09 09:43:12 -08003077 }
3078 }
3079
3080 /**
Hall Liub64ac4c2017-02-06 10:49:48 -08003081 * Informs listeners that a previously requested RTT session via
3082 * {@link ConnectionRequest#isRequestingRtt()} or
Hall Liu37dfdb02017-12-04 14:19:30 -08003083 * {@link #onStartRtt(RttTextStream)} has succeeded.
Hall Liub64ac4c2017-02-06 10:49:48 -08003084 */
3085 public final void sendRttInitiationSuccess() {
3086 mListeners.forEach((l) -> l.onRttInitiationSuccess(Connection.this));
3087 }
3088
3089 /**
3090 * Informs listeners that a previously requested RTT session via
Hall Liu37dfdb02017-12-04 14:19:30 -08003091 * {@link ConnectionRequest#isRequestingRtt()} or {@link #onStartRtt(RttTextStream)}
Hall Liub64ac4c2017-02-06 10:49:48 -08003092 * has failed.
3093 * @param reason One of the reason codes defined in {@link RttModifyStatus}, with the
3094 * exception of {@link RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}.
Hall Liub64ac4c2017-02-06 10:49:48 -08003095 */
3096 public final void sendRttInitiationFailure(int reason) {
3097 mListeners.forEach((l) -> l.onRttInitiationFailure(Connection.this, reason));
3098 }
3099
3100 /**
3101 * Informs listeners that a currently active RTT session has been terminated by the remote
3102 * side of the coll.
Hall Liub64ac4c2017-02-06 10:49:48 -08003103 */
3104 public final void sendRttSessionRemotelyTerminated() {
3105 mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this));
3106 }
3107
3108 /**
3109 * Informs listeners that the remote side of the call has requested an upgrade to include an
3110 * RTT session in the call.
Hall Liub64ac4c2017-02-06 10:49:48 -08003111 */
3112 public final void sendRemoteRttRequest() {
3113 mListeners.forEach((l) -> l.onRemoteRttRequest(Connection.this));
3114 }
3115
3116 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003117 * Notifies this Connection that the {@link #getAudioState()} property has a new value.
Sailesh Nepal400cc482014-06-26 12:04:00 -07003118 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003119 * @param state The new connection audio state.
Yorke Lee4af59352015-05-13 14:14:54 -07003120 * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead.
3121 * @hide
Sailesh Nepal400cc482014-06-26 12:04:00 -07003122 */
Yorke Lee4af59352015-05-13 14:14:54 -07003123 @SystemApi
3124 @Deprecated
Nancy Chen354b2bd2014-09-08 18:27:26 -07003125 public void onAudioStateChanged(AudioState state) {}
Sailesh Nepal400cc482014-06-26 12:04:00 -07003126
3127 /**
Yorke Lee4af59352015-05-13 14:14:54 -07003128 * Notifies this Connection that the {@link #getCallAudioState()} property has a new value.
3129 *
3130 * @param state The new connection audio state.
3131 */
3132 public void onCallAudioStateChanged(CallAudioState state) {}
3133
3134 /**
Grace Jiae99fde92021-01-19 14:58:01 -08003135 * Inform this Connection when it will or will not be tracked by an {@link InCallService} which
3136 * can provide an InCall UI.
3137 * This is primarily intended for use by Connections reported by self-managed
3138 * {@link ConnectionService} which typically maintain their own UI.
3139 *
3140 * @param isUsingAlternativeUi Indicates whether an InCallService that can provide InCall UI is
3141 * currently tracking the self-managed call.
3142 */
3143 public void onUsingAlternativeUi(boolean isUsingAlternativeUi) {}
3144
3145 /**
3146 * Inform this Conenection when it will or will not be tracked by an non-UI
3147 * {@link InCallService}.
3148 *
3149 * @param isTracked Indicates whether an non-UI InCallService is currently tracking the
3150 * self-managed call.
3151 */
3152 public void onTrackedByNonUiService(boolean isTracked) {}
3153
3154 /**
Evan Charltonbf11f982014-07-20 22:06:28 -07003155 * Notifies this Connection of an internal state change. This method is called after the
3156 * state is changed.
Ihab Awadf8358972014-05-28 16:46:42 -07003157 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003158 * @param state The new state, one of the {@code STATE_*} constants.
Ihab Awadf8358972014-05-28 16:46:42 -07003159 */
Nancy Chen354b2bd2014-09-08 18:27:26 -07003160 public void onStateChanged(int state) {}
Ihab Awadf8358972014-05-28 16:46:42 -07003161
3162 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07003163 * Notifies this Connection of a request to play a DTMF tone.
3164 *
3165 * @param c A DTMF character.
3166 */
Santos Cordonf2951102014-07-20 19:06:29 -07003167 public void onPlayDtmfTone(char c) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003168
3169 /**
3170 * Notifies this Connection of a request to stop any currently playing DTMF tones.
3171 */
Santos Cordonf2951102014-07-20 19:06:29 -07003172 public void onStopDtmfTone() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003173
3174 /**
3175 * Notifies this Connection of a request to disconnect.
3176 */
Santos Cordonf2951102014-07-20 19:06:29 -07003177 public void onDisconnect() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003178
3179 /**
Tyler Gunn3b4b1dc2014-11-04 14:53:37 -08003180 * Notifies this Connection of a request to disconnect a participant of the conference managed
3181 * by the connection.
3182 *
3183 * @param endpoint the {@link Uri} of the participant to disconnect.
3184 * @hide
3185 */
3186 public void onDisconnectConferenceParticipant(Uri endpoint) {}
3187
3188 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003189 * Notifies this Connection of a request to separate from its parent conference.
Santos Cordonb6939982014-06-04 20:20:58 -07003190 */
Santos Cordonf2951102014-07-20 19:06:29 -07003191 public void onSeparate() {}
Santos Cordonb6939982014-06-04 20:20:58 -07003192
3193 /**
Tyler Gunn0c62ef02020-02-11 14:39:43 -08003194 * Supports initiation of a conference call by directly adding participants to an ongoing call.
Ravi Paluri404babb2020-01-23 19:02:44 +05303195 *
3196 * @param participants with which conference call will be formed.
3197 */
3198 public void onAddConferenceParticipants(@NonNull List<Uri> participants) {}
3199
3200 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07003201 * Notifies this Connection of a request to abort.
3202 */
Santos Cordonf2951102014-07-20 19:06:29 -07003203 public void onAbort() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003204
3205 /**
3206 * Notifies this Connection of a request to hold.
3207 */
Santos Cordonf2951102014-07-20 19:06:29 -07003208 public void onHold() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003209
3210 /**
3211 * Notifies this Connection of a request to exit a hold state.
3212 */
Santos Cordonf2951102014-07-20 19:06:29 -07003213 public void onUnhold() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003214
3215 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003216 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Santos Cordond34e5712014-08-05 18:54:03 +00003217 * a request to accept.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003218 * <p>
3219 * For managed {@link ConnectionService}s, this will be called when the user answers a call via
3220 * the default dialer's {@link InCallService}.
3221 * <p>
3222 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3223 * Telecom framework may request that the call is answered in the following circumstances:
3224 * <ul>
3225 * <li>The user chooses to answer an incoming call via a Bluetooth device.</li>
3226 * <li>A car mode {@link InCallService} is in use which has declared
3227 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3228 * {@link InCallService} will be able to see calls from self-managed
3229 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3230 * behalf.</li>
3231 * </ul>
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003232 * @param videoState The video state in which to answer the connection.
Ihab Awad542e0ea2014-05-16 10:22:16 -07003233 */
Santos Cordonf2951102014-07-20 19:06:29 -07003234 public void onAnswer(int videoState) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003235
3236 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003237 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Tyler Gunnbe74de02014-08-29 14:51:48 -07003238 * a request to accept.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003239 * <p>
3240 * For managed {@link ConnectionService}s, this will be called when the user answers a call via
3241 * the default dialer's {@link InCallService}.
3242 * <p>
3243 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3244 * Telecom framework may request that the call is answered in the following circumstances:
3245 * <ul>
3246 * <li>The user chooses to answer an incoming call via a Bluetooth device.</li>
3247 * <li>A car mode {@link InCallService} is in use which has declared
3248 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3249 * {@link InCallService} will be able to see calls from self-managed
3250 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3251 * behalf.</li>
3252 * </ul>
Tyler Gunnbe74de02014-08-29 14:51:48 -07003253 */
3254 public void onAnswer() {
Tyler Gunn87b73f32015-06-03 10:09:59 -07003255 onAnswer(VideoProfile.STATE_AUDIO_ONLY);
Tyler Gunnbe74de02014-08-29 14:51:48 -07003256 }
3257
3258 /**
3259 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Pooja Jaind34698d2017-12-28 14:15:31 +05303260 * a request to deflect.
3261 */
3262 public void onDeflect(Uri address) {}
3263
3264 /**
3265 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Santos Cordond34e5712014-08-05 18:54:03 +00003266 * a request to reject.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003267 * <p>
3268 * For managed {@link ConnectionService}s, this will be called when the user rejects a call via
3269 * the default dialer's {@link InCallService}.
3270 * <p>
3271 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3272 * Telecom framework may request that the call is rejected in the following circumstances:
3273 * <ul>
3274 * <li>The user chooses to reject an incoming call via a Bluetooth device.</li>
3275 * <li>A car mode {@link InCallService} is in use which has declared
3276 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3277 * {@link InCallService} will be able to see calls from self-managed
3278 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3279 * behalf.</li>
3280 * </ul>
Ihab Awad542e0ea2014-05-16 10:22:16 -07003281 */
Santos Cordonf2951102014-07-20 19:06:29 -07003282 public void onReject() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003283
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003284 /**
Tyler Gunnfacfdee2020-01-23 13:10:37 -08003285 * Notifies this Connection, which is in {@link #STATE_RINGING}, of a request to reject.
3286 * <p>
3287 * For managed {@link ConnectionService}s, this will be called when the user rejects a call via
3288 * the default dialer's {@link InCallService} using {@link Call#reject(int)}.
3289 * @param rejectReason the reason the user provided for rejecting the call.
3290 */
3291 public void onReject(@android.telecom.Call.RejectReason int rejectReason) {
3292 // to be implemented by ConnectionService.
3293 }
3294
3295 /**
Hall Liu712acbe2016-03-14 16:38:56 -07003296 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
3297 * a request to reject with a message.
Bryce Lee81901682015-08-28 16:38:02 -07003298 */
3299 public void onReject(String replyMessage) {}
3300
3301 /**
Ravi Palurif4b38e72020-02-05 12:35:41 +05303302 * Notifies this Connection, a request to transfer to a target number.
3303 * @param number the number to transfer this {@link Connection} to.
3304 * @param isConfirmationRequired when {@code true}, the {@link ConnectionService}
3305 * should wait until the transfer has successfully completed before disconnecting
3306 * the current {@link Connection}.
3307 * When {@code false}, the {@link ConnectionService} should signal the network to
3308 * perform the transfer, but should immediately disconnect the call regardless of
3309 * the outcome of the transfer.
3310 * @hide
3311 */
3312 public void onTransfer(@NonNull Uri number, boolean isConfirmationRequired) {}
3313
3314 /**
3315 * Notifies this Connection, a request to transfer to another Connection.
3316 * @param otherConnection the {@link Connection} to transfer this call to.
3317 * @hide
3318 */
3319 public void onTransfer(@NonNull Connection otherConnection) {}
3320
3321 /**
Tyler Gunn06f06162018-06-18 11:24:15 -07003322 * Notifies this Connection of a request to silence the ringer.
3323 * <p>
3324 * The ringer may be silenced by any of the following methods:
3325 * <ul>
3326 * <li>{@link TelecomManager#silenceRinger()}</li>
3327 * <li>The user presses the volume-down button while a call is ringing.</li>
3328 * </ul>
3329 * <p>
3330 * Self-managed {@link ConnectionService} implementations should override this method in their
3331 * {@link Connection} implementation and implement logic to silence their app's ringtone. If
3332 * your app set the ringtone as part of the incoming call {@link Notification} (see
3333 * {@link #onShowIncomingCallUi()}), it should re-post the notification now, except call
3334 * {@link android.app.Notification.Builder#setOnlyAlertOnce(boolean)} with {@code true}. This
3335 * will ensure the ringtone sound associated with your {@link android.app.NotificationChannel}
3336 * stops playing.
Bryce Leecac50772015-11-17 15:13:29 -08003337 */
3338 public void onSilence() {}
3339
3340 /**
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003341 * Notifies this Connection whether the user wishes to proceed with the post-dial DTMF codes.
3342 */
Santos Cordonf2951102014-07-20 19:06:29 -07003343 public void onPostDialContinue(boolean proceed) {}
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003344
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003345 /**
3346 * Notifies this Connection of a request to pull an external call to the local device.
3347 * <p>
3348 * The {@link InCallService} issues a request to pull an external call to the local device via
3349 * {@link Call#pullExternalCall()}.
3350 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -07003351 * For a Connection to be pulled, both the {@link Connection#CAPABILITY_CAN_PULL_CALL}
3352 * capability and {@link Connection#PROPERTY_IS_EXTERNAL_CALL} property bits must be set.
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003353 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -07003354 * For more information on external calls, see {@link Connection#PROPERTY_IS_EXTERNAL_CALL}.
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003355 */
3356 public void onPullExternalCall() {}
3357
3358 /**
3359 * Notifies this Connection of a {@link Call} event initiated from an {@link InCallService}.
3360 * <p>
3361 * The {@link InCallService} issues a Call event via {@link Call#sendCallEvent(String, Bundle)}.
3362 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003363 * Where possible, the Connection should make an attempt to handle {@link Call} events which
3364 * are part of the {@code android.telecom.*} namespace. The Connection should ignore any events
3365 * it does not wish to handle. Unexpected events should be handled gracefully, as it is
3366 * possible that a {@link InCallService} has defined its own Call events which a Connection is
3367 * not aware of.
3368 * <p>
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003369 * See also {@link Call#sendCallEvent(String, Bundle)}.
3370 *
3371 * @param event The call event.
3372 * @param extras Extras associated with the call event.
3373 */
3374 public void onCallEvent(String event, Bundle extras) {}
3375
Tyler Gunndee56a82016-03-23 16:06:34 -07003376 /**
Tyler Gunn79bc1ec2018-01-22 15:17:54 -08003377 * Notifies this {@link Connection} that a handover has completed.
3378 * <p>
3379 * A handover is initiated with {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int,
3380 * Bundle)} on the initiating side of the handover, and
3381 * {@link TelecomManager#acceptHandover(Uri, int, PhoneAccountHandle)}.
3382 */
3383 public void onHandoverComplete() {}
3384
3385 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07003386 * Notifies this {@link Connection} of a change to the extras made outside the
3387 * {@link ConnectionService}.
3388 * <p>
3389 * These extras changes can originate from Telecom itself, or from an {@link InCallService} via
3390 * the {@link android.telecom.Call#putExtras(Bundle)} and
3391 * {@link Call#removeExtras(List)}.
3392 *
3393 * @param extras The new extras bundle.
3394 */
3395 public void onExtrasChanged(Bundle extras) {}
3396
Tyler Gunnf5035432017-01-09 09:43:12 -08003397 /**
3398 * Notifies this {@link Connection} that its {@link ConnectionService} is responsible for
3399 * displaying its incoming call user interface for the {@link Connection}.
3400 * <p>
3401 * Will only be called for incoming calls added via a self-managed {@link ConnectionService}
3402 * (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}), where the {@link ConnectionService}
3403 * should show its own incoming call user interface.
3404 * <p>
3405 * Where there are ongoing calls in other self-managed {@link ConnectionService}s, or in a
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003406 * regular {@link ConnectionService}, and it is not possible to hold these other calls, the
3407 * Telecom framework will display its own incoming call user interface to allow the user to
3408 * choose whether to answer the new incoming call and disconnect other ongoing calls, or to
3409 * reject the new incoming call.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003410 * <p>
3411 * You should trigger the display of the incoming call user interface for your application by
3412 * showing a {@link Notification} with a full-screen {@link Intent} specified.
Tyler Gunn06f06162018-06-18 11:24:15 -07003413 *
3414 * In your application code, you should create a {@link android.app.NotificationChannel} for
3415 * incoming call notifications from your app:
3416 * <pre><code>
3417 * NotificationChannel channel = new NotificationChannel(YOUR_CHANNEL_ID, "Incoming Calls",
3418 * NotificationManager.IMPORTANCE_MAX);
3419 * // other channel setup stuff goes here.
3420 *
3421 * // We'll use the default system ringtone for our incoming call notification channel. You can
3422 * // use your own audio resource here.
3423 * Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
3424 * channel.setSound(ringtoneUri, new AudioAttributes.Builder()
3425 * // Setting the AudioAttributes is important as it identifies the purpose of your
3426 * // notification sound.
3427 * .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
3428 * .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
3429 * .build());
3430 *
3431 * NotificationManager mgr = getSystemService(NotificationManager.class);
3432 * mgr.createNotificationChannel(channel);
3433 * </code></pre>
3434 * When it comes time to post a notification for your incoming call, ensure it uses your
3435 * incoming call {@link android.app.NotificationChannel}.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003436 * <pre><code>
3437 * // Create an intent which triggers your fullscreen incoming call user interface.
3438 * Intent intent = new Intent(Intent.ACTION_MAIN, null);
3439 * intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_ACTIVITY_NEW_TASK);
3440 * intent.setClass(context, YourIncomingCallActivity.class);
Ashwini Orugantif8191e82021-01-07 12:04:25 -08003441 * PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_MUTABLE_UNAUDITED);
Tyler Gunn159f35c2017-03-02 09:28:37 -08003442 *
3443 * // Build the notification as an ongoing high priority item; this ensures it will show as
3444 * // a heads up notification which slides down over top of the current content.
3445 * final Notification.Builder builder = new Notification.Builder(context);
3446 * builder.setOngoing(true);
3447 * builder.setPriority(Notification.PRIORITY_HIGH);
3448 *
3449 * // Set notification content intent to take user to fullscreen UI if user taps on the
3450 * // notification body.
3451 * builder.setContentIntent(pendingIntent);
3452 * // Set full screen intent to trigger display of the fullscreen UI when the notification
3453 * // manager deems it appropriate.
3454 * builder.setFullScreenIntent(pendingIntent, true);
3455 *
3456 * // Setup notification content.
3457 * builder.setSmallIcon( yourIconResourceId );
3458 * builder.setContentTitle("Your notification title");
3459 * builder.setContentText("Your notification content.");
3460 *
Tyler Gunn06f06162018-06-18 11:24:15 -07003461 * // Set notification as insistent to cause your ringtone to loop.
3462 * Notification notification = builder.build();
3463 * notification.flags |= Notification.FLAG_INSISTENT;
Tyler Gunn159f35c2017-03-02 09:28:37 -08003464 *
Tyler Gunn06f06162018-06-18 11:24:15 -07003465 * // Use builder.addAction(..) to add buttons to answer or reject the call.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003466 * NotificationManager notificationManager = mContext.getSystemService(
3467 * NotificationManager.class);
Tyler Gunn06f06162018-06-18 11:24:15 -07003468 * notificationManager.notify(YOUR_CHANNEL_ID, YOUR_TAG, YOUR_ID, notification);
Tyler Gunn159f35c2017-03-02 09:28:37 -08003469 * </code></pre>
Tyler Gunnf5035432017-01-09 09:43:12 -08003470 */
3471 public void onShowIncomingCallUi() {}
3472
Hall Liub64ac4c2017-02-06 10:49:48 -08003473 /**
3474 * Notifies this {@link Connection} that the user has requested an RTT session.
3475 * The connection service should call {@link #sendRttInitiationSuccess} or
3476 * {@link #sendRttInitiationFailure} to inform Telecom of the success or failure of the
3477 * request, respectively.
3478 * @param rttTextStream The object that should be used to send text to or receive text from
3479 * the in-call app.
Hall Liub64ac4c2017-02-06 10:49:48 -08003480 */
3481 public void onStartRtt(@NonNull RttTextStream rttTextStream) {}
3482
3483 /**
3484 * Notifies this {@link Connection} that it should terminate any existing RTT communication
3485 * channel. No response to Telecom is needed for this method.
Hall Liub64ac4c2017-02-06 10:49:48 -08003486 */
3487 public void onStopRtt() {}
3488
3489 /**
3490 * Notifies this connection of a response to a previous remotely-initiated RTT upgrade
3491 * request sent via {@link #sendRemoteRttRequest}. Acceptance of the request is
3492 * indicated by the supplied {@link RttTextStream} being non-null, and rejection is
3493 * indicated by {@code rttTextStream} being {@code null}
Hall Liub64ac4c2017-02-06 10:49:48 -08003494 * @param rttTextStream The object that should be used to send text to or receive text from
3495 * the in-call app.
3496 */
3497 public void handleRttUpgradeResponse(@Nullable RttTextStream rttTextStream) {}
3498
Hall Liu49cabcc2021-01-15 11:41:48 -08003499 /**
Hall Liu73903142021-02-18 18:41:41 -08003500 * Information provided to a {@link Connection} upon completion of call filtering in Telecom.
3501 *
3502 * @hide
3503 */
3504 @SystemApi
3505 public static final class CallFilteringCompletionInfo implements Parcelable {
3506 private final boolean mIsBlocked;
3507 private final boolean mIsInContacts;
3508 private final CallScreeningService.CallResponse mCallResponse;
3509 private final ComponentName mCallScreeningComponent;
3510
3511 /**
3512 * Constructor for {@link CallFilteringCompletionInfo}
3513 *
3514 * @param isBlocked Whether any part of the call filtering process indicated that this call
3515 * should be blocked.
3516 * @param isInContacts Whether the caller is in the user's contacts.
3517 * @param callResponse The instance of {@link CallScreeningService.CallResponse} provided
3518 * by the {@link CallScreeningService} that processed this call, or
3519 * {@code null} if no call screening service ran.
3520 * @param callScreeningComponent The component of the {@link CallScreeningService}
3521 * that processed this call, or {@link null} if no
3522 * call screening service ran.
3523 */
3524 public CallFilteringCompletionInfo(boolean isBlocked, boolean isInContacts,
3525 @Nullable CallScreeningService.CallResponse callResponse,
3526 @Nullable ComponentName callScreeningComponent) {
3527 mIsBlocked = isBlocked;
3528 mIsInContacts = isInContacts;
3529 mCallResponse = callResponse;
3530 mCallScreeningComponent = callScreeningComponent;
3531 }
3532
3533 /** @hide */
3534 protected CallFilteringCompletionInfo(Parcel in) {
3535 mIsBlocked = in.readByte() != 0;
3536 mIsInContacts = in.readByte() != 0;
3537 CallScreeningService.ParcelableCallResponse response
3538 = in.readParcelable(CallScreeningService.class.getClassLoader());
3539 mCallResponse = response == null ? null : response.toCallResponse();
3540 mCallScreeningComponent = in.readParcelable(ComponentName.class.getClassLoader());
3541 }
3542
3543 @NonNull
3544 public static final Creator<CallFilteringCompletionInfo> CREATOR =
3545 new Creator<CallFilteringCompletionInfo>() {
3546 @Override
3547 public CallFilteringCompletionInfo createFromParcel(Parcel in) {
3548 return new CallFilteringCompletionInfo(in);
3549 }
3550
3551 @Override
3552 public CallFilteringCompletionInfo[] newArray(int size) {
3553 return new CallFilteringCompletionInfo[size];
3554 }
3555 };
3556
3557 /**
3558 * @return Whether any part of the call filtering process indicated that this call should be
3559 * blocked.
3560 */
3561 public boolean isBlocked() {
3562 return mIsBlocked;
3563 }
3564
3565 /**
3566 * @return Whether the caller is in the user's contacts.
3567 */
3568 public boolean isInContacts() {
3569 return mIsInContacts;
3570 }
3571
3572 /**
3573 * @return The instance of {@link CallScreeningService.CallResponse} provided
3574 * by the {@link CallScreeningService} that processed this
3575 * call, or {@code null} if no call screening service ran.
3576 */
3577 public @Nullable CallScreeningService.CallResponse getCallResponse() {
3578 return mCallResponse;
3579 }
3580
3581 /**
3582 * @return The component of the {@link CallScreeningService}
3583 * that processed this call, or {@code null} if no call screening service ran.
3584 */
3585 public @Nullable ComponentName getCallScreeningComponent() {
3586 return mCallScreeningComponent;
3587 }
3588
3589 @Override
3590 public int describeContents() {
3591 return 0;
3592 }
3593
3594 @Override
3595 public String toString() {
3596 return "CallFilteringCompletionInfo{" +
3597 "mIsBlocked=" + mIsBlocked +
3598 ", mIsInContacts=" + mIsInContacts +
3599 ", mCallResponse=" + mCallResponse +
3600 ", mCallScreeningPackageName='" + mCallScreeningComponent + '\'' +
3601 '}';
3602 }
3603
3604 /** @hide */
3605 @Override
3606 public void writeToParcel(Parcel dest, int flags) {
3607 dest.writeByte((byte) (mIsBlocked ? 1 : 0));
3608 dest.writeByte((byte) (mIsInContacts ? 1 : 0));
3609 dest.writeParcelable(mCallResponse == null ? null : mCallResponse.toParcelable(), 0);
3610 dest.writeParcelable(mCallScreeningComponent, 0);
3611 }
3612 }
3613
3614 /**
Hall Liu49cabcc2021-01-15 11:41:48 -08003615 * Indicates that call filtering in Telecom is complete
3616 *
3617 * This method is called for a connection created via
3618 * {@link ConnectionService#onCreateIncomingConnection} when call filtering completes in
3619 * Telecom, including checking the blocked number db, per-contact settings, and custom call
3620 * filtering apps.
3621 *
Hall Liu73903142021-02-18 18:41:41 -08003622 * @param callFilteringCompletionInfo Info provided by Telecom on the results of call filtering.
Hall Liu49cabcc2021-01-15 11:41:48 -08003623 * @hide
3624 */
3625 @SystemApi
3626 @RequiresPermission(Manifest.permission.READ_CONTACTS)
Hall Liu73903142021-02-18 18:41:41 -08003627 public void onCallFilteringCompleted(
3628 @NonNull CallFilteringCompletionInfo callFilteringCompletionInfo) { }
Hall Liu49cabcc2021-01-15 11:41:48 -08003629
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003630 static String toLogSafePhoneNumber(String number) {
3631 // For unknown number, log empty string.
3632 if (number == null) {
3633 return "";
3634 }
3635
3636 if (PII_DEBUG) {
3637 // When PII_DEBUG is true we emit PII.
3638 return number;
3639 }
3640
3641 // Do exactly same thing as Uri#toSafeString() does, which will enable us to compare
3642 // sanitized phone numbers.
3643 StringBuilder builder = new StringBuilder();
3644 for (int i = 0; i < number.length(); i++) {
3645 char c = number.charAt(i);
3646 if (c == '-' || c == '@' || c == '.') {
3647 builder.append(c);
3648 } else {
3649 builder.append('x');
3650 }
3651 }
3652 return builder.toString();
3653 }
3654
Ihab Awad542e0ea2014-05-16 10:22:16 -07003655 private void setState(int state) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003656 checkImmutable();
Ihab Awad6107bab2014-08-18 09:23:25 -07003657 if (mState == STATE_DISCONNECTED && mState != state) {
3658 Log.d(this, "Connection already DISCONNECTED; cannot transition out of this state.");
Evan Charltonbf11f982014-07-20 22:06:28 -07003659 return;
Sailesh Nepal400cc482014-06-26 12:04:00 -07003660 }
Evan Charltonbf11f982014-07-20 22:06:28 -07003661 if (mState != state) {
3662 Log.d(this, "setState: %s", stateToString(state));
3663 mState = state;
Nancy Chen354b2bd2014-09-08 18:27:26 -07003664 onStateChanged(state);
Evan Charltonbf11f982014-07-20 22:06:28 -07003665 for (Listener l : mListeners) {
3666 l.onStateChanged(this, state);
3667 }
Evan Charltonbf11f982014-07-20 22:06:28 -07003668 }
3669 }
3670
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07003671 private static class FailureSignalingConnection extends Connection {
Ihab Awad90e34e32014-12-01 16:23:17 -08003672 private boolean mImmutable = false;
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003673 public FailureSignalingConnection(DisconnectCause disconnectCause) {
3674 setDisconnected(disconnectCause);
Tyler Gunn2915af72020-03-06 11:36:21 -08003675 mImmutable = true;
Ihab Awad6107bab2014-08-18 09:23:25 -07003676 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003677
3678 public void checkImmutable() {
Ihab Awad90e34e32014-12-01 16:23:17 -08003679 if (mImmutable) {
3680 throw new UnsupportedOperationException("Connection is immutable");
3681 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003682 }
Ihab Awad6107bab2014-08-18 09:23:25 -07003683 }
3684
Evan Charltonbf11f982014-07-20 22:06:28 -07003685 /**
Ihab Awad6107bab2014-08-18 09:23:25 -07003686 * Return a {@code Connection} which represents a failed connection attempt. The returned
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003687 * {@code Connection} will have a {@link android.telecom.DisconnectCause} and as specified,
3688 * and a {@link #getState()} of {@link #STATE_DISCONNECTED}.
Ihab Awad6107bab2014-08-18 09:23:25 -07003689 * <p>
3690 * The returned {@code Connection} can be assumed to {@link #destroy()} itself when appropriate,
3691 * so users of this method need not maintain a reference to its return value to destroy it.
Evan Charltonbf11f982014-07-20 22:06:28 -07003692 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003693 * @param disconnectCause The disconnect cause, ({@see android.telecomm.DisconnectCause}).
Ihab Awad6107bab2014-08-18 09:23:25 -07003694 * @return A {@code Connection} which indicates failure.
Evan Charltonbf11f982014-07-20 22:06:28 -07003695 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003696 public static Connection createFailedConnection(DisconnectCause disconnectCause) {
3697 return new FailureSignalingConnection(disconnectCause);
Evan Charltonbf11f982014-07-20 22:06:28 -07003698 }
3699
Evan Charltonbf11f982014-07-20 22:06:28 -07003700 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003701 * Override to throw an {@link UnsupportedOperationException} if this {@code Connection} is
3702 * not intended to be mutated, e.g., if it is a marker for failure. Only for framework use;
3703 * this should never be un-@hide-den.
3704 *
3705 * @hide
3706 */
3707 public void checkImmutable() {}
3708
3709 /**
Ihab Awad6107bab2014-08-18 09:23:25 -07003710 * Return a {@code Connection} which represents a canceled connection attempt. The returned
3711 * {@code Connection} will have state {@link #STATE_DISCONNECTED}, and cannot be moved out of
3712 * that state. This connection should not be used for anything, and no other
3713 * {@code Connection}s should be attempted.
3714 * <p>
Ihab Awad6107bab2014-08-18 09:23:25 -07003715 * so users of this method need not maintain a reference to its return value to destroy it.
Evan Charltonbf11f982014-07-20 22:06:28 -07003716 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003717 * @return A {@code Connection} which indicates that the underlying connection should
3718 * be canceled.
Evan Charltonbf11f982014-07-20 22:06:28 -07003719 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003720 public static Connection createCanceledConnection() {
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003721 return new FailureSignalingConnection(new DisconnectCause(DisconnectCause.CANCELED));
Ihab Awad542e0ea2014-05-16 10:22:16 -07003722 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003723
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003724 private final void fireOnConferenceableConnectionsChanged() {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003725 for (Listener l : mListeners) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003726 l.onConferenceablesChanged(this, getConferenceables());
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003727 }
3728 }
3729
Santos Cordon823fd3c2014-08-07 18:35:18 -07003730 private final void fireConferenceChanged() {
3731 for (Listener l : mListeners) {
3732 l.onConferenceChanged(this, mConference);
3733 }
3734 }
3735
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003736 private final void clearConferenceableList() {
Tyler Gunndf2cbc82015-04-20 09:13:01 -07003737 for (Conferenceable c : mConferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003738 if (c instanceof Connection) {
3739 Connection connection = (Connection) c;
3740 connection.removeConnectionListener(mConnectionDeathListener);
3741 } else if (c instanceof Conference) {
3742 Conference conference = (Conference) c;
3743 conference.removeListener(mConferenceDeathListener);
3744 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003745 }
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003746 mConferenceables.clear();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003747 }
Tyler Gunn3bffcf72014-10-28 13:51:27 -07003748
3749 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07003750 * Handles a change to extras received from Telecom.
3751 *
3752 * @param extras The new extras.
3753 * @hide
3754 */
3755 final void handleExtrasChanged(Bundle extras) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003756 Bundle b = null;
3757 synchronized (mExtrasLock) {
3758 mExtras = extras;
3759 if (mExtras != null) {
3760 b = new Bundle(mExtras);
3761 }
3762 }
3763 onExtrasChanged(b);
Tyler Gunndee56a82016-03-23 16:06:34 -07003764 }
3765
3766 /**
Tyler Gunnc63f9082019-10-15 13:19:26 -07003767 * Called by a {@link ConnectionService} to notify Telecom that a {@link Conference#onMerge()}
3768 * request failed.
Anthony Lee17455a32015-04-24 15:25:29 -07003769 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003770 public final void notifyConferenceMergeFailed() {
Anthony Lee17455a32015-04-24 15:25:29 -07003771 for (Listener l : mListeners) {
3772 l.onConferenceMergeFailed(this);
3773 }
3774 }
3775
3776 /**
Srikanth Chintalafcb15012017-05-04 20:58:34 +05303777 * Notifies listeners when phone account is changed. For example, when the PhoneAccount is
3778 * changed due to an emergency call being redialed.
3779 * @param pHandle The new PhoneAccountHandle for this connection.
3780 * @hide
3781 */
3782 public void notifyPhoneAccountChanged(PhoneAccountHandle pHandle) {
3783 for (Listener l : mListeners) {
3784 l.onPhoneAccountChanged(this, pHandle);
3785 }
3786 }
3787
3788 /**
Pengquan Meng70c9885332017-10-02 18:09:03 -07003789 * Sets the {@link PhoneAccountHandle} associated with this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003790 * <p>
3791 * Used by the Telephony {@link ConnectionService} to handle changes to the {@link PhoneAccount}
3792 * which take place after call initiation (important for emergency calling scenarios).
Pengquan Meng70c9885332017-10-02 18:09:03 -07003793 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07003794 * @param phoneAccountHandle the phone account handle to set.
Pengquan Meng70c9885332017-10-02 18:09:03 -07003795 * @hide
3796 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003797 @SystemApi
3798 public void setPhoneAccountHandle(@NonNull PhoneAccountHandle phoneAccountHandle) {
Pengquan Meng70c9885332017-10-02 18:09:03 -07003799 if (mPhoneAccountHandle != phoneAccountHandle) {
3800 mPhoneAccountHandle = phoneAccountHandle;
3801 notifyPhoneAccountChanged(phoneAccountHandle);
3802 }
3803 }
3804
3805 /**
3806 * Returns the {@link PhoneAccountHandle} associated with this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003807 * <p>
3808 * Used by the Telephony {@link ConnectionService} to handle changes to the {@link PhoneAccount}
3809 * which take place after call initiation (important for emergency calling scenarios).
Pengquan Meng70c9885332017-10-02 18:09:03 -07003810 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07003811 * @return the phone account handle specified via
3812 * {@link #setPhoneAccountHandle(PhoneAccountHandle)}, or {@code null} if none was set.
Pengquan Meng70c9885332017-10-02 18:09:03 -07003813 * @hide
3814 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003815 @SystemApi
3816 public @Nullable PhoneAccountHandle getPhoneAccountHandle() {
Pengquan Meng70c9885332017-10-02 18:09:03 -07003817 return mPhoneAccountHandle;
3818 }
3819
3820 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003821 * Sends an event associated with this {@code Connection} with associated event extras to the
3822 * {@link InCallService}.
3823 * <p>
3824 * Connection events are used to communicate point in time information from a
3825 * {@link ConnectionService} to a {@link InCallService} implementations. An example of a
3826 * custom connection event includes notifying the UI when a WIFI call has been handed over to
3827 * LTE, which the InCall UI might use to inform the user that billing charges may apply. The
3828 * Android Telephony framework will send the {@link #EVENT_CALL_MERGE_FAILED} connection event
3829 * when a call to {@link Call#mergeConference()} has failed to complete successfully. A
3830 * connection event could also be used to trigger UI in the {@link InCallService} which prompts
3831 * the user to make a choice (e.g. whether they want to incur roaming costs for making a call),
3832 * which is communicated back via {@link Call#sendCallEvent(String, Bundle)}.
3833 * <p>
3834 * Events are exposed to {@link InCallService} implementations via
3835 * {@link Call.Callback#onConnectionEvent(Call, String, Bundle)}.
3836 * <p>
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003837 * 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 -07003838 * The {@link ConnectionService} must assume that the In-Call UI could even chose to ignore
3839 * some events altogether.
3840 * <p>
3841 * Events should be fully qualified (e.g. {@code com.example.event.MY_EVENT}) to avoid
3842 * conflicts between {@link ConnectionService} implementations. Further, custom
3843 * {@link ConnectionService} implementations shall not re-purpose events in the
3844 * {@code android.*} namespace, nor shall they define new event types in this namespace. When
3845 * defining a custom event type, ensure the contents of the extras {@link Bundle} is clearly
3846 * defined. Extra keys for this bundle should be named similar to the event type (e.g.
3847 * {@code com.example.extra.MY_EXTRA}).
3848 * <p>
3849 * When defining events and the associated extras, it is important to keep their behavior
3850 * consistent when the associated {@link ConnectionService} is updated. Support for deprecated
3851 * events/extras should me maintained to ensure backwards compatibility with older
3852 * {@link InCallService} implementations which were built to support the older behavior.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003853 *
3854 * @param event The connection event.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003855 * @param extras Optional bundle containing extra information associated with the event.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003856 */
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003857 public void sendConnectionEvent(String event, Bundle extras) {
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003858 for (Listener l : mListeners) {
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07003859 l.onConnectionEvent(this, event, extras);
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003860 }
3861 }
Tyler Gunn6986a632019-06-25 13:45:32 -07003862
3863 /**
3864 * @return The direction of the call.
3865 * @hide
3866 */
3867 public final @Call.Details.CallDirection int getCallDirection() {
3868 return mCallDirection;
3869 }
3870
3871 /**
3872 * Sets the direction of this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003873 * <p>
3874 * Used when calling {@link ConnectionService#addExistingConnection} to specify the existing
3875 * call direction.
3876 *
Tyler Gunn6986a632019-06-25 13:45:32 -07003877 * @param callDirection The direction of this connection.
3878 * @hide
3879 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003880 @SystemApi
Tyler Gunn6986a632019-06-25 13:45:32 -07003881 public void setCallDirection(@Call.Details.CallDirection int callDirection) {
3882 mCallDirection = callDirection;
3883 }
Tyler Gunnd57d76c2019-09-24 14:53:23 -07003884
3885 /**
3886 * Gets the verification status for the phone number of an incoming call as identified in
3887 * ATIS-1000082.
3888 * @return the verification status.
3889 */
Tyler Gunna131d6e2020-02-13 14:53:28 -08003890 public final @VerificationStatus int getCallerNumberVerificationStatus() {
Tyler Gunnd57d76c2019-09-24 14:53:23 -07003891 return mCallerNumberVerificationStatus;
3892 }
3893
3894 /**
3895 * Sets the verification status for the phone number of an incoming call as identified in
3896 * ATIS-1000082.
3897 * <p>
3898 * This property can only be set at the time of creation of a {@link Connection} being returned
3899 * by
3900 * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)}.
3901 */
Tyler Gunna131d6e2020-02-13 14:53:28 -08003902 public final void setCallerNumberVerificationStatus(
Tyler Gunnd57d76c2019-09-24 14:53:23 -07003903 @VerificationStatus int callerNumberVerificationStatus) {
3904 mCallerNumberVerificationStatus = callerNumberVerificationStatus;
3905 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07003906}