blob: 568c8abc40a2a83c645374b247ee6fa5463e87c8 [file] [log] [blame]
Ihab Awad542e0ea2014-05-16 10:22:16 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Tyler Gunnef9f6f92014-09-12 22:16:17 -070017package android.telecom;
Ihab Awad542e0ea2014-05-16 10:22:16 -070018
Tyler Gunnc9503d62020-01-27 10:30:51 -080019import static android.Manifest.permission.MODIFY_PHONE_STATE;
20
Hall Liu49cabcc2021-01-15 11:41:48 -080021import android.Manifest;
Tyler Gunnc9503d62020-01-27 10:30:51 -080022import android.annotation.ElapsedRealtimeLong;
Tyler Gunnd57d76c2019-09-24 14:53:23 -070023import android.annotation.IntDef;
Tyler Gunnc9503d62020-01-27 10:30:51 -080024import android.annotation.IntRange;
Tyler Gunndee56a82016-03-23 16:06:34 -070025import android.annotation.NonNull;
Santos Cordon6b7f9552015-05-27 17:21:45 -070026import android.annotation.Nullable;
Tyler Gunnc9503d62020-01-27 10:30:51 -080027import android.annotation.RequiresPermission;
Yorke Lee4af59352015-05-13 14:14:54 -070028import android.annotation.SystemApi;
Tyler Gunn159f35c2017-03-02 09:28:37 -080029import android.app.Notification;
Hall Liua98f58b52017-11-07 17:59:28 -080030import android.bluetooth.BluetoothDevice;
Artur Satayev53ada2a2019-12-10 17:47:56 +000031import android.compat.annotation.UnsupportedAppUsage;
Hall Liu73903142021-02-18 18:41:41 -080032import android.content.ComponentName;
Tyler Gunn159f35c2017-03-02 09:28:37 -080033import android.content.Intent;
Tyler Gunnb702ef82015-05-29 11:51:53 -070034import android.hardware.camera2.CameraManager;
Ihab Awad542e0ea2014-05-16 10:22:16 -070035import android.net.Uri;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -080036import android.os.Binder;
Santos Cordon6b7f9552015-05-27 17:21:45 -070037import android.os.Bundle;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070038import android.os.Handler;
39import android.os.IBinder;
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -070040import android.os.Looper;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070041import android.os.Message;
Hall Liu73903142021-02-18 18:41:41 -080042import android.os.Parcel;
Hall Liu95d55872017-01-25 17:12:49 -080043import android.os.ParcelFileDescriptor;
Hall Liu73903142021-02-18 18:41:41 -080044import android.os.Parcelable;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070045import android.os.RemoteException;
Tyler Gunn3fa819c2017-08-04 09:27:26 -070046import android.os.SystemClock;
Tyler Gunn0a1c6d12021-03-12 15:44:08 -080047import android.telephony.CallQuality;
Sooraj Sasindran065b77d2022-02-24 00:14:51 -080048import android.telephony.CellIdentity;
allenwtsu2aca9892019-11-25 14:38:21 +080049import android.telephony.ims.ImsStreamMediaProfile;
Tyler Gunndee56a82016-03-23 16:06:34 -070050import android.util.ArraySet;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070051import android.view.Surface;
Ihab Awad542e0ea2014-05-16 10:22:16 -070052
Youming Yed6de26e2019-01-30 11:20:35 -080053import com.android.internal.os.SomeArgs;
54import com.android.internal.telecom.IVideoCallback;
55import com.android.internal.telecom.IVideoProvider;
56
Hall Liua549fed2018-02-09 16:40:03 -080057import java.io.FileInputStream;
58import java.io.FileOutputStream;
Hall Liu95d55872017-01-25 17:12:49 -080059import java.io.IOException;
60import java.io.InputStreamReader;
61import java.io.OutputStreamWriter;
Tyler Gunnd57d76c2019-09-24 14:53:23 -070062import java.lang.annotation.Retention;
63import java.lang.annotation.RetentionPolicy;
Hall Liu730a2592018-06-25 19:48:33 -070064import java.nio.channels.Channels;
Santos Cordonb6939982014-06-04 20:20:58 -070065import java.util.ArrayList;
Tyler Gunn071be6f2016-05-10 14:52:33 -070066import java.util.Arrays;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070067import java.util.Collections;
Santos Cordonb6939982014-06-04 20:20:58 -070068import java.util.List;
Edgar Arriaga2db19d22022-10-14 14:25:14 -070069import java.util.Objects;
Ihab Awad542e0ea2014-05-16 10:22:16 -070070import java.util.Set;
Jay Shrauner229e3822014-08-15 09:23:07 -070071import java.util.concurrent.ConcurrentHashMap;
Ihab Awad542e0ea2014-05-16 10:22:16 -070072
73/**
Santos Cordon895d4b82015-06-25 16:41:48 -070074 * Represents a phone call or connection to a remote endpoint that carries voice and/or video
75 * traffic.
Ihab Awad6107bab2014-08-18 09:23:25 -070076 * <p>
77 * Implementations create a custom subclass of {@code Connection} and return it to the framework
78 * as the return value of
79 * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)}
80 * or
81 * {@link ConnectionService#onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
82 * Implementations are then responsible for updating the state of the {@code Connection}, and
83 * must call {@link #destroy()} to signal to the framework that the {@code Connection} is no
84 * longer used and associated resources may be recovered.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -070085 * <p>
86 * Subclasses of {@code Connection} override the {@code on*} methods to provide the the
87 * {@link ConnectionService}'s implementation of calling functionality. The {@code on*} methods are
88 * called by Telecom to inform an instance of a {@code Connection} of actions specific to that
89 * {@code Connection} instance.
90 * <p>
91 * Basic call support requires overriding the following methods: {@link #onAnswer()},
92 * {@link #onDisconnect()}, {@link #onReject()}, {@link #onAbort()}
93 * <p>
94 * Where a {@code Connection} has {@link #CAPABILITY_SUPPORT_HOLD}, the {@link #onHold()} and
95 * {@link #onUnhold()} methods should be overridden to provide hold support for the
96 * {@code Connection}.
97 * <p>
98 * Where a {@code Connection} supports a variation of video calling (e.g. the
99 * {@code CAPABILITY_SUPPORTS_VT_*} capability bits), {@link #onAnswer(int)} should be overridden
100 * to support answering a call as a video call.
101 * <p>
102 * Where a {@code Connection} has {@link #PROPERTY_IS_EXTERNAL_CALL} and
103 * {@link #CAPABILITY_CAN_PULL_CALL}, {@link #onPullExternalCall()} should be overridden to provide
104 * support for pulling the external call.
105 * <p>
106 * Where a {@code Connection} supports conference calling {@link #onSeparate()} should be
107 * overridden.
108 * <p>
109 * There are a number of other {@code on*} methods which a {@code Connection} can choose to
110 * implement, depending on whether it is concerned with the associated calls from Telecom. If,
111 * for example, call events from a {@link InCallService} are handled,
112 * {@link #onCallEvent(String, Bundle)} should be overridden. Another example is
113 * {@link #onExtrasChanged(Bundle)}, which should be overridden if the {@code Connection} wishes to
114 * make use of extra information provided via the {@link Call#putExtras(Bundle)} and
115 * {@link Call#removeExtras(String...)} methods.
Ihab Awad542e0ea2014-05-16 10:22:16 -0700116 */
Yorke Leeabfcfdc2015-05-13 18:55:18 -0700117public abstract class Connection extends Conferenceable {
Ihab Awad542e0ea2014-05-16 10:22:16 -0700118
Tyler Gunn50d437f2021-01-12 16:34:59 -0800119 /**@hide*/
120 @Retention(RetentionPolicy.SOURCE)
121 @IntDef(prefix = "STATE_", value = {
122 STATE_INITIALIZING,
123 STATE_NEW,
124 STATE_RINGING,
125 STATE_DIALING,
126 STATE_ACTIVE,
127 STATE_HOLDING,
128 STATE_DISCONNECTED,
129 STATE_PULLING_CALL
130 })
131 public @interface ConnectionState {}
132
Santos Cordon895d4b82015-06-25 16:41:48 -0700133 /**
134 * The connection is initializing. This is generally the first state for a {@code Connection}
135 * returned by a {@link ConnectionService}.
136 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700137 public static final int STATE_INITIALIZING = 0;
138
Santos Cordon895d4b82015-06-25 16:41:48 -0700139 /**
140 * The connection is new and not connected.
141 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700142 public static final int STATE_NEW = 1;
143
Santos Cordon895d4b82015-06-25 16:41:48 -0700144 /**
145 * An incoming connection is in the ringing state. During this state, the user's ringer or
146 * vibration feature will be activated.
147 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700148 public static final int STATE_RINGING = 2;
149
Santos Cordon895d4b82015-06-25 16:41:48 -0700150 /**
151 * An outgoing connection is in the dialing state. In this state the other party has not yet
152 * answered the call and the user traditionally hears a ringback tone.
153 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700154 public static final int STATE_DIALING = 3;
155
Santos Cordon895d4b82015-06-25 16:41:48 -0700156 /**
157 * A connection is active. Both parties are connected to the call and can actively communicate.
158 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700159 public static final int STATE_ACTIVE = 4;
160
Santos Cordon895d4b82015-06-25 16:41:48 -0700161 /**
162 * A connection is on hold.
163 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700164 public static final int STATE_HOLDING = 5;
165
Santos Cordon895d4b82015-06-25 16:41:48 -0700166 /**
167 * A connection has been disconnected. This is the final state once the user has been
168 * disconnected from a call either locally, remotely or by an error in the service.
169 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700170 public static final int STATE_DISCONNECTED = 6;
171
Santos Cordon895d4b82015-06-25 16:41:48 -0700172 /**
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700173 * The state of an external connection which is in the process of being pulled from a remote
174 * device to the local device.
175 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -0700176 * A connection can only be in this state if the {@link #PROPERTY_IS_EXTERNAL_CALL} property and
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700177 * {@link #CAPABILITY_CAN_PULL_CALL} capability bits are set on the connection.
178 */
179 public static final int STATE_PULLING_CALL = 7;
180
181 /**
Tyler Gunnd57d76c2019-09-24 14:53:23 -0700182 * Indicates that the network could not perform verification.
183 */
184 public static final int VERIFICATION_STATUS_NOT_VERIFIED = 0;
185
186 /**
187 * Indicates that verification by the network passed. This indicates there is a high likelihood
188 * that the call originated from a valid source.
189 */
190 public static final int VERIFICATION_STATUS_PASSED = 1;
191
192 /**
193 * Indicates that verification by the network failed. This indicates there is a high likelihood
194 * that the call did not originate from a valid source.
195 */
196 public static final int VERIFICATION_STATUS_FAILED = 2;
197
198 /**@hide*/
199 @Retention(RetentionPolicy.SOURCE)
200 @IntDef(prefix = "VERIFICATION_STATUS_", value = {
201 VERIFICATION_STATUS_NOT_VERIFIED,
202 VERIFICATION_STATUS_PASSED,
203 VERIFICATION_STATUS_FAILED
204 })
205 public @interface VerificationStatus {}
206
207 /**
Santos Cordon895d4b82015-06-25 16:41:48 -0700208 * Connection can currently be put on hold or unheld. This is distinct from
209 * {@link #CAPABILITY_SUPPORT_HOLD} in that although a connection may support 'hold' most times,
210 * it does not at the moment support the function. This can be true while the call is in the
211 * state {@link #STATE_DIALING}, for example. During this condition, an in-call UI may
212 * display a disabled 'hold' button.
213 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800214 public static final int CAPABILITY_HOLD = 0x00000001;
215
216 /** Connection supports the hold feature. */
217 public static final int CAPABILITY_SUPPORT_HOLD = 0x00000002;
218
219 /**
220 * Connections within a conference can be merged. A {@link ConnectionService} has the option to
221 * add a {@link Conference} before the child {@link Connection}s are merged. This is how
222 * CDMA-based {@link Connection}s are implemented. For these unmerged {@link Conference}s, this
223 * capability allows a merge button to be shown while the conference is in the foreground
224 * of the in-call UI.
225 * <p>
226 * This is only intended for use by a {@link Conference}.
227 */
228 public static final int CAPABILITY_MERGE_CONFERENCE = 0x00000004;
229
230 /**
231 * Connections within a conference can be swapped between foreground and background.
232 * See {@link #CAPABILITY_MERGE_CONFERENCE} for additional information.
233 * <p>
234 * This is only intended for use by a {@link Conference}.
235 */
236 public static final int CAPABILITY_SWAP_CONFERENCE = 0x00000008;
237
238 /**
239 * @hide
240 */
241 public static final int CAPABILITY_UNUSED = 0x00000010;
242
243 /** Connection supports responding via text option. */
244 public static final int CAPABILITY_RESPOND_VIA_TEXT = 0x00000020;
245
246 /** Connection can be muted. */
247 public static final int CAPABILITY_MUTE = 0x00000040;
248
249 /**
250 * Connection supports conference management. This capability only applies to
251 * {@link Conference}s which can have {@link Connection}s as children.
252 */
253 public static final int CAPABILITY_MANAGE_CONFERENCE = 0x00000080;
254
255 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700256 * Local device supports receiving video.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800257 */
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700258 public static final int CAPABILITY_SUPPORTS_VT_LOCAL_RX = 0x00000100;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800259
260 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700261 * Local device supports transmitting video.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800262 */
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700263 public static final int CAPABILITY_SUPPORTS_VT_LOCAL_TX = 0x00000200;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800264
265 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700266 * Local device supports bidirectional video calling.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800267 */
Andrew Lee9a8f9ce2015-04-10 18:09:46 -0700268 public static final int CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL =
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700269 CAPABILITY_SUPPORTS_VT_LOCAL_RX | CAPABILITY_SUPPORTS_VT_LOCAL_TX;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800270
271 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700272 * Remote device supports receiving video.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800273 */
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700274 public static final int CAPABILITY_SUPPORTS_VT_REMOTE_RX = 0x00000400;
275
276 /**
277 * Remote device supports transmitting video.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700278 */
279 public static final int CAPABILITY_SUPPORTS_VT_REMOTE_TX = 0x00000800;
280
281 /**
282 * Remote device supports bidirectional video calling.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700283 */
Andrew Lee9a8f9ce2015-04-10 18:09:46 -0700284 public static final int CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL =
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700285 CAPABILITY_SUPPORTS_VT_REMOTE_RX | CAPABILITY_SUPPORTS_VT_REMOTE_TX;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800286
287 /**
288 * Connection is able to be separated from its parent {@code Conference}, if any.
289 */
290 public static final int CAPABILITY_SEPARATE_FROM_CONFERENCE = 0x00001000;
291
292 /**
293 * Connection is able to be individually disconnected when in a {@code Conference}.
294 */
295 public static final int CAPABILITY_DISCONNECT_FROM_CONFERENCE = 0x00002000;
296
297 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700298 * Un-used.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800299 * @hide
300 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700301 public static final int CAPABILITY_UNUSED_2 = 0x00004000;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800302
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700303 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700304 * Un-used.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700305 * @hide
306 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700307 public static final int CAPABILITY_UNUSED_3 = 0x00008000;
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700308
309 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700310 * Un-used.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700311 * @hide
312 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700313 public static final int CAPABILITY_UNUSED_4 = 0x00010000;
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700314
Tyler Gunn068085b2015-02-06 13:56:52 -0800315 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700316 * Un-used.
Tyler Gunn068085b2015-02-06 13:56:52 -0800317 * @hide
318 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700319 public static final int CAPABILITY_UNUSED_5 = 0x00020000;
Tyler Gunn068085b2015-02-06 13:56:52 -0800320
Tyler Gunn96d6c402015-03-18 12:39:23 -0700321 /**
Dong Zhou89f41eb2015-03-15 11:59:49 -0500322 * Speed up audio setup for MT call.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700323 * <p>
324 * Used for IMS calls to indicate that mobile-terminated (incoming) call audio setup should take
325 * place as soon as the device answers the call, but prior to it being connected. This is an
326 * optimization some IMS stacks depend on to ensure prompt setup of call audio.
Dong Zhou89f41eb2015-03-15 11:59:49 -0500327 * @hide
Tyler Gunn96d6c402015-03-18 12:39:23 -0700328 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700329 @SystemApi
Tyler Gunn96d6c402015-03-18 12:39:23 -0700330 public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00040000;
Tyler Gunn068085b2015-02-06 13:56:52 -0800331
Rekha Kumar07366812015-03-24 16:42:31 -0700332 /**
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700333 * Call can be upgraded to a video call.
Tyler Gunn6e3ecc42018-11-12 11:30:56 -0800334 * @deprecated Use {@link #CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL} and
335 * {@link #CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL} to indicate for a call whether or not
336 * video calling is supported.
Rekha Kumar07366812015-03-24 16:42:31 -0700337 */
338 public static final int CAPABILITY_CAN_UPGRADE_TO_VIDEO = 0x00080000;
339
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700340 /**
341 * For video calls, indicates whether the outgoing video for the call can be paused using
Yorke Lee32f24732015-05-12 16:18:03 -0700342 * the {@link android.telecom.VideoProfile#STATE_PAUSED} VideoState.
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700343 */
344 public static final int CAPABILITY_CAN_PAUSE_VIDEO = 0x00100000;
345
Tyler Gunnd4091732015-06-29 09:15:37 -0700346 /**
347 * For a conference, indicates the conference will not have child connections.
348 * <p>
349 * An example of a conference with child connections is a GSM conference call, where the radio
350 * retains connections to the individual participants of the conference. Another example is an
351 * IMS conference call where conference event package functionality is supported; in this case
352 * the conference server ensures the radio is aware of the participants in the conference, which
353 * are represented by child connections.
354 * <p>
355 * An example of a conference with no child connections is an IMS conference call with no
356 * conference event package support. Such a conference is represented by the radio as a single
357 * connection to the IMS conference server.
358 * <p>
359 * Indicating whether a conference has children or not is important to help user interfaces
360 * visually represent a conference. A conference with no children, for example, will have the
361 * conference connection shown in the list of calls on a Bluetooth device, where if the
362 * conference has children, only the children will be shown in the list of calls on a Bluetooth
363 * device.
364 * @hide
365 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700366 @SystemApi
Tyler Gunnd4091732015-06-29 09:15:37 -0700367 public static final int CAPABILITY_CONFERENCE_HAS_NO_CHILDREN = 0x00200000;
368
Bryce Lee81901682015-08-28 16:38:02 -0700369 /**
370 * Indicates that the connection itself wants to handle any sort of reply response, rather than
371 * relying on SMS.
Bryce Lee81901682015-08-28 16:38:02 -0700372 */
373 public static final int CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION = 0x00400000;
374
Tyler Gunnf97a0092016-01-19 15:59:34 -0800375 /**
376 * When set, prevents a video call from being downgraded to an audio-only call.
377 * <p>
378 * Should be set when the VideoState has the {@link VideoProfile#STATE_TX_ENABLED} or
379 * {@link VideoProfile#STATE_RX_ENABLED} bits set to indicate that the connection cannot be
380 * downgraded from a video call back to a VideoState of
381 * {@link VideoProfile#STATE_AUDIO_ONLY}.
382 * <p>
383 * Intuitively, a call which can be downgraded to audio should also have local and remote
384 * video
385 * capabilities (see {@link #CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL} and
386 * {@link #CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL}).
387 */
388 public static final int CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO = 0x00800000;
389
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700390 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700391 * When set for an external connection, indicates that this {@code Connection} can be pulled
392 * from a remote device to the current device.
393 * <p>
394 * Should only be set on a {@code Connection} where {@link #PROPERTY_IS_EXTERNAL_CALL}
395 * is set.
396 */
397 public static final int CAPABILITY_CAN_PULL_CALL = 0x01000000;
398
Pooja Jaind34698d2017-12-28 14:15:31 +0530399 /** Call supports the deflect feature. */
400 public static final int CAPABILITY_SUPPORT_DEFLECT = 0x02000000;
401
Ravi Paluri404babb2020-01-23 19:02:44 +0530402 /**
403 * When set, indicates that this {@link Connection} supports initiation of a conference call
Grace Jia8587ee52020-07-10 15:42:32 -0700404 * by directly adding participants using {@link #onAddConferenceParticipants(List)}. When
405 * participants are added to a {@link Connection}, it will be replaced by a {@link Conference}
406 * instance with {@link #PROPERTY_IS_ADHOC_CONFERENCE} set to indicate that it is an adhoc
407 * conference call.
Ravi Paluri404babb2020-01-23 19:02:44 +0530408 */
409 public static final int CAPABILITY_ADD_PARTICIPANT = 0x04000000;
Ravi Palurif4b38e72020-02-05 12:35:41 +0530410
411 /**
412 * Indicates that this {@code Connection} can be transferred to another
413 * number.
Tyler Gunn460360d2020-07-29 10:21:45 -0700414 * Connection supports the confirmed and unconfirmed call transfer feature.
Ravi Palurif4b38e72020-02-05 12:35:41 +0530415 * @hide
416 */
417 public static final int CAPABILITY_TRANSFER = 0x08000000;
418
419 /**
420 * Indicates that this {@code Connection} can be transferred to another
421 * ongoing {@code Connection}.
422 * Connection supports the consultative call transfer feature.
423 * @hide
424 */
425 public static final int CAPABILITY_TRANSFER_CONSULTATIVE = 0x10000000;
426
Alvin Dey2f37d772018-05-18 23:16:10 +0530427 /**
428 * Indicates whether the remote party supports RTT or not to the UI.
429 */
430
431 public static final int CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT = 0x20000000;
432
Tyler Gunn720c6642016-03-22 09:02:47 -0700433 //**********************************************************************************************
Alvin Dey2f37d772018-05-18 23:16:10 +0530434 // Next CAPABILITY value: 0x40000000
Tyler Gunn720c6642016-03-22 09:02:47 -0700435 //**********************************************************************************************
436
437 /**
438 * Indicates that the current device callback number should be shown.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700439 * <p>
440 * Supports Telephony calls where CDMA emergency callback mode is active.
Tyler Gunn720c6642016-03-22 09:02:47 -0700441 * @hide
442 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700443 @SystemApi
Hall Liu25c7c4d2016-08-30 13:41:02 -0700444 public static final int PROPERTY_EMERGENCY_CALLBACK_MODE = 1<<0;
Tyler Gunn720c6642016-03-22 09:02:47 -0700445
446 /**
447 * Whether the call is a generic conference, where we do not know the precise state of
448 * participants in the conference (eg. on CDMA).
Tyler Gunnc63f9082019-10-15 13:19:26 -0700449 * <p>
450 * Supports legacy telephony CDMA calls.
Tyler Gunn720c6642016-03-22 09:02:47 -0700451 * @hide
452 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700453 @SystemApi
Tyler Gunn720c6642016-03-22 09:02:47 -0700454 public static final int PROPERTY_GENERIC_CONFERENCE = 1<<1;
455
456 /**
457 * Connection is using high definition audio.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700458 * <p>
459 * Indicates that the {@link Connection} is using a "high definition" audio codec. This usually
460 * implies something like AMR wideband, but the interpretation of when a call is considered high
461 * definition is left to the {@link ConnectionService} to decide.
462 * <p>
463 * Translates to {@link android.telecom.Call.Details#PROPERTY_HIGH_DEF_AUDIO}.
Tyler Gunn720c6642016-03-22 09:02:47 -0700464 */
465 public static final int PROPERTY_HIGH_DEF_AUDIO = 1<<2;
466
467 /**
468 * Connection is using WIFI.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700469 * <p>
470 * Used to indicate that a call is taking place over WIFI versus a carrier network.
471 * <p>
472 * Translates to {@link android.telecom.Call.Details#PROPERTY_WIFI}.
Tyler Gunn720c6642016-03-22 09:02:47 -0700473 */
474 public static final int PROPERTY_WIFI = 1<<3;
475
476 /**
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700477 * When set, indicates that the {@code Connection} does not actually exist locally for the
478 * {@link ConnectionService}.
479 * <p>
480 * Consider, for example, a scenario where a user has two devices with the same phone number.
481 * When a user places a call on one devices, the telephony stack can represent that call on the
482 * other device by adding is to the {@link ConnectionService} with the
Tyler Gunn720c6642016-03-22 09:02:47 -0700483 * {@link #PROPERTY_IS_EXTERNAL_CALL} capability set.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700484 * <p>
485 * An {@link ConnectionService} should not assume that all {@link InCallService}s will handle
486 * external connections. Only those {@link InCallService}s which have the
487 * {@link TelecomManager#METADATA_INCLUDE_EXTERNAL_CALLS} metadata set to {@code true} in its
488 * manifest will see external connections.
489 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700490 public static final int PROPERTY_IS_EXTERNAL_CALL = 1<<4;
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700491
Brad Ebinger15847072016-05-18 11:08:36 -0700492 /**
493 * Indicates that the connection has CDMA Enhanced Voice Privacy enabled.
494 */
495 public static final int PROPERTY_HAS_CDMA_VOICE_PRIVACY = 1<<5;
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700496
Hall Liu9f332c72016-07-14 15:37:37 -0700497 /**
498 * Indicates that the connection represents a downgraded IMS conference.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700499 * <p>
500 * This property is set when an IMS conference undergoes SRVCC and is re-added to Telecom as a
501 * new entity to indicate that the new connection was a conference.
Hall Liu9f332c72016-07-14 15:37:37 -0700502 * @hide
503 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700504 @SystemApi
Hall Liu9f332c72016-07-14 15:37:37 -0700505 public static final int PROPERTY_IS_DOWNGRADED_CONFERENCE = 1<<6;
506
Tyler Gunnf5035432017-01-09 09:43:12 -0800507 /**
508 * Set by the framework to indicate that the {@link Connection} originated from a self-managed
509 * {@link ConnectionService}.
510 * <p>
511 * See {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.
512 */
513 public static final int PROPERTY_SELF_MANAGED = 1<<7;
514
Hall Liu95d55872017-01-25 17:12:49 -0800515 /**
Hall Liuffa4a812017-03-02 16:11:00 -0800516 * Set by the framework to indicate that a connection has an active RTT session associated with
517 * it.
Hall Liu95d55872017-01-25 17:12:49 -0800518 */
519 public static final int PROPERTY_IS_RTT = 1 << 8;
520
Eric Erfanian62706c52017-12-06 16:27:53 -0800521 /**
522 * Set by the framework to indicate that a connection is using assisted dialing.
Tyler Gunn5567d742019-10-31 13:04:37 -0700523 * <p>
524 * This is used for outgoing calls.
525 *
526 * @see TelecomManager#EXTRA_USE_ASSISTED_DIALING
Eric Erfanian62706c52017-12-06 16:27:53 -0800527 */
Tyler Gunnc9503d62020-01-27 10:30:51 -0800528 public static final int PROPERTY_ASSISTED_DIALING = 1 << 9;
Eric Erfanian62706c52017-12-06 16:27:53 -0800529
Tyler Gunn5bd90852018-09-21 09:37:07 -0700530 /**
531 * Set by the framework to indicate that the network has identified a Connection as an emergency
532 * call.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700533 * <p>
534 * This is used for incoming (mobile-terminated) calls to indicate the call is from emergency
535 * services.
Tyler Gunn5bd90852018-09-21 09:37:07 -0700536 */
537 public static final int PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL = 1 << 10;
538
Tyler Gunnac60f952019-05-31 07:23:16 -0700539 /**
540 * Set by the framework to indicate that a Conference or Connection is hosted by a device other
541 * than the current one. Used in scenarios where the conference originator is the remote device
542 * and the current device is a participant of that conference.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700543 * <p>
544 * This property is specific to IMS conference calls originating in Telephony.
Tyler Gunnac60f952019-05-31 07:23:16 -0700545 * @hide
546 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700547 @SystemApi
Tyler Gunnac60f952019-05-31 07:23:16 -0700548 public static final int PROPERTY_REMOTELY_HOSTED = 1 << 11;
549
Ravi Paluri80aa2142019-12-02 11:57:37 +0530550 /**
Grace Jia8587ee52020-07-10 15:42:32 -0700551 * Set by the framework to indicate that a call is an adhoc conference call.
Ravi Paluri80aa2142019-12-02 11:57:37 +0530552 * <p>
Grace Jia8587ee52020-07-10 15:42:32 -0700553 * This is used for outgoing and incoming conference calls.
Ravi Paluri80aa2142019-12-02 11:57:37 +0530554 */
555 public static final int PROPERTY_IS_ADHOC_CONFERENCE = 1 << 12;
556
Sooraj Sasindran64f05b12020-11-18 12:07:10 -0800557 /**
558 * Connection is using cross sim technology.
559 * <p>
560 * Indicates that the {@link Connection} is using a cross sim technology which would
561 * register IMS over internet APN of default data subscription.
562 * <p>
563 */
564 public static final int PROPERTY_CROSS_SIM = 1 << 13;
Ravi Paluri80aa2142019-12-02 11:57:37 +0530565
Tyler Gunn96d6c402015-03-18 12:39:23 -0700566 //**********************************************************************************************
Sooraj Sasindran64f05b12020-11-18 12:07:10 -0800567 // Next PROPERTY value: 1<<14
Tyler Gunn96d6c402015-03-18 12:39:23 -0700568 //**********************************************************************************************
Tyler Gunn068085b2015-02-06 13:56:52 -0800569
Tyler Gunn335ff2e2015-07-30 14:18:33 -0700570 /**
Tyler Gunn1c687622019-12-20 11:08:13 -0800571 * Indicates that the audio codec is currently not specified or is unknown.
allenwtsu2aca9892019-11-25 14:38:21 +0800572 */
allenwtsu2aca9892019-11-25 14:38:21 +0800573 public static final int AUDIO_CODEC_NONE = ImsStreamMediaProfile.AUDIO_QUALITY_NONE; // 0
Tyler Gunn1c687622019-12-20 11:08:13 -0800574 /**
575 * Adaptive Multi-rate audio codec.
576 */
allenwtsu2aca9892019-11-25 14:38:21 +0800577 public static final int AUDIO_CODEC_AMR = ImsStreamMediaProfile.AUDIO_QUALITY_AMR; // 1
Tyler Gunn1c687622019-12-20 11:08:13 -0800578 /**
579 * Adaptive Multi-rate wideband audio codec.
580 */
allenwtsu2aca9892019-11-25 14:38:21 +0800581 public static final int AUDIO_CODEC_AMR_WB = ImsStreamMediaProfile.AUDIO_QUALITY_AMR_WB; // 2
Tyler Gunn1c687622019-12-20 11:08:13 -0800582 /**
583 * Qualcomm code-excited linear prediction 13 kilobit audio codec.
584 */
allenwtsu2aca9892019-11-25 14:38:21 +0800585 public static final int AUDIO_CODEC_QCELP13K = ImsStreamMediaProfile.AUDIO_QUALITY_QCELP13K; //3
Tyler Gunn1c687622019-12-20 11:08:13 -0800586 /**
587 * Enhanced Variable Rate Codec. See 3GPP2 C.S0014-A.
588 */
allenwtsu2aca9892019-11-25 14:38:21 +0800589 public static final int AUDIO_CODEC_EVRC = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC; // 4
Tyler Gunn1c687622019-12-20 11:08:13 -0800590 /**
591 * Enhanced Variable Rate Codec B. Commonly used on CDMA networks.
592 */
allenwtsu2aca9892019-11-25 14:38:21 +0800593 public static final int AUDIO_CODEC_EVRC_B = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_B; // 5
Tyler Gunn1c687622019-12-20 11:08:13 -0800594 /**
595 * Enhanced Variable Rate Wideband Codec. See RFC5188.
596 */
allenwtsu2aca9892019-11-25 14:38:21 +0800597 public static final int AUDIO_CODEC_EVRC_WB = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_WB; // 6
Tyler Gunn1c687622019-12-20 11:08:13 -0800598 /**
599 * Enhanced Variable Rate Narrowband-Wideband Codec.
600 */
allenwtsu2aca9892019-11-25 14:38:21 +0800601 public static final int AUDIO_CODEC_EVRC_NW = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_NW; // 7
Tyler Gunn1c687622019-12-20 11:08:13 -0800602 /**
603 * GSM Enhanced Full-Rate audio codec, also known as GSM-EFR, GSM 06.60, or simply EFR.
604 */
allenwtsu2aca9892019-11-25 14:38:21 +0800605 public static final int AUDIO_CODEC_GSM_EFR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_EFR; // 8
Tyler Gunn1c687622019-12-20 11:08:13 -0800606 /**
607 * GSM Full-Rate audio codec, also known as GSM-FR, GSM 06.10, GSM, or simply FR.
608 */
allenwtsu2aca9892019-11-25 14:38:21 +0800609 public static final int AUDIO_CODEC_GSM_FR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_FR; // 9
Tyler Gunn1c687622019-12-20 11:08:13 -0800610 /**
611 * GSM Half Rate audio codec.
612 */
allenwtsu2aca9892019-11-25 14:38:21 +0800613 public static final int AUDIO_CODEC_GSM_HR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_HR; // 10
Tyler Gunn1c687622019-12-20 11:08:13 -0800614 /**
615 * ITU-T G711U audio codec.
616 */
allenwtsu2aca9892019-11-25 14:38:21 +0800617 public static final int AUDIO_CODEC_G711U = ImsStreamMediaProfile.AUDIO_QUALITY_G711U; // 11
Tyler Gunn1c687622019-12-20 11:08:13 -0800618 /**
619 * ITU-T G723 audio codec.
620 */
allenwtsu2aca9892019-11-25 14:38:21 +0800621 public static final int AUDIO_CODEC_G723 = ImsStreamMediaProfile.AUDIO_QUALITY_G723; // 12
Tyler Gunn1c687622019-12-20 11:08:13 -0800622 /**
623 * ITU-T G711A audio codec.
624 */
allenwtsu2aca9892019-11-25 14:38:21 +0800625 public static final int AUDIO_CODEC_G711A = ImsStreamMediaProfile.AUDIO_QUALITY_G711A; // 13
Tyler Gunn1c687622019-12-20 11:08:13 -0800626 /**
627 * ITU-T G722 audio codec.
628 */
allenwtsu2aca9892019-11-25 14:38:21 +0800629 public static final int AUDIO_CODEC_G722 = ImsStreamMediaProfile.AUDIO_QUALITY_G722; // 14
Tyler Gunn1c687622019-12-20 11:08:13 -0800630 /**
631 * ITU-T G711AB audio codec.
632 */
allenwtsu2aca9892019-11-25 14:38:21 +0800633 public static final int AUDIO_CODEC_G711AB = ImsStreamMediaProfile.AUDIO_QUALITY_G711AB; // 15
Tyler Gunn1c687622019-12-20 11:08:13 -0800634 /**
635 * ITU-T G729 audio codec.
636 */
allenwtsu2aca9892019-11-25 14:38:21 +0800637 public static final int AUDIO_CODEC_G729 = ImsStreamMediaProfile.AUDIO_QUALITY_G729; // 16
Tyler Gunn1c687622019-12-20 11:08:13 -0800638 /**
639 * Enhanced Voice Services Narrowband audio codec. See 3GPP TS 26.441.
640 */
allenwtsu2aca9892019-11-25 14:38:21 +0800641 public static final int AUDIO_CODEC_EVS_NB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_NB; // 17
Tyler Gunn1c687622019-12-20 11:08:13 -0800642 /**
643 * Enhanced Voice Services Wideband audio codec. See 3GPP TS 26.441.
644 */
allenwtsu2aca9892019-11-25 14:38:21 +0800645 public static final int AUDIO_CODEC_EVS_WB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_WB; // 18
Tyler Gunn1c687622019-12-20 11:08:13 -0800646 /**
647 * Enhanced Voice Services Super-Wideband audio codec. See 3GPP TS 26.441.
648 */
allenwtsu2aca9892019-11-25 14:38:21 +0800649 public static final int AUDIO_CODEC_EVS_SWB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_SWB; // 19
Tyler Gunn1c687622019-12-20 11:08:13 -0800650 /**
651 * Enhanced Voice Services Fullband audio codec. See 3GPP TS 26.441.
652 */
allenwtsu2aca9892019-11-25 14:38:21 +0800653 public static final int AUDIO_CODEC_EVS_FB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_FB; // 20
654
Tyler Gunn1c687622019-12-20 11:08:13 -0800655 /**@hide*/
656 @Retention(RetentionPolicy.SOURCE)
657 @IntDef(prefix = "AUDIO_CODEC_", value = {
658 AUDIO_CODEC_NONE,
659 AUDIO_CODEC_AMR,
660 AUDIO_CODEC_AMR_WB,
661 AUDIO_CODEC_QCELP13K,
662 AUDIO_CODEC_EVRC,
663 AUDIO_CODEC_EVRC_B,
664 AUDIO_CODEC_EVRC_WB,
665 AUDIO_CODEC_EVRC_NW,
666 AUDIO_CODEC_GSM_EFR,
667 AUDIO_CODEC_GSM_FR,
668 AUDIO_CODEC_GSM_HR,
669 AUDIO_CODEC_G711U,
670 AUDIO_CODEC_G723,
671 AUDIO_CODEC_G711A,
672 AUDIO_CODEC_G722,
673 AUDIO_CODEC_G711AB,
674 AUDIO_CODEC_G729,
675 AUDIO_CODEC_EVS_NB,
676 AUDIO_CODEC_EVS_SWB,
677 AUDIO_CODEC_EVS_FB
678 })
679 public @interface AudioCodec {}
680
allenwtsu2aca9892019-11-25 14:38:21 +0800681 /**
Tyler Gunn60e5eb62021-07-01 16:55:32 -0700682 * Contains the same value as {@link #getCallerNumberVerificationStatus()}, except will be
683 * present in the {@link #getExtras()} using this key.
684 * @hide
685 */
686 public static final String EXTRA_CALLER_NUMBER_VERIFICATION_STATUS =
687 "android.telecom.extra.CALLER_NUMBER_VERIFICATION_STATUS";
688
689 /**
Tyler Gunn335ff2e2015-07-30 14:18:33 -0700690 * Connection extra key used to store the last forwarded number associated with the current
691 * connection. Used to communicate to the user interface that the connection was forwarded via
692 * the specified number.
693 */
694 public static final String EXTRA_LAST_FORWARDED_NUMBER =
695 "android.telecom.extra.LAST_FORWARDED_NUMBER";
696
697 /**
698 * Connection extra key used to store a child number associated with the current connection.
699 * Used to communicate to the user interface that the connection was received via
700 * a child address (i.e. phone number) associated with the {@link PhoneAccount}'s primary
701 * address.
702 */
703 public static final String EXTRA_CHILD_ADDRESS = "android.telecom.extra.CHILD_ADDRESS";
704
705 /**
706 * Connection extra key used to store the subject for an incoming call. The user interface can
707 * query this extra and display its contents for incoming calls. Will only be used if the
708 * {@link PhoneAccount} supports the capability {@link PhoneAccount#CAPABILITY_CALL_SUBJECT}.
709 */
710 public static final String EXTRA_CALL_SUBJECT = "android.telecom.extra.CALL_SUBJECT";
711
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800712 /**
Tyler Gunn4b6614e2016-06-22 10:35:13 -0700713 * Boolean connection extra key set on a {@link Connection} in
714 * {@link Connection#STATE_RINGING} state to indicate that answering the call will cause the
715 * current active foreground call to be dropped.
716 */
717 public static final String EXTRA_ANSWERING_DROPS_FG_CALL =
718 "android.telecom.extra.ANSWERING_DROPS_FG_CALL";
719
720 /**
Tyler Gunn37653562017-03-13 18:15:15 -0700721 * String connection extra key set on a {@link Connection} in {@link Connection#STATE_RINGING}
722 * state to indicate the name of the third-party app which is responsible for the current
723 * foreground call.
724 * <p>
725 * Used when {@link #EXTRA_ANSWERING_DROPS_FG_CALL} is true to ensure that the default Phone app
726 * is able to inform the user that answering the new incoming call will cause a call owned by
727 * another app to be dropped when the incoming call is answered.
728 */
729 public static final String EXTRA_ANSWERING_DROPS_FG_CALL_APP_NAME =
730 "android.telecom.extra.ANSWERING_DROPS_FG_CALL_APP_NAME";
731
732 /**
Hall Liu10208662016-06-15 17:55:00 -0700733 * Boolean connection extra key on a {@link Connection} which indicates that adding an
Hall Liuee6e86b2016-07-06 16:32:43 -0700734 * additional call is disallowed.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700735 * <p>
736 * Used for mobile-network calls to identify scenarios where carrier requirements preclude
737 * adding another call at the current time.
Hall Liu10208662016-06-15 17:55:00 -0700738 * @hide
739 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700740 @SystemApi
Hall Liuee6e86b2016-07-06 16:32:43 -0700741 public static final String EXTRA_DISABLE_ADD_CALL =
742 "android.telecom.extra.DISABLE_ADD_CALL";
Hall Liu10208662016-06-15 17:55:00 -0700743
744 /**
Tyler Gunncd6ccfd2016-10-17 15:48:19 -0700745 * String connection extra key on a {@link Connection} or {@link Conference} which contains the
746 * original Connection ID associated with the connection. Used in
747 * {@link RemoteConnectionService} to track the Connection ID which was originally assigned to a
748 * connection/conference added via
749 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)} and
750 * {@link ConnectionService#addConference(Conference)} APIs. This is important to pass to
751 * Telecom for when it deals with RemoteConnections. When the ConnectionManager wraps the
752 * {@link RemoteConnection} and {@link RemoteConference} and adds it to Telecom, there needs to
753 * be a way to ensure that we don't add the connection again as a duplicate.
754 * <p>
755 * For example, the TelephonyCS calls addExistingConnection for a Connection with ID
756 * {@code TelephonyCS@1}. The ConnectionManager learns of this via
757 * {@link ConnectionService#onRemoteExistingConnectionAdded(RemoteConnection)}, and wraps this
758 * in a new {@link Connection} which it adds to Telecom via
759 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)}. As part of
760 * this process, the wrapped RemoteConnection gets assigned a new ID (e.g. {@code ConnMan@1}).
761 * The TelephonyCS will ALSO try to add the existing connection to Telecom, except with the
762 * ID it originally referred to the connection as. Thus Telecom needs to know that the
763 * Connection with ID {@code ConnMan@1} is really the same as {@code TelephonyCS@1}.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700764 * <p>
765 * This is an internal Telecom framework concept and is not exposed outside of the Telecom
766 * framework.
Tyler Gunncd6ccfd2016-10-17 15:48:19 -0700767 * @hide
768 */
769 public static final String EXTRA_ORIGINAL_CONNECTION_ID =
770 "android.telecom.extra.ORIGINAL_CONNECTION_ID";
771
772 /**
Tyler Gunnc59fd0c2020-04-17 14:03:35 -0700773 * Extra key set on a {@link Connection} when it was created via a remote connection service.
774 * For example, if a connection manager requests a remote connection service to create a call
775 * using one of the remote connection service's phone account handle, this extra will be set so
776 * that Telecom knows that the wrapped remote connection originated in a remote connection
777 * service. We stash this in the extras since connection managers will typically copy the
778 * extras from a {@link RemoteConnection} to a {@link Connection} (there is ultimately not
779 * other way to relate a {@link RemoteConnection} to a {@link Connection}.
780 * @hide
781 */
782 public static final String EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE =
783 "android.telecom.extra.REMOTE_PHONE_ACCOUNT_HANDLE";
784
785 /**
Tyler Gunnfdc4bff2021-06-24 11:25:07 -0700786 * The Telecom call ID of the conference an existing connection should be added to. This is
787 * required when {@link com.android.services.telephony.TelephonyConnectionService} adds a
788 * {@link Conference} to Telecom using the
789 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection, Conference)}
790 * API. That API specifies a parent conference associated with the new existing connection
791 * being added, and there is no equivalent as part of the {@link RemoteConnectionService} API.
792 * This extra key is used to stack the ID of the conference to which the existing connection
793 * will be added so that Telecom can link it up correctly when the {@link RemoteConference}
794 * is added to Telecom by the connection manager.
795 * @hide
796 */
797 public static final String EXTRA_ADD_TO_CONFERENCE_ID =
798 "android.telecom.extra.ADD_TO_CONFERENCE_ID";
799
800 /**
Tyler Gunnc59fd0c2020-04-17 14:03:35 -0700801 * Extra key set from a {@link ConnectionService} when using the remote connection APIs
802 * (e.g. {@link RemoteConnectionService#createRemoteConnection(PhoneAccountHandle,
803 * ConnectionRequest, boolean)}) to create a remote connection. Provides the receiving
804 * {@link ConnectionService} with a means to know the package name of the requesting
805 * {@link ConnectionService} so that {@link #EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE} can be set for
806 * better visibility in Telecom of where a connection ultimately originated.
807 * @hide
808 */
809 public static final String EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME =
810 "android.telecom.extra.REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME";
811
812 /**
Wileen Chiuf2ec2982018-07-01 14:21:50 -0700813 * Boolean connection extra key set on the extras passed to
814 * {@link Connection#sendConnectionEvent} which indicates that audio is present
815 * on the RTT call when the extra value is true.
816 */
817 public static final String EXTRA_IS_RTT_AUDIO_PRESENT =
818 "android.telecom.extra.IS_RTT_AUDIO_PRESENT";
819
820 /**
Tyler Gunn1c687622019-12-20 11:08:13 -0800821 * The audio codec in use for the current {@link Connection}, if known. Examples of valid
822 * values include {@link #AUDIO_CODEC_AMR_WB} and {@link #AUDIO_CODEC_EVS_WB}.
allenwtsu2aca9892019-11-25 14:38:21 +0800823 */
Tyler Gunn1c687622019-12-20 11:08:13 -0800824 public static final @AudioCodec String EXTRA_AUDIO_CODEC =
allenwtsu2aca9892019-11-25 14:38:21 +0800825 "android.telecom.extra.AUDIO_CODEC";
826
827 /**
allenwtsu6ec972a2020-11-10 17:32:46 +0800828 * Float connection extra key used to store the audio codec bitrate in kbps for the current
829 * {@link Connection}.
830 */
831 public static final String EXTRA_AUDIO_CODEC_BITRATE_KBPS =
832 "android.telecom.extra.AUDIO_CODEC_BITRATE_KBPS";
833
834 /**
835 * Float connection extra key used to store the audio codec bandwidth in khz for the current
836 * {@link Connection}.
837 */
838 public static final String EXTRA_AUDIO_CODEC_BANDWIDTH_KHZ =
839 "android.telecom.extra.AUDIO_CODEC_BANDWIDTH_KHZ";
Tyler Gunn78a59ff2021-05-07 16:41:19 -0700840
841 /**
Sooraj Sasindran065b77d2022-02-24 00:14:51 -0800842 * Last known cell identity key {@link CellIdentity} to be used to fill geo location header
843 * in case of an emergency call. This entry will not be filled if call is not identified as
844 * an emergency call. Only provided to the {@link ConnectionService} for the purpose of
845 * placing an emergency call; will not be present in the {@link InCallService} layer.
Sooraj Sasindran81be0822021-10-26 02:03:37 -0700846 * The {@link ConnectionService}'s implementation will be logged for fine location access
847 * when an outgoing call is placed in this case.
848 */
849 public static final String EXTRA_LAST_KNOWN_CELL_IDENTITY =
850 "android.telecom.extra.LAST_KNOWN_CELL_IDENTITY";
851
852 /**
Tyler Gunn78a59ff2021-05-07 16:41:19 -0700853 * Boolean connection extra key used to indicate whether device to device communication is
854 * available for the current call.
855 * @hide
856 */
857 public static final String EXTRA_IS_DEVICE_TO_DEVICE_COMMUNICATION_AVAILABLE =
858 "android.telecom.extra.IS_DEVICE_TO_DEVICE_COMMUNICATION_AVAILABLE";
859
allenwtsu6ec972a2020-11-10 17:32:46 +0800860 /**
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800861 * Connection event used to inform Telecom that it should play the on hold tone. This is used
862 * to play a tone when the peer puts the current call on hold. Sent to Telecom via
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700863 * {@link #sendConnectionEvent(String, Bundle)}.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800864 */
865 public static final String EVENT_ON_HOLD_TONE_START =
866 "android.telecom.event.ON_HOLD_TONE_START";
867
868 /**
869 * Connection event used to inform Telecom that it should stop the on hold tone. This is used
870 * to stop a tone when the peer puts the current call on hold. Sent to Telecom via
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700871 * {@link #sendConnectionEvent(String, Bundle)}.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800872 */
873 public static final String EVENT_ON_HOLD_TONE_END =
874 "android.telecom.event.ON_HOLD_TONE_END";
875
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700876 /**
877 * Connection event used to inform {@link InCallService}s when pulling of an external call has
878 * failed. The user interface should inform the user of the error.
879 * <p>
880 * Expected to be used by the {@link ConnectionService} when the {@link Call#pullExternalCall()}
881 * API is called on a {@link Call} with the properties
882 * {@link Call.Details#PROPERTY_IS_EXTERNAL_CALL} and
883 * {@link Call.Details#CAPABILITY_CAN_PULL_CALL}, but the {@link ConnectionService} could not
884 * pull the external call due to an error condition.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700885 * <p>
886 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
887 * expected to be null when this connection event is used.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700888 */
889 public static final String EVENT_CALL_PULL_FAILED = "android.telecom.event.CALL_PULL_FAILED";
890
Brad Ebinger2c1c16452016-05-27 15:58:10 -0700891 /**
892 * Connection event used to inform {@link InCallService}s when the merging of two calls has
893 * failed. The User Interface should use this message to inform the user of the error.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700894 * <p>
895 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
896 * expected to be null when this connection event is used.
Brad Ebinger2c1c16452016-05-27 15:58:10 -0700897 */
898 public static final String EVENT_CALL_MERGE_FAILED = "android.telecom.event.CALL_MERGE_FAILED";
899
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700900 /**
Hall Liu06ae75b2019-03-11 19:11:35 -0700901 * Connection event used to inform Telecom when a hold operation on a call has failed.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700902 * <p>
Hall Liu06ae75b2019-03-11 19:11:35 -0700903 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
904 * expected to be null when this connection event is used.
Hall Liu06ae75b2019-03-11 19:11:35 -0700905 */
906 public static final String EVENT_CALL_HOLD_FAILED = "android.telecom.event.CALL_HOLD_FAILED";
907
908 /**
Masaho Nishikawacb8fa742019-11-07 14:41:21 +0900909 * Connection event used to inform Telecom when a switch operation on a call has failed.
910 * <p>
911 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
912 * expected to be null when this connection event is used.
913 */
914 public static final String EVENT_CALL_SWITCH_FAILED =
915 "android.telecom.event.CALL_SWITCH_FAILED";
916
917 /**
Tyler Gunn78da7812017-05-09 14:34:57 -0700918 * Connection event used to inform {@link InCallService}s when the process of merging a
919 * Connection into a conference has begun.
920 * <p>
921 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
922 * expected to be null when this connection event is used.
Tyler Gunn78da7812017-05-09 14:34:57 -0700923 */
924 public static final String EVENT_MERGE_START = "android.telecom.event.MERGE_START";
925
926 /**
927 * Connection event used to inform {@link InCallService}s when the process of merging a
928 * Connection into a conference has completed.
929 * <p>
930 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
931 * expected to be null when this connection event is used.
Tyler Gunn78da7812017-05-09 14:34:57 -0700932 */
933 public static final String EVENT_MERGE_COMPLETE = "android.telecom.event.MERGE_COMPLETE";
934
935 /**
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700936 * Connection event used to inform {@link InCallService}s when a call has been put on hold by
937 * the remote party.
938 * <p>
939 * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the
940 * call is being held locally on the device. When a capable {@link ConnectionService} receives
941 * signalling to indicate that the remote party has put the call on hold, it can send this
942 * connection event.
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700943 */
944 public static final String EVENT_CALL_REMOTELY_HELD =
945 "android.telecom.event.CALL_REMOTELY_HELD";
946
947 /**
948 * Connection event used to inform {@link InCallService}s when a call which was remotely held
949 * (see {@link #EVENT_CALL_REMOTELY_HELD}) has been un-held by the remote party.
950 * <p>
951 * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the
952 * call is being held locally on the device. When a capable {@link ConnectionService} receives
953 * signalling to indicate that the remote party has taken the call off hold, it can send this
954 * connection event.
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700955 */
956 public static final String EVENT_CALL_REMOTELY_UNHELD =
957 "android.telecom.event.CALL_REMOTELY_UNHELD";
958
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700959 /**
960 * Connection event used to inform an {@link InCallService} which initiated a call handover via
961 * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has
962 * successfully completed.
963 * @hide
Tyler Gunn1a505fa2018-09-14 13:36:38 -0700964 * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated
965 * APIs instead.
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700966 */
967 public static final String EVENT_HANDOVER_COMPLETE =
968 "android.telecom.event.HANDOVER_COMPLETE";
969
970 /**
971 * Connection event used to inform an {@link InCallService} which initiated a call handover via
972 * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has failed
973 * to complete.
974 * @hide
Tyler Gunn1a505fa2018-09-14 13:36:38 -0700975 * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated
976 * APIs instead.
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700977 */
978 public static final String EVENT_HANDOVER_FAILED =
979 "android.telecom.event.HANDOVER_FAILED";
980
shilub7ec9a02018-11-09 15:52:04 -0800981 /**
Shi Lu528eb5b2019-02-08 05:09:11 +0000982 * String Connection extra key used to store SIP invite fields for an incoming call for IMS call
shilub7ec9a02018-11-09 15:52:04 -0800983 */
984 public static final String EXTRA_SIP_INVITE = "android.telecom.extra.SIP_INVITE";
985
Wileen Chiuf2ec2982018-07-01 14:21:50 -0700986 /**
987 * Connection event used to inform an {@link InCallService} that the RTT audio indication
988 * has changed.
989 */
990 public static final String EVENT_RTT_AUDIO_INDICATION_CHANGED =
991 "android.telecom.event.RTT_AUDIO_INDICATION_CHANGED";
992
Tyler Gunnd5821842021-02-05 11:12:57 -0800993 /**
994 * Connection event used to signal between the telephony {@link ConnectionService} and Telecom
995 * when device to device messages are sent/received.
996 * <p>
997 * Device to device messages originating from the network are sent by telephony using
998 * {@link Connection#sendConnectionEvent(String, Bundle)} and are routed up to any active
999 * {@link CallDiagnosticService} implementation which is active.
1000 * <p>
1001 * Likewise, if a {@link CallDiagnosticService} sends a message using
Tyler Gunn066de602021-03-16 09:58:07 -07001002 * {@link CallDiagnostics#sendDeviceToDeviceMessage(int, int)}, it will be routed to telephony
Tyler Gunnd5821842021-02-05 11:12:57 -08001003 * via {@link Connection#onCallEvent(String, Bundle)}. The telephony stack will relay the
1004 * message to the other device.
1005 * @hide
1006 */
1007 @SystemApi
1008 public static final String EVENT_DEVICE_TO_DEVICE_MESSAGE =
1009 "android.telecom.event.DEVICE_TO_DEVICE_MESSAGE";
1010
1011 /**
1012 * Sent along with {@link #EVENT_DEVICE_TO_DEVICE_MESSAGE} to indicate the device to device
1013 * message type.
1014 *
Tyler Gunn066de602021-03-16 09:58:07 -07001015 * See {@link CallDiagnostics} for more information.
Tyler Gunnd5821842021-02-05 11:12:57 -08001016 * @hide
1017 */
1018 @SystemApi
1019 public static final String EXTRA_DEVICE_TO_DEVICE_MESSAGE_TYPE =
1020 "android.telecom.extra.DEVICE_TO_DEVICE_MESSAGE_TYPE";
1021
1022 /**
1023 * Sent along with {@link #EVENT_DEVICE_TO_DEVICE_MESSAGE} to indicate the device to device
1024 * message value.
1025 * <p>
Tyler Gunn066de602021-03-16 09:58:07 -07001026 * See {@link CallDiagnostics} for more information.
Tyler Gunnd5821842021-02-05 11:12:57 -08001027 * @hide
1028 */
1029 @SystemApi
1030 public static final String EXTRA_DEVICE_TO_DEVICE_MESSAGE_VALUE =
1031 "android.telecom.extra.DEVICE_TO_DEVICE_MESSAGE_VALUE";
1032
Tyler Gunn0a1c6d12021-03-12 15:44:08 -08001033 /**
1034 * Connection event used to communicate a {@link android.telephony.CallQuality} report from
1035 * telephony to Telecom for relaying to
1036 * {@link DiagnosticCall#onCallQualityReceived(CallQuality)}.
1037 * @hide
1038 */
1039 public static final String EVENT_CALL_QUALITY_REPORT =
1040 "android.telecom.event.CALL_QUALITY_REPORT";
1041
1042 /**
1043 * Extra sent with {@link #EVENT_CALL_QUALITY_REPORT} containing the
1044 * {@link android.telephony.CallQuality} data.
1045 * @hide
1046 */
1047 public static final String EXTRA_CALL_QUALITY_REPORT =
1048 "android.telecom.extra.CALL_QUALITY_REPORT";
1049
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001050 // Flag controlling whether PII is emitted into the logs
1051 private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG);
1052
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001053 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07001054 * Renders a set of capability bits ({@code CAPABILITY_*}) as a human readable string.
1055 *
1056 * @param capabilities A capability bit field.
1057 * @return A human readable string representation.
1058 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001059 public static String capabilitiesToString(int capabilities) {
Santos Cordon1a749302016-07-26 16:08:53 -07001060 return capabilitiesToStringInternal(capabilities, true /* isLong */);
1061 }
1062
1063 /**
1064 * Renders a set of capability bits ({@code CAPABILITY_*}) as a *short* human readable
1065 * string.
1066 *
1067 * @param capabilities A capability bit field.
1068 * @return A human readable string representation.
1069 * @hide
1070 */
1071 public static String capabilitiesToStringShort(int capabilities) {
1072 return capabilitiesToStringInternal(capabilities, false /* isLong */);
1073 }
1074
1075 private static String capabilitiesToStringInternal(int capabilities, boolean isLong) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001076 StringBuilder builder = new StringBuilder();
Santos Cordon1a749302016-07-26 16:08:53 -07001077 builder.append("[");
1078 if (isLong) {
1079 builder.append("Capabilities:");
1080 }
1081
Tyler Gunnc63f9082019-10-15 13:19:26 -07001082 if ((capabilities & CAPABILITY_HOLD) == CAPABILITY_HOLD) {
Santos Cordon1a749302016-07-26 16:08:53 -07001083 builder.append(isLong ? " CAPABILITY_HOLD" : " hld");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001084 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001085 if ((capabilities & CAPABILITY_SUPPORT_HOLD) == CAPABILITY_SUPPORT_HOLD) {
Santos Cordon1a749302016-07-26 16:08:53 -07001086 builder.append(isLong ? " CAPABILITY_SUPPORT_HOLD" : " sup_hld");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001087 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001088 if ((capabilities & CAPABILITY_MERGE_CONFERENCE) == CAPABILITY_MERGE_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001089 builder.append(isLong ? " CAPABILITY_MERGE_CONFERENCE" : " mrg_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001090 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001091 if ((capabilities & CAPABILITY_SWAP_CONFERENCE) == CAPABILITY_SWAP_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001092 builder.append(isLong ? " CAPABILITY_SWAP_CONFERENCE" : " swp_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001093 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001094 if ((capabilities & CAPABILITY_RESPOND_VIA_TEXT) == CAPABILITY_RESPOND_VIA_TEXT) {
Santos Cordon1a749302016-07-26 16:08:53 -07001095 builder.append(isLong ? " CAPABILITY_RESPOND_VIA_TEXT" : " txt");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001096 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001097 if ((capabilities & CAPABILITY_MUTE) == CAPABILITY_MUTE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001098 builder.append(isLong ? " CAPABILITY_MUTE" : " mut");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001099 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001100 if ((capabilities & CAPABILITY_MANAGE_CONFERENCE) == CAPABILITY_MANAGE_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001101 builder.append(isLong ? " CAPABILITY_MANAGE_CONFERENCE" : " mng_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001102 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001103 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_RX) == CAPABILITY_SUPPORTS_VT_LOCAL_RX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001104 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_RX" : " VTlrx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001105 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001106 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_TX) == CAPABILITY_SUPPORTS_VT_LOCAL_TX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001107 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_TX" : " VTltx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001108 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001109 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL)
1110 == CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001111 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL" : " VTlbi");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001112 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001113 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_RX) == CAPABILITY_SUPPORTS_VT_REMOTE_RX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001114 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_RX" : " VTrrx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001115 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001116 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_TX) == CAPABILITY_SUPPORTS_VT_REMOTE_TX) {
Santos Cordon1a749302016-07-26 16:08:53 -07001117 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_TX" : " VTrtx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -07001118 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001119 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL)
1120 == CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001121 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL" : " VTrbi");
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001122 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001123 if ((capabilities & CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO)
1124 == CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001125 builder.append(isLong ? " CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO" : " !v2a");
Tyler Gunnf97a0092016-01-19 15:59:34 -08001126 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001127 if ((capabilities & CAPABILITY_SPEED_UP_MT_AUDIO) == CAPABILITY_SPEED_UP_MT_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001128 builder.append(isLong ? " CAPABILITY_SPEED_UP_MT_AUDIO" : " spd_aud");
Dong Zhou89f41eb2015-03-15 11:59:49 -05001129 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001130 if ((capabilities & CAPABILITY_CAN_UPGRADE_TO_VIDEO) == CAPABILITY_CAN_UPGRADE_TO_VIDEO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001131 builder.append(isLong ? " CAPABILITY_CAN_UPGRADE_TO_VIDEO" : " a2v");
Rekha Kumar07366812015-03-24 16:42:31 -07001132 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001133 if ((capabilities & CAPABILITY_CAN_PAUSE_VIDEO) == CAPABILITY_CAN_PAUSE_VIDEO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001134 builder.append(isLong ? " CAPABILITY_CAN_PAUSE_VIDEO" : " paus_VT");
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -07001135 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001136 if ((capabilities & CAPABILITY_CONFERENCE_HAS_NO_CHILDREN)
1137 == CAPABILITY_CONFERENCE_HAS_NO_CHILDREN) {
Santos Cordon1a749302016-07-26 16:08:53 -07001138 builder.append(isLong ? " CAPABILITY_SINGLE_PARTY_CONFERENCE" : " 1p_cnf");
Tyler Gunnd4091732015-06-29 09:15:37 -07001139 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001140 if ((capabilities & CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION)
1141 == CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION) {
Santos Cordon1a749302016-07-26 16:08:53 -07001142 builder.append(isLong ? " CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION" : " rsp_by_con");
Bryce Lee81901682015-08-28 16:38:02 -07001143 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001144 if ((capabilities & CAPABILITY_CAN_PULL_CALL) == CAPABILITY_CAN_PULL_CALL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001145 builder.append(isLong ? " CAPABILITY_CAN_PULL_CALL" : " pull");
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001146 }
Tyler Gunnc63f9082019-10-15 13:19:26 -07001147 if ((capabilities & CAPABILITY_SUPPORT_DEFLECT) == CAPABILITY_SUPPORT_DEFLECT) {
Pooja Jaind34698d2017-12-28 14:15:31 +05301148 builder.append(isLong ? " CAPABILITY_SUPPORT_DEFLECT" : " sup_def");
1149 }
Ravi Paluri404babb2020-01-23 19:02:44 +05301150 if ((capabilities & CAPABILITY_ADD_PARTICIPANT) == CAPABILITY_ADD_PARTICIPANT) {
1151 builder.append(isLong ? " CAPABILITY_ADD_PARTICIPANT" : " add_participant");
1152 }
Ravi Palurif4b38e72020-02-05 12:35:41 +05301153 if ((capabilities & CAPABILITY_TRANSFER) == CAPABILITY_TRANSFER) {
1154 builder.append(isLong ? " CAPABILITY_TRANSFER" : " sup_trans");
1155 }
1156 if ((capabilities & CAPABILITY_TRANSFER_CONSULTATIVE)
1157 == CAPABILITY_TRANSFER_CONSULTATIVE) {
1158 builder.append(isLong ? " CAPABILITY_TRANSFER_CONSULTATIVE" : " sup_cTrans");
1159 }
Alvin Dey2f37d772018-05-18 23:16:10 +05301160 if ((capabilities & CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT)
1161 == CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT) {
1162 builder.append(isLong ? " CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT" : " sup_rtt");
1163 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001164 builder.append("]");
1165 return builder.toString();
1166 }
1167
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07001168 /**
1169 * Renders a set of property bits ({@code PROPERTY_*}) as a human readable string.
1170 *
1171 * @param properties A property bit field.
1172 * @return A human readable string representation.
1173 */
Tyler Gunn720c6642016-03-22 09:02:47 -07001174 public static String propertiesToString(int properties) {
Santos Cordon1a749302016-07-26 16:08:53 -07001175 return propertiesToStringInternal(properties, true /* isLong */);
1176 }
1177
1178 /**
1179 * Renders a set of property bits ({@code PROPERTY_*}) as a *short* human readable string.
1180 *
1181 * @param properties A property bit field.
1182 * @return A human readable string representation.
1183 * @hide
1184 */
1185 public static String propertiesToStringShort(int properties) {
1186 return propertiesToStringInternal(properties, false /* isLong */);
1187 }
1188
1189 private static String propertiesToStringInternal(int properties, boolean isLong) {
Tyler Gunn720c6642016-03-22 09:02:47 -07001190 StringBuilder builder = new StringBuilder();
Santos Cordon1a749302016-07-26 16:08:53 -07001191 builder.append("[");
1192 if (isLong) {
1193 builder.append("Properties:");
1194 }
Tyler Gunn720c6642016-03-22 09:02:47 -07001195
Tyler Gunnc63f9082019-10-15 13:19:26 -07001196 if ((properties & PROPERTY_SELF_MANAGED) == PROPERTY_SELF_MANAGED) {
Tyler Gunnf5035432017-01-09 09:43:12 -08001197 builder.append(isLong ? " PROPERTY_SELF_MANAGED" : " self_mng");
1198 }
1199
Tyler Gunnc63f9082019-10-15 13:19:26 -07001200 if ((properties & PROPERTY_EMERGENCY_CALLBACK_MODE) == PROPERTY_EMERGENCY_CALLBACK_MODE) {
Hall Liu25c7c4d2016-08-30 13:41:02 -07001201 builder.append(isLong ? " PROPERTY_EMERGENCY_CALLBACK_MODE" : " ecbm");
Tyler Gunn720c6642016-03-22 09:02:47 -07001202 }
1203
Tyler Gunnc63f9082019-10-15 13:19:26 -07001204 if ((properties & PROPERTY_HIGH_DEF_AUDIO) == PROPERTY_HIGH_DEF_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -07001205 builder.append(isLong ? " PROPERTY_HIGH_DEF_AUDIO" : " HD");
Tyler Gunn720c6642016-03-22 09:02:47 -07001206 }
1207
Tyler Gunnc63f9082019-10-15 13:19:26 -07001208 if ((properties & PROPERTY_WIFI) == PROPERTY_WIFI) {
Santos Cordon1a749302016-07-26 16:08:53 -07001209 builder.append(isLong ? " PROPERTY_WIFI" : " wifi");
Tyler Gunn720c6642016-03-22 09:02:47 -07001210 }
1211
Tyler Gunnc63f9082019-10-15 13:19:26 -07001212 if ((properties & PROPERTY_GENERIC_CONFERENCE) == PROPERTY_GENERIC_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -07001213 builder.append(isLong ? " PROPERTY_GENERIC_CONFERENCE" : " gen_conf");
Tyler Gunn720c6642016-03-22 09:02:47 -07001214 }
1215
Tyler Gunnc63f9082019-10-15 13:19:26 -07001216 if ((properties & PROPERTY_IS_EXTERNAL_CALL) == PROPERTY_IS_EXTERNAL_CALL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001217 builder.append(isLong ? " PROPERTY_IS_EXTERNAL_CALL" : " xtrnl");
Tyler Gunn720c6642016-03-22 09:02:47 -07001218 }
1219
Tyler Gunnc63f9082019-10-15 13:19:26 -07001220 if ((properties & PROPERTY_HAS_CDMA_VOICE_PRIVACY) == PROPERTY_HAS_CDMA_VOICE_PRIVACY) {
Santos Cordon1a749302016-07-26 16:08:53 -07001221 builder.append(isLong ? " PROPERTY_HAS_CDMA_VOICE_PRIVACY" : " priv");
Brad Ebinger15847072016-05-18 11:08:36 -07001222 }
1223
Tyler Gunnc63f9082019-10-15 13:19:26 -07001224 if ((properties & PROPERTY_IS_RTT) == PROPERTY_IS_RTT) {
Hall Liud4d2a8a2018-01-29 17:22:02 -08001225 builder.append(isLong ? " PROPERTY_IS_RTT" : " rtt");
1226 }
1227
Tyler Gunnc63f9082019-10-15 13:19:26 -07001228 if ((properties & PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL)
1229 == PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL) {
Tyler Gunn5bd90852018-09-21 09:37:07 -07001230 builder.append(isLong ? " PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL" : " ecall");
1231 }
1232
Tyler Gunnc63f9082019-10-15 13:19:26 -07001233 if ((properties & PROPERTY_REMOTELY_HOSTED) == PROPERTY_REMOTELY_HOSTED) {
Tyler Gunnac60f952019-05-31 07:23:16 -07001234 builder.append(isLong ? " PROPERTY_REMOTELY_HOSTED" : " remote_hst");
1235 }
1236
Ravi Paluri80aa2142019-12-02 11:57:37 +05301237 if ((properties & PROPERTY_IS_ADHOC_CONFERENCE) == PROPERTY_IS_ADHOC_CONFERENCE) {
1238 builder.append(isLong ? " PROPERTY_IS_ADHOC_CONFERENCE" : " adhoc_conf");
1239 }
1240
Hall Liue0f787c2020-07-08 11:25:56 -07001241 if ((properties & PROPERTY_IS_DOWNGRADED_CONFERENCE) == PROPERTY_IS_DOWNGRADED_CONFERENCE) {
1242 builder.append(isLong ? " PROPERTY_IS_DOWNGRADED_CONFERENCE" : " dngrd_conf");
1243 }
1244
Tyler Gunn720c6642016-03-22 09:02:47 -07001245 builder.append("]");
1246 return builder.toString();
1247 }
1248
Sailesh Nepal091768c2014-06-30 15:15:23 -07001249 /** @hide */
Tyler Gunn633e4c32019-10-24 15:40:48 -07001250 abstract static class Listener {
Ihab Awad542e0ea2014-05-16 10:22:16 -07001251 public void onStateChanged(Connection c, int state) {}
Andrew Lee100e2932014-09-08 15:34:24 -07001252 public void onAddressChanged(Connection c, Uri newAddress, int presentation) {}
Sailesh Nepal61203862014-07-11 14:50:13 -07001253 public void onCallerDisplayNameChanged(
1254 Connection c, String callerDisplayName, int presentation) {}
Tyler Gunnaa07df82014-07-17 07:50:22 -07001255 public void onVideoStateChanged(Connection c, int videoState) {}
Andrew Lee7f3d41f2014-09-11 17:33:16 -07001256 public void onDisconnected(Connection c, DisconnectCause disconnectCause) {}
Sailesh Nepal091768c2014-06-30 15:15:23 -07001257 public void onPostDialWait(Connection c, String remaining) {}
Nancy Chen27d1c2d2014-12-15 16:12:50 -08001258 public void onPostDialChar(Connection c, char nextChar) {}
Andrew Lee100e2932014-09-08 15:34:24 -07001259 public void onRingbackRequested(Connection c, boolean ringback) {}
Sailesh Nepal61203862014-07-11 14:50:13 -07001260 public void onDestroyed(Connection c) {}
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001261 public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {}
Tyler Gunn720c6642016-03-22 09:02:47 -07001262 public void onConnectionPropertiesChanged(Connection c, int properties) {}
Christine Hallstrom2830ce92016-11-30 16:06:42 -08001263 public void onSupportedAudioRoutesChanged(Connection c, int supportedAudioRoutes) {}
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001264 public void onVideoProviderChanged(
1265 Connection c, VideoProvider videoProvider) {}
Sailesh Nepal001bbbb2014-07-15 14:40:39 -07001266 public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {}
1267 public void onStatusHintsChanged(Connection c, StatusHints statusHints) {}
Tyler Gunn6d76ca02014-11-17 15:49:51 -08001268 public void onConferenceablesChanged(
Tyler Gunndf2cbc82015-04-20 09:13:01 -07001269 Connection c, List<Conferenceable> conferenceables) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -07001270 public void onConferenceChanged(Connection c, Conference conference) {}
Anthony Lee17455a32015-04-24 15:25:29 -07001271 public void onConferenceMergeFailed(Connection c) {}
Santos Cordon6b7f9552015-05-27 17:21:45 -07001272 public void onExtrasChanged(Connection c, Bundle extras) {}
Tyler Gunndee56a82016-03-23 16:06:34 -07001273 public void onExtrasRemoved(Connection c, List<String> keys) {}
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001274 public void onConnectionEvent(Connection c, String event, Bundle extras) {}
Hall Liua98f58b52017-11-07 17:59:28 -08001275 public void onAudioRouteChanged(Connection c, int audioRoute, String bluetoothAddress) {}
Hall Liub64ac4c2017-02-06 10:49:48 -08001276 public void onRttInitiationSuccess(Connection c) {}
1277 public void onRttInitiationFailure(Connection c, int reason) {}
1278 public void onRttSessionRemotelyTerminated(Connection c) {}
1279 public void onRemoteRttRequest(Connection c) {}
Srikanth Chintalafcb15012017-05-04 20:58:34 +05301280 /** @hide */
1281 public void onPhoneAccountChanged(Connection c, PhoneAccountHandle pHandle) {}
Mengjun Leng25707742017-07-04 11:10:37 +08001282 public void onConnectionTimeReset(Connection c) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07001283 }
1284
Tyler Gunnb702ef82015-05-29 11:51:53 -07001285 /**
Hall Liu95d55872017-01-25 17:12:49 -08001286 * Provides methods to read and write RTT data to/from the in-call app.
Hall Liu95d55872017-01-25 17:12:49 -08001287 */
1288 public static final class RttTextStream {
1289 private static final int READ_BUFFER_SIZE = 1000;
1290 private final InputStreamReader mPipeFromInCall;
1291 private final OutputStreamWriter mPipeToInCall;
Hall Liub64ac4c2017-02-06 10:49:48 -08001292 private final ParcelFileDescriptor mFdFromInCall;
1293 private final ParcelFileDescriptor mFdToInCall;
Hall Liu17eb1bd2018-07-03 15:17:41 -07001294
1295 private final FileInputStream mFromInCallFileInputStream;
Hall Liu95d55872017-01-25 17:12:49 -08001296 private char[] mReadBuffer = new char[READ_BUFFER_SIZE];
1297
1298 /**
1299 * @hide
1300 */
1301 public RttTextStream(ParcelFileDescriptor toInCall, ParcelFileDescriptor fromInCall) {
Hall Liub64ac4c2017-02-06 10:49:48 -08001302 mFdFromInCall = fromInCall;
1303 mFdToInCall = toInCall;
Hall Liu17eb1bd2018-07-03 15:17:41 -07001304 mFromInCallFileInputStream = new FileInputStream(fromInCall.getFileDescriptor());
Hall Liu730a2592018-06-25 19:48:33 -07001305
1306 // Wrap the FileInputStream in a Channel so that it's interruptible.
Hall Liu95d55872017-01-25 17:12:49 -08001307 mPipeFromInCall = new InputStreamReader(
Hall Liu17eb1bd2018-07-03 15:17:41 -07001308 Channels.newInputStream(Channels.newChannel(mFromInCallFileInputStream)));
Hall Liu95d55872017-01-25 17:12:49 -08001309 mPipeToInCall = new OutputStreamWriter(
Hall Liua549fed2018-02-09 16:40:03 -08001310 new FileOutputStream(toInCall.getFileDescriptor()));
Hall Liu95d55872017-01-25 17:12:49 -08001311 }
1312
1313 /**
1314 * Writes the string {@param input} into the text stream to the UI for this RTT call. Since
1315 * RTT transmits text in real-time, this method should be called as often as text snippets
1316 * are received from the remote user, even if it is only one character.
Hall Liua549fed2018-02-09 16:40:03 -08001317 * <p>
Hall Liu95d55872017-01-25 17:12:49 -08001318 * This method is not thread-safe -- calling it from multiple threads simultaneously may
1319 * lead to interleaved text.
Hall Liua549fed2018-02-09 16:40:03 -08001320 *
Hall Liu95d55872017-01-25 17:12:49 -08001321 * @param input The message to send to the in-call app.
1322 */
1323 public void write(String input) throws IOException {
1324 mPipeToInCall.write(input);
1325 mPipeToInCall.flush();
1326 }
1327
1328
1329 /**
1330 * Reads a string from the in-call app, blocking if there is no data available. Returns
1331 * {@code null} if the RTT conversation has been terminated and there is no further data
1332 * to read.
Hall Liua549fed2018-02-09 16:40:03 -08001333 * <p>
Hall Liu95d55872017-01-25 17:12:49 -08001334 * This method is not thread-safe -- calling it from multiple threads simultaneously may
1335 * lead to interleaved text.
Hall Liua549fed2018-02-09 16:40:03 -08001336 *
Hall Liu95d55872017-01-25 17:12:49 -08001337 * @return A string containing text entered by the user, or {@code null} if the
1338 * conversation has been terminated or if there was an error while reading.
1339 */
Hall Liuffa4a812017-03-02 16:11:00 -08001340 public String read() throws IOException {
1341 int numRead = mPipeFromInCall.read(mReadBuffer, 0, READ_BUFFER_SIZE);
1342 if (numRead < 0) {
1343 return null;
1344 }
1345 return new String(mReadBuffer, 0, numRead);
1346 }
1347
1348 /**
1349 * Non-blocking version of {@link #read()}. Returns {@code null} if there is nothing to
1350 * be read.
Hall Liua549fed2018-02-09 16:40:03 -08001351 *
Hall Liuffa4a812017-03-02 16:11:00 -08001352 * @return A string containing text entered by the user, or {@code null} if the user has
1353 * not entered any new text yet.
1354 */
1355 public String readImmediately() throws IOException {
Hall Liu17eb1bd2018-07-03 15:17:41 -07001356 if (mFromInCallFileInputStream.available() > 0) {
Hall Liuffa4a812017-03-02 16:11:00 -08001357 return read();
1358 } else {
Hall Liu95d55872017-01-25 17:12:49 -08001359 return null;
1360 }
1361 }
Hall Liub64ac4c2017-02-06 10:49:48 -08001362
1363 /** @hide */
1364 public ParcelFileDescriptor getFdFromInCall() {
1365 return mFdFromInCall;
1366 }
1367
1368 /** @hide */
1369 public ParcelFileDescriptor getFdToInCall() {
1370 return mFdToInCall;
1371 }
1372 }
1373
1374 /**
1375 * Provides constants to represent the results of responses to session modify requests sent via
1376 * {@link Call#sendRttRequest()}
1377 */
1378 public static final class RttModifyStatus {
Hall Liu8dd49082017-04-21 14:33:12 -07001379 private RttModifyStatus() {}
Hall Liub64ac4c2017-02-06 10:49:48 -08001380 /**
1381 * Session modify request was successful.
1382 */
1383 public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1;
1384
1385 /**
1386 * Session modify request failed.
1387 */
1388 public static final int SESSION_MODIFY_REQUEST_FAIL = 2;
1389
1390 /**
1391 * Session modify request ignored due to invalid parameters.
1392 */
1393 public static final int SESSION_MODIFY_REQUEST_INVALID = 3;
1394
1395 /**
1396 * Session modify request timed out.
1397 */
1398 public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4;
1399
1400 /**
1401 * Session modify request rejected by remote user.
1402 */
1403 public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5;
Tyler Gunnb9a04962022-02-17 08:23:54 -08001404
1405
1406 /**@hide*/
1407 @Retention(RetentionPolicy.SOURCE)
1408 @IntDef(prefix = "SESSION_MODIFY_REQUEST_", value = {
1409 SESSION_MODIFY_REQUEST_SUCCESS,
1410 SESSION_MODIFY_REQUEST_FAIL,
1411 SESSION_MODIFY_REQUEST_INVALID,
1412 SESSION_MODIFY_REQUEST_TIMED_OUT,
1413 SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE
1414 })
1415 public @interface RttSessionModifyStatus {}
Hall Liu95d55872017-01-25 17:12:49 -08001416 }
1417
1418 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001419 * Provides a means of controlling the video session associated with a {@link Connection}.
1420 * <p>
1421 * Implementations create a custom subclass of {@link VideoProvider} and the
1422 * {@link ConnectionService} creates an instance sets it on the {@link Connection} using
1423 * {@link Connection#setVideoProvider(VideoProvider)}. Any connection which supports video
1424 * should set the {@link VideoProvider}.
1425 * <p>
1426 * The {@link VideoProvider} serves two primary purposes: it provides a means for Telecom and
1427 * {@link InCallService} implementations to issue requests related to the video session;
1428 * it provides a means for the {@link ConnectionService} to report events and information
1429 * related to the video session to Telecom and the {@link InCallService} implementations.
1430 * <p>
1431 * {@link InCallService} implementations interact with the {@link VideoProvider} via
1432 * {@link android.telecom.InCallService.VideoCall}.
1433 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001434 public static abstract class VideoProvider {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001435 /**
1436 * Video is not being received (no protocol pause was issued).
Tyler Gunnb702ef82015-05-29 11:51:53 -07001437 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001438 */
1439 public static final int SESSION_EVENT_RX_PAUSE = 1;
Evan Charltonbf11f982014-07-20 22:06:28 -07001440
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001441 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001442 * Video reception has resumed after a {@link #SESSION_EVENT_RX_PAUSE}.
1443 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001444 */
1445 public static final int SESSION_EVENT_RX_RESUME = 2;
1446
1447 /**
1448 * Video transmission has begun. This occurs after a negotiated start of video transmission
1449 * when the underlying protocol has actually begun transmitting video to the remote party.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001450 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001451 */
1452 public static final int SESSION_EVENT_TX_START = 3;
1453
1454 /**
1455 * Video transmission has stopped. This occurs after a negotiated stop of video transmission
1456 * when the underlying protocol has actually stopped transmitting video to the remote party.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001457 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001458 */
1459 public static final int SESSION_EVENT_TX_STOP = 4;
1460
1461 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001462 * A camera failure has occurred for the selected camera. The {@link VideoProvider} can use
Tyler Gunnb702ef82015-05-29 11:51:53 -07001463 * this as a cue to inform the user the camera is not available.
1464 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001465 */
1466 public static final int SESSION_EVENT_CAMERA_FAILURE = 5;
1467
1468 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001469 * Issued after {@link #SESSION_EVENT_CAMERA_FAILURE} when the camera is once again ready
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001470 * for operation. The {@link VideoProvider} can use this as a cue to inform the user that
Tyler Gunnb702ef82015-05-29 11:51:53 -07001471 * the camera has become available again.
1472 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001473 */
1474 public static final int SESSION_EVENT_CAMERA_READY = 6;
1475
1476 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001477 * Session event raised by Telecom when
1478 * {@link android.telecom.InCallService.VideoCall#setCamera(String)} is called and the
1479 * caller does not have the necessary {@link android.Manifest.permission#CAMERA} permission.
1480 * @see #handleCallSessionEvent(int)
1481 */
1482 public static final int SESSION_EVENT_CAMERA_PERMISSION_ERROR = 7;
1483
1484 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001485 * Session modify request was successful.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001486 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001487 */
1488 public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1;
1489
1490 /**
1491 * Session modify request failed.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001492 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001493 */
1494 public static final int SESSION_MODIFY_REQUEST_FAIL = 2;
1495
1496 /**
1497 * Session modify request ignored due to invalid parameters.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001498 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001499 */
1500 public static final int SESSION_MODIFY_REQUEST_INVALID = 3;
1501
Rekha Kumar07366812015-03-24 16:42:31 -07001502 /**
1503 * Session modify request timed out.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001504 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Rekha Kumar07366812015-03-24 16:42:31 -07001505 */
1506 public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4;
1507
1508 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001509 * Session modify request rejected by remote user.
1510 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Rekha Kumar07366812015-03-24 16:42:31 -07001511 */
1512 public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5;
1513
Tyler Gunn75958422015-04-15 14:23:42 -07001514 private static final int MSG_ADD_VIDEO_CALLBACK = 1;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001515 private static final int MSG_SET_CAMERA = 2;
1516 private static final int MSG_SET_PREVIEW_SURFACE = 3;
1517 private static final int MSG_SET_DISPLAY_SURFACE = 4;
1518 private static final int MSG_SET_DEVICE_ORIENTATION = 5;
1519 private static final int MSG_SET_ZOOM = 6;
1520 private static final int MSG_SEND_SESSION_MODIFY_REQUEST = 7;
1521 private static final int MSG_SEND_SESSION_MODIFY_RESPONSE = 8;
1522 private static final int MSG_REQUEST_CAMERA_CAPABILITIES = 9;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001523 private static final int MSG_REQUEST_CONNECTION_DATA_USAGE = 10;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001524 private static final int MSG_SET_PAUSE_IMAGE = 11;
Tyler Gunn75958422015-04-15 14:23:42 -07001525 private static final int MSG_REMOVE_VIDEO_CALLBACK = 12;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001526
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001527 private static final String SESSION_EVENT_RX_PAUSE_STR = "RX_PAUSE";
1528 private static final String SESSION_EVENT_RX_RESUME_STR = "RX_RESUME";
1529 private static final String SESSION_EVENT_TX_START_STR = "TX_START";
1530 private static final String SESSION_EVENT_TX_STOP_STR = "TX_STOP";
1531 private static final String SESSION_EVENT_CAMERA_FAILURE_STR = "CAMERA_FAIL";
1532 private static final String SESSION_EVENT_CAMERA_READY_STR = "CAMERA_READY";
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001533 private static final String SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR =
1534 "CAMERA_PERMISSION_ERROR";
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001535 private static final String SESSION_EVENT_UNKNOWN_STR = "UNKNOWN";
1536
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001537 private VideoProvider.VideoProviderHandler mMessageHandler;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001538 private final VideoProvider.VideoProviderBinder mBinder;
Tyler Gunn75958422015-04-15 14:23:42 -07001539
1540 /**
1541 * Stores a list of the video callbacks, keyed by IBinder.
Tyler Gunn84f381b2015-06-12 09:26:45 -07001542 *
1543 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
1544 * load factor before resizing, 1 means we only expect a single thread to
1545 * access the map so make only a single shard
Tyler Gunn75958422015-04-15 14:23:42 -07001546 */
Tyler Gunn84f381b2015-06-12 09:26:45 -07001547 private ConcurrentHashMap<IBinder, IVideoCallback> mVideoCallbacks =
1548 new ConcurrentHashMap<IBinder, IVideoCallback>(8, 0.9f, 1);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001549
1550 /**
1551 * Default handler used to consolidate binder method calls onto a single thread.
1552 */
1553 private final class VideoProviderHandler extends Handler {
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001554 public VideoProviderHandler() {
1555 super();
1556 }
1557
1558 public VideoProviderHandler(Looper looper) {
1559 super(looper);
1560 }
1561
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001562 @Override
1563 public void handleMessage(Message msg) {
1564 switch (msg.what) {
Tyler Gunn75958422015-04-15 14:23:42 -07001565 case MSG_ADD_VIDEO_CALLBACK: {
1566 IBinder binder = (IBinder) msg.obj;
1567 IVideoCallback callback = IVideoCallback.Stub
1568 .asInterface((IBinder) msg.obj);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001569 if (callback == null) {
1570 Log.w(this, "addVideoProvider - skipped; callback is null.");
1571 break;
1572 }
1573
Tyler Gunn75958422015-04-15 14:23:42 -07001574 if (mVideoCallbacks.containsKey(binder)) {
1575 Log.i(this, "addVideoProvider - skipped; already present.");
1576 break;
1577 }
1578 mVideoCallbacks.put(binder, callback);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001579 break;
Tyler Gunn75958422015-04-15 14:23:42 -07001580 }
1581 case MSG_REMOVE_VIDEO_CALLBACK: {
1582 IBinder binder = (IBinder) msg.obj;
1583 IVideoCallback callback = IVideoCallback.Stub
1584 .asInterface((IBinder) msg.obj);
1585 if (!mVideoCallbacks.containsKey(binder)) {
1586 Log.i(this, "removeVideoProvider - skipped; not present.");
1587 break;
1588 }
1589 mVideoCallbacks.remove(binder);
1590 break;
1591 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001592 case MSG_SET_CAMERA:
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001593 {
1594 SomeArgs args = (SomeArgs) msg.obj;
1595 try {
1596 onSetCamera((String) args.arg1);
1597 onSetCamera((String) args.arg1, (String) args.arg2, args.argi1,
Tyler Gunn159f35c2017-03-02 09:28:37 -08001598 args.argi2, args.argi3);
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001599 } finally {
1600 args.recycle();
1601 }
1602 }
1603 break;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001604 case MSG_SET_PREVIEW_SURFACE:
1605 onSetPreviewSurface((Surface) msg.obj);
1606 break;
1607 case MSG_SET_DISPLAY_SURFACE:
1608 onSetDisplaySurface((Surface) msg.obj);
1609 break;
1610 case MSG_SET_DEVICE_ORIENTATION:
1611 onSetDeviceOrientation(msg.arg1);
1612 break;
1613 case MSG_SET_ZOOM:
1614 onSetZoom((Float) msg.obj);
1615 break;
Tyler Gunn45382162015-05-06 08:52:27 -07001616 case MSG_SEND_SESSION_MODIFY_REQUEST: {
1617 SomeArgs args = (SomeArgs) msg.obj;
1618 try {
1619 onSendSessionModifyRequest((VideoProfile) args.arg1,
1620 (VideoProfile) args.arg2);
1621 } finally {
1622 args.recycle();
1623 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001624 break;
Tyler Gunn45382162015-05-06 08:52:27 -07001625 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001626 case MSG_SEND_SESSION_MODIFY_RESPONSE:
1627 onSendSessionModifyResponse((VideoProfile) msg.obj);
1628 break;
1629 case MSG_REQUEST_CAMERA_CAPABILITIES:
1630 onRequestCameraCapabilities();
1631 break;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001632 case MSG_REQUEST_CONNECTION_DATA_USAGE:
1633 onRequestConnectionDataUsage();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001634 break;
1635 case MSG_SET_PAUSE_IMAGE:
Yorke Lee32f24732015-05-12 16:18:03 -07001636 onSetPauseImage((Uri) msg.obj);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001637 break;
1638 default:
1639 break;
1640 }
1641 }
1642 }
1643
1644 /**
1645 * IVideoProvider stub implementation.
1646 */
1647 private final class VideoProviderBinder extends IVideoProvider.Stub {
Tyler Gunn75958422015-04-15 14:23:42 -07001648 public void addVideoCallback(IBinder videoCallbackBinder) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001649 mMessageHandler.obtainMessage(
Tyler Gunn75958422015-04-15 14:23:42 -07001650 MSG_ADD_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget();
1651 }
1652
1653 public void removeVideoCallback(IBinder videoCallbackBinder) {
1654 mMessageHandler.obtainMessage(
1655 MSG_REMOVE_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001656 }
1657
Tyler Gunn159f35c2017-03-02 09:28:37 -08001658 public void setCamera(String cameraId, String callingPackageName,
1659 int targetSdkVersion) {
1660
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001661 SomeArgs args = SomeArgs.obtain();
1662 args.arg1 = cameraId;
1663 // Propagate the calling package; originally determined in
1664 // android.telecom.InCallService.VideoCall#setCamera(String) from the calling
1665 // process.
1666 args.arg2 = callingPackageName;
1667 // Pass along the uid and pid of the calling app; this gets lost when we put the
1668 // message onto the handler. These are required for Telecom to perform a permission
1669 // check to see if the calling app is able to use the camera.
1670 args.argi1 = Binder.getCallingUid();
1671 args.argi2 = Binder.getCallingPid();
Tyler Gunn159f35c2017-03-02 09:28:37 -08001672 // Pass along the target SDK version of the calling InCallService. This is used to
1673 // maintain backwards compatibility of the API for older callers.
1674 args.argi3 = targetSdkVersion;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001675 mMessageHandler.obtainMessage(MSG_SET_CAMERA, args).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001676 }
1677
1678 public void setPreviewSurface(Surface surface) {
1679 mMessageHandler.obtainMessage(MSG_SET_PREVIEW_SURFACE, surface).sendToTarget();
1680 }
1681
1682 public void setDisplaySurface(Surface surface) {
1683 mMessageHandler.obtainMessage(MSG_SET_DISPLAY_SURFACE, surface).sendToTarget();
1684 }
1685
1686 public void setDeviceOrientation(int rotation) {
Rekha Kumar07366812015-03-24 16:42:31 -07001687 mMessageHandler.obtainMessage(
1688 MSG_SET_DEVICE_ORIENTATION, rotation, 0).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001689 }
1690
1691 public void setZoom(float value) {
1692 mMessageHandler.obtainMessage(MSG_SET_ZOOM, value).sendToTarget();
1693 }
1694
Tyler Gunn45382162015-05-06 08:52:27 -07001695 public void sendSessionModifyRequest(VideoProfile fromProfile, VideoProfile toProfile) {
1696 SomeArgs args = SomeArgs.obtain();
1697 args.arg1 = fromProfile;
1698 args.arg2 = toProfile;
1699 mMessageHandler.obtainMessage(MSG_SEND_SESSION_MODIFY_REQUEST, args).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001700 }
1701
1702 public void sendSessionModifyResponse(VideoProfile responseProfile) {
1703 mMessageHandler.obtainMessage(
1704 MSG_SEND_SESSION_MODIFY_RESPONSE, responseProfile).sendToTarget();
1705 }
1706
1707 public void requestCameraCapabilities() {
1708 mMessageHandler.obtainMessage(MSG_REQUEST_CAMERA_CAPABILITIES).sendToTarget();
1709 }
1710
1711 public void requestCallDataUsage() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001712 mMessageHandler.obtainMessage(MSG_REQUEST_CONNECTION_DATA_USAGE).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001713 }
1714
Yorke Lee32f24732015-05-12 16:18:03 -07001715 public void setPauseImage(Uri uri) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001716 mMessageHandler.obtainMessage(MSG_SET_PAUSE_IMAGE, uri).sendToTarget();
1717 }
1718 }
1719
1720 public VideoProvider() {
1721 mBinder = new VideoProvider.VideoProviderBinder();
Tyler Gunn84f381b2015-06-12 09:26:45 -07001722 mMessageHandler = new VideoProvider.VideoProviderHandler(Looper.getMainLooper());
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001723 }
1724
1725 /**
1726 * Creates an instance of the {@link VideoProvider}, specifying the looper to use.
1727 *
1728 * @param looper The looper.
1729 * @hide
1730 */
Mathew Inwood42346d12018-08-01 11:33:05 +01001731 @UnsupportedAppUsage
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001732 public VideoProvider(Looper looper) {
1733 mBinder = new VideoProvider.VideoProviderBinder();
1734 mMessageHandler = new VideoProvider.VideoProviderHandler(looper);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001735 }
1736
1737 /**
1738 * Returns binder object which can be used across IPC methods.
1739 * @hide
1740 */
1741 public final IVideoProvider getInterface() {
1742 return mBinder;
1743 }
1744
1745 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001746 * Sets the camera to be used for the outgoing video.
1747 * <p>
1748 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1749 * camera via
1750 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1751 * <p>
1752 * Sent from the {@link InCallService} via
1753 * {@link InCallService.VideoCall#setCamera(String)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001754 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001755 * @param cameraId The id of the camera (use ids as reported by
1756 * {@link CameraManager#getCameraIdList()}).
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001757 */
1758 public abstract void onSetCamera(String cameraId);
1759
1760 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001761 * Sets the camera to be used for the outgoing video.
1762 * <p>
1763 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1764 * camera via
1765 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1766 * <p>
1767 * This prototype is used internally to ensure that the calling package name, UID and PID
1768 * are sent to Telecom so that can perform a camera permission check on the caller.
1769 * <p>
1770 * Sent from the {@link InCallService} via
1771 * {@link InCallService.VideoCall#setCamera(String)}.
1772 *
1773 * @param cameraId The id of the camera (use ids as reported by
1774 * {@link CameraManager#getCameraIdList()}).
1775 * @param callingPackageName The AppOpps package name of the caller.
1776 * @param callingUid The UID of the caller.
1777 * @param callingPid The PID of the caller.
Tyler Gunn159f35c2017-03-02 09:28:37 -08001778 * @param targetSdkVersion The target SDK version of the caller.
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001779 * @hide
1780 */
1781 public void onSetCamera(String cameraId, String callingPackageName, int callingUid,
Tyler Gunn159f35c2017-03-02 09:28:37 -08001782 int callingPid, int targetSdkVersion) {}
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001783
1784 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001785 * Sets the surface to be used for displaying a preview of what the user's camera is
1786 * currently capturing. When video transmission is enabled, this is the video signal which
1787 * is sent to the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001788 * <p>
1789 * Sent from the {@link InCallService} via
1790 * {@link InCallService.VideoCall#setPreviewSurface(Surface)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001791 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001792 * @param surface The {@link Surface}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001793 */
1794 public abstract void onSetPreviewSurface(Surface surface);
1795
1796 /**
1797 * Sets the surface to be used for displaying the video received from the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001798 * <p>
1799 * Sent from the {@link InCallService} via
1800 * {@link InCallService.VideoCall#setDisplaySurface(Surface)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001801 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001802 * @param surface The {@link Surface}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001803 */
1804 public abstract void onSetDisplaySurface(Surface surface);
1805
1806 /**
1807 * Sets the device orientation, in degrees. Assumes that a standard portrait orientation of
1808 * the device is 0 degrees.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001809 * <p>
1810 * Sent from the {@link InCallService} via
1811 * {@link InCallService.VideoCall#setDeviceOrientation(int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001812 *
1813 * @param rotation The device orientation, in degrees.
1814 */
1815 public abstract void onSetDeviceOrientation(int rotation);
1816
1817 /**
Tyler Gunnc603b462021-06-14 17:24:40 -07001818 * Sets the camera zoom ratio.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001819 * <p>
1820 * Sent from the {@link InCallService} via {@link InCallService.VideoCall#setZoom(float)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001821 *
Tyler Gunnc603b462021-06-14 17:24:40 -07001822 * @param value The camera zoom ratio; for the current camera, should be a value in the
1823 * range defined by
1824 * {@link android.hardware.camera2.CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001825 */
1826 public abstract void onSetZoom(float value);
1827
1828 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001829 * Issues a request to modify the properties of the current video session.
1830 * <p>
1831 * Example scenarios include: requesting an audio-only call to be upgraded to a
1832 * bi-directional video call, turning on or off the user's camera, sending a pause signal
1833 * when the {@link InCallService} is no longer the foreground application.
1834 * <p>
1835 * If the {@link VideoProvider} determines a request to be invalid, it should call
1836 * {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)} to report the
1837 * invalid request back to the {@link InCallService}.
1838 * <p>
1839 * Where a request requires confirmation from the user of the peer device, the
1840 * {@link VideoProvider} must communicate the request to the peer device and handle the
1841 * user's response. {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)}
1842 * is used to inform the {@link InCallService} of the result of the request.
1843 * <p>
1844 * Sent from the {@link InCallService} via
1845 * {@link InCallService.VideoCall#sendSessionModifyRequest(VideoProfile)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001846 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001847 * @param fromProfile The video profile prior to the request.
1848 * @param toProfile The video profile with the requested changes made.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001849 */
Tyler Gunn45382162015-05-06 08:52:27 -07001850 public abstract void onSendSessionModifyRequest(VideoProfile fromProfile,
1851 VideoProfile toProfile);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001852
Tyler Gunnb702ef82015-05-29 11:51:53 -07001853 /**
1854 * Provides a response to a request to change the current video session properties.
1855 * <p>
1856 * For example, if the peer requests and upgrade from an audio-only call to a bi-directional
1857 * video call, could decline the request and keep the call as audio-only.
1858 * In such a scenario, the {@code responseProfile} would have a video state of
1859 * {@link VideoProfile#STATE_AUDIO_ONLY}. If the user had decided to accept the request,
1860 * the video state would be {@link VideoProfile#STATE_BIDIRECTIONAL}.
1861 * <p>
1862 * Sent from the {@link InCallService} via
1863 * {@link InCallService.VideoCall#sendSessionModifyResponse(VideoProfile)} in response to
1864 * a {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)}
1865 * callback.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001866 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001867 * @param responseProfile The response video profile.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001868 */
1869 public abstract void onSendSessionModifyResponse(VideoProfile responseProfile);
1870
1871 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001872 * Issues a request to the {@link VideoProvider} to retrieve the camera capabilities.
1873 * <p>
1874 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1875 * camera via
1876 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1877 * <p>
1878 * Sent from the {@link InCallService} via
1879 * {@link InCallService.VideoCall#requestCameraCapabilities()}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001880 */
1881 public abstract void onRequestCameraCapabilities();
1882
1883 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001884 * Issues a request to the {@link VideoProvider} to retrieve the current data usage for the
1885 * video component of the current {@link Connection}.
1886 * <p>
1887 * The {@link VideoProvider} should respond by communicating current data usage, in bytes,
1888 * via {@link VideoProvider#setCallDataUsage(long)}.
1889 * <p>
1890 * Sent from the {@link InCallService} via
1891 * {@link InCallService.VideoCall#requestCallDataUsage()}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001892 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001893 public abstract void onRequestConnectionDataUsage();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001894
1895 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001896 * Provides the {@link VideoProvider} with the {@link Uri} of an image to be displayed to
1897 * the peer device when the video signal is paused.
1898 * <p>
1899 * Sent from the {@link InCallService} via
1900 * {@link InCallService.VideoCall#setPauseImage(Uri)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001901 *
1902 * @param uri URI of image to display.
1903 */
Yorke Lee32f24732015-05-12 16:18:03 -07001904 public abstract void onSetPauseImage(Uri uri);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001905
1906 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001907 * Used to inform listening {@link InCallService} implementations when the
1908 * {@link VideoProvider} receives a session modification request.
1909 * <p>
1910 * Received by the {@link InCallService} via
1911 * {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)},
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001912 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001913 * @param videoProfile The requested video profile.
1914 * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001915 */
1916 public void receiveSessionModifyRequest(VideoProfile videoProfile) {
Tyler Gunn75958422015-04-15 14:23:42 -07001917 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001918 for (IVideoCallback callback : mVideoCallbacks.values()) {
1919 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001920 callback.receiveSessionModifyRequest(videoProfile);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001921 } catch (RemoteException ignored) {
1922 Log.w(this, "receiveSessionModifyRequest callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001923 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001924 }
1925 }
1926 }
1927
1928 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001929 * Used to inform listening {@link InCallService} implementations when the
1930 * {@link VideoProvider} receives a response to a session modification request.
1931 * <p>
1932 * Received by the {@link InCallService} via
1933 * {@link InCallService.VideoCall.Callback#onSessionModifyResponseReceived(int,
1934 * VideoProfile, VideoProfile)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001935 *
1936 * @param status Status of the session modify request. Valid values are
1937 * {@link VideoProvider#SESSION_MODIFY_REQUEST_SUCCESS},
1938 * {@link VideoProvider#SESSION_MODIFY_REQUEST_FAIL},
Tyler Gunnb702ef82015-05-29 11:51:53 -07001939 * {@link VideoProvider#SESSION_MODIFY_REQUEST_INVALID},
1940 * {@link VideoProvider#SESSION_MODIFY_REQUEST_TIMED_OUT},
1941 * {@link VideoProvider#SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE}
1942 * @param requestedProfile The original request which was sent to the peer device.
1943 * @param responseProfile The actual profile changes agreed to by the peer device.
1944 * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001945 */
1946 public void receiveSessionModifyResponse(int status,
1947 VideoProfile requestedProfile, VideoProfile responseProfile) {
Tyler Gunn75958422015-04-15 14:23:42 -07001948 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001949 for (IVideoCallback callback : mVideoCallbacks.values()) {
1950 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001951 callback.receiveSessionModifyResponse(status, requestedProfile,
1952 responseProfile);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001953 } catch (RemoteException ignored) {
1954 Log.w(this, "receiveSessionModifyResponse callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001955 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001956 }
1957 }
1958 }
1959
1960 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001961 * Used to inform listening {@link InCallService} implementations when the
1962 * {@link VideoProvider} reports a call session event.
1963 * <p>
1964 * Received by the {@link InCallService} via
1965 * {@link InCallService.VideoCall.Callback#onCallSessionEvent(int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001966 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001967 * @param event The event. Valid values are: {@link VideoProvider#SESSION_EVENT_RX_PAUSE},
1968 * {@link VideoProvider#SESSION_EVENT_RX_RESUME},
1969 * {@link VideoProvider#SESSION_EVENT_TX_START},
1970 * {@link VideoProvider#SESSION_EVENT_TX_STOP},
1971 * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE},
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001972 * {@link VideoProvider#SESSION_EVENT_CAMERA_READY},
1973 * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001974 */
1975 public void handleCallSessionEvent(int event) {
Tyler Gunn75958422015-04-15 14:23:42 -07001976 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001977 for (IVideoCallback callback : mVideoCallbacks.values()) {
1978 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001979 callback.handleCallSessionEvent(event);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001980 } catch (RemoteException ignored) {
1981 Log.w(this, "handleCallSessionEvent callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001982 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001983 }
1984 }
1985 }
1986
1987 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001988 * Used to inform listening {@link InCallService} implementations when the dimensions of the
1989 * peer's video have changed.
1990 * <p>
1991 * This could occur if, for example, the peer rotates their device, changing the aspect
1992 * ratio of the video, or if the user switches between the back and front cameras.
1993 * <p>
1994 * Received by the {@link InCallService} via
1995 * {@link InCallService.VideoCall.Callback#onPeerDimensionsChanged(int, int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001996 *
1997 * @param width The updated peer video width.
1998 * @param height The updated peer video height.
1999 */
2000 public void changePeerDimensions(int width, int height) {
Tyler Gunn75958422015-04-15 14:23:42 -07002001 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002002 for (IVideoCallback callback : mVideoCallbacks.values()) {
2003 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002004 callback.changePeerDimensions(width, height);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002005 } catch (RemoteException ignored) {
2006 Log.w(this, "changePeerDimensions callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002007 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002008 }
2009 }
2010 }
2011
2012 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002013 * Used to inform listening {@link InCallService} implementations when the data usage of the
2014 * video associated with the current {@link Connection} has changed.
2015 * <p>
2016 * This could be in response to a preview request via
2017 * {@link #onRequestConnectionDataUsage()}, or as a periodic update by the
Tyler Gunn295f5d72015-06-04 11:08:54 -07002018 * {@link VideoProvider}. Where periodic updates of data usage are provided, they should be
2019 * 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 -07002020 * <p>
2021 * Received by the {@link InCallService} via
2022 * {@link InCallService.VideoCall.Callback#onCallDataUsageChanged(long)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002023 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002024 * @param dataUsage The updated data usage (in bytes). Reported as the cumulative bytes
2025 * used since the start of the call.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002026 */
Yorke Lee32f24732015-05-12 16:18:03 -07002027 public void setCallDataUsage(long dataUsage) {
Tyler Gunn75958422015-04-15 14:23:42 -07002028 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002029 for (IVideoCallback callback : mVideoCallbacks.values()) {
2030 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002031 callback.changeCallDataUsage(dataUsage);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002032 } catch (RemoteException ignored) {
2033 Log.w(this, "setCallDataUsage callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002034 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002035 }
2036 }
2037 }
2038
2039 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002040 * @see #setCallDataUsage(long)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002041 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002042 * @param dataUsage The updated data usage (in byes).
Yorke Lee32f24732015-05-12 16:18:03 -07002043 * @deprecated - Use {@link #setCallDataUsage(long)} instead.
2044 * @hide
2045 */
2046 public void changeCallDataUsage(long dataUsage) {
2047 setCallDataUsage(dataUsage);
2048 }
2049
2050 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002051 * Used to inform listening {@link InCallService} implementations when the capabilities of
2052 * the current camera have changed.
2053 * <p>
2054 * The {@link VideoProvider} should call this in response to
2055 * {@link VideoProvider#onRequestCameraCapabilities()}, or when the current camera is
2056 * changed via {@link VideoProvider#onSetCamera(String)}.
2057 * <p>
2058 * Received by the {@link InCallService} via
2059 * {@link InCallService.VideoCall.Callback#onCameraCapabilitiesChanged(
2060 * VideoProfile.CameraCapabilities)}.
Yorke Lee32f24732015-05-12 16:18:03 -07002061 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002062 * @param cameraCapabilities The new camera capabilities.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002063 */
Yorke Lee400470f2015-05-12 13:31:25 -07002064 public void changeCameraCapabilities(VideoProfile.CameraCapabilities cameraCapabilities) {
Tyler Gunn75958422015-04-15 14:23:42 -07002065 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002066 for (IVideoCallback callback : mVideoCallbacks.values()) {
2067 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002068 callback.changeCameraCapabilities(cameraCapabilities);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002069 } catch (RemoteException ignored) {
2070 Log.w(this, "changeCameraCapabilities callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002071 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002072 }
2073 }
2074 }
Rekha Kumar07366812015-03-24 16:42:31 -07002075
2076 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07002077 * Used to inform listening {@link InCallService} implementations when the video quality
2078 * of the call has changed.
2079 * <p>
2080 * Received by the {@link InCallService} via
2081 * {@link InCallService.VideoCall.Callback#onVideoQualityChanged(int)}.
Rekha Kumar07366812015-03-24 16:42:31 -07002082 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07002083 * @param videoQuality The updated video quality. Valid values:
2084 * {@link VideoProfile#QUALITY_HIGH},
2085 * {@link VideoProfile#QUALITY_MEDIUM},
2086 * {@link VideoProfile#QUALITY_LOW},
2087 * {@link VideoProfile#QUALITY_DEFAULT}.
Rekha Kumar07366812015-03-24 16:42:31 -07002088 */
2089 public void changeVideoQuality(int videoQuality) {
Tyler Gunn75958422015-04-15 14:23:42 -07002090 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07002091 for (IVideoCallback callback : mVideoCallbacks.values()) {
2092 try {
Tyler Gunn75958422015-04-15 14:23:42 -07002093 callback.changeVideoQuality(videoQuality);
Tyler Gunn84f381b2015-06-12 09:26:45 -07002094 } catch (RemoteException ignored) {
2095 Log.w(this, "changeVideoQuality callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07002096 }
Rekha Kumar07366812015-03-24 16:42:31 -07002097 }
2098 }
2099 }
Tyler Gunn6f657ee2016-09-02 09:55:25 -07002100
2101 /**
2102 * Returns a string representation of a call session event.
2103 *
2104 * @param event A call session event passed to {@link #handleCallSessionEvent(int)}.
2105 * @return String representation of the call session event.
2106 * @hide
2107 */
2108 public static String sessionEventToString(int event) {
2109 switch (event) {
2110 case SESSION_EVENT_CAMERA_FAILURE:
2111 return SESSION_EVENT_CAMERA_FAILURE_STR;
2112 case SESSION_EVENT_CAMERA_READY:
2113 return SESSION_EVENT_CAMERA_READY_STR;
2114 case SESSION_EVENT_RX_PAUSE:
2115 return SESSION_EVENT_RX_PAUSE_STR;
2116 case SESSION_EVENT_RX_RESUME:
2117 return SESSION_EVENT_RX_RESUME_STR;
2118 case SESSION_EVENT_TX_START:
2119 return SESSION_EVENT_TX_START_STR;
2120 case SESSION_EVENT_TX_STOP:
2121 return SESSION_EVENT_TX_STOP_STR;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08002122 case SESSION_EVENT_CAMERA_PERMISSION_ERROR:
2123 return SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR;
Tyler Gunn6f657ee2016-09-02 09:55:25 -07002124 default:
2125 return SESSION_EVENT_UNKNOWN_STR + " " + event;
2126 }
2127 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002128 }
2129
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002130 private final Listener mConnectionDeathListener = new Listener() {
2131 @Override
2132 public void onDestroyed(Connection c) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002133 if (mConferenceables.remove(c)) {
2134 fireOnConferenceableConnectionsChanged();
2135 }
2136 }
2137 };
2138
2139 private final Conference.Listener mConferenceDeathListener = new Conference.Listener() {
2140 @Override
2141 public void onDestroyed(Conference c) {
2142 if (mConferenceables.remove(c)) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002143 fireOnConferenceableConnectionsChanged();
2144 }
2145 }
2146 };
2147
Jay Shrauner229e3822014-08-15 09:23:07 -07002148 /**
2149 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
2150 * load factor before resizing, 1 means we only expect a single thread to
2151 * access the map so make only a single shard
2152 */
2153 private final Set<Listener> mListeners = Collections.newSetFromMap(
2154 new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1));
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002155 private final List<Conferenceable> mConferenceables = new ArrayList<>();
2156 private final List<Conferenceable> mUnmodifiableConferenceables =
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002157 Collections.unmodifiableList(mConferenceables);
Santos Cordonb6939982014-06-04 20:20:58 -07002158
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002159 // The internal telecom call ID associated with this connection.
2160 private String mTelecomCallId;
Pengquan Meng70c9885332017-10-02 18:09:03 -07002161 // The PhoneAccountHandle associated with this connection.
2162 private PhoneAccountHandle mPhoneAccountHandle;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002163 private int mState = STATE_NEW;
Yorke Lee4af59352015-05-13 14:14:54 -07002164 private CallAudioState mCallAudioState;
Andrew Lee100e2932014-09-08 15:34:24 -07002165 private Uri mAddress;
2166 private int mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -07002167 private String mCallerDisplayName;
2168 private int mCallerDisplayNamePresentation;
Andrew Lee100e2932014-09-08 15:34:24 -07002169 private boolean mRingbackRequested = false;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002170 private int mConnectionCapabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -07002171 private int mConnectionProperties;
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002172 private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002173 private VideoProvider mVideoProvider;
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002174 private boolean mAudioModeIsVoip;
Roshan Piuse927ec02015-07-15 15:47:21 -07002175 private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002176 private long mConnectElapsedTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002177 private StatusHints mStatusHints;
Tyler Gunnaa07df82014-07-17 07:50:22 -07002178 private int mVideoState;
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002179 private DisconnectCause mDisconnectCause;
Santos Cordon823fd3c2014-08-07 18:35:18 -07002180 private Conference mConference;
2181 private ConnectionService mConnectionService;
Santos Cordon6b7f9552015-05-27 17:21:45 -07002182 private Bundle mExtras;
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002183 private final Object mExtrasLock = new Object();
Tyler Gunn6986a632019-06-25 13:45:32 -07002184 /**
2185 * The direction of the connection; used where an existing connection is created and we need to
2186 * communicate to Telecom whether its incoming or outgoing.
2187 */
2188 private @Call.Details.CallDirection int mCallDirection = Call.Details.DIRECTION_UNKNOWN;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002189
2190 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002191 * Tracks the key set for the extras bundle provided on the last invocation of
2192 * {@link #setExtras(Bundle)}. Used so that on subsequent invocations we can remove any extras
2193 * keys which were set previously but are no longer present in the replacement Bundle.
2194 */
2195 private Set<String> mPreviousExtraKeys;
2196
2197 /**
Tyler Gunnd57d76c2019-09-24 14:53:23 -07002198 * The verification status for an incoming call's phone number.
2199 */
2200 private @VerificationStatus int mCallerNumberVerificationStatus;
2201
2202
2203 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002204 * Create a new Connection.
2205 */
Santos Cordonf2951102014-07-20 19:06:29 -07002206 public Connection() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002207
2208 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002209 * Returns the Telecom internal call ID associated with this connection. Should only be used
2210 * for debugging and tracing purposes.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002211 * <p>
2212 * Note: Access to the Telecom internal call ID is used for logging purposes only; this API is
2213 * provided to facilitate debugging of the Telephony stack only.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002214 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07002215 * @return The Telecom call ID, or {@code null} if it was not set.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002216 * @hide
2217 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002218 @SystemApi
2219 public final @Nullable String getTelecomCallId() {
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002220 return mTelecomCallId;
2221 }
2222
2223 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002224 * @return The address (e.g., phone number) to which this Connection is currently communicating.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002225 */
Andrew Lee100e2932014-09-08 15:34:24 -07002226 public final Uri getAddress() {
2227 return mAddress;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002228 }
2229
2230 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002231 * @return The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002232 * See {@link TelecomManager} for valid values.
Sailesh Nepal61203862014-07-11 14:50:13 -07002233 */
Andrew Lee100e2932014-09-08 15:34:24 -07002234 public final int getAddressPresentation() {
2235 return mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -07002236 }
2237
2238 /**
2239 * @return The caller display name (CNAP).
2240 */
2241 public final String getCallerDisplayName() {
2242 return mCallerDisplayName;
2243 }
2244
2245 /**
Nancy Chen9d568c02014-09-08 14:17:59 -07002246 * @return The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002247 * See {@link TelecomManager} for valid values.
Sailesh Nepal61203862014-07-11 14:50:13 -07002248 */
2249 public final int getCallerDisplayNamePresentation() {
2250 return mCallerDisplayNamePresentation;
2251 }
2252
2253 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002254 * @return The state of this Connection.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002255 */
2256 public final int getState() {
2257 return mState;
2258 }
2259
2260 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002261 * Returns the video state of the connection.
Yorke Lee32f24732015-05-12 16:18:03 -07002262 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
2263 * {@link VideoProfile#STATE_BIDIRECTIONAL},
2264 * {@link VideoProfile#STATE_TX_ENABLED},
2265 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002266 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002267 * @return The video state of the connection.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002268 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002269 public final @VideoProfile.VideoState int getVideoState() {
Tyler Gunnaa07df82014-07-17 07:50:22 -07002270 return mVideoState;
2271 }
2272
2273 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002274 * @return The audio state of the connection, describing how its audio is currently
Ihab Awad542e0ea2014-05-16 10:22:16 -07002275 * being routed by the system. This is {@code null} if this Connection
2276 * does not directly know about its audio state.
Yorke Lee4af59352015-05-13 14:14:54 -07002277 * @deprecated Use {@link #getCallAudioState()} instead.
2278 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -07002279 */
Yorke Lee4af59352015-05-13 14:14:54 -07002280 @SystemApi
2281 @Deprecated
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002282 public final AudioState getAudioState() {
Sailesh Nepal000d38a2015-06-21 10:25:13 -07002283 if (mCallAudioState == null) {
2284 return null;
2285 }
Yorke Lee4af59352015-05-13 14:14:54 -07002286 return new AudioState(mCallAudioState);
2287 }
2288
2289 /**
2290 * @return The audio state of the connection, describing how its audio is currently
2291 * being routed by the system. This is {@code null} if this Connection
2292 * does not directly know about its audio state.
2293 */
2294 public final CallAudioState getCallAudioState() {
2295 return mCallAudioState;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002296 }
2297
2298 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002299 * @return The conference that this connection is a part of. Null if it is not part of any
2300 * conference.
2301 */
2302 public final Conference getConference() {
2303 return mConference;
2304 }
2305
2306 /**
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002307 * Returns whether this connection is requesting that the system play a ringback tone
2308 * on its behalf.
2309 */
Andrew Lee100e2932014-09-08 15:34:24 -07002310 public final boolean isRingbackRequested() {
2311 return mRingbackRequested;
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002312 }
2313
2314 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002315 * @return True if the connection's audio mode is VOIP.
2316 */
2317 public final boolean getAudioModeIsVoip() {
2318 return mAudioModeIsVoip;
2319 }
2320
2321 /**
Roshan Piuse927ec02015-07-15 15:47:21 -07002322 * Retrieves the connection start time of the {@code Connnection}, if specified. A value of
2323 * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
2324 * start time of the conference.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002325 * <p>
2326 * Note: This is an implementation detail specific to IMS conference calls over a mobile
2327 * network.
Roshan Piuse927ec02015-07-15 15:47:21 -07002328 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07002329 * @return The time at which the {@code Connnection} was connected. Will be a value as retrieved
2330 * from {@link System#currentTimeMillis()}.
Roshan Piuse927ec02015-07-15 15:47:21 -07002331 *
2332 * @hide
2333 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002334 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002335 public final @IntRange(from = 0) long getConnectTimeMillis() {
Roshan Piuse927ec02015-07-15 15:47:21 -07002336 return mConnectTimeMillis;
2337 }
2338
2339 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002340 * Retrieves the connection start time of the {@link Connection}, if specified. A value of
2341 * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
Tyler Gunnc9503d62020-01-27 10:30:51 -08002342 * start time of the connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002343 * <p>
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002344 * Based on the value of {@link SystemClock#elapsedRealtime()}, which ensures that wall-clock
2345 * changes do not impact the call duration.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002346 * <p>
2347 * Used internally in Telephony when migrating conference participant data for IMS conferences.
Tyler Gunnc9503d62020-01-27 10:30:51 -08002348 * <p>
2349 * The value returned is the same one set using
2350 * {@link #setConnectionStartElapsedRealtimeMillis(long)}. This value is never updated from
2351 * the Telecom framework, so no permission enforcement occurs when retrieving the value with
2352 * this method.
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002353 *
2354 * @return The time at which the {@link Connection} was connected.
2355 *
2356 * @hide
2357 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002358 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002359 public final @ElapsedRealtimeLong long getConnectionStartElapsedRealtimeMillis() {
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002360 return mConnectElapsedTimeMillis;
2361 }
2362
2363 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002364 * @return The status hints for this connection.
2365 */
2366 public final StatusHints getStatusHints() {
2367 return mStatusHints;
2368 }
2369
2370 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002371 * Returns the extras associated with this connection.
Tyler Gunn2cbe2b52016-05-04 15:48:10 +00002372 * <p>
2373 * Extras should be updated using {@link #putExtras(Bundle)}.
2374 * <p>
2375 * Telecom or an {@link InCallService} can also update the extras via
2376 * {@link android.telecom.Call#putExtras(Bundle)}, and
2377 * {@link Call#removeExtras(List)}.
2378 * <p>
2379 * The connection is notified of changes to the extras made by Telecom or an
2380 * {@link InCallService} by {@link #onExtrasChanged(Bundle)}.
Tyler Gunndee56a82016-03-23 16:06:34 -07002381 *
Santos Cordon6b7f9552015-05-27 17:21:45 -07002382 * @return The extras associated with this connection.
2383 */
2384 public final Bundle getExtras() {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002385 Bundle extras = null;
2386 synchronized (mExtrasLock) {
2387 if (mExtras != null) {
2388 extras = new Bundle(mExtras);
2389 }
2390 }
2391 return extras;
Santos Cordon6b7f9552015-05-27 17:21:45 -07002392 }
2393
2394 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002395 * Assign a listener to be notified of state changes.
2396 *
2397 * @param l A listener.
2398 * @return This Connection.
2399 *
2400 * @hide
2401 */
Tyler Gunn633e4c32019-10-24 15:40:48 -07002402 final Connection addConnectionListener(Listener l) {
Santos Cordond34e5712014-08-05 18:54:03 +00002403 mListeners.add(l);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002404 return this;
2405 }
2406
2407 /**
2408 * Remove a previously assigned listener that was being notified of state changes.
2409 *
2410 * @param l A Listener.
2411 * @return This Connection.
2412 *
2413 * @hide
2414 */
Tyler Gunn633e4c32019-10-24 15:40:48 -07002415 final Connection removeConnectionListener(Listener l) {
Jay Shrauner229e3822014-08-15 09:23:07 -07002416 if (l != null) {
2417 mListeners.remove(l);
2418 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002419 return this;
2420 }
2421
2422 /**
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002423 * @return The {@link DisconnectCause} for this connection.
Evan Charltonbf11f982014-07-20 22:06:28 -07002424 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002425 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002426 return mDisconnectCause;
Evan Charltonbf11f982014-07-20 22:06:28 -07002427 }
2428
2429 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002430 * Sets the telecom call ID associated with this Connection. The Telecom Call ID should be used
2431 * ONLY for debugging purposes.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002432 * <p>
2433 * Note: Access to the Telecom internal call ID is used for logging purposes only; this API is
2434 * provided to facilitate debugging of the Telephony stack only. Changing the ID via this
2435 * method does NOT change any functionality in Telephony or Telecom and impacts only logging.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002436 *
2437 * @param callId The telecom call ID.
2438 * @hide
2439 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002440 @SystemApi
2441 public void setTelecomCallId(@NonNull String callId) {
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002442 mTelecomCallId = callId;
2443 }
2444
2445 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002446 * Inform this Connection that the state of its audio output has been changed externally.
2447 *
2448 * @param state The new audio state.
Sailesh Nepal400cc482014-06-26 12:04:00 -07002449 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -07002450 */
Yorke Lee4af59352015-05-13 14:14:54 -07002451 final void setCallAudioState(CallAudioState state) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002452 checkImmutable();
Ihab Awad60ac30b2014-05-20 22:32:12 -07002453 Log.d(this, "setAudioState %s", state);
Yorke Lee4af59352015-05-13 14:14:54 -07002454 mCallAudioState = state;
2455 onAudioStateChanged(getAudioState());
2456 onCallAudioStateChanged(state);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002457 }
2458
2459 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002460 * @param state An integer value of a {@code STATE_*} constant.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002461 * @return A string representation of the value.
2462 */
2463 public static String stateToString(int state) {
2464 switch (state) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002465 case STATE_INITIALIZING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002466 return "INITIALIZING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002467 case STATE_NEW:
Yorke Leee911c8d2015-07-14 11:39:36 -07002468 return "NEW";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002469 case STATE_RINGING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002470 return "RINGING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002471 case STATE_DIALING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002472 return "DIALING";
Tyler Gunnc96b5e02016-07-07 22:53:57 -07002473 case STATE_PULLING_CALL:
2474 return "PULLING_CALL";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002475 case STATE_ACTIVE:
Yorke Leee911c8d2015-07-14 11:39:36 -07002476 return "ACTIVE";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002477 case STATE_HOLDING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002478 return "HOLDING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002479 case STATE_DISCONNECTED:
Ihab Awad542e0ea2014-05-16 10:22:16 -07002480 return "DISCONNECTED";
2481 default:
Ihab Awad60ac30b2014-05-20 22:32:12 -07002482 Log.wtf(Connection.class, "Unknown state %d", state);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002483 return "UNKNOWN";
2484 }
2485 }
2486
2487 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002488 * Returns the connection's capabilities, as a bit mask of the {@code CAPABILITY_*} constants.
Ihab Awad52a28f62014-06-18 10:26:34 -07002489 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002490 public final int getConnectionCapabilities() {
2491 return mConnectionCapabilities;
Ihab Awad52a28f62014-06-18 10:26:34 -07002492 }
2493
2494 /**
Tyler Gunn720c6642016-03-22 09:02:47 -07002495 * Returns the connection's properties, as a bit mask of the {@code PROPERTY_*} constants.
2496 */
2497 public final int getConnectionProperties() {
2498 return mConnectionProperties;
2499 }
2500
2501 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002502 * Returns the connection's supported audio routes.
2503 *
2504 * @hide
2505 */
2506 public final int getSupportedAudioRoutes() {
2507 return mSupportedAudioRoutes;
2508 }
2509
2510 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002511 * Sets the value of the {@link #getAddress()} property.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002512 *
Andrew Lee100e2932014-09-08 15:34:24 -07002513 * @param address The new address.
2514 * @param presentation The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002515 * See {@link TelecomManager} for valid values.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002516 */
Andrew Lee100e2932014-09-08 15:34:24 -07002517 public final void setAddress(Uri address, int presentation) {
2518 Log.d(this, "setAddress %s", address);
2519 mAddress = address;
2520 mAddressPresentation = presentation;
Santos Cordond34e5712014-08-05 18:54:03 +00002521 for (Listener l : mListeners) {
Andrew Lee100e2932014-09-08 15:34:24 -07002522 l.onAddressChanged(this, address, presentation);
Santos Cordond34e5712014-08-05 18:54:03 +00002523 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002524 }
2525
2526 /**
Sailesh Nepal61203862014-07-11 14:50:13 -07002527 * Sets the caller display name (CNAP).
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002528 *
Sailesh Nepal61203862014-07-11 14:50:13 -07002529 * @param callerDisplayName The new display name.
Nancy Chen9d568c02014-09-08 14:17:59 -07002530 * @param presentation The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002531 * See {@link TelecomManager} for valid values.
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002532 */
Sailesh Nepal61203862014-07-11 14:50:13 -07002533 public final void setCallerDisplayName(String callerDisplayName, int presentation) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002534 checkImmutable();
Edgar Arriaga2db19d22022-10-14 14:25:14 -07002535 boolean nameChanged = !Objects.equals(mCallerDisplayName, callerDisplayName);
2536 boolean presentationChanged = mCallerDisplayNamePresentation != presentation;
2537 if (nameChanged) {
2538 // Ensure the new name is not clobbering the old one with a null value due to the caller
2539 // wanting to only set the presentation and not knowing the display name.
2540 mCallerDisplayName = callerDisplayName;
2541 }
2542 if (presentationChanged) {
2543 mCallerDisplayNamePresentation = presentation;
2544 }
2545 if (nameChanged || presentationChanged) {
2546 for (Listener l : mListeners) {
2547 l.onCallerDisplayNameChanged(this, mCallerDisplayName,
2548 mCallerDisplayNamePresentation);
2549 }
Santos Cordond34e5712014-08-05 18:54:03 +00002550 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002551 }
2552
2553 /**
Tyler Gunnaa07df82014-07-17 07:50:22 -07002554 * Set the video state for the connection.
Yorke Lee32f24732015-05-12 16:18:03 -07002555 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
2556 * {@link VideoProfile#STATE_BIDIRECTIONAL},
2557 * {@link VideoProfile#STATE_TX_ENABLED},
2558 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002559 *
2560 * @param videoState The new video state.
2561 */
2562 public final void setVideoState(int videoState) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002563 checkImmutable();
Tyler Gunnaa07df82014-07-17 07:50:22 -07002564 Log.d(this, "setVideoState %d", videoState);
Santos Cordond34e5712014-08-05 18:54:03 +00002565 mVideoState = videoState;
2566 for (Listener l : mListeners) {
2567 l.onVideoStateChanged(this, mVideoState);
2568 }
Tyler Gunnaa07df82014-07-17 07:50:22 -07002569 }
2570
2571 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002572 * Sets state to active (e.g., an ongoing connection where two or more parties can actively
Ihab Awad542e0ea2014-05-16 10:22:16 -07002573 * communicate).
2574 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002575 public final void setActive() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002576 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002577 setRingbackRequested(false);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002578 setState(STATE_ACTIVE);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002579 }
2580
2581 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002582 * Sets state to ringing (e.g., an inbound ringing connection).
Ihab Awad542e0ea2014-05-16 10:22:16 -07002583 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002584 public final void setRinging() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002585 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002586 setState(STATE_RINGING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002587 }
2588
2589 /**
Evan Charltonbf11f982014-07-20 22:06:28 -07002590 * Sets state to initializing (this Connection is not yet ready to be used).
2591 */
2592 public final void setInitializing() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002593 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002594 setState(STATE_INITIALIZING);
Evan Charltonbf11f982014-07-20 22:06:28 -07002595 }
2596
2597 /**
2598 * Sets state to initialized (the Connection has been set up and is now ready to be used).
2599 */
2600 public final void setInitialized() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002601 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002602 setState(STATE_NEW);
Evan Charltonbf11f982014-07-20 22:06:28 -07002603 }
2604
2605 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002606 * Sets state to dialing (e.g., dialing an outbound connection).
Ihab Awad542e0ea2014-05-16 10:22:16 -07002607 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002608 public final void setDialing() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002609 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002610 setState(STATE_DIALING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002611 }
2612
2613 /**
Tyler Gunnc242ceb2016-06-29 22:35:45 -07002614 * Sets state to pulling (e.g. the connection is being pulled to the local device from another
2615 * device). Only applicable for {@link Connection}s with
2616 * {@link Connection#PROPERTY_IS_EXTERNAL_CALL} and {@link Connection#CAPABILITY_CAN_PULL_CALL}.
2617 */
2618 public final void setPulling() {
2619 checkImmutable();
2620 setState(STATE_PULLING_CALL);
2621 }
2622
2623 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002624 * Sets state to be on hold.
2625 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002626 public final void setOnHold() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002627 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002628 setState(STATE_HOLDING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002629 }
2630
2631 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002632 * Sets the video connection provider.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002633 * @param videoProvider The video provider.
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002634 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002635 public final void setVideoProvider(VideoProvider videoProvider) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002636 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002637 mVideoProvider = videoProvider;
Santos Cordond34e5712014-08-05 18:54:03 +00002638 for (Listener l : mListeners) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002639 l.onVideoProviderChanged(this, videoProvider);
Santos Cordond34e5712014-08-05 18:54:03 +00002640 }
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002641 }
2642
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002643 public final VideoProvider getVideoProvider() {
2644 return mVideoProvider;
Andrew Leea27a1932014-07-09 17:07:13 -07002645 }
2646
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002647 /**
Sailesh Nepal091768c2014-06-30 15:15:23 -07002648 * Sets state to disconnected.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002649 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002650 * @param disconnectCause The reason for the disconnection, as specified by
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002651 * {@link DisconnectCause}.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002652 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002653 public final void setDisconnected(DisconnectCause disconnectCause) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002654 checkImmutable();
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002655 mDisconnectCause = disconnectCause;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002656 setState(STATE_DISCONNECTED);
mike dooleyf34519b2014-09-16 17:33:40 -07002657 Log.d(this, "Disconnected with cause %s", disconnectCause);
Santos Cordond34e5712014-08-05 18:54:03 +00002658 for (Listener l : mListeners) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002659 l.onDisconnected(this, disconnectCause);
Santos Cordond34e5712014-08-05 18:54:03 +00002660 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002661 }
2662
2663 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002664 * Informs listeners that this {@code Connection} is in a post-dial wait state. This is done
2665 * when (a) the {@code Connection} is issuing a DTMF sequence; (b) it has encountered a "wait"
2666 * character; and (c) it wishes to inform the In-Call app that it is waiting for the end-user
2667 * to send an {@link #onPostDialContinue(boolean)} signal.
2668 *
2669 * @param remaining The DTMF character sequence remaining to be emitted once the
2670 * {@link #onPostDialContinue(boolean)} is received, including any "wait" characters
2671 * that remaining sequence may contain.
Sailesh Nepal091768c2014-06-30 15:15:23 -07002672 */
2673 public final void setPostDialWait(String remaining) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002674 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002675 for (Listener l : mListeners) {
2676 l.onPostDialWait(this, remaining);
2677 }
Sailesh Nepal091768c2014-06-30 15:15:23 -07002678 }
2679
2680 /**
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002681 * Informs listeners that this {@code Connection} has processed a character in the post-dial
2682 * started state. This is done when (a) the {@code Connection} is issuing a DTMF sequence;
Sailesh Nepal1ed85612015-01-31 15:17:19 -08002683 * and (b) it wishes to signal Telecom to play the corresponding DTMF tone locally.
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002684 *
2685 * @param nextChar The DTMF character that was just processed by the {@code Connection}.
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002686 */
Sailesh Nepal1ed85612015-01-31 15:17:19 -08002687 public final void setNextPostDialChar(char nextChar) {
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002688 checkImmutable();
2689 for (Listener l : mListeners) {
2690 l.onPostDialChar(this, nextChar);
2691 }
2692 }
2693
2694 /**
Ihab Awadf8358972014-05-28 16:46:42 -07002695 * Requests that the framework play a ringback tone. This is to be invoked by implementations
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002696 * that do not play a ringback tone themselves in the connection's audio stream.
Ihab Awadf8358972014-05-28 16:46:42 -07002697 *
2698 * @param ringback Whether the ringback tone is to be played.
2699 */
Andrew Lee100e2932014-09-08 15:34:24 -07002700 public final void setRingbackRequested(boolean ringback) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002701 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002702 if (mRingbackRequested != ringback) {
2703 mRingbackRequested = ringback;
Santos Cordond34e5712014-08-05 18:54:03 +00002704 for (Listener l : mListeners) {
Andrew Lee100e2932014-09-08 15:34:24 -07002705 l.onRingbackRequested(this, ringback);
Santos Cordond34e5712014-08-05 18:54:03 +00002706 }
2707 }
Ihab Awadf8358972014-05-28 16:46:42 -07002708 }
2709
2710 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002711 * Sets the connection's capabilities as a bit mask of the {@code CAPABILITY_*} constants.
Sailesh Nepal1a7061b2014-07-09 21:03:20 -07002712 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002713 * @param connectionCapabilities The new connection capabilities.
Santos Cordonb6939982014-06-04 20:20:58 -07002714 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002715 public final void setConnectionCapabilities(int connectionCapabilities) {
2716 checkImmutable();
2717 if (mConnectionCapabilities != connectionCapabilities) {
2718 mConnectionCapabilities = connectionCapabilities;
Santos Cordond34e5712014-08-05 18:54:03 +00002719 for (Listener l : mListeners) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002720 l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities);
Santos Cordond34e5712014-08-05 18:54:03 +00002721 }
2722 }
Santos Cordonb6939982014-06-04 20:20:58 -07002723 }
2724
2725 /**
Tyler Gunn720c6642016-03-22 09:02:47 -07002726 * Sets the connection's properties as a bit mask of the {@code PROPERTY_*} constants.
2727 *
2728 * @param connectionProperties The new connection properties.
2729 */
2730 public final void setConnectionProperties(int connectionProperties) {
2731 checkImmutable();
2732 if (mConnectionProperties != connectionProperties) {
2733 mConnectionProperties = connectionProperties;
2734 for (Listener l : mListeners) {
2735 l.onConnectionPropertiesChanged(this, mConnectionProperties);
2736 }
2737 }
2738 }
2739
2740 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002741 * Sets the supported audio routes.
2742 *
2743 * @param supportedAudioRoutes the supported audio routes as a bitmask.
2744 * See {@link CallAudioState}
2745 * @hide
2746 */
2747 public final void setSupportedAudioRoutes(int supportedAudioRoutes) {
2748 if ((supportedAudioRoutes
2749 & (CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_SPEAKER)) == 0) {
2750 throw new IllegalArgumentException(
2751 "supported audio routes must include either speaker or earpiece");
2752 }
2753
2754 if (mSupportedAudioRoutes != supportedAudioRoutes) {
2755 mSupportedAudioRoutes = supportedAudioRoutes;
2756 for (Listener l : mListeners) {
2757 l.onSupportedAudioRoutesChanged(this, mSupportedAudioRoutes);
2758 }
2759 }
2760 }
2761
2762 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002763 * Tears down the Connection object.
Santos Cordonb6939982014-06-04 20:20:58 -07002764 */
Evan Charlton36a71342014-07-19 16:31:02 -07002765 public final void destroy() {
Jay Shrauner229e3822014-08-15 09:23:07 -07002766 for (Listener l : mListeners) {
2767 l.onDestroyed(this);
Santos Cordond34e5712014-08-05 18:54:03 +00002768 }
Santos Cordonb6939982014-06-04 20:20:58 -07002769 }
2770
2771 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002772 * Requests that the framework use VOIP audio mode for this connection.
2773 *
2774 * @param isVoip True if the audio mode is VOIP.
2775 */
2776 public final void setAudioModeIsVoip(boolean isVoip) {
Thomas Stuartb83cc192022-07-06 10:59:41 -07002777 if (!isVoip && (mConnectionProperties & PROPERTY_SELF_MANAGED) == PROPERTY_SELF_MANAGED) {
2778 Log.i(this,
2779 "setAudioModeIsVoip: Ignored request to set a self-managed connection's"
2780 + " audioModeIsVoip to false. Doing so can cause unwanted behavior.");
2781 return;
2782 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002783 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002784 mAudioModeIsVoip = isVoip;
2785 for (Listener l : mListeners) {
2786 l.onAudioModeIsVoipChanged(this, isVoip);
2787 }
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002788 }
2789
2790 /**
Roshan Piuse927ec02015-07-15 15:47:21 -07002791 * Sets the time at which a call became active on this Connection. This is set only
2792 * when a conference call becomes active on this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002793 * <p>
Tyler Gunnc9503d62020-01-27 10:30:51 -08002794 * This time corresponds to the date/time of connection and is stored in the call log in
2795 * {@link android.provider.CallLog.Calls#DATE}.
2796 * <p>
Tyler Gunnc63f9082019-10-15 13:19:26 -07002797 * Used by telephony to maintain calls associated with an IMS Conference.
Roshan Piuse927ec02015-07-15 15:47:21 -07002798 *
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002799 * @param connectTimeMillis The connection time, in milliseconds. Should be set using a value
2800 * obtained from {@link System#currentTimeMillis()}.
Roshan Piuse927ec02015-07-15 15:47:21 -07002801 *
2802 * @hide
2803 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002804 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002805 @RequiresPermission(MODIFY_PHONE_STATE)
2806 public final void setConnectTimeMillis(@IntRange(from = 0) long connectTimeMillis) {
Roshan Piuse927ec02015-07-15 15:47:21 -07002807 mConnectTimeMillis = connectTimeMillis;
2808 }
2809
2810 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002811 * Sets the time at which a call became active on this Connection. This is set only
2812 * when a conference call becomes active on this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002813 * <p>
Tyler Gunnc9503d62020-01-27 10:30:51 -08002814 * This time is used to establish the duration of a call. It uses
2815 * {@link SystemClock#elapsedRealtime()} to ensure that the call duration is not impacted by
2816 * time zone changes during a call. The difference between the current
2817 * {@link SystemClock#elapsedRealtime()} and the value set at the connection start time is used
2818 * to populate {@link android.provider.CallLog.Calls#DURATION} in the call log.
2819 * <p>
Tyler Gunnc63f9082019-10-15 13:19:26 -07002820 * Used by telephony to maintain calls associated with an IMS Conference.
Tyler Gunnc9503d62020-01-27 10:30:51 -08002821 *
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002822 * @param connectElapsedTimeMillis The connection time, in milliseconds. Stored in the format
2823 * {@link SystemClock#elapsedRealtime()}.
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002824 * @hide
2825 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002826 @SystemApi
Tyler Gunnc9503d62020-01-27 10:30:51 -08002827 @RequiresPermission(MODIFY_PHONE_STATE)
2828 public final void setConnectionStartElapsedRealtimeMillis(
2829 @ElapsedRealtimeLong long connectElapsedTimeMillis) {
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002830 mConnectElapsedTimeMillis = connectElapsedTimeMillis;
2831 }
2832
2833 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002834 * Sets the label and icon status to display in the in-call UI.
2835 *
2836 * @param statusHints The status label and icon to set.
2837 */
2838 public final void setStatusHints(StatusHints statusHints) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002839 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002840 mStatusHints = statusHints;
2841 for (Listener l : mListeners) {
2842 l.onStatusHintsChanged(this, statusHints);
2843 }
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002844 }
2845
2846 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002847 * Sets the connections with which this connection can be conferenced.
2848 *
2849 * @param conferenceableConnections The set of connections this connection can conference with.
2850 */
2851 public final void setConferenceableConnections(List<Connection> conferenceableConnections) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002852 checkImmutable();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002853 clearConferenceableList();
2854 for (Connection c : conferenceableConnections) {
2855 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
2856 // small amount of items here.
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002857 if (!mConferenceables.contains(c)) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002858 c.addConnectionListener(mConnectionDeathListener);
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002859 mConferenceables.add(c);
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002860 }
2861 }
2862 fireOnConferenceableConnectionsChanged();
2863 }
2864
2865 /**
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002866 * Similar to {@link #setConferenceableConnections(java.util.List)}, sets a list of connections
2867 * or conferences with which this connection can be conferenced.
2868 *
2869 * @param conferenceables The conferenceables.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002870 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002871 public final void setConferenceables(List<Conferenceable> conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002872 clearConferenceableList();
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002873 for (Conferenceable c : conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002874 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
2875 // small amount of items here.
2876 if (!mConferenceables.contains(c)) {
2877 if (c instanceof Connection) {
2878 Connection connection = (Connection) c;
2879 connection.addConnectionListener(mConnectionDeathListener);
2880 } else if (c instanceof Conference) {
2881 Conference conference = (Conference) c;
2882 conference.addListener(mConferenceDeathListener);
2883 }
2884 mConferenceables.add(c);
2885 }
2886 }
2887 fireOnConferenceableConnectionsChanged();
2888 }
2889
2890 /**
Tyler Gunnc63f9082019-10-15 13:19:26 -07002891 * Resets the CDMA connection time.
2892 * <p>
2893 * This is an implementation detail specific to legacy CDMA calls on mobile networks.
Mengjun Leng25707742017-07-04 11:10:37 +08002894 * @hide
Mengjun Leng25707742017-07-04 11:10:37 +08002895 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002896 @SystemApi
Mengjun Leng25707742017-07-04 11:10:37 +08002897 public final void resetConnectionTime() {
2898 for (Listener l : mListeners) {
2899 l.onConnectionTimeReset(this);
2900 }
2901 }
2902
2903 /**
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002904 * Returns the connections or conferences with which this connection can be conferenced.
2905 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002906 public final List<Conferenceable> getConferenceables() {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002907 return mUnmodifiableConferenceables;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002908 }
2909
Yorke Lee53463962015-08-04 16:07:19 -07002910 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002911 * @hide
2912 */
2913 public final void setConnectionService(ConnectionService connectionService) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002914 checkImmutable();
Santos Cordon823fd3c2014-08-07 18:35:18 -07002915 if (mConnectionService != null) {
2916 Log.e(this, new Exception(), "Trying to set ConnectionService on a connection " +
2917 "which is already associated with another ConnectionService.");
2918 } else {
2919 mConnectionService = connectionService;
2920 }
2921 }
2922
2923 /**
2924 * @hide
2925 */
2926 public final void unsetConnectionService(ConnectionService connectionService) {
2927 if (mConnectionService != connectionService) {
2928 Log.e(this, new Exception(), "Trying to remove ConnectionService from a Connection " +
2929 "that does not belong to the ConnectionService.");
2930 } else {
2931 mConnectionService = null;
2932 }
2933 }
2934
2935 /**
2936 * Sets the conference that this connection is a part of. This will fail if the connection is
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002937 * already part of a conference. {@link #resetConference} to un-set the conference first.
Santos Cordon823fd3c2014-08-07 18:35:18 -07002938 *
2939 * @param conference The conference.
2940 * @return {@code true} if the conference was successfully set.
2941 * @hide
2942 */
2943 public final boolean setConference(Conference conference) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002944 checkImmutable();
Santos Cordon823fd3c2014-08-07 18:35:18 -07002945 // We check to see if it is already part of another conference.
Santos Cordon0159ac02014-08-21 14:28:11 -07002946 if (mConference == null) {
Santos Cordon823fd3c2014-08-07 18:35:18 -07002947 mConference = conference;
Santos Cordon0159ac02014-08-21 14:28:11 -07002948 if (mConnectionService != null && mConnectionService.containsConference(conference)) {
2949 fireConferenceChanged();
2950 }
Santos Cordon823fd3c2014-08-07 18:35:18 -07002951 return true;
2952 }
2953 return false;
2954 }
2955
2956 /**
2957 * Resets the conference that this connection is a part of.
2958 * @hide
2959 */
2960 public final void resetConference() {
2961 if (mConference != null) {
Santos Cordon0159ac02014-08-21 14:28:11 -07002962 Log.d(this, "Conference reset");
Santos Cordon823fd3c2014-08-07 18:35:18 -07002963 mConference = null;
2964 fireConferenceChanged();
2965 }
2966 }
2967
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002968 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002969 * Set some extras that can be associated with this {@code Connection}.
2970 * <p>
2971 * New or existing keys are replaced in the {@code Connection} extras. Keys which are no longer
2972 * in the new extras, but were present the last time {@code setExtras} was called are removed.
2973 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07002974 * Alternatively you may use the {@link #putExtras(Bundle)}, and
2975 * {@link #removeExtras(String...)} methods to modify the extras.
2976 * <p>
Tyler Gunndee56a82016-03-23 16:06:34 -07002977 * 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 -07002978 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
2979 *
2980 * @param extras The extras associated with this {@code Connection}.
2981 */
2982 public final void setExtras(@Nullable Bundle extras) {
2983 checkImmutable();
Tyler Gunndee56a82016-03-23 16:06:34 -07002984
2985 // Add/replace any new or changed extras values.
2986 putExtras(extras);
2987
2988 // If we have used "setExtras" in the past, compare the key set from the last invocation to
2989 // the current one and remove any keys that went away.
2990 if (mPreviousExtraKeys != null) {
2991 List<String> toRemove = new ArrayList<String>();
2992 for (String oldKey : mPreviousExtraKeys) {
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07002993 if (extras == null || !extras.containsKey(oldKey)) {
Tyler Gunndee56a82016-03-23 16:06:34 -07002994 toRemove.add(oldKey);
2995 }
2996 }
2997 if (!toRemove.isEmpty()) {
2998 removeExtras(toRemove);
2999 }
3000 }
3001
3002 // Track the keys the last time set called setExtras. This way, the next time setExtras is
3003 // called we can see if the caller has removed any extras values.
3004 if (mPreviousExtraKeys == null) {
3005 mPreviousExtraKeys = new ArraySet<String>();
3006 }
3007 mPreviousExtraKeys.clear();
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07003008 if (extras != null) {
3009 mPreviousExtraKeys.addAll(extras.keySet());
3010 }
Tyler Gunndee56a82016-03-23 16:06:34 -07003011 }
3012
3013 /**
3014 * Adds some extras to this {@code Connection}. Existing keys are replaced and new ones are
3015 * added.
3016 * <p>
3017 * No assumptions should be made as to how an In-Call UI or service will handle these extras.
3018 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
3019 *
3020 * @param extras The extras to add.
3021 */
3022 public final void putExtras(@NonNull Bundle extras) {
3023 checkImmutable();
3024 if (extras == null) {
3025 return;
3026 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003027 // Creating a duplicate bundle so we don't have to synchronize on mExtrasLock while calling
3028 // the listeners.
3029 Bundle listenerExtras;
3030 synchronized (mExtrasLock) {
3031 if (mExtras == null) {
3032 mExtras = new Bundle();
3033 }
3034 mExtras.putAll(extras);
3035 listenerExtras = new Bundle(mExtras);
Tyler Gunndee56a82016-03-23 16:06:34 -07003036 }
Santos Cordon6b7f9552015-05-27 17:21:45 -07003037 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003038 // Create a new clone of the extras for each listener so that they don't clobber
3039 // each other
3040 l.onExtrasChanged(this, new Bundle(listenerExtras));
Santos Cordon6b7f9552015-05-27 17:21:45 -07003041 }
3042 }
3043
3044 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -07003045 * Removes extras from this {@code Connection}.
Tyler Gunndee56a82016-03-23 16:06:34 -07003046 *
Tyler Gunn071be6f2016-05-10 14:52:33 -07003047 * @param keys The keys of the extras to remove.
Tyler Gunndee56a82016-03-23 16:06:34 -07003048 */
3049 public final void removeExtras(List<String> keys) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003050 synchronized (mExtrasLock) {
3051 if (mExtras != null) {
3052 for (String key : keys) {
3053 mExtras.remove(key);
3054 }
Tyler Gunndee56a82016-03-23 16:06:34 -07003055 }
3056 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003057 List<String> unmodifiableKeys = Collections.unmodifiableList(keys);
Tyler Gunndee56a82016-03-23 16:06:34 -07003058 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003059 l.onExtrasRemoved(this, unmodifiableKeys);
Tyler Gunndee56a82016-03-23 16:06:34 -07003060 }
3061 }
3062
3063 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -07003064 * Removes extras from this {@code Connection}.
3065 *
3066 * @param keys The keys of the extras to remove.
3067 */
3068 public final void removeExtras(String ... keys) {
3069 removeExtras(Arrays.asList(keys));
3070 }
3071
3072 /**
Tyler Gunnf5035432017-01-09 09:43:12 -08003073 * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will
3074 * be change to the {@link #getCallAudioState()}.
3075 * <p>
3076 * Used by self-managed {@link ConnectionService}s which wish to change the audio route for a
3077 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
3078 * <p>
3079 * See also {@link InCallService#setAudioRoute(int)}.
3080 *
3081 * @param route The audio route to use (one of {@link CallAudioState#ROUTE_BLUETOOTH},
3082 * {@link CallAudioState#ROUTE_EARPIECE}, {@link CallAudioState#ROUTE_SPEAKER}, or
3083 * {@link CallAudioState#ROUTE_WIRED_HEADSET}).
3084 */
3085 public final void setAudioRoute(int route) {
3086 for (Listener l : mListeners) {
Hall Liua98f58b52017-11-07 17:59:28 -08003087 l.onAudioRouteChanged(this, route, null);
3088 }
3089 }
3090
3091 /**
Hall Liua98f58b52017-11-07 17:59:28 -08003092 * Request audio routing to a specific bluetooth device. Calling this method may result in
3093 * the device routing audio to a different bluetooth device than the one specified if the
3094 * bluetooth stack is unable to route audio to the requested device.
3095 * A list of available devices can be obtained via
3096 * {@link CallAudioState#getSupportedBluetoothDevices()}
3097 *
3098 * <p>
3099 * Used by self-managed {@link ConnectionService}s which wish to use bluetooth audio for a
3100 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
3101 * <p>
Hall Liu2b6a6a32018-04-02 13:52:57 -07003102 * See also {@link InCallService#requestBluetoothAudio(BluetoothDevice)}
3103 * @param bluetoothDevice The bluetooth device to connect to.
Hall Liua98f58b52017-11-07 17:59:28 -08003104 */
Hall Liu2b6a6a32018-04-02 13:52:57 -07003105 public void requestBluetoothAudio(@NonNull BluetoothDevice bluetoothDevice) {
Hall Liua98f58b52017-11-07 17:59:28 -08003106 for (Listener l : mListeners) {
Hall Liu2b6a6a32018-04-02 13:52:57 -07003107 l.onAudioRouteChanged(this, CallAudioState.ROUTE_BLUETOOTH,
3108 bluetoothDevice.getAddress());
Tyler Gunnf5035432017-01-09 09:43:12 -08003109 }
3110 }
3111
3112 /**
Hall Liub64ac4c2017-02-06 10:49:48 -08003113 * Informs listeners that a previously requested RTT session via
3114 * {@link ConnectionRequest#isRequestingRtt()} or
Hall Liu37dfdb02017-12-04 14:19:30 -08003115 * {@link #onStartRtt(RttTextStream)} has succeeded.
Hall Liub64ac4c2017-02-06 10:49:48 -08003116 */
3117 public final void sendRttInitiationSuccess() {
3118 mListeners.forEach((l) -> l.onRttInitiationSuccess(Connection.this));
3119 }
3120
3121 /**
3122 * Informs listeners that a previously requested RTT session via
Hall Liu37dfdb02017-12-04 14:19:30 -08003123 * {@link ConnectionRequest#isRequestingRtt()} or {@link #onStartRtt(RttTextStream)}
Hall Liub64ac4c2017-02-06 10:49:48 -08003124 * has failed.
3125 * @param reason One of the reason codes defined in {@link RttModifyStatus}, with the
3126 * exception of {@link RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}.
Hall Liub64ac4c2017-02-06 10:49:48 -08003127 */
3128 public final void sendRttInitiationFailure(int reason) {
3129 mListeners.forEach((l) -> l.onRttInitiationFailure(Connection.this, reason));
3130 }
3131
3132 /**
3133 * Informs listeners that a currently active RTT session has been terminated by the remote
3134 * side of the coll.
Hall Liub64ac4c2017-02-06 10:49:48 -08003135 */
3136 public final void sendRttSessionRemotelyTerminated() {
3137 mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this));
3138 }
3139
3140 /**
3141 * Informs listeners that the remote side of the call has requested an upgrade to include an
3142 * RTT session in the call.
Hall Liub64ac4c2017-02-06 10:49:48 -08003143 */
3144 public final void sendRemoteRttRequest() {
3145 mListeners.forEach((l) -> l.onRemoteRttRequest(Connection.this));
3146 }
3147
3148 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003149 * Notifies this Connection that the {@link #getAudioState()} property has a new value.
Sailesh Nepal400cc482014-06-26 12:04:00 -07003150 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003151 * @param state The new connection audio state.
Yorke Lee4af59352015-05-13 14:14:54 -07003152 * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead.
3153 * @hide
Sailesh Nepal400cc482014-06-26 12:04:00 -07003154 */
Yorke Lee4af59352015-05-13 14:14:54 -07003155 @SystemApi
3156 @Deprecated
Nancy Chen354b2bd2014-09-08 18:27:26 -07003157 public void onAudioStateChanged(AudioState state) {}
Sailesh Nepal400cc482014-06-26 12:04:00 -07003158
3159 /**
Yorke Lee4af59352015-05-13 14:14:54 -07003160 * Notifies this Connection that the {@link #getCallAudioState()} property has a new value.
3161 *
3162 * @param state The new connection audio state.
3163 */
3164 public void onCallAudioStateChanged(CallAudioState state) {}
3165
3166 /**
Grace Jiae99fde92021-01-19 14:58:01 -08003167 * Inform this Connection when it will or will not be tracked by an {@link InCallService} which
3168 * can provide an InCall UI.
3169 * This is primarily intended for use by Connections reported by self-managed
3170 * {@link ConnectionService} which typically maintain their own UI.
3171 *
3172 * @param isUsingAlternativeUi Indicates whether an InCallService that can provide InCall UI is
3173 * currently tracking the self-managed call.
3174 */
3175 public void onUsingAlternativeUi(boolean isUsingAlternativeUi) {}
3176
3177 /**
3178 * Inform this Conenection when it will or will not be tracked by an non-UI
3179 * {@link InCallService}.
3180 *
3181 * @param isTracked Indicates whether an non-UI InCallService is currently tracking the
3182 * self-managed call.
3183 */
3184 public void onTrackedByNonUiService(boolean isTracked) {}
3185
3186 /**
Evan Charltonbf11f982014-07-20 22:06:28 -07003187 * Notifies this Connection of an internal state change. This method is called after the
3188 * state is changed.
Ihab Awadf8358972014-05-28 16:46:42 -07003189 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003190 * @param state The new state, one of the {@code STATE_*} constants.
Ihab Awadf8358972014-05-28 16:46:42 -07003191 */
Nancy Chen354b2bd2014-09-08 18:27:26 -07003192 public void onStateChanged(int state) {}
Ihab Awadf8358972014-05-28 16:46:42 -07003193
3194 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07003195 * Notifies this Connection of a request to play a DTMF tone.
3196 *
3197 * @param c A DTMF character.
3198 */
Santos Cordonf2951102014-07-20 19:06:29 -07003199 public void onPlayDtmfTone(char c) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003200
3201 /**
3202 * Notifies this Connection of a request to stop any currently playing DTMF tones.
3203 */
Santos Cordonf2951102014-07-20 19:06:29 -07003204 public void onStopDtmfTone() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003205
3206 /**
3207 * Notifies this Connection of a request to disconnect.
3208 */
Santos Cordonf2951102014-07-20 19:06:29 -07003209 public void onDisconnect() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003210
3211 /**
Tyler Gunn3b4b1dc2014-11-04 14:53:37 -08003212 * Notifies this Connection of a request to disconnect a participant of the conference managed
3213 * by the connection.
3214 *
3215 * @param endpoint the {@link Uri} of the participant to disconnect.
3216 * @hide
3217 */
3218 public void onDisconnectConferenceParticipant(Uri endpoint) {}
3219
3220 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003221 * Notifies this Connection of a request to separate from its parent conference.
Santos Cordonb6939982014-06-04 20:20:58 -07003222 */
Santos Cordonf2951102014-07-20 19:06:29 -07003223 public void onSeparate() {}
Santos Cordonb6939982014-06-04 20:20:58 -07003224
3225 /**
Tyler Gunn0c62ef02020-02-11 14:39:43 -08003226 * Supports initiation of a conference call by directly adding participants to an ongoing call.
Ravi Paluri404babb2020-01-23 19:02:44 +05303227 *
3228 * @param participants with which conference call will be formed.
3229 */
3230 public void onAddConferenceParticipants(@NonNull List<Uri> participants) {}
3231
3232 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07003233 * Notifies this Connection of a request to abort.
3234 */
Santos Cordonf2951102014-07-20 19:06:29 -07003235 public void onAbort() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003236
3237 /**
3238 * Notifies this Connection of a request to hold.
3239 */
Santos Cordonf2951102014-07-20 19:06:29 -07003240 public void onHold() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003241
3242 /**
3243 * Notifies this Connection of a request to exit a hold state.
3244 */
Santos Cordonf2951102014-07-20 19:06:29 -07003245 public void onUnhold() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003246
3247 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003248 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Santos Cordond34e5712014-08-05 18:54:03 +00003249 * a request to accept.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003250 * <p>
3251 * For managed {@link ConnectionService}s, this will be called when the user answers a call via
3252 * the default dialer's {@link InCallService}.
3253 * <p>
3254 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3255 * Telecom framework may request that the call is answered in the following circumstances:
3256 * <ul>
3257 * <li>The user chooses to answer an incoming call via a Bluetooth device.</li>
3258 * <li>A car mode {@link InCallService} is in use which has declared
3259 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3260 * {@link InCallService} will be able to see calls from self-managed
3261 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3262 * behalf.</li>
3263 * </ul>
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003264 * @param videoState The video state in which to answer the connection.
Ihab Awad542e0ea2014-05-16 10:22:16 -07003265 */
Santos Cordonf2951102014-07-20 19:06:29 -07003266 public void onAnswer(int videoState) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003267
3268 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003269 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Tyler Gunnbe74de02014-08-29 14:51:48 -07003270 * a request to accept.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003271 * <p>
3272 * For managed {@link ConnectionService}s, this will be called when the user answers a call via
3273 * the default dialer's {@link InCallService}.
3274 * <p>
3275 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3276 * Telecom framework may request that the call is answered in the following circumstances:
3277 * <ul>
3278 * <li>The user chooses to answer an incoming call via a Bluetooth device.</li>
3279 * <li>A car mode {@link InCallService} is in use which has declared
3280 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3281 * {@link InCallService} will be able to see calls from self-managed
3282 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3283 * behalf.</li>
3284 * </ul>
Tyler Gunnbe74de02014-08-29 14:51:48 -07003285 */
3286 public void onAnswer() {
Tyler Gunn87b73f32015-06-03 10:09:59 -07003287 onAnswer(VideoProfile.STATE_AUDIO_ONLY);
Tyler Gunnbe74de02014-08-29 14:51:48 -07003288 }
3289
3290 /**
3291 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Pooja Jaind34698d2017-12-28 14:15:31 +05303292 * a request to deflect.
3293 */
3294 public void onDeflect(Uri address) {}
3295
3296 /**
3297 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Santos Cordond34e5712014-08-05 18:54:03 +00003298 * a request to reject.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003299 * <p>
3300 * For managed {@link ConnectionService}s, this will be called when the user rejects a call via
3301 * the default dialer's {@link InCallService}.
3302 * <p>
3303 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3304 * Telecom framework may request that the call is rejected in the following circumstances:
3305 * <ul>
3306 * <li>The user chooses to reject an incoming call via a Bluetooth device.</li>
3307 * <li>A car mode {@link InCallService} is in use which has declared
3308 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3309 * {@link InCallService} will be able to see calls from self-managed
3310 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3311 * behalf.</li>
3312 * </ul>
Ihab Awad542e0ea2014-05-16 10:22:16 -07003313 */
Santos Cordonf2951102014-07-20 19:06:29 -07003314 public void onReject() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003315
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003316 /**
Tyler Gunnfacfdee2020-01-23 13:10:37 -08003317 * Notifies this Connection, which is in {@link #STATE_RINGING}, of a request to reject.
3318 * <p>
3319 * For managed {@link ConnectionService}s, this will be called when the user rejects a call via
3320 * the default dialer's {@link InCallService} using {@link Call#reject(int)}.
3321 * @param rejectReason the reason the user provided for rejecting the call.
3322 */
3323 public void onReject(@android.telecom.Call.RejectReason int rejectReason) {
3324 // to be implemented by ConnectionService.
3325 }
3326
3327 /**
Hall Liu712acbe2016-03-14 16:38:56 -07003328 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
3329 * a request to reject with a message.
Bryce Lee81901682015-08-28 16:38:02 -07003330 */
3331 public void onReject(String replyMessage) {}
3332
3333 /**
Ravi Palurif4b38e72020-02-05 12:35:41 +05303334 * Notifies this Connection, a request to transfer to a target number.
3335 * @param number the number to transfer this {@link Connection} to.
3336 * @param isConfirmationRequired when {@code true}, the {@link ConnectionService}
3337 * should wait until the transfer has successfully completed before disconnecting
3338 * the current {@link Connection}.
3339 * When {@code false}, the {@link ConnectionService} should signal the network to
3340 * perform the transfer, but should immediately disconnect the call regardless of
3341 * the outcome of the transfer.
3342 * @hide
3343 */
3344 public void onTransfer(@NonNull Uri number, boolean isConfirmationRequired) {}
3345
3346 /**
3347 * Notifies this Connection, a request to transfer to another Connection.
3348 * @param otherConnection the {@link Connection} to transfer this call to.
3349 * @hide
3350 */
3351 public void onTransfer(@NonNull Connection otherConnection) {}
3352
3353 /**
Tyler Gunn06f06162018-06-18 11:24:15 -07003354 * Notifies this Connection of a request to silence the ringer.
3355 * <p>
3356 * The ringer may be silenced by any of the following methods:
3357 * <ul>
3358 * <li>{@link TelecomManager#silenceRinger()}</li>
3359 * <li>The user presses the volume-down button while a call is ringing.</li>
3360 * </ul>
3361 * <p>
3362 * Self-managed {@link ConnectionService} implementations should override this method in their
3363 * {@link Connection} implementation and implement logic to silence their app's ringtone. If
3364 * your app set the ringtone as part of the incoming call {@link Notification} (see
3365 * {@link #onShowIncomingCallUi()}), it should re-post the notification now, except call
3366 * {@link android.app.Notification.Builder#setOnlyAlertOnce(boolean)} with {@code true}. This
3367 * will ensure the ringtone sound associated with your {@link android.app.NotificationChannel}
3368 * stops playing.
Bryce Leecac50772015-11-17 15:13:29 -08003369 */
3370 public void onSilence() {}
3371
3372 /**
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003373 * Notifies this Connection whether the user wishes to proceed with the post-dial DTMF codes.
3374 */
Santos Cordonf2951102014-07-20 19:06:29 -07003375 public void onPostDialContinue(boolean proceed) {}
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003376
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003377 /**
3378 * Notifies this Connection of a request to pull an external call to the local device.
3379 * <p>
3380 * The {@link InCallService} issues a request to pull an external call to the local device via
3381 * {@link Call#pullExternalCall()}.
3382 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -07003383 * For a Connection to be pulled, both the {@link Connection#CAPABILITY_CAN_PULL_CALL}
3384 * capability and {@link Connection#PROPERTY_IS_EXTERNAL_CALL} property bits must be set.
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003385 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -07003386 * For more information on external calls, see {@link Connection#PROPERTY_IS_EXTERNAL_CALL}.
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003387 */
3388 public void onPullExternalCall() {}
3389
3390 /**
3391 * Notifies this Connection of a {@link Call} event initiated from an {@link InCallService}.
3392 * <p>
3393 * The {@link InCallService} issues a Call event via {@link Call#sendCallEvent(String, Bundle)}.
3394 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003395 * Where possible, the Connection should make an attempt to handle {@link Call} events which
3396 * are part of the {@code android.telecom.*} namespace. The Connection should ignore any events
3397 * it does not wish to handle. Unexpected events should be handled gracefully, as it is
3398 * possible that a {@link InCallService} has defined its own Call events which a Connection is
3399 * not aware of.
3400 * <p>
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003401 * See also {@link Call#sendCallEvent(String, Bundle)}.
3402 *
3403 * @param event The call event.
3404 * @param extras Extras associated with the call event.
3405 */
3406 public void onCallEvent(String event, Bundle extras) {}
3407
Tyler Gunndee56a82016-03-23 16:06:34 -07003408 /**
Tyler Gunn79bc1ec2018-01-22 15:17:54 -08003409 * Notifies this {@link Connection} that a handover has completed.
3410 * <p>
3411 * A handover is initiated with {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int,
3412 * Bundle)} on the initiating side of the handover, and
3413 * {@link TelecomManager#acceptHandover(Uri, int, PhoneAccountHandle)}.
3414 */
3415 public void onHandoverComplete() {}
3416
3417 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07003418 * Notifies this {@link Connection} of a change to the extras made outside the
3419 * {@link ConnectionService}.
3420 * <p>
3421 * These extras changes can originate from Telecom itself, or from an {@link InCallService} via
3422 * the {@link android.telecom.Call#putExtras(Bundle)} and
3423 * {@link Call#removeExtras(List)}.
3424 *
3425 * @param extras The new extras bundle.
3426 */
3427 public void onExtrasChanged(Bundle extras) {}
3428
Tyler Gunnf5035432017-01-09 09:43:12 -08003429 /**
3430 * Notifies this {@link Connection} that its {@link ConnectionService} is responsible for
3431 * displaying its incoming call user interface for the {@link Connection}.
3432 * <p>
3433 * Will only be called for incoming calls added via a self-managed {@link ConnectionService}
3434 * (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}), where the {@link ConnectionService}
3435 * should show its own incoming call user interface.
3436 * <p>
3437 * Where there are ongoing calls in other self-managed {@link ConnectionService}s, or in a
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003438 * regular {@link ConnectionService}, and it is not possible to hold these other calls, the
3439 * Telecom framework will display its own incoming call user interface to allow the user to
3440 * choose whether to answer the new incoming call and disconnect other ongoing calls, or to
3441 * reject the new incoming call.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003442 * <p>
3443 * You should trigger the display of the incoming call user interface for your application by
3444 * showing a {@link Notification} with a full-screen {@link Intent} specified.
Tyler Gunn06f06162018-06-18 11:24:15 -07003445 *
3446 * In your application code, you should create a {@link android.app.NotificationChannel} for
3447 * incoming call notifications from your app:
3448 * <pre><code>
3449 * NotificationChannel channel = new NotificationChannel(YOUR_CHANNEL_ID, "Incoming Calls",
3450 * NotificationManager.IMPORTANCE_MAX);
3451 * // other channel setup stuff goes here.
3452 *
3453 * // We'll use the default system ringtone for our incoming call notification channel. You can
3454 * // use your own audio resource here.
3455 * Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
3456 * channel.setSound(ringtoneUri, new AudioAttributes.Builder()
3457 * // Setting the AudioAttributes is important as it identifies the purpose of your
3458 * // notification sound.
3459 * .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
3460 * .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
3461 * .build());
3462 *
3463 * NotificationManager mgr = getSystemService(NotificationManager.class);
3464 * mgr.createNotificationChannel(channel);
3465 * </code></pre>
3466 * When it comes time to post a notification for your incoming call, ensure it uses your
3467 * incoming call {@link android.app.NotificationChannel}.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003468 * <pre><code>
3469 * // Create an intent which triggers your fullscreen incoming call user interface.
3470 * Intent intent = new Intent(Intent.ACTION_MAIN, null);
3471 * intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_ACTIVITY_NEW_TASK);
3472 * intent.setClass(context, YourIncomingCallActivity.class);
Ashwini Orugantif8191e82021-01-07 12:04:25 -08003473 * PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_MUTABLE_UNAUDITED);
Tyler Gunn159f35c2017-03-02 09:28:37 -08003474 *
3475 * // Build the notification as an ongoing high priority item; this ensures it will show as
3476 * // a heads up notification which slides down over top of the current content.
3477 * final Notification.Builder builder = new Notification.Builder(context);
3478 * builder.setOngoing(true);
3479 * builder.setPriority(Notification.PRIORITY_HIGH);
3480 *
3481 * // Set notification content intent to take user to fullscreen UI if user taps on the
3482 * // notification body.
3483 * builder.setContentIntent(pendingIntent);
3484 * // Set full screen intent to trigger display of the fullscreen UI when the notification
3485 * // manager deems it appropriate.
3486 * builder.setFullScreenIntent(pendingIntent, true);
3487 *
3488 * // Setup notification content.
3489 * builder.setSmallIcon( yourIconResourceId );
3490 * builder.setContentTitle("Your notification title");
3491 * builder.setContentText("Your notification content.");
3492 *
Tyler Gunn06f06162018-06-18 11:24:15 -07003493 * // Set notification as insistent to cause your ringtone to loop.
3494 * Notification notification = builder.build();
3495 * notification.flags |= Notification.FLAG_INSISTENT;
Tyler Gunn159f35c2017-03-02 09:28:37 -08003496 *
Tyler Gunn06f06162018-06-18 11:24:15 -07003497 * // Use builder.addAction(..) to add buttons to answer or reject the call.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003498 * NotificationManager notificationManager = mContext.getSystemService(
3499 * NotificationManager.class);
Tyler Gunn06f06162018-06-18 11:24:15 -07003500 * notificationManager.notify(YOUR_CHANNEL_ID, YOUR_TAG, YOUR_ID, notification);
Tyler Gunn159f35c2017-03-02 09:28:37 -08003501 * </code></pre>
Tyler Gunnf5035432017-01-09 09:43:12 -08003502 */
3503 public void onShowIncomingCallUi() {}
3504
Hall Liub64ac4c2017-02-06 10:49:48 -08003505 /**
3506 * Notifies this {@link Connection} that the user has requested an RTT session.
3507 * The connection service should call {@link #sendRttInitiationSuccess} or
3508 * {@link #sendRttInitiationFailure} to inform Telecom of the success or failure of the
3509 * request, respectively.
3510 * @param rttTextStream The object that should be used to send text to or receive text from
3511 * the in-call app.
Hall Liub64ac4c2017-02-06 10:49:48 -08003512 */
3513 public void onStartRtt(@NonNull RttTextStream rttTextStream) {}
3514
3515 /**
3516 * Notifies this {@link Connection} that it should terminate any existing RTT communication
3517 * channel. No response to Telecom is needed for this method.
Hall Liub64ac4c2017-02-06 10:49:48 -08003518 */
3519 public void onStopRtt() {}
3520
3521 /**
3522 * Notifies this connection of a response to a previous remotely-initiated RTT upgrade
3523 * request sent via {@link #sendRemoteRttRequest}. Acceptance of the request is
3524 * indicated by the supplied {@link RttTextStream} being non-null, and rejection is
3525 * indicated by {@code rttTextStream} being {@code null}
Hall Liub64ac4c2017-02-06 10:49:48 -08003526 * @param rttTextStream The object that should be used to send text to or receive text from
3527 * the in-call app.
3528 */
3529 public void handleRttUpgradeResponse(@Nullable RttTextStream rttTextStream) {}
3530
Hall Liu49cabcc2021-01-15 11:41:48 -08003531 /**
Hall Liu73903142021-02-18 18:41:41 -08003532 * Information provided to a {@link Connection} upon completion of call filtering in Telecom.
3533 *
3534 * @hide
3535 */
3536 @SystemApi
3537 public static final class CallFilteringCompletionInfo implements Parcelable {
3538 private final boolean mIsBlocked;
3539 private final boolean mIsInContacts;
3540 private final CallScreeningService.CallResponse mCallResponse;
3541 private final ComponentName mCallScreeningComponent;
3542
3543 /**
3544 * Constructor for {@link CallFilteringCompletionInfo}
3545 *
3546 * @param isBlocked Whether any part of the call filtering process indicated that this call
3547 * should be blocked.
3548 * @param isInContacts Whether the caller is in the user's contacts.
3549 * @param callResponse The instance of {@link CallScreeningService.CallResponse} provided
3550 * by the {@link CallScreeningService} that processed this call, or
3551 * {@code null} if no call screening service ran.
3552 * @param callScreeningComponent The component of the {@link CallScreeningService}
3553 * that processed this call, or {@link null} if no
3554 * call screening service ran.
3555 */
3556 public CallFilteringCompletionInfo(boolean isBlocked, boolean isInContacts,
3557 @Nullable CallScreeningService.CallResponse callResponse,
3558 @Nullable ComponentName callScreeningComponent) {
3559 mIsBlocked = isBlocked;
3560 mIsInContacts = isInContacts;
3561 mCallResponse = callResponse;
3562 mCallScreeningComponent = callScreeningComponent;
3563 }
3564
3565 /** @hide */
3566 protected CallFilteringCompletionInfo(Parcel in) {
3567 mIsBlocked = in.readByte() != 0;
3568 mIsInContacts = in.readByte() != 0;
3569 CallScreeningService.ParcelableCallResponse response
Bernardo Rufino90bb3702021-12-07 20:01:45 +00003570 = in.readParcelable(CallScreeningService.class.getClassLoader(), android.telecom.CallScreeningService.ParcelableCallResponse.class);
Hall Liu73903142021-02-18 18:41:41 -08003571 mCallResponse = response == null ? null : response.toCallResponse();
Bernardo Rufino90bb3702021-12-07 20:01:45 +00003572 mCallScreeningComponent = in.readParcelable(ComponentName.class.getClassLoader(), android.content.ComponentName.class);
Hall Liu73903142021-02-18 18:41:41 -08003573 }
3574
3575 @NonNull
3576 public static final Creator<CallFilteringCompletionInfo> CREATOR =
3577 new Creator<CallFilteringCompletionInfo>() {
3578 @Override
3579 public CallFilteringCompletionInfo createFromParcel(Parcel in) {
3580 return new CallFilteringCompletionInfo(in);
3581 }
3582
3583 @Override
3584 public CallFilteringCompletionInfo[] newArray(int size) {
3585 return new CallFilteringCompletionInfo[size];
3586 }
3587 };
3588
3589 /**
3590 * @return Whether any part of the call filtering process indicated that this call should be
3591 * blocked.
3592 */
3593 public boolean isBlocked() {
3594 return mIsBlocked;
3595 }
3596
3597 /**
3598 * @return Whether the caller is in the user's contacts.
3599 */
3600 public boolean isInContacts() {
3601 return mIsInContacts;
3602 }
3603
3604 /**
3605 * @return The instance of {@link CallScreeningService.CallResponse} provided
3606 * by the {@link CallScreeningService} that processed this
3607 * call, or {@code null} if no call screening service ran.
3608 */
3609 public @Nullable CallScreeningService.CallResponse getCallResponse() {
3610 return mCallResponse;
3611 }
3612
3613 /**
3614 * @return The component of the {@link CallScreeningService}
3615 * that processed this call, or {@code null} if no call screening service ran.
3616 */
3617 public @Nullable ComponentName getCallScreeningComponent() {
3618 return mCallScreeningComponent;
3619 }
3620
3621 @Override
3622 public int describeContents() {
3623 return 0;
3624 }
3625
3626 @Override
3627 public String toString() {
3628 return "CallFilteringCompletionInfo{" +
3629 "mIsBlocked=" + mIsBlocked +
3630 ", mIsInContacts=" + mIsInContacts +
3631 ", mCallResponse=" + mCallResponse +
3632 ", mCallScreeningPackageName='" + mCallScreeningComponent + '\'' +
3633 '}';
3634 }
3635
3636 /** @hide */
3637 @Override
3638 public void writeToParcel(Parcel dest, int flags) {
3639 dest.writeByte((byte) (mIsBlocked ? 1 : 0));
3640 dest.writeByte((byte) (mIsInContacts ? 1 : 0));
3641 dest.writeParcelable(mCallResponse == null ? null : mCallResponse.toParcelable(), 0);
3642 dest.writeParcelable(mCallScreeningComponent, 0);
3643 }
3644 }
3645
3646 /**
Hall Liu49cabcc2021-01-15 11:41:48 -08003647 * Indicates that call filtering in Telecom is complete
3648 *
3649 * This method is called for a connection created via
3650 * {@link ConnectionService#onCreateIncomingConnection} when call filtering completes in
3651 * Telecom, including checking the blocked number db, per-contact settings, and custom call
3652 * filtering apps.
3653 *
Hall Liu73903142021-02-18 18:41:41 -08003654 * @param callFilteringCompletionInfo Info provided by Telecom on the results of call filtering.
Hall Liu49cabcc2021-01-15 11:41:48 -08003655 * @hide
3656 */
3657 @SystemApi
3658 @RequiresPermission(Manifest.permission.READ_CONTACTS)
Hall Liu73903142021-02-18 18:41:41 -08003659 public void onCallFilteringCompleted(
3660 @NonNull CallFilteringCompletionInfo callFilteringCompletionInfo) { }
Hall Liu49cabcc2021-01-15 11:41:48 -08003661
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003662 static String toLogSafePhoneNumber(String number) {
3663 // For unknown number, log empty string.
3664 if (number == null) {
3665 return "";
3666 }
3667
3668 if (PII_DEBUG) {
3669 // When PII_DEBUG is true we emit PII.
3670 return number;
3671 }
3672
3673 // Do exactly same thing as Uri#toSafeString() does, which will enable us to compare
3674 // sanitized phone numbers.
3675 StringBuilder builder = new StringBuilder();
3676 for (int i = 0; i < number.length(); i++) {
3677 char c = number.charAt(i);
3678 if (c == '-' || c == '@' || c == '.') {
3679 builder.append(c);
3680 } else {
3681 builder.append('x');
3682 }
3683 }
3684 return builder.toString();
3685 }
3686
Ihab Awad542e0ea2014-05-16 10:22:16 -07003687 private void setState(int state) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003688 checkImmutable();
Ihab Awad6107bab2014-08-18 09:23:25 -07003689 if (mState == STATE_DISCONNECTED && mState != state) {
3690 Log.d(this, "Connection already DISCONNECTED; cannot transition out of this state.");
Evan Charltonbf11f982014-07-20 22:06:28 -07003691 return;
Sailesh Nepal400cc482014-06-26 12:04:00 -07003692 }
Evan Charltonbf11f982014-07-20 22:06:28 -07003693 if (mState != state) {
3694 Log.d(this, "setState: %s", stateToString(state));
3695 mState = state;
Nancy Chen354b2bd2014-09-08 18:27:26 -07003696 onStateChanged(state);
Evan Charltonbf11f982014-07-20 22:06:28 -07003697 for (Listener l : mListeners) {
3698 l.onStateChanged(this, state);
3699 }
Evan Charltonbf11f982014-07-20 22:06:28 -07003700 }
3701 }
3702
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07003703 private static class FailureSignalingConnection extends Connection {
Ihab Awad90e34e32014-12-01 16:23:17 -08003704 private boolean mImmutable = false;
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003705 public FailureSignalingConnection(DisconnectCause disconnectCause) {
3706 setDisconnected(disconnectCause);
Tyler Gunn2915af72020-03-06 11:36:21 -08003707 mImmutable = true;
Ihab Awad6107bab2014-08-18 09:23:25 -07003708 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003709
3710 public void checkImmutable() {
Ihab Awad90e34e32014-12-01 16:23:17 -08003711 if (mImmutable) {
3712 throw new UnsupportedOperationException("Connection is immutable");
3713 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003714 }
Ihab Awad6107bab2014-08-18 09:23:25 -07003715 }
3716
Evan Charltonbf11f982014-07-20 22:06:28 -07003717 /**
Ihab Awad6107bab2014-08-18 09:23:25 -07003718 * Return a {@code Connection} which represents a failed connection attempt. The returned
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003719 * {@code Connection} will have a {@link android.telecom.DisconnectCause} and as specified,
3720 * and a {@link #getState()} of {@link #STATE_DISCONNECTED}.
Ihab Awad6107bab2014-08-18 09:23:25 -07003721 * <p>
3722 * The returned {@code Connection} can be assumed to {@link #destroy()} itself when appropriate,
3723 * so users of this method need not maintain a reference to its return value to destroy it.
Evan Charltonbf11f982014-07-20 22:06:28 -07003724 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003725 * @param disconnectCause The disconnect cause, ({@see android.telecomm.DisconnectCause}).
Ihab Awad6107bab2014-08-18 09:23:25 -07003726 * @return A {@code Connection} which indicates failure.
Evan Charltonbf11f982014-07-20 22:06:28 -07003727 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003728 public static Connection createFailedConnection(DisconnectCause disconnectCause) {
3729 return new FailureSignalingConnection(disconnectCause);
Evan Charltonbf11f982014-07-20 22:06:28 -07003730 }
3731
Evan Charltonbf11f982014-07-20 22:06:28 -07003732 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003733 * Override to throw an {@link UnsupportedOperationException} if this {@code Connection} is
3734 * not intended to be mutated, e.g., if it is a marker for failure. Only for framework use;
3735 * this should never be un-@hide-den.
3736 *
3737 * @hide
3738 */
3739 public void checkImmutable() {}
3740
3741 /**
Ihab Awad6107bab2014-08-18 09:23:25 -07003742 * Return a {@code Connection} which represents a canceled connection attempt. The returned
3743 * {@code Connection} will have state {@link #STATE_DISCONNECTED}, and cannot be moved out of
3744 * that state. This connection should not be used for anything, and no other
3745 * {@code Connection}s should be attempted.
3746 * <p>
Ihab Awad6107bab2014-08-18 09:23:25 -07003747 * so users of this method need not maintain a reference to its return value to destroy it.
Evan Charltonbf11f982014-07-20 22:06:28 -07003748 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003749 * @return A {@code Connection} which indicates that the underlying connection should
3750 * be canceled.
Evan Charltonbf11f982014-07-20 22:06:28 -07003751 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003752 public static Connection createCanceledConnection() {
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003753 return new FailureSignalingConnection(new DisconnectCause(DisconnectCause.CANCELED));
Ihab Awad542e0ea2014-05-16 10:22:16 -07003754 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003755
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003756 private final void fireOnConferenceableConnectionsChanged() {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003757 for (Listener l : mListeners) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003758 l.onConferenceablesChanged(this, getConferenceables());
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003759 }
3760 }
3761
Santos Cordon823fd3c2014-08-07 18:35:18 -07003762 private final void fireConferenceChanged() {
3763 for (Listener l : mListeners) {
3764 l.onConferenceChanged(this, mConference);
3765 }
3766 }
3767
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003768 private final void clearConferenceableList() {
Tyler Gunndf2cbc82015-04-20 09:13:01 -07003769 for (Conferenceable c : mConferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003770 if (c instanceof Connection) {
3771 Connection connection = (Connection) c;
3772 connection.removeConnectionListener(mConnectionDeathListener);
3773 } else if (c instanceof Conference) {
3774 Conference conference = (Conference) c;
3775 conference.removeListener(mConferenceDeathListener);
3776 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003777 }
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003778 mConferenceables.clear();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003779 }
Tyler Gunn3bffcf72014-10-28 13:51:27 -07003780
3781 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07003782 * Handles a change to extras received from Telecom.
3783 *
3784 * @param extras The new extras.
3785 * @hide
3786 */
3787 final void handleExtrasChanged(Bundle extras) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003788 Bundle b = null;
3789 synchronized (mExtrasLock) {
3790 mExtras = extras;
3791 if (mExtras != null) {
3792 b = new Bundle(mExtras);
3793 }
3794 }
3795 onExtrasChanged(b);
Tyler Gunndee56a82016-03-23 16:06:34 -07003796 }
3797
3798 /**
Tyler Gunnc63f9082019-10-15 13:19:26 -07003799 * Called by a {@link ConnectionService} to notify Telecom that a {@link Conference#onMerge()}
3800 * request failed.
Anthony Lee17455a32015-04-24 15:25:29 -07003801 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003802 public final void notifyConferenceMergeFailed() {
Anthony Lee17455a32015-04-24 15:25:29 -07003803 for (Listener l : mListeners) {
3804 l.onConferenceMergeFailed(this);
3805 }
3806 }
3807
3808 /**
Srikanth Chintalafcb15012017-05-04 20:58:34 +05303809 * Notifies listeners when phone account is changed. For example, when the PhoneAccount is
3810 * changed due to an emergency call being redialed.
3811 * @param pHandle The new PhoneAccountHandle for this connection.
3812 * @hide
3813 */
3814 public void notifyPhoneAccountChanged(PhoneAccountHandle pHandle) {
3815 for (Listener l : mListeners) {
3816 l.onPhoneAccountChanged(this, pHandle);
3817 }
3818 }
3819
3820 /**
Pengquan Meng70c9885332017-10-02 18:09:03 -07003821 * Sets the {@link PhoneAccountHandle} associated with this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003822 * <p>
3823 * Used by the Telephony {@link ConnectionService} to handle changes to the {@link PhoneAccount}
3824 * which take place after call initiation (important for emergency calling scenarios).
Pengquan Meng70c9885332017-10-02 18:09:03 -07003825 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07003826 * @param phoneAccountHandle the phone account handle to set.
Pengquan Meng70c9885332017-10-02 18:09:03 -07003827 * @hide
3828 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003829 @SystemApi
3830 public void setPhoneAccountHandle(@NonNull PhoneAccountHandle phoneAccountHandle) {
Pengquan Meng70c9885332017-10-02 18:09:03 -07003831 if (mPhoneAccountHandle != phoneAccountHandle) {
3832 mPhoneAccountHandle = phoneAccountHandle;
3833 notifyPhoneAccountChanged(phoneAccountHandle);
3834 }
3835 }
3836
3837 /**
3838 * Returns the {@link PhoneAccountHandle} associated with this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003839 * <p>
3840 * Used by the Telephony {@link ConnectionService} to handle changes to the {@link PhoneAccount}
3841 * which take place after call initiation (important for emergency calling scenarios).
Pengquan Meng70c9885332017-10-02 18:09:03 -07003842 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07003843 * @return the phone account handle specified via
3844 * {@link #setPhoneAccountHandle(PhoneAccountHandle)}, or {@code null} if none was set.
Pengquan Meng70c9885332017-10-02 18:09:03 -07003845 * @hide
3846 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003847 @SystemApi
3848 public @Nullable PhoneAccountHandle getPhoneAccountHandle() {
Pengquan Meng70c9885332017-10-02 18:09:03 -07003849 return mPhoneAccountHandle;
3850 }
3851
3852 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003853 * Sends an event associated with this {@code Connection} with associated event extras to the
3854 * {@link InCallService}.
3855 * <p>
3856 * Connection events are used to communicate point in time information from a
3857 * {@link ConnectionService} to a {@link InCallService} implementations. An example of a
3858 * custom connection event includes notifying the UI when a WIFI call has been handed over to
3859 * LTE, which the InCall UI might use to inform the user that billing charges may apply. The
3860 * Android Telephony framework will send the {@link #EVENT_CALL_MERGE_FAILED} connection event
3861 * when a call to {@link Call#mergeConference()} has failed to complete successfully. A
3862 * connection event could also be used to trigger UI in the {@link InCallService} which prompts
3863 * the user to make a choice (e.g. whether they want to incur roaming costs for making a call),
3864 * which is communicated back via {@link Call#sendCallEvent(String, Bundle)}.
3865 * <p>
3866 * Events are exposed to {@link InCallService} implementations via
3867 * {@link Call.Callback#onConnectionEvent(Call, String, Bundle)}.
3868 * <p>
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003869 * 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 -07003870 * The {@link ConnectionService} must assume that the In-Call UI could even chose to ignore
3871 * some events altogether.
3872 * <p>
3873 * Events should be fully qualified (e.g. {@code com.example.event.MY_EVENT}) to avoid
3874 * conflicts between {@link ConnectionService} implementations. Further, custom
3875 * {@link ConnectionService} implementations shall not re-purpose events in the
3876 * {@code android.*} namespace, nor shall they define new event types in this namespace. When
3877 * defining a custom event type, ensure the contents of the extras {@link Bundle} is clearly
3878 * defined. Extra keys for this bundle should be named similar to the event type (e.g.
3879 * {@code com.example.extra.MY_EXTRA}).
3880 * <p>
3881 * When defining events and the associated extras, it is important to keep their behavior
3882 * consistent when the associated {@link ConnectionService} is updated. Support for deprecated
3883 * events/extras should me maintained to ensure backwards compatibility with older
3884 * {@link InCallService} implementations which were built to support the older behavior.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003885 *
3886 * @param event The connection event.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003887 * @param extras Optional bundle containing extra information associated with the event.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003888 */
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003889 public void sendConnectionEvent(String event, Bundle extras) {
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003890 for (Listener l : mListeners) {
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07003891 l.onConnectionEvent(this, event, extras);
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003892 }
3893 }
Tyler Gunn6986a632019-06-25 13:45:32 -07003894
3895 /**
3896 * @return The direction of the call.
3897 * @hide
3898 */
3899 public final @Call.Details.CallDirection int getCallDirection() {
3900 return mCallDirection;
3901 }
3902
3903 /**
3904 * Sets the direction of this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003905 * <p>
3906 * Used when calling {@link ConnectionService#addExistingConnection} to specify the existing
3907 * call direction.
3908 *
Tyler Gunn6986a632019-06-25 13:45:32 -07003909 * @param callDirection The direction of this connection.
3910 * @hide
3911 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003912 @SystemApi
Tyler Gunn6986a632019-06-25 13:45:32 -07003913 public void setCallDirection(@Call.Details.CallDirection int callDirection) {
3914 mCallDirection = callDirection;
3915 }
Tyler Gunnd57d76c2019-09-24 14:53:23 -07003916
3917 /**
3918 * Gets the verification status for the phone number of an incoming call as identified in
3919 * ATIS-1000082.
3920 * @return the verification status.
3921 */
Tyler Gunna131d6e2020-02-13 14:53:28 -08003922 public final @VerificationStatus int getCallerNumberVerificationStatus() {
Tyler Gunnd57d76c2019-09-24 14:53:23 -07003923 return mCallerNumberVerificationStatus;
3924 }
3925
3926 /**
3927 * Sets the verification status for the phone number of an incoming call as identified in
3928 * ATIS-1000082.
3929 * <p>
3930 * This property can only be set at the time of creation of a {@link Connection} being returned
3931 * by
3932 * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)}.
3933 */
Tyler Gunna131d6e2020-02-13 14:53:28 -08003934 public final void setCallerNumberVerificationStatus(
Tyler Gunnd57d76c2019-09-24 14:53:23 -07003935 @VerificationStatus int callerNumberVerificationStatus) {
3936 mCallerNumberVerificationStatus = callerNumberVerificationStatus;
3937 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07003938}