blob: 6a283df5b48068bcfafd5c6a41229149498bee4d [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
Tyler Gunn96d6c402015-03-18 12:39:23 -0700564 //**********************************************************************************************
Sooraj Sasindran64f05b12020-11-18 12:07:10 -0800565 // Next PROPERTY value: 1<<14
Tyler Gunn96d6c402015-03-18 12:39:23 -0700566 //**********************************************************************************************
Tyler Gunn068085b2015-02-06 13:56:52 -0800567
Tyler Gunn335ff2e2015-07-30 14:18:33 -0700568 /**
Tyler Gunn1c687622019-12-20 11:08:13 -0800569 * Indicates that the audio codec is currently not specified or is unknown.
allenwtsu2aca9892019-11-25 14:38:21 +0800570 */
allenwtsu2aca9892019-11-25 14:38:21 +0800571 public static final int AUDIO_CODEC_NONE = ImsStreamMediaProfile.AUDIO_QUALITY_NONE; // 0
Tyler Gunn1c687622019-12-20 11:08:13 -0800572 /**
573 * Adaptive Multi-rate audio codec.
574 */
allenwtsu2aca9892019-11-25 14:38:21 +0800575 public static final int AUDIO_CODEC_AMR = ImsStreamMediaProfile.AUDIO_QUALITY_AMR; // 1
Tyler Gunn1c687622019-12-20 11:08:13 -0800576 /**
577 * Adaptive Multi-rate wideband audio codec.
578 */
allenwtsu2aca9892019-11-25 14:38:21 +0800579 public static final int AUDIO_CODEC_AMR_WB = ImsStreamMediaProfile.AUDIO_QUALITY_AMR_WB; // 2
Tyler Gunn1c687622019-12-20 11:08:13 -0800580 /**
581 * Qualcomm code-excited linear prediction 13 kilobit audio codec.
582 */
allenwtsu2aca9892019-11-25 14:38:21 +0800583 public static final int AUDIO_CODEC_QCELP13K = ImsStreamMediaProfile.AUDIO_QUALITY_QCELP13K; //3
Tyler Gunn1c687622019-12-20 11:08:13 -0800584 /**
585 * Enhanced Variable Rate Codec. See 3GPP2 C.S0014-A.
586 */
allenwtsu2aca9892019-11-25 14:38:21 +0800587 public static final int AUDIO_CODEC_EVRC = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC; // 4
Tyler Gunn1c687622019-12-20 11:08:13 -0800588 /**
589 * Enhanced Variable Rate Codec B. Commonly used on CDMA networks.
590 */
allenwtsu2aca9892019-11-25 14:38:21 +0800591 public static final int AUDIO_CODEC_EVRC_B = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_B; // 5
Tyler Gunn1c687622019-12-20 11:08:13 -0800592 /**
593 * Enhanced Variable Rate Wideband Codec. See RFC5188.
594 */
allenwtsu2aca9892019-11-25 14:38:21 +0800595 public static final int AUDIO_CODEC_EVRC_WB = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_WB; // 6
Tyler Gunn1c687622019-12-20 11:08:13 -0800596 /**
597 * Enhanced Variable Rate Narrowband-Wideband Codec.
598 */
allenwtsu2aca9892019-11-25 14:38:21 +0800599 public static final int AUDIO_CODEC_EVRC_NW = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_NW; // 7
Tyler Gunn1c687622019-12-20 11:08:13 -0800600 /**
601 * GSM Enhanced Full-Rate audio codec, also known as GSM-EFR, GSM 06.60, or simply EFR.
602 */
allenwtsu2aca9892019-11-25 14:38:21 +0800603 public static final int AUDIO_CODEC_GSM_EFR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_EFR; // 8
Tyler Gunn1c687622019-12-20 11:08:13 -0800604 /**
605 * GSM Full-Rate audio codec, also known as GSM-FR, GSM 06.10, GSM, or simply FR.
606 */
allenwtsu2aca9892019-11-25 14:38:21 +0800607 public static final int AUDIO_CODEC_GSM_FR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_FR; // 9
Tyler Gunn1c687622019-12-20 11:08:13 -0800608 /**
609 * GSM Half Rate audio codec.
610 */
allenwtsu2aca9892019-11-25 14:38:21 +0800611 public static final int AUDIO_CODEC_GSM_HR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_HR; // 10
Tyler Gunn1c687622019-12-20 11:08:13 -0800612 /**
613 * ITU-T G711U audio codec.
614 */
allenwtsu2aca9892019-11-25 14:38:21 +0800615 public static final int AUDIO_CODEC_G711U = ImsStreamMediaProfile.AUDIO_QUALITY_G711U; // 11
Tyler Gunn1c687622019-12-20 11:08:13 -0800616 /**
617 * ITU-T G723 audio codec.
618 */
allenwtsu2aca9892019-11-25 14:38:21 +0800619 public static final int AUDIO_CODEC_G723 = ImsStreamMediaProfile.AUDIO_QUALITY_G723; // 12
Tyler Gunn1c687622019-12-20 11:08:13 -0800620 /**
621 * ITU-T G711A audio codec.
622 */
allenwtsu2aca9892019-11-25 14:38:21 +0800623 public static final int AUDIO_CODEC_G711A = ImsStreamMediaProfile.AUDIO_QUALITY_G711A; // 13
Tyler Gunn1c687622019-12-20 11:08:13 -0800624 /**
625 * ITU-T G722 audio codec.
626 */
allenwtsu2aca9892019-11-25 14:38:21 +0800627 public static final int AUDIO_CODEC_G722 = ImsStreamMediaProfile.AUDIO_QUALITY_G722; // 14
Tyler Gunn1c687622019-12-20 11:08:13 -0800628 /**
629 * ITU-T G711AB audio codec.
630 */
allenwtsu2aca9892019-11-25 14:38:21 +0800631 public static final int AUDIO_CODEC_G711AB = ImsStreamMediaProfile.AUDIO_QUALITY_G711AB; // 15
Tyler Gunn1c687622019-12-20 11:08:13 -0800632 /**
633 * ITU-T G729 audio codec.
634 */
allenwtsu2aca9892019-11-25 14:38:21 +0800635 public static final int AUDIO_CODEC_G729 = ImsStreamMediaProfile.AUDIO_QUALITY_G729; // 16
Tyler Gunn1c687622019-12-20 11:08:13 -0800636 /**
637 * Enhanced Voice Services Narrowband audio codec. See 3GPP TS 26.441.
638 */
allenwtsu2aca9892019-11-25 14:38:21 +0800639 public static final int AUDIO_CODEC_EVS_NB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_NB; // 17
Tyler Gunn1c687622019-12-20 11:08:13 -0800640 /**
641 * Enhanced Voice Services Wideband audio codec. See 3GPP TS 26.441.
642 */
allenwtsu2aca9892019-11-25 14:38:21 +0800643 public static final int AUDIO_CODEC_EVS_WB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_WB; // 18
Tyler Gunn1c687622019-12-20 11:08:13 -0800644 /**
645 * Enhanced Voice Services Super-Wideband audio codec. See 3GPP TS 26.441.
646 */
allenwtsu2aca9892019-11-25 14:38:21 +0800647 public static final int AUDIO_CODEC_EVS_SWB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_SWB; // 19
Tyler Gunn1c687622019-12-20 11:08:13 -0800648 /**
649 * Enhanced Voice Services Fullband audio codec. See 3GPP TS 26.441.
650 */
allenwtsu2aca9892019-11-25 14:38:21 +0800651 public static final int AUDIO_CODEC_EVS_FB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_FB; // 20
652
Tyler Gunn1c687622019-12-20 11:08:13 -0800653 /**@hide*/
654 @Retention(RetentionPolicy.SOURCE)
655 @IntDef(prefix = "AUDIO_CODEC_", value = {
656 AUDIO_CODEC_NONE,
657 AUDIO_CODEC_AMR,
658 AUDIO_CODEC_AMR_WB,
659 AUDIO_CODEC_QCELP13K,
660 AUDIO_CODEC_EVRC,
661 AUDIO_CODEC_EVRC_B,
662 AUDIO_CODEC_EVRC_WB,
663 AUDIO_CODEC_EVRC_NW,
664 AUDIO_CODEC_GSM_EFR,
665 AUDIO_CODEC_GSM_FR,
666 AUDIO_CODEC_GSM_HR,
667 AUDIO_CODEC_G711U,
668 AUDIO_CODEC_G723,
669 AUDIO_CODEC_G711A,
670 AUDIO_CODEC_G722,
671 AUDIO_CODEC_G711AB,
672 AUDIO_CODEC_G729,
673 AUDIO_CODEC_EVS_NB,
674 AUDIO_CODEC_EVS_SWB,
675 AUDIO_CODEC_EVS_FB
676 })
677 public @interface AudioCodec {}
678
allenwtsu2aca9892019-11-25 14:38:21 +0800679 /**
Tyler Gunn60e5eb62021-07-01 16:55:32 -0700680 * Contains the same value as {@link #getCallerNumberVerificationStatus()}, except will be
681 * present in the {@link #getExtras()} using this key.
682 * @hide
683 */
684 public static final String EXTRA_CALLER_NUMBER_VERIFICATION_STATUS =
685 "android.telecom.extra.CALLER_NUMBER_VERIFICATION_STATUS";
686
687 /**
Tyler Gunn335ff2e2015-07-30 14:18:33 -0700688 * Connection extra key used to store the last forwarded number associated with the current
689 * connection. Used to communicate to the user interface that the connection was forwarded via
690 * the specified number.
691 */
692 public static final String EXTRA_LAST_FORWARDED_NUMBER =
693 "android.telecom.extra.LAST_FORWARDED_NUMBER";
694
695 /**
696 * Connection extra key used to store a child number associated with the current connection.
697 * Used to communicate to the user interface that the connection was received via
698 * a child address (i.e. phone number) associated with the {@link PhoneAccount}'s primary
699 * address.
700 */
701 public static final String EXTRA_CHILD_ADDRESS = "android.telecom.extra.CHILD_ADDRESS";
702
703 /**
704 * Connection extra key used to store the subject for an incoming call. The user interface can
705 * query this extra and display its contents for incoming calls. Will only be used if the
706 * {@link PhoneAccount} supports the capability {@link PhoneAccount#CAPABILITY_CALL_SUBJECT}.
707 */
708 public static final String EXTRA_CALL_SUBJECT = "android.telecom.extra.CALL_SUBJECT";
709
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800710 /**
Tyler Gunn4b6614e2016-06-22 10:35:13 -0700711 * Boolean connection extra key set on a {@link Connection} in
712 * {@link Connection#STATE_RINGING} state to indicate that answering the call will cause the
713 * current active foreground call to be dropped.
714 */
715 public static final String EXTRA_ANSWERING_DROPS_FG_CALL =
716 "android.telecom.extra.ANSWERING_DROPS_FG_CALL";
717
718 /**
Tyler Gunn37653562017-03-13 18:15:15 -0700719 * String connection extra key set on a {@link Connection} in {@link Connection#STATE_RINGING}
720 * state to indicate the name of the third-party app which is responsible for the current
721 * foreground call.
722 * <p>
723 * Used when {@link #EXTRA_ANSWERING_DROPS_FG_CALL} is true to ensure that the default Phone app
724 * is able to inform the user that answering the new incoming call will cause a call owned by
725 * another app to be dropped when the incoming call is answered.
726 */
727 public static final String EXTRA_ANSWERING_DROPS_FG_CALL_APP_NAME =
728 "android.telecom.extra.ANSWERING_DROPS_FG_CALL_APP_NAME";
729
730 /**
Hall Liu10208662016-06-15 17:55:00 -0700731 * Boolean connection extra key on a {@link Connection} which indicates that adding an
Hall Liuee6e86b2016-07-06 16:32:43 -0700732 * additional call is disallowed.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700733 * <p>
734 * Used for mobile-network calls to identify scenarios where carrier requirements preclude
735 * adding another call at the current time.
Hall Liu10208662016-06-15 17:55:00 -0700736 * @hide
737 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700738 @SystemApi
Hall Liuee6e86b2016-07-06 16:32:43 -0700739 public static final String EXTRA_DISABLE_ADD_CALL =
740 "android.telecom.extra.DISABLE_ADD_CALL";
Hall Liu10208662016-06-15 17:55:00 -0700741
742 /**
Tyler Gunncd6ccfd2016-10-17 15:48:19 -0700743 * String connection extra key on a {@link Connection} or {@link Conference} which contains the
744 * original Connection ID associated with the connection. Used in
745 * {@link RemoteConnectionService} to track the Connection ID which was originally assigned to a
746 * connection/conference added via
747 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)} and
748 * {@link ConnectionService#addConference(Conference)} APIs. This is important to pass to
749 * Telecom for when it deals with RemoteConnections. When the ConnectionManager wraps the
750 * {@link RemoteConnection} and {@link RemoteConference} and adds it to Telecom, there needs to
751 * be a way to ensure that we don't add the connection again as a duplicate.
752 * <p>
753 * For example, the TelephonyCS calls addExistingConnection for a Connection with ID
754 * {@code TelephonyCS@1}. The ConnectionManager learns of this via
755 * {@link ConnectionService#onRemoteExistingConnectionAdded(RemoteConnection)}, and wraps this
756 * in a new {@link Connection} which it adds to Telecom via
757 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)}. As part of
758 * this process, the wrapped RemoteConnection gets assigned a new ID (e.g. {@code ConnMan@1}).
759 * The TelephonyCS will ALSO try to add the existing connection to Telecom, except with the
760 * ID it originally referred to the connection as. Thus Telecom needs to know that the
761 * Connection with ID {@code ConnMan@1} is really the same as {@code TelephonyCS@1}.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700762 * <p>
763 * This is an internal Telecom framework concept and is not exposed outside of the Telecom
764 * framework.
Tyler Gunncd6ccfd2016-10-17 15:48:19 -0700765 * @hide
766 */
767 public static final String EXTRA_ORIGINAL_CONNECTION_ID =
768 "android.telecom.extra.ORIGINAL_CONNECTION_ID";
769
770 /**
Tyler Gunnc59fd0c2020-04-17 14:03:35 -0700771 * Extra key set on a {@link Connection} when it was created via a remote connection service.
772 * For example, if a connection manager requests a remote connection service to create a call
773 * using one of the remote connection service's phone account handle, this extra will be set so
774 * that Telecom knows that the wrapped remote connection originated in a remote connection
775 * service. We stash this in the extras since connection managers will typically copy the
776 * extras from a {@link RemoteConnection} to a {@link Connection} (there is ultimately not
777 * other way to relate a {@link RemoteConnection} to a {@link Connection}.
778 * @hide
779 */
780 public static final String EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE =
781 "android.telecom.extra.REMOTE_PHONE_ACCOUNT_HANDLE";
782
783 /**
Tyler Gunnfdc4bff2021-06-24 11:25:07 -0700784 * The Telecom call ID of the conference an existing connection should be added to. This is
785 * required when {@link com.android.services.telephony.TelephonyConnectionService} adds a
786 * {@link Conference} to Telecom using the
787 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection, Conference)}
788 * API. That API specifies a parent conference associated with the new existing connection
789 * being added, and there is no equivalent as part of the {@link RemoteConnectionService} API.
790 * This extra key is used to stack the ID of the conference to which the existing connection
791 * will be added so that Telecom can link it up correctly when the {@link RemoteConference}
792 * is added to Telecom by the connection manager.
793 * @hide
794 */
795 public static final String EXTRA_ADD_TO_CONFERENCE_ID =
796 "android.telecom.extra.ADD_TO_CONFERENCE_ID";
797
798 /**
Tyler Gunnc59fd0c2020-04-17 14:03:35 -0700799 * Extra key set from a {@link ConnectionService} when using the remote connection APIs
800 * (e.g. {@link RemoteConnectionService#createRemoteConnection(PhoneAccountHandle,
801 * ConnectionRequest, boolean)}) to create a remote connection. Provides the receiving
802 * {@link ConnectionService} with a means to know the package name of the requesting
803 * {@link ConnectionService} so that {@link #EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE} can be set for
804 * better visibility in Telecom of where a connection ultimately originated.
805 * @hide
806 */
807 public static final String EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME =
808 "android.telecom.extra.REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME";
809
810 /**
Wileen Chiuf2ec2982018-07-01 14:21:50 -0700811 * Boolean connection extra key set on the extras passed to
812 * {@link Connection#sendConnectionEvent} which indicates that audio is present
813 * on the RTT call when the extra value is true.
814 */
815 public static final String EXTRA_IS_RTT_AUDIO_PRESENT =
816 "android.telecom.extra.IS_RTT_AUDIO_PRESENT";
817
818 /**
Tyler Gunn1c687622019-12-20 11:08:13 -0800819 * The audio codec in use for the current {@link Connection}, if known. Examples of valid
820 * values include {@link #AUDIO_CODEC_AMR_WB} and {@link #AUDIO_CODEC_EVS_WB}.
allenwtsu2aca9892019-11-25 14:38:21 +0800821 */
Tyler Gunn1c687622019-12-20 11:08:13 -0800822 public static final @AudioCodec String EXTRA_AUDIO_CODEC =
allenwtsu2aca9892019-11-25 14:38:21 +0800823 "android.telecom.extra.AUDIO_CODEC";
824
825 /**
allenwtsu6ec972a2020-11-10 17:32:46 +0800826 * Float connection extra key used to store the audio codec bitrate in kbps for the current
827 * {@link Connection}.
828 */
829 public static final String EXTRA_AUDIO_CODEC_BITRATE_KBPS =
830 "android.telecom.extra.AUDIO_CODEC_BITRATE_KBPS";
831
832 /**
833 * Float connection extra key used to store the audio codec bandwidth in khz for the current
834 * {@link Connection}.
835 */
836 public static final String EXTRA_AUDIO_CODEC_BANDWIDTH_KHZ =
837 "android.telecom.extra.AUDIO_CODEC_BANDWIDTH_KHZ";
Tyler Gunn78a59ff2021-05-07 16:41:19 -0700838
839 /**
Sooraj Sasindran81be0822021-10-26 02:03:37 -0700840 * Last known cell identity key to be used to fill geo location header in case of an emergency
841 * call. This entry will not be filled if call is not identified as an emergency call.
842 * {@link Connection}. Only provided to the {@link ConnectionService} for the purpose
843 * of placing an emergency call; will not be present in the {@link InCallService} layer.
844 * The {@link ConnectionService}'s implementation will be logged for fine location access
845 * when an outgoing call is placed in this case.
846 */
847 public static final String EXTRA_LAST_KNOWN_CELL_IDENTITY =
848 "android.telecom.extra.LAST_KNOWN_CELL_IDENTITY";
849
850 /**
Tyler Gunn78a59ff2021-05-07 16:41:19 -0700851 * Boolean connection extra key used to indicate whether device to device communication is
852 * available for the current call.
853 * @hide
854 */
855 public static final String EXTRA_IS_DEVICE_TO_DEVICE_COMMUNICATION_AVAILABLE =
856 "android.telecom.extra.IS_DEVICE_TO_DEVICE_COMMUNICATION_AVAILABLE";
857
allenwtsu6ec972a2020-11-10 17:32:46 +0800858 /**
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800859 * Connection event used to inform Telecom that it should play the on hold tone. This is used
860 * to play a tone when the peer puts the current call on hold. Sent to Telecom via
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700861 * {@link #sendConnectionEvent(String, Bundle)}.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800862 */
863 public static final String EVENT_ON_HOLD_TONE_START =
864 "android.telecom.event.ON_HOLD_TONE_START";
865
866 /**
867 * Connection event used to inform Telecom that it should stop the on hold tone. This is used
868 * to stop a tone when the peer puts the current call on hold. Sent to Telecom via
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700869 * {@link #sendConnectionEvent(String, Bundle)}.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800870 */
871 public static final String EVENT_ON_HOLD_TONE_END =
872 "android.telecom.event.ON_HOLD_TONE_END";
873
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700874 /**
875 * Connection event used to inform {@link InCallService}s when pulling of an external call has
876 * failed. The user interface should inform the user of the error.
877 * <p>
878 * Expected to be used by the {@link ConnectionService} when the {@link Call#pullExternalCall()}
879 * API is called on a {@link Call} with the properties
880 * {@link Call.Details#PROPERTY_IS_EXTERNAL_CALL} and
881 * {@link Call.Details#CAPABILITY_CAN_PULL_CALL}, but the {@link ConnectionService} could not
882 * pull the external call due to an error condition.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700883 * <p>
884 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
885 * expected to be null when this connection event is used.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700886 */
887 public static final String EVENT_CALL_PULL_FAILED = "android.telecom.event.CALL_PULL_FAILED";
888
Brad Ebinger2c1c16452016-05-27 15:58:10 -0700889 /**
890 * Connection event used to inform {@link InCallService}s when the merging of two calls has
891 * failed. The User Interface should use this message to inform the user of the error.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700892 * <p>
893 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
894 * expected to be null when this connection event is used.
Brad Ebinger2c1c16452016-05-27 15:58:10 -0700895 */
896 public static final String EVENT_CALL_MERGE_FAILED = "android.telecom.event.CALL_MERGE_FAILED";
897
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700898 /**
Hall Liu06ae75b2019-03-11 19:11:35 -0700899 * Connection event used to inform Telecom when a hold operation on a call has failed.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700900 * <p>
Hall Liu06ae75b2019-03-11 19:11:35 -0700901 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
902 * expected to be null when this connection event is used.
Hall Liu06ae75b2019-03-11 19:11:35 -0700903 */
904 public static final String EVENT_CALL_HOLD_FAILED = "android.telecom.event.CALL_HOLD_FAILED";
905
906 /**
Masaho Nishikawacb8fa742019-11-07 14:41:21 +0900907 * Connection event used to inform Telecom when a switch operation on a call has failed.
908 * <p>
909 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
910 * expected to be null when this connection event is used.
911 */
912 public static final String EVENT_CALL_SWITCH_FAILED =
913 "android.telecom.event.CALL_SWITCH_FAILED";
914
915 /**
Tyler Gunn78da7812017-05-09 14:34:57 -0700916 * Connection event used to inform {@link InCallService}s when the process of merging a
917 * Connection into a conference has begun.
918 * <p>
919 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
920 * expected to be null when this connection event is used.
Tyler Gunn78da7812017-05-09 14:34:57 -0700921 */
922 public static final String EVENT_MERGE_START = "android.telecom.event.MERGE_START";
923
924 /**
925 * Connection event used to inform {@link InCallService}s when the process of merging a
926 * Connection into a conference has completed.
927 * <p>
928 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
929 * expected to be null when this connection event is used.
Tyler Gunn78da7812017-05-09 14:34:57 -0700930 */
931 public static final String EVENT_MERGE_COMPLETE = "android.telecom.event.MERGE_COMPLETE";
932
933 /**
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700934 * Connection event used to inform {@link InCallService}s when a call has been put on hold by
935 * the remote party.
936 * <p>
937 * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the
938 * call is being held locally on the device. When a capable {@link ConnectionService} receives
939 * signalling to indicate that the remote party has put the call on hold, it can send this
940 * connection event.
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700941 */
942 public static final String EVENT_CALL_REMOTELY_HELD =
943 "android.telecom.event.CALL_REMOTELY_HELD";
944
945 /**
946 * Connection event used to inform {@link InCallService}s when a call which was remotely held
947 * (see {@link #EVENT_CALL_REMOTELY_HELD}) has been un-held by the remote party.
948 * <p>
949 * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the
950 * call is being held locally on the device. When a capable {@link ConnectionService} receives
951 * signalling to indicate that the remote party has taken the call off hold, it can send this
952 * connection event.
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700953 */
954 public static final String EVENT_CALL_REMOTELY_UNHELD =
955 "android.telecom.event.CALL_REMOTELY_UNHELD";
956
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700957 /**
958 * Connection event used to inform an {@link InCallService} which initiated a call handover via
959 * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has
960 * successfully completed.
961 * @hide
Tyler Gunn1a505fa2018-09-14 13:36:38 -0700962 * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated
963 * APIs instead.
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700964 */
965 public static final String EVENT_HANDOVER_COMPLETE =
966 "android.telecom.event.HANDOVER_COMPLETE";
967
968 /**
969 * Connection event used to inform an {@link InCallService} which initiated a call handover via
970 * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has failed
971 * to complete.
972 * @hide
Tyler Gunn1a505fa2018-09-14 13:36:38 -0700973 * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated
974 * APIs instead.
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700975 */
976 public static final String EVENT_HANDOVER_FAILED =
977 "android.telecom.event.HANDOVER_FAILED";
978
shilub7ec9a02018-11-09 15:52:04 -0800979 /**
Shi Lu528eb5b2019-02-08 05:09:11 +0000980 * String Connection extra key used to store SIP invite fields for an incoming call for IMS call
shilub7ec9a02018-11-09 15:52:04 -0800981 */
982 public static final String EXTRA_SIP_INVITE = "android.telecom.extra.SIP_INVITE";
983
Wileen Chiuf2ec2982018-07-01 14:21:50 -0700984 /**
985 * Connection event used to inform an {@link InCallService} that the RTT audio indication
986 * has changed.
987 */
988 public static final String EVENT_RTT_AUDIO_INDICATION_CHANGED =
989 "android.telecom.event.RTT_AUDIO_INDICATION_CHANGED";
990
Tyler Gunnd5821842021-02-05 11:12:57 -0800991 /**
992 * Connection event used to signal between the telephony {@link ConnectionService} and Telecom
993 * when device to device messages are sent/received.
994 * <p>
995 * Device to device messages originating from the network are sent by telephony using
996 * {@link Connection#sendConnectionEvent(String, Bundle)} and are routed up to any active
997 * {@link CallDiagnosticService} implementation which is active.
998 * <p>
999 * Likewise, if a {@link CallDiagnosticService} sends a message using
Tyler Gunn066de602021-03-16 09:58:07 -07001000 * {@link CallDiagnostics#sendDeviceToDeviceMessage(int, int)}, it will be routed to telephony
Tyler Gunnd5821842021-02-05 11:12:57 -08001001 * via {@link Connection#onCallEvent(String, Bundle)}. The telephony stack will relay the
1002 * message to the other device.
1003 * @hide
1004 */
1005 @SystemApi
1006 public static final String EVENT_DEVICE_TO_DEVICE_MESSAGE =
1007 "android.telecom.event.DEVICE_TO_DEVICE_MESSAGE";
1008
1009 /**
1010 * Sent along with {@link #EVENT_DEVICE_TO_DEVICE_MESSAGE} to indicate the device to device
1011 * message type.
1012 *
Tyler Gunn066de602021-03-16 09:58:07 -07001013 * See {@link CallDiagnostics} for more information.
Tyler Gunnd5821842021-02-05 11:12:57 -08001014 * @hide
1015 */
1016 @SystemApi
1017 public static final String EXTRA_DEVICE_TO_DEVICE_MESSAGE_TYPE =
1018 "android.telecom.extra.DEVICE_TO_DEVICE_MESSAGE_TYPE";
1019
1020 /**
1021 * Sent along with {@link #EVENT_DEVICE_TO_DEVICE_MESSAGE} to indicate the device to device
1022 * message value.
1023 * <p>
Tyler Gunn066de602021-03-16 09:58:07 -07001024 * See {@link CallDiagnostics} for more information.
Tyler Gunnd5821842021-02-05 11:12:57 -08001025 * @hide
1026 */
1027 @SystemApi
1028 public static final String EXTRA_DEVICE_TO_DEVICE_MESSAGE_VALUE =
1029 "android.telecom.extra.DEVICE_TO_DEVICE_MESSAGE_VALUE";
1030
Tyler Gunn0a1c6d12021-03-12 15:44:08 -08001031 /**
1032 * Connection event used to communicate a {@link android.telephony.CallQuality} report from
1033 * telephony to Telecom for relaying to
1034 * {@link DiagnosticCall#onCallQualityReceived(CallQuality)}.
1035 * @hide
1036 */
1037 public static final String EVENT_CALL_QUALITY_REPORT =
1038 "android.telecom.event.CALL_QUALITY_REPORT";
1039
1040 /**
1041 * Extra sent with {@link #EVENT_CALL_QUALITY_REPORT} containing the
1042 * {@link android.telephony.CallQuality} data.
1043 * @hide
1044 */
1045 public static final String EXTRA_CALL_QUALITY_REPORT =
1046 "android.telecom.extra.CALL_QUALITY_REPORT";
1047
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001048 // Flag controlling whether PII is emitted into the logs
1049 private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG);
1050
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001051 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07001052 * Renders a set of capability bits ({@code CAPABILITY_*}) as a human readable string.
1053 *
1054 * @param capabilities A capability bit field.
1055 * @return A human readable string representation.
1056 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001057 public static String capabilitiesToString(int capabilities) {
Santos Cordon1a749302016-07-26 16:08:53 -07001058 return capabilitiesToStringInternal(capabilities, true /* isLong */);
1059 }
1060
1061 /**
1062 * Renders a set of capability bits ({@code CAPABILITY_*}) as a *short* human readable
1063 * string.
1064 *
1065 * @param capabilities A capability bit field.
1066 * @return A human readable string representation.
1067 * @hide
1068 */
1069 public static String capabilitiesToStringShort(int capabilities) {
1070 return capabilitiesToStringInternal(capabilities, false /* isLong */);
1071 }
1072
1073 private static String capabilitiesToStringInternal(int capabilities, boolean isLong) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001074 StringBuilder builder = new StringBuilder();
Santos Cordon1a749302016-07-26 16:08:53 -07001075 builder.append("[");
1076 if (isLong) {
1077 builder.append("Capabilities:");
1078 }
1079
Tyler Gunnc63f9082019-10-15 13:19:26 -07001080 if ((capabilities & CAPABILITY_HOLD) == CAPABILITY_HOLD) {
Santos Cordon1a749302016-07-26 16:08:53 -07001081 builder.append(isLong ? " CAPABILITY_HOLD" : " hld");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001082 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001083 if ((capabilities & CAPABILITY_SUPPORT_HOLD) == CAPABILITY_SUPPORT_HOLD) {
Santos Cordon1a749302016-07-26 16:08:53 -07001084 builder.append(isLong ? " CAPABILITY_SUPPORT_HOLD" : " sup_hld");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001085 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001086 if ((capabilities & CAPABILITY_MERGE_CONFERENCE) == CAPABILITY_MERGE_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001087 builder.append(isLong ? " CAPABILITY_MERGE_CONFERENCE" : " mrg_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001088 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001089 if ((capabilities & CAPABILITY_SWAP_CONFERENCE) == CAPABILITY_SWAP_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001090 builder.append(isLong ? " CAPABILITY_SWAP_CONFERENCE" : " swp_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001091 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001092 if ((capabilities & CAPABILITY_RESPOND_VIA_TEXT) == CAPABILITY_RESPOND_VIA_TEXT) {
Santos Cordon1a749302016-07-26 16:08:53 -07001093 builder.append(isLong ? " CAPABILITY_RESPOND_VIA_TEXT" : " txt");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001094 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001095 if ((capabilities & CAPABILITY_MUTE) == CAPABILITY_MUTE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001096 builder.append(isLong ? " CAPABILITY_MUTE" : " mut");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001097 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001098 if ((capabilities & CAPABILITY_MANAGE_CONFERENCE) == CAPABILITY_MANAGE_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001099 builder.append(isLong ? " CAPABILITY_MANAGE_CONFERENCE" : " mng_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001100 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001101 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_RX) == CAPABILITY_SUPPORTS_VT_LOCAL_RX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001102 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_RX" : " VTlrx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001103 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001104 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_TX) == CAPABILITY_SUPPORTS_VT_LOCAL_TX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001105 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_TX" : " VTltx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001106 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001107 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL)
1108 == CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001109 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL" : " VTlbi");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001110 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001111 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_RX) == CAPABILITY_SUPPORTS_VT_REMOTE_RX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001112 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_RX" : " VTrrx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001113 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001114 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_TX) == CAPABILITY_SUPPORTS_VT_REMOTE_TX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001115 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_TX" : " VTrtx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001116 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001117 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL)
1118 == CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001119 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL" : " VTrbi");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001120 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001121 if ((capabilities & CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO)
1122 == CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001123 builder.append(isLong ? " CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO" : " !v2a");
Tyler Gunnf97a0092016-01-19 15:59:34 -08001124 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001125 if ((capabilities & CAPABILITY_SPEED_UP_MT_AUDIO) == CAPABILITY_SPEED_UP_MT_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001126 builder.append(isLong ? " CAPABILITY_SPEED_UP_MT_AUDIO" : " spd_aud");
Dong Zhou89f41eb2015-03-15 11:59:49 -05001127 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001128 if ((capabilities & CAPABILITY_CAN_UPGRADE_TO_VIDEO) == CAPABILITY_CAN_UPGRADE_TO_VIDEO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001129 builder.append(isLong ? " CAPABILITY_CAN_UPGRADE_TO_VIDEO" : " a2v");
Rekha Kumar07366812015-03-24 16:42:31 -07001130 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001131 if ((capabilities & CAPABILITY_CAN_PAUSE_VIDEO) == CAPABILITY_CAN_PAUSE_VIDEO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001132 builder.append(isLong ? " CAPABILITY_CAN_PAUSE_VIDEO" : " paus_VT");
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -07001133 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001134 if ((capabilities & CAPABILITY_CONFERENCE_HAS_NO_CHILDREN)
1135 == CAPABILITY_CONFERENCE_HAS_NO_CHILDREN) {
Santos Cordon1a749302016-07-26 16:08:53 -07001136 builder.append(isLong ? " CAPABILITY_SINGLE_PARTY_CONFERENCE" : " 1p_cnf");
Tyler Gunnd4091732015-06-29 09:15:37 -07001137 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001138 if ((capabilities & CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION)
1139 == CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION) {
Santos Cordon1a749302016-07-26 16:08:53 -07001140 builder.append(isLong ? " CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION" : " rsp_by_con");
Bryce Lee81901682015-08-28 16:38:02 -07001141 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001142 if ((capabilities & CAPABILITY_CAN_PULL_CALL) == CAPABILITY_CAN_PULL_CALL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001143 builder.append(isLong ? " CAPABILITY_CAN_PULL_CALL" : " pull");
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001144 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001145 if ((capabilities & CAPABILITY_SUPPORT_DEFLECT) == CAPABILITY_SUPPORT_DEFLECT) {
Pooja Jaind34698d2017-12-28 14:15:31 +05301146 builder.append(isLong ? " CAPABILITY_SUPPORT_DEFLECT" : " sup_def");
1147 }
Ravi Paluri404babb2020-01-23 19:02:44 +05301148 if ((capabilities & CAPABILITY_ADD_PARTICIPANT) == CAPABILITY_ADD_PARTICIPANT) {
1149 builder.append(isLong ? " CAPABILITY_ADD_PARTICIPANT" : " add_participant");
1150 }
Ravi Palurif4b38e72020-02-05 12:35:41 +05301151 if ((capabilities & CAPABILITY_TRANSFER) == CAPABILITY_TRANSFER) {
1152 builder.append(isLong ? " CAPABILITY_TRANSFER" : " sup_trans");
1153 }
1154 if ((capabilities & CAPABILITY_TRANSFER_CONSULTATIVE)
1155 == CAPABILITY_TRANSFER_CONSULTATIVE) {
1156 builder.append(isLong ? " CAPABILITY_TRANSFER_CONSULTATIVE" : " sup_cTrans");
1157 }
Alvin Dey2f37d772018-05-18 23:16:10 +05301158 if ((capabilities & CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT)
1159 == CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT) {
1160 builder.append(isLong ? " CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT" : " sup_rtt");
1161 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001162 builder.append("]");
1163 return builder.toString();
1164 }
1165
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07001166 /**
1167 * Renders a set of property bits ({@code PROPERTY_*}) as a human readable string.
1168 *
1169 * @param properties A property bit field.
1170 * @return A human readable string representation.
1171 */
Tyler Gunn720c6642016-03-22 09:02:47 -07001172 public static String propertiesToString(int properties) {
Santos Cordon1a749302016-07-26 16:08:53 -07001173 return propertiesToStringInternal(properties, true /* isLong */);
1174 }
1175
1176 /**
1177 * Renders a set of property bits ({@code PROPERTY_*}) as a *short* human readable string.
1178 *
1179 * @param properties A property bit field.
1180 * @return A human readable string representation.
1181 * @hide
1182 */
1183 public static String propertiesToStringShort(int properties) {
1184 return propertiesToStringInternal(properties, false /* isLong */);
1185 }
1186
1187 private static String propertiesToStringInternal(int properties, boolean isLong) {
Tyler Gunn720c6642016-03-22 09:02:47 -07001188 StringBuilder builder = new StringBuilder();
Santos Cordon1a749302016-07-26 16:08:53 -07001189 builder.append("[");
1190 if (isLong) {
1191 builder.append("Properties:");
1192 }
Tyler Gunn720c6642016-03-22 09:02:47 -07001193
Tyler Gunnc63f9082019-10-15 13:19:26 -07001194 if ((properties & PROPERTY_SELF_MANAGED) == PROPERTY_SELF_MANAGED) {
Tyler Gunnf5035432017-01-09 09:43:12 -08001195 builder.append(isLong ? " PROPERTY_SELF_MANAGED" : " self_mng");
1196 }
1197
Tyler Gunnc63f9082019-10-15 13:19:26 -07001198 if ((properties & PROPERTY_EMERGENCY_CALLBACK_MODE) == PROPERTY_EMERGENCY_CALLBACK_MODE) {
Hall Liu25c7c4d2016-08-30 13:41:02 -07001199 builder.append(isLong ? " PROPERTY_EMERGENCY_CALLBACK_MODE" : " ecbm");
Tyler Gunn720c6642016-03-22 09:02:47 -07001200 }
1201
Tyler Gunnc63f9082019-10-15 13:19:26 -07001202 if ((properties & PROPERTY_HIGH_DEF_AUDIO) == PROPERTY_HIGH_DEF_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001203 builder.append(isLong ? " PROPERTY_HIGH_DEF_AUDIO" : " HD");
Tyler Gunn720c6642016-03-22 09:02:47 -07001204 }
1205
Tyler Gunnc63f9082019-10-15 13:19:26 -07001206 if ((properties & PROPERTY_WIFI) == PROPERTY_WIFI) {
Santos Cordon1a749302016-07-26 16:08:53 -07001207 builder.append(isLong ? " PROPERTY_WIFI" : " wifi");
Tyler Gunn720c6642016-03-22 09:02:47 -07001208 }
1209
Tyler Gunnc63f9082019-10-15 13:19:26 -07001210 if ((properties & PROPERTY_GENERIC_CONFERENCE) == PROPERTY_GENERIC_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001211 builder.append(isLong ? " PROPERTY_GENERIC_CONFERENCE" : " gen_conf");
Tyler Gunn720c6642016-03-22 09:02:47 -07001212 }
1213
Tyler Gunnc63f9082019-10-15 13:19:26 -07001214 if ((properties & PROPERTY_IS_EXTERNAL_CALL) == PROPERTY_IS_EXTERNAL_CALL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001215 builder.append(isLong ? " PROPERTY_IS_EXTERNAL_CALL" : " xtrnl");
Tyler Gunn720c6642016-03-22 09:02:47 -07001216 }
1217
Tyler Gunnc63f9082019-10-15 13:19:26 -07001218 if ((properties & PROPERTY_HAS_CDMA_VOICE_PRIVACY) == PROPERTY_HAS_CDMA_VOICE_PRIVACY) {
Santos Cordon1a749302016-07-26 16:08:53 -07001219 builder.append(isLong ? " PROPERTY_HAS_CDMA_VOICE_PRIVACY" : " priv");
Brad Ebinger15847072016-05-18 11:08:36 -07001220 }
1221
Tyler Gunnc63f9082019-10-15 13:19:26 -07001222 if ((properties & PROPERTY_IS_RTT) == PROPERTY_IS_RTT) {
Hall Liud4d2a8a2018-01-29 17:22:02 -08001223 builder.append(isLong ? " PROPERTY_IS_RTT" : " rtt");
1224 }
1225
Tyler Gunnc63f9082019-10-15 13:19:26 -07001226 if ((properties & PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL)
1227 == PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL) {
Tyler Gunn5bd90852018-09-21 09:37:07 -07001228 builder.append(isLong ? " PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL" : " ecall");
1229 }
1230
Tyler Gunnc63f9082019-10-15 13:19:26 -07001231 if ((properties & PROPERTY_REMOTELY_HOSTED) == PROPERTY_REMOTELY_HOSTED) {
Tyler Gunnac60f952019-05-31 07:23:16 -07001232 builder.append(isLong ? " PROPERTY_REMOTELY_HOSTED" : " remote_hst");
1233 }
1234
Ravi Paluri80aa2142019-12-02 11:57:37 +05301235 if ((properties & PROPERTY_IS_ADHOC_CONFERENCE) == PROPERTY_IS_ADHOC_CONFERENCE) {
1236 builder.append(isLong ? " PROPERTY_IS_ADHOC_CONFERENCE" : " adhoc_conf");
1237 }
1238
Hall Liue0f787c2020-07-08 11:25:56 -07001239 if ((properties & PROPERTY_IS_DOWNGRADED_CONFERENCE) == PROPERTY_IS_DOWNGRADED_CONFERENCE) {
1240 builder.append(isLong ? " PROPERTY_IS_DOWNGRADED_CONFERENCE" : " dngrd_conf");
1241 }
1242
Tyler Gunn720c6642016-03-22 09:02:47 -07001243 builder.append("]");
1244 return builder.toString();
1245 }
1246
Sailesh Nepal091768c2014-06-30 15:15:23 -07001247 /** @hide */
Tyler Gunn633e4c32019-10-24 15:40:48 -07001248 abstract static class Listener {
Ihab Awad542e0ea2014-05-16 10:22:16 -07001249 public void onStateChanged(Connection c, int state) {}
Andrew Lee100e2932014-09-08 15:34:24 -07001250 public void onAddressChanged(Connection c, Uri newAddress, int presentation) {}
Sailesh Nepal61203862014-07-11 14:50:13 -07001251 public void onCallerDisplayNameChanged(
1252 Connection c, String callerDisplayName, int presentation) {}
Tyler Gunnaa07df82014-07-17 07:50:22 -07001253 public void onVideoStateChanged(Connection c, int videoState) {}
Andrew Lee7f3d41f2014-09-11 17:33:16 -07001254 public void onDisconnected(Connection c, DisconnectCause disconnectCause) {}
Sailesh Nepal091768c2014-06-30 15:15:23 -07001255 public void onPostDialWait(Connection c, String remaining) {}
Nancy Chen27d1c2d2014-12-15 16:12:50 -08001256 public void onPostDialChar(Connection c, char nextChar) {}
Andrew Lee100e2932014-09-08 15:34:24 -07001257 public void onRingbackRequested(Connection c, boolean ringback) {}
Sailesh Nepal61203862014-07-11 14:50:13 -07001258 public void onDestroyed(Connection c) {}
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001259 public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {}
Tyler Gunn720c6642016-03-22 09:02:47 -07001260 public void onConnectionPropertiesChanged(Connection c, int properties) {}
Christine Hallstrom2830ce92016-11-30 16:06:42 -08001261 public void onSupportedAudioRoutesChanged(Connection c, int supportedAudioRoutes) {}
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001262 public void onVideoProviderChanged(
1263 Connection c, VideoProvider videoProvider) {}
Sailesh Nepal001bbbb2014-07-15 14:40:39 -07001264 public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {}
1265 public void onStatusHintsChanged(Connection c, StatusHints statusHints) {}
Tyler Gunn6d76ca02014-11-17 15:49:51 -08001266 public void onConferenceablesChanged(
Tyler Gunndf2cbc82015-04-20 09:13:01 -07001267 Connection c, List<Conferenceable> conferenceables) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -07001268 public void onConferenceChanged(Connection c, Conference conference) {}
Anthony Lee17455a32015-04-24 15:25:29 -07001269 public void onConferenceMergeFailed(Connection c) {}
Santos Cordon6b7f9552015-05-27 17:21:45 -07001270 public void onExtrasChanged(Connection c, Bundle extras) {}
Tyler Gunndee56a82016-03-23 16:06:34 -07001271 public void onExtrasRemoved(Connection c, List<String> keys) {}
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001272 public void onConnectionEvent(Connection c, String event, Bundle extras) {}
Hall Liua98f58b52017-11-07 17:59:28 -08001273 public void onAudioRouteChanged(Connection c, int audioRoute, String bluetoothAddress) {}
Hall Liub64ac4c2017-02-06 10:49:48 -08001274 public void onRttInitiationSuccess(Connection c) {}
1275 public void onRttInitiationFailure(Connection c, int reason) {}
1276 public void onRttSessionRemotelyTerminated(Connection c) {}
1277 public void onRemoteRttRequest(Connection c) {}
Srikanth Chintalafcb15012017-05-04 20:58:34 +05301278 /** @hide */
1279 public void onPhoneAccountChanged(Connection c, PhoneAccountHandle pHandle) {}
Mengjun Leng25707742017-07-04 11:10:37 +08001280 public void onConnectionTimeReset(Connection c) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07001281 }
1282
Tyler Gunnb702ef82015-05-29 11:51:53 -07001283 /**
Hall Liu95d55872017-01-25 17:12:49 -08001284 * Provides methods to read and write RTT data to/from the in-call app.
Hall Liu95d55872017-01-25 17:12:49 -08001285 */
1286 public static final class RttTextStream {
1287 private static final int READ_BUFFER_SIZE = 1000;
1288 private final InputStreamReader mPipeFromInCall;
1289 private final OutputStreamWriter mPipeToInCall;
Hall Liub64ac4c2017-02-06 10:49:48 -08001290 private final ParcelFileDescriptor mFdFromInCall;
1291 private final ParcelFileDescriptor mFdToInCall;
Hall Liu17eb1bd2018-07-03 15:17:41 -07001292
1293 private final FileInputStream mFromInCallFileInputStream;
Hall Liu95d55872017-01-25 17:12:49 -08001294 private char[] mReadBuffer = new char[READ_BUFFER_SIZE];
1295
1296 /**
1297 * @hide
1298 */
1299 public RttTextStream(ParcelFileDescriptor toInCall, ParcelFileDescriptor fromInCall) {
Hall Liub64ac4c2017-02-06 10:49:48 -08001300 mFdFromInCall = fromInCall;
1301 mFdToInCall = toInCall;
Hall Liu17eb1bd2018-07-03 15:17:41 -07001302 mFromInCallFileInputStream = new FileInputStream(fromInCall.getFileDescriptor());
Hall Liu730a2592018-06-25 19:48:33 -07001303
1304 // Wrap the FileInputStream in a Channel so that it's interruptible.
Hall Liu95d55872017-01-25 17:12:49 -08001305 mPipeFromInCall = new InputStreamReader(
Hall Liu17eb1bd2018-07-03 15:17:41 -07001306 Channels.newInputStream(Channels.newChannel(mFromInCallFileInputStream)));
Hall Liu95d55872017-01-25 17:12:49 -08001307 mPipeToInCall = new OutputStreamWriter(
Hall Liua549fed2018-02-09 16:40:03 -08001308 new FileOutputStream(toInCall.getFileDescriptor()));
Hall Liu95d55872017-01-25 17:12:49 -08001309 }
1310
1311 /**
1312 * Writes the string {@param input} into the text stream to the UI for this RTT call. Since
1313 * RTT transmits text in real-time, this method should be called as often as text snippets
1314 * are received from the remote user, even if it is only one character.
Hall Liua549fed2018-02-09 16:40:03 -08001315 * <p>
Hall Liu95d55872017-01-25 17:12:49 -08001316 * This method is not thread-safe -- calling it from multiple threads simultaneously may
1317 * lead to interleaved text.
Hall Liua549fed2018-02-09 16:40:03 -08001318 *
Hall Liu95d55872017-01-25 17:12:49 -08001319 * @param input The message to send to the in-call app.
1320 */
1321 public void write(String input) throws IOException {
1322 mPipeToInCall.write(input);
1323 mPipeToInCall.flush();
1324 }
1325
1326
1327 /**
1328 * Reads a string from the in-call app, blocking if there is no data available. Returns
1329 * {@code null} if the RTT conversation has been terminated and there is no further data
1330 * to read.
Hall Liua549fed2018-02-09 16:40:03 -08001331 * <p>
Hall Liu95d55872017-01-25 17:12:49 -08001332 * This method is not thread-safe -- calling it from multiple threads simultaneously may
1333 * lead to interleaved text.
Hall Liua549fed2018-02-09 16:40:03 -08001334 *
Hall Liu95d55872017-01-25 17:12:49 -08001335 * @return A string containing text entered by the user, or {@code null} if the
1336 * conversation has been terminated or if there was an error while reading.
1337 */
Hall Liuffa4a812017-03-02 16:11:00 -08001338 public String read() throws IOException {
1339 int numRead = mPipeFromInCall.read(mReadBuffer, 0, READ_BUFFER_SIZE);
1340 if (numRead < 0) {
1341 return null;
1342 }
1343 return new String(mReadBuffer, 0, numRead);
1344 }
1345
1346 /**
1347 * Non-blocking version of {@link #read()}. Returns {@code null} if there is nothing to
1348 * be read.
Hall Liua549fed2018-02-09 16:40:03 -08001349 *
Hall Liuffa4a812017-03-02 16:11:00 -08001350 * @return A string containing text entered by the user, or {@code null} if the user has
1351 * not entered any new text yet.
1352 */
1353 public String readImmediately() throws IOException {
Hall Liu17eb1bd2018-07-03 15:17:41 -07001354 if (mFromInCallFileInputStream.available() > 0) {
Hall Liuffa4a812017-03-02 16:11:00 -08001355 return read();
1356 } else {
Hall Liu95d55872017-01-25 17:12:49 -08001357 return null;
1358 }
1359 }
Hall Liub64ac4c2017-02-06 10:49:48 -08001360
1361 /** @hide */
1362 public ParcelFileDescriptor getFdFromInCall() {
1363 return mFdFromInCall;
1364 }
1365
1366 /** @hide */
1367 public ParcelFileDescriptor getFdToInCall() {
1368 return mFdToInCall;
1369 }
1370 }
1371
1372 /**
1373 * Provides constants to represent the results of responses to session modify requests sent via
1374 * {@link Call#sendRttRequest()}
1375 */
1376 public static final class RttModifyStatus {
Hall Liu8dd49082017-04-21 14:33:12 -07001377 private RttModifyStatus() {}
Hall Liub64ac4c2017-02-06 10:49:48 -08001378 /**
1379 * Session modify request was successful.
1380 */
1381 public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1;
1382
1383 /**
1384 * Session modify request failed.
1385 */
1386 public static final int SESSION_MODIFY_REQUEST_FAIL = 2;
1387
1388 /**
1389 * Session modify request ignored due to invalid parameters.
1390 */
1391 public static final int SESSION_MODIFY_REQUEST_INVALID = 3;
1392
1393 /**
1394 * Session modify request timed out.
1395 */
1396 public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4;
1397
1398 /**
1399 * Session modify request rejected by remote user.
1400 */
1401 public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5;
Tyler Gunnb9a04962022-02-17 08:23:54 -08001402
1403
1404 /**@hide*/
1405 @Retention(RetentionPolicy.SOURCE)
1406 @IntDef(prefix = "SESSION_MODIFY_REQUEST_", value = {
1407 SESSION_MODIFY_REQUEST_SUCCESS,
1408 SESSION_MODIFY_REQUEST_FAIL,
1409 SESSION_MODIFY_REQUEST_INVALID,
1410 SESSION_MODIFY_REQUEST_TIMED_OUT,
1411 SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE
1412 })
1413 public @interface RttSessionModifyStatus {}
Hall Liu95d55872017-01-25 17:12:49 -08001414 }
1415
1416 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001417 * Provides a means of controlling the video session associated with a {@link Connection}.
1418 * <p>
1419 * Implementations create a custom subclass of {@link VideoProvider} and the
1420 * {@link ConnectionService} creates an instance sets it on the {@link Connection} using
1421 * {@link Connection#setVideoProvider(VideoProvider)}. Any connection which supports video
1422 * should set the {@link VideoProvider}.
1423 * <p>
1424 * The {@link VideoProvider} serves two primary purposes: it provides a means for Telecom and
1425 * {@link InCallService} implementations to issue requests related to the video session;
1426 * it provides a means for the {@link ConnectionService} to report events and information
1427 * related to the video session to Telecom and the {@link InCallService} implementations.
1428 * <p>
1429 * {@link InCallService} implementations interact with the {@link VideoProvider} via
1430 * {@link android.telecom.InCallService.VideoCall}.
1431 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001432 public static abstract class VideoProvider {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001433 /**
1434 * Video is not being received (no protocol pause was issued).
Tyler Gunnb702ef82015-05-29 11:51:53 -07001435 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001436 */
1437 public static final int SESSION_EVENT_RX_PAUSE = 1;
Evan Charltonbf11f982014-07-20 22:06:28 -07001438
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001439 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001440 * Video reception has resumed after a {@link #SESSION_EVENT_RX_PAUSE}.
1441 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001442 */
1443 public static final int SESSION_EVENT_RX_RESUME = 2;
1444
1445 /**
1446 * Video transmission has begun. This occurs after a negotiated start of video transmission
1447 * when the underlying protocol has actually begun transmitting video to the remote party.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001448 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001449 */
1450 public static final int SESSION_EVENT_TX_START = 3;
1451
1452 /**
1453 * Video transmission has stopped. This occurs after a negotiated stop of video transmission
1454 * when the underlying protocol has actually stopped transmitting video to the remote party.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001455 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001456 */
1457 public static final int SESSION_EVENT_TX_STOP = 4;
1458
1459 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001460 * A camera failure has occurred for the selected camera. The {@link VideoProvider} can use
Tyler Gunnb702ef82015-05-29 11:51:53 -07001461 * this as a cue to inform the user the camera is not available.
1462 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001463 */
1464 public static final int SESSION_EVENT_CAMERA_FAILURE = 5;
1465
1466 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001467 * Issued after {@link #SESSION_EVENT_CAMERA_FAILURE} when the camera is once again ready
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001468 * for operation. The {@link VideoProvider} can use this as a cue to inform the user that
Tyler Gunnb702ef82015-05-29 11:51:53 -07001469 * the camera has become available again.
1470 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001471 */
1472 public static final int SESSION_EVENT_CAMERA_READY = 6;
1473
1474 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001475 * Session event raised by Telecom when
1476 * {@link android.telecom.InCallService.VideoCall#setCamera(String)} is called and the
1477 * caller does not have the necessary {@link android.Manifest.permission#CAMERA} permission.
1478 * @see #handleCallSessionEvent(int)
1479 */
1480 public static final int SESSION_EVENT_CAMERA_PERMISSION_ERROR = 7;
1481
1482 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001483 * Session modify request was successful.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001484 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001485 */
1486 public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1;
1487
1488 /**
1489 * Session modify request failed.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001490 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001491 */
1492 public static final int SESSION_MODIFY_REQUEST_FAIL = 2;
1493
1494 /**
1495 * Session modify request ignored due to invalid parameters.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001496 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001497 */
1498 public static final int SESSION_MODIFY_REQUEST_INVALID = 3;
1499
Rekha Kumar07366812015-03-24 16:42:31 -07001500 /**
1501 * Session modify request timed out.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001502 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Rekha Kumar07366812015-03-24 16:42:31 -07001503 */
1504 public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4;
1505
1506 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001507 * Session modify request rejected by remote user.
1508 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Rekha Kumar07366812015-03-24 16:42:31 -07001509 */
1510 public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5;
1511
Tyler Gunn75958422015-04-15 14:23:42 -07001512 private static final int MSG_ADD_VIDEO_CALLBACK = 1;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001513 private static final int MSG_SET_CAMERA = 2;
1514 private static final int MSG_SET_PREVIEW_SURFACE = 3;
1515 private static final int MSG_SET_DISPLAY_SURFACE = 4;
1516 private static final int MSG_SET_DEVICE_ORIENTATION = 5;
1517 private static final int MSG_SET_ZOOM = 6;
1518 private static final int MSG_SEND_SESSION_MODIFY_REQUEST = 7;
1519 private static final int MSG_SEND_SESSION_MODIFY_RESPONSE = 8;
1520 private static final int MSG_REQUEST_CAMERA_CAPABILITIES = 9;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001521 private static final int MSG_REQUEST_CONNECTION_DATA_USAGE = 10;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001522 private static final int MSG_SET_PAUSE_IMAGE = 11;
Tyler Gunn75958422015-04-15 14:23:42 -07001523 private static final int MSG_REMOVE_VIDEO_CALLBACK = 12;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001524
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001525 private static final String SESSION_EVENT_RX_PAUSE_STR = "RX_PAUSE";
1526 private static final String SESSION_EVENT_RX_RESUME_STR = "RX_RESUME";
1527 private static final String SESSION_EVENT_TX_START_STR = "TX_START";
1528 private static final String SESSION_EVENT_TX_STOP_STR = "TX_STOP";
1529 private static final String SESSION_EVENT_CAMERA_FAILURE_STR = "CAMERA_FAIL";
1530 private static final String SESSION_EVENT_CAMERA_READY_STR = "CAMERA_READY";
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001531 private static final String SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR =
1532 "CAMERA_PERMISSION_ERROR";
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001533 private static final String SESSION_EVENT_UNKNOWN_STR = "UNKNOWN";
1534
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001535 private VideoProvider.VideoProviderHandler mMessageHandler;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001536 private final VideoProvider.VideoProviderBinder mBinder;
Tyler Gunn75958422015-04-15 14:23:42 -07001537
1538 /**
1539 * Stores a list of the video callbacks, keyed by IBinder.
Tyler Gunn84f381b2015-06-12 09:26:45 -07001540 *
1541 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
1542 * load factor before resizing, 1 means we only expect a single thread to
1543 * access the map so make only a single shard
Tyler Gunn75958422015-04-15 14:23:42 -07001544 */
Tyler Gunn84f381b2015-06-12 09:26:45 -07001545 private ConcurrentHashMap<IBinder, IVideoCallback> mVideoCallbacks =
1546 new ConcurrentHashMap<IBinder, IVideoCallback>(8, 0.9f, 1);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001547
1548 /**
1549 * Default handler used to consolidate binder method calls onto a single thread.
1550 */
1551 private final class VideoProviderHandler extends Handler {
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001552 public VideoProviderHandler() {
1553 super();
1554 }
1555
1556 public VideoProviderHandler(Looper looper) {
1557 super(looper);
1558 }
1559
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001560 @Override
1561 public void handleMessage(Message msg) {
1562 switch (msg.what) {
Tyler Gunn75958422015-04-15 14:23:42 -07001563 case MSG_ADD_VIDEO_CALLBACK: {
1564 IBinder binder = (IBinder) msg.obj;
1565 IVideoCallback callback = IVideoCallback.Stub
1566 .asInterface((IBinder) msg.obj);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001567 if (callback == null) {
1568 Log.w(this, "addVideoProvider - skipped; callback is null.");
1569 break;
1570 }
1571
Tyler Gunn75958422015-04-15 14:23:42 -07001572 if (mVideoCallbacks.containsKey(binder)) {
1573 Log.i(this, "addVideoProvider - skipped; already present.");
1574 break;
1575 }
1576 mVideoCallbacks.put(binder, callback);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001577 break;
Tyler Gunn75958422015-04-15 14:23:42 -07001578 }
1579 case MSG_REMOVE_VIDEO_CALLBACK: {
1580 IBinder binder = (IBinder) msg.obj;
1581 IVideoCallback callback = IVideoCallback.Stub
1582 .asInterface((IBinder) msg.obj);
1583 if (!mVideoCallbacks.containsKey(binder)) {
1584 Log.i(this, "removeVideoProvider - skipped; not present.");
1585 break;
1586 }
1587 mVideoCallbacks.remove(binder);
1588 break;
1589 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001590 case MSG_SET_CAMERA:
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001591 {
1592 SomeArgs args = (SomeArgs) msg.obj;
1593 try {
1594 onSetCamera((String) args.arg1);
1595 onSetCamera((String) args.arg1, (String) args.arg2, args.argi1,
Tyler Gunn159f35c2017-03-02 09:28:37 -08001596 args.argi2, args.argi3);
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001597 } finally {
1598 args.recycle();
1599 }
1600 }
1601 break;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001602 case MSG_SET_PREVIEW_SURFACE:
1603 onSetPreviewSurface((Surface) msg.obj);
1604 break;
1605 case MSG_SET_DISPLAY_SURFACE:
1606 onSetDisplaySurface((Surface) msg.obj);
1607 break;
1608 case MSG_SET_DEVICE_ORIENTATION:
1609 onSetDeviceOrientation(msg.arg1);
1610 break;
1611 case MSG_SET_ZOOM:
1612 onSetZoom((Float) msg.obj);
1613 break;
Tyler Gunn45382162015-05-06 08:52:27 -07001614 case MSG_SEND_SESSION_MODIFY_REQUEST: {
1615 SomeArgs args = (SomeArgs) msg.obj;
1616 try {
1617 onSendSessionModifyRequest((VideoProfile) args.arg1,
1618 (VideoProfile) args.arg2);
1619 } finally {
1620 args.recycle();
1621 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001622 break;
Tyler Gunn45382162015-05-06 08:52:27 -07001623 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001624 case MSG_SEND_SESSION_MODIFY_RESPONSE:
1625 onSendSessionModifyResponse((VideoProfile) msg.obj);
1626 break;
1627 case MSG_REQUEST_CAMERA_CAPABILITIES:
1628 onRequestCameraCapabilities();
1629 break;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001630 case MSG_REQUEST_CONNECTION_DATA_USAGE:
1631 onRequestConnectionDataUsage();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001632 break;
1633 case MSG_SET_PAUSE_IMAGE:
Yorke Lee32f24732015-05-12 16:18:03 -07001634 onSetPauseImage((Uri) msg.obj);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001635 break;
1636 default:
1637 break;
1638 }
1639 }
1640 }
1641
1642 /**
1643 * IVideoProvider stub implementation.
1644 */
1645 private final class VideoProviderBinder extends IVideoProvider.Stub {
Tyler Gunn75958422015-04-15 14:23:42 -07001646 public void addVideoCallback(IBinder videoCallbackBinder) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001647 mMessageHandler.obtainMessage(
Tyler Gunn75958422015-04-15 14:23:42 -07001648 MSG_ADD_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget();
1649 }
1650
1651 public void removeVideoCallback(IBinder videoCallbackBinder) {
1652 mMessageHandler.obtainMessage(
1653 MSG_REMOVE_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001654 }
1655
Tyler Gunn159f35c2017-03-02 09:28:37 -08001656 public void setCamera(String cameraId, String callingPackageName,
1657 int targetSdkVersion) {
1658
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001659 SomeArgs args = SomeArgs.obtain();
1660 args.arg1 = cameraId;
1661 // Propagate the calling package; originally determined in
1662 // android.telecom.InCallService.VideoCall#setCamera(String) from the calling
1663 // process.
1664 args.arg2 = callingPackageName;
1665 // Pass along the uid and pid of the calling app; this gets lost when we put the
1666 // message onto the handler. These are required for Telecom to perform a permission
1667 // check to see if the calling app is able to use the camera.
1668 args.argi1 = Binder.getCallingUid();
1669 args.argi2 = Binder.getCallingPid();
Tyler Gunn159f35c2017-03-02 09:28:37 -08001670 // Pass along the target SDK version of the calling InCallService. This is used to
1671 // maintain backwards compatibility of the API for older callers.
1672 args.argi3 = targetSdkVersion;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001673 mMessageHandler.obtainMessage(MSG_SET_CAMERA, args).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001674 }
1675
1676 public void setPreviewSurface(Surface surface) {
1677 mMessageHandler.obtainMessage(MSG_SET_PREVIEW_SURFACE, surface).sendToTarget();
1678 }
1679
1680 public void setDisplaySurface(Surface surface) {
1681 mMessageHandler.obtainMessage(MSG_SET_DISPLAY_SURFACE, surface).sendToTarget();
1682 }
1683
1684 public void setDeviceOrientation(int rotation) {
Rekha Kumar07366812015-03-24 16:42:31 -07001685 mMessageHandler.obtainMessage(
1686 MSG_SET_DEVICE_ORIENTATION, rotation, 0).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001687 }
1688
1689 public void setZoom(float value) {
1690 mMessageHandler.obtainMessage(MSG_SET_ZOOM, value).sendToTarget();
1691 }
1692
Tyler Gunn45382162015-05-06 08:52:27 -07001693 public void sendSessionModifyRequest(VideoProfile fromProfile, VideoProfile toProfile) {
1694 SomeArgs args = SomeArgs.obtain();
1695 args.arg1 = fromProfile;
1696 args.arg2 = toProfile;
1697 mMessageHandler.obtainMessage(MSG_SEND_SESSION_MODIFY_REQUEST, args).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001698 }
1699
1700 public void sendSessionModifyResponse(VideoProfile responseProfile) {
1701 mMessageHandler.obtainMessage(
1702 MSG_SEND_SESSION_MODIFY_RESPONSE, responseProfile).sendToTarget();
1703 }
1704
1705 public void requestCameraCapabilities() {
1706 mMessageHandler.obtainMessage(MSG_REQUEST_CAMERA_CAPABILITIES).sendToTarget();
1707 }
1708
1709 public void requestCallDataUsage() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001710 mMessageHandler.obtainMessage(MSG_REQUEST_CONNECTION_DATA_USAGE).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001711 }
1712
Yorke Lee32f24732015-05-12 16:18:03 -07001713 public void setPauseImage(Uri uri) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001714 mMessageHandler.obtainMessage(MSG_SET_PAUSE_IMAGE, uri).sendToTarget();
1715 }
1716 }
1717
1718 public VideoProvider() {
1719 mBinder = new VideoProvider.VideoProviderBinder();
Tyler Gunn84f381b2015-06-12 09:26:45 -07001720 mMessageHandler = new VideoProvider.VideoProviderHandler(Looper.getMainLooper());
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001721 }
1722
1723 /**
1724 * Creates an instance of the {@link VideoProvider}, specifying the looper to use.
1725 *
1726 * @param looper The looper.
1727 * @hide
1728 */
Mathew Inwood42346d12018-08-01 11:33:05 +01001729 @UnsupportedAppUsage
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001730 public VideoProvider(Looper looper) {
1731 mBinder = new VideoProvider.VideoProviderBinder();
1732 mMessageHandler = new VideoProvider.VideoProviderHandler(looper);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001733 }
1734
1735 /**
1736 * Returns binder object which can be used across IPC methods.
1737 * @hide
1738 */
1739 public final IVideoProvider getInterface() {
1740 return mBinder;
1741 }
1742
1743 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001744 * Sets the camera to be used for the outgoing video.
1745 * <p>
1746 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1747 * camera via
1748 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1749 * <p>
1750 * Sent from the {@link InCallService} via
1751 * {@link InCallService.VideoCall#setCamera(String)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001752 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001753 * @param cameraId The id of the camera (use ids as reported by
1754 * {@link CameraManager#getCameraIdList()}).
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001755 */
1756 public abstract void onSetCamera(String cameraId);
1757
1758 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001759 * Sets the camera to be used for the outgoing video.
1760 * <p>
1761 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1762 * camera via
1763 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1764 * <p>
1765 * This prototype is used internally to ensure that the calling package name, UID and PID
1766 * are sent to Telecom so that can perform a camera permission check on the caller.
1767 * <p>
1768 * Sent from the {@link InCallService} via
1769 * {@link InCallService.VideoCall#setCamera(String)}.
1770 *
1771 * @param cameraId The id of the camera (use ids as reported by
1772 * {@link CameraManager#getCameraIdList()}).
1773 * @param callingPackageName The AppOpps package name of the caller.
1774 * @param callingUid The UID of the caller.
1775 * @param callingPid The PID of the caller.
Tyler Gunn159f35c2017-03-02 09:28:37 -08001776 * @param targetSdkVersion The target SDK version of the caller.
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001777 * @hide
1778 */
1779 public void onSetCamera(String cameraId, String callingPackageName, int callingUid,
Tyler Gunn159f35c2017-03-02 09:28:37 -08001780 int callingPid, int targetSdkVersion) {}
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001781
1782 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001783 * Sets the surface to be used for displaying a preview of what the user's camera is
1784 * currently capturing. When video transmission is enabled, this is the video signal which
1785 * is sent to the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001786 * <p>
1787 * Sent from the {@link InCallService} via
1788 * {@link InCallService.VideoCall#setPreviewSurface(Surface)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001789 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001790 * @param surface The {@link Surface}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001791 */
1792 public abstract void onSetPreviewSurface(Surface surface);
1793
1794 /**
1795 * Sets the surface to be used for displaying the video received from the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001796 * <p>
1797 * Sent from the {@link InCallService} via
1798 * {@link InCallService.VideoCall#setDisplaySurface(Surface)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001799 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001800 * @param surface The {@link Surface}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001801 */
1802 public abstract void onSetDisplaySurface(Surface surface);
1803
1804 /**
1805 * Sets the device orientation, in degrees. Assumes that a standard portrait orientation of
1806 * the device is 0 degrees.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001807 * <p>
1808 * Sent from the {@link InCallService} via
1809 * {@link InCallService.VideoCall#setDeviceOrientation(int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001810 *
1811 * @param rotation The device orientation, in degrees.
1812 */
1813 public abstract void onSetDeviceOrientation(int rotation);
1814
1815 /**
Tyler Gunnc603b462021-06-14 17:24:40 -07001816 * Sets the camera zoom ratio.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001817 * <p>
1818 * Sent from the {@link InCallService} via {@link InCallService.VideoCall#setZoom(float)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001819 *
Tyler Gunnc603b462021-06-14 17:24:40 -07001820 * @param value The camera zoom ratio; for the current camera, should be a value in the
1821 * range defined by
1822 * {@link android.hardware.camera2.CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001823 */
1824 public abstract void onSetZoom(float value);
1825
1826 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001827 * Issues a request to modify the properties of the current video session.
1828 * <p>
1829 * Example scenarios include: requesting an audio-only call to be upgraded to a
1830 * bi-directional video call, turning on or off the user's camera, sending a pause signal
1831 * when the {@link InCallService} is no longer the foreground application.
1832 * <p>
1833 * If the {@link VideoProvider} determines a request to be invalid, it should call
1834 * {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)} to report the
1835 * invalid request back to the {@link InCallService}.
1836 * <p>
1837 * Where a request requires confirmation from the user of the peer device, the
1838 * {@link VideoProvider} must communicate the request to the peer device and handle the
1839 * user's response. {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)}
1840 * is used to inform the {@link InCallService} of the result of the request.
1841 * <p>
1842 * Sent from the {@link InCallService} via
1843 * {@link InCallService.VideoCall#sendSessionModifyRequest(VideoProfile)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001844 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001845 * @param fromProfile The video profile prior to the request.
1846 * @param toProfile The video profile with the requested changes made.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001847 */
Tyler Gunn45382162015-05-06 08:52:27 -07001848 public abstract void onSendSessionModifyRequest(VideoProfile fromProfile,
1849 VideoProfile toProfile);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001850
Tyler Gunnb702ef82015-05-29 11:51:53 -07001851 /**
1852 * Provides a response to a request to change the current video session properties.
1853 * <p>
1854 * For example, if the peer requests and upgrade from an audio-only call to a bi-directional
1855 * video call, could decline the request and keep the call as audio-only.
1856 * In such a scenario, the {@code responseProfile} would have a video state of
1857 * {@link VideoProfile#STATE_AUDIO_ONLY}. If the user had decided to accept the request,
1858 * the video state would be {@link VideoProfile#STATE_BIDIRECTIONAL}.
1859 * <p>
1860 * Sent from the {@link InCallService} via
1861 * {@link InCallService.VideoCall#sendSessionModifyResponse(VideoProfile)} in response to
1862 * a {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)}
1863 * callback.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001864 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001865 * @param responseProfile The response video profile.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001866 */
1867 public abstract void onSendSessionModifyResponse(VideoProfile responseProfile);
1868
1869 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001870 * Issues a request to the {@link VideoProvider} to retrieve the camera capabilities.
1871 * <p>
1872 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1873 * camera via
1874 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1875 * <p>
1876 * Sent from the {@link InCallService} via
1877 * {@link InCallService.VideoCall#requestCameraCapabilities()}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001878 */
1879 public abstract void onRequestCameraCapabilities();
1880
1881 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001882 * Issues a request to the {@link VideoProvider} to retrieve the current data usage for the
1883 * video component of the current {@link Connection}.
1884 * <p>
1885 * The {@link VideoProvider} should respond by communicating current data usage, in bytes,
1886 * via {@link VideoProvider#setCallDataUsage(long)}.
1887 * <p>
1888 * Sent from the {@link InCallService} via
1889 * {@link InCallService.VideoCall#requestCallDataUsage()}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001890 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001891 public abstract void onRequestConnectionDataUsage();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001892
1893 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001894 * Provides the {@link VideoProvider} with the {@link Uri} of an image to be displayed to
1895 * the peer device when the video signal is paused.
1896 * <p>
1897 * Sent from the {@link InCallService} via
1898 * {@link InCallService.VideoCall#setPauseImage(Uri)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001899 *
1900 * @param uri URI of image to display.
1901 */
Yorke Lee32f24732015-05-12 16:18:03 -07001902 public abstract void onSetPauseImage(Uri uri);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001903
1904 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001905 * Used to inform listening {@link InCallService} implementations when the
1906 * {@link VideoProvider} receives a session modification request.
1907 * <p>
1908 * Received by the {@link InCallService} via
1909 * {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)},
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001910 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001911 * @param videoProfile The requested video profile.
1912 * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001913 */
1914 public void receiveSessionModifyRequest(VideoProfile videoProfile) {
Tyler Gunn75958422015-04-15 14:23:42 -07001915 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001916 for (IVideoCallback callback : mVideoCallbacks.values()) {
1917 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001918 callback.receiveSessionModifyRequest(videoProfile);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001919 } catch (RemoteException ignored) {
1920 Log.w(this, "receiveSessionModifyRequest callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001921 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001922 }
1923 }
1924 }
1925
1926 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001927 * Used to inform listening {@link InCallService} implementations when the
1928 * {@link VideoProvider} receives a response to a session modification request.
1929 * <p>
1930 * Received by the {@link InCallService} via
1931 * {@link InCallService.VideoCall.Callback#onSessionModifyResponseReceived(int,
1932 * VideoProfile, VideoProfile)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001933 *
1934 * @param status Status of the session modify request. Valid values are
1935 * {@link VideoProvider#SESSION_MODIFY_REQUEST_SUCCESS},
1936 * {@link VideoProvider#SESSION_MODIFY_REQUEST_FAIL},
Tyler Gunnb702ef82015-05-29 11:51:53 -07001937 * {@link VideoProvider#SESSION_MODIFY_REQUEST_INVALID},
1938 * {@link VideoProvider#SESSION_MODIFY_REQUEST_TIMED_OUT},
1939 * {@link VideoProvider#SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE}
1940 * @param requestedProfile The original request which was sent to the peer device.
1941 * @param responseProfile The actual profile changes agreed to by the peer device.
1942 * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001943 */
1944 public void receiveSessionModifyResponse(int status,
1945 VideoProfile requestedProfile, VideoProfile responseProfile) {
Tyler Gunn75958422015-04-15 14:23:42 -07001946 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001947 for (IVideoCallback callback : mVideoCallbacks.values()) {
1948 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001949 callback.receiveSessionModifyResponse(status, requestedProfile,
1950 responseProfile);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001951 } catch (RemoteException ignored) {
1952 Log.w(this, "receiveSessionModifyResponse callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001953 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001954 }
1955 }
1956 }
1957
1958 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001959 * Used to inform listening {@link InCallService} implementations when the
1960 * {@link VideoProvider} reports a call session event.
1961 * <p>
1962 * Received by the {@link InCallService} via
1963 * {@link InCallService.VideoCall.Callback#onCallSessionEvent(int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001964 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001965 * @param event The event. Valid values are: {@link VideoProvider#SESSION_EVENT_RX_PAUSE},
1966 * {@link VideoProvider#SESSION_EVENT_RX_RESUME},
1967 * {@link VideoProvider#SESSION_EVENT_TX_START},
1968 * {@link VideoProvider#SESSION_EVENT_TX_STOP},
1969 * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE},
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001970 * {@link VideoProvider#SESSION_EVENT_CAMERA_READY},
1971 * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001972 */
1973 public void handleCallSessionEvent(int event) {
Tyler Gunn75958422015-04-15 14:23:42 -07001974 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001975 for (IVideoCallback callback : mVideoCallbacks.values()) {
1976 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001977 callback.handleCallSessionEvent(event);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001978 } catch (RemoteException ignored) {
1979 Log.w(this, "handleCallSessionEvent callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001980 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001981 }
1982 }
1983 }
1984
1985 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001986 * Used to inform listening {@link InCallService} implementations when the dimensions of the
1987 * peer's video have changed.
1988 * <p>
1989 * This could occur if, for example, the peer rotates their device, changing the aspect
1990 * ratio of the video, or if the user switches between the back and front cameras.
1991 * <p>
1992 * Received by the {@link InCallService} via
1993 * {@link InCallService.VideoCall.Callback#onPeerDimensionsChanged(int, int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001994 *
1995 * @param width The updated peer video width.
1996 * @param height The updated peer video height.
1997 */
1998 public void changePeerDimensions(int width, int height) {
Tyler Gunn75958422015-04-15 14:23:42 -07001999 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002000 for (IVideoCallback callback : mVideoCallbacks.values()) {
2001 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002002 callback.changePeerDimensions(width, height);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002003 } catch (RemoteException ignored) {
2004 Log.w(this, "changePeerDimensions callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002005 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002006 }
2007 }
2008 }
2009
2010 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002011 * Used to inform listening {@link InCallService} implementations when the data usage of the
2012 * video associated with the current {@link Connection} has changed.
2013 * <p>
2014 * This could be in response to a preview request via
2015 * {@link #onRequestConnectionDataUsage()}, or as a periodic update by the
Tyler Gunn295f5d72015-06-04 11:08:54 -07002016 * {@link VideoProvider}. Where periodic updates of data usage are provided, they should be
2017 * 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 -07002018 * <p>
2019 * Received by the {@link InCallService} via
2020 * {@link InCallService.VideoCall.Callback#onCallDataUsageChanged(long)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002021 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002022 * @param dataUsage The updated data usage (in bytes). Reported as the cumulative bytes
2023 * used since the start of the call.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002024 */
Yorke Lee32f24732015-05-12 16:18:03 -07002025 public void setCallDataUsage(long dataUsage) {
Tyler Gunn75958422015-04-15 14:23:42 -07002026 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002027 for (IVideoCallback callback : mVideoCallbacks.values()) {
2028 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002029 callback.changeCallDataUsage(dataUsage);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002030 } catch (RemoteException ignored) {
2031 Log.w(this, "setCallDataUsage callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002032 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002033 }
2034 }
2035 }
2036
2037 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002038 * @see #setCallDataUsage(long)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002039 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002040 * @param dataUsage The updated data usage (in byes).
Yorke Lee32f24732015-05-12 16:18:03 -07002041 * @deprecated - Use {@link #setCallDataUsage(long)} instead.
2042 * @hide
2043 */
2044 public void changeCallDataUsage(long dataUsage) {
2045 setCallDataUsage(dataUsage);
2046 }
2047
2048 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002049 * Used to inform listening {@link InCallService} implementations when the capabilities of
2050 * the current camera have changed.
2051 * <p>
2052 * The {@link VideoProvider} should call this in response to
2053 * {@link VideoProvider#onRequestCameraCapabilities()}, or when the current camera is
2054 * changed via {@link VideoProvider#onSetCamera(String)}.
2055 * <p>
2056 * Received by the {@link InCallService} via
2057 * {@link InCallService.VideoCall.Callback#onCameraCapabilitiesChanged(
2058 * VideoProfile.CameraCapabilities)}.
Yorke Lee32f24732015-05-12 16:18:03 -07002059 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002060 * @param cameraCapabilities The new camera capabilities.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002061 */
Yorke Lee400470f2015-05-12 13:31:25 -07002062 public void changeCameraCapabilities(VideoProfile.CameraCapabilities cameraCapabilities) {
Tyler Gunn75958422015-04-15 14:23:42 -07002063 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002064 for (IVideoCallback callback : mVideoCallbacks.values()) {
2065 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002066 callback.changeCameraCapabilities(cameraCapabilities);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002067 } catch (RemoteException ignored) {
2068 Log.w(this, "changeCameraCapabilities callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002069 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002070 }
2071 }
2072 }
Rekha Kumar07366812015-03-24 16:42:31 -07002073
2074 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002075 * Used to inform listening {@link InCallService} implementations when the video quality
2076 * of the call has changed.
2077 * <p>
2078 * Received by the {@link InCallService} via
2079 * {@link InCallService.VideoCall.Callback#onVideoQualityChanged(int)}.
Rekha Kumar07366812015-03-24 16:42:31 -07002080 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002081 * @param videoQuality The updated video quality. Valid values:
2082 * {@link VideoProfile#QUALITY_HIGH},
2083 * {@link VideoProfile#QUALITY_MEDIUM},
2084 * {@link VideoProfile#QUALITY_LOW},
2085 * {@link VideoProfile#QUALITY_DEFAULT}.
Rekha Kumar07366812015-03-24 16:42:31 -07002086 */
2087 public void changeVideoQuality(int videoQuality) {
Tyler Gunn75958422015-04-15 14:23:42 -07002088 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002089 for (IVideoCallback callback : mVideoCallbacks.values()) {
2090 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002091 callback.changeVideoQuality(videoQuality);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002092 } catch (RemoteException ignored) {
2093 Log.w(this, "changeVideoQuality callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002094 }
Rekha Kumar07366812015-03-24 16:42:31 -07002095 }
2096 }
2097 }
Tyler Gunn6f657ee2016-09-02 09:55:25 -07002098
2099 /**
2100 * Returns a string representation of a call session event.
2101 *
2102 * @param event A call session event passed to {@link #handleCallSessionEvent(int)}.
2103 * @return String representation of the call session event.
2104 * @hide
2105 */
2106 public static String sessionEventToString(int event) {
2107 switch (event) {
2108 case SESSION_EVENT_CAMERA_FAILURE:
2109 return SESSION_EVENT_CAMERA_FAILURE_STR;
2110 case SESSION_EVENT_CAMERA_READY:
2111 return SESSION_EVENT_CAMERA_READY_STR;
2112 case SESSION_EVENT_RX_PAUSE:
2113 return SESSION_EVENT_RX_PAUSE_STR;
2114 case SESSION_EVENT_RX_RESUME:
2115 return SESSION_EVENT_RX_RESUME_STR;
2116 case SESSION_EVENT_TX_START:
2117 return SESSION_EVENT_TX_START_STR;
2118 case SESSION_EVENT_TX_STOP:
2119 return SESSION_EVENT_TX_STOP_STR;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08002120 case SESSION_EVENT_CAMERA_PERMISSION_ERROR:
2121 return SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR;
Tyler Gunn6f657ee2016-09-02 09:55:25 -07002122 default:
2123 return SESSION_EVENT_UNKNOWN_STR + " " + event;
2124 }
2125 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002126 }
2127
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002128 private final Listener mConnectionDeathListener = new Listener() {
2129 @Override
2130 public void onDestroyed(Connection c) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002131 if (mConferenceables.remove(c)) {
2132 fireOnConferenceableConnectionsChanged();
2133 }
2134 }
2135 };
2136
2137 private final Conference.Listener mConferenceDeathListener = new Conference.Listener() {
2138 @Override
2139 public void onDestroyed(Conference c) {
2140 if (mConferenceables.remove(c)) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002141 fireOnConferenceableConnectionsChanged();
2142 }
2143 }
2144 };
2145
Jay Shrauner229e3822014-08-15 09:23:07 -07002146 /**
2147 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
2148 * load factor before resizing, 1 means we only expect a single thread to
2149 * access the map so make only a single shard
2150 */
2151 private final Set<Listener> mListeners = Collections.newSetFromMap(
2152 new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1));
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002153 private final List<Conferenceable> mConferenceables = new ArrayList<>();
2154 private final List<Conferenceable> mUnmodifiableConferenceables =
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002155 Collections.unmodifiableList(mConferenceables);
Santos Cordonb6939982014-06-04 20:20:58 -07002156
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002157 // The internal telecom call ID associated with this connection.
2158 private String mTelecomCallId;
Pengquan Meng70c9885332017-10-02 18:09:03 -07002159 // The PhoneAccountHandle associated with this connection.
2160 private PhoneAccountHandle mPhoneAccountHandle;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002161 private int mState = STATE_NEW;
Yorke Lee4af59352015-05-13 14:14:54 -07002162 private CallAudioState mCallAudioState;
Andrew Lee100e2932014-09-08 15:34:24 -07002163 private Uri mAddress;
2164 private int mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -07002165 private String mCallerDisplayName;
2166 private int mCallerDisplayNamePresentation;
Andrew Lee100e2932014-09-08 15:34:24 -07002167 private boolean mRingbackRequested = false;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002168 private int mConnectionCapabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -07002169 private int mConnectionProperties;
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002170 private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002171 private VideoProvider mVideoProvider;
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002172 private boolean mAudioModeIsVoip;
Roshan Piuse927ec02015-07-15 15:47:21 -07002173 private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002174 private long mConnectElapsedTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002175 private StatusHints mStatusHints;
Tyler Gunnaa07df82014-07-17 07:50:22 -07002176 private int mVideoState;
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002177 private DisconnectCause mDisconnectCause;
Santos Cordon823fd3c2014-08-07 18:35:18 -07002178 private Conference mConference;
2179 private ConnectionService mConnectionService;
Santos Cordon6b7f9552015-05-27 17:21:45 -07002180 private Bundle mExtras;
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002181 private final Object mExtrasLock = new Object();
Tyler Gunn6986a632019-06-25 13:45:32 -07002182 /**
2183 * The direction of the connection; used where an existing connection is created and we need to
2184 * communicate to Telecom whether its incoming or outgoing.
2185 */
2186 private @Call.Details.CallDirection int mCallDirection = Call.Details.DIRECTION_UNKNOWN;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002187
2188 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002189 * Tracks the key set for the extras bundle provided on the last invocation of
2190 * {@link #setExtras(Bundle)}. Used so that on subsequent invocations we can remove any extras
2191 * keys which were set previously but are no longer present in the replacement Bundle.
2192 */
2193 private Set<String> mPreviousExtraKeys;
2194
2195 /**
Tyler Gunnd57d76c2019-09-24 14:53:23 -07002196 * The verification status for an incoming call's phone number.
2197 */
2198 private @VerificationStatus int mCallerNumberVerificationStatus;
2199
2200
2201 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002202 * Create a new Connection.
2203 */
Santos Cordonf2951102014-07-20 19:06:29 -07002204 public Connection() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002205
2206 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002207 * Returns the Telecom internal call ID associated with this connection. Should only be used
2208 * for debugging and tracing purposes.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002209 * <p>
2210 * Note: Access to the Telecom internal call ID is used for logging purposes only; this API is
2211 * provided to facilitate debugging of the Telephony stack only.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002212 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07002213 * @return The Telecom call ID, or {@code null} if it was not set.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002214 * @hide
2215 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002216 @SystemApi
2217 public final @Nullable String getTelecomCallId() {
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002218 return mTelecomCallId;
2219 }
2220
2221 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002222 * @return The address (e.g., phone number) to which this Connection is currently communicating.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002223 */
Andrew Lee100e2932014-09-08 15:34:24 -07002224 public final Uri getAddress() {
2225 return mAddress;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002226 }
2227
2228 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002229 * @return The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002230 * See {@link TelecomManager} for valid values.
Sailesh Nepal61203862014-07-11 14:50:13 -07002231 */
Andrew Lee100e2932014-09-08 15:34:24 -07002232 public final int getAddressPresentation() {
2233 return mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -07002234 }
2235
2236 /**
2237 * @return The caller display name (CNAP).
2238 */
2239 public final String getCallerDisplayName() {
2240 return mCallerDisplayName;
2241 }
2242
2243 /**
Nancy Chen9d568c02014-09-08 14:17:59 -07002244 * @return The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002245 * See {@link TelecomManager} for valid values.
Sailesh Nepal61203862014-07-11 14:50:13 -07002246 */
2247 public final int getCallerDisplayNamePresentation() {
2248 return mCallerDisplayNamePresentation;
2249 }
2250
2251 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002252 * @return The state of this Connection.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002253 */
2254 public final int getState() {
2255 return mState;
2256 }
2257
2258 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002259 * Returns the video state of the connection.
Yorke Lee32f24732015-05-12 16:18:03 -07002260 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
2261 * {@link VideoProfile#STATE_BIDIRECTIONAL},
2262 * {@link VideoProfile#STATE_TX_ENABLED},
2263 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002264 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002265 * @return The video state of the connection.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002266 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002267 public final @VideoProfile.VideoState int getVideoState() {
Tyler Gunnaa07df82014-07-17 07:50:22 -07002268 return mVideoState;
2269 }
2270
2271 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002272 * @return The audio state of the connection, describing how its audio is currently
Ihab Awad542e0ea2014-05-16 10:22:16 -07002273 * being routed by the system. This is {@code null} if this Connection
2274 * does not directly know about its audio state.
Yorke Lee4af59352015-05-13 14:14:54 -07002275 * @deprecated Use {@link #getCallAudioState()} instead.
2276 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -07002277 */
Yorke Lee4af59352015-05-13 14:14:54 -07002278 @SystemApi
2279 @Deprecated
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002280 public final AudioState getAudioState() {
Sailesh Nepal000d38a2015-06-21 10:25:13 -07002281 if (mCallAudioState == null) {
2282 return null;
2283 }
Yorke Lee4af59352015-05-13 14:14:54 -07002284 return new AudioState(mCallAudioState);
2285 }
2286
2287 /**
2288 * @return The audio state of the connection, describing how its audio is currently
2289 * being routed by the system. This is {@code null} if this Connection
2290 * does not directly know about its audio state.
2291 */
2292 public final CallAudioState getCallAudioState() {
2293 return mCallAudioState;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002294 }
2295
2296 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002297 * @return The conference that this connection is a part of. Null if it is not part of any
2298 * conference.
2299 */
2300 public final Conference getConference() {
2301 return mConference;
2302 }
2303
2304 /**
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002305 * Returns whether this connection is requesting that the system play a ringback tone
2306 * on its behalf.
2307 */
Andrew Lee100e2932014-09-08 15:34:24 -07002308 public final boolean isRingbackRequested() {
2309 return mRingbackRequested;
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002310 }
2311
2312 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002313 * @return True if the connection's audio mode is VOIP.
2314 */
2315 public final boolean getAudioModeIsVoip() {
2316 return mAudioModeIsVoip;
2317 }
2318
2319 /**
Roshan Piuse927ec02015-07-15 15:47:21 -07002320 * Retrieves the connection start time of the {@code Connnection}, if specified. A value of
2321 * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
2322 * start time of the conference.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002323 * <p>
2324 * Note: This is an implementation detail specific to IMS conference calls over a mobile
2325 * network.
Roshan Piuse927ec02015-07-15 15:47:21 -07002326 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07002327 * @return The time at which the {@code Connnection} was connected. Will be a value as retrieved
2328 * from {@link System#currentTimeMillis()}.
Roshan Piuse927ec02015-07-15 15:47:21 -07002329 *
2330 * @hide
2331 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002332 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002333 public final @IntRange(from = 0) long getConnectTimeMillis() {
Roshan Piuse927ec02015-07-15 15:47:21 -07002334 return mConnectTimeMillis;
2335 }
2336
2337 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002338 * Retrieves the connection start time of the {@link Connection}, if specified. A value of
2339 * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
Tyler Gunnc9503d62020-01-27 10:30:51 -08002340 * start time of the connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002341 * <p>
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002342 * Based on the value of {@link SystemClock#elapsedRealtime()}, which ensures that wall-clock
2343 * changes do not impact the call duration.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002344 * <p>
2345 * Used internally in Telephony when migrating conference participant data for IMS conferences.
Tyler Gunnc9503d62020-01-27 10:30:51 -08002346 * <p>
2347 * The value returned is the same one set using
2348 * {@link #setConnectionStartElapsedRealtimeMillis(long)}. This value is never updated from
2349 * the Telecom framework, so no permission enforcement occurs when retrieving the value with
2350 * this method.
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002351 *
2352 * @return The time at which the {@link Connection} was connected.
2353 *
2354 * @hide
2355 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002356 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002357 public final @ElapsedRealtimeLong long getConnectionStartElapsedRealtimeMillis() {
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002358 return mConnectElapsedTimeMillis;
2359 }
2360
2361 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002362 * @return The status hints for this connection.
2363 */
2364 public final StatusHints getStatusHints() {
2365 return mStatusHints;
2366 }
2367
2368 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002369 * Returns the extras associated with this connection.
Tyler Gunn2cbe2b52016-05-04 15:48:10 +00002370 * <p>
2371 * Extras should be updated using {@link #putExtras(Bundle)}.
2372 * <p>
2373 * Telecom or an {@link InCallService} can also update the extras via
2374 * {@link android.telecom.Call#putExtras(Bundle)}, and
2375 * {@link Call#removeExtras(List)}.
2376 * <p>
2377 * The connection is notified of changes to the extras made by Telecom or an
2378 * {@link InCallService} by {@link #onExtrasChanged(Bundle)}.
Tyler Gunndee56a82016-03-23 16:06:34 -07002379 *
Santos Cordon6b7f9552015-05-27 17:21:45 -07002380 * @return The extras associated with this connection.
2381 */
2382 public final Bundle getExtras() {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002383 Bundle extras = null;
2384 synchronized (mExtrasLock) {
2385 if (mExtras != null) {
2386 extras = new Bundle(mExtras);
2387 }
2388 }
2389 return extras;
Santos Cordon6b7f9552015-05-27 17:21:45 -07002390 }
2391
2392 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002393 * Assign a listener to be notified of state changes.
2394 *
2395 * @param l A listener.
2396 * @return This Connection.
2397 *
2398 * @hide
2399 */
Tyler Gunn633e4c32019-10-24 15:40:48 -07002400 final Connection addConnectionListener(Listener l) {
Santos Cordond34e5712014-08-05 18:54:03 +00002401 mListeners.add(l);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002402 return this;
2403 }
2404
2405 /**
2406 * Remove a previously assigned listener that was being notified of state changes.
2407 *
2408 * @param l A Listener.
2409 * @return This Connection.
2410 *
2411 * @hide
2412 */
Tyler Gunn633e4c32019-10-24 15:40:48 -07002413 final Connection removeConnectionListener(Listener l) {
Jay Shrauner229e3822014-08-15 09:23:07 -07002414 if (l != null) {
2415 mListeners.remove(l);
2416 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002417 return this;
2418 }
2419
2420 /**
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002421 * @return The {@link DisconnectCause} for this connection.
Evan Charltonbf11f982014-07-20 22:06:28 -07002422 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002423 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002424 return mDisconnectCause;
Evan Charltonbf11f982014-07-20 22:06:28 -07002425 }
2426
2427 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002428 * Sets the telecom call ID associated with this Connection. The Telecom Call ID should be used
2429 * ONLY for debugging purposes.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002430 * <p>
2431 * Note: Access to the Telecom internal call ID is used for logging purposes only; this API is
2432 * provided to facilitate debugging of the Telephony stack only. Changing the ID via this
2433 * method does NOT change any functionality in Telephony or Telecom and impacts only logging.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002434 *
2435 * @param callId The telecom call ID.
2436 * @hide
2437 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002438 @SystemApi
2439 public void setTelecomCallId(@NonNull String callId) {
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002440 mTelecomCallId = callId;
2441 }
2442
2443 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002444 * Inform this Connection that the state of its audio output has been changed externally.
2445 *
2446 * @param state The new audio state.
Sailesh Nepal400cc482014-06-26 12:04:00 -07002447 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -07002448 */
Yorke Lee4af59352015-05-13 14:14:54 -07002449 final void setCallAudioState(CallAudioState state) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002450 checkImmutable();
Ihab Awad60ac30b2014-05-20 22:32:12 -07002451 Log.d(this, "setAudioState %s", state);
Yorke Lee4af59352015-05-13 14:14:54 -07002452 mCallAudioState = state;
2453 onAudioStateChanged(getAudioState());
2454 onCallAudioStateChanged(state);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002455 }
2456
2457 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002458 * @param state An integer value of a {@code STATE_*} constant.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002459 * @return A string representation of the value.
2460 */
2461 public static String stateToString(int state) {
2462 switch (state) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002463 case STATE_INITIALIZING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002464 return "INITIALIZING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002465 case STATE_NEW:
Yorke Leee911c8d2015-07-14 11:39:36 -07002466 return "NEW";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002467 case STATE_RINGING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002468 return "RINGING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002469 case STATE_DIALING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002470 return "DIALING";
Tyler Gunnc96b5e02016-07-07 22:53:57 -07002471 case STATE_PULLING_CALL:
2472 return "PULLING_CALL";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002473 case STATE_ACTIVE:
Yorke Leee911c8d2015-07-14 11:39:36 -07002474 return "ACTIVE";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002475 case STATE_HOLDING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002476 return "HOLDING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002477 case STATE_DISCONNECTED:
Ihab Awad542e0ea2014-05-16 10:22:16 -07002478 return "DISCONNECTED";
2479 default:
Ihab Awad60ac30b2014-05-20 22:32:12 -07002480 Log.wtf(Connection.class, "Unknown state %d", state);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002481 return "UNKNOWN";
2482 }
2483 }
2484
2485 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002486 * Returns the connection's capabilities, as a bit mask of the {@code CAPABILITY_*} constants.
Ihab Awad52a28f62014-06-18 10:26:34 -07002487 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002488 public final int getConnectionCapabilities() {
2489 return mConnectionCapabilities;
Ihab Awad52a28f62014-06-18 10:26:34 -07002490 }
2491
2492 /**
Tyler Gunn720c6642016-03-22 09:02:47 -07002493 * Returns the connection's properties, as a bit mask of the {@code PROPERTY_*} constants.
2494 */
2495 public final int getConnectionProperties() {
2496 return mConnectionProperties;
2497 }
2498
2499 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002500 * Returns the connection's supported audio routes.
2501 *
2502 * @hide
2503 */
2504 public final int getSupportedAudioRoutes() {
2505 return mSupportedAudioRoutes;
2506 }
2507
2508 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002509 * Sets the value of the {@link #getAddress()} property.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002510 *
Andrew Lee100e2932014-09-08 15:34:24 -07002511 * @param address The new address.
2512 * @param presentation The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002513 * See {@link TelecomManager} for valid values.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002514 */
Andrew Lee100e2932014-09-08 15:34:24 -07002515 public final void setAddress(Uri address, int presentation) {
2516 Log.d(this, "setAddress %s", address);
2517 mAddress = address;
2518 mAddressPresentation = presentation;
Santos Cordond34e5712014-08-05 18:54:03 +00002519 for (Listener l : mListeners) {
Andrew Lee100e2932014-09-08 15:34:24 -07002520 l.onAddressChanged(this, address, presentation);
Santos Cordond34e5712014-08-05 18:54:03 +00002521 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002522 }
2523
2524 /**
Sailesh Nepal61203862014-07-11 14:50:13 -07002525 * Sets the caller display name (CNAP).
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002526 *
Sailesh Nepal61203862014-07-11 14:50:13 -07002527 * @param callerDisplayName The new display name.
Nancy Chen9d568c02014-09-08 14:17:59 -07002528 * @param presentation The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002529 * See {@link TelecomManager} for valid values.
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002530 */
Sailesh Nepal61203862014-07-11 14:50:13 -07002531 public final void setCallerDisplayName(String callerDisplayName, int presentation) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002532 checkImmutable();
Sailesh Nepal61203862014-07-11 14:50:13 -07002533 Log.d(this, "setCallerDisplayName %s", callerDisplayName);
Santos Cordond34e5712014-08-05 18:54:03 +00002534 mCallerDisplayName = callerDisplayName;
2535 mCallerDisplayNamePresentation = presentation;
2536 for (Listener l : mListeners) {
2537 l.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
2538 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002539 }
2540
2541 /**
Tyler Gunnaa07df82014-07-17 07:50:22 -07002542 * Set the video state for the connection.
Yorke Lee32f24732015-05-12 16:18:03 -07002543 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
2544 * {@link VideoProfile#STATE_BIDIRECTIONAL},
2545 * {@link VideoProfile#STATE_TX_ENABLED},
2546 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002547 *
2548 * @param videoState The new video state.
2549 */
2550 public final void setVideoState(int videoState) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002551 checkImmutable();
Tyler Gunnaa07df82014-07-17 07:50:22 -07002552 Log.d(this, "setVideoState %d", videoState);
Santos Cordond34e5712014-08-05 18:54:03 +00002553 mVideoState = videoState;
2554 for (Listener l : mListeners) {
2555 l.onVideoStateChanged(this, mVideoState);
2556 }
Tyler Gunnaa07df82014-07-17 07:50:22 -07002557 }
2558
2559 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002560 * Sets state to active (e.g., an ongoing connection where two or more parties can actively
Ihab Awad542e0ea2014-05-16 10:22:16 -07002561 * communicate).
2562 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002563 public final void setActive() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002564 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002565 setRingbackRequested(false);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002566 setState(STATE_ACTIVE);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002567 }
2568
2569 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002570 * Sets state to ringing (e.g., an inbound ringing connection).
Ihab Awad542e0ea2014-05-16 10:22:16 -07002571 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002572 public final void setRinging() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002573 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002574 setState(STATE_RINGING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002575 }
2576
2577 /**
Evan Charltonbf11f982014-07-20 22:06:28 -07002578 * Sets state to initializing (this Connection is not yet ready to be used).
2579 */
2580 public final void setInitializing() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002581 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002582 setState(STATE_INITIALIZING);
Evan Charltonbf11f982014-07-20 22:06:28 -07002583 }
2584
2585 /**
2586 * Sets state to initialized (the Connection has been set up and is now ready to be used).
2587 */
2588 public final void setInitialized() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002589 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002590 setState(STATE_NEW);
Evan Charltonbf11f982014-07-20 22:06:28 -07002591 }
2592
2593 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002594 * Sets state to dialing (e.g., dialing an outbound connection).
Ihab Awad542e0ea2014-05-16 10:22:16 -07002595 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002596 public final void setDialing() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002597 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002598 setState(STATE_DIALING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002599 }
2600
2601 /**
Tyler Gunnc242ceb2016-06-29 22:35:45 -07002602 * Sets state to pulling (e.g. the connection is being pulled to the local device from another
2603 * device). Only applicable for {@link Connection}s with
2604 * {@link Connection#PROPERTY_IS_EXTERNAL_CALL} and {@link Connection#CAPABILITY_CAN_PULL_CALL}.
2605 */
2606 public final void setPulling() {
2607 checkImmutable();
2608 setState(STATE_PULLING_CALL);
2609 }
2610
2611 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002612 * Sets state to be on hold.
2613 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002614 public final void setOnHold() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002615 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002616 setState(STATE_HOLDING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002617 }
2618
2619 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002620 * Sets the video connection provider.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002621 * @param videoProvider The video provider.
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002622 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002623 public final void setVideoProvider(VideoProvider videoProvider) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002624 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002625 mVideoProvider = videoProvider;
Santos Cordond34e5712014-08-05 18:54:03 +00002626 for (Listener l : mListeners) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002627 l.onVideoProviderChanged(this, videoProvider);
Santos Cordond34e5712014-08-05 18:54:03 +00002628 }
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002629 }
2630
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002631 public final VideoProvider getVideoProvider() {
2632 return mVideoProvider;
Andrew Leea27a1932014-07-09 17:07:13 -07002633 }
2634
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002635 /**
Sailesh Nepal091768c2014-06-30 15:15:23 -07002636 * Sets state to disconnected.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002637 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002638 * @param disconnectCause The reason for the disconnection, as specified by
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002639 * {@link DisconnectCause}.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002640 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002641 public final void setDisconnected(DisconnectCause disconnectCause) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002642 checkImmutable();
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002643 mDisconnectCause = disconnectCause;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002644 setState(STATE_DISCONNECTED);
mike dooleyf34519b2014-09-16 17:33:40 -07002645 Log.d(this, "Disconnected with cause %s", disconnectCause);
Santos Cordond34e5712014-08-05 18:54:03 +00002646 for (Listener l : mListeners) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002647 l.onDisconnected(this, disconnectCause);
Santos Cordond34e5712014-08-05 18:54:03 +00002648 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002649 }
2650
2651 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002652 * Informs listeners that this {@code Connection} is in a post-dial wait state. This is done
2653 * when (a) the {@code Connection} is issuing a DTMF sequence; (b) it has encountered a "wait"
2654 * character; and (c) it wishes to inform the In-Call app that it is waiting for the end-user
2655 * to send an {@link #onPostDialContinue(boolean)} signal.
2656 *
2657 * @param remaining The DTMF character sequence remaining to be emitted once the
2658 * {@link #onPostDialContinue(boolean)} is received, including any "wait" characters
2659 * that remaining sequence may contain.
Sailesh Nepal091768c2014-06-30 15:15:23 -07002660 */
2661 public final void setPostDialWait(String remaining) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002662 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002663 for (Listener l : mListeners) {
2664 l.onPostDialWait(this, remaining);
2665 }
Sailesh Nepal091768c2014-06-30 15:15:23 -07002666 }
2667
2668 /**
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002669 * Informs listeners that this {@code Connection} has processed a character in the post-dial
2670 * started state. This is done when (a) the {@code Connection} is issuing a DTMF sequence;
Sailesh Nepal1ed85612015-01-31 15:17:19 -08002671 * and (b) it wishes to signal Telecom to play the corresponding DTMF tone locally.
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002672 *
2673 * @param nextChar The DTMF character that was just processed by the {@code Connection}.
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002674 */
Sailesh Nepal1ed85612015-01-31 15:17:19 -08002675 public final void setNextPostDialChar(char nextChar) {
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002676 checkImmutable();
2677 for (Listener l : mListeners) {
2678 l.onPostDialChar(this, nextChar);
2679 }
2680 }
2681
2682 /**
Ihab Awadf8358972014-05-28 16:46:42 -07002683 * Requests that the framework play a ringback tone. This is to be invoked by implementations
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002684 * that do not play a ringback tone themselves in the connection's audio stream.
Ihab Awadf8358972014-05-28 16:46:42 -07002685 *
2686 * @param ringback Whether the ringback tone is to be played.
2687 */
Andrew Lee100e2932014-09-08 15:34:24 -07002688 public final void setRingbackRequested(boolean ringback) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002689 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002690 if (mRingbackRequested != ringback) {
2691 mRingbackRequested = ringback;
Santos Cordond34e5712014-08-05 18:54:03 +00002692 for (Listener l : mListeners) {
Andrew Lee100e2932014-09-08 15:34:24 -07002693 l.onRingbackRequested(this, ringback);
Santos Cordond34e5712014-08-05 18:54:03 +00002694 }
2695 }
Ihab Awadf8358972014-05-28 16:46:42 -07002696 }
2697
2698 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002699 * Sets the connection's capabilities as a bit mask of the {@code CAPABILITY_*} constants.
Sailesh Nepal1a7061b2014-07-09 21:03:20 -07002700 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002701 * @param connectionCapabilities The new connection capabilities.
Santos Cordonb6939982014-06-04 20:20:58 -07002702 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002703 public final void setConnectionCapabilities(int connectionCapabilities) {
2704 checkImmutable();
2705 if (mConnectionCapabilities != connectionCapabilities) {
2706 mConnectionCapabilities = connectionCapabilities;
Santos Cordond34e5712014-08-05 18:54:03 +00002707 for (Listener l : mListeners) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002708 l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities);
Santos Cordond34e5712014-08-05 18:54:03 +00002709 }
2710 }
Santos Cordonb6939982014-06-04 20:20:58 -07002711 }
2712
2713 /**
Tyler Gunn720c6642016-03-22 09:02:47 -07002714 * Sets the connection's properties as a bit mask of the {@code PROPERTY_*} constants.
2715 *
2716 * @param connectionProperties The new connection properties.
2717 */
2718 public final void setConnectionProperties(int connectionProperties) {
2719 checkImmutable();
2720 if (mConnectionProperties != connectionProperties) {
2721 mConnectionProperties = connectionProperties;
2722 for (Listener l : mListeners) {
2723 l.onConnectionPropertiesChanged(this, mConnectionProperties);
2724 }
2725 }
2726 }
2727
2728 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002729 * Sets the supported audio routes.
2730 *
2731 * @param supportedAudioRoutes the supported audio routes as a bitmask.
2732 * See {@link CallAudioState}
2733 * @hide
2734 */
2735 public final void setSupportedAudioRoutes(int supportedAudioRoutes) {
2736 if ((supportedAudioRoutes
2737 & (CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_SPEAKER)) == 0) {
2738 throw new IllegalArgumentException(
2739 "supported audio routes must include either speaker or earpiece");
2740 }
2741
2742 if (mSupportedAudioRoutes != supportedAudioRoutes) {
2743 mSupportedAudioRoutes = supportedAudioRoutes;
2744 for (Listener l : mListeners) {
2745 l.onSupportedAudioRoutesChanged(this, mSupportedAudioRoutes);
2746 }
2747 }
2748 }
2749
2750 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002751 * Tears down the Connection object.
Santos Cordonb6939982014-06-04 20:20:58 -07002752 */
Evan Charlton36a71342014-07-19 16:31:02 -07002753 public final void destroy() {
Jay Shrauner229e3822014-08-15 09:23:07 -07002754 for (Listener l : mListeners) {
2755 l.onDestroyed(this);
Santos Cordond34e5712014-08-05 18:54:03 +00002756 }
Santos Cordonb6939982014-06-04 20:20:58 -07002757 }
2758
2759 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002760 * Requests that the framework use VOIP audio mode for this connection.
2761 *
2762 * @param isVoip True if the audio mode is VOIP.
2763 */
2764 public final void setAudioModeIsVoip(boolean isVoip) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002765 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002766 mAudioModeIsVoip = isVoip;
2767 for (Listener l : mListeners) {
2768 l.onAudioModeIsVoipChanged(this, isVoip);
2769 }
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002770 }
2771
2772 /**
Roshan Piuse927ec02015-07-15 15:47:21 -07002773 * Sets the time at which a call became active on this Connection. This is set only
2774 * when a conference call becomes active on this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002775 * <p>
Tyler Gunnc9503d62020-01-27 10:30:51 -08002776 * This time corresponds to the date/time of connection and is stored in the call log in
2777 * {@link android.provider.CallLog.Calls#DATE}.
2778 * <p>
Tyler Gunnc63f9082019-10-15 13:19:26 -07002779 * Used by telephony to maintain calls associated with an IMS Conference.
Roshan Piuse927ec02015-07-15 15:47:21 -07002780 *
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002781 * @param connectTimeMillis The connection time, in milliseconds. Should be set using a value
2782 * obtained from {@link System#currentTimeMillis()}.
Roshan Piuse927ec02015-07-15 15:47:21 -07002783 *
2784 * @hide
2785 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002786 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002787 @RequiresPermission(MODIFY_PHONE_STATE)
2788 public final void setConnectTimeMillis(@IntRange(from = 0) long connectTimeMillis) {
Roshan Piuse927ec02015-07-15 15:47:21 -07002789 mConnectTimeMillis = connectTimeMillis;
2790 }
2791
2792 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002793 * Sets the time at which a call became active on this Connection. This is set only
2794 * when a conference call becomes active on this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002795 * <p>
Tyler Gunnc9503d62020-01-27 10:30:51 -08002796 * This time is used to establish the duration of a call. It uses
2797 * {@link SystemClock#elapsedRealtime()} to ensure that the call duration is not impacted by
2798 * time zone changes during a call. The difference between the current
2799 * {@link SystemClock#elapsedRealtime()} and the value set at the connection start time is used
2800 * to populate {@link android.provider.CallLog.Calls#DURATION} in the call log.
2801 * <p>
Tyler Gunnc63f9082019-10-15 13:19:26 -07002802 * Used by telephony to maintain calls associated with an IMS Conference.
Tyler Gunnc9503d62020-01-27 10:30:51 -08002803 *
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002804 * @param connectElapsedTimeMillis The connection time, in milliseconds. Stored in the format
2805 * {@link SystemClock#elapsedRealtime()}.
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002806 * @hide
2807 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002808 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002809 @RequiresPermission(MODIFY_PHONE_STATE)
2810 public final void setConnectionStartElapsedRealtimeMillis(
2811 @ElapsedRealtimeLong long connectElapsedTimeMillis) {
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002812 mConnectElapsedTimeMillis = connectElapsedTimeMillis;
2813 }
2814
2815 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002816 * Sets the label and icon status to display in the in-call UI.
2817 *
2818 * @param statusHints The status label and icon to set.
2819 */
2820 public final void setStatusHints(StatusHints statusHints) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002821 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002822 mStatusHints = statusHints;
2823 for (Listener l : mListeners) {
2824 l.onStatusHintsChanged(this, statusHints);
2825 }
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002826 }
2827
2828 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002829 * Sets the connections with which this connection can be conferenced.
2830 *
2831 * @param conferenceableConnections The set of connections this connection can conference with.
2832 */
2833 public final void setConferenceableConnections(List<Connection> conferenceableConnections) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002834 checkImmutable();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002835 clearConferenceableList();
2836 for (Connection c : conferenceableConnections) {
2837 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
2838 // small amount of items here.
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002839 if (!mConferenceables.contains(c)) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002840 c.addConnectionListener(mConnectionDeathListener);
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002841 mConferenceables.add(c);
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002842 }
2843 }
2844 fireOnConferenceableConnectionsChanged();
2845 }
2846
2847 /**
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002848 * Similar to {@link #setConferenceableConnections(java.util.List)}, sets a list of connections
2849 * or conferences with which this connection can be conferenced.
2850 *
2851 * @param conferenceables The conferenceables.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002852 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002853 public final void setConferenceables(List<Conferenceable> conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002854 clearConferenceableList();
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002855 for (Conferenceable c : conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002856 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
2857 // small amount of items here.
2858 if (!mConferenceables.contains(c)) {
2859 if (c instanceof Connection) {
2860 Connection connection = (Connection) c;
2861 connection.addConnectionListener(mConnectionDeathListener);
2862 } else if (c instanceof Conference) {
2863 Conference conference = (Conference) c;
2864 conference.addListener(mConferenceDeathListener);
2865 }
2866 mConferenceables.add(c);
2867 }
2868 }
2869 fireOnConferenceableConnectionsChanged();
2870 }
2871
2872 /**
Tyler Gunnc63f9082019-10-15 13:19:26 -07002873 * Resets the CDMA connection time.
2874 * <p>
2875 * This is an implementation detail specific to legacy CDMA calls on mobile networks.
Mengjun Leng25707742017-07-04 11:10:37 +08002876 * @hide
Mengjun Leng25707742017-07-04 11:10:37 +08002877 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002878 @SystemApi
Mengjun Leng25707742017-07-04 11:10:37 +08002879 public final void resetConnectionTime() {
2880 for (Listener l : mListeners) {
2881 l.onConnectionTimeReset(this);
2882 }
2883 }
2884
2885 /**
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002886 * Returns the connections or conferences with which this connection can be conferenced.
2887 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002888 public final List<Conferenceable> getConferenceables() {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002889 return mUnmodifiableConferenceables;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002890 }
2891
Yorke Lee53463962015-08-04 16:07:19 -07002892 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002893 * @hide
2894 */
2895 public final void setConnectionService(ConnectionService connectionService) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002896 checkImmutable();
Santos Cordon823fd3c2014-08-07 18:35:18 -07002897 if (mConnectionService != null) {
2898 Log.e(this, new Exception(), "Trying to set ConnectionService on a connection " +
2899 "which is already associated with another ConnectionService.");
2900 } else {
2901 mConnectionService = connectionService;
2902 }
2903 }
2904
2905 /**
2906 * @hide
2907 */
2908 public final void unsetConnectionService(ConnectionService connectionService) {
2909 if (mConnectionService != connectionService) {
2910 Log.e(this, new Exception(), "Trying to remove ConnectionService from a Connection " +
2911 "that does not belong to the ConnectionService.");
2912 } else {
2913 mConnectionService = null;
2914 }
2915 }
2916
2917 /**
2918 * Sets the conference that this connection is a part of. This will fail if the connection is
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002919 * already part of a conference. {@link #resetConference} to un-set the conference first.
Santos Cordon823fd3c2014-08-07 18:35:18 -07002920 *
2921 * @param conference The conference.
2922 * @return {@code true} if the conference was successfully set.
2923 * @hide
2924 */
2925 public final boolean setConference(Conference conference) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002926 checkImmutable();
Santos Cordon823fd3c2014-08-07 18:35:18 -07002927 // We check to see if it is already part of another conference.
Santos Cordon0159ac02014-08-21 14:28:11 -07002928 if (mConference == null) {
Santos Cordon823fd3c2014-08-07 18:35:18 -07002929 mConference = conference;
Santos Cordon0159ac02014-08-21 14:28:11 -07002930 if (mConnectionService != null && mConnectionService.containsConference(conference)) {
2931 fireConferenceChanged();
2932 }
Santos Cordon823fd3c2014-08-07 18:35:18 -07002933 return true;
2934 }
2935 return false;
2936 }
2937
2938 /**
2939 * Resets the conference that this connection is a part of.
2940 * @hide
2941 */
2942 public final void resetConference() {
2943 if (mConference != null) {
Santos Cordon0159ac02014-08-21 14:28:11 -07002944 Log.d(this, "Conference reset");
Santos Cordon823fd3c2014-08-07 18:35:18 -07002945 mConference = null;
2946 fireConferenceChanged();
2947 }
2948 }
2949
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002950 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002951 * Set some extras that can be associated with this {@code Connection}.
2952 * <p>
2953 * New or existing keys are replaced in the {@code Connection} extras. Keys which are no longer
2954 * in the new extras, but were present the last time {@code setExtras} was called are removed.
2955 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07002956 * Alternatively you may use the {@link #putExtras(Bundle)}, and
2957 * {@link #removeExtras(String...)} methods to modify the extras.
2958 * <p>
Tyler Gunndee56a82016-03-23 16:06:34 -07002959 * 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 -07002960 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
2961 *
2962 * @param extras The extras associated with this {@code Connection}.
2963 */
2964 public final void setExtras(@Nullable Bundle extras) {
2965 checkImmutable();
Tyler Gunndee56a82016-03-23 16:06:34 -07002966
2967 // Add/replace any new or changed extras values.
2968 putExtras(extras);
2969
2970 // If we have used "setExtras" in the past, compare the key set from the last invocation to
2971 // the current one and remove any keys that went away.
2972 if (mPreviousExtraKeys != null) {
2973 List<String> toRemove = new ArrayList<String>();
2974 for (String oldKey : mPreviousExtraKeys) {
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07002975 if (extras == null || !extras.containsKey(oldKey)) {
Tyler Gunndee56a82016-03-23 16:06:34 -07002976 toRemove.add(oldKey);
2977 }
2978 }
2979 if (!toRemove.isEmpty()) {
2980 removeExtras(toRemove);
2981 }
2982 }
2983
2984 // Track the keys the last time set called setExtras. This way, the next time setExtras is
2985 // called we can see if the caller has removed any extras values.
2986 if (mPreviousExtraKeys == null) {
2987 mPreviousExtraKeys = new ArraySet<String>();
2988 }
2989 mPreviousExtraKeys.clear();
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07002990 if (extras != null) {
2991 mPreviousExtraKeys.addAll(extras.keySet());
2992 }
Tyler Gunndee56a82016-03-23 16:06:34 -07002993 }
2994
2995 /**
2996 * Adds some extras to this {@code Connection}. Existing keys are replaced and new ones are
2997 * added.
2998 * <p>
2999 * No assumptions should be made as to how an In-Call UI or service will handle these extras.
3000 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
3001 *
3002 * @param extras The extras to add.
3003 */
3004 public final void putExtras(@NonNull Bundle extras) {
3005 checkImmutable();
3006 if (extras == null) {
3007 return;
3008 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003009 // Creating a duplicate bundle so we don't have to synchronize on mExtrasLock while calling
3010 // the listeners.
3011 Bundle listenerExtras;
3012 synchronized (mExtrasLock) {
3013 if (mExtras == null) {
3014 mExtras = new Bundle();
3015 }
3016 mExtras.putAll(extras);
3017 listenerExtras = new Bundle(mExtras);
Tyler Gunndee56a82016-03-23 16:06:34 -07003018 }
Santos Cordon6b7f9552015-05-27 17:21:45 -07003019 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003020 // Create a new clone of the extras for each listener so that they don't clobber
3021 // each other
3022 l.onExtrasChanged(this, new Bundle(listenerExtras));
Santos Cordon6b7f9552015-05-27 17:21:45 -07003023 }
3024 }
3025
3026 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -07003027 * Removes extras from this {@code Connection}.
Tyler Gunndee56a82016-03-23 16:06:34 -07003028 *
Tyler Gunn071be6f2016-05-10 14:52:33 -07003029 * @param keys The keys of the extras to remove.
Tyler Gunndee56a82016-03-23 16:06:34 -07003030 */
3031 public final void removeExtras(List<String> keys) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003032 synchronized (mExtrasLock) {
3033 if (mExtras != null) {
3034 for (String key : keys) {
3035 mExtras.remove(key);
3036 }
Tyler Gunndee56a82016-03-23 16:06:34 -07003037 }
3038 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003039 List<String> unmodifiableKeys = Collections.unmodifiableList(keys);
Tyler Gunndee56a82016-03-23 16:06:34 -07003040 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003041 l.onExtrasRemoved(this, unmodifiableKeys);
Tyler Gunndee56a82016-03-23 16:06:34 -07003042 }
3043 }
3044
3045 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -07003046 * Removes extras from this {@code Connection}.
3047 *
3048 * @param keys The keys of the extras to remove.
3049 */
3050 public final void removeExtras(String ... keys) {
3051 removeExtras(Arrays.asList(keys));
3052 }
3053
3054 /**
Tyler Gunnf5035432017-01-09 09:43:12 -08003055 * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will
3056 * be change to the {@link #getCallAudioState()}.
3057 * <p>
3058 * Used by self-managed {@link ConnectionService}s which wish to change the audio route for a
3059 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
3060 * <p>
3061 * See also {@link InCallService#setAudioRoute(int)}.
3062 *
3063 * @param route The audio route to use (one of {@link CallAudioState#ROUTE_BLUETOOTH},
3064 * {@link CallAudioState#ROUTE_EARPIECE}, {@link CallAudioState#ROUTE_SPEAKER}, or
3065 * {@link CallAudioState#ROUTE_WIRED_HEADSET}).
3066 */
3067 public final void setAudioRoute(int route) {
3068 for (Listener l : mListeners) {
Hall Liua98f58b52017-11-07 17:59:28 -08003069 l.onAudioRouteChanged(this, route, null);
3070 }
3071 }
3072
3073 /**
Hall Liua98f58b52017-11-07 17:59:28 -08003074 * Request audio routing to a specific bluetooth device. Calling this method may result in
3075 * the device routing audio to a different bluetooth device than the one specified if the
3076 * bluetooth stack is unable to route audio to the requested device.
3077 * A list of available devices can be obtained via
3078 * {@link CallAudioState#getSupportedBluetoothDevices()}
3079 *
3080 * <p>
3081 * Used by self-managed {@link ConnectionService}s which wish to use bluetooth audio for a
3082 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
3083 * <p>
Hall Liu2b6a6a32018-04-02 13:52:57 -07003084 * See also {@link InCallService#requestBluetoothAudio(BluetoothDevice)}
3085 * @param bluetoothDevice The bluetooth device to connect to.
Hall Liua98f58b52017-11-07 17:59:28 -08003086 */
Hall Liu2b6a6a32018-04-02 13:52:57 -07003087 public void requestBluetoothAudio(@NonNull BluetoothDevice bluetoothDevice) {
Hall Liua98f58b52017-11-07 17:59:28 -08003088 for (Listener l : mListeners) {
Hall Liu2b6a6a32018-04-02 13:52:57 -07003089 l.onAudioRouteChanged(this, CallAudioState.ROUTE_BLUETOOTH,
3090 bluetoothDevice.getAddress());
Tyler Gunnf5035432017-01-09 09:43:12 -08003091 }
3092 }
3093
3094 /**
Hall Liub64ac4c2017-02-06 10:49:48 -08003095 * Informs listeners that a previously requested RTT session via
3096 * {@link ConnectionRequest#isRequestingRtt()} or
Hall Liu37dfdb02017-12-04 14:19:30 -08003097 * {@link #onStartRtt(RttTextStream)} has succeeded.
Hall Liub64ac4c2017-02-06 10:49:48 -08003098 */
3099 public final void sendRttInitiationSuccess() {
3100 mListeners.forEach((l) -> l.onRttInitiationSuccess(Connection.this));
3101 }
3102
3103 /**
3104 * Informs listeners that a previously requested RTT session via
Hall Liu37dfdb02017-12-04 14:19:30 -08003105 * {@link ConnectionRequest#isRequestingRtt()} or {@link #onStartRtt(RttTextStream)}
Hall Liub64ac4c2017-02-06 10:49:48 -08003106 * has failed.
3107 * @param reason One of the reason codes defined in {@link RttModifyStatus}, with the
3108 * exception of {@link RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}.
Hall Liub64ac4c2017-02-06 10:49:48 -08003109 */
3110 public final void sendRttInitiationFailure(int reason) {
3111 mListeners.forEach((l) -> l.onRttInitiationFailure(Connection.this, reason));
3112 }
3113
3114 /**
3115 * Informs listeners that a currently active RTT session has been terminated by the remote
3116 * side of the coll.
Hall Liub64ac4c2017-02-06 10:49:48 -08003117 */
3118 public final void sendRttSessionRemotelyTerminated() {
3119 mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this));
3120 }
3121
3122 /**
3123 * Informs listeners that the remote side of the call has requested an upgrade to include an
3124 * RTT session in the call.
Hall Liub64ac4c2017-02-06 10:49:48 -08003125 */
3126 public final void sendRemoteRttRequest() {
3127 mListeners.forEach((l) -> l.onRemoteRttRequest(Connection.this));
3128 }
3129
3130 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003131 * Notifies this Connection that the {@link #getAudioState()} property has a new value.
Sailesh Nepal400cc482014-06-26 12:04:00 -07003132 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003133 * @param state The new connection audio state.
Yorke Lee4af59352015-05-13 14:14:54 -07003134 * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead.
3135 * @hide
Sailesh Nepal400cc482014-06-26 12:04:00 -07003136 */
Yorke Lee4af59352015-05-13 14:14:54 -07003137 @SystemApi
3138 @Deprecated
Nancy Chen354b2bd2014-09-08 18:27:26 -07003139 public void onAudioStateChanged(AudioState state) {}
Sailesh Nepal400cc482014-06-26 12:04:00 -07003140
3141 /**
Yorke Lee4af59352015-05-13 14:14:54 -07003142 * Notifies this Connection that the {@link #getCallAudioState()} property has a new value.
3143 *
3144 * @param state The new connection audio state.
3145 */
3146 public void onCallAudioStateChanged(CallAudioState state) {}
3147
3148 /**
Grace Jiae99fde92021-01-19 14:58:01 -08003149 * Inform this Connection when it will or will not be tracked by an {@link InCallService} which
3150 * can provide an InCall UI.
3151 * This is primarily intended for use by Connections reported by self-managed
3152 * {@link ConnectionService} which typically maintain their own UI.
3153 *
3154 * @param isUsingAlternativeUi Indicates whether an InCallService that can provide InCall UI is
3155 * currently tracking the self-managed call.
3156 */
3157 public void onUsingAlternativeUi(boolean isUsingAlternativeUi) {}
3158
3159 /**
3160 * Inform this Conenection when it will or will not be tracked by an non-UI
3161 * {@link InCallService}.
3162 *
3163 * @param isTracked Indicates whether an non-UI InCallService is currently tracking the
3164 * self-managed call.
3165 */
3166 public void onTrackedByNonUiService(boolean isTracked) {}
3167
3168 /**
Evan Charltonbf11f982014-07-20 22:06:28 -07003169 * Notifies this Connection of an internal state change. This method is called after the
3170 * state is changed.
Ihab Awadf8358972014-05-28 16:46:42 -07003171 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003172 * @param state The new state, one of the {@code STATE_*} constants.
Ihab Awadf8358972014-05-28 16:46:42 -07003173 */
Nancy Chen354b2bd2014-09-08 18:27:26 -07003174 public void onStateChanged(int state) {}
Ihab Awadf8358972014-05-28 16:46:42 -07003175
3176 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07003177 * Notifies this Connection of a request to play a DTMF tone.
3178 *
3179 * @param c A DTMF character.
3180 */
Santos Cordonf2951102014-07-20 19:06:29 -07003181 public void onPlayDtmfTone(char c) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003182
3183 /**
3184 * Notifies this Connection of a request to stop any currently playing DTMF tones.
3185 */
Santos Cordonf2951102014-07-20 19:06:29 -07003186 public void onStopDtmfTone() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003187
3188 /**
3189 * Notifies this Connection of a request to disconnect.
3190 */
Santos Cordonf2951102014-07-20 19:06:29 -07003191 public void onDisconnect() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003192
3193 /**
Tyler Gunn3b4b1dc2014-11-04 14:53:37 -08003194 * Notifies this Connection of a request to disconnect a participant of the conference managed
3195 * by the connection.
3196 *
3197 * @param endpoint the {@link Uri} of the participant to disconnect.
3198 * @hide
3199 */
3200 public void onDisconnectConferenceParticipant(Uri endpoint) {}
3201
3202 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003203 * Notifies this Connection of a request to separate from its parent conference.
Santos Cordonb6939982014-06-04 20:20:58 -07003204 */
Santos Cordonf2951102014-07-20 19:06:29 -07003205 public void onSeparate() {}
Santos Cordonb6939982014-06-04 20:20:58 -07003206
3207 /**
Tyler Gunn0c62ef02020-02-11 14:39:43 -08003208 * Supports initiation of a conference call by directly adding participants to an ongoing call.
Ravi Paluri404babb2020-01-23 19:02:44 +05303209 *
3210 * @param participants with which conference call will be formed.
3211 */
3212 public void onAddConferenceParticipants(@NonNull List<Uri> participants) {}
3213
3214 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07003215 * Notifies this Connection of a request to abort.
3216 */
Santos Cordonf2951102014-07-20 19:06:29 -07003217 public void onAbort() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003218
3219 /**
3220 * Notifies this Connection of a request to hold.
3221 */
Santos Cordonf2951102014-07-20 19:06:29 -07003222 public void onHold() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003223
3224 /**
3225 * Notifies this Connection of a request to exit a hold state.
3226 */
Santos Cordonf2951102014-07-20 19:06:29 -07003227 public void onUnhold() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003228
3229 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003230 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Santos Cordond34e5712014-08-05 18:54:03 +00003231 * a request to accept.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003232 * <p>
3233 * For managed {@link ConnectionService}s, this will be called when the user answers a call via
3234 * the default dialer's {@link InCallService}.
3235 * <p>
3236 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3237 * Telecom framework may request that the call is answered in the following circumstances:
3238 * <ul>
3239 * <li>The user chooses to answer an incoming call via a Bluetooth device.</li>
3240 * <li>A car mode {@link InCallService} is in use which has declared
3241 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3242 * {@link InCallService} will be able to see calls from self-managed
3243 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3244 * behalf.</li>
3245 * </ul>
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003246 * @param videoState The video state in which to answer the connection.
Ihab Awad542e0ea2014-05-16 10:22:16 -07003247 */
Santos Cordonf2951102014-07-20 19:06:29 -07003248 public void onAnswer(int videoState) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003249
3250 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003251 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Tyler Gunnbe74de02014-08-29 14:51:48 -07003252 * a request to accept.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003253 * <p>
3254 * For managed {@link ConnectionService}s, this will be called when the user answers a call via
3255 * the default dialer's {@link InCallService}.
3256 * <p>
3257 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3258 * Telecom framework may request that the call is answered in the following circumstances:
3259 * <ul>
3260 * <li>The user chooses to answer an incoming call via a Bluetooth device.</li>
3261 * <li>A car mode {@link InCallService} is in use which has declared
3262 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3263 * {@link InCallService} will be able to see calls from self-managed
3264 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3265 * behalf.</li>
3266 * </ul>
Tyler Gunnbe74de02014-08-29 14:51:48 -07003267 */
3268 public void onAnswer() {
Tyler Gunn87b73f32015-06-03 10:09:59 -07003269 onAnswer(VideoProfile.STATE_AUDIO_ONLY);
Tyler Gunnbe74de02014-08-29 14:51:48 -07003270 }
3271
3272 /**
3273 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Pooja Jaind34698d2017-12-28 14:15:31 +05303274 * a request to deflect.
3275 */
3276 public void onDeflect(Uri address) {}
3277
3278 /**
3279 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Santos Cordond34e5712014-08-05 18:54:03 +00003280 * a request to reject.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003281 * <p>
3282 * For managed {@link ConnectionService}s, this will be called when the user rejects a call via
3283 * the default dialer's {@link InCallService}.
3284 * <p>
3285 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3286 * Telecom framework may request that the call is rejected in the following circumstances:
3287 * <ul>
3288 * <li>The user chooses to reject an incoming call via a Bluetooth device.</li>
3289 * <li>A car mode {@link InCallService} is in use which has declared
3290 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3291 * {@link InCallService} will be able to see calls from self-managed
3292 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3293 * behalf.</li>
3294 * </ul>
Ihab Awad542e0ea2014-05-16 10:22:16 -07003295 */
Santos Cordonf2951102014-07-20 19:06:29 -07003296 public void onReject() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003297
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003298 /**
Tyler Gunnfacfdee2020-01-23 13:10:37 -08003299 * Notifies this Connection, which is in {@link #STATE_RINGING}, of a request to reject.
3300 * <p>
3301 * For managed {@link ConnectionService}s, this will be called when the user rejects a call via
3302 * the default dialer's {@link InCallService} using {@link Call#reject(int)}.
3303 * @param rejectReason the reason the user provided for rejecting the call.
3304 */
3305 public void onReject(@android.telecom.Call.RejectReason int rejectReason) {
3306 // to be implemented by ConnectionService.
3307 }
3308
3309 /**
Hall Liu712acbe2016-03-14 16:38:56 -07003310 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
3311 * a request to reject with a message.
Bryce Lee81901682015-08-28 16:38:02 -07003312 */
3313 public void onReject(String replyMessage) {}
3314
3315 /**
Ravi Palurif4b38e72020-02-05 12:35:41 +05303316 * Notifies this Connection, a request to transfer to a target number.
3317 * @param number the number to transfer this {@link Connection} to.
3318 * @param isConfirmationRequired when {@code true}, the {@link ConnectionService}
3319 * should wait until the transfer has successfully completed before disconnecting
3320 * the current {@link Connection}.
3321 * When {@code false}, the {@link ConnectionService} should signal the network to
3322 * perform the transfer, but should immediately disconnect the call regardless of
3323 * the outcome of the transfer.
3324 * @hide
3325 */
3326 public void onTransfer(@NonNull Uri number, boolean isConfirmationRequired) {}
3327
3328 /**
3329 * Notifies this Connection, a request to transfer to another Connection.
3330 * @param otherConnection the {@link Connection} to transfer this call to.
3331 * @hide
3332 */
3333 public void onTransfer(@NonNull Connection otherConnection) {}
3334
3335 /**
Tyler Gunn06f06162018-06-18 11:24:15 -07003336 * Notifies this Connection of a request to silence the ringer.
3337 * <p>
3338 * The ringer may be silenced by any of the following methods:
3339 * <ul>
3340 * <li>{@link TelecomManager#silenceRinger()}</li>
3341 * <li>The user presses the volume-down button while a call is ringing.</li>
3342 * </ul>
3343 * <p>
3344 * Self-managed {@link ConnectionService} implementations should override this method in their
3345 * {@link Connection} implementation and implement logic to silence their app's ringtone. If
3346 * your app set the ringtone as part of the incoming call {@link Notification} (see
3347 * {@link #onShowIncomingCallUi()}), it should re-post the notification now, except call
3348 * {@link android.app.Notification.Builder#setOnlyAlertOnce(boolean)} with {@code true}. This
3349 * will ensure the ringtone sound associated with your {@link android.app.NotificationChannel}
3350 * stops playing.
Bryce Leecac50772015-11-17 15:13:29 -08003351 */
3352 public void onSilence() {}
3353
3354 /**
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003355 * Notifies this Connection whether the user wishes to proceed with the post-dial DTMF codes.
3356 */
Santos Cordonf2951102014-07-20 19:06:29 -07003357 public void onPostDialContinue(boolean proceed) {}
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003358
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003359 /**
3360 * Notifies this Connection of a request to pull an external call to the local device.
3361 * <p>
3362 * The {@link InCallService} issues a request to pull an external call to the local device via
3363 * {@link Call#pullExternalCall()}.
3364 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -07003365 * For a Connection to be pulled, both the {@link Connection#CAPABILITY_CAN_PULL_CALL}
3366 * capability and {@link Connection#PROPERTY_IS_EXTERNAL_CALL} property bits must be set.
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003367 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -07003368 * For more information on external calls, see {@link Connection#PROPERTY_IS_EXTERNAL_CALL}.
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003369 */
3370 public void onPullExternalCall() {}
3371
3372 /**
3373 * Notifies this Connection of a {@link Call} event initiated from an {@link InCallService}.
3374 * <p>
3375 * The {@link InCallService} issues a Call event via {@link Call#sendCallEvent(String, Bundle)}.
3376 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003377 * Where possible, the Connection should make an attempt to handle {@link Call} events which
3378 * are part of the {@code android.telecom.*} namespace. The Connection should ignore any events
3379 * it does not wish to handle. Unexpected events should be handled gracefully, as it is
3380 * possible that a {@link InCallService} has defined its own Call events which a Connection is
3381 * not aware of.
3382 * <p>
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003383 * See also {@link Call#sendCallEvent(String, Bundle)}.
3384 *
3385 * @param event The call event.
3386 * @param extras Extras associated with the call event.
3387 */
3388 public void onCallEvent(String event, Bundle extras) {}
3389
Tyler Gunndee56a82016-03-23 16:06:34 -07003390 /**
Tyler Gunn79bc1ec2018-01-22 15:17:54 -08003391 * Notifies this {@link Connection} that a handover has completed.
3392 * <p>
3393 * A handover is initiated with {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int,
3394 * Bundle)} on the initiating side of the handover, and
3395 * {@link TelecomManager#acceptHandover(Uri, int, PhoneAccountHandle)}.
3396 */
3397 public void onHandoverComplete() {}
3398
3399 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07003400 * Notifies this {@link Connection} of a change to the extras made outside the
3401 * {@link ConnectionService}.
3402 * <p>
3403 * These extras changes can originate from Telecom itself, or from an {@link InCallService} via
3404 * the {@link android.telecom.Call#putExtras(Bundle)} and
3405 * {@link Call#removeExtras(List)}.
3406 *
3407 * @param extras The new extras bundle.
3408 */
3409 public void onExtrasChanged(Bundle extras) {}
3410
Tyler Gunnf5035432017-01-09 09:43:12 -08003411 /**
3412 * Notifies this {@link Connection} that its {@link ConnectionService} is responsible for
3413 * displaying its incoming call user interface for the {@link Connection}.
3414 * <p>
3415 * Will only be called for incoming calls added via a self-managed {@link ConnectionService}
3416 * (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}), where the {@link ConnectionService}
3417 * should show its own incoming call user interface.
3418 * <p>
3419 * Where there are ongoing calls in other self-managed {@link ConnectionService}s, or in a
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003420 * regular {@link ConnectionService}, and it is not possible to hold these other calls, the
3421 * Telecom framework will display its own incoming call user interface to allow the user to
3422 * choose whether to answer the new incoming call and disconnect other ongoing calls, or to
3423 * reject the new incoming call.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003424 * <p>
3425 * You should trigger the display of the incoming call user interface for your application by
3426 * showing a {@link Notification} with a full-screen {@link Intent} specified.
Tyler Gunn06f06162018-06-18 11:24:15 -07003427 *
3428 * In your application code, you should create a {@link android.app.NotificationChannel} for
3429 * incoming call notifications from your app:
3430 * <pre><code>
3431 * NotificationChannel channel = new NotificationChannel(YOUR_CHANNEL_ID, "Incoming Calls",
3432 * NotificationManager.IMPORTANCE_MAX);
3433 * // other channel setup stuff goes here.
3434 *
3435 * // We'll use the default system ringtone for our incoming call notification channel. You can
3436 * // use your own audio resource here.
3437 * Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
3438 * channel.setSound(ringtoneUri, new AudioAttributes.Builder()
3439 * // Setting the AudioAttributes is important as it identifies the purpose of your
3440 * // notification sound.
3441 * .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
3442 * .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
3443 * .build());
3444 *
3445 * NotificationManager mgr = getSystemService(NotificationManager.class);
3446 * mgr.createNotificationChannel(channel);
3447 * </code></pre>
3448 * When it comes time to post a notification for your incoming call, ensure it uses your
3449 * incoming call {@link android.app.NotificationChannel}.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003450 * <pre><code>
3451 * // Create an intent which triggers your fullscreen incoming call user interface.
3452 * Intent intent = new Intent(Intent.ACTION_MAIN, null);
3453 * intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_ACTIVITY_NEW_TASK);
3454 * intent.setClass(context, YourIncomingCallActivity.class);
Ashwini Orugantif8191e82021-01-07 12:04:25 -08003455 * PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_MUTABLE_UNAUDITED);
Tyler Gunn159f35c2017-03-02 09:28:37 -08003456 *
3457 * // Build the notification as an ongoing high priority item; this ensures it will show as
3458 * // a heads up notification which slides down over top of the current content.
3459 * final Notification.Builder builder = new Notification.Builder(context);
3460 * builder.setOngoing(true);
3461 * builder.setPriority(Notification.PRIORITY_HIGH);
3462 *
3463 * // Set notification content intent to take user to fullscreen UI if user taps on the
3464 * // notification body.
3465 * builder.setContentIntent(pendingIntent);
3466 * // Set full screen intent to trigger display of the fullscreen UI when the notification
3467 * // manager deems it appropriate.
3468 * builder.setFullScreenIntent(pendingIntent, true);
3469 *
3470 * // Setup notification content.
3471 * builder.setSmallIcon( yourIconResourceId );
3472 * builder.setContentTitle("Your notification title");
3473 * builder.setContentText("Your notification content.");
3474 *
Tyler Gunn06f06162018-06-18 11:24:15 -07003475 * // Set notification as insistent to cause your ringtone to loop.
3476 * Notification notification = builder.build();
3477 * notification.flags |= Notification.FLAG_INSISTENT;
Tyler Gunn159f35c2017-03-02 09:28:37 -08003478 *
Tyler Gunn06f06162018-06-18 11:24:15 -07003479 * // Use builder.addAction(..) to add buttons to answer or reject the call.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003480 * NotificationManager notificationManager = mContext.getSystemService(
3481 * NotificationManager.class);
Tyler Gunn06f06162018-06-18 11:24:15 -07003482 * notificationManager.notify(YOUR_CHANNEL_ID, YOUR_TAG, YOUR_ID, notification);
Tyler Gunn159f35c2017-03-02 09:28:37 -08003483 * </code></pre>
Tyler Gunnf5035432017-01-09 09:43:12 -08003484 */
3485 public void onShowIncomingCallUi() {}
3486
Hall Liub64ac4c2017-02-06 10:49:48 -08003487 /**
3488 * Notifies this {@link Connection} that the user has requested an RTT session.
3489 * The connection service should call {@link #sendRttInitiationSuccess} or
3490 * {@link #sendRttInitiationFailure} to inform Telecom of the success or failure of the
3491 * request, respectively.
3492 * @param rttTextStream The object that should be used to send text to or receive text from
3493 * the in-call app.
Hall Liub64ac4c2017-02-06 10:49:48 -08003494 */
3495 public void onStartRtt(@NonNull RttTextStream rttTextStream) {}
3496
3497 /**
3498 * Notifies this {@link Connection} that it should terminate any existing RTT communication
3499 * channel. No response to Telecom is needed for this method.
Hall Liub64ac4c2017-02-06 10:49:48 -08003500 */
3501 public void onStopRtt() {}
3502
3503 /**
3504 * Notifies this connection of a response to a previous remotely-initiated RTT upgrade
3505 * request sent via {@link #sendRemoteRttRequest}. Acceptance of the request is
3506 * indicated by the supplied {@link RttTextStream} being non-null, and rejection is
3507 * indicated by {@code rttTextStream} being {@code null}
Hall Liub64ac4c2017-02-06 10:49:48 -08003508 * @param rttTextStream The object that should be used to send text to or receive text from
3509 * the in-call app.
3510 */
3511 public void handleRttUpgradeResponse(@Nullable RttTextStream rttTextStream) {}
3512
Hall Liu49cabcc2021-01-15 11:41:48 -08003513 /**
Hall Liu73903142021-02-18 18:41:41 -08003514 * Information provided to a {@link Connection} upon completion of call filtering in Telecom.
3515 *
3516 * @hide
3517 */
3518 @SystemApi
3519 public static final class CallFilteringCompletionInfo implements Parcelable {
3520 private final boolean mIsBlocked;
3521 private final boolean mIsInContacts;
3522 private final CallScreeningService.CallResponse mCallResponse;
3523 private final ComponentName mCallScreeningComponent;
3524
3525 /**
3526 * Constructor for {@link CallFilteringCompletionInfo}
3527 *
3528 * @param isBlocked Whether any part of the call filtering process indicated that this call
3529 * should be blocked.
3530 * @param isInContacts Whether the caller is in the user's contacts.
3531 * @param callResponse The instance of {@link CallScreeningService.CallResponse} provided
3532 * by the {@link CallScreeningService} that processed this call, or
3533 * {@code null} if no call screening service ran.
3534 * @param callScreeningComponent The component of the {@link CallScreeningService}
3535 * that processed this call, or {@link null} if no
3536 * call screening service ran.
3537 */
3538 public CallFilteringCompletionInfo(boolean isBlocked, boolean isInContacts,
3539 @Nullable CallScreeningService.CallResponse callResponse,
3540 @Nullable ComponentName callScreeningComponent) {
3541 mIsBlocked = isBlocked;
3542 mIsInContacts = isInContacts;
3543 mCallResponse = callResponse;
3544 mCallScreeningComponent = callScreeningComponent;
3545 }
3546
3547 /** @hide */
3548 protected CallFilteringCompletionInfo(Parcel in) {
3549 mIsBlocked = in.readByte() != 0;
3550 mIsInContacts = in.readByte() != 0;
3551 CallScreeningService.ParcelableCallResponse response
Bernardo Rufino90bb3702021-12-07 20:01:45 +00003552 = in.readParcelable(CallScreeningService.class.getClassLoader(), android.telecom.CallScreeningService.ParcelableCallResponse.class);
Hall Liu73903142021-02-18 18:41:41 -08003553 mCallResponse = response == null ? null : response.toCallResponse();
Bernardo Rufino90bb3702021-12-07 20:01:45 +00003554 mCallScreeningComponent = in.readParcelable(ComponentName.class.getClassLoader(), android.content.ComponentName.class);
Hall Liu73903142021-02-18 18:41:41 -08003555 }
3556
3557 @NonNull
3558 public static final Creator<CallFilteringCompletionInfo> CREATOR =
3559 new Creator<CallFilteringCompletionInfo>() {
3560 @Override
3561 public CallFilteringCompletionInfo createFromParcel(Parcel in) {
3562 return new CallFilteringCompletionInfo(in);
3563 }
3564
3565 @Override
3566 public CallFilteringCompletionInfo[] newArray(int size) {
3567 return new CallFilteringCompletionInfo[size];
3568 }
3569 };
3570
3571 /**
3572 * @return Whether any part of the call filtering process indicated that this call should be
3573 * blocked.
3574 */
3575 public boolean isBlocked() {
3576 return mIsBlocked;
3577 }
3578
3579 /**
3580 * @return Whether the caller is in the user's contacts.
3581 */
3582 public boolean isInContacts() {
3583 return mIsInContacts;
3584 }
3585
3586 /**
3587 * @return The instance of {@link CallScreeningService.CallResponse} provided
3588 * by the {@link CallScreeningService} that processed this
3589 * call, or {@code null} if no call screening service ran.
3590 */
3591 public @Nullable CallScreeningService.CallResponse getCallResponse() {
3592 return mCallResponse;
3593 }
3594
3595 /**
3596 * @return The component of the {@link CallScreeningService}
3597 * that processed this call, or {@code null} if no call screening service ran.
3598 */
3599 public @Nullable ComponentName getCallScreeningComponent() {
3600 return mCallScreeningComponent;
3601 }
3602
3603 @Override
3604 public int describeContents() {
3605 return 0;
3606 }
3607
3608 @Override
3609 public String toString() {
3610 return "CallFilteringCompletionInfo{" +
3611 "mIsBlocked=" + mIsBlocked +
3612 ", mIsInContacts=" + mIsInContacts +
3613 ", mCallResponse=" + mCallResponse +
3614 ", mCallScreeningPackageName='" + mCallScreeningComponent + '\'' +
3615 '}';
3616 }
3617
3618 /** @hide */
3619 @Override
3620 public void writeToParcel(Parcel dest, int flags) {
3621 dest.writeByte((byte) (mIsBlocked ? 1 : 0));
3622 dest.writeByte((byte) (mIsInContacts ? 1 : 0));
3623 dest.writeParcelable(mCallResponse == null ? null : mCallResponse.toParcelable(), 0);
3624 dest.writeParcelable(mCallScreeningComponent, 0);
3625 }
3626 }
3627
3628 /**
Hall Liu49cabcc2021-01-15 11:41:48 -08003629 * Indicates that call filtering in Telecom is complete
3630 *
3631 * This method is called for a connection created via
3632 * {@link ConnectionService#onCreateIncomingConnection} when call filtering completes in
3633 * Telecom, including checking the blocked number db, per-contact settings, and custom call
3634 * filtering apps.
3635 *
Hall Liu73903142021-02-18 18:41:41 -08003636 * @param callFilteringCompletionInfo Info provided by Telecom on the results of call filtering.
Hall Liu49cabcc2021-01-15 11:41:48 -08003637 * @hide
3638 */
3639 @SystemApi
3640 @RequiresPermission(Manifest.permission.READ_CONTACTS)
Hall Liu73903142021-02-18 18:41:41 -08003641 public void onCallFilteringCompleted(
3642 @NonNull CallFilteringCompletionInfo callFilteringCompletionInfo) { }
Hall Liu49cabcc2021-01-15 11:41:48 -08003643
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003644 static String toLogSafePhoneNumber(String number) {
3645 // For unknown number, log empty string.
3646 if (number == null) {
3647 return "";
3648 }
3649
3650 if (PII_DEBUG) {
3651 // When PII_DEBUG is true we emit PII.
3652 return number;
3653 }
3654
3655 // Do exactly same thing as Uri#toSafeString() does, which will enable us to compare
3656 // sanitized phone numbers.
3657 StringBuilder builder = new StringBuilder();
3658 for (int i = 0; i < number.length(); i++) {
3659 char c = number.charAt(i);
3660 if (c == '-' || c == '@' || c == '.') {
3661 builder.append(c);
3662 } else {
3663 builder.append('x');
3664 }
3665 }
3666 return builder.toString();
3667 }
3668
Ihab Awad542e0ea2014-05-16 10:22:16 -07003669 private void setState(int state) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003670 checkImmutable();
Ihab Awad6107bab2014-08-18 09:23:25 -07003671 if (mState == STATE_DISCONNECTED && mState != state) {
3672 Log.d(this, "Connection already DISCONNECTED; cannot transition out of this state.");
Evan Charltonbf11f982014-07-20 22:06:28 -07003673 return;
Sailesh Nepal400cc482014-06-26 12:04:00 -07003674 }
Evan Charltonbf11f982014-07-20 22:06:28 -07003675 if (mState != state) {
3676 Log.d(this, "setState: %s", stateToString(state));
3677 mState = state;
Nancy Chen354b2bd2014-09-08 18:27:26 -07003678 onStateChanged(state);
Evan Charltonbf11f982014-07-20 22:06:28 -07003679 for (Listener l : mListeners) {
3680 l.onStateChanged(this, state);
3681 }
Evan Charltonbf11f982014-07-20 22:06:28 -07003682 }
3683 }
3684
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07003685 private static class FailureSignalingConnection extends Connection {
Ihab Awad90e34e32014-12-01 16:23:17 -08003686 private boolean mImmutable = false;
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003687 public FailureSignalingConnection(DisconnectCause disconnectCause) {
3688 setDisconnected(disconnectCause);
Tyler Gunn2915af72020-03-06 11:36:21 -08003689 mImmutable = true;
Ihab Awad6107bab2014-08-18 09:23:25 -07003690 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003691
3692 public void checkImmutable() {
Ihab Awad90e34e32014-12-01 16:23:17 -08003693 if (mImmutable) {
3694 throw new UnsupportedOperationException("Connection is immutable");
3695 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003696 }
Ihab Awad6107bab2014-08-18 09:23:25 -07003697 }
3698
Evan Charltonbf11f982014-07-20 22:06:28 -07003699 /**
Ihab Awad6107bab2014-08-18 09:23:25 -07003700 * Return a {@code Connection} which represents a failed connection attempt. The returned
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003701 * {@code Connection} will have a {@link android.telecom.DisconnectCause} and as specified,
3702 * and a {@link #getState()} of {@link #STATE_DISCONNECTED}.
Ihab Awad6107bab2014-08-18 09:23:25 -07003703 * <p>
3704 * The returned {@code Connection} can be assumed to {@link #destroy()} itself when appropriate,
3705 * so users of this method need not maintain a reference to its return value to destroy it.
Evan Charltonbf11f982014-07-20 22:06:28 -07003706 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003707 * @param disconnectCause The disconnect cause, ({@see android.telecomm.DisconnectCause}).
Ihab Awad6107bab2014-08-18 09:23:25 -07003708 * @return A {@code Connection} which indicates failure.
Evan Charltonbf11f982014-07-20 22:06:28 -07003709 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003710 public static Connection createFailedConnection(DisconnectCause disconnectCause) {
3711 return new FailureSignalingConnection(disconnectCause);
Evan Charltonbf11f982014-07-20 22:06:28 -07003712 }
3713
Evan Charltonbf11f982014-07-20 22:06:28 -07003714 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003715 * Override to throw an {@link UnsupportedOperationException} if this {@code Connection} is
3716 * not intended to be mutated, e.g., if it is a marker for failure. Only for framework use;
3717 * this should never be un-@hide-den.
3718 *
3719 * @hide
3720 */
3721 public void checkImmutable() {}
3722
3723 /**
Ihab Awad6107bab2014-08-18 09:23:25 -07003724 * Return a {@code Connection} which represents a canceled connection attempt. The returned
3725 * {@code Connection} will have state {@link #STATE_DISCONNECTED}, and cannot be moved out of
3726 * that state. This connection should not be used for anything, and no other
3727 * {@code Connection}s should be attempted.
3728 * <p>
Ihab Awad6107bab2014-08-18 09:23:25 -07003729 * so users of this method need not maintain a reference to its return value to destroy it.
Evan Charltonbf11f982014-07-20 22:06:28 -07003730 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003731 * @return A {@code Connection} which indicates that the underlying connection should
3732 * be canceled.
Evan Charltonbf11f982014-07-20 22:06:28 -07003733 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003734 public static Connection createCanceledConnection() {
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003735 return new FailureSignalingConnection(new DisconnectCause(DisconnectCause.CANCELED));
Ihab Awad542e0ea2014-05-16 10:22:16 -07003736 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003737
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003738 private final void fireOnConferenceableConnectionsChanged() {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003739 for (Listener l : mListeners) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003740 l.onConferenceablesChanged(this, getConferenceables());
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003741 }
3742 }
3743
Santos Cordon823fd3c2014-08-07 18:35:18 -07003744 private final void fireConferenceChanged() {
3745 for (Listener l : mListeners) {
3746 l.onConferenceChanged(this, mConference);
3747 }
3748 }
3749
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003750 private final void clearConferenceableList() {
Tyler Gunndf2cbc82015-04-20 09:13:01 -07003751 for (Conferenceable c : mConferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003752 if (c instanceof Connection) {
3753 Connection connection = (Connection) c;
3754 connection.removeConnectionListener(mConnectionDeathListener);
3755 } else if (c instanceof Conference) {
3756 Conference conference = (Conference) c;
3757 conference.removeListener(mConferenceDeathListener);
3758 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003759 }
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003760 mConferenceables.clear();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003761 }
Tyler Gunn3bffcf72014-10-28 13:51:27 -07003762
3763 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07003764 * Handles a change to extras received from Telecom.
3765 *
3766 * @param extras The new extras.
3767 * @hide
3768 */
3769 final void handleExtrasChanged(Bundle extras) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003770 Bundle b = null;
3771 synchronized (mExtrasLock) {
3772 mExtras = extras;
3773 if (mExtras != null) {
3774 b = new Bundle(mExtras);
3775 }
3776 }
3777 onExtrasChanged(b);
Tyler Gunndee56a82016-03-23 16:06:34 -07003778 }
3779
3780 /**
Tyler Gunnc63f9082019-10-15 13:19:26 -07003781 * Called by a {@link ConnectionService} to notify Telecom that a {@link Conference#onMerge()}
3782 * request failed.
Anthony Lee17455a32015-04-24 15:25:29 -07003783 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003784 public final void notifyConferenceMergeFailed() {
Anthony Lee17455a32015-04-24 15:25:29 -07003785 for (Listener l : mListeners) {
3786 l.onConferenceMergeFailed(this);
3787 }
3788 }
3789
3790 /**
Srikanth Chintalafcb15012017-05-04 20:58:34 +05303791 * Notifies listeners when phone account is changed. For example, when the PhoneAccount is
3792 * changed due to an emergency call being redialed.
3793 * @param pHandle The new PhoneAccountHandle for this connection.
3794 * @hide
3795 */
3796 public void notifyPhoneAccountChanged(PhoneAccountHandle pHandle) {
3797 for (Listener l : mListeners) {
3798 l.onPhoneAccountChanged(this, pHandle);
3799 }
3800 }
3801
3802 /**
Pengquan Meng70c9885332017-10-02 18:09:03 -07003803 * Sets the {@link PhoneAccountHandle} associated with this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003804 * <p>
3805 * Used by the Telephony {@link ConnectionService} to handle changes to the {@link PhoneAccount}
3806 * which take place after call initiation (important for emergency calling scenarios).
Pengquan Meng70c9885332017-10-02 18:09:03 -07003807 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07003808 * @param phoneAccountHandle the phone account handle to set.
Pengquan Meng70c9885332017-10-02 18:09:03 -07003809 * @hide
3810 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003811 @SystemApi
3812 public void setPhoneAccountHandle(@NonNull PhoneAccountHandle phoneAccountHandle) {
Pengquan Meng70c9885332017-10-02 18:09:03 -07003813 if (mPhoneAccountHandle != phoneAccountHandle) {
3814 mPhoneAccountHandle = phoneAccountHandle;
3815 notifyPhoneAccountChanged(phoneAccountHandle);
3816 }
3817 }
3818
3819 /**
3820 * Returns the {@link PhoneAccountHandle} associated with this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003821 * <p>
3822 * Used by the Telephony {@link ConnectionService} to handle changes to the {@link PhoneAccount}
3823 * which take place after call initiation (important for emergency calling scenarios).
Pengquan Meng70c9885332017-10-02 18:09:03 -07003824 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07003825 * @return the phone account handle specified via
3826 * {@link #setPhoneAccountHandle(PhoneAccountHandle)}, or {@code null} if none was set.
Pengquan Meng70c9885332017-10-02 18:09:03 -07003827 * @hide
3828 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003829 @SystemApi
3830 public @Nullable PhoneAccountHandle getPhoneAccountHandle() {
Pengquan Meng70c9885332017-10-02 18:09:03 -07003831 return mPhoneAccountHandle;
3832 }
3833
3834 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003835 * Sends an event associated with this {@code Connection} with associated event extras to the
3836 * {@link InCallService}.
3837 * <p>
3838 * Connection events are used to communicate point in time information from a
3839 * {@link ConnectionService} to a {@link InCallService} implementations. An example of a
3840 * custom connection event includes notifying the UI when a WIFI call has been handed over to
3841 * LTE, which the InCall UI might use to inform the user that billing charges may apply. The
3842 * Android Telephony framework will send the {@link #EVENT_CALL_MERGE_FAILED} connection event
3843 * when a call to {@link Call#mergeConference()} has failed to complete successfully. A
3844 * connection event could also be used to trigger UI in the {@link InCallService} which prompts
3845 * the user to make a choice (e.g. whether they want to incur roaming costs for making a call),
3846 * which is communicated back via {@link Call#sendCallEvent(String, Bundle)}.
3847 * <p>
3848 * Events are exposed to {@link InCallService} implementations via
3849 * {@link Call.Callback#onConnectionEvent(Call, String, Bundle)}.
3850 * <p>
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003851 * 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 -07003852 * The {@link ConnectionService} must assume that the In-Call UI could even chose to ignore
3853 * some events altogether.
3854 * <p>
3855 * Events should be fully qualified (e.g. {@code com.example.event.MY_EVENT}) to avoid
3856 * conflicts between {@link ConnectionService} implementations. Further, custom
3857 * {@link ConnectionService} implementations shall not re-purpose events in the
3858 * {@code android.*} namespace, nor shall they define new event types in this namespace. When
3859 * defining a custom event type, ensure the contents of the extras {@link Bundle} is clearly
3860 * defined. Extra keys for this bundle should be named similar to the event type (e.g.
3861 * {@code com.example.extra.MY_EXTRA}).
3862 * <p>
3863 * When defining events and the associated extras, it is important to keep their behavior
3864 * consistent when the associated {@link ConnectionService} is updated. Support for deprecated
3865 * events/extras should me maintained to ensure backwards compatibility with older
3866 * {@link InCallService} implementations which were built to support the older behavior.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003867 *
3868 * @param event The connection event.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003869 * @param extras Optional bundle containing extra information associated with the event.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003870 */
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003871 public void sendConnectionEvent(String event, Bundle extras) {
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003872 for (Listener l : mListeners) {
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07003873 l.onConnectionEvent(this, event, extras);
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003874 }
3875 }
Tyler Gunn6986a632019-06-25 13:45:32 -07003876
3877 /**
3878 * @return The direction of the call.
3879 * @hide
3880 */
3881 public final @Call.Details.CallDirection int getCallDirection() {
3882 return mCallDirection;
3883 }
3884
3885 /**
3886 * Sets the direction of this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003887 * <p>
3888 * Used when calling {@link ConnectionService#addExistingConnection} to specify the existing
3889 * call direction.
3890 *
Tyler Gunn6986a632019-06-25 13:45:32 -07003891 * @param callDirection The direction of this connection.
3892 * @hide
3893 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003894 @SystemApi
Tyler Gunn6986a632019-06-25 13:45:32 -07003895 public void setCallDirection(@Call.Details.CallDirection int callDirection) {
3896 mCallDirection = callDirection;
3897 }
Tyler Gunnd57d76c2019-09-24 14:53:23 -07003898
3899 /**
3900 * Gets the verification status for the phone number of an incoming call as identified in
3901 * ATIS-1000082.
3902 * @return the verification status.
3903 */
Tyler Gunna131d6e2020-02-13 14:53:28 -08003904 public final @VerificationStatus int getCallerNumberVerificationStatus() {
Tyler Gunnd57d76c2019-09-24 14:53:23 -07003905 return mCallerNumberVerificationStatus;
3906 }
3907
3908 /**
3909 * Sets the verification status for the phone number of an incoming call as identified in
3910 * ATIS-1000082.
3911 * <p>
3912 * This property can only be set at the time of creation of a {@link Connection} being returned
3913 * by
3914 * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)}.
3915 */
Tyler Gunna131d6e2020-02-13 14:53:28 -08003916 public final void setCallerNumberVerificationStatus(
Tyler Gunnd57d76c2019-09-24 14:53:23 -07003917 @VerificationStatus int callerNumberVerificationStatus) {
3918 mCallerNumberVerificationStatus = callerNumberVerificationStatus;
3919 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07003920}