blob: 8808339b1664784f53e92672d684f66d0b18a3c7 [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 Gunnd57d76c2019-09-24 14:53:23 -070019import android.annotation.IntDef;
Tyler Gunndee56a82016-03-23 16:06:34 -070020import android.annotation.NonNull;
Santos Cordon6b7f9552015-05-27 17:21:45 -070021import android.annotation.Nullable;
Yorke Lee4af59352015-05-13 14:14:54 -070022import android.annotation.SystemApi;
Tyler Gunn5567d742019-10-31 13:04:37 -070023import android.annotation.TestApi;
Austin Wanga63a2c02019-12-19 06:38:19 +000024import android.annotation.UnsupportedAppUsage;
Tyler Gunn159f35c2017-03-02 09:28:37 -080025import android.app.Notification;
Hall Liua98f58b52017-11-07 17:59:28 -080026import android.bluetooth.BluetoothDevice;
Tyler Gunn159f35c2017-03-02 09:28:37 -080027import android.content.Intent;
Tyler Gunnb702ef82015-05-29 11:51:53 -070028import android.hardware.camera2.CameraManager;
Ihab Awad542e0ea2014-05-16 10:22:16 -070029import android.net.Uri;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -080030import android.os.Binder;
Santos Cordon6b7f9552015-05-27 17:21:45 -070031import android.os.Bundle;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070032import android.os.Handler;
33import android.os.IBinder;
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -070034import android.os.Looper;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070035import android.os.Message;
Hall Liu95d55872017-01-25 17:12:49 -080036import android.os.ParcelFileDescriptor;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070037import android.os.RemoteException;
Tyler Gunn3fa819c2017-08-04 09:27:26 -070038import android.os.SystemClock;
allenwtsu2aca9892019-11-25 14:38:21 +080039import android.telephony.ims.ImsStreamMediaProfile;
Tyler Gunndee56a82016-03-23 16:06:34 -070040import android.util.ArraySet;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070041import android.view.Surface;
Ihab Awad542e0ea2014-05-16 10:22:16 -070042
Youming Yed6de26e2019-01-30 11:20:35 -080043import com.android.internal.os.SomeArgs;
44import com.android.internal.telecom.IVideoCallback;
45import com.android.internal.telecom.IVideoProvider;
46
Hall Liua549fed2018-02-09 16:40:03 -080047import java.io.FileInputStream;
48import java.io.FileOutputStream;
Hall Liu95d55872017-01-25 17:12:49 -080049import java.io.IOException;
50import java.io.InputStreamReader;
51import java.io.OutputStreamWriter;
Tyler Gunnd57d76c2019-09-24 14:53:23 -070052import java.lang.annotation.Retention;
53import java.lang.annotation.RetentionPolicy;
Hall Liu730a2592018-06-25 19:48:33 -070054import java.nio.channels.Channels;
Santos Cordonb6939982014-06-04 20:20:58 -070055import java.util.ArrayList;
Tyler Gunn071be6f2016-05-10 14:52:33 -070056import java.util.Arrays;
Ihab Awadb19a0bc2014-08-07 19:46:01 -070057import java.util.Collections;
Santos Cordonb6939982014-06-04 20:20:58 -070058import java.util.List;
Ihab Awad542e0ea2014-05-16 10:22:16 -070059import java.util.Set;
Jay Shrauner229e3822014-08-15 09:23:07 -070060import java.util.concurrent.ConcurrentHashMap;
Ihab Awad542e0ea2014-05-16 10:22:16 -070061
62/**
Santos Cordon895d4b82015-06-25 16:41:48 -070063 * Represents a phone call or connection to a remote endpoint that carries voice and/or video
64 * traffic.
Ihab Awad6107bab2014-08-18 09:23:25 -070065 * <p>
66 * Implementations create a custom subclass of {@code Connection} and return it to the framework
67 * as the return value of
68 * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)}
69 * or
70 * {@link ConnectionService#onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
71 * Implementations are then responsible for updating the state of the {@code Connection}, and
72 * must call {@link #destroy()} to signal to the framework that the {@code Connection} is no
73 * longer used and associated resources may be recovered.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -070074 * <p>
75 * Subclasses of {@code Connection} override the {@code on*} methods to provide the the
76 * {@link ConnectionService}'s implementation of calling functionality. The {@code on*} methods are
77 * called by Telecom to inform an instance of a {@code Connection} of actions specific to that
78 * {@code Connection} instance.
79 * <p>
80 * Basic call support requires overriding the following methods: {@link #onAnswer()},
81 * {@link #onDisconnect()}, {@link #onReject()}, {@link #onAbort()}
82 * <p>
83 * Where a {@code Connection} has {@link #CAPABILITY_SUPPORT_HOLD}, the {@link #onHold()} and
84 * {@link #onUnhold()} methods should be overridden to provide hold support for the
85 * {@code Connection}.
86 * <p>
87 * Where a {@code Connection} supports a variation of video calling (e.g. the
88 * {@code CAPABILITY_SUPPORTS_VT_*} capability bits), {@link #onAnswer(int)} should be overridden
89 * to support answering a call as a video call.
90 * <p>
91 * Where a {@code Connection} has {@link #PROPERTY_IS_EXTERNAL_CALL} and
92 * {@link #CAPABILITY_CAN_PULL_CALL}, {@link #onPullExternalCall()} should be overridden to provide
93 * support for pulling the external call.
94 * <p>
95 * Where a {@code Connection} supports conference calling {@link #onSeparate()} should be
96 * overridden.
97 * <p>
98 * There are a number of other {@code on*} methods which a {@code Connection} can choose to
99 * implement, depending on whether it is concerned with the associated calls from Telecom. If,
100 * for example, call events from a {@link InCallService} are handled,
101 * {@link #onCallEvent(String, Bundle)} should be overridden. Another example is
102 * {@link #onExtrasChanged(Bundle)}, which should be overridden if the {@code Connection} wishes to
103 * make use of extra information provided via the {@link Call#putExtras(Bundle)} and
104 * {@link Call#removeExtras(String...)} methods.
Ihab Awad542e0ea2014-05-16 10:22:16 -0700105 */
Yorke Leeabfcfdc2015-05-13 18:55:18 -0700106public abstract class Connection extends Conferenceable {
Ihab Awad542e0ea2014-05-16 10:22:16 -0700107
Santos Cordon895d4b82015-06-25 16:41:48 -0700108 /**
109 * The connection is initializing. This is generally the first state for a {@code Connection}
110 * returned by a {@link ConnectionService}.
111 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700112 public static final int STATE_INITIALIZING = 0;
113
Santos Cordon895d4b82015-06-25 16:41:48 -0700114 /**
115 * The connection is new and not connected.
116 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700117 public static final int STATE_NEW = 1;
118
Santos Cordon895d4b82015-06-25 16:41:48 -0700119 /**
120 * An incoming connection is in the ringing state. During this state, the user's ringer or
121 * vibration feature will be activated.
122 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700123 public static final int STATE_RINGING = 2;
124
Santos Cordon895d4b82015-06-25 16:41:48 -0700125 /**
126 * An outgoing connection is in the dialing state. In this state the other party has not yet
127 * answered the call and the user traditionally hears a ringback tone.
128 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700129 public static final int STATE_DIALING = 3;
130
Santos Cordon895d4b82015-06-25 16:41:48 -0700131 /**
132 * A connection is active. Both parties are connected to the call and can actively communicate.
133 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700134 public static final int STATE_ACTIVE = 4;
135
Santos Cordon895d4b82015-06-25 16:41:48 -0700136 /**
137 * A connection is on hold.
138 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700139 public static final int STATE_HOLDING = 5;
140
Santos Cordon895d4b82015-06-25 16:41:48 -0700141 /**
142 * A connection has been disconnected. This is the final state once the user has been
143 * disconnected from a call either locally, remotely or by an error in the service.
144 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700145 public static final int STATE_DISCONNECTED = 6;
146
Santos Cordon895d4b82015-06-25 16:41:48 -0700147 /**
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700148 * The state of an external connection which is in the process of being pulled from a remote
149 * device to the local device.
150 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -0700151 * A connection can only be in this state if the {@link #PROPERTY_IS_EXTERNAL_CALL} property and
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700152 * {@link #CAPABILITY_CAN_PULL_CALL} capability bits are set on the connection.
153 */
154 public static final int STATE_PULLING_CALL = 7;
155
156 /**
Tyler Gunnd57d76c2019-09-24 14:53:23 -0700157 * Indicates that the network could not perform verification.
158 */
159 public static final int VERIFICATION_STATUS_NOT_VERIFIED = 0;
160
161 /**
162 * Indicates that verification by the network passed. This indicates there is a high likelihood
163 * that the call originated from a valid source.
164 */
165 public static final int VERIFICATION_STATUS_PASSED = 1;
166
167 /**
168 * Indicates that verification by the network failed. This indicates there is a high likelihood
169 * that the call did not originate from a valid source.
170 */
171 public static final int VERIFICATION_STATUS_FAILED = 2;
172
173 /**@hide*/
174 @Retention(RetentionPolicy.SOURCE)
175 @IntDef(prefix = "VERIFICATION_STATUS_", value = {
176 VERIFICATION_STATUS_NOT_VERIFIED,
177 VERIFICATION_STATUS_PASSED,
178 VERIFICATION_STATUS_FAILED
179 })
180 public @interface VerificationStatus {}
181
182 /**
Santos Cordon895d4b82015-06-25 16:41:48 -0700183 * Connection can currently be put on hold or unheld. This is distinct from
184 * {@link #CAPABILITY_SUPPORT_HOLD} in that although a connection may support 'hold' most times,
185 * it does not at the moment support the function. This can be true while the call is in the
186 * state {@link #STATE_DIALING}, for example. During this condition, an in-call UI may
187 * display a disabled 'hold' button.
188 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800189 public static final int CAPABILITY_HOLD = 0x00000001;
190
191 /** Connection supports the hold feature. */
192 public static final int CAPABILITY_SUPPORT_HOLD = 0x00000002;
193
194 /**
195 * Connections within a conference can be merged. A {@link ConnectionService} has the option to
196 * add a {@link Conference} before the child {@link Connection}s are merged. This is how
197 * CDMA-based {@link Connection}s are implemented. For these unmerged {@link Conference}s, this
198 * capability allows a merge button to be shown while the conference is in the foreground
199 * of the in-call UI.
200 * <p>
201 * This is only intended for use by a {@link Conference}.
202 */
203 public static final int CAPABILITY_MERGE_CONFERENCE = 0x00000004;
204
205 /**
206 * Connections within a conference can be swapped between foreground and background.
207 * See {@link #CAPABILITY_MERGE_CONFERENCE} for additional information.
208 * <p>
209 * This is only intended for use by a {@link Conference}.
210 */
211 public static final int CAPABILITY_SWAP_CONFERENCE = 0x00000008;
212
213 /**
214 * @hide
215 */
216 public static final int CAPABILITY_UNUSED = 0x00000010;
217
218 /** Connection supports responding via text option. */
219 public static final int CAPABILITY_RESPOND_VIA_TEXT = 0x00000020;
220
221 /** Connection can be muted. */
222 public static final int CAPABILITY_MUTE = 0x00000040;
223
224 /**
225 * Connection supports conference management. This capability only applies to
226 * {@link Conference}s which can have {@link Connection}s as children.
227 */
228 public static final int CAPABILITY_MANAGE_CONFERENCE = 0x00000080;
229
230 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700231 * Local device supports receiving video.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800232 */
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700233 public static final int CAPABILITY_SUPPORTS_VT_LOCAL_RX = 0x00000100;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800234
235 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700236 * Local device supports transmitting video.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800237 */
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700238 public static final int CAPABILITY_SUPPORTS_VT_LOCAL_TX = 0x00000200;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800239
240 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700241 * Local device supports bidirectional video calling.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800242 */
Andrew Lee9a8f9ce2015-04-10 18:09:46 -0700243 public static final int CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL =
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700244 CAPABILITY_SUPPORTS_VT_LOCAL_RX | CAPABILITY_SUPPORTS_VT_LOCAL_TX;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800245
246 /**
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700247 * Remote device supports receiving video.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800248 */
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700249 public static final int CAPABILITY_SUPPORTS_VT_REMOTE_RX = 0x00000400;
250
251 /**
252 * Remote device supports transmitting video.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700253 */
254 public static final int CAPABILITY_SUPPORTS_VT_REMOTE_TX = 0x00000800;
255
256 /**
257 * Remote device supports bidirectional video calling.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700258 */
Andrew Lee9a8f9ce2015-04-10 18:09:46 -0700259 public static final int CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL =
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700260 CAPABILITY_SUPPORTS_VT_REMOTE_RX | CAPABILITY_SUPPORTS_VT_REMOTE_TX;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800261
262 /**
263 * Connection is able to be separated from its parent {@code Conference}, if any.
264 */
265 public static final int CAPABILITY_SEPARATE_FROM_CONFERENCE = 0x00001000;
266
267 /**
268 * Connection is able to be individually disconnected when in a {@code Conference}.
269 */
270 public static final int CAPABILITY_DISCONNECT_FROM_CONFERENCE = 0x00002000;
271
272 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700273 * Un-used.
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800274 * @hide
275 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700276 public static final int CAPABILITY_UNUSED_2 = 0x00004000;
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800277
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700278 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700279 * Un-used.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700280 * @hide
281 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700282 public static final int CAPABILITY_UNUSED_3 = 0x00008000;
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700283
284 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700285 * Un-used.
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700286 * @hide
287 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700288 public static final int CAPABILITY_UNUSED_4 = 0x00010000;
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700289
Tyler Gunn068085b2015-02-06 13:56:52 -0800290 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700291 * Un-used.
Tyler Gunn068085b2015-02-06 13:56:52 -0800292 * @hide
293 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700294 public static final int CAPABILITY_UNUSED_5 = 0x00020000;
Tyler Gunn068085b2015-02-06 13:56:52 -0800295
Tyler Gunn96d6c402015-03-18 12:39:23 -0700296 /**
Dong Zhou89f41eb2015-03-15 11:59:49 -0500297 * Speed up audio setup for MT call.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700298 * <p>
299 * Used for IMS calls to indicate that mobile-terminated (incoming) call audio setup should take
300 * place as soon as the device answers the call, but prior to it being connected. This is an
301 * optimization some IMS stacks depend on to ensure prompt setup of call audio.
Dong Zhou89f41eb2015-03-15 11:59:49 -0500302 * @hide
Tyler Gunn96d6c402015-03-18 12:39:23 -0700303 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700304 @SystemApi
Tyler Gunn5567d742019-10-31 13:04:37 -0700305 @TestApi
Tyler Gunn96d6c402015-03-18 12:39:23 -0700306 public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00040000;
Tyler Gunn068085b2015-02-06 13:56:52 -0800307
Rekha Kumar07366812015-03-24 16:42:31 -0700308 /**
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700309 * Call can be upgraded to a video call.
Tyler Gunn6e3ecc42018-11-12 11:30:56 -0800310 * @deprecated Use {@link #CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL} and
311 * {@link #CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL} to indicate for a call whether or not
312 * video calling is supported.
Rekha Kumar07366812015-03-24 16:42:31 -0700313 */
314 public static final int CAPABILITY_CAN_UPGRADE_TO_VIDEO = 0x00080000;
315
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700316 /**
317 * For video calls, indicates whether the outgoing video for the call can be paused using
Yorke Lee32f24732015-05-12 16:18:03 -0700318 * the {@link android.telecom.VideoProfile#STATE_PAUSED} VideoState.
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700319 */
320 public static final int CAPABILITY_CAN_PAUSE_VIDEO = 0x00100000;
321
Tyler Gunnd4091732015-06-29 09:15:37 -0700322 /**
323 * For a conference, indicates the conference will not have child connections.
324 * <p>
325 * An example of a conference with child connections is a GSM conference call, where the radio
326 * retains connections to the individual participants of the conference. Another example is an
327 * IMS conference call where conference event package functionality is supported; in this case
328 * the conference server ensures the radio is aware of the participants in the conference, which
329 * are represented by child connections.
330 * <p>
331 * An example of a conference with no child connections is an IMS conference call with no
332 * conference event package support. Such a conference is represented by the radio as a single
333 * connection to the IMS conference server.
334 * <p>
335 * Indicating whether a conference has children or not is important to help user interfaces
336 * visually represent a conference. A conference with no children, for example, will have the
337 * conference connection shown in the list of calls on a Bluetooth device, where if the
338 * conference has children, only the children will be shown in the list of calls on a Bluetooth
339 * device.
340 * @hide
341 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700342 @SystemApi
Tyler Gunn5567d742019-10-31 13:04:37 -0700343 @TestApi
Tyler Gunnd4091732015-06-29 09:15:37 -0700344 public static final int CAPABILITY_CONFERENCE_HAS_NO_CHILDREN = 0x00200000;
345
Bryce Lee81901682015-08-28 16:38:02 -0700346 /**
347 * Indicates that the connection itself wants to handle any sort of reply response, rather than
348 * relying on SMS.
Bryce Lee81901682015-08-28 16:38:02 -0700349 */
350 public static final int CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION = 0x00400000;
351
Tyler Gunnf97a0092016-01-19 15:59:34 -0800352 /**
353 * When set, prevents a video call from being downgraded to an audio-only call.
354 * <p>
355 * Should be set when the VideoState has the {@link VideoProfile#STATE_TX_ENABLED} or
356 * {@link VideoProfile#STATE_RX_ENABLED} bits set to indicate that the connection cannot be
357 * downgraded from a video call back to a VideoState of
358 * {@link VideoProfile#STATE_AUDIO_ONLY}.
359 * <p>
360 * Intuitively, a call which can be downgraded to audio should also have local and remote
361 * video
362 * capabilities (see {@link #CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL} and
363 * {@link #CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL}).
364 */
365 public static final int CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO = 0x00800000;
366
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700367 /**
Tyler Gunn720c6642016-03-22 09:02:47 -0700368 * When set for an external connection, indicates that this {@code Connection} can be pulled
369 * from a remote device to the current device.
370 * <p>
371 * Should only be set on a {@code Connection} where {@link #PROPERTY_IS_EXTERNAL_CALL}
372 * is set.
373 */
374 public static final int CAPABILITY_CAN_PULL_CALL = 0x01000000;
375
Pooja Jaind34698d2017-12-28 14:15:31 +0530376 /** Call supports the deflect feature. */
377 public static final int CAPABILITY_SUPPORT_DEFLECT = 0x02000000;
378
Tyler Gunn720c6642016-03-22 09:02:47 -0700379 //**********************************************************************************************
Pooja Jaind34698d2017-12-28 14:15:31 +0530380 // Next CAPABILITY value: 0x04000000
Tyler Gunn720c6642016-03-22 09:02:47 -0700381 //**********************************************************************************************
382
383 /**
384 * Indicates that the current device callback number should be shown.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700385 * <p>
386 * Supports Telephony calls where CDMA emergency callback mode is active.
Tyler Gunn720c6642016-03-22 09:02:47 -0700387 * @hide
388 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700389 @SystemApi
Tyler Gunn5567d742019-10-31 13:04:37 -0700390 @TestApi
Hall Liu25c7c4d2016-08-30 13:41:02 -0700391 public static final int PROPERTY_EMERGENCY_CALLBACK_MODE = 1<<0;
Tyler Gunn720c6642016-03-22 09:02:47 -0700392
393 /**
394 * Whether the call is a generic conference, where we do not know the precise state of
395 * participants in the conference (eg. on CDMA).
Tyler Gunnc63f9082019-10-15 13:19:26 -0700396 * <p>
397 * Supports legacy telephony CDMA calls.
Tyler Gunn720c6642016-03-22 09:02:47 -0700398 * @hide
399 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700400 @SystemApi
Tyler Gunn5567d742019-10-31 13:04:37 -0700401 @TestApi
Tyler Gunn720c6642016-03-22 09:02:47 -0700402 public static final int PROPERTY_GENERIC_CONFERENCE = 1<<1;
403
404 /**
405 * Connection is using high definition audio.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700406 * <p>
407 * Indicates that the {@link Connection} is using a "high definition" audio codec. This usually
408 * implies something like AMR wideband, but the interpretation of when a call is considered high
409 * definition is left to the {@link ConnectionService} to decide.
410 * <p>
411 * Translates to {@link android.telecom.Call.Details#PROPERTY_HIGH_DEF_AUDIO}.
Tyler Gunn720c6642016-03-22 09:02:47 -0700412 */
413 public static final int PROPERTY_HIGH_DEF_AUDIO = 1<<2;
414
415 /**
416 * Connection is using WIFI.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700417 * <p>
418 * Used to indicate that a call is taking place over WIFI versus a carrier network.
419 * <p>
420 * Translates to {@link android.telecom.Call.Details#PROPERTY_WIFI}.
Tyler Gunn720c6642016-03-22 09:02:47 -0700421 */
422 public static final int PROPERTY_WIFI = 1<<3;
423
424 /**
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700425 * When set, indicates that the {@code Connection} does not actually exist locally for the
426 * {@link ConnectionService}.
427 * <p>
428 * Consider, for example, a scenario where a user has two devices with the same phone number.
429 * When a user places a call on one devices, the telephony stack can represent that call on the
430 * other device by adding is to the {@link ConnectionService} with the
Tyler Gunn720c6642016-03-22 09:02:47 -0700431 * {@link #PROPERTY_IS_EXTERNAL_CALL} capability set.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700432 * <p>
433 * An {@link ConnectionService} should not assume that all {@link InCallService}s will handle
434 * external connections. Only those {@link InCallService}s which have the
435 * {@link TelecomManager#METADATA_INCLUDE_EXTERNAL_CALLS} metadata set to {@code true} in its
436 * manifest will see external connections.
437 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700438 public static final int PROPERTY_IS_EXTERNAL_CALL = 1<<4;
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700439
Brad Ebinger15847072016-05-18 11:08:36 -0700440 /**
441 * Indicates that the connection has CDMA Enhanced Voice Privacy enabled.
442 */
443 public static final int PROPERTY_HAS_CDMA_VOICE_PRIVACY = 1<<5;
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700444
Hall Liu9f332c72016-07-14 15:37:37 -0700445 /**
446 * Indicates that the connection represents a downgraded IMS conference.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700447 * <p>
448 * This property is set when an IMS conference undergoes SRVCC and is re-added to Telecom as a
449 * new entity to indicate that the new connection was a conference.
Hall Liu9f332c72016-07-14 15:37:37 -0700450 * @hide
451 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700452 @SystemApi
Tyler Gunn5567d742019-10-31 13:04:37 -0700453 @TestApi
Hall Liu9f332c72016-07-14 15:37:37 -0700454 public static final int PROPERTY_IS_DOWNGRADED_CONFERENCE = 1<<6;
455
Tyler Gunnf5035432017-01-09 09:43:12 -0800456 /**
457 * Set by the framework to indicate that the {@link Connection} originated from a self-managed
458 * {@link ConnectionService}.
459 * <p>
460 * See {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.
461 */
462 public static final int PROPERTY_SELF_MANAGED = 1<<7;
463
Hall Liu95d55872017-01-25 17:12:49 -0800464 /**
Hall Liuffa4a812017-03-02 16:11:00 -0800465 * Set by the framework to indicate that a connection has an active RTT session associated with
466 * it.
Hall Liu95d55872017-01-25 17:12:49 -0800467 */
468 public static final int PROPERTY_IS_RTT = 1 << 8;
469
Eric Erfanian62706c52017-12-06 16:27:53 -0800470 /**
471 * Set by the framework to indicate that a connection is using assisted dialing.
Tyler Gunn5567d742019-10-31 13:04:37 -0700472 * <p>
473 * This is used for outgoing calls.
474 *
475 * @see TelecomManager#EXTRA_USE_ASSISTED_DIALING
Eric Erfanian62706c52017-12-06 16:27:53 -0800476 */
477 public static final int PROPERTY_ASSISTED_DIALING_USED = 1 << 9;
478
Tyler Gunn5bd90852018-09-21 09:37:07 -0700479 /**
480 * Set by the framework to indicate that the network has identified a Connection as an emergency
481 * call.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700482 * <p>
483 * This is used for incoming (mobile-terminated) calls to indicate the call is from emergency
484 * services.
Tyler Gunn5bd90852018-09-21 09:37:07 -0700485 */
486 public static final int PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL = 1 << 10;
487
Tyler Gunnac60f952019-05-31 07:23:16 -0700488 /**
489 * Set by the framework to indicate that a Conference or Connection is hosted by a device other
490 * than the current one. Used in scenarios where the conference originator is the remote device
491 * and the current device is a participant of that conference.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700492 * <p>
493 * This property is specific to IMS conference calls originating in Telephony.
Tyler Gunnac60f952019-05-31 07:23:16 -0700494 * @hide
495 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700496 @SystemApi
Tyler Gunn5567d742019-10-31 13:04:37 -0700497 @TestApi
Tyler Gunnac60f952019-05-31 07:23:16 -0700498 public static final int PROPERTY_REMOTELY_HOSTED = 1 << 11;
499
Tyler Gunn96d6c402015-03-18 12:39:23 -0700500 //**********************************************************************************************
Tyler Gunnac60f952019-05-31 07:23:16 -0700501 // Next PROPERTY value: 1<<12
Tyler Gunn96d6c402015-03-18 12:39:23 -0700502 //**********************************************************************************************
Tyler Gunn068085b2015-02-06 13:56:52 -0800503
Tyler Gunn335ff2e2015-07-30 14:18:33 -0700504 /**
Tyler Gunn1c687622019-12-20 11:08:13 -0800505 * Indicates that the audio codec is currently not specified or is unknown.
allenwtsu2aca9892019-11-25 14:38:21 +0800506 */
allenwtsu2aca9892019-11-25 14:38:21 +0800507 public static final int AUDIO_CODEC_NONE = ImsStreamMediaProfile.AUDIO_QUALITY_NONE; // 0
Tyler Gunn1c687622019-12-20 11:08:13 -0800508 /**
509 * Adaptive Multi-rate audio codec.
510 */
allenwtsu2aca9892019-11-25 14:38:21 +0800511 public static final int AUDIO_CODEC_AMR = ImsStreamMediaProfile.AUDIO_QUALITY_AMR; // 1
Tyler Gunn1c687622019-12-20 11:08:13 -0800512 /**
513 * Adaptive Multi-rate wideband audio codec.
514 */
allenwtsu2aca9892019-11-25 14:38:21 +0800515 public static final int AUDIO_CODEC_AMR_WB = ImsStreamMediaProfile.AUDIO_QUALITY_AMR_WB; // 2
Tyler Gunn1c687622019-12-20 11:08:13 -0800516 /**
517 * Qualcomm code-excited linear prediction 13 kilobit audio codec.
518 */
allenwtsu2aca9892019-11-25 14:38:21 +0800519 public static final int AUDIO_CODEC_QCELP13K = ImsStreamMediaProfile.AUDIO_QUALITY_QCELP13K; //3
Tyler Gunn1c687622019-12-20 11:08:13 -0800520 /**
521 * Enhanced Variable Rate Codec. See 3GPP2 C.S0014-A.
522 */
allenwtsu2aca9892019-11-25 14:38:21 +0800523 public static final int AUDIO_CODEC_EVRC = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC; // 4
Tyler Gunn1c687622019-12-20 11:08:13 -0800524 /**
525 * Enhanced Variable Rate Codec B. Commonly used on CDMA networks.
526 */
allenwtsu2aca9892019-11-25 14:38:21 +0800527 public static final int AUDIO_CODEC_EVRC_B = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_B; // 5
Tyler Gunn1c687622019-12-20 11:08:13 -0800528 /**
529 * Enhanced Variable Rate Wideband Codec. See RFC5188.
530 */
allenwtsu2aca9892019-11-25 14:38:21 +0800531 public static final int AUDIO_CODEC_EVRC_WB = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_WB; // 6
Tyler Gunn1c687622019-12-20 11:08:13 -0800532 /**
533 * Enhanced Variable Rate Narrowband-Wideband Codec.
534 */
allenwtsu2aca9892019-11-25 14:38:21 +0800535 public static final int AUDIO_CODEC_EVRC_NW = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_NW; // 7
Tyler Gunn1c687622019-12-20 11:08:13 -0800536 /**
537 * GSM Enhanced Full-Rate audio codec, also known as GSM-EFR, GSM 06.60, or simply EFR.
538 */
allenwtsu2aca9892019-11-25 14:38:21 +0800539 public static final int AUDIO_CODEC_GSM_EFR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_EFR; // 8
Tyler Gunn1c687622019-12-20 11:08:13 -0800540 /**
541 * GSM Full-Rate audio codec, also known as GSM-FR, GSM 06.10, GSM, or simply FR.
542 */
allenwtsu2aca9892019-11-25 14:38:21 +0800543 public static final int AUDIO_CODEC_GSM_FR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_FR; // 9
Tyler Gunn1c687622019-12-20 11:08:13 -0800544 /**
545 * GSM Half Rate audio codec.
546 */
allenwtsu2aca9892019-11-25 14:38:21 +0800547 public static final int AUDIO_CODEC_GSM_HR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_HR; // 10
Tyler Gunn1c687622019-12-20 11:08:13 -0800548 /**
549 * ITU-T G711U audio codec.
550 */
allenwtsu2aca9892019-11-25 14:38:21 +0800551 public static final int AUDIO_CODEC_G711U = ImsStreamMediaProfile.AUDIO_QUALITY_G711U; // 11
Tyler Gunn1c687622019-12-20 11:08:13 -0800552 /**
553 * ITU-T G723 audio codec.
554 */
allenwtsu2aca9892019-11-25 14:38:21 +0800555 public static final int AUDIO_CODEC_G723 = ImsStreamMediaProfile.AUDIO_QUALITY_G723; // 12
Tyler Gunn1c687622019-12-20 11:08:13 -0800556 /**
557 * ITU-T G711A audio codec.
558 */
allenwtsu2aca9892019-11-25 14:38:21 +0800559 public static final int AUDIO_CODEC_G711A = ImsStreamMediaProfile.AUDIO_QUALITY_G711A; // 13
Tyler Gunn1c687622019-12-20 11:08:13 -0800560 /**
561 * ITU-T G722 audio codec.
562 */
allenwtsu2aca9892019-11-25 14:38:21 +0800563 public static final int AUDIO_CODEC_G722 = ImsStreamMediaProfile.AUDIO_QUALITY_G722; // 14
Tyler Gunn1c687622019-12-20 11:08:13 -0800564 /**
565 * ITU-T G711AB audio codec.
566 */
allenwtsu2aca9892019-11-25 14:38:21 +0800567 public static final int AUDIO_CODEC_G711AB = ImsStreamMediaProfile.AUDIO_QUALITY_G711AB; // 15
Tyler Gunn1c687622019-12-20 11:08:13 -0800568 /**
569 * ITU-T G729 audio codec.
570 */
allenwtsu2aca9892019-11-25 14:38:21 +0800571 public static final int AUDIO_CODEC_G729 = ImsStreamMediaProfile.AUDIO_QUALITY_G729; // 16
Tyler Gunn1c687622019-12-20 11:08:13 -0800572 /**
573 * Enhanced Voice Services Narrowband audio codec. See 3GPP TS 26.441.
574 */
allenwtsu2aca9892019-11-25 14:38:21 +0800575 public static final int AUDIO_CODEC_EVS_NB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_NB; // 17
Tyler Gunn1c687622019-12-20 11:08:13 -0800576 /**
577 * Enhanced Voice Services Wideband audio codec. See 3GPP TS 26.441.
578 */
allenwtsu2aca9892019-11-25 14:38:21 +0800579 public static final int AUDIO_CODEC_EVS_WB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_WB; // 18
Tyler Gunn1c687622019-12-20 11:08:13 -0800580 /**
581 * Enhanced Voice Services Super-Wideband audio codec. See 3GPP TS 26.441.
582 */
allenwtsu2aca9892019-11-25 14:38:21 +0800583 public static final int AUDIO_CODEC_EVS_SWB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_SWB; // 19
Tyler Gunn1c687622019-12-20 11:08:13 -0800584 /**
585 * Enhanced Voice Services Fullband audio codec. See 3GPP TS 26.441.
586 */
allenwtsu2aca9892019-11-25 14:38:21 +0800587 public static final int AUDIO_CODEC_EVS_FB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_FB; // 20
588
Tyler Gunn1c687622019-12-20 11:08:13 -0800589 /**@hide*/
590 @Retention(RetentionPolicy.SOURCE)
591 @IntDef(prefix = "AUDIO_CODEC_", value = {
592 AUDIO_CODEC_NONE,
593 AUDIO_CODEC_AMR,
594 AUDIO_CODEC_AMR_WB,
595 AUDIO_CODEC_QCELP13K,
596 AUDIO_CODEC_EVRC,
597 AUDIO_CODEC_EVRC_B,
598 AUDIO_CODEC_EVRC_WB,
599 AUDIO_CODEC_EVRC_NW,
600 AUDIO_CODEC_GSM_EFR,
601 AUDIO_CODEC_GSM_FR,
602 AUDIO_CODEC_GSM_HR,
603 AUDIO_CODEC_G711U,
604 AUDIO_CODEC_G723,
605 AUDIO_CODEC_G711A,
606 AUDIO_CODEC_G722,
607 AUDIO_CODEC_G711AB,
608 AUDIO_CODEC_G729,
609 AUDIO_CODEC_EVS_NB,
610 AUDIO_CODEC_EVS_SWB,
611 AUDIO_CODEC_EVS_FB
612 })
613 public @interface AudioCodec {}
614
allenwtsu2aca9892019-11-25 14:38:21 +0800615 /**
Tyler Gunn335ff2e2015-07-30 14:18:33 -0700616 * Connection extra key used to store the last forwarded number associated with the current
617 * connection. Used to communicate to the user interface that the connection was forwarded via
618 * the specified number.
619 */
620 public static final String EXTRA_LAST_FORWARDED_NUMBER =
621 "android.telecom.extra.LAST_FORWARDED_NUMBER";
622
623 /**
624 * Connection extra key used to store a child number associated with the current connection.
625 * Used to communicate to the user interface that the connection was received via
626 * a child address (i.e. phone number) associated with the {@link PhoneAccount}'s primary
627 * address.
628 */
629 public static final String EXTRA_CHILD_ADDRESS = "android.telecom.extra.CHILD_ADDRESS";
630
631 /**
632 * Connection extra key used to store the subject for an incoming call. The user interface can
633 * query this extra and display its contents for incoming calls. Will only be used if the
634 * {@link PhoneAccount} supports the capability {@link PhoneAccount#CAPABILITY_CALL_SUBJECT}.
635 */
636 public static final String EXTRA_CALL_SUBJECT = "android.telecom.extra.CALL_SUBJECT";
637
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800638 /**
Tyler Gunn4b6614e2016-06-22 10:35:13 -0700639 * Boolean connection extra key set on a {@link Connection} in
640 * {@link Connection#STATE_RINGING} state to indicate that answering the call will cause the
641 * current active foreground call to be dropped.
642 */
643 public static final String EXTRA_ANSWERING_DROPS_FG_CALL =
644 "android.telecom.extra.ANSWERING_DROPS_FG_CALL";
645
646 /**
Tyler Gunn37653562017-03-13 18:15:15 -0700647 * String connection extra key set on a {@link Connection} in {@link Connection#STATE_RINGING}
648 * state to indicate the name of the third-party app which is responsible for the current
649 * foreground call.
650 * <p>
651 * Used when {@link #EXTRA_ANSWERING_DROPS_FG_CALL} is true to ensure that the default Phone app
652 * is able to inform the user that answering the new incoming call will cause a call owned by
653 * another app to be dropped when the incoming call is answered.
654 */
655 public static final String EXTRA_ANSWERING_DROPS_FG_CALL_APP_NAME =
656 "android.telecom.extra.ANSWERING_DROPS_FG_CALL_APP_NAME";
657
658 /**
Hall Liu10208662016-06-15 17:55:00 -0700659 * Boolean connection extra key on a {@link Connection} which indicates that adding an
Hall Liuee6e86b2016-07-06 16:32:43 -0700660 * additional call is disallowed.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700661 * <p>
662 * Used for mobile-network calls to identify scenarios where carrier requirements preclude
663 * adding another call at the current time.
Hall Liu10208662016-06-15 17:55:00 -0700664 * @hide
665 */
Tyler Gunnc63f9082019-10-15 13:19:26 -0700666 @SystemApi
Tyler Gunn5567d742019-10-31 13:04:37 -0700667 @TestApi
Hall Liuee6e86b2016-07-06 16:32:43 -0700668 public static final String EXTRA_DISABLE_ADD_CALL =
669 "android.telecom.extra.DISABLE_ADD_CALL";
Hall Liu10208662016-06-15 17:55:00 -0700670
671 /**
Tyler Gunncd6ccfd2016-10-17 15:48:19 -0700672 * String connection extra key on a {@link Connection} or {@link Conference} which contains the
673 * original Connection ID associated with the connection. Used in
674 * {@link RemoteConnectionService} to track the Connection ID which was originally assigned to a
675 * connection/conference added via
676 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)} and
677 * {@link ConnectionService#addConference(Conference)} APIs. This is important to pass to
678 * Telecom for when it deals with RemoteConnections. When the ConnectionManager wraps the
679 * {@link RemoteConnection} and {@link RemoteConference} and adds it to Telecom, there needs to
680 * be a way to ensure that we don't add the connection again as a duplicate.
681 * <p>
682 * For example, the TelephonyCS calls addExistingConnection for a Connection with ID
683 * {@code TelephonyCS@1}. The ConnectionManager learns of this via
684 * {@link ConnectionService#onRemoteExistingConnectionAdded(RemoteConnection)}, and wraps this
685 * in a new {@link Connection} which it adds to Telecom via
686 * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)}. As part of
687 * this process, the wrapped RemoteConnection gets assigned a new ID (e.g. {@code ConnMan@1}).
688 * The TelephonyCS will ALSO try to add the existing connection to Telecom, except with the
689 * ID it originally referred to the connection as. Thus Telecom needs to know that the
690 * Connection with ID {@code ConnMan@1} is really the same as {@code TelephonyCS@1}.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700691 * <p>
692 * This is an internal Telecom framework concept and is not exposed outside of the Telecom
693 * framework.
Tyler Gunncd6ccfd2016-10-17 15:48:19 -0700694 * @hide
695 */
696 public static final String EXTRA_ORIGINAL_CONNECTION_ID =
697 "android.telecom.extra.ORIGINAL_CONNECTION_ID";
698
699 /**
Wileen Chiuf2ec2982018-07-01 14:21:50 -0700700 * Boolean connection extra key set on the extras passed to
701 * {@link Connection#sendConnectionEvent} which indicates that audio is present
702 * on the RTT call when the extra value is true.
703 */
704 public static final String EXTRA_IS_RTT_AUDIO_PRESENT =
705 "android.telecom.extra.IS_RTT_AUDIO_PRESENT";
706
707 /**
Tyler Gunn1c687622019-12-20 11:08:13 -0800708 * The audio codec in use for the current {@link Connection}, if known. Examples of valid
709 * values include {@link #AUDIO_CODEC_AMR_WB} and {@link #AUDIO_CODEC_EVS_WB}.
allenwtsu2aca9892019-11-25 14:38:21 +0800710 */
Tyler Gunn1c687622019-12-20 11:08:13 -0800711 public static final @AudioCodec String EXTRA_AUDIO_CODEC =
allenwtsu2aca9892019-11-25 14:38:21 +0800712 "android.telecom.extra.AUDIO_CODEC";
713
714 /**
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800715 * Connection event used to inform Telecom that it should play the on hold tone. This is used
716 * to play a tone when the peer puts the current call on hold. Sent to Telecom via
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700717 * {@link #sendConnectionEvent(String, Bundle)}.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800718 */
719 public static final String EVENT_ON_HOLD_TONE_START =
720 "android.telecom.event.ON_HOLD_TONE_START";
721
722 /**
723 * Connection event used to inform Telecom that it should stop the on hold tone. This is used
724 * to stop a tone when the peer puts the current call on hold. Sent to Telecom via
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700725 * {@link #sendConnectionEvent(String, Bundle)}.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -0800726 */
727 public static final String EVENT_ON_HOLD_TONE_END =
728 "android.telecom.event.ON_HOLD_TONE_END";
729
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700730 /**
731 * Connection event used to inform {@link InCallService}s when pulling of an external call has
732 * failed. The user interface should inform the user of the error.
733 * <p>
734 * Expected to be used by the {@link ConnectionService} when the {@link Call#pullExternalCall()}
735 * API is called on a {@link Call} with the properties
736 * {@link Call.Details#PROPERTY_IS_EXTERNAL_CALL} and
737 * {@link Call.Details#CAPABILITY_CAN_PULL_CALL}, but the {@link ConnectionService} could not
738 * pull the external call due to an error condition.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700739 * <p>
740 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
741 * expected to be null when this connection event is used.
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700742 */
743 public static final String EVENT_CALL_PULL_FAILED = "android.telecom.event.CALL_PULL_FAILED";
744
Brad Ebinger2c1c16452016-05-27 15:58:10 -0700745 /**
746 * Connection event used to inform {@link InCallService}s when the merging of two calls has
747 * failed. The User Interface should use this message to inform the user of the error.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700748 * <p>
749 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
750 * expected to be null when this connection event is used.
Brad Ebinger2c1c16452016-05-27 15:58:10 -0700751 */
752 public static final String EVENT_CALL_MERGE_FAILED = "android.telecom.event.CALL_MERGE_FAILED";
753
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700754 /**
Hall Liu06ae75b2019-03-11 19:11:35 -0700755 * Connection event used to inform Telecom when a hold operation on a call has failed.
Tyler Gunnc63f9082019-10-15 13:19:26 -0700756 * <p>
Hall Liu06ae75b2019-03-11 19:11:35 -0700757 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
758 * expected to be null when this connection event is used.
Hall Liu06ae75b2019-03-11 19:11:35 -0700759 */
760 public static final String EVENT_CALL_HOLD_FAILED = "android.telecom.event.CALL_HOLD_FAILED";
761
762 /**
Masaho Nishikawacb8fa742019-11-07 14:41:21 +0900763 * Connection event used to inform Telecom when a switch operation on a call has failed.
764 * <p>
765 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
766 * expected to be null when this connection event is used.
767 */
768 public static final String EVENT_CALL_SWITCH_FAILED =
769 "android.telecom.event.CALL_SWITCH_FAILED";
770
771 /**
Tyler Gunn78da7812017-05-09 14:34:57 -0700772 * Connection event used to inform {@link InCallService}s when the process of merging a
773 * Connection into a conference has begun.
774 * <p>
775 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
776 * expected to be null when this connection event is used.
Tyler Gunn78da7812017-05-09 14:34:57 -0700777 */
778 public static final String EVENT_MERGE_START = "android.telecom.event.MERGE_START";
779
780 /**
781 * Connection event used to inform {@link InCallService}s when the process of merging a
782 * Connection into a conference has completed.
783 * <p>
784 * Sent via {@link #sendConnectionEvent(String, Bundle)}. The {@link Bundle} parameter is
785 * expected to be null when this connection event is used.
Tyler Gunn78da7812017-05-09 14:34:57 -0700786 */
787 public static final String EVENT_MERGE_COMPLETE = "android.telecom.event.MERGE_COMPLETE";
788
789 /**
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700790 * Connection event used to inform {@link InCallService}s when a call has been put on hold by
791 * the remote party.
792 * <p>
793 * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the
794 * call is being held locally on the device. When a capable {@link ConnectionService} receives
795 * signalling to indicate that the remote party has put the call on hold, it can send this
796 * connection event.
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700797 */
798 public static final String EVENT_CALL_REMOTELY_HELD =
799 "android.telecom.event.CALL_REMOTELY_HELD";
800
801 /**
802 * Connection event used to inform {@link InCallService}s when a call which was remotely held
803 * (see {@link #EVENT_CALL_REMOTELY_HELD}) has been un-held by the remote party.
804 * <p>
805 * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the
806 * call is being held locally on the device. When a capable {@link ConnectionService} receives
807 * signalling to indicate that the remote party has taken the call off hold, it can send this
808 * connection event.
Tyler Gunnb5ed8602016-08-17 13:48:27 -0700809 */
810 public static final String EVENT_CALL_REMOTELY_UNHELD =
811 "android.telecom.event.CALL_REMOTELY_UNHELD";
812
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700813 /**
814 * Connection event used to inform an {@link InCallService} which initiated a call handover via
815 * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has
816 * successfully completed.
817 * @hide
Tyler Gunn1a505fa2018-09-14 13:36:38 -0700818 * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated
819 * APIs instead.
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700820 */
821 public static final String EVENT_HANDOVER_COMPLETE =
822 "android.telecom.event.HANDOVER_COMPLETE";
823
824 /**
825 * Connection event used to inform an {@link InCallService} which initiated a call handover via
826 * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has failed
827 * to complete.
828 * @hide
Tyler Gunn1a505fa2018-09-14 13:36:38 -0700829 * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated
830 * APIs instead.
Tyler Gunn9f6f0472017-04-17 18:25:22 -0700831 */
832 public static final String EVENT_HANDOVER_FAILED =
833 "android.telecom.event.HANDOVER_FAILED";
834
shilub7ec9a02018-11-09 15:52:04 -0800835 /**
Shi Lu528eb5b2019-02-08 05:09:11 +0000836 * String Connection extra key used to store SIP invite fields for an incoming call for IMS call
shilub7ec9a02018-11-09 15:52:04 -0800837 */
838 public static final String EXTRA_SIP_INVITE = "android.telecom.extra.SIP_INVITE";
839
Wileen Chiuf2ec2982018-07-01 14:21:50 -0700840 /**
841 * Connection event used to inform an {@link InCallService} that the RTT audio indication
842 * has changed.
843 */
844 public static final String EVENT_RTT_AUDIO_INDICATION_CHANGED =
845 "android.telecom.event.RTT_AUDIO_INDICATION_CHANGED";
846
Ihab Awadb19a0bc2014-08-07 19:46:01 -0700847 // Flag controlling whether PII is emitted into the logs
848 private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG);
849
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800850 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700851 * Renders a set of capability bits ({@code CAPABILITY_*}) as a human readable string.
852 *
853 * @param capabilities A capability bit field.
854 * @return A human readable string representation.
855 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800856 public static String capabilitiesToString(int capabilities) {
Santos Cordon1a749302016-07-26 16:08:53 -0700857 return capabilitiesToStringInternal(capabilities, true /* isLong */);
858 }
859
860 /**
861 * Renders a set of capability bits ({@code CAPABILITY_*}) as a *short* human readable
862 * string.
863 *
864 * @param capabilities A capability bit field.
865 * @return A human readable string representation.
866 * @hide
867 */
868 public static String capabilitiesToStringShort(int capabilities) {
869 return capabilitiesToStringInternal(capabilities, false /* isLong */);
870 }
871
872 private static String capabilitiesToStringInternal(int capabilities, boolean isLong) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800873 StringBuilder builder = new StringBuilder();
Santos Cordon1a749302016-07-26 16:08:53 -0700874 builder.append("[");
875 if (isLong) {
876 builder.append("Capabilities:");
877 }
878
Tyler Gunnc63f9082019-10-15 13:19:26 -0700879 if ((capabilities & CAPABILITY_HOLD) == CAPABILITY_HOLD) {
Santos Cordon1a749302016-07-26 16:08:53 -0700880 builder.append(isLong ? " CAPABILITY_HOLD" : " hld");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800881 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700882 if ((capabilities & CAPABILITY_SUPPORT_HOLD) == CAPABILITY_SUPPORT_HOLD) {
Santos Cordon1a749302016-07-26 16:08:53 -0700883 builder.append(isLong ? " CAPABILITY_SUPPORT_HOLD" : " sup_hld");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800884 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700885 if ((capabilities & CAPABILITY_MERGE_CONFERENCE) == CAPABILITY_MERGE_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -0700886 builder.append(isLong ? " CAPABILITY_MERGE_CONFERENCE" : " mrg_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800887 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700888 if ((capabilities & CAPABILITY_SWAP_CONFERENCE) == CAPABILITY_SWAP_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -0700889 builder.append(isLong ? " CAPABILITY_SWAP_CONFERENCE" : " swp_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800890 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700891 if ((capabilities & CAPABILITY_RESPOND_VIA_TEXT) == CAPABILITY_RESPOND_VIA_TEXT) {
Santos Cordon1a749302016-07-26 16:08:53 -0700892 builder.append(isLong ? " CAPABILITY_RESPOND_VIA_TEXT" : " txt");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800893 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700894 if ((capabilities & CAPABILITY_MUTE) == CAPABILITY_MUTE) {
Santos Cordon1a749302016-07-26 16:08:53 -0700895 builder.append(isLong ? " CAPABILITY_MUTE" : " mut");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800896 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700897 if ((capabilities & CAPABILITY_MANAGE_CONFERENCE) == CAPABILITY_MANAGE_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -0700898 builder.append(isLong ? " CAPABILITY_MANAGE_CONFERENCE" : " mng_cnf");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800899 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700900 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_RX) == CAPABILITY_SUPPORTS_VT_LOCAL_RX) {
Santos Cordon1a749302016-07-26 16:08:53 -0700901 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_RX" : " VTlrx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700902 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700903 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_TX) == CAPABILITY_SUPPORTS_VT_LOCAL_TX) {
Santos Cordon1a749302016-07-26 16:08:53 -0700904 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_TX" : " VTltx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700905 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700906 if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL)
907 == CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL) {
Santos Cordon1a749302016-07-26 16:08:53 -0700908 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL" : " VTlbi");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800909 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700910 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_RX) == CAPABILITY_SUPPORTS_VT_REMOTE_RX) {
Santos Cordon1a749302016-07-26 16:08:53 -0700911 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_RX" : " VTrrx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700912 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700913 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_TX) == CAPABILITY_SUPPORTS_VT_REMOTE_TX) {
Santos Cordon1a749302016-07-26 16:08:53 -0700914 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_TX" : " VTrtx");
Andrew Lee5e9e8bb2015-03-10 13:58:24 -0700915 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700916 if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL)
917 == CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL) {
Santos Cordon1a749302016-07-26 16:08:53 -0700918 builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL" : " VTrbi");
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800919 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700920 if ((capabilities & CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO)
921 == CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -0700922 builder.append(isLong ? " CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO" : " !v2a");
Tyler Gunnf97a0092016-01-19 15:59:34 -0800923 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700924 if ((capabilities & CAPABILITY_SPEED_UP_MT_AUDIO) == CAPABILITY_SPEED_UP_MT_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -0700925 builder.append(isLong ? " CAPABILITY_SPEED_UP_MT_AUDIO" : " spd_aud");
Dong Zhou89f41eb2015-03-15 11:59:49 -0500926 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700927 if ((capabilities & CAPABILITY_CAN_UPGRADE_TO_VIDEO) == CAPABILITY_CAN_UPGRADE_TO_VIDEO) {
Santos Cordon1a749302016-07-26 16:08:53 -0700928 builder.append(isLong ? " CAPABILITY_CAN_UPGRADE_TO_VIDEO" : " a2v");
Rekha Kumar07366812015-03-24 16:42:31 -0700929 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700930 if ((capabilities & CAPABILITY_CAN_PAUSE_VIDEO) == CAPABILITY_CAN_PAUSE_VIDEO) {
Santos Cordon1a749302016-07-26 16:08:53 -0700931 builder.append(isLong ? " CAPABILITY_CAN_PAUSE_VIDEO" : " paus_VT");
Tyler Gunnb5e0cfb2015-04-07 16:10:51 -0700932 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700933 if ((capabilities & CAPABILITY_CONFERENCE_HAS_NO_CHILDREN)
934 == CAPABILITY_CONFERENCE_HAS_NO_CHILDREN) {
Santos Cordon1a749302016-07-26 16:08:53 -0700935 builder.append(isLong ? " CAPABILITY_SINGLE_PARTY_CONFERENCE" : " 1p_cnf");
Tyler Gunnd4091732015-06-29 09:15:37 -0700936 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700937 if ((capabilities & CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION)
938 == CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION) {
Santos Cordon1a749302016-07-26 16:08:53 -0700939 builder.append(isLong ? " CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION" : " rsp_by_con");
Bryce Lee81901682015-08-28 16:38:02 -0700940 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700941 if ((capabilities & CAPABILITY_CAN_PULL_CALL) == CAPABILITY_CAN_PULL_CALL) {
Santos Cordon1a749302016-07-26 16:08:53 -0700942 builder.append(isLong ? " CAPABILITY_CAN_PULL_CALL" : " pull");
Tyler Gunn876dbfb2016-03-14 15:18:07 -0700943 }
Tyler Gunnc63f9082019-10-15 13:19:26 -0700944 if ((capabilities & CAPABILITY_SUPPORT_DEFLECT) == CAPABILITY_SUPPORT_DEFLECT) {
Pooja Jaind34698d2017-12-28 14:15:31 +0530945 builder.append(isLong ? " CAPABILITY_SUPPORT_DEFLECT" : " sup_def");
946 }
Bryce Lee81901682015-08-28 16:38:02 -0700947
Ihab Awad5c9c86e2014-11-12 13:41:16 -0800948 builder.append("]");
949 return builder.toString();
950 }
951
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -0700952 /**
953 * Renders a set of property bits ({@code PROPERTY_*}) as a human readable string.
954 *
955 * @param properties A property bit field.
956 * @return A human readable string representation.
957 */
Tyler Gunn720c6642016-03-22 09:02:47 -0700958 public static String propertiesToString(int properties) {
Santos Cordon1a749302016-07-26 16:08:53 -0700959 return propertiesToStringInternal(properties, true /* isLong */);
960 }
961
962 /**
963 * Renders a set of property bits ({@code PROPERTY_*}) as a *short* human readable string.
964 *
965 * @param properties A property bit field.
966 * @return A human readable string representation.
967 * @hide
968 */
969 public static String propertiesToStringShort(int properties) {
970 return propertiesToStringInternal(properties, false /* isLong */);
971 }
972
973 private static String propertiesToStringInternal(int properties, boolean isLong) {
Tyler Gunn720c6642016-03-22 09:02:47 -0700974 StringBuilder builder = new StringBuilder();
Santos Cordon1a749302016-07-26 16:08:53 -0700975 builder.append("[");
976 if (isLong) {
977 builder.append("Properties:");
978 }
Tyler Gunn720c6642016-03-22 09:02:47 -0700979
Tyler Gunnc63f9082019-10-15 13:19:26 -0700980 if ((properties & PROPERTY_SELF_MANAGED) == PROPERTY_SELF_MANAGED) {
Tyler Gunnf5035432017-01-09 09:43:12 -0800981 builder.append(isLong ? " PROPERTY_SELF_MANAGED" : " self_mng");
982 }
983
Tyler Gunnc63f9082019-10-15 13:19:26 -0700984 if ((properties & PROPERTY_EMERGENCY_CALLBACK_MODE) == PROPERTY_EMERGENCY_CALLBACK_MODE) {
Hall Liu25c7c4d2016-08-30 13:41:02 -0700985 builder.append(isLong ? " PROPERTY_EMERGENCY_CALLBACK_MODE" : " ecbm");
Tyler Gunn720c6642016-03-22 09:02:47 -0700986 }
987
Tyler Gunnc63f9082019-10-15 13:19:26 -0700988 if ((properties & PROPERTY_HIGH_DEF_AUDIO) == PROPERTY_HIGH_DEF_AUDIO) {
Santos Cordon1a749302016-07-26 16:08:53 -0700989 builder.append(isLong ? " PROPERTY_HIGH_DEF_AUDIO" : " HD");
Tyler Gunn720c6642016-03-22 09:02:47 -0700990 }
991
Tyler Gunnc63f9082019-10-15 13:19:26 -0700992 if ((properties & PROPERTY_WIFI) == PROPERTY_WIFI) {
Santos Cordon1a749302016-07-26 16:08:53 -0700993 builder.append(isLong ? " PROPERTY_WIFI" : " wifi");
Tyler Gunn720c6642016-03-22 09:02:47 -0700994 }
995
Tyler Gunnc63f9082019-10-15 13:19:26 -0700996 if ((properties & PROPERTY_GENERIC_CONFERENCE) == PROPERTY_GENERIC_CONFERENCE) {
Santos Cordon1a749302016-07-26 16:08:53 -0700997 builder.append(isLong ? " PROPERTY_GENERIC_CONFERENCE" : " gen_conf");
Tyler Gunn720c6642016-03-22 09:02:47 -0700998 }
999
Tyler Gunnc63f9082019-10-15 13:19:26 -07001000 if ((properties & PROPERTY_IS_EXTERNAL_CALL) == PROPERTY_IS_EXTERNAL_CALL) {
Santos Cordon1a749302016-07-26 16:08:53 -07001001 builder.append(isLong ? " PROPERTY_IS_EXTERNAL_CALL" : " xtrnl");
Tyler Gunn720c6642016-03-22 09:02:47 -07001002 }
1003
Tyler Gunnc63f9082019-10-15 13:19:26 -07001004 if ((properties & PROPERTY_HAS_CDMA_VOICE_PRIVACY) == PROPERTY_HAS_CDMA_VOICE_PRIVACY) {
Santos Cordon1a749302016-07-26 16:08:53 -07001005 builder.append(isLong ? " PROPERTY_HAS_CDMA_VOICE_PRIVACY" : " priv");
Brad Ebinger15847072016-05-18 11:08:36 -07001006 }
1007
Tyler Gunnc63f9082019-10-15 13:19:26 -07001008 if ((properties & PROPERTY_IS_RTT) == PROPERTY_IS_RTT) {
Hall Liud4d2a8a2018-01-29 17:22:02 -08001009 builder.append(isLong ? " PROPERTY_IS_RTT" : " rtt");
1010 }
1011
Tyler Gunnc63f9082019-10-15 13:19:26 -07001012 if ((properties & PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL)
1013 == PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL) {
Tyler Gunn5bd90852018-09-21 09:37:07 -07001014 builder.append(isLong ? " PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL" : " ecall");
1015 }
1016
Tyler Gunnc63f9082019-10-15 13:19:26 -07001017 if ((properties & PROPERTY_REMOTELY_HOSTED) == PROPERTY_REMOTELY_HOSTED) {
Tyler Gunnac60f952019-05-31 07:23:16 -07001018 builder.append(isLong ? " PROPERTY_REMOTELY_HOSTED" : " remote_hst");
1019 }
1020
Tyler Gunn720c6642016-03-22 09:02:47 -07001021 builder.append("]");
1022 return builder.toString();
1023 }
1024
Sailesh Nepal091768c2014-06-30 15:15:23 -07001025 /** @hide */
Tyler Gunn633e4c32019-10-24 15:40:48 -07001026 abstract static class Listener {
Ihab Awad542e0ea2014-05-16 10:22:16 -07001027 public void onStateChanged(Connection c, int state) {}
Andrew Lee100e2932014-09-08 15:34:24 -07001028 public void onAddressChanged(Connection c, Uri newAddress, int presentation) {}
Sailesh Nepal61203862014-07-11 14:50:13 -07001029 public void onCallerDisplayNameChanged(
1030 Connection c, String callerDisplayName, int presentation) {}
Tyler Gunnaa07df82014-07-17 07:50:22 -07001031 public void onVideoStateChanged(Connection c, int videoState) {}
Andrew Lee7f3d41f2014-09-11 17:33:16 -07001032 public void onDisconnected(Connection c, DisconnectCause disconnectCause) {}
Sailesh Nepal091768c2014-06-30 15:15:23 -07001033 public void onPostDialWait(Connection c, String remaining) {}
Nancy Chen27d1c2d2014-12-15 16:12:50 -08001034 public void onPostDialChar(Connection c, char nextChar) {}
Andrew Lee100e2932014-09-08 15:34:24 -07001035 public void onRingbackRequested(Connection c, boolean ringback) {}
Sailesh Nepal61203862014-07-11 14:50:13 -07001036 public void onDestroyed(Connection c) {}
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001037 public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {}
Tyler Gunn720c6642016-03-22 09:02:47 -07001038 public void onConnectionPropertiesChanged(Connection c, int properties) {}
Christine Hallstrom2830ce92016-11-30 16:06:42 -08001039 public void onSupportedAudioRoutesChanged(Connection c, int supportedAudioRoutes) {}
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001040 public void onVideoProviderChanged(
1041 Connection c, VideoProvider videoProvider) {}
Sailesh Nepal001bbbb2014-07-15 14:40:39 -07001042 public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {}
1043 public void onStatusHintsChanged(Connection c, StatusHints statusHints) {}
Tyler Gunn6d76ca02014-11-17 15:49:51 -08001044 public void onConferenceablesChanged(
Tyler Gunndf2cbc82015-04-20 09:13:01 -07001045 Connection c, List<Conferenceable> conferenceables) {}
Santos Cordon823fd3c2014-08-07 18:35:18 -07001046 public void onConferenceChanged(Connection c, Conference conference) {}
Anthony Lee17455a32015-04-24 15:25:29 -07001047 public void onConferenceMergeFailed(Connection c) {}
Santos Cordon6b7f9552015-05-27 17:21:45 -07001048 public void onExtrasChanged(Connection c, Bundle extras) {}
Tyler Gunndee56a82016-03-23 16:06:34 -07001049 public void onExtrasRemoved(Connection c, List<String> keys) {}
Tyler Gunn876dbfb2016-03-14 15:18:07 -07001050 public void onConnectionEvent(Connection c, String event, Bundle extras) {}
Hall Liua98f58b52017-11-07 17:59:28 -08001051 public void onAudioRouteChanged(Connection c, int audioRoute, String bluetoothAddress) {}
Hall Liub64ac4c2017-02-06 10:49:48 -08001052 public void onRttInitiationSuccess(Connection c) {}
1053 public void onRttInitiationFailure(Connection c, int reason) {}
1054 public void onRttSessionRemotelyTerminated(Connection c) {}
1055 public void onRemoteRttRequest(Connection c) {}
Srikanth Chintalafcb15012017-05-04 20:58:34 +05301056 /** @hide */
1057 public void onPhoneAccountChanged(Connection c, PhoneAccountHandle pHandle) {}
Mengjun Leng25707742017-07-04 11:10:37 +08001058 public void onConnectionTimeReset(Connection c) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07001059 }
1060
Tyler Gunnb702ef82015-05-29 11:51:53 -07001061 /**
Hall Liu95d55872017-01-25 17:12:49 -08001062 * Provides methods to read and write RTT data to/from the in-call app.
Hall Liu95d55872017-01-25 17:12:49 -08001063 */
1064 public static final class RttTextStream {
1065 private static final int READ_BUFFER_SIZE = 1000;
1066 private final InputStreamReader mPipeFromInCall;
1067 private final OutputStreamWriter mPipeToInCall;
Hall Liub64ac4c2017-02-06 10:49:48 -08001068 private final ParcelFileDescriptor mFdFromInCall;
1069 private final ParcelFileDescriptor mFdToInCall;
Hall Liu17eb1bd2018-07-03 15:17:41 -07001070
1071 private final FileInputStream mFromInCallFileInputStream;
Hall Liu95d55872017-01-25 17:12:49 -08001072 private char[] mReadBuffer = new char[READ_BUFFER_SIZE];
1073
1074 /**
1075 * @hide
1076 */
1077 public RttTextStream(ParcelFileDescriptor toInCall, ParcelFileDescriptor fromInCall) {
Hall Liub64ac4c2017-02-06 10:49:48 -08001078 mFdFromInCall = fromInCall;
1079 mFdToInCall = toInCall;
Hall Liu17eb1bd2018-07-03 15:17:41 -07001080 mFromInCallFileInputStream = new FileInputStream(fromInCall.getFileDescriptor());
Hall Liu730a2592018-06-25 19:48:33 -07001081
1082 // Wrap the FileInputStream in a Channel so that it's interruptible.
Hall Liu95d55872017-01-25 17:12:49 -08001083 mPipeFromInCall = new InputStreamReader(
Hall Liu17eb1bd2018-07-03 15:17:41 -07001084 Channels.newInputStream(Channels.newChannel(mFromInCallFileInputStream)));
Hall Liu95d55872017-01-25 17:12:49 -08001085 mPipeToInCall = new OutputStreamWriter(
Hall Liua549fed2018-02-09 16:40:03 -08001086 new FileOutputStream(toInCall.getFileDescriptor()));
Hall Liu95d55872017-01-25 17:12:49 -08001087 }
1088
1089 /**
1090 * Writes the string {@param input} into the text stream to the UI for this RTT call. Since
1091 * RTT transmits text in real-time, this method should be called as often as text snippets
1092 * are received from the remote user, even if it is only one character.
Hall Liua549fed2018-02-09 16:40:03 -08001093 * <p>
Hall Liu95d55872017-01-25 17:12:49 -08001094 * This method is not thread-safe -- calling it from multiple threads simultaneously may
1095 * lead to interleaved text.
Hall Liua549fed2018-02-09 16:40:03 -08001096 *
Hall Liu95d55872017-01-25 17:12:49 -08001097 * @param input The message to send to the in-call app.
1098 */
1099 public void write(String input) throws IOException {
1100 mPipeToInCall.write(input);
1101 mPipeToInCall.flush();
1102 }
1103
1104
1105 /**
1106 * Reads a string from the in-call app, blocking if there is no data available. Returns
1107 * {@code null} if the RTT conversation has been terminated and there is no further data
1108 * to read.
Hall Liua549fed2018-02-09 16:40:03 -08001109 * <p>
Hall Liu95d55872017-01-25 17:12:49 -08001110 * This method is not thread-safe -- calling it from multiple threads simultaneously may
1111 * lead to interleaved text.
Hall Liua549fed2018-02-09 16:40:03 -08001112 *
Hall Liu95d55872017-01-25 17:12:49 -08001113 * @return A string containing text entered by the user, or {@code null} if the
1114 * conversation has been terminated or if there was an error while reading.
1115 */
Hall Liuffa4a812017-03-02 16:11:00 -08001116 public String read() throws IOException {
1117 int numRead = mPipeFromInCall.read(mReadBuffer, 0, READ_BUFFER_SIZE);
1118 if (numRead < 0) {
1119 return null;
1120 }
1121 return new String(mReadBuffer, 0, numRead);
1122 }
1123
1124 /**
1125 * Non-blocking version of {@link #read()}. Returns {@code null} if there is nothing to
1126 * be read.
Hall Liua549fed2018-02-09 16:40:03 -08001127 *
Hall Liuffa4a812017-03-02 16:11:00 -08001128 * @return A string containing text entered by the user, or {@code null} if the user has
1129 * not entered any new text yet.
1130 */
1131 public String readImmediately() throws IOException {
Hall Liu17eb1bd2018-07-03 15:17:41 -07001132 if (mFromInCallFileInputStream.available() > 0) {
Hall Liuffa4a812017-03-02 16:11:00 -08001133 return read();
1134 } else {
Hall Liu95d55872017-01-25 17:12:49 -08001135 return null;
1136 }
1137 }
Hall Liub64ac4c2017-02-06 10:49:48 -08001138
1139 /** @hide */
1140 public ParcelFileDescriptor getFdFromInCall() {
1141 return mFdFromInCall;
1142 }
1143
1144 /** @hide */
1145 public ParcelFileDescriptor getFdToInCall() {
1146 return mFdToInCall;
1147 }
1148 }
1149
1150 /**
1151 * Provides constants to represent the results of responses to session modify requests sent via
1152 * {@link Call#sendRttRequest()}
1153 */
1154 public static final class RttModifyStatus {
Hall Liu8dd49082017-04-21 14:33:12 -07001155 private RttModifyStatus() {}
Hall Liub64ac4c2017-02-06 10:49:48 -08001156 /**
1157 * Session modify request was successful.
1158 */
1159 public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1;
1160
1161 /**
1162 * Session modify request failed.
1163 */
1164 public static final int SESSION_MODIFY_REQUEST_FAIL = 2;
1165
1166 /**
1167 * Session modify request ignored due to invalid parameters.
1168 */
1169 public static final int SESSION_MODIFY_REQUEST_INVALID = 3;
1170
1171 /**
1172 * Session modify request timed out.
1173 */
1174 public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4;
1175
1176 /**
1177 * Session modify request rejected by remote user.
1178 */
1179 public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5;
Hall Liu95d55872017-01-25 17:12:49 -08001180 }
1181
1182 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001183 * Provides a means of controlling the video session associated with a {@link Connection}.
1184 * <p>
1185 * Implementations create a custom subclass of {@link VideoProvider} and the
1186 * {@link ConnectionService} creates an instance sets it on the {@link Connection} using
1187 * {@link Connection#setVideoProvider(VideoProvider)}. Any connection which supports video
1188 * should set the {@link VideoProvider}.
1189 * <p>
1190 * The {@link VideoProvider} serves two primary purposes: it provides a means for Telecom and
1191 * {@link InCallService} implementations to issue requests related to the video session;
1192 * it provides a means for the {@link ConnectionService} to report events and information
1193 * related to the video session to Telecom and the {@link InCallService} implementations.
1194 * <p>
1195 * {@link InCallService} implementations interact with the {@link VideoProvider} via
1196 * {@link android.telecom.InCallService.VideoCall}.
1197 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001198 public static abstract class VideoProvider {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001199 /**
1200 * Video is not being received (no protocol pause was issued).
Tyler Gunnb702ef82015-05-29 11:51:53 -07001201 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001202 */
1203 public static final int SESSION_EVENT_RX_PAUSE = 1;
Evan Charltonbf11f982014-07-20 22:06:28 -07001204
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001205 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001206 * Video reception has resumed after a {@link #SESSION_EVENT_RX_PAUSE}.
1207 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001208 */
1209 public static final int SESSION_EVENT_RX_RESUME = 2;
1210
1211 /**
1212 * Video transmission has begun. This occurs after a negotiated start of video transmission
1213 * when the underlying protocol has actually begun transmitting video to the remote party.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001214 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001215 */
1216 public static final int SESSION_EVENT_TX_START = 3;
1217
1218 /**
1219 * Video transmission has stopped. This occurs after a negotiated stop of video transmission
1220 * when the underlying protocol has actually stopped transmitting video to the remote party.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001221 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001222 */
1223 public static final int SESSION_EVENT_TX_STOP = 4;
1224
1225 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001226 * A camera failure has occurred for the selected camera. The {@link VideoProvider} can use
Tyler Gunnb702ef82015-05-29 11:51:53 -07001227 * this as a cue to inform the user the camera is not available.
1228 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001229 */
1230 public static final int SESSION_EVENT_CAMERA_FAILURE = 5;
1231
1232 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001233 * Issued after {@link #SESSION_EVENT_CAMERA_FAILURE} when the camera is once again ready
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001234 * for operation. The {@link VideoProvider} can use this as a cue to inform the user that
Tyler Gunnb702ef82015-05-29 11:51:53 -07001235 * the camera has become available again.
1236 * @see #handleCallSessionEvent(int)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001237 */
1238 public static final int SESSION_EVENT_CAMERA_READY = 6;
1239
1240 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001241 * Session event raised by Telecom when
1242 * {@link android.telecom.InCallService.VideoCall#setCamera(String)} is called and the
1243 * caller does not have the necessary {@link android.Manifest.permission#CAMERA} permission.
1244 * @see #handleCallSessionEvent(int)
1245 */
1246 public static final int SESSION_EVENT_CAMERA_PERMISSION_ERROR = 7;
1247
1248 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001249 * Session modify request was successful.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001250 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001251 */
1252 public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1;
1253
1254 /**
1255 * Session modify request failed.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001256 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001257 */
1258 public static final int SESSION_MODIFY_REQUEST_FAIL = 2;
1259
1260 /**
1261 * Session modify request ignored due to invalid parameters.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001262 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001263 */
1264 public static final int SESSION_MODIFY_REQUEST_INVALID = 3;
1265
Rekha Kumar07366812015-03-24 16:42:31 -07001266 /**
1267 * Session modify request timed out.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001268 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Rekha Kumar07366812015-03-24 16:42:31 -07001269 */
1270 public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4;
1271
1272 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001273 * Session modify request rejected by remote user.
1274 * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)
Rekha Kumar07366812015-03-24 16:42:31 -07001275 */
1276 public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5;
1277
Tyler Gunn75958422015-04-15 14:23:42 -07001278 private static final int MSG_ADD_VIDEO_CALLBACK = 1;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001279 private static final int MSG_SET_CAMERA = 2;
1280 private static final int MSG_SET_PREVIEW_SURFACE = 3;
1281 private static final int MSG_SET_DISPLAY_SURFACE = 4;
1282 private static final int MSG_SET_DEVICE_ORIENTATION = 5;
1283 private static final int MSG_SET_ZOOM = 6;
1284 private static final int MSG_SEND_SESSION_MODIFY_REQUEST = 7;
1285 private static final int MSG_SEND_SESSION_MODIFY_RESPONSE = 8;
1286 private static final int MSG_REQUEST_CAMERA_CAPABILITIES = 9;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001287 private static final int MSG_REQUEST_CONNECTION_DATA_USAGE = 10;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001288 private static final int MSG_SET_PAUSE_IMAGE = 11;
Tyler Gunn75958422015-04-15 14:23:42 -07001289 private static final int MSG_REMOVE_VIDEO_CALLBACK = 12;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001290
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001291 private static final String SESSION_EVENT_RX_PAUSE_STR = "RX_PAUSE";
1292 private static final String SESSION_EVENT_RX_RESUME_STR = "RX_RESUME";
1293 private static final String SESSION_EVENT_TX_START_STR = "TX_START";
1294 private static final String SESSION_EVENT_TX_STOP_STR = "TX_STOP";
1295 private static final String SESSION_EVENT_CAMERA_FAILURE_STR = "CAMERA_FAIL";
1296 private static final String SESSION_EVENT_CAMERA_READY_STR = "CAMERA_READY";
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001297 private static final String SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR =
1298 "CAMERA_PERMISSION_ERROR";
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001299 private static final String SESSION_EVENT_UNKNOWN_STR = "UNKNOWN";
1300
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001301 private VideoProvider.VideoProviderHandler mMessageHandler;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001302 private final VideoProvider.VideoProviderBinder mBinder;
Tyler Gunn75958422015-04-15 14:23:42 -07001303
1304 /**
1305 * Stores a list of the video callbacks, keyed by IBinder.
Tyler Gunn84f381b2015-06-12 09:26:45 -07001306 *
1307 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
1308 * load factor before resizing, 1 means we only expect a single thread to
1309 * access the map so make only a single shard
Tyler Gunn75958422015-04-15 14:23:42 -07001310 */
Tyler Gunn84f381b2015-06-12 09:26:45 -07001311 private ConcurrentHashMap<IBinder, IVideoCallback> mVideoCallbacks =
1312 new ConcurrentHashMap<IBinder, IVideoCallback>(8, 0.9f, 1);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001313
1314 /**
1315 * Default handler used to consolidate binder method calls onto a single thread.
1316 */
1317 private final class VideoProviderHandler extends Handler {
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001318 public VideoProviderHandler() {
1319 super();
1320 }
1321
1322 public VideoProviderHandler(Looper looper) {
1323 super(looper);
1324 }
1325
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001326 @Override
1327 public void handleMessage(Message msg) {
1328 switch (msg.what) {
Tyler Gunn75958422015-04-15 14:23:42 -07001329 case MSG_ADD_VIDEO_CALLBACK: {
1330 IBinder binder = (IBinder) msg.obj;
1331 IVideoCallback callback = IVideoCallback.Stub
1332 .asInterface((IBinder) msg.obj);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001333 if (callback == null) {
1334 Log.w(this, "addVideoProvider - skipped; callback is null.");
1335 break;
1336 }
1337
Tyler Gunn75958422015-04-15 14:23:42 -07001338 if (mVideoCallbacks.containsKey(binder)) {
1339 Log.i(this, "addVideoProvider - skipped; already present.");
1340 break;
1341 }
1342 mVideoCallbacks.put(binder, callback);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001343 break;
Tyler Gunn75958422015-04-15 14:23:42 -07001344 }
1345 case MSG_REMOVE_VIDEO_CALLBACK: {
1346 IBinder binder = (IBinder) msg.obj;
1347 IVideoCallback callback = IVideoCallback.Stub
1348 .asInterface((IBinder) msg.obj);
1349 if (!mVideoCallbacks.containsKey(binder)) {
1350 Log.i(this, "removeVideoProvider - skipped; not present.");
1351 break;
1352 }
1353 mVideoCallbacks.remove(binder);
1354 break;
1355 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001356 case MSG_SET_CAMERA:
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001357 {
1358 SomeArgs args = (SomeArgs) msg.obj;
1359 try {
1360 onSetCamera((String) args.arg1);
1361 onSetCamera((String) args.arg1, (String) args.arg2, args.argi1,
Tyler Gunn159f35c2017-03-02 09:28:37 -08001362 args.argi2, args.argi3);
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001363 } finally {
1364 args.recycle();
1365 }
1366 }
1367 break;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001368 case MSG_SET_PREVIEW_SURFACE:
1369 onSetPreviewSurface((Surface) msg.obj);
1370 break;
1371 case MSG_SET_DISPLAY_SURFACE:
1372 onSetDisplaySurface((Surface) msg.obj);
1373 break;
1374 case MSG_SET_DEVICE_ORIENTATION:
1375 onSetDeviceOrientation(msg.arg1);
1376 break;
1377 case MSG_SET_ZOOM:
1378 onSetZoom((Float) msg.obj);
1379 break;
Tyler Gunn45382162015-05-06 08:52:27 -07001380 case MSG_SEND_SESSION_MODIFY_REQUEST: {
1381 SomeArgs args = (SomeArgs) msg.obj;
1382 try {
1383 onSendSessionModifyRequest((VideoProfile) args.arg1,
1384 (VideoProfile) args.arg2);
1385 } finally {
1386 args.recycle();
1387 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001388 break;
Tyler Gunn45382162015-05-06 08:52:27 -07001389 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001390 case MSG_SEND_SESSION_MODIFY_RESPONSE:
1391 onSendSessionModifyResponse((VideoProfile) msg.obj);
1392 break;
1393 case MSG_REQUEST_CAMERA_CAPABILITIES:
1394 onRequestCameraCapabilities();
1395 break;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001396 case MSG_REQUEST_CONNECTION_DATA_USAGE:
1397 onRequestConnectionDataUsage();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001398 break;
1399 case MSG_SET_PAUSE_IMAGE:
Yorke Lee32f24732015-05-12 16:18:03 -07001400 onSetPauseImage((Uri) msg.obj);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001401 break;
1402 default:
1403 break;
1404 }
1405 }
1406 }
1407
1408 /**
1409 * IVideoProvider stub implementation.
1410 */
1411 private final class VideoProviderBinder extends IVideoProvider.Stub {
Tyler Gunn75958422015-04-15 14:23:42 -07001412 public void addVideoCallback(IBinder videoCallbackBinder) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001413 mMessageHandler.obtainMessage(
Tyler Gunn75958422015-04-15 14:23:42 -07001414 MSG_ADD_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget();
1415 }
1416
1417 public void removeVideoCallback(IBinder videoCallbackBinder) {
1418 mMessageHandler.obtainMessage(
1419 MSG_REMOVE_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001420 }
1421
Tyler Gunn159f35c2017-03-02 09:28:37 -08001422 public void setCamera(String cameraId, String callingPackageName,
1423 int targetSdkVersion) {
1424
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001425 SomeArgs args = SomeArgs.obtain();
1426 args.arg1 = cameraId;
1427 // Propagate the calling package; originally determined in
1428 // android.telecom.InCallService.VideoCall#setCamera(String) from the calling
1429 // process.
1430 args.arg2 = callingPackageName;
1431 // Pass along the uid and pid of the calling app; this gets lost when we put the
1432 // message onto the handler. These are required for Telecom to perform a permission
1433 // check to see if the calling app is able to use the camera.
1434 args.argi1 = Binder.getCallingUid();
1435 args.argi2 = Binder.getCallingPid();
Tyler Gunn159f35c2017-03-02 09:28:37 -08001436 // Pass along the target SDK version of the calling InCallService. This is used to
1437 // maintain backwards compatibility of the API for older callers.
1438 args.argi3 = targetSdkVersion;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001439 mMessageHandler.obtainMessage(MSG_SET_CAMERA, args).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001440 }
1441
1442 public void setPreviewSurface(Surface surface) {
1443 mMessageHandler.obtainMessage(MSG_SET_PREVIEW_SURFACE, surface).sendToTarget();
1444 }
1445
1446 public void setDisplaySurface(Surface surface) {
1447 mMessageHandler.obtainMessage(MSG_SET_DISPLAY_SURFACE, surface).sendToTarget();
1448 }
1449
1450 public void setDeviceOrientation(int rotation) {
Rekha Kumar07366812015-03-24 16:42:31 -07001451 mMessageHandler.obtainMessage(
1452 MSG_SET_DEVICE_ORIENTATION, rotation, 0).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001453 }
1454
1455 public void setZoom(float value) {
1456 mMessageHandler.obtainMessage(MSG_SET_ZOOM, value).sendToTarget();
1457 }
1458
Tyler Gunn45382162015-05-06 08:52:27 -07001459 public void sendSessionModifyRequest(VideoProfile fromProfile, VideoProfile toProfile) {
1460 SomeArgs args = SomeArgs.obtain();
1461 args.arg1 = fromProfile;
1462 args.arg2 = toProfile;
1463 mMessageHandler.obtainMessage(MSG_SEND_SESSION_MODIFY_REQUEST, args).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001464 }
1465
1466 public void sendSessionModifyResponse(VideoProfile responseProfile) {
1467 mMessageHandler.obtainMessage(
1468 MSG_SEND_SESSION_MODIFY_RESPONSE, responseProfile).sendToTarget();
1469 }
1470
1471 public void requestCameraCapabilities() {
1472 mMessageHandler.obtainMessage(MSG_REQUEST_CAMERA_CAPABILITIES).sendToTarget();
1473 }
1474
1475 public void requestCallDataUsage() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001476 mMessageHandler.obtainMessage(MSG_REQUEST_CONNECTION_DATA_USAGE).sendToTarget();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001477 }
1478
Yorke Lee32f24732015-05-12 16:18:03 -07001479 public void setPauseImage(Uri uri) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001480 mMessageHandler.obtainMessage(MSG_SET_PAUSE_IMAGE, uri).sendToTarget();
1481 }
1482 }
1483
1484 public VideoProvider() {
1485 mBinder = new VideoProvider.VideoProviderBinder();
Tyler Gunn84f381b2015-06-12 09:26:45 -07001486 mMessageHandler = new VideoProvider.VideoProviderHandler(Looper.getMainLooper());
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001487 }
1488
1489 /**
1490 * Creates an instance of the {@link VideoProvider}, specifying the looper to use.
1491 *
1492 * @param looper The looper.
1493 * @hide
1494 */
Mathew Inwood42346d12018-08-01 11:33:05 +01001495 @UnsupportedAppUsage
Tyler Gunn4e9bbaf2015-05-22 15:43:28 -07001496 public VideoProvider(Looper looper) {
1497 mBinder = new VideoProvider.VideoProviderBinder();
1498 mMessageHandler = new VideoProvider.VideoProviderHandler(looper);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001499 }
1500
1501 /**
1502 * Returns binder object which can be used across IPC methods.
1503 * @hide
1504 */
1505 public final IVideoProvider getInterface() {
1506 return mBinder;
1507 }
1508
1509 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001510 * Sets the camera to be used for the outgoing video.
1511 * <p>
1512 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1513 * camera via
1514 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1515 * <p>
1516 * Sent from the {@link InCallService} via
1517 * {@link InCallService.VideoCall#setCamera(String)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001518 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001519 * @param cameraId The id of the camera (use ids as reported by
1520 * {@link CameraManager#getCameraIdList()}).
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001521 */
1522 public abstract void onSetCamera(String cameraId);
1523
1524 /**
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001525 * Sets the camera to be used for the outgoing video.
1526 * <p>
1527 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1528 * camera via
1529 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1530 * <p>
1531 * This prototype is used internally to ensure that the calling package name, UID and PID
1532 * are sent to Telecom so that can perform a camera permission check on the caller.
1533 * <p>
1534 * Sent from the {@link InCallService} via
1535 * {@link InCallService.VideoCall#setCamera(String)}.
1536 *
1537 * @param cameraId The id of the camera (use ids as reported by
1538 * {@link CameraManager#getCameraIdList()}).
1539 * @param callingPackageName The AppOpps package name of the caller.
1540 * @param callingUid The UID of the caller.
1541 * @param callingPid The PID of the caller.
Tyler Gunn159f35c2017-03-02 09:28:37 -08001542 * @param targetSdkVersion The target SDK version of the caller.
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001543 * @hide
1544 */
1545 public void onSetCamera(String cameraId, String callingPackageName, int callingUid,
Tyler Gunn159f35c2017-03-02 09:28:37 -08001546 int callingPid, int targetSdkVersion) {}
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001547
1548 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001549 * Sets the surface to be used for displaying a preview of what the user's camera is
1550 * currently capturing. When video transmission is enabled, this is the video signal which
1551 * is sent to the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001552 * <p>
1553 * Sent from the {@link InCallService} via
1554 * {@link InCallService.VideoCall#setPreviewSurface(Surface)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001555 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001556 * @param surface The {@link Surface}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001557 */
1558 public abstract void onSetPreviewSurface(Surface surface);
1559
1560 /**
1561 * Sets the surface to be used for displaying the video received from the remote device.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001562 * <p>
1563 * Sent from the {@link InCallService} via
1564 * {@link InCallService.VideoCall#setDisplaySurface(Surface)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001565 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001566 * @param surface The {@link Surface}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001567 */
1568 public abstract void onSetDisplaySurface(Surface surface);
1569
1570 /**
1571 * Sets the device orientation, in degrees. Assumes that a standard portrait orientation of
1572 * the device is 0 degrees.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001573 * <p>
1574 * Sent from the {@link InCallService} via
1575 * {@link InCallService.VideoCall#setDeviceOrientation(int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001576 *
1577 * @param rotation The device orientation, in degrees.
1578 */
1579 public abstract void onSetDeviceOrientation(int rotation);
1580
1581 /**
1582 * Sets camera zoom ratio.
Tyler Gunnb702ef82015-05-29 11:51:53 -07001583 * <p>
1584 * Sent from the {@link InCallService} via {@link InCallService.VideoCall#setZoom(float)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001585 *
1586 * @param value The camera zoom ratio.
1587 */
1588 public abstract void onSetZoom(float value);
1589
1590 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001591 * Issues a request to modify the properties of the current video session.
1592 * <p>
1593 * Example scenarios include: requesting an audio-only call to be upgraded to a
1594 * bi-directional video call, turning on or off the user's camera, sending a pause signal
1595 * when the {@link InCallService} is no longer the foreground application.
1596 * <p>
1597 * If the {@link VideoProvider} determines a request to be invalid, it should call
1598 * {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)} to report the
1599 * invalid request back to the {@link InCallService}.
1600 * <p>
1601 * Where a request requires confirmation from the user of the peer device, the
1602 * {@link VideoProvider} must communicate the request to the peer device and handle the
1603 * user's response. {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)}
1604 * is used to inform the {@link InCallService} of the result of the request.
1605 * <p>
1606 * Sent from the {@link InCallService} via
1607 * {@link InCallService.VideoCall#sendSessionModifyRequest(VideoProfile)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001608 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001609 * @param fromProfile The video profile prior to the request.
1610 * @param toProfile The video profile with the requested changes made.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001611 */
Tyler Gunn45382162015-05-06 08:52:27 -07001612 public abstract void onSendSessionModifyRequest(VideoProfile fromProfile,
1613 VideoProfile toProfile);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001614
Tyler Gunnb702ef82015-05-29 11:51:53 -07001615 /**
1616 * Provides a response to a request to change the current video session properties.
1617 * <p>
1618 * For example, if the peer requests and upgrade from an audio-only call to a bi-directional
1619 * video call, could decline the request and keep the call as audio-only.
1620 * In such a scenario, the {@code responseProfile} would have a video state of
1621 * {@link VideoProfile#STATE_AUDIO_ONLY}. If the user had decided to accept the request,
1622 * the video state would be {@link VideoProfile#STATE_BIDIRECTIONAL}.
1623 * <p>
1624 * Sent from the {@link InCallService} via
1625 * {@link InCallService.VideoCall#sendSessionModifyResponse(VideoProfile)} in response to
1626 * a {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)}
1627 * callback.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001628 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001629 * @param responseProfile The response video profile.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001630 */
1631 public abstract void onSendSessionModifyResponse(VideoProfile responseProfile);
1632
1633 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001634 * Issues a request to the {@link VideoProvider} to retrieve the camera capabilities.
1635 * <p>
1636 * The {@link VideoProvider} should respond by communicating the capabilities of the chosen
1637 * camera via
1638 * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}.
1639 * <p>
1640 * Sent from the {@link InCallService} via
1641 * {@link InCallService.VideoCall#requestCameraCapabilities()}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001642 */
1643 public abstract void onRequestCameraCapabilities();
1644
1645 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001646 * Issues a request to the {@link VideoProvider} to retrieve the current data usage for the
1647 * video component of the current {@link Connection}.
1648 * <p>
1649 * The {@link VideoProvider} should respond by communicating current data usage, in bytes,
1650 * via {@link VideoProvider#setCallDataUsage(long)}.
1651 * <p>
1652 * Sent from the {@link InCallService} via
1653 * {@link InCallService.VideoCall#requestCallDataUsage()}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001654 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001655 public abstract void onRequestConnectionDataUsage();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001656
1657 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001658 * Provides the {@link VideoProvider} with the {@link Uri} of an image to be displayed to
1659 * the peer device when the video signal is paused.
1660 * <p>
1661 * Sent from the {@link InCallService} via
1662 * {@link InCallService.VideoCall#setPauseImage(Uri)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001663 *
1664 * @param uri URI of image to display.
1665 */
Yorke Lee32f24732015-05-12 16:18:03 -07001666 public abstract void onSetPauseImage(Uri uri);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001667
1668 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001669 * Used to inform listening {@link InCallService} implementations when the
1670 * {@link VideoProvider} receives a session modification request.
1671 * <p>
1672 * Received by the {@link InCallService} via
1673 * {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)},
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001674 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001675 * @param videoProfile The requested video profile.
1676 * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001677 */
1678 public void receiveSessionModifyRequest(VideoProfile videoProfile) {
Tyler Gunn75958422015-04-15 14:23:42 -07001679 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001680 for (IVideoCallback callback : mVideoCallbacks.values()) {
1681 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001682 callback.receiveSessionModifyRequest(videoProfile);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001683 } catch (RemoteException ignored) {
1684 Log.w(this, "receiveSessionModifyRequest callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001685 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001686 }
1687 }
1688 }
1689
1690 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001691 * Used to inform listening {@link InCallService} implementations when the
1692 * {@link VideoProvider} receives a response to a session modification request.
1693 * <p>
1694 * Received by the {@link InCallService} via
1695 * {@link InCallService.VideoCall.Callback#onSessionModifyResponseReceived(int,
1696 * VideoProfile, VideoProfile)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001697 *
1698 * @param status Status of the session modify request. Valid values are
1699 * {@link VideoProvider#SESSION_MODIFY_REQUEST_SUCCESS},
1700 * {@link VideoProvider#SESSION_MODIFY_REQUEST_FAIL},
Tyler Gunnb702ef82015-05-29 11:51:53 -07001701 * {@link VideoProvider#SESSION_MODIFY_REQUEST_INVALID},
1702 * {@link VideoProvider#SESSION_MODIFY_REQUEST_TIMED_OUT},
1703 * {@link VideoProvider#SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE}
1704 * @param requestedProfile The original request which was sent to the peer device.
1705 * @param responseProfile The actual profile changes agreed to by the peer device.
1706 * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001707 */
1708 public void receiveSessionModifyResponse(int status,
1709 VideoProfile requestedProfile, VideoProfile responseProfile) {
Tyler Gunn75958422015-04-15 14:23:42 -07001710 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001711 for (IVideoCallback callback : mVideoCallbacks.values()) {
1712 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001713 callback.receiveSessionModifyResponse(status, requestedProfile,
1714 responseProfile);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001715 } catch (RemoteException ignored) {
1716 Log.w(this, "receiveSessionModifyResponse callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001717 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001718 }
1719 }
1720 }
1721
1722 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001723 * Used to inform listening {@link InCallService} implementations when the
1724 * {@link VideoProvider} reports a call session event.
1725 * <p>
1726 * Received by the {@link InCallService} via
1727 * {@link InCallService.VideoCall.Callback#onCallSessionEvent(int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001728 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001729 * @param event The event. Valid values are: {@link VideoProvider#SESSION_EVENT_RX_PAUSE},
1730 * {@link VideoProvider#SESSION_EVENT_RX_RESUME},
1731 * {@link VideoProvider#SESSION_EVENT_TX_START},
1732 * {@link VideoProvider#SESSION_EVENT_TX_STOP},
1733 * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE},
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001734 * {@link VideoProvider#SESSION_EVENT_CAMERA_READY},
1735 * {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001736 */
1737 public void handleCallSessionEvent(int event) {
Tyler Gunn75958422015-04-15 14:23:42 -07001738 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001739 for (IVideoCallback callback : mVideoCallbacks.values()) {
1740 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001741 callback.handleCallSessionEvent(event);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001742 } catch (RemoteException ignored) {
1743 Log.w(this, "handleCallSessionEvent callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001744 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001745 }
1746 }
1747 }
1748
1749 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001750 * Used to inform listening {@link InCallService} implementations when the dimensions of the
1751 * peer's video have changed.
1752 * <p>
1753 * This could occur if, for example, the peer rotates their device, changing the aspect
1754 * ratio of the video, or if the user switches between the back and front cameras.
1755 * <p>
1756 * Received by the {@link InCallService} via
1757 * {@link InCallService.VideoCall.Callback#onPeerDimensionsChanged(int, int)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001758 *
1759 * @param width The updated peer video width.
1760 * @param height The updated peer video height.
1761 */
1762 public void changePeerDimensions(int width, int height) {
Tyler Gunn75958422015-04-15 14:23:42 -07001763 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001764 for (IVideoCallback callback : mVideoCallbacks.values()) {
1765 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001766 callback.changePeerDimensions(width, height);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001767 } catch (RemoteException ignored) {
1768 Log.w(this, "changePeerDimensions callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001769 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001770 }
1771 }
1772 }
1773
1774 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001775 * Used to inform listening {@link InCallService} implementations when the data usage of the
1776 * video associated with the current {@link Connection} has changed.
1777 * <p>
1778 * This could be in response to a preview request via
1779 * {@link #onRequestConnectionDataUsage()}, or as a periodic update by the
Tyler Gunn295f5d72015-06-04 11:08:54 -07001780 * {@link VideoProvider}. Where periodic updates of data usage are provided, they should be
1781 * 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 -07001782 * <p>
1783 * Received by the {@link InCallService} via
1784 * {@link InCallService.VideoCall.Callback#onCallDataUsageChanged(long)}.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001785 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001786 * @param dataUsage The updated data usage (in bytes). Reported as the cumulative bytes
1787 * used since the start of the call.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001788 */
Yorke Lee32f24732015-05-12 16:18:03 -07001789 public void setCallDataUsage(long dataUsage) {
Tyler Gunn75958422015-04-15 14:23:42 -07001790 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001791 for (IVideoCallback callback : mVideoCallbacks.values()) {
1792 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001793 callback.changeCallDataUsage(dataUsage);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001794 } catch (RemoteException ignored) {
1795 Log.w(this, "setCallDataUsage callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001796 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001797 }
1798 }
1799 }
1800
1801 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001802 * @see #setCallDataUsage(long)
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001803 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001804 * @param dataUsage The updated data usage (in byes).
Yorke Lee32f24732015-05-12 16:18:03 -07001805 * @deprecated - Use {@link #setCallDataUsage(long)} instead.
1806 * @hide
1807 */
1808 public void changeCallDataUsage(long dataUsage) {
1809 setCallDataUsage(dataUsage);
1810 }
1811
1812 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001813 * Used to inform listening {@link InCallService} implementations when the capabilities of
1814 * the current camera have changed.
1815 * <p>
1816 * The {@link VideoProvider} should call this in response to
1817 * {@link VideoProvider#onRequestCameraCapabilities()}, or when the current camera is
1818 * changed via {@link VideoProvider#onSetCamera(String)}.
1819 * <p>
1820 * Received by the {@link InCallService} via
1821 * {@link InCallService.VideoCall.Callback#onCameraCapabilitiesChanged(
1822 * VideoProfile.CameraCapabilities)}.
Yorke Lee32f24732015-05-12 16:18:03 -07001823 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001824 * @param cameraCapabilities The new camera capabilities.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001825 */
Yorke Lee400470f2015-05-12 13:31:25 -07001826 public void changeCameraCapabilities(VideoProfile.CameraCapabilities cameraCapabilities) {
Tyler Gunn75958422015-04-15 14:23:42 -07001827 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001828 for (IVideoCallback callback : mVideoCallbacks.values()) {
1829 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001830 callback.changeCameraCapabilities(cameraCapabilities);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001831 } catch (RemoteException ignored) {
1832 Log.w(this, "changeCameraCapabilities callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001833 }
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001834 }
1835 }
1836 }
Rekha Kumar07366812015-03-24 16:42:31 -07001837
1838 /**
Tyler Gunnb702ef82015-05-29 11:51:53 -07001839 * Used to inform listening {@link InCallService} implementations when the video quality
1840 * of the call has changed.
1841 * <p>
1842 * Received by the {@link InCallService} via
1843 * {@link InCallService.VideoCall.Callback#onVideoQualityChanged(int)}.
Rekha Kumar07366812015-03-24 16:42:31 -07001844 *
Tyler Gunnb702ef82015-05-29 11:51:53 -07001845 * @param videoQuality The updated video quality. Valid values:
1846 * {@link VideoProfile#QUALITY_HIGH},
1847 * {@link VideoProfile#QUALITY_MEDIUM},
1848 * {@link VideoProfile#QUALITY_LOW},
1849 * {@link VideoProfile#QUALITY_DEFAULT}.
Rekha Kumar07366812015-03-24 16:42:31 -07001850 */
1851 public void changeVideoQuality(int videoQuality) {
Tyler Gunn75958422015-04-15 14:23:42 -07001852 if (mVideoCallbacks != null) {
Tyler Gunn84f381b2015-06-12 09:26:45 -07001853 for (IVideoCallback callback : mVideoCallbacks.values()) {
1854 try {
Tyler Gunn75958422015-04-15 14:23:42 -07001855 callback.changeVideoQuality(videoQuality);
Tyler Gunn84f381b2015-06-12 09:26:45 -07001856 } catch (RemoteException ignored) {
1857 Log.w(this, "changeVideoQuality callback failed", ignored);
Tyler Gunn75958422015-04-15 14:23:42 -07001858 }
Rekha Kumar07366812015-03-24 16:42:31 -07001859 }
1860 }
1861 }
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001862
1863 /**
1864 * Returns a string representation of a call session event.
1865 *
1866 * @param event A call session event passed to {@link #handleCallSessionEvent(int)}.
1867 * @return String representation of the call session event.
1868 * @hide
1869 */
1870 public static String sessionEventToString(int event) {
1871 switch (event) {
1872 case SESSION_EVENT_CAMERA_FAILURE:
1873 return SESSION_EVENT_CAMERA_FAILURE_STR;
1874 case SESSION_EVENT_CAMERA_READY:
1875 return SESSION_EVENT_CAMERA_READY_STR;
1876 case SESSION_EVENT_RX_PAUSE:
1877 return SESSION_EVENT_RX_PAUSE_STR;
1878 case SESSION_EVENT_RX_RESUME:
1879 return SESSION_EVENT_RX_RESUME_STR;
1880 case SESSION_EVENT_TX_START:
1881 return SESSION_EVENT_TX_START_STR;
1882 case SESSION_EVENT_TX_STOP:
1883 return SESSION_EVENT_TX_STOP_STR;
Tyler Gunnbf9c6fd2016-11-09 10:19:23 -08001884 case SESSION_EVENT_CAMERA_PERMISSION_ERROR:
1885 return SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR;
Tyler Gunn6f657ee2016-09-02 09:55:25 -07001886 default:
1887 return SESSION_EVENT_UNKNOWN_STR + " " + event;
1888 }
1889 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07001890 }
1891
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07001892 private final Listener mConnectionDeathListener = new Listener() {
1893 @Override
1894 public void onDestroyed(Connection c) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08001895 if (mConferenceables.remove(c)) {
1896 fireOnConferenceableConnectionsChanged();
1897 }
1898 }
1899 };
1900
1901 private final Conference.Listener mConferenceDeathListener = new Conference.Listener() {
1902 @Override
1903 public void onDestroyed(Conference c) {
1904 if (mConferenceables.remove(c)) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07001905 fireOnConferenceableConnectionsChanged();
1906 }
1907 }
1908 };
1909
Jay Shrauner229e3822014-08-15 09:23:07 -07001910 /**
1911 * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is
1912 * load factor before resizing, 1 means we only expect a single thread to
1913 * access the map so make only a single shard
1914 */
1915 private final Set<Listener> mListeners = Collections.newSetFromMap(
1916 new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1));
Tyler Gunndf2cbc82015-04-20 09:13:01 -07001917 private final List<Conferenceable> mConferenceables = new ArrayList<>();
1918 private final List<Conferenceable> mUnmodifiableConferenceables =
Tyler Gunn6d76ca02014-11-17 15:49:51 -08001919 Collections.unmodifiableList(mConferenceables);
Santos Cordonb6939982014-06-04 20:20:58 -07001920
Tyler Gunnf0500bd2015-09-01 10:59:48 -07001921 // The internal telecom call ID associated with this connection.
1922 private String mTelecomCallId;
Pengquan Meng70c9885332017-10-02 18:09:03 -07001923 // The PhoneAccountHandle associated with this connection.
1924 private PhoneAccountHandle mPhoneAccountHandle;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001925 private int mState = STATE_NEW;
Yorke Lee4af59352015-05-13 14:14:54 -07001926 private CallAudioState mCallAudioState;
Andrew Lee100e2932014-09-08 15:34:24 -07001927 private Uri mAddress;
1928 private int mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -07001929 private String mCallerDisplayName;
1930 private int mCallerDisplayNamePresentation;
Andrew Lee100e2932014-09-08 15:34:24 -07001931 private boolean mRingbackRequested = false;
Ihab Awad5c9c86e2014-11-12 13:41:16 -08001932 private int mConnectionCapabilities;
Tyler Gunn720c6642016-03-22 09:02:47 -07001933 private int mConnectionProperties;
Christine Hallstrom2830ce92016-11-30 16:06:42 -08001934 private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07001935 private VideoProvider mVideoProvider;
Sailesh Nepal33aaae42014-07-07 22:49:44 -07001936 private boolean mAudioModeIsVoip;
Roshan Piuse927ec02015-07-15 15:47:21 -07001937 private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Tyler Gunn3fa819c2017-08-04 09:27:26 -07001938 private long mConnectElapsedTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07001939 private StatusHints mStatusHints;
Tyler Gunnaa07df82014-07-17 07:50:22 -07001940 private int mVideoState;
Andrew Lee7f3d41f2014-09-11 17:33:16 -07001941 private DisconnectCause mDisconnectCause;
Santos Cordon823fd3c2014-08-07 18:35:18 -07001942 private Conference mConference;
1943 private ConnectionService mConnectionService;
Santos Cordon6b7f9552015-05-27 17:21:45 -07001944 private Bundle mExtras;
Brad Ebinger4fa6a012016-06-14 17:04:01 -07001945 private final Object mExtrasLock = new Object();
Tyler Gunn6986a632019-06-25 13:45:32 -07001946 /**
1947 * The direction of the connection; used where an existing connection is created and we need to
1948 * communicate to Telecom whether its incoming or outgoing.
1949 */
1950 private @Call.Details.CallDirection int mCallDirection = Call.Details.DIRECTION_UNKNOWN;
Ihab Awad542e0ea2014-05-16 10:22:16 -07001951
1952 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07001953 * Tracks the key set for the extras bundle provided on the last invocation of
1954 * {@link #setExtras(Bundle)}. Used so that on subsequent invocations we can remove any extras
1955 * keys which were set previously but are no longer present in the replacement Bundle.
1956 */
1957 private Set<String> mPreviousExtraKeys;
1958
1959 /**
Tyler Gunnd57d76c2019-09-24 14:53:23 -07001960 * The verification status for an incoming call's phone number.
1961 */
1962 private @VerificationStatus int mCallerNumberVerificationStatus;
1963
1964
1965 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07001966 * Create a new Connection.
1967 */
Santos Cordonf2951102014-07-20 19:06:29 -07001968 public Connection() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07001969
1970 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07001971 * Returns the Telecom internal call ID associated with this connection. Should only be used
1972 * for debugging and tracing purposes.
Tyler Gunnc63f9082019-10-15 13:19:26 -07001973 * <p>
1974 * Note: Access to the Telecom internal call ID is used for logging purposes only; this API is
1975 * provided to facilitate debugging of the Telephony stack only.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07001976 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07001977 * @return The Telecom call ID, or {@code null} if it was not set.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07001978 * @hide
1979 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07001980 @SystemApi
Tyler Gunn5567d742019-10-31 13:04:37 -07001981 @TestApi
Tyler Gunnc63f9082019-10-15 13:19:26 -07001982 public final @Nullable String getTelecomCallId() {
Tyler Gunnf0500bd2015-09-01 10:59:48 -07001983 return mTelecomCallId;
1984 }
1985
1986 /**
Andrew Lee100e2932014-09-08 15:34:24 -07001987 * @return The address (e.g., phone number) to which this Connection is currently communicating.
Ihab Awad542e0ea2014-05-16 10:22:16 -07001988 */
Andrew Lee100e2932014-09-08 15:34:24 -07001989 public final Uri getAddress() {
1990 return mAddress;
Ihab Awad542e0ea2014-05-16 10:22:16 -07001991 }
1992
1993 /**
Andrew Lee100e2932014-09-08 15:34:24 -07001994 * @return The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07001995 * See {@link TelecomManager} for valid values.
Sailesh Nepal61203862014-07-11 14:50:13 -07001996 */
Andrew Lee100e2932014-09-08 15:34:24 -07001997 public final int getAddressPresentation() {
1998 return mAddressPresentation;
Sailesh Nepal61203862014-07-11 14:50:13 -07001999 }
2000
2001 /**
2002 * @return The caller display name (CNAP).
2003 */
2004 public final String getCallerDisplayName() {
2005 return mCallerDisplayName;
2006 }
2007
2008 /**
Nancy Chen9d568c02014-09-08 14:17:59 -07002009 * @return The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002010 * See {@link TelecomManager} for valid values.
Sailesh Nepal61203862014-07-11 14:50:13 -07002011 */
2012 public final int getCallerDisplayNamePresentation() {
2013 return mCallerDisplayNamePresentation;
2014 }
2015
2016 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002017 * @return The state of this Connection.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002018 */
2019 public final int getState() {
2020 return mState;
2021 }
2022
2023 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002024 * Returns the video state of the connection.
Yorke Lee32f24732015-05-12 16:18:03 -07002025 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
2026 * {@link VideoProfile#STATE_BIDIRECTIONAL},
2027 * {@link VideoProfile#STATE_TX_ENABLED},
2028 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002029 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002030 * @return The video state of the connection.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002031 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002032 public final @VideoProfile.VideoState int getVideoState() {
Tyler Gunnaa07df82014-07-17 07:50:22 -07002033 return mVideoState;
2034 }
2035
2036 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002037 * @return The audio state of the connection, describing how its audio is currently
Ihab Awad542e0ea2014-05-16 10:22:16 -07002038 * being routed by the system. This is {@code null} if this Connection
2039 * does not directly know about its audio state.
Yorke Lee4af59352015-05-13 14:14:54 -07002040 * @deprecated Use {@link #getCallAudioState()} instead.
2041 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -07002042 */
Yorke Lee4af59352015-05-13 14:14:54 -07002043 @SystemApi
2044 @Deprecated
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002045 public final AudioState getAudioState() {
Sailesh Nepal000d38a2015-06-21 10:25:13 -07002046 if (mCallAudioState == null) {
2047 return null;
2048 }
Yorke Lee4af59352015-05-13 14:14:54 -07002049 return new AudioState(mCallAudioState);
2050 }
2051
2052 /**
2053 * @return The audio state of the connection, describing how its audio is currently
2054 * being routed by the system. This is {@code null} if this Connection
2055 * does not directly know about its audio state.
2056 */
2057 public final CallAudioState getCallAudioState() {
2058 return mCallAudioState;
Ihab Awad542e0ea2014-05-16 10:22:16 -07002059 }
2060
2061 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002062 * @return The conference that this connection is a part of. Null if it is not part of any
2063 * conference.
2064 */
2065 public final Conference getConference() {
2066 return mConference;
2067 }
2068
2069 /**
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002070 * Returns whether this connection is requesting that the system play a ringback tone
2071 * on its behalf.
2072 */
Andrew Lee100e2932014-09-08 15:34:24 -07002073 public final boolean isRingbackRequested() {
2074 return mRingbackRequested;
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002075 }
2076
2077 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002078 * @return True if the connection's audio mode is VOIP.
2079 */
2080 public final boolean getAudioModeIsVoip() {
2081 return mAudioModeIsVoip;
2082 }
2083
2084 /**
Roshan Piuse927ec02015-07-15 15:47:21 -07002085 * Retrieves the connection start time of the {@code Connnection}, if specified. A value of
2086 * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
2087 * start time of the conference.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002088 * <p>
2089 * Note: This is an implementation detail specific to IMS conference calls over a mobile
2090 * network.
Roshan Piuse927ec02015-07-15 15:47:21 -07002091 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07002092 * @return The time at which the {@code Connnection} was connected. Will be a value as retrieved
2093 * from {@link System#currentTimeMillis()}.
Roshan Piuse927ec02015-07-15 15:47:21 -07002094 *
2095 * @hide
2096 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002097 @SystemApi
Tyler Gunn5567d742019-10-31 13:04:37 -07002098 @TestApi
Roshan Piuse927ec02015-07-15 15:47:21 -07002099 public final long getConnectTimeMillis() {
2100 return mConnectTimeMillis;
2101 }
2102
2103 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002104 * Retrieves the connection start time of the {@link Connection}, if specified. A value of
2105 * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the
2106 * start time of the conference.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002107 * <p>
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002108 * Based on the value of {@link SystemClock#elapsedRealtime()}, which ensures that wall-clock
2109 * changes do not impact the call duration.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002110 * <p>
2111 * Used internally in Telephony when migrating conference participant data for IMS conferences.
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002112 *
2113 * @return The time at which the {@link Connection} was connected.
2114 *
2115 * @hide
2116 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002117 @SystemApi
Tyler Gunn5567d742019-10-31 13:04:37 -07002118 @TestApi
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002119 public final long getConnectElapsedTimeMillis() {
2120 return mConnectElapsedTimeMillis;
2121 }
2122
2123 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002124 * @return The status hints for this connection.
2125 */
2126 public final StatusHints getStatusHints() {
2127 return mStatusHints;
2128 }
2129
2130 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002131 * Returns the extras associated with this connection.
Tyler Gunn2cbe2b52016-05-04 15:48:10 +00002132 * <p>
2133 * Extras should be updated using {@link #putExtras(Bundle)}.
2134 * <p>
2135 * Telecom or an {@link InCallService} can also update the extras via
2136 * {@link android.telecom.Call#putExtras(Bundle)}, and
2137 * {@link Call#removeExtras(List)}.
2138 * <p>
2139 * The connection is notified of changes to the extras made by Telecom or an
2140 * {@link InCallService} by {@link #onExtrasChanged(Bundle)}.
Tyler Gunndee56a82016-03-23 16:06:34 -07002141 *
Santos Cordon6b7f9552015-05-27 17:21:45 -07002142 * @return The extras associated with this connection.
2143 */
2144 public final Bundle getExtras() {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002145 Bundle extras = null;
2146 synchronized (mExtrasLock) {
2147 if (mExtras != null) {
2148 extras = new Bundle(mExtras);
2149 }
2150 }
2151 return extras;
Santos Cordon6b7f9552015-05-27 17:21:45 -07002152 }
2153
2154 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002155 * Assign a listener to be notified of state changes.
2156 *
2157 * @param l A listener.
2158 * @return This Connection.
2159 *
2160 * @hide
2161 */
Tyler Gunn633e4c32019-10-24 15:40:48 -07002162 final Connection addConnectionListener(Listener l) {
Santos Cordond34e5712014-08-05 18:54:03 +00002163 mListeners.add(l);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002164 return this;
2165 }
2166
2167 /**
2168 * Remove a previously assigned listener that was being notified of state changes.
2169 *
2170 * @param l A Listener.
2171 * @return This Connection.
2172 *
2173 * @hide
2174 */
Tyler Gunn633e4c32019-10-24 15:40:48 -07002175 final Connection removeConnectionListener(Listener l) {
Jay Shrauner229e3822014-08-15 09:23:07 -07002176 if (l != null) {
2177 mListeners.remove(l);
2178 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002179 return this;
2180 }
2181
2182 /**
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002183 * @return The {@link DisconnectCause} for this connection.
Evan Charltonbf11f982014-07-20 22:06:28 -07002184 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002185 public final DisconnectCause getDisconnectCause() {
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07002186 return mDisconnectCause;
Evan Charltonbf11f982014-07-20 22:06:28 -07002187 }
2188
2189 /**
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002190 * Sets the telecom call ID associated with this Connection. The Telecom Call ID should be used
2191 * ONLY for debugging purposes.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002192 * <p>
2193 * Note: Access to the Telecom internal call ID is used for logging purposes only; this API is
2194 * provided to facilitate debugging of the Telephony stack only. Changing the ID via this
2195 * method does NOT change any functionality in Telephony or Telecom and impacts only logging.
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002196 *
2197 * @param callId The telecom call ID.
2198 * @hide
2199 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002200 @SystemApi
Tyler Gunn5567d742019-10-31 13:04:37 -07002201 @TestApi
Tyler Gunnc63f9082019-10-15 13:19:26 -07002202 public void setTelecomCallId(@NonNull String callId) {
Tyler Gunnf0500bd2015-09-01 10:59:48 -07002203 mTelecomCallId = callId;
2204 }
2205
2206 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002207 * Inform this Connection that the state of its audio output has been changed externally.
2208 *
2209 * @param state The new audio state.
Sailesh Nepal400cc482014-06-26 12:04:00 -07002210 * @hide
Ihab Awad542e0ea2014-05-16 10:22:16 -07002211 */
Yorke Lee4af59352015-05-13 14:14:54 -07002212 final void setCallAudioState(CallAudioState state) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002213 checkImmutable();
Ihab Awad60ac30b2014-05-20 22:32:12 -07002214 Log.d(this, "setAudioState %s", state);
Yorke Lee4af59352015-05-13 14:14:54 -07002215 mCallAudioState = state;
2216 onAudioStateChanged(getAudioState());
2217 onCallAudioStateChanged(state);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002218 }
2219
2220 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002221 * @param state An integer value of a {@code STATE_*} constant.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002222 * @return A string representation of the value.
2223 */
2224 public static String stateToString(int state) {
2225 switch (state) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002226 case STATE_INITIALIZING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002227 return "INITIALIZING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002228 case STATE_NEW:
Yorke Leee911c8d2015-07-14 11:39:36 -07002229 return "NEW";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002230 case STATE_RINGING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002231 return "RINGING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002232 case STATE_DIALING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002233 return "DIALING";
Tyler Gunnc96b5e02016-07-07 22:53:57 -07002234 case STATE_PULLING_CALL:
2235 return "PULLING_CALL";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002236 case STATE_ACTIVE:
Yorke Leee911c8d2015-07-14 11:39:36 -07002237 return "ACTIVE";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002238 case STATE_HOLDING:
Yorke Leee911c8d2015-07-14 11:39:36 -07002239 return "HOLDING";
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002240 case STATE_DISCONNECTED:
Ihab Awad542e0ea2014-05-16 10:22:16 -07002241 return "DISCONNECTED";
2242 default:
Ihab Awad60ac30b2014-05-20 22:32:12 -07002243 Log.wtf(Connection.class, "Unknown state %d", state);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002244 return "UNKNOWN";
2245 }
2246 }
2247
2248 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002249 * Returns the connection's capabilities, as a bit mask of the {@code CAPABILITY_*} constants.
Ihab Awad52a28f62014-06-18 10:26:34 -07002250 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002251 public final int getConnectionCapabilities() {
2252 return mConnectionCapabilities;
Ihab Awad52a28f62014-06-18 10:26:34 -07002253 }
2254
2255 /**
Tyler Gunn720c6642016-03-22 09:02:47 -07002256 * Returns the connection's properties, as a bit mask of the {@code PROPERTY_*} constants.
2257 */
2258 public final int getConnectionProperties() {
2259 return mConnectionProperties;
2260 }
2261
2262 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002263 * Returns the connection's supported audio routes.
2264 *
2265 * @hide
2266 */
2267 public final int getSupportedAudioRoutes() {
2268 return mSupportedAudioRoutes;
2269 }
2270
2271 /**
Andrew Lee100e2932014-09-08 15:34:24 -07002272 * Sets the value of the {@link #getAddress()} property.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002273 *
Andrew Lee100e2932014-09-08 15:34:24 -07002274 * @param address The new address.
2275 * @param presentation The presentation requirements for the address.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002276 * See {@link TelecomManager} for valid values.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002277 */
Andrew Lee100e2932014-09-08 15:34:24 -07002278 public final void setAddress(Uri address, int presentation) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002279 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002280 Log.d(this, "setAddress %s", address);
2281 mAddress = address;
2282 mAddressPresentation = presentation;
Santos Cordond34e5712014-08-05 18:54:03 +00002283 for (Listener l : mListeners) {
Andrew Lee100e2932014-09-08 15:34:24 -07002284 l.onAddressChanged(this, address, presentation);
Santos Cordond34e5712014-08-05 18:54:03 +00002285 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002286 }
2287
2288 /**
Sailesh Nepal61203862014-07-11 14:50:13 -07002289 * Sets the caller display name (CNAP).
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002290 *
Sailesh Nepal61203862014-07-11 14:50:13 -07002291 * @param callerDisplayName The new display name.
Nancy Chen9d568c02014-09-08 14:17:59 -07002292 * @param presentation The presentation requirements for the handle.
Tyler Gunnef9f6f92014-09-12 22:16:17 -07002293 * See {@link TelecomManager} for valid values.
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002294 */
Sailesh Nepal61203862014-07-11 14:50:13 -07002295 public final void setCallerDisplayName(String callerDisplayName, int presentation) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002296 checkImmutable();
Sailesh Nepal61203862014-07-11 14:50:13 -07002297 Log.d(this, "setCallerDisplayName %s", callerDisplayName);
Santos Cordond34e5712014-08-05 18:54:03 +00002298 mCallerDisplayName = callerDisplayName;
2299 mCallerDisplayNamePresentation = presentation;
2300 for (Listener l : mListeners) {
2301 l.onCallerDisplayNameChanged(this, callerDisplayName, presentation);
2302 }
Sailesh Nepal2a46b902014-07-04 17:21:07 -07002303 }
2304
2305 /**
Tyler Gunnaa07df82014-07-17 07:50:22 -07002306 * Set the video state for the connection.
Yorke Lee32f24732015-05-12 16:18:03 -07002307 * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY},
2308 * {@link VideoProfile#STATE_BIDIRECTIONAL},
2309 * {@link VideoProfile#STATE_TX_ENABLED},
2310 * {@link VideoProfile#STATE_RX_ENABLED}.
Tyler Gunnaa07df82014-07-17 07:50:22 -07002311 *
2312 * @param videoState The new video state.
2313 */
2314 public final void setVideoState(int videoState) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002315 checkImmutable();
Tyler Gunnaa07df82014-07-17 07:50:22 -07002316 Log.d(this, "setVideoState %d", videoState);
Santos Cordond34e5712014-08-05 18:54:03 +00002317 mVideoState = videoState;
2318 for (Listener l : mListeners) {
2319 l.onVideoStateChanged(this, mVideoState);
2320 }
Tyler Gunnaa07df82014-07-17 07:50:22 -07002321 }
2322
2323 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002324 * Sets state to active (e.g., an ongoing connection where two or more parties can actively
Ihab Awad542e0ea2014-05-16 10:22:16 -07002325 * communicate).
2326 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002327 public final void setActive() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002328 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002329 setRingbackRequested(false);
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002330 setState(STATE_ACTIVE);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002331 }
2332
2333 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002334 * Sets state to ringing (e.g., an inbound ringing connection).
Ihab Awad542e0ea2014-05-16 10:22:16 -07002335 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002336 public final void setRinging() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002337 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002338 setState(STATE_RINGING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002339 }
2340
2341 /**
Evan Charltonbf11f982014-07-20 22:06:28 -07002342 * Sets state to initializing (this Connection is not yet ready to be used).
2343 */
2344 public final void setInitializing() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002345 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002346 setState(STATE_INITIALIZING);
Evan Charltonbf11f982014-07-20 22:06:28 -07002347 }
2348
2349 /**
2350 * Sets state to initialized (the Connection has been set up and is now ready to be used).
2351 */
2352 public final void setInitialized() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002353 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002354 setState(STATE_NEW);
Evan Charltonbf11f982014-07-20 22:06:28 -07002355 }
2356
2357 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002358 * Sets state to dialing (e.g., dialing an outbound connection).
Ihab Awad542e0ea2014-05-16 10:22:16 -07002359 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002360 public final void setDialing() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002361 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002362 setState(STATE_DIALING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002363 }
2364
2365 /**
Tyler Gunnc242ceb2016-06-29 22:35:45 -07002366 * Sets state to pulling (e.g. the connection is being pulled to the local device from another
2367 * device). Only applicable for {@link Connection}s with
2368 * {@link Connection#PROPERTY_IS_EXTERNAL_CALL} and {@link Connection#CAPABILITY_CAN_PULL_CALL}.
2369 */
2370 public final void setPulling() {
2371 checkImmutable();
2372 setState(STATE_PULLING_CALL);
2373 }
2374
2375 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002376 * Sets state to be on hold.
2377 */
Sailesh Nepal400cc482014-06-26 12:04:00 -07002378 public final void setOnHold() {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002379 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002380 setState(STATE_HOLDING);
Ihab Awad542e0ea2014-05-16 10:22:16 -07002381 }
2382
2383 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002384 * Sets the video connection provider.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002385 * @param videoProvider The video provider.
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002386 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002387 public final void setVideoProvider(VideoProvider videoProvider) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002388 checkImmutable();
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002389 mVideoProvider = videoProvider;
Santos Cordond34e5712014-08-05 18:54:03 +00002390 for (Listener l : mListeners) {
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002391 l.onVideoProviderChanged(this, videoProvider);
Santos Cordond34e5712014-08-05 18:54:03 +00002392 }
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002393 }
2394
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002395 public final VideoProvider getVideoProvider() {
2396 return mVideoProvider;
Andrew Leea27a1932014-07-09 17:07:13 -07002397 }
2398
Andrew Lee5ffbe8b82014-06-20 16:29:33 -07002399 /**
Sailesh Nepal091768c2014-06-30 15:15:23 -07002400 * Sets state to disconnected.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002401 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002402 * @param disconnectCause The reason for the disconnection, as specified by
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002403 * {@link DisconnectCause}.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002404 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002405 public final void setDisconnected(DisconnectCause disconnectCause) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002406 checkImmutable();
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002407 mDisconnectCause = disconnectCause;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002408 setState(STATE_DISCONNECTED);
mike dooleyf34519b2014-09-16 17:33:40 -07002409 Log.d(this, "Disconnected with cause %s", disconnectCause);
Santos Cordond34e5712014-08-05 18:54:03 +00002410 for (Listener l : mListeners) {
Andrew Lee7f3d41f2014-09-11 17:33:16 -07002411 l.onDisconnected(this, disconnectCause);
Santos Cordond34e5712014-08-05 18:54:03 +00002412 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07002413 }
2414
2415 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002416 * Informs listeners that this {@code Connection} is in a post-dial wait state. This is done
2417 * when (a) the {@code Connection} is issuing a DTMF sequence; (b) it has encountered a "wait"
2418 * character; and (c) it wishes to inform the In-Call app that it is waiting for the end-user
2419 * to send an {@link #onPostDialContinue(boolean)} signal.
2420 *
2421 * @param remaining The DTMF character sequence remaining to be emitted once the
2422 * {@link #onPostDialContinue(boolean)} is received, including any "wait" characters
2423 * that remaining sequence may contain.
Sailesh Nepal091768c2014-06-30 15:15:23 -07002424 */
2425 public final void setPostDialWait(String remaining) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002426 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002427 for (Listener l : mListeners) {
2428 l.onPostDialWait(this, remaining);
2429 }
Sailesh Nepal091768c2014-06-30 15:15:23 -07002430 }
2431
2432 /**
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002433 * Informs listeners that this {@code Connection} has processed a character in the post-dial
2434 * started state. This is done when (a) the {@code Connection} is issuing a DTMF sequence;
Sailesh Nepal1ed85612015-01-31 15:17:19 -08002435 * and (b) it wishes to signal Telecom to play the corresponding DTMF tone locally.
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002436 *
2437 * @param nextChar The DTMF character that was just processed by the {@code Connection}.
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002438 */
Sailesh Nepal1ed85612015-01-31 15:17:19 -08002439 public final void setNextPostDialChar(char nextChar) {
Nancy Chen27d1c2d2014-12-15 16:12:50 -08002440 checkImmutable();
2441 for (Listener l : mListeners) {
2442 l.onPostDialChar(this, nextChar);
2443 }
2444 }
2445
2446 /**
Ihab Awadf8358972014-05-28 16:46:42 -07002447 * Requests that the framework play a ringback tone. This is to be invoked by implementations
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002448 * that do not play a ringback tone themselves in the connection's audio stream.
Ihab Awadf8358972014-05-28 16:46:42 -07002449 *
2450 * @param ringback Whether the ringback tone is to be played.
2451 */
Andrew Lee100e2932014-09-08 15:34:24 -07002452 public final void setRingbackRequested(boolean ringback) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002453 checkImmutable();
Andrew Lee100e2932014-09-08 15:34:24 -07002454 if (mRingbackRequested != ringback) {
2455 mRingbackRequested = ringback;
Santos Cordond34e5712014-08-05 18:54:03 +00002456 for (Listener l : mListeners) {
Andrew Lee100e2932014-09-08 15:34:24 -07002457 l.onRingbackRequested(this, ringback);
Santos Cordond34e5712014-08-05 18:54:03 +00002458 }
2459 }
Ihab Awadf8358972014-05-28 16:46:42 -07002460 }
2461
2462 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002463 * Sets the connection's capabilities as a bit mask of the {@code CAPABILITY_*} constants.
Sailesh Nepal1a7061b2014-07-09 21:03:20 -07002464 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002465 * @param connectionCapabilities The new connection capabilities.
Santos Cordonb6939982014-06-04 20:20:58 -07002466 */
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002467 public final void setConnectionCapabilities(int connectionCapabilities) {
2468 checkImmutable();
2469 if (mConnectionCapabilities != connectionCapabilities) {
2470 mConnectionCapabilities = connectionCapabilities;
Santos Cordond34e5712014-08-05 18:54:03 +00002471 for (Listener l : mListeners) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002472 l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities);
Santos Cordond34e5712014-08-05 18:54:03 +00002473 }
2474 }
Santos Cordonb6939982014-06-04 20:20:58 -07002475 }
2476
2477 /**
Tyler Gunn720c6642016-03-22 09:02:47 -07002478 * Sets the connection's properties as a bit mask of the {@code PROPERTY_*} constants.
2479 *
2480 * @param connectionProperties The new connection properties.
2481 */
2482 public final void setConnectionProperties(int connectionProperties) {
2483 checkImmutable();
2484 if (mConnectionProperties != connectionProperties) {
2485 mConnectionProperties = connectionProperties;
2486 for (Listener l : mListeners) {
2487 l.onConnectionPropertiesChanged(this, mConnectionProperties);
2488 }
2489 }
2490 }
2491
2492 /**
Christine Hallstrom2830ce92016-11-30 16:06:42 -08002493 * Sets the supported audio routes.
2494 *
2495 * @param supportedAudioRoutes the supported audio routes as a bitmask.
2496 * See {@link CallAudioState}
2497 * @hide
2498 */
2499 public final void setSupportedAudioRoutes(int supportedAudioRoutes) {
2500 if ((supportedAudioRoutes
2501 & (CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_SPEAKER)) == 0) {
2502 throw new IllegalArgumentException(
2503 "supported audio routes must include either speaker or earpiece");
2504 }
2505
2506 if (mSupportedAudioRoutes != supportedAudioRoutes) {
2507 mSupportedAudioRoutes = supportedAudioRoutes;
2508 for (Listener l : mListeners) {
2509 l.onSupportedAudioRoutesChanged(this, mSupportedAudioRoutes);
2510 }
2511 }
2512 }
2513
2514 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002515 * Tears down the Connection object.
Santos Cordonb6939982014-06-04 20:20:58 -07002516 */
Evan Charlton36a71342014-07-19 16:31:02 -07002517 public final void destroy() {
Jay Shrauner229e3822014-08-15 09:23:07 -07002518 for (Listener l : mListeners) {
2519 l.onDestroyed(this);
Santos Cordond34e5712014-08-05 18:54:03 +00002520 }
Santos Cordonb6939982014-06-04 20:20:58 -07002521 }
2522
2523 /**
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002524 * Requests that the framework use VOIP audio mode for this connection.
2525 *
2526 * @param isVoip True if the audio mode is VOIP.
2527 */
2528 public final void setAudioModeIsVoip(boolean isVoip) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002529 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002530 mAudioModeIsVoip = isVoip;
2531 for (Listener l : mListeners) {
2532 l.onAudioModeIsVoipChanged(this, isVoip);
2533 }
Sailesh Nepal33aaae42014-07-07 22:49:44 -07002534 }
2535
2536 /**
Roshan Piuse927ec02015-07-15 15:47:21 -07002537 * Sets the time at which a call became active on this Connection. This is set only
2538 * when a conference call becomes active on this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002539 * <p>
2540 * Used by telephony to maintain calls associated with an IMS Conference.
Roshan Piuse927ec02015-07-15 15:47:21 -07002541 *
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002542 * @param connectTimeMillis The connection time, in milliseconds. Should be set using a value
2543 * obtained from {@link System#currentTimeMillis()}.
Roshan Piuse927ec02015-07-15 15:47:21 -07002544 *
2545 * @hide
2546 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002547 @SystemApi
Tyler Gunn5567d742019-10-31 13:04:37 -07002548 @TestApi
Roshan Piuse927ec02015-07-15 15:47:21 -07002549 public final void setConnectTimeMillis(long connectTimeMillis) {
2550 mConnectTimeMillis = connectTimeMillis;
2551 }
2552
2553 /**
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002554 * Sets the time at which a call became active on this Connection. This is set only
2555 * when a conference call becomes active on this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07002556 * <p>
2557 * Used by telephony to maintain calls associated with an IMS Conference.
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002558 * @param connectElapsedTimeMillis The connection time, in milliseconds. Stored in the format
2559 * {@link SystemClock#elapsedRealtime()}.
2560 *
2561 * @hide
2562 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002563 @SystemApi
Tyler Gunn5567d742019-10-31 13:04:37 -07002564 @TestApi
Tyler Gunn17541392018-02-01 08:58:38 -08002565 public final void setConnectionStartElapsedRealTime(long connectElapsedTimeMillis) {
Tyler Gunn3fa819c2017-08-04 09:27:26 -07002566 mConnectElapsedTimeMillis = connectElapsedTimeMillis;
2567 }
2568
2569 /**
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002570 * Sets the label and icon status to display in the in-call UI.
2571 *
2572 * @param statusHints The status label and icon to set.
2573 */
2574 public final void setStatusHints(StatusHints statusHints) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002575 checkImmutable();
Santos Cordond34e5712014-08-05 18:54:03 +00002576 mStatusHints = statusHints;
2577 for (Listener l : mListeners) {
2578 l.onStatusHintsChanged(this, statusHints);
2579 }
Sailesh Nepale7ef59a2014-07-08 21:48:22 -07002580 }
2581
2582 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002583 * Sets the connections with which this connection can be conferenced.
2584 *
2585 * @param conferenceableConnections The set of connections this connection can conference with.
2586 */
2587 public final void setConferenceableConnections(List<Connection> conferenceableConnections) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002588 checkImmutable();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002589 clearConferenceableList();
2590 for (Connection c : conferenceableConnections) {
2591 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
2592 // small amount of items here.
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002593 if (!mConferenceables.contains(c)) {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002594 c.addConnectionListener(mConnectionDeathListener);
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002595 mConferenceables.add(c);
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002596 }
2597 }
2598 fireOnConferenceableConnectionsChanged();
2599 }
2600
2601 /**
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002602 * Similar to {@link #setConferenceableConnections(java.util.List)}, sets a list of connections
2603 * or conferences with which this connection can be conferenced.
2604 *
2605 * @param conferenceables The conferenceables.
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002606 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002607 public final void setConferenceables(List<Conferenceable> conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002608 clearConferenceableList();
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002609 for (Conferenceable c : conferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002610 // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a
2611 // small amount of items here.
2612 if (!mConferenceables.contains(c)) {
2613 if (c instanceof Connection) {
2614 Connection connection = (Connection) c;
2615 connection.addConnectionListener(mConnectionDeathListener);
2616 } else if (c instanceof Conference) {
2617 Conference conference = (Conference) c;
2618 conference.addListener(mConferenceDeathListener);
2619 }
2620 mConferenceables.add(c);
2621 }
2622 }
2623 fireOnConferenceableConnectionsChanged();
2624 }
2625
2626 /**
Tyler Gunnc63f9082019-10-15 13:19:26 -07002627 * Resets the CDMA connection time.
2628 * <p>
2629 * This is an implementation detail specific to legacy CDMA calls on mobile networks.
Mengjun Leng25707742017-07-04 11:10:37 +08002630 * @hide
Mengjun Leng25707742017-07-04 11:10:37 +08002631 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07002632 @SystemApi
Tyler Gunn5567d742019-10-31 13:04:37 -07002633 @TestApi
Mengjun Leng25707742017-07-04 11:10:37 +08002634 public final void resetConnectionTime() {
2635 for (Listener l : mListeners) {
2636 l.onConnectionTimeReset(this);
2637 }
2638 }
2639
2640 /**
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002641 * Returns the connections or conferences with which this connection can be conferenced.
2642 */
Tyler Gunndf2cbc82015-04-20 09:13:01 -07002643 public final List<Conferenceable> getConferenceables() {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08002644 return mUnmodifiableConferenceables;
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002645 }
2646
Yorke Lee53463962015-08-04 16:07:19 -07002647 /**
Santos Cordon823fd3c2014-08-07 18:35:18 -07002648 * @hide
2649 */
2650 public final void setConnectionService(ConnectionService connectionService) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002651 checkImmutable();
Santos Cordon823fd3c2014-08-07 18:35:18 -07002652 if (mConnectionService != null) {
2653 Log.e(this, new Exception(), "Trying to set ConnectionService on a connection " +
2654 "which is already associated with another ConnectionService.");
2655 } else {
2656 mConnectionService = connectionService;
2657 }
2658 }
2659
2660 /**
2661 * @hide
2662 */
2663 public final void unsetConnectionService(ConnectionService connectionService) {
2664 if (mConnectionService != connectionService) {
2665 Log.e(this, new Exception(), "Trying to remove ConnectionService from a Connection " +
2666 "that does not belong to the ConnectionService.");
2667 } else {
2668 mConnectionService = null;
2669 }
2670 }
2671
2672 /**
2673 * Sets the conference that this connection is a part of. This will fail if the connection is
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002674 * already part of a conference. {@link #resetConference} to un-set the conference first.
Santos Cordon823fd3c2014-08-07 18:35:18 -07002675 *
2676 * @param conference The conference.
2677 * @return {@code true} if the conference was successfully set.
2678 * @hide
2679 */
2680 public final boolean setConference(Conference conference) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002681 checkImmutable();
Santos Cordon823fd3c2014-08-07 18:35:18 -07002682 // We check to see if it is already part of another conference.
Santos Cordon0159ac02014-08-21 14:28:11 -07002683 if (mConference == null) {
Santos Cordon823fd3c2014-08-07 18:35:18 -07002684 mConference = conference;
Santos Cordon0159ac02014-08-21 14:28:11 -07002685 if (mConnectionService != null && mConnectionService.containsConference(conference)) {
2686 fireConferenceChanged();
2687 }
Santos Cordon823fd3c2014-08-07 18:35:18 -07002688 return true;
2689 }
2690 return false;
2691 }
2692
2693 /**
2694 * Resets the conference that this connection is a part of.
2695 * @hide
2696 */
2697 public final void resetConference() {
2698 if (mConference != null) {
Santos Cordon0159ac02014-08-21 14:28:11 -07002699 Log.d(this, "Conference reset");
Santos Cordon823fd3c2014-08-07 18:35:18 -07002700 mConference = null;
2701 fireConferenceChanged();
2702 }
2703 }
2704
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002705 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07002706 * Set some extras that can be associated with this {@code Connection}.
2707 * <p>
2708 * New or existing keys are replaced in the {@code Connection} extras. Keys which are no longer
2709 * in the new extras, but were present the last time {@code setExtras} was called are removed.
2710 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07002711 * Alternatively you may use the {@link #putExtras(Bundle)}, and
2712 * {@link #removeExtras(String...)} methods to modify the extras.
2713 * <p>
Tyler Gunndee56a82016-03-23 16:06:34 -07002714 * 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 -07002715 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
2716 *
2717 * @param extras The extras associated with this {@code Connection}.
2718 */
2719 public final void setExtras(@Nullable Bundle extras) {
2720 checkImmutable();
Tyler Gunndee56a82016-03-23 16:06:34 -07002721
2722 // Add/replace any new or changed extras values.
2723 putExtras(extras);
2724
2725 // If we have used "setExtras" in the past, compare the key set from the last invocation to
2726 // the current one and remove any keys that went away.
2727 if (mPreviousExtraKeys != null) {
2728 List<String> toRemove = new ArrayList<String>();
2729 for (String oldKey : mPreviousExtraKeys) {
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07002730 if (extras == null || !extras.containsKey(oldKey)) {
Tyler Gunndee56a82016-03-23 16:06:34 -07002731 toRemove.add(oldKey);
2732 }
2733 }
2734 if (!toRemove.isEmpty()) {
2735 removeExtras(toRemove);
2736 }
2737 }
2738
2739 // Track the keys the last time set called setExtras. This way, the next time setExtras is
2740 // called we can see if the caller has removed any extras values.
2741 if (mPreviousExtraKeys == null) {
2742 mPreviousExtraKeys = new ArraySet<String>();
2743 }
2744 mPreviousExtraKeys.clear();
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07002745 if (extras != null) {
2746 mPreviousExtraKeys.addAll(extras.keySet());
2747 }
Tyler Gunndee56a82016-03-23 16:06:34 -07002748 }
2749
2750 /**
2751 * Adds some extras to this {@code Connection}. Existing keys are replaced and new ones are
2752 * added.
2753 * <p>
2754 * No assumptions should be made as to how an In-Call UI or service will handle these extras.
2755 * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts.
2756 *
2757 * @param extras The extras to add.
2758 */
2759 public final void putExtras(@NonNull Bundle extras) {
2760 checkImmutable();
2761 if (extras == null) {
2762 return;
2763 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002764 // Creating a duplicate bundle so we don't have to synchronize on mExtrasLock while calling
2765 // the listeners.
2766 Bundle listenerExtras;
2767 synchronized (mExtrasLock) {
2768 if (mExtras == null) {
2769 mExtras = new Bundle();
2770 }
2771 mExtras.putAll(extras);
2772 listenerExtras = new Bundle(mExtras);
Tyler Gunndee56a82016-03-23 16:06:34 -07002773 }
Santos Cordon6b7f9552015-05-27 17:21:45 -07002774 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002775 // Create a new clone of the extras for each listener so that they don't clobber
2776 // each other
2777 l.onExtrasChanged(this, new Bundle(listenerExtras));
Santos Cordon6b7f9552015-05-27 17:21:45 -07002778 }
2779 }
2780
2781 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -07002782 * Removes extras from this {@code Connection}.
Tyler Gunndee56a82016-03-23 16:06:34 -07002783 *
Tyler Gunn071be6f2016-05-10 14:52:33 -07002784 * @param keys The keys of the extras to remove.
Tyler Gunndee56a82016-03-23 16:06:34 -07002785 */
2786 public final void removeExtras(List<String> keys) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002787 synchronized (mExtrasLock) {
2788 if (mExtras != null) {
2789 for (String key : keys) {
2790 mExtras.remove(key);
2791 }
Tyler Gunndee56a82016-03-23 16:06:34 -07002792 }
2793 }
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002794 List<String> unmodifiableKeys = Collections.unmodifiableList(keys);
Tyler Gunndee56a82016-03-23 16:06:34 -07002795 for (Listener l : mListeners) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07002796 l.onExtrasRemoved(this, unmodifiableKeys);
Tyler Gunndee56a82016-03-23 16:06:34 -07002797 }
2798 }
2799
2800 /**
Tyler Gunn071be6f2016-05-10 14:52:33 -07002801 * Removes extras from this {@code Connection}.
2802 *
2803 * @param keys The keys of the extras to remove.
2804 */
2805 public final void removeExtras(String ... keys) {
2806 removeExtras(Arrays.asList(keys));
2807 }
2808
2809 /**
Tyler Gunnf5035432017-01-09 09:43:12 -08002810 * Sets the audio route (speaker, bluetooth, etc...). When this request is honored, there will
2811 * be change to the {@link #getCallAudioState()}.
2812 * <p>
2813 * Used by self-managed {@link ConnectionService}s which wish to change the audio route for a
2814 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
2815 * <p>
2816 * See also {@link InCallService#setAudioRoute(int)}.
2817 *
2818 * @param route The audio route to use (one of {@link CallAudioState#ROUTE_BLUETOOTH},
2819 * {@link CallAudioState#ROUTE_EARPIECE}, {@link CallAudioState#ROUTE_SPEAKER}, or
2820 * {@link CallAudioState#ROUTE_WIRED_HEADSET}).
2821 */
2822 public final void setAudioRoute(int route) {
2823 for (Listener l : mListeners) {
Hall Liua98f58b52017-11-07 17:59:28 -08002824 l.onAudioRouteChanged(this, route, null);
2825 }
2826 }
2827
2828 /**
Hall Liua98f58b52017-11-07 17:59:28 -08002829 * Request audio routing to a specific bluetooth device. Calling this method may result in
2830 * the device routing audio to a different bluetooth device than the one specified if the
2831 * bluetooth stack is unable to route audio to the requested device.
2832 * A list of available devices can be obtained via
2833 * {@link CallAudioState#getSupportedBluetoothDevices()}
2834 *
2835 * <p>
2836 * Used by self-managed {@link ConnectionService}s which wish to use bluetooth audio for a
2837 * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
2838 * <p>
Hall Liu2b6a6a32018-04-02 13:52:57 -07002839 * See also {@link InCallService#requestBluetoothAudio(BluetoothDevice)}
2840 * @param bluetoothDevice The bluetooth device to connect to.
Hall Liua98f58b52017-11-07 17:59:28 -08002841 */
Hall Liu2b6a6a32018-04-02 13:52:57 -07002842 public void requestBluetoothAudio(@NonNull BluetoothDevice bluetoothDevice) {
Hall Liua98f58b52017-11-07 17:59:28 -08002843 for (Listener l : mListeners) {
Hall Liu2b6a6a32018-04-02 13:52:57 -07002844 l.onAudioRouteChanged(this, CallAudioState.ROUTE_BLUETOOTH,
2845 bluetoothDevice.getAddress());
Tyler Gunnf5035432017-01-09 09:43:12 -08002846 }
2847 }
2848
2849 /**
Hall Liub64ac4c2017-02-06 10:49:48 -08002850 * Informs listeners that a previously requested RTT session via
2851 * {@link ConnectionRequest#isRequestingRtt()} or
Hall Liu37dfdb02017-12-04 14:19:30 -08002852 * {@link #onStartRtt(RttTextStream)} has succeeded.
Hall Liub64ac4c2017-02-06 10:49:48 -08002853 */
2854 public final void sendRttInitiationSuccess() {
2855 mListeners.forEach((l) -> l.onRttInitiationSuccess(Connection.this));
2856 }
2857
2858 /**
2859 * Informs listeners that a previously requested RTT session via
Hall Liu37dfdb02017-12-04 14:19:30 -08002860 * {@link ConnectionRequest#isRequestingRtt()} or {@link #onStartRtt(RttTextStream)}
Hall Liub64ac4c2017-02-06 10:49:48 -08002861 * has failed.
2862 * @param reason One of the reason codes defined in {@link RttModifyStatus}, with the
2863 * exception of {@link RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}.
Hall Liub64ac4c2017-02-06 10:49:48 -08002864 */
2865 public final void sendRttInitiationFailure(int reason) {
2866 mListeners.forEach((l) -> l.onRttInitiationFailure(Connection.this, reason));
2867 }
2868
2869 /**
2870 * Informs listeners that a currently active RTT session has been terminated by the remote
2871 * side of the coll.
Hall Liub64ac4c2017-02-06 10:49:48 -08002872 */
2873 public final void sendRttSessionRemotelyTerminated() {
2874 mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this));
2875 }
2876
2877 /**
2878 * Informs listeners that the remote side of the call has requested an upgrade to include an
2879 * RTT session in the call.
Hall Liub64ac4c2017-02-06 10:49:48 -08002880 */
2881 public final void sendRemoteRttRequest() {
2882 mListeners.forEach((l) -> l.onRemoteRttRequest(Connection.this));
2883 }
2884
2885 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002886 * Notifies this Connection that the {@link #getAudioState()} property has a new value.
Sailesh Nepal400cc482014-06-26 12:04:00 -07002887 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002888 * @param state The new connection audio state.
Yorke Lee4af59352015-05-13 14:14:54 -07002889 * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead.
2890 * @hide
Sailesh Nepal400cc482014-06-26 12:04:00 -07002891 */
Yorke Lee4af59352015-05-13 14:14:54 -07002892 @SystemApi
2893 @Deprecated
Nancy Chen354b2bd2014-09-08 18:27:26 -07002894 public void onAudioStateChanged(AudioState state) {}
Sailesh Nepal400cc482014-06-26 12:04:00 -07002895
2896 /**
Yorke Lee4af59352015-05-13 14:14:54 -07002897 * Notifies this Connection that the {@link #getCallAudioState()} property has a new value.
2898 *
2899 * @param state The new connection audio state.
2900 */
2901 public void onCallAudioStateChanged(CallAudioState state) {}
2902
2903 /**
Evan Charltonbf11f982014-07-20 22:06:28 -07002904 * Notifies this Connection of an internal state change. This method is called after the
2905 * state is changed.
Ihab Awadf8358972014-05-28 16:46:42 -07002906 *
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002907 * @param state The new state, one of the {@code STATE_*} constants.
Ihab Awadf8358972014-05-28 16:46:42 -07002908 */
Nancy Chen354b2bd2014-09-08 18:27:26 -07002909 public void onStateChanged(int state) {}
Ihab Awadf8358972014-05-28 16:46:42 -07002910
2911 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002912 * Notifies this Connection of a request to play a DTMF tone.
2913 *
2914 * @param c A DTMF character.
2915 */
Santos Cordonf2951102014-07-20 19:06:29 -07002916 public void onPlayDtmfTone(char c) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002917
2918 /**
2919 * Notifies this Connection of a request to stop any currently playing DTMF tones.
2920 */
Santos Cordonf2951102014-07-20 19:06:29 -07002921 public void onStopDtmfTone() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002922
2923 /**
2924 * Notifies this Connection of a request to disconnect.
2925 */
Santos Cordonf2951102014-07-20 19:06:29 -07002926 public void onDisconnect() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002927
2928 /**
Tyler Gunn3b4b1dc2014-11-04 14:53:37 -08002929 * Notifies this Connection of a request to disconnect a participant of the conference managed
2930 * by the connection.
2931 *
2932 * @param endpoint the {@link Uri} of the participant to disconnect.
2933 * @hide
2934 */
2935 public void onDisconnectConferenceParticipant(Uri endpoint) {}
2936
2937 /**
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07002938 * Notifies this Connection of a request to separate from its parent conference.
Santos Cordonb6939982014-06-04 20:20:58 -07002939 */
Santos Cordonf2951102014-07-20 19:06:29 -07002940 public void onSeparate() {}
Santos Cordonb6939982014-06-04 20:20:58 -07002941
2942 /**
Ihab Awad542e0ea2014-05-16 10:22:16 -07002943 * Notifies this Connection of a request to abort.
2944 */
Santos Cordonf2951102014-07-20 19:06:29 -07002945 public void onAbort() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002946
2947 /**
2948 * Notifies this Connection of a request to hold.
2949 */
Santos Cordonf2951102014-07-20 19:06:29 -07002950 public void onHold() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002951
2952 /**
2953 * Notifies this Connection of a request to exit a hold state.
2954 */
Santos Cordonf2951102014-07-20 19:06:29 -07002955 public void onUnhold() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002956
2957 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002958 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Santos Cordond34e5712014-08-05 18:54:03 +00002959 * a request to accept.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08002960 * <p>
2961 * For managed {@link ConnectionService}s, this will be called when the user answers a call via
2962 * the default dialer's {@link InCallService}.
2963 * <p>
2964 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
2965 * Telecom framework may request that the call is answered in the following circumstances:
2966 * <ul>
2967 * <li>The user chooses to answer an incoming call via a Bluetooth device.</li>
2968 * <li>A car mode {@link InCallService} is in use which has declared
2969 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
2970 * {@link InCallService} will be able to see calls from self-managed
2971 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
2972 * behalf.</li>
2973 * </ul>
Ihab Awad5c9c86e2014-11-12 13:41:16 -08002974 * @param videoState The video state in which to answer the connection.
Ihab Awad542e0ea2014-05-16 10:22:16 -07002975 */
Santos Cordonf2951102014-07-20 19:06:29 -07002976 public void onAnswer(int videoState) {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07002977
2978 /**
Ihab Awadb19a0bc2014-08-07 19:46:01 -07002979 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Tyler Gunnbe74de02014-08-29 14:51:48 -07002980 * a request to accept.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08002981 * <p>
2982 * For managed {@link ConnectionService}s, this will be called when the user answers a call via
2983 * the default dialer's {@link InCallService}.
2984 * <p>
2985 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
2986 * Telecom framework may request that the call is answered in the following circumstances:
2987 * <ul>
2988 * <li>The user chooses to answer an incoming call via a Bluetooth device.</li>
2989 * <li>A car mode {@link InCallService} is in use which has declared
2990 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
2991 * {@link InCallService} will be able to see calls from self-managed
2992 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
2993 * behalf.</li>
2994 * </ul>
Tyler Gunnbe74de02014-08-29 14:51:48 -07002995 */
2996 public void onAnswer() {
Tyler Gunn87b73f32015-06-03 10:09:59 -07002997 onAnswer(VideoProfile.STATE_AUDIO_ONLY);
Tyler Gunnbe74de02014-08-29 14:51:48 -07002998 }
2999
3000 /**
3001 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Pooja Jaind34698d2017-12-28 14:15:31 +05303002 * a request to deflect.
3003 */
3004 public void onDeflect(Uri address) {}
3005
3006 /**
3007 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
Santos Cordond34e5712014-08-05 18:54:03 +00003008 * a request to reject.
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003009 * <p>
3010 * For managed {@link ConnectionService}s, this will be called when the user rejects a call via
3011 * the default dialer's {@link InCallService}.
3012 * <p>
3013 * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the
3014 * Telecom framework may request that the call is rejected in the following circumstances:
3015 * <ul>
3016 * <li>The user chooses to reject an incoming call via a Bluetooth device.</li>
3017 * <li>A car mode {@link InCallService} is in use which has declared
3018 * {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest. Such an
3019 * {@link InCallService} will be able to see calls from self-managed
3020 * {@link ConnectionService}s, and will be able to display an incoming call UI on their
3021 * behalf.</li>
3022 * </ul>
Ihab Awad542e0ea2014-05-16 10:22:16 -07003023 */
Santos Cordonf2951102014-07-20 19:06:29 -07003024 public void onReject() {}
Ihab Awad542e0ea2014-05-16 10:22:16 -07003025
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003026 /**
Hall Liu712acbe2016-03-14 16:38:56 -07003027 * Notifies this Connection, which is in {@link #STATE_RINGING}, of
3028 * a request to reject with a message.
Bryce Lee81901682015-08-28 16:38:02 -07003029 */
3030 public void onReject(String replyMessage) {}
3031
3032 /**
Tyler Gunn06f06162018-06-18 11:24:15 -07003033 * Notifies this Connection of a request to silence the ringer.
3034 * <p>
3035 * The ringer may be silenced by any of the following methods:
3036 * <ul>
3037 * <li>{@link TelecomManager#silenceRinger()}</li>
3038 * <li>The user presses the volume-down button while a call is ringing.</li>
3039 * </ul>
3040 * <p>
3041 * Self-managed {@link ConnectionService} implementations should override this method in their
3042 * {@link Connection} implementation and implement logic to silence their app's ringtone. If
3043 * your app set the ringtone as part of the incoming call {@link Notification} (see
3044 * {@link #onShowIncomingCallUi()}), it should re-post the notification now, except call
3045 * {@link android.app.Notification.Builder#setOnlyAlertOnce(boolean)} with {@code true}. This
3046 * will ensure the ringtone sound associated with your {@link android.app.NotificationChannel}
3047 * stops playing.
Bryce Leecac50772015-11-17 15:13:29 -08003048 */
3049 public void onSilence() {}
3050
3051 /**
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003052 * Notifies this Connection whether the user wishes to proceed with the post-dial DTMF codes.
3053 */
Santos Cordonf2951102014-07-20 19:06:29 -07003054 public void onPostDialContinue(boolean proceed) {}
Evan Charlton6dea4ac2014-06-03 14:07:13 -07003055
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003056 /**
3057 * Notifies this Connection of a request to pull an external call to the local device.
3058 * <p>
3059 * The {@link InCallService} issues a request to pull an external call to the local device via
3060 * {@link Call#pullExternalCall()}.
3061 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -07003062 * For a Connection to be pulled, both the {@link Connection#CAPABILITY_CAN_PULL_CALL}
3063 * capability and {@link Connection#PROPERTY_IS_EXTERNAL_CALL} property bits must be set.
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003064 * <p>
Tyler Gunn720c6642016-03-22 09:02:47 -07003065 * For more information on external calls, see {@link Connection#PROPERTY_IS_EXTERNAL_CALL}.
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003066 */
3067 public void onPullExternalCall() {}
3068
3069 /**
3070 * Notifies this Connection of a {@link Call} event initiated from an {@link InCallService}.
3071 * <p>
3072 * The {@link InCallService} issues a Call event via {@link Call#sendCallEvent(String, Bundle)}.
3073 * <p>
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003074 * Where possible, the Connection should make an attempt to handle {@link Call} events which
3075 * are part of the {@code android.telecom.*} namespace. The Connection should ignore any events
3076 * it does not wish to handle. Unexpected events should be handled gracefully, as it is
3077 * possible that a {@link InCallService} has defined its own Call events which a Connection is
3078 * not aware of.
3079 * <p>
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003080 * See also {@link Call#sendCallEvent(String, Bundle)}.
3081 *
3082 * @param event The call event.
3083 * @param extras Extras associated with the call event.
3084 */
3085 public void onCallEvent(String event, Bundle extras) {}
3086
Tyler Gunndee56a82016-03-23 16:06:34 -07003087 /**
Tyler Gunn79bc1ec2018-01-22 15:17:54 -08003088 * Notifies this {@link Connection} that a handover has completed.
3089 * <p>
3090 * A handover is initiated with {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int,
3091 * Bundle)} on the initiating side of the handover, and
3092 * {@link TelecomManager#acceptHandover(Uri, int, PhoneAccountHandle)}.
3093 */
3094 public void onHandoverComplete() {}
3095
3096 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07003097 * Notifies this {@link Connection} of a change to the extras made outside the
3098 * {@link ConnectionService}.
3099 * <p>
3100 * These extras changes can originate from Telecom itself, or from an {@link InCallService} via
3101 * the {@link android.telecom.Call#putExtras(Bundle)} and
3102 * {@link Call#removeExtras(List)}.
3103 *
3104 * @param extras The new extras bundle.
3105 */
3106 public void onExtrasChanged(Bundle extras) {}
3107
Tyler Gunnf5035432017-01-09 09:43:12 -08003108 /**
3109 * Notifies this {@link Connection} that its {@link ConnectionService} is responsible for
3110 * displaying its incoming call user interface for the {@link Connection}.
3111 * <p>
3112 * Will only be called for incoming calls added via a self-managed {@link ConnectionService}
3113 * (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}), where the {@link ConnectionService}
3114 * should show its own incoming call user interface.
3115 * <p>
3116 * Where there are ongoing calls in other self-managed {@link ConnectionService}s, or in a
Tyler Gunn7c3ddcf2018-02-08 11:28:33 -08003117 * regular {@link ConnectionService}, and it is not possible to hold these other calls, the
3118 * Telecom framework will display its own incoming call user interface to allow the user to
3119 * choose whether to answer the new incoming call and disconnect other ongoing calls, or to
3120 * reject the new incoming call.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003121 * <p>
3122 * You should trigger the display of the incoming call user interface for your application by
3123 * showing a {@link Notification} with a full-screen {@link Intent} specified.
Tyler Gunn06f06162018-06-18 11:24:15 -07003124 *
3125 * In your application code, you should create a {@link android.app.NotificationChannel} for
3126 * incoming call notifications from your app:
3127 * <pre><code>
3128 * NotificationChannel channel = new NotificationChannel(YOUR_CHANNEL_ID, "Incoming Calls",
3129 * NotificationManager.IMPORTANCE_MAX);
3130 * // other channel setup stuff goes here.
3131 *
3132 * // We'll use the default system ringtone for our incoming call notification channel. You can
3133 * // use your own audio resource here.
3134 * Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
3135 * channel.setSound(ringtoneUri, new AudioAttributes.Builder()
3136 * // Setting the AudioAttributes is important as it identifies the purpose of your
3137 * // notification sound.
3138 * .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE)
3139 * .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
3140 * .build());
3141 *
3142 * NotificationManager mgr = getSystemService(NotificationManager.class);
3143 * mgr.createNotificationChannel(channel);
3144 * </code></pre>
3145 * When it comes time to post a notification for your incoming call, ensure it uses your
3146 * incoming call {@link android.app.NotificationChannel}.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003147 * <pre><code>
3148 * // Create an intent which triggers your fullscreen incoming call user interface.
3149 * Intent intent = new Intent(Intent.ACTION_MAIN, null);
3150 * intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_ACTIVITY_NEW_TASK);
3151 * intent.setClass(context, YourIncomingCallActivity.class);
3152 * PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, 0);
3153 *
3154 * // Build the notification as an ongoing high priority item; this ensures it will show as
3155 * // a heads up notification which slides down over top of the current content.
3156 * final Notification.Builder builder = new Notification.Builder(context);
3157 * builder.setOngoing(true);
3158 * builder.setPriority(Notification.PRIORITY_HIGH);
3159 *
3160 * // Set notification content intent to take user to fullscreen UI if user taps on the
3161 * // notification body.
3162 * builder.setContentIntent(pendingIntent);
3163 * // Set full screen intent to trigger display of the fullscreen UI when the notification
3164 * // manager deems it appropriate.
3165 * builder.setFullScreenIntent(pendingIntent, true);
3166 *
3167 * // Setup notification content.
3168 * builder.setSmallIcon( yourIconResourceId );
3169 * builder.setContentTitle("Your notification title");
3170 * builder.setContentText("Your notification content.");
3171 *
Tyler Gunn06f06162018-06-18 11:24:15 -07003172 * // Set notification as insistent to cause your ringtone to loop.
3173 * Notification notification = builder.build();
3174 * notification.flags |= Notification.FLAG_INSISTENT;
Tyler Gunn159f35c2017-03-02 09:28:37 -08003175 *
Tyler Gunn06f06162018-06-18 11:24:15 -07003176 * // Use builder.addAction(..) to add buttons to answer or reject the call.
Tyler Gunn159f35c2017-03-02 09:28:37 -08003177 * NotificationManager notificationManager = mContext.getSystemService(
3178 * NotificationManager.class);
Tyler Gunn06f06162018-06-18 11:24:15 -07003179 * notificationManager.notify(YOUR_CHANNEL_ID, YOUR_TAG, YOUR_ID, notification);
Tyler Gunn159f35c2017-03-02 09:28:37 -08003180 * </code></pre>
Tyler Gunnf5035432017-01-09 09:43:12 -08003181 */
3182 public void onShowIncomingCallUi() {}
3183
Hall Liub64ac4c2017-02-06 10:49:48 -08003184 /**
3185 * Notifies this {@link Connection} that the user has requested an RTT session.
3186 * The connection service should call {@link #sendRttInitiationSuccess} or
3187 * {@link #sendRttInitiationFailure} to inform Telecom of the success or failure of the
3188 * request, respectively.
3189 * @param rttTextStream The object that should be used to send text to or receive text from
3190 * the in-call app.
Hall Liub64ac4c2017-02-06 10:49:48 -08003191 */
3192 public void onStartRtt(@NonNull RttTextStream rttTextStream) {}
3193
3194 /**
3195 * Notifies this {@link Connection} that it should terminate any existing RTT communication
3196 * channel. No response to Telecom is needed for this method.
Hall Liub64ac4c2017-02-06 10:49:48 -08003197 */
3198 public void onStopRtt() {}
3199
3200 /**
3201 * Notifies this connection of a response to a previous remotely-initiated RTT upgrade
3202 * request sent via {@link #sendRemoteRttRequest}. Acceptance of the request is
3203 * indicated by the supplied {@link RttTextStream} being non-null, and rejection is
3204 * indicated by {@code rttTextStream} being {@code null}
Hall Liub64ac4c2017-02-06 10:49:48 -08003205 * @param rttTextStream The object that should be used to send text to or receive text from
3206 * the in-call app.
3207 */
3208 public void handleRttUpgradeResponse(@Nullable RttTextStream rttTextStream) {}
3209
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003210 static String toLogSafePhoneNumber(String number) {
3211 // For unknown number, log empty string.
3212 if (number == null) {
3213 return "";
3214 }
3215
3216 if (PII_DEBUG) {
3217 // When PII_DEBUG is true we emit PII.
3218 return number;
3219 }
3220
3221 // Do exactly same thing as Uri#toSafeString() does, which will enable us to compare
3222 // sanitized phone numbers.
3223 StringBuilder builder = new StringBuilder();
3224 for (int i = 0; i < number.length(); i++) {
3225 char c = number.charAt(i);
3226 if (c == '-' || c == '@' || c == '.') {
3227 builder.append(c);
3228 } else {
3229 builder.append('x');
3230 }
3231 }
3232 return builder.toString();
3233 }
3234
Ihab Awad542e0ea2014-05-16 10:22:16 -07003235 private void setState(int state) {
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003236 checkImmutable();
Ihab Awad6107bab2014-08-18 09:23:25 -07003237 if (mState == STATE_DISCONNECTED && mState != state) {
3238 Log.d(this, "Connection already DISCONNECTED; cannot transition out of this state.");
Evan Charltonbf11f982014-07-20 22:06:28 -07003239 return;
Sailesh Nepal400cc482014-06-26 12:04:00 -07003240 }
Evan Charltonbf11f982014-07-20 22:06:28 -07003241 if (mState != state) {
3242 Log.d(this, "setState: %s", stateToString(state));
3243 mState = state;
Nancy Chen354b2bd2014-09-08 18:27:26 -07003244 onStateChanged(state);
Evan Charltonbf11f982014-07-20 22:06:28 -07003245 for (Listener l : mListeners) {
3246 l.onStateChanged(this, state);
3247 }
Evan Charltonbf11f982014-07-20 22:06:28 -07003248 }
3249 }
3250
Sailesh Nepalcf7020b2014-08-20 10:07:19 -07003251 private static class FailureSignalingConnection extends Connection {
Ihab Awad90e34e32014-12-01 16:23:17 -08003252 private boolean mImmutable = false;
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003253 public FailureSignalingConnection(DisconnectCause disconnectCause) {
3254 setDisconnected(disconnectCause);
Ihab Awad90e34e32014-12-01 16:23:17 -08003255 mImmutable = true;
Ihab Awad6107bab2014-08-18 09:23:25 -07003256 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003257
3258 public void checkImmutable() {
Ihab Awad90e34e32014-12-01 16:23:17 -08003259 if (mImmutable) {
3260 throw new UnsupportedOperationException("Connection is immutable");
3261 }
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003262 }
Ihab Awad6107bab2014-08-18 09:23:25 -07003263 }
3264
Evan Charltonbf11f982014-07-20 22:06:28 -07003265 /**
Ihab Awad6107bab2014-08-18 09:23:25 -07003266 * Return a {@code Connection} which represents a failed connection attempt. The returned
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003267 * {@code Connection} will have a {@link android.telecom.DisconnectCause} and as specified,
3268 * and a {@link #getState()} of {@link #STATE_DISCONNECTED}.
Ihab Awad6107bab2014-08-18 09:23:25 -07003269 * <p>
3270 * The returned {@code Connection} can be assumed to {@link #destroy()} itself when appropriate,
3271 * so users of this method need not maintain a reference to its return value to destroy it.
Evan Charltonbf11f982014-07-20 22:06:28 -07003272 *
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003273 * @param disconnectCause The disconnect cause, ({@see android.telecomm.DisconnectCause}).
Ihab Awad6107bab2014-08-18 09:23:25 -07003274 * @return A {@code Connection} which indicates failure.
Evan Charltonbf11f982014-07-20 22:06:28 -07003275 */
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003276 public static Connection createFailedConnection(DisconnectCause disconnectCause) {
3277 return new FailureSignalingConnection(disconnectCause);
Evan Charltonbf11f982014-07-20 22:06:28 -07003278 }
3279
Evan Charltonbf11f982014-07-20 22:06:28 -07003280 /**
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003281 * Override to throw an {@link UnsupportedOperationException} if this {@code Connection} is
3282 * not intended to be mutated, e.g., if it is a marker for failure. Only for framework use;
3283 * this should never be un-@hide-den.
3284 *
3285 * @hide
3286 */
3287 public void checkImmutable() {}
3288
3289 /**
Ihab Awad6107bab2014-08-18 09:23:25 -07003290 * Return a {@code Connection} which represents a canceled connection attempt. The returned
3291 * {@code Connection} will have state {@link #STATE_DISCONNECTED}, and cannot be moved out of
3292 * that state. This connection should not be used for anything, and no other
3293 * {@code Connection}s should be attempted.
3294 * <p>
Ihab Awad6107bab2014-08-18 09:23:25 -07003295 * so users of this method need not maintain a reference to its return value to destroy it.
Evan Charltonbf11f982014-07-20 22:06:28 -07003296 *
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003297 * @return A {@code Connection} which indicates that the underlying connection should
3298 * be canceled.
Evan Charltonbf11f982014-07-20 22:06:28 -07003299 */
Ihab Awadb19a0bc2014-08-07 19:46:01 -07003300 public static Connection createCanceledConnection() {
Andrew Lee7f3d41f2014-09-11 17:33:16 -07003301 return new FailureSignalingConnection(new DisconnectCause(DisconnectCause.CANCELED));
Ihab Awad542e0ea2014-05-16 10:22:16 -07003302 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003303
Ihab Awad5c9c86e2014-11-12 13:41:16 -08003304 private final void fireOnConferenceableConnectionsChanged() {
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003305 for (Listener l : mListeners) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003306 l.onConferenceablesChanged(this, getConferenceables());
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003307 }
3308 }
3309
Santos Cordon823fd3c2014-08-07 18:35:18 -07003310 private final void fireConferenceChanged() {
3311 for (Listener l : mListeners) {
3312 l.onConferenceChanged(this, mConference);
3313 }
3314 }
3315
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003316 private final void clearConferenceableList() {
Tyler Gunndf2cbc82015-04-20 09:13:01 -07003317 for (Conferenceable c : mConferenceables) {
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003318 if (c instanceof Connection) {
3319 Connection connection = (Connection) c;
3320 connection.removeConnectionListener(mConnectionDeathListener);
3321 } else if (c instanceof Conference) {
3322 Conference conference = (Conference) c;
3323 conference.removeListener(mConferenceDeathListener);
3324 }
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003325 }
Tyler Gunn6d76ca02014-11-17 15:49:51 -08003326 mConferenceables.clear();
Santos Cordon7c7bc7f2014-07-28 18:15:48 -07003327 }
Tyler Gunn3bffcf72014-10-28 13:51:27 -07003328
3329 /**
Tyler Gunndee56a82016-03-23 16:06:34 -07003330 * Handles a change to extras received from Telecom.
3331 *
3332 * @param extras The new extras.
3333 * @hide
3334 */
3335 final void handleExtrasChanged(Bundle extras) {
Brad Ebinger4fa6a012016-06-14 17:04:01 -07003336 Bundle b = null;
3337 synchronized (mExtrasLock) {
3338 mExtras = extras;
3339 if (mExtras != null) {
3340 b = new Bundle(mExtras);
3341 }
3342 }
3343 onExtrasChanged(b);
Tyler Gunndee56a82016-03-23 16:06:34 -07003344 }
3345
3346 /**
Tyler Gunnc63f9082019-10-15 13:19:26 -07003347 * Called by a {@link ConnectionService} to notify Telecom that a {@link Conference#onMerge()}
3348 * request failed.
Anthony Lee17455a32015-04-24 15:25:29 -07003349 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003350 public final void notifyConferenceMergeFailed() {
Anthony Lee17455a32015-04-24 15:25:29 -07003351 for (Listener l : mListeners) {
3352 l.onConferenceMergeFailed(this);
3353 }
3354 }
3355
3356 /**
Srikanth Chintalafcb15012017-05-04 20:58:34 +05303357 * Notifies listeners when phone account is changed. For example, when the PhoneAccount is
3358 * changed due to an emergency call being redialed.
3359 * @param pHandle The new PhoneAccountHandle for this connection.
3360 * @hide
3361 */
3362 public void notifyPhoneAccountChanged(PhoneAccountHandle pHandle) {
3363 for (Listener l : mListeners) {
3364 l.onPhoneAccountChanged(this, pHandle);
3365 }
3366 }
3367
3368 /**
Pengquan Meng70c9885332017-10-02 18:09:03 -07003369 * Sets the {@link PhoneAccountHandle} associated with this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003370 * <p>
3371 * Used by the Telephony {@link ConnectionService} to handle changes to the {@link PhoneAccount}
3372 * which take place after call initiation (important for emergency calling scenarios).
Pengquan Meng70c9885332017-10-02 18:09:03 -07003373 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07003374 * @param phoneAccountHandle the phone account handle to set.
Pengquan Meng70c9885332017-10-02 18:09:03 -07003375 * @hide
3376 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003377 @SystemApi
Tyler Gunn5567d742019-10-31 13:04:37 -07003378 @TestApi
Tyler Gunnc63f9082019-10-15 13:19:26 -07003379 public void setPhoneAccountHandle(@NonNull PhoneAccountHandle phoneAccountHandle) {
Pengquan Meng70c9885332017-10-02 18:09:03 -07003380 if (mPhoneAccountHandle != phoneAccountHandle) {
3381 mPhoneAccountHandle = phoneAccountHandle;
3382 notifyPhoneAccountChanged(phoneAccountHandle);
3383 }
3384 }
3385
3386 /**
3387 * Returns the {@link PhoneAccountHandle} associated with this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003388 * <p>
3389 * Used by the Telephony {@link ConnectionService} to handle changes to the {@link PhoneAccount}
3390 * which take place after call initiation (important for emergency calling scenarios).
Pengquan Meng70c9885332017-10-02 18:09:03 -07003391 *
Tyler Gunnc63f9082019-10-15 13:19:26 -07003392 * @return the phone account handle specified via
3393 * {@link #setPhoneAccountHandle(PhoneAccountHandle)}, or {@code null} if none was set.
Pengquan Meng70c9885332017-10-02 18:09:03 -07003394 * @hide
3395 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003396 @SystemApi
Tyler Gunn5567d742019-10-31 13:04:37 -07003397 @TestApi
Tyler Gunnc63f9082019-10-15 13:19:26 -07003398 public @Nullable PhoneAccountHandle getPhoneAccountHandle() {
Pengquan Meng70c9885332017-10-02 18:09:03 -07003399 return mPhoneAccountHandle;
3400 }
3401
3402 /**
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003403 * Sends an event associated with this {@code Connection} with associated event extras to the
3404 * {@link InCallService}.
3405 * <p>
3406 * Connection events are used to communicate point in time information from a
3407 * {@link ConnectionService} to a {@link InCallService} implementations. An example of a
3408 * custom connection event includes notifying the UI when a WIFI call has been handed over to
3409 * LTE, which the InCall UI might use to inform the user that billing charges may apply. The
3410 * Android Telephony framework will send the {@link #EVENT_CALL_MERGE_FAILED} connection event
3411 * when a call to {@link Call#mergeConference()} has failed to complete successfully. A
3412 * connection event could also be used to trigger UI in the {@link InCallService} which prompts
3413 * the user to make a choice (e.g. whether they want to incur roaming costs for making a call),
3414 * which is communicated back via {@link Call#sendCallEvent(String, Bundle)}.
3415 * <p>
3416 * Events are exposed to {@link InCallService} implementations via
3417 * {@link Call.Callback#onConnectionEvent(Call, String, Bundle)}.
3418 * <p>
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003419 * 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 -07003420 * The {@link ConnectionService} must assume that the In-Call UI could even chose to ignore
3421 * some events altogether.
3422 * <p>
3423 * Events should be fully qualified (e.g. {@code com.example.event.MY_EVENT}) to avoid
3424 * conflicts between {@link ConnectionService} implementations. Further, custom
3425 * {@link ConnectionService} implementations shall not re-purpose events in the
3426 * {@code android.*} namespace, nor shall they define new event types in this namespace. When
3427 * defining a custom event type, ensure the contents of the extras {@link Bundle} is clearly
3428 * defined. Extra keys for this bundle should be named similar to the event type (e.g.
3429 * {@code com.example.extra.MY_EXTRA}).
3430 * <p>
3431 * When defining events and the associated extras, it is important to keep their behavior
3432 * consistent when the associated {@link ConnectionService} is updated. Support for deprecated
3433 * events/extras should me maintained to ensure backwards compatibility with older
3434 * {@link InCallService} implementations which were built to support the older behavior.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003435 *
3436 * @param event The connection event.
Tyler Gunn9c0eb0b2016-06-29 11:23:25 -07003437 * @param extras Optional bundle containing extra information associated with the event.
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003438 */
Tyler Gunn876dbfb2016-03-14 15:18:07 -07003439 public void sendConnectionEvent(String event, Bundle extras) {
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003440 for (Listener l : mListeners) {
Tyler Gunna8fb8ab2016-03-29 10:24:22 -07003441 l.onConnectionEvent(this, event, extras);
Tyler Gunnbd1eb1f2016-02-16 14:36:20 -08003442 }
3443 }
Tyler Gunn6986a632019-06-25 13:45:32 -07003444
3445 /**
3446 * @return The direction of the call.
3447 * @hide
3448 */
3449 public final @Call.Details.CallDirection int getCallDirection() {
3450 return mCallDirection;
3451 }
3452
3453 /**
3454 * Sets the direction of this connection.
Tyler Gunnc63f9082019-10-15 13:19:26 -07003455 * <p>
3456 * Used when calling {@link ConnectionService#addExistingConnection} to specify the existing
3457 * call direction.
3458 *
Tyler Gunn6986a632019-06-25 13:45:32 -07003459 * @param callDirection The direction of this connection.
3460 * @hide
3461 */
Tyler Gunnc63f9082019-10-15 13:19:26 -07003462 @SystemApi
Tyler Gunn5567d742019-10-31 13:04:37 -07003463 @TestApi
Tyler Gunn6986a632019-06-25 13:45:32 -07003464 public void setCallDirection(@Call.Details.CallDirection int callDirection) {
3465 mCallDirection = callDirection;
3466 }
Tyler Gunnd57d76c2019-09-24 14:53:23 -07003467
3468 /**
3469 * Gets the verification status for the phone number of an incoming call as identified in
3470 * ATIS-1000082.
3471 * @return the verification status.
3472 */
3473 public @VerificationStatus int getCallerNumberVerificationStatus() {
3474 return mCallerNumberVerificationStatus;
3475 }
3476
3477 /**
3478 * Sets the verification status for the phone number of an incoming call as identified in
3479 * ATIS-1000082.
3480 * <p>
3481 * This property can only be set at the time of creation of a {@link Connection} being returned
3482 * by
3483 * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)}.
3484 */
3485 public void setCallerNumberVerificationStatus(
3486 @VerificationStatus int callerNumberVerificationStatus) {
3487 mCallerNumberVerificationStatus = callerNumberVerificationStatus;
3488 }
Ihab Awad542e0ea2014-05-16 10:22:16 -07003489}