| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1 | /* | 
|  | 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 Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 17 | package android.telecom; | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 18 |  | 
| Tyler Gunn | c9503d6 | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 19 | import static android.Manifest.permission.MODIFY_PHONE_STATE; | 
|  | 20 |  | 
| Hall Liu | 49cabcc | 2021-01-15 11:41:48 -0800 | [diff] [blame] | 21 | import android.Manifest; | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 22 | import android.annotation.CallbackExecutor; | 
| Tyler Gunn | c9503d6 | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 23 | import android.annotation.ElapsedRealtimeLong; | 
| Tyler Gunn | d57d76c | 2019-09-24 14:53:23 -0700 | [diff] [blame] | 24 | import android.annotation.IntDef; | 
| Tyler Gunn | c9503d6 | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 25 | import android.annotation.IntRange; | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 26 | import android.annotation.NonNull; | 
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 27 | import android.annotation.Nullable; | 
| Tyler Gunn | c9503d6 | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 28 | import android.annotation.RequiresPermission; | 
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 29 | import android.annotation.SystemApi; | 
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 30 | import android.app.Notification; | 
| Hall Liu | a98f58b5 | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 31 | import android.bluetooth.BluetoothDevice; | 
| Artur Satayev | 53ada2a | 2019-12-10 17:47:56 +0000 | [diff] [blame] | 32 | import android.compat.annotation.UnsupportedAppUsage; | 
| Hall Liu | 7390314 | 2021-02-18 18:41:41 -0800 | [diff] [blame] | 33 | import android.content.ComponentName; | 
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 34 | import android.content.Intent; | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 35 | import android.hardware.camera2.CameraManager; | 
| yongnamcha | 8ec5624 | 2022-11-28 06:23:02 +0000 | [diff] [blame] | 36 | import android.location.Location; | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 37 | import android.net.Uri; | 
| Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 38 | import android.os.Binder; | 
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 39 | import android.os.Bundle; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 40 | import android.os.Handler; | 
|  | 41 | import android.os.IBinder; | 
| Tyler Gunn | 4e9bbaf | 2015-05-22 15:43:28 -0700 | [diff] [blame] | 42 | import android.os.Looper; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 43 | import android.os.Message; | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 44 | import android.os.OutcomeReceiver; | 
| Hall Liu | 7390314 | 2021-02-18 18:41:41 -0800 | [diff] [blame] | 45 | import android.os.Parcel; | 
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 46 | import android.os.ParcelFileDescriptor; | 
| Hall Liu | 7390314 | 2021-02-18 18:41:41 -0800 | [diff] [blame] | 47 | import android.os.Parcelable; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 48 | import android.os.RemoteException; | 
| Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 49 | import android.os.SystemClock; | 
| Tyler Gunn | 0a1c6d1 | 2021-03-12 15:44:08 -0800 | [diff] [blame] | 50 | import android.telephony.CallQuality; | 
| Sooraj Sasindran | 065b77d | 2022-02-24 00:14:51 -0800 | [diff] [blame] | 51 | import android.telephony.CellIdentity; | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 52 | import android.telephony.ims.ImsStreamMediaProfile; | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 53 | import android.util.ArraySet; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 54 | import android.view.Surface; | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 55 |  | 
| Youming Ye | d6de26e | 2019-01-30 11:20:35 -0800 | [diff] [blame] | 56 | import com.android.internal.os.SomeArgs; | 
|  | 57 | import com.android.internal.telecom.IVideoCallback; | 
|  | 58 | import com.android.internal.telecom.IVideoProvider; | 
|  | 59 |  | 
| Hall Liu | a549fed | 2018-02-09 16:40:03 -0800 | [diff] [blame] | 60 | import java.io.FileInputStream; | 
|  | 61 | import java.io.FileOutputStream; | 
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 62 | import java.io.IOException; | 
|  | 63 | import java.io.InputStreamReader; | 
|  | 64 | import java.io.OutputStreamWriter; | 
| Tyler Gunn | d57d76c | 2019-09-24 14:53:23 -0700 | [diff] [blame] | 65 | import java.lang.annotation.Retention; | 
|  | 66 | import java.lang.annotation.RetentionPolicy; | 
| Hall Liu | 730a259 | 2018-06-25 19:48:33 -0700 | [diff] [blame] | 67 | import java.nio.channels.Channels; | 
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 68 | import java.util.ArrayList; | 
| Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 69 | import java.util.Arrays; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 70 | import java.util.Collections; | 
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 71 | import java.util.List; | 
| Edgar Arriaga | 2db19d2 | 2022-10-14 14:25:14 -0700 | [diff] [blame] | 72 | import java.util.Objects; | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 73 | import java.util.Set; | 
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 74 | import java.util.concurrent.ConcurrentHashMap; | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 75 | import java.util.concurrent.Executor; | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 76 |  | 
|  | 77 | /** | 
| Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 78 | * Represents a phone call or connection to a remote endpoint that carries voice and/or video | 
|  | 79 | * traffic. | 
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 80 | * <p> | 
|  | 81 | * Implementations create a custom subclass of {@code Connection} and return it to the framework | 
|  | 82 | * as the return value of | 
|  | 83 | * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)} | 
|  | 84 | * or | 
|  | 85 | * {@link ConnectionService#onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}. | 
|  | 86 | * Implementations are then responsible for updating the state of the {@code Connection}, and | 
|  | 87 | * must call {@link #destroy()} to signal to the framework that the {@code Connection} is no | 
|  | 88 | * longer used and associated resources may be recovered. | 
| Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 89 | * <p> | 
| Mateus Azis | 6349436 | 2023-03-10 09:29:01 -0800 | [diff] [blame] | 90 | * Subclasses of {@code Connection} override the {@code on*} methods to provide the | 
| Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 91 | * {@link ConnectionService}'s implementation of calling functionality.  The {@code on*} methods are | 
|  | 92 | * called by Telecom to inform an instance of a {@code Connection} of actions specific to that | 
|  | 93 | * {@code Connection} instance. | 
|  | 94 | * <p> | 
|  | 95 | * Basic call support requires overriding the following methods: {@link #onAnswer()}, | 
|  | 96 | * {@link #onDisconnect()}, {@link #onReject()}, {@link #onAbort()} | 
|  | 97 | * <p> | 
|  | 98 | * Where a {@code Connection} has {@link #CAPABILITY_SUPPORT_HOLD}, the {@link #onHold()} and | 
|  | 99 | * {@link #onUnhold()} methods should be overridden to provide hold support for the | 
|  | 100 | * {@code Connection}. | 
|  | 101 | * <p> | 
|  | 102 | * Where a {@code Connection} supports a variation of video calling (e.g. the | 
|  | 103 | * {@code CAPABILITY_SUPPORTS_VT_*} capability bits), {@link #onAnswer(int)} should be overridden | 
|  | 104 | * to support answering a call as a video call. | 
|  | 105 | * <p> | 
|  | 106 | * Where a {@code Connection} has {@link #PROPERTY_IS_EXTERNAL_CALL} and | 
|  | 107 | * {@link #CAPABILITY_CAN_PULL_CALL}, {@link #onPullExternalCall()} should be overridden to provide | 
|  | 108 | * support for pulling the external call. | 
|  | 109 | * <p> | 
|  | 110 | * Where a {@code Connection} supports conference calling {@link #onSeparate()} should be | 
|  | 111 | * overridden. | 
|  | 112 | * <p> | 
|  | 113 | * There are a number of other {@code on*} methods which a {@code Connection} can choose to | 
|  | 114 | * implement, depending on whether it is concerned with the associated calls from Telecom.  If, | 
|  | 115 | * for example, call events from a {@link InCallService} are handled, | 
|  | 116 | * {@link #onCallEvent(String, Bundle)} should be overridden.  Another example is | 
|  | 117 | * {@link #onExtrasChanged(Bundle)}, which should be overridden if the {@code Connection} wishes to | 
|  | 118 | * make use of extra information provided via the {@link Call#putExtras(Bundle)} and | 
|  | 119 | * {@link Call#removeExtras(String...)} methods. | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 120 | */ | 
| Yorke Lee | abfcfdc | 2015-05-13 18:55:18 -0700 | [diff] [blame] | 121 | public abstract class Connection extends Conferenceable { | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 122 |  | 
| Tyler Gunn | 50d437f | 2021-01-12 16:34:59 -0800 | [diff] [blame] | 123 | /**@hide*/ | 
|  | 124 | @Retention(RetentionPolicy.SOURCE) | 
|  | 125 | @IntDef(prefix = "STATE_", value = { | 
|  | 126 | STATE_INITIALIZING, | 
|  | 127 | STATE_NEW, | 
|  | 128 | STATE_RINGING, | 
|  | 129 | STATE_DIALING, | 
|  | 130 | STATE_ACTIVE, | 
|  | 131 | STATE_HOLDING, | 
|  | 132 | STATE_DISCONNECTED, | 
|  | 133 | STATE_PULLING_CALL | 
|  | 134 | }) | 
|  | 135 | public @interface ConnectionState {} | 
|  | 136 |  | 
| Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 137 | /** | 
|  | 138 | * The connection is initializing. This is generally the first state for a {@code Connection} | 
|  | 139 | * returned by a {@link ConnectionService}. | 
|  | 140 | */ | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 141 | public static final int STATE_INITIALIZING = 0; | 
|  | 142 |  | 
| Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 143 | /** | 
|  | 144 | * The connection is new and not connected. | 
|  | 145 | */ | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 146 | public static final int STATE_NEW = 1; | 
|  | 147 |  | 
| Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 148 | /** | 
|  | 149 | * An incoming connection is in the ringing state. During this state, the user's ringer or | 
|  | 150 | * vibration feature will be activated. | 
|  | 151 | */ | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 152 | public static final int STATE_RINGING = 2; | 
|  | 153 |  | 
| Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 154 | /** | 
|  | 155 | * An outgoing connection is in the dialing state. In this state the other party has not yet | 
|  | 156 | * answered the call and the user traditionally hears a ringback tone. | 
|  | 157 | */ | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 158 | public static final int STATE_DIALING = 3; | 
|  | 159 |  | 
| Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 160 | /** | 
|  | 161 | * A connection is active. Both parties are connected to the call and can actively communicate. | 
|  | 162 | */ | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 163 | public static final int STATE_ACTIVE = 4; | 
|  | 164 |  | 
| Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 165 | /** | 
|  | 166 | * A connection is on hold. | 
|  | 167 | */ | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 168 | public static final int STATE_HOLDING = 5; | 
|  | 169 |  | 
| Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 170 | /** | 
|  | 171 | * A connection has been disconnected. This is the final state once the user has been | 
|  | 172 | * disconnected from a call either locally, remotely or by an error in the service. | 
|  | 173 | */ | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 174 | public static final int STATE_DISCONNECTED = 6; | 
|  | 175 |  | 
| Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 176 | /** | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 177 | * The state of an external connection which is in the process of being pulled from a remote | 
|  | 178 | * device to the local device. | 
|  | 179 | * <p> | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 180 | * A connection can only be in this state if the {@link #PROPERTY_IS_EXTERNAL_CALL} property and | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 181 | * {@link #CAPABILITY_CAN_PULL_CALL} capability bits are set on the connection. | 
|  | 182 | */ | 
|  | 183 | public static final int STATE_PULLING_CALL = 7; | 
|  | 184 |  | 
|  | 185 | /** | 
| Tyler Gunn | d57d76c | 2019-09-24 14:53:23 -0700 | [diff] [blame] | 186 | * Indicates that the network could not perform verification. | 
|  | 187 | */ | 
|  | 188 | public static final int VERIFICATION_STATUS_NOT_VERIFIED = 0; | 
|  | 189 |  | 
|  | 190 | /** | 
|  | 191 | * Indicates that verification by the network passed.  This indicates there is a high likelihood | 
|  | 192 | * that the call originated from a valid source. | 
|  | 193 | */ | 
|  | 194 | public static final int VERIFICATION_STATUS_PASSED = 1; | 
|  | 195 |  | 
|  | 196 | /** | 
|  | 197 | * Indicates that verification by the network failed.  This indicates there is a high likelihood | 
|  | 198 | * that the call did not originate from a valid source. | 
|  | 199 | */ | 
|  | 200 | public static final int VERIFICATION_STATUS_FAILED = 2; | 
|  | 201 |  | 
|  | 202 | /**@hide*/ | 
|  | 203 | @Retention(RetentionPolicy.SOURCE) | 
|  | 204 | @IntDef(prefix = "VERIFICATION_STATUS_", value = { | 
|  | 205 | VERIFICATION_STATUS_NOT_VERIFIED, | 
|  | 206 | VERIFICATION_STATUS_PASSED, | 
|  | 207 | VERIFICATION_STATUS_FAILED | 
|  | 208 | }) | 
|  | 209 | public @interface VerificationStatus {} | 
|  | 210 |  | 
|  | 211 | /** | 
| Santos Cordon | 895d4b8 | 2015-06-25 16:41:48 -0700 | [diff] [blame] | 212 | * Connection can currently be put on hold or unheld. This is distinct from | 
|  | 213 | * {@link #CAPABILITY_SUPPORT_HOLD} in that although a connection may support 'hold' most times, | 
|  | 214 | * it does not at the moment support the function. This can be true while the call is in the | 
|  | 215 | * state {@link #STATE_DIALING}, for example. During this condition, an in-call UI may | 
|  | 216 | * display a disabled 'hold' button. | 
|  | 217 | */ | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 218 | public static final int CAPABILITY_HOLD = 0x00000001; | 
|  | 219 |  | 
|  | 220 | /** Connection supports the hold feature. */ | 
|  | 221 | public static final int CAPABILITY_SUPPORT_HOLD = 0x00000002; | 
|  | 222 |  | 
|  | 223 | /** | 
|  | 224 | * Connections within a conference can be merged. A {@link ConnectionService} has the option to | 
|  | 225 | * add a {@link Conference} before the child {@link Connection}s are merged. This is how | 
|  | 226 | * CDMA-based {@link Connection}s are implemented. For these unmerged {@link Conference}s, this | 
|  | 227 | * capability allows a merge button to be shown while the conference is in the foreground | 
|  | 228 | * of the in-call UI. | 
|  | 229 | * <p> | 
|  | 230 | * This is only intended for use by a {@link Conference}. | 
|  | 231 | */ | 
|  | 232 | public static final int CAPABILITY_MERGE_CONFERENCE = 0x00000004; | 
|  | 233 |  | 
|  | 234 | /** | 
|  | 235 | * Connections within a conference can be swapped between foreground and background. | 
|  | 236 | * See {@link #CAPABILITY_MERGE_CONFERENCE} for additional information. | 
|  | 237 | * <p> | 
|  | 238 | * This is only intended for use by a {@link Conference}. | 
|  | 239 | */ | 
|  | 240 | public static final int CAPABILITY_SWAP_CONFERENCE = 0x00000008; | 
|  | 241 |  | 
|  | 242 | /** | 
|  | 243 | * @hide | 
|  | 244 | */ | 
|  | 245 | public static final int CAPABILITY_UNUSED = 0x00000010; | 
|  | 246 |  | 
|  | 247 | /** Connection supports responding via text option. */ | 
|  | 248 | public static final int CAPABILITY_RESPOND_VIA_TEXT = 0x00000020; | 
|  | 249 |  | 
|  | 250 | /** Connection can be muted. */ | 
|  | 251 | public static final int CAPABILITY_MUTE = 0x00000040; | 
|  | 252 |  | 
|  | 253 | /** | 
|  | 254 | * Connection supports conference management. This capability only applies to | 
|  | 255 | * {@link Conference}s which can have {@link Connection}s as children. | 
|  | 256 | */ | 
|  | 257 | public static final int CAPABILITY_MANAGE_CONFERENCE = 0x00000080; | 
|  | 258 |  | 
|  | 259 | /** | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 260 | * Local device supports receiving video. | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 261 | */ | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 262 | public static final int CAPABILITY_SUPPORTS_VT_LOCAL_RX = 0x00000100; | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 263 |  | 
|  | 264 | /** | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 265 | * Local device supports transmitting video. | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 266 | */ | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 267 | public static final int CAPABILITY_SUPPORTS_VT_LOCAL_TX = 0x00000200; | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 268 |  | 
|  | 269 | /** | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 270 | * Local device supports bidirectional video calling. | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 271 | */ | 
| Andrew Lee | 9a8f9ce | 2015-04-10 18:09:46 -0700 | [diff] [blame] | 272 | public static final int CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL = | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 273 | CAPABILITY_SUPPORTS_VT_LOCAL_RX | CAPABILITY_SUPPORTS_VT_LOCAL_TX; | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 274 |  | 
|  | 275 | /** | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 276 | * Remote device supports receiving video. | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 277 | */ | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 278 | public static final int CAPABILITY_SUPPORTS_VT_REMOTE_RX = 0x00000400; | 
|  | 279 |  | 
|  | 280 | /** | 
|  | 281 | * Remote device supports transmitting video. | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 282 | */ | 
|  | 283 | public static final int CAPABILITY_SUPPORTS_VT_REMOTE_TX = 0x00000800; | 
|  | 284 |  | 
|  | 285 | /** | 
|  | 286 | * Remote device supports bidirectional video calling. | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 287 | */ | 
| Andrew Lee | 9a8f9ce | 2015-04-10 18:09:46 -0700 | [diff] [blame] | 288 | public static final int CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL = | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 289 | CAPABILITY_SUPPORTS_VT_REMOTE_RX | CAPABILITY_SUPPORTS_VT_REMOTE_TX; | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 290 |  | 
|  | 291 | /** | 
|  | 292 | * Connection is able to be separated from its parent {@code Conference}, if any. | 
|  | 293 | */ | 
|  | 294 | public static final int CAPABILITY_SEPARATE_FROM_CONFERENCE = 0x00001000; | 
|  | 295 |  | 
|  | 296 | /** | 
|  | 297 | * Connection is able to be individually disconnected when in a {@code Conference}. | 
|  | 298 | */ | 
|  | 299 | public static final int CAPABILITY_DISCONNECT_FROM_CONFERENCE = 0x00002000; | 
|  | 300 |  | 
|  | 301 | /** | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 302 | * Un-used. | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 303 | * @hide | 
|  | 304 | */ | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 305 | public static final int CAPABILITY_UNUSED_2 = 0x00004000; | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 306 |  | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 307 | /** | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 308 | * Un-used. | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 309 | * @hide | 
|  | 310 | */ | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 311 | public static final int CAPABILITY_UNUSED_3 = 0x00008000; | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 312 |  | 
|  | 313 | /** | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 314 | * Un-used. | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 315 | * @hide | 
|  | 316 | */ | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 317 | public static final int CAPABILITY_UNUSED_4 = 0x00010000; | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 318 |  | 
| Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 319 | /** | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 320 | * Un-used. | 
| Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 321 | * @hide | 
|  | 322 | */ | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 323 | public static final int CAPABILITY_UNUSED_5 = 0x00020000; | 
| Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 324 |  | 
| Tyler Gunn | 96d6c40 | 2015-03-18 12:39:23 -0700 | [diff] [blame] | 325 | /** | 
| Dong Zhou | 89f41eb | 2015-03-15 11:59:49 -0500 | [diff] [blame] | 326 | * Speed up audio setup for MT call. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 327 | * <p> | 
|  | 328 | * Used for IMS calls to indicate that mobile-terminated (incoming) call audio setup should take | 
|  | 329 | * place as soon as the device answers the call, but prior to it being connected.  This is an | 
|  | 330 | * optimization some IMS stacks depend on to ensure prompt setup of call audio. | 
| Dong Zhou | 89f41eb | 2015-03-15 11:59:49 -0500 | [diff] [blame] | 331 | * @hide | 
| Tyler Gunn | 96d6c40 | 2015-03-18 12:39:23 -0700 | [diff] [blame] | 332 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 333 | @SystemApi | 
| Tyler Gunn | 96d6c40 | 2015-03-18 12:39:23 -0700 | [diff] [blame] | 334 | public static final int CAPABILITY_SPEED_UP_MT_AUDIO = 0x00040000; | 
| Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 335 |  | 
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 336 | /** | 
| Tyler Gunn | b5e0cfb | 2015-04-07 16:10:51 -0700 | [diff] [blame] | 337 | * Call can be upgraded to a video call. | 
| Tyler Gunn | 6e3ecc4 | 2018-11-12 11:30:56 -0800 | [diff] [blame] | 338 | * @deprecated Use {@link #CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL} and | 
|  | 339 | * {@link #CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL} to indicate for a call whether or not | 
|  | 340 | * video calling is supported. | 
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 341 | */ | 
|  | 342 | public static final int CAPABILITY_CAN_UPGRADE_TO_VIDEO = 0x00080000; | 
|  | 343 |  | 
| Tyler Gunn | b5e0cfb | 2015-04-07 16:10:51 -0700 | [diff] [blame] | 344 | /** | 
|  | 345 | * For video calls, indicates whether the outgoing video for the call can be paused using | 
| Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 346 | * the {@link android.telecom.VideoProfile#STATE_PAUSED} VideoState. | 
| Tyler Gunn | b5e0cfb | 2015-04-07 16:10:51 -0700 | [diff] [blame] | 347 | */ | 
|  | 348 | public static final int CAPABILITY_CAN_PAUSE_VIDEO = 0x00100000; | 
|  | 349 |  | 
| Tyler Gunn | d409173 | 2015-06-29 09:15:37 -0700 | [diff] [blame] | 350 | /** | 
|  | 351 | * For a conference, indicates the conference will not have child connections. | 
|  | 352 | * <p> | 
|  | 353 | * An example of a conference with child connections is a GSM conference call, where the radio | 
|  | 354 | * retains connections to the individual participants of the conference.  Another example is an | 
|  | 355 | * IMS conference call where conference event package functionality is supported; in this case | 
|  | 356 | * the conference server ensures the radio is aware of the participants in the conference, which | 
|  | 357 | * are represented by child connections. | 
|  | 358 | * <p> | 
|  | 359 | * An example of a conference with no child connections is an IMS conference call with no | 
|  | 360 | * conference event package support.  Such a conference is represented by the radio as a single | 
|  | 361 | * connection to the IMS conference server. | 
|  | 362 | * <p> | 
|  | 363 | * Indicating whether a conference has children or not is important to help user interfaces | 
|  | 364 | * visually represent a conference.  A conference with no children, for example, will have the | 
|  | 365 | * conference connection shown in the list of calls on a Bluetooth device, where if the | 
|  | 366 | * conference has children, only the children will be shown in the list of calls on a Bluetooth | 
|  | 367 | * device. | 
|  | 368 | * @hide | 
|  | 369 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 370 | @SystemApi | 
| Tyler Gunn | d409173 | 2015-06-29 09:15:37 -0700 | [diff] [blame] | 371 | public static final int CAPABILITY_CONFERENCE_HAS_NO_CHILDREN = 0x00200000; | 
|  | 372 |  | 
| Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 373 | /** | 
|  | 374 | * Indicates that the connection itself wants to handle any sort of reply response, rather than | 
|  | 375 | * relying on SMS. | 
| Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 376 | */ | 
|  | 377 | public static final int CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION = 0x00400000; | 
|  | 378 |  | 
| Tyler Gunn | f97a009 | 2016-01-19 15:59:34 -0800 | [diff] [blame] | 379 | /** | 
|  | 380 | * When set, prevents a video call from being downgraded to an audio-only call. | 
|  | 381 | * <p> | 
|  | 382 | * Should be set when the VideoState has the {@link VideoProfile#STATE_TX_ENABLED} or | 
|  | 383 | * {@link VideoProfile#STATE_RX_ENABLED} bits set to indicate that the connection cannot be | 
|  | 384 | * downgraded from a video call back to a VideoState of | 
|  | 385 | * {@link VideoProfile#STATE_AUDIO_ONLY}. | 
|  | 386 | * <p> | 
|  | 387 | * Intuitively, a call which can be downgraded to audio should also have local and remote | 
|  | 388 | * video | 
|  | 389 | * capabilities (see {@link #CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL} and | 
|  | 390 | * {@link #CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL}). | 
|  | 391 | */ | 
|  | 392 | public static final int CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO = 0x00800000; | 
|  | 393 |  | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 394 | /** | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 395 | * When set for an external connection, indicates that this {@code Connection} can be pulled | 
|  | 396 | * from a remote device to the current device. | 
|  | 397 | * <p> | 
|  | 398 | * Should only be set on a {@code Connection} where {@link #PROPERTY_IS_EXTERNAL_CALL} | 
|  | 399 | * is set. | 
|  | 400 | */ | 
|  | 401 | public static final int CAPABILITY_CAN_PULL_CALL = 0x01000000; | 
|  | 402 |  | 
| Pooja Jain | d34698d | 2017-12-28 14:15:31 +0530 | [diff] [blame] | 403 | /** Call supports the deflect feature. */ | 
|  | 404 | public static final int CAPABILITY_SUPPORT_DEFLECT = 0x02000000; | 
|  | 405 |  | 
| Ravi Paluri | 404babb | 2020-01-23 19:02:44 +0530 | [diff] [blame] | 406 | /** | 
|  | 407 | * When set, indicates that this {@link Connection} supports initiation of a conference call | 
| Grace Jia | 8587ee5 | 2020-07-10 15:42:32 -0700 | [diff] [blame] | 408 | * by directly adding participants using {@link #onAddConferenceParticipants(List)}. When | 
|  | 409 | * participants are added to a {@link Connection}, it will be replaced by a {@link Conference} | 
|  | 410 | * instance with {@link #PROPERTY_IS_ADHOC_CONFERENCE} set to indicate that it is an adhoc | 
|  | 411 | * conference call. | 
| Ravi Paluri | 404babb | 2020-01-23 19:02:44 +0530 | [diff] [blame] | 412 | */ | 
|  | 413 | public static final int CAPABILITY_ADD_PARTICIPANT = 0x04000000; | 
| Ravi Paluri | f4b38e7 | 2020-02-05 12:35:41 +0530 | [diff] [blame] | 414 |  | 
|  | 415 | /** | 
|  | 416 | * Indicates that this {@code Connection} can be transferred to another | 
|  | 417 | * number. | 
| Tyler Gunn | 460360d | 2020-07-29 10:21:45 -0700 | [diff] [blame] | 418 | * Connection supports the confirmed and unconfirmed call transfer feature. | 
| Ravi Paluri | f4b38e7 | 2020-02-05 12:35:41 +0530 | [diff] [blame] | 419 | * @hide | 
|  | 420 | */ | 
|  | 421 | public static final int CAPABILITY_TRANSFER = 0x08000000; | 
|  | 422 |  | 
|  | 423 | /** | 
|  | 424 | * Indicates that this {@code Connection} can be transferred to another | 
|  | 425 | * ongoing {@code Connection}. | 
|  | 426 | * Connection supports the consultative call transfer feature. | 
|  | 427 | * @hide | 
|  | 428 | */ | 
|  | 429 | public static final int CAPABILITY_TRANSFER_CONSULTATIVE = 0x10000000; | 
|  | 430 |  | 
| Alvin Dey | 2f37d77 | 2018-05-18 23:16:10 +0530 | [diff] [blame] | 431 | /** | 
|  | 432 | * Indicates whether the remote party supports RTT or not to the UI. | 
|  | 433 | */ | 
|  | 434 |  | 
|  | 435 | public static final int CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT = 0x20000000; | 
|  | 436 |  | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 437 | //********************************************************************************************** | 
| Alvin Dey | 2f37d77 | 2018-05-18 23:16:10 +0530 | [diff] [blame] | 438 | // Next CAPABILITY value: 0x40000000 | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 439 | //********************************************************************************************** | 
|  | 440 |  | 
|  | 441 | /** | 
|  | 442 | * Indicates that the current device callback number should be shown. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 443 | * <p> | 
|  | 444 | * Supports Telephony calls where CDMA emergency callback mode is active. | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 445 | * @hide | 
|  | 446 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 447 | @SystemApi | 
| Hall Liu | 25c7c4d | 2016-08-30 13:41:02 -0700 | [diff] [blame] | 448 | public static final int PROPERTY_EMERGENCY_CALLBACK_MODE = 1<<0; | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 449 |  | 
|  | 450 | /** | 
|  | 451 | * Whether the call is a generic conference, where we do not know the precise state of | 
|  | 452 | * participants in the conference (eg. on CDMA). | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 453 | * <p> | 
|  | 454 | * Supports legacy telephony CDMA calls. | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 455 | * @hide | 
|  | 456 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 457 | @SystemApi | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 458 | public static final int PROPERTY_GENERIC_CONFERENCE = 1<<1; | 
|  | 459 |  | 
|  | 460 | /** | 
|  | 461 | * Connection is using high definition audio. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 462 | * <p> | 
|  | 463 | * Indicates that the {@link Connection} is using a "high definition" audio codec.  This usually | 
|  | 464 | * implies something like AMR wideband, but the interpretation of when a call is considered high | 
|  | 465 | * definition is left to the {@link ConnectionService} to decide. | 
|  | 466 | * <p> | 
|  | 467 | * Translates to {@link android.telecom.Call.Details#PROPERTY_HIGH_DEF_AUDIO}. | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 468 | */ | 
|  | 469 | public static final int PROPERTY_HIGH_DEF_AUDIO = 1<<2; | 
|  | 470 |  | 
|  | 471 | /** | 
|  | 472 | * Connection is using WIFI. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 473 | * <p> | 
|  | 474 | * Used to indicate that a call is taking place over WIFI versus a carrier network. | 
|  | 475 | * <p> | 
|  | 476 | * Translates to {@link android.telecom.Call.Details#PROPERTY_WIFI}. | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 477 | */ | 
|  | 478 | public static final int PROPERTY_WIFI = 1<<3; | 
|  | 479 |  | 
|  | 480 | /** | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 481 | * When set, indicates that the {@code Connection} does not actually exist locally for the | 
|  | 482 | * {@link ConnectionService}. | 
|  | 483 | * <p> | 
|  | 484 | * Consider, for example, a scenario where a user has two devices with the same phone number. | 
|  | 485 | * When a user places a call on one devices, the telephony stack can represent that call on the | 
|  | 486 | * other device by adding is to the {@link ConnectionService} with the | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 487 | * {@link #PROPERTY_IS_EXTERNAL_CALL} capability set. | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 488 | * <p> | 
|  | 489 | * An {@link ConnectionService} should not assume that all {@link InCallService}s will handle | 
|  | 490 | * external connections.  Only those {@link InCallService}s which have the | 
|  | 491 | * {@link TelecomManager#METADATA_INCLUDE_EXTERNAL_CALLS} metadata set to {@code true} in its | 
|  | 492 | * manifest will see external connections. | 
|  | 493 | */ | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 494 | public static final int PROPERTY_IS_EXTERNAL_CALL = 1<<4; | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 495 |  | 
| Brad Ebinger | 1584707 | 2016-05-18 11:08:36 -0700 | [diff] [blame] | 496 | /** | 
|  | 497 | * Indicates that the connection has CDMA Enhanced Voice Privacy enabled. | 
|  | 498 | */ | 
|  | 499 | public static final int PROPERTY_HAS_CDMA_VOICE_PRIVACY = 1<<5; | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 500 |  | 
| Hall Liu | 9f332c7 | 2016-07-14 15:37:37 -0700 | [diff] [blame] | 501 | /** | 
|  | 502 | * Indicates that the connection represents a downgraded IMS conference. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 503 | * <p> | 
|  | 504 | * This property is set when an IMS conference undergoes SRVCC and is re-added to Telecom as a | 
|  | 505 | * new entity to indicate that the new connection was a conference. | 
| Hall Liu | 9f332c7 | 2016-07-14 15:37:37 -0700 | [diff] [blame] | 506 | * @hide | 
|  | 507 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 508 | @SystemApi | 
| Hall Liu | 9f332c7 | 2016-07-14 15:37:37 -0700 | [diff] [blame] | 509 | public static final int PROPERTY_IS_DOWNGRADED_CONFERENCE = 1<<6; | 
|  | 510 |  | 
| Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 511 | /** | 
|  | 512 | * Set by the framework to indicate that the {@link Connection} originated from a self-managed | 
|  | 513 | * {@link ConnectionService}. | 
|  | 514 | * <p> | 
|  | 515 | * See {@link PhoneAccount#CAPABILITY_SELF_MANAGED}. | 
|  | 516 | */ | 
|  | 517 | public static final int PROPERTY_SELF_MANAGED = 1<<7; | 
|  | 518 |  | 
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 519 | /** | 
| Hall Liu | ffa4a81 | 2017-03-02 16:11:00 -0800 | [diff] [blame] | 520 | * Set by the framework to indicate that a connection has an active RTT session associated with | 
|  | 521 | * it. | 
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 522 | */ | 
|  | 523 | public static final int PROPERTY_IS_RTT = 1 << 8; | 
|  | 524 |  | 
| Eric Erfanian | 62706c5 | 2017-12-06 16:27:53 -0800 | [diff] [blame] | 525 | /** | 
|  | 526 | * Set by the framework to indicate that a connection is using assisted dialing. | 
| Tyler Gunn | 5567d74 | 2019-10-31 13:04:37 -0700 | [diff] [blame] | 527 | * <p> | 
|  | 528 | * This is used for outgoing calls. | 
|  | 529 | * | 
|  | 530 | * @see TelecomManager#EXTRA_USE_ASSISTED_DIALING | 
| Eric Erfanian | 62706c5 | 2017-12-06 16:27:53 -0800 | [diff] [blame] | 531 | */ | 
| Tyler Gunn | c9503d6 | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 532 | public static final int PROPERTY_ASSISTED_DIALING = 1 << 9; | 
| Eric Erfanian | 62706c5 | 2017-12-06 16:27:53 -0800 | [diff] [blame] | 533 |  | 
| Tyler Gunn | 5bd9085 | 2018-09-21 09:37:07 -0700 | [diff] [blame] | 534 | /** | 
|  | 535 | * Set by the framework to indicate that the network has identified a Connection as an emergency | 
|  | 536 | * call. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 537 | * <p> | 
|  | 538 | * This is used for incoming (mobile-terminated) calls to indicate the call is from emergency | 
|  | 539 | * services. | 
| Tyler Gunn | 5bd9085 | 2018-09-21 09:37:07 -0700 | [diff] [blame] | 540 | */ | 
|  | 541 | public static final int PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL = 1 << 10; | 
|  | 542 |  | 
| Tyler Gunn | ac60f95 | 2019-05-31 07:23:16 -0700 | [diff] [blame] | 543 | /** | 
|  | 544 | * Set by the framework to indicate that a Conference or Connection is hosted by a device other | 
|  | 545 | * than the current one.  Used in scenarios where the conference originator is the remote device | 
|  | 546 | * and the current device is a participant of that conference. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 547 | * <p> | 
|  | 548 | * This property is specific to IMS conference calls originating in Telephony. | 
| Tyler Gunn | ac60f95 | 2019-05-31 07:23:16 -0700 | [diff] [blame] | 549 | * @hide | 
|  | 550 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 551 | @SystemApi | 
| Tyler Gunn | ac60f95 | 2019-05-31 07:23:16 -0700 | [diff] [blame] | 552 | public static final int PROPERTY_REMOTELY_HOSTED = 1 << 11; | 
|  | 553 |  | 
| Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 554 | /** | 
| Grace Jia | 8587ee5 | 2020-07-10 15:42:32 -0700 | [diff] [blame] | 555 | * Set by the framework to indicate that a call is an adhoc conference call. | 
| Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 556 | * <p> | 
| Grace Jia | 8587ee5 | 2020-07-10 15:42:32 -0700 | [diff] [blame] | 557 | * This is used for outgoing and incoming conference calls. | 
| Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 558 | */ | 
|  | 559 | public static final int PROPERTY_IS_ADHOC_CONFERENCE = 1 << 12; | 
|  | 560 |  | 
| Sooraj Sasindran | 64f05b1 | 2020-11-18 12:07:10 -0800 | [diff] [blame] | 561 | /** | 
|  | 562 | * Connection is using cross sim technology. | 
|  | 563 | * <p> | 
|  | 564 | * Indicates that the {@link Connection} is using a cross sim technology which would | 
|  | 565 | * register IMS over internet APN of default data subscription. | 
|  | 566 | * <p> | 
|  | 567 | */ | 
|  | 568 | public static final int PROPERTY_CROSS_SIM = 1 << 13; | 
| Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 569 |  | 
| Tyler Gunn | 96d6c40 | 2015-03-18 12:39:23 -0700 | [diff] [blame] | 570 | //********************************************************************************************** | 
| Sooraj Sasindran | 64f05b1 | 2020-11-18 12:07:10 -0800 | [diff] [blame] | 571 | // Next PROPERTY value: 1<<14 | 
| Tyler Gunn | 96d6c40 | 2015-03-18 12:39:23 -0700 | [diff] [blame] | 572 | //********************************************************************************************** | 
| Tyler Gunn | 068085b | 2015-02-06 13:56:52 -0800 | [diff] [blame] | 573 |  | 
| Tyler Gunn | 335ff2e | 2015-07-30 14:18:33 -0700 | [diff] [blame] | 574 | /** | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 575 | * Indicates that the audio codec is currently not specified or is unknown. | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 576 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 577 | public static final int AUDIO_CODEC_NONE = ImsStreamMediaProfile.AUDIO_QUALITY_NONE; // 0 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 578 | /** | 
|  | 579 | * Adaptive Multi-rate audio codec. | 
|  | 580 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 581 | public static final int AUDIO_CODEC_AMR = ImsStreamMediaProfile.AUDIO_QUALITY_AMR; // 1 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 582 | /** | 
|  | 583 | * Adaptive Multi-rate wideband audio codec. | 
|  | 584 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 585 | public static final int AUDIO_CODEC_AMR_WB = ImsStreamMediaProfile.AUDIO_QUALITY_AMR_WB; // 2 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 586 | /** | 
|  | 587 | * Qualcomm code-excited linear prediction 13 kilobit audio codec. | 
|  | 588 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 589 | public static final int AUDIO_CODEC_QCELP13K = ImsStreamMediaProfile.AUDIO_QUALITY_QCELP13K; //3 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 590 | /** | 
|  | 591 | * Enhanced Variable Rate Codec.  See 3GPP2 C.S0014-A. | 
|  | 592 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 593 | public static final int AUDIO_CODEC_EVRC = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC; // 4 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 594 | /** | 
|  | 595 | * Enhanced Variable Rate Codec B.  Commonly used on CDMA networks. | 
|  | 596 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 597 | public static final int AUDIO_CODEC_EVRC_B = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_B; // 5 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 598 | /** | 
|  | 599 | * Enhanced Variable Rate Wideband Codec.  See RFC5188. | 
|  | 600 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 601 | public static final int AUDIO_CODEC_EVRC_WB = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_WB; // 6 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 602 | /** | 
|  | 603 | * Enhanced Variable Rate Narrowband-Wideband Codec. | 
|  | 604 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 605 | public static final int AUDIO_CODEC_EVRC_NW = ImsStreamMediaProfile.AUDIO_QUALITY_EVRC_NW; // 7 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 606 | /** | 
|  | 607 | * GSM Enhanced Full-Rate audio codec, also known as GSM-EFR, GSM 06.60, or simply EFR. | 
|  | 608 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 609 | public static final int AUDIO_CODEC_GSM_EFR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_EFR; // 8 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 610 | /** | 
|  | 611 | * GSM Full-Rate audio codec, also known as GSM-FR, GSM 06.10, GSM, or simply FR. | 
|  | 612 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 613 | public static final int AUDIO_CODEC_GSM_FR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_FR; // 9 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 614 | /** | 
|  | 615 | * GSM Half Rate audio codec. | 
|  | 616 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 617 | public static final int AUDIO_CODEC_GSM_HR = ImsStreamMediaProfile.AUDIO_QUALITY_GSM_HR; // 10 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 618 | /** | 
|  | 619 | * ITU-T G711U audio codec. | 
|  | 620 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 621 | public static final int AUDIO_CODEC_G711U = ImsStreamMediaProfile.AUDIO_QUALITY_G711U; // 11 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 622 | /** | 
|  | 623 | * ITU-T G723 audio codec. | 
|  | 624 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 625 | public static final int AUDIO_CODEC_G723 = ImsStreamMediaProfile.AUDIO_QUALITY_G723; // 12 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 626 | /** | 
|  | 627 | * ITU-T G711A audio codec. | 
|  | 628 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 629 | public static final int AUDIO_CODEC_G711A = ImsStreamMediaProfile.AUDIO_QUALITY_G711A; // 13 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 630 | /** | 
|  | 631 | * ITU-T G722 audio codec. | 
|  | 632 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 633 | public static final int AUDIO_CODEC_G722 = ImsStreamMediaProfile.AUDIO_QUALITY_G722; // 14 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 634 | /** | 
|  | 635 | * ITU-T G711AB audio codec. | 
|  | 636 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 637 | public static final int AUDIO_CODEC_G711AB = ImsStreamMediaProfile.AUDIO_QUALITY_G711AB; // 15 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 638 | /** | 
|  | 639 | * ITU-T G729 audio codec. | 
|  | 640 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 641 | public static final int AUDIO_CODEC_G729 = ImsStreamMediaProfile.AUDIO_QUALITY_G729; // 16 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 642 | /** | 
|  | 643 | * Enhanced Voice Services Narrowband audio codec.  See 3GPP TS 26.441. | 
|  | 644 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 645 | public static final int AUDIO_CODEC_EVS_NB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_NB; // 17 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 646 | /** | 
|  | 647 | * Enhanced Voice Services Wideband audio codec.  See 3GPP TS 26.441. | 
|  | 648 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 649 | public static final int AUDIO_CODEC_EVS_WB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_WB; // 18 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 650 | /** | 
|  | 651 | * Enhanced Voice Services Super-Wideband audio codec.  See 3GPP TS 26.441. | 
|  | 652 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 653 | public static final int AUDIO_CODEC_EVS_SWB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_SWB; // 19 | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 654 | /** | 
|  | 655 | * Enhanced Voice Services Fullband audio codec.  See 3GPP TS 26.441. | 
|  | 656 | */ | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 657 | public static final int AUDIO_CODEC_EVS_FB = ImsStreamMediaProfile.AUDIO_QUALITY_EVS_FB; // 20 | 
|  | 658 |  | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 659 | /**@hide*/ | 
|  | 660 | @Retention(RetentionPolicy.SOURCE) | 
|  | 661 | @IntDef(prefix = "AUDIO_CODEC_", value = { | 
|  | 662 | AUDIO_CODEC_NONE, | 
|  | 663 | AUDIO_CODEC_AMR, | 
|  | 664 | AUDIO_CODEC_AMR_WB, | 
|  | 665 | AUDIO_CODEC_QCELP13K, | 
|  | 666 | AUDIO_CODEC_EVRC, | 
|  | 667 | AUDIO_CODEC_EVRC_B, | 
|  | 668 | AUDIO_CODEC_EVRC_WB, | 
|  | 669 | AUDIO_CODEC_EVRC_NW, | 
|  | 670 | AUDIO_CODEC_GSM_EFR, | 
|  | 671 | AUDIO_CODEC_GSM_FR, | 
|  | 672 | AUDIO_CODEC_GSM_HR, | 
|  | 673 | AUDIO_CODEC_G711U, | 
|  | 674 | AUDIO_CODEC_G723, | 
|  | 675 | AUDIO_CODEC_G711A, | 
|  | 676 | AUDIO_CODEC_G722, | 
|  | 677 | AUDIO_CODEC_G711AB, | 
|  | 678 | AUDIO_CODEC_G729, | 
|  | 679 | AUDIO_CODEC_EVS_NB, | 
|  | 680 | AUDIO_CODEC_EVS_SWB, | 
|  | 681 | AUDIO_CODEC_EVS_FB | 
|  | 682 | }) | 
|  | 683 | public @interface AudioCodec {} | 
|  | 684 |  | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 685 | /** | 
| Tyler Gunn | 60e5eb6 | 2021-07-01 16:55:32 -0700 | [diff] [blame] | 686 | * Contains the same value as {@link #getCallerNumberVerificationStatus()}, except will be | 
|  | 687 | * present in the {@link #getExtras()} using this key. | 
|  | 688 | * @hide | 
|  | 689 | */ | 
|  | 690 | public static final String EXTRA_CALLER_NUMBER_VERIFICATION_STATUS = | 
|  | 691 | "android.telecom.extra.CALLER_NUMBER_VERIFICATION_STATUS"; | 
|  | 692 |  | 
|  | 693 | /** | 
| Tyler Gunn | 335ff2e | 2015-07-30 14:18:33 -0700 | [diff] [blame] | 694 | * Connection extra key used to store the last forwarded number associated with the current | 
|  | 695 | * connection.  Used to communicate to the user interface that the connection was forwarded via | 
|  | 696 | * the specified number. | 
|  | 697 | */ | 
|  | 698 | public static final String EXTRA_LAST_FORWARDED_NUMBER = | 
|  | 699 | "android.telecom.extra.LAST_FORWARDED_NUMBER"; | 
|  | 700 |  | 
|  | 701 | /** | 
|  | 702 | * Connection extra key used to store a child number associated with the current connection. | 
|  | 703 | * Used to communicate to the user interface that the connection was received via | 
|  | 704 | * a child address (i.e. phone number) associated with the {@link PhoneAccount}'s primary | 
|  | 705 | * address. | 
|  | 706 | */ | 
|  | 707 | public static final String EXTRA_CHILD_ADDRESS = "android.telecom.extra.CHILD_ADDRESS"; | 
|  | 708 |  | 
|  | 709 | /** | 
|  | 710 | * Connection extra key used to store the subject for an incoming call.  The user interface can | 
|  | 711 | * query this extra and display its contents for incoming calls.  Will only be used if the | 
|  | 712 | * {@link PhoneAccount} supports the capability {@link PhoneAccount#CAPABILITY_CALL_SUBJECT}. | 
|  | 713 | */ | 
|  | 714 | public static final String EXTRA_CALL_SUBJECT = "android.telecom.extra.CALL_SUBJECT"; | 
|  | 715 |  | 
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 716 | /** | 
| Tyler Gunn | 4b6614e | 2016-06-22 10:35:13 -0700 | [diff] [blame] | 717 | * Boolean connection extra key set on a {@link Connection} in | 
|  | 718 | * {@link Connection#STATE_RINGING} state to indicate that answering the call will cause the | 
|  | 719 | * current active foreground call to be dropped. | 
|  | 720 | */ | 
|  | 721 | public static final String EXTRA_ANSWERING_DROPS_FG_CALL = | 
|  | 722 | "android.telecom.extra.ANSWERING_DROPS_FG_CALL"; | 
|  | 723 |  | 
|  | 724 | /** | 
| Tyler Gunn | 3765356 | 2017-03-13 18:15:15 -0700 | [diff] [blame] | 725 | * String connection extra key set on a {@link Connection} in {@link Connection#STATE_RINGING} | 
|  | 726 | * state to indicate the name of the third-party app which is responsible for the current | 
|  | 727 | * foreground call. | 
|  | 728 | * <p> | 
|  | 729 | * Used when {@link #EXTRA_ANSWERING_DROPS_FG_CALL} is true to ensure that the default Phone app | 
|  | 730 | * is able to inform the user that answering the new incoming call will cause a call owned by | 
|  | 731 | * another app to be dropped when the incoming call is answered. | 
|  | 732 | */ | 
|  | 733 | public static final String EXTRA_ANSWERING_DROPS_FG_CALL_APP_NAME = | 
|  | 734 | "android.telecom.extra.ANSWERING_DROPS_FG_CALL_APP_NAME"; | 
|  | 735 |  | 
|  | 736 | /** | 
| Hall Liu | 1020866 | 2016-06-15 17:55:00 -0700 | [diff] [blame] | 737 | * Boolean connection extra key on a {@link Connection} which indicates that adding an | 
| Hall Liu | ee6e86b | 2016-07-06 16:32:43 -0700 | [diff] [blame] | 738 | * additional call is disallowed. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 739 | * <p> | 
|  | 740 | * Used for mobile-network calls to identify scenarios where carrier requirements preclude | 
|  | 741 | * adding another call at the current time. | 
| Hall Liu | 1020866 | 2016-06-15 17:55:00 -0700 | [diff] [blame] | 742 | * @hide | 
|  | 743 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 744 | @SystemApi | 
| Hall Liu | ee6e86b | 2016-07-06 16:32:43 -0700 | [diff] [blame] | 745 | public static final String EXTRA_DISABLE_ADD_CALL = | 
|  | 746 | "android.telecom.extra.DISABLE_ADD_CALL"; | 
| Hall Liu | 1020866 | 2016-06-15 17:55:00 -0700 | [diff] [blame] | 747 |  | 
|  | 748 | /** | 
| Tyler Gunn | cd6ccfd | 2016-10-17 15:48:19 -0700 | [diff] [blame] | 749 | * String connection extra key on a {@link Connection} or {@link Conference} which contains the | 
|  | 750 | * original Connection ID associated with the connection.  Used in | 
|  | 751 | * {@link RemoteConnectionService} to track the Connection ID which was originally assigned to a | 
|  | 752 | * connection/conference added via | 
|  | 753 | * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)} and | 
|  | 754 | * {@link ConnectionService#addConference(Conference)} APIs.  This is important to pass to | 
|  | 755 | * Telecom for when it deals with RemoteConnections.  When the ConnectionManager wraps the | 
|  | 756 | * {@link RemoteConnection} and {@link RemoteConference} and adds it to Telecom, there needs to | 
|  | 757 | * be a way to ensure that we don't add the connection again as a duplicate. | 
|  | 758 | * <p> | 
|  | 759 | * For example, the TelephonyCS calls addExistingConnection for a Connection with ID | 
|  | 760 | * {@code TelephonyCS@1}.  The ConnectionManager learns of this via | 
|  | 761 | * {@link ConnectionService#onRemoteExistingConnectionAdded(RemoteConnection)}, and wraps this | 
|  | 762 | * in a new {@link Connection} which it adds to Telecom via | 
|  | 763 | * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)}.  As part of | 
|  | 764 | * this process, the wrapped RemoteConnection gets assigned a new ID (e.g. {@code ConnMan@1}). | 
|  | 765 | * The TelephonyCS will ALSO try to add the existing connection to Telecom, except with the | 
|  | 766 | * ID it originally referred to the connection as.  Thus Telecom needs to know that the | 
|  | 767 | * Connection with ID {@code ConnMan@1} is really the same as {@code TelephonyCS@1}. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 768 | * <p> | 
|  | 769 | * This is an internal Telecom framework concept and is not exposed outside of the Telecom | 
|  | 770 | * framework. | 
| Tyler Gunn | cd6ccfd | 2016-10-17 15:48:19 -0700 | [diff] [blame] | 771 | * @hide | 
|  | 772 | */ | 
|  | 773 | public static final String EXTRA_ORIGINAL_CONNECTION_ID = | 
|  | 774 | "android.telecom.extra.ORIGINAL_CONNECTION_ID"; | 
|  | 775 |  | 
|  | 776 | /** | 
| Tyler Gunn | c59fd0c | 2020-04-17 14:03:35 -0700 | [diff] [blame] | 777 | * Extra key set on a {@link Connection} when it was created via a remote connection service. | 
|  | 778 | * For example, if a connection manager requests a remote connection service to create a call | 
|  | 779 | * using one of the remote connection service's phone account handle, this extra will be set so | 
|  | 780 | * that Telecom knows that the wrapped remote connection originated in a remote connection | 
|  | 781 | * service.  We stash this in the extras since connection managers will typically copy the | 
|  | 782 | * extras from a {@link RemoteConnection} to a {@link Connection} (there is ultimately not | 
|  | 783 | * other way to relate a {@link RemoteConnection} to a {@link Connection}. | 
|  | 784 | * @hide | 
|  | 785 | */ | 
|  | 786 | public static final String EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE = | 
|  | 787 | "android.telecom.extra.REMOTE_PHONE_ACCOUNT_HANDLE"; | 
|  | 788 |  | 
|  | 789 | /** | 
| Tyler Gunn | fdc4bff | 2021-06-24 11:25:07 -0700 | [diff] [blame] | 790 | * The Telecom call ID of the conference an existing connection should be added to.  This is | 
|  | 791 | * required when {@link com.android.services.telephony.TelephonyConnectionService} adds a | 
|  | 792 | * {@link Conference} to Telecom using the | 
|  | 793 | * {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection, Conference)} | 
|  | 794 | * API.  That API specifies a parent conference associated with the new existing connection | 
|  | 795 | * being added, and there is no equivalent as part of the {@link RemoteConnectionService} API. | 
|  | 796 | * This extra key is used to stack the ID of the conference to which the existing connection | 
|  | 797 | * will be added so that Telecom can link it up correctly when the {@link RemoteConference} | 
|  | 798 | * is added to Telecom by the connection manager. | 
|  | 799 | * @hide | 
|  | 800 | */ | 
|  | 801 | public static final String EXTRA_ADD_TO_CONFERENCE_ID = | 
|  | 802 | "android.telecom.extra.ADD_TO_CONFERENCE_ID"; | 
|  | 803 |  | 
|  | 804 | /** | 
| Tyler Gunn | c59fd0c | 2020-04-17 14:03:35 -0700 | [diff] [blame] | 805 | * Extra key set from a {@link ConnectionService} when using the remote connection APIs | 
|  | 806 | * (e.g. {@link RemoteConnectionService#createRemoteConnection(PhoneAccountHandle, | 
|  | 807 | * ConnectionRequest, boolean)}) to create a remote connection.  Provides the receiving | 
|  | 808 | * {@link ConnectionService} with a means to know the package name of the requesting | 
|  | 809 | * {@link ConnectionService} so that {@link #EXTRA_REMOTE_PHONE_ACCOUNT_HANDLE} can be set for | 
|  | 810 | * better visibility in Telecom of where a connection ultimately originated. | 
|  | 811 | * @hide | 
|  | 812 | */ | 
|  | 813 | public static final String EXTRA_REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME = | 
|  | 814 | "android.telecom.extra.REMOTE_CONNECTION_ORIGINATING_PACKAGE_NAME"; | 
|  | 815 |  | 
|  | 816 | /** | 
| Wileen Chiu | f2ec298 | 2018-07-01 14:21:50 -0700 | [diff] [blame] | 817 | * Boolean connection extra key set on the extras passed to | 
|  | 818 | * {@link Connection#sendConnectionEvent} which indicates that audio is present | 
|  | 819 | * on the RTT call when the extra value is true. | 
|  | 820 | */ | 
|  | 821 | public static final String EXTRA_IS_RTT_AUDIO_PRESENT = | 
|  | 822 | "android.telecom.extra.IS_RTT_AUDIO_PRESENT"; | 
|  | 823 |  | 
|  | 824 | /** | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 825 | * The audio codec in use for the current {@link Connection}, if known.  Examples of valid | 
|  | 826 | * values include {@link #AUDIO_CODEC_AMR_WB} and {@link #AUDIO_CODEC_EVS_WB}. | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 827 | */ | 
| Tyler Gunn | 1c68762 | 2019-12-20 11:08:13 -0800 | [diff] [blame] | 828 | public static final @AudioCodec String EXTRA_AUDIO_CODEC = | 
| allenwtsu | 2aca989 | 2019-11-25 14:38:21 +0800 | [diff] [blame] | 829 | "android.telecom.extra.AUDIO_CODEC"; | 
|  | 830 |  | 
|  | 831 | /** | 
| allenwtsu | 6ec972a | 2020-11-10 17:32:46 +0800 | [diff] [blame] | 832 | * Float connection extra key used to store the audio codec bitrate in kbps for the current | 
|  | 833 | * {@link Connection}. | 
|  | 834 | */ | 
|  | 835 | public static final String EXTRA_AUDIO_CODEC_BITRATE_KBPS = | 
|  | 836 | "android.telecom.extra.AUDIO_CODEC_BITRATE_KBPS"; | 
|  | 837 |  | 
|  | 838 | /** | 
|  | 839 | * Float connection extra key used to store the audio codec bandwidth in khz for the current | 
|  | 840 | * {@link Connection}. | 
|  | 841 | */ | 
|  | 842 | public static final String EXTRA_AUDIO_CODEC_BANDWIDTH_KHZ = | 
|  | 843 | "android.telecom.extra.AUDIO_CODEC_BANDWIDTH_KHZ"; | 
| Tyler Gunn | 78a59ff | 2021-05-07 16:41:19 -0700 | [diff] [blame] | 844 |  | 
|  | 845 | /** | 
| Sooraj Sasindran | 065b77d | 2022-02-24 00:14:51 -0800 | [diff] [blame] | 846 | * Last known cell identity key {@link CellIdentity} to be used to fill geo location header | 
|  | 847 | * in case of an emergency  call. This entry will not be filled if call is not identified as | 
|  | 848 | * an emergency call. Only provided to the {@link ConnectionService}  for the purpose of | 
|  | 849 | * placing an emergency call; will not be present in the  {@link InCallService} layer. | 
| Sooraj Sasindran | 81be082 | 2021-10-26 02:03:37 -0700 | [diff] [blame] | 850 | * The {@link ConnectionService}'s implementation will be logged for fine location access | 
|  | 851 | * when an outgoing call is placed in this case. | 
|  | 852 | */ | 
|  | 853 | public static final String EXTRA_LAST_KNOWN_CELL_IDENTITY = | 
|  | 854 | "android.telecom.extra.LAST_KNOWN_CELL_IDENTITY"; | 
|  | 855 |  | 
|  | 856 | /** | 
| Tyler Gunn | 78a59ff | 2021-05-07 16:41:19 -0700 | [diff] [blame] | 857 | * Boolean connection extra key used to indicate whether device to device communication is | 
|  | 858 | * available for the current call. | 
|  | 859 | * @hide | 
|  | 860 | */ | 
|  | 861 | public static final String EXTRA_IS_DEVICE_TO_DEVICE_COMMUNICATION_AVAILABLE = | 
|  | 862 | "android.telecom.extra.IS_DEVICE_TO_DEVICE_COMMUNICATION_AVAILABLE"; | 
|  | 863 |  | 
| allenwtsu | 6ec972a | 2020-11-10 17:32:46 +0800 | [diff] [blame] | 864 | /** | 
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 865 | * Connection event used to inform Telecom that it should play the on hold tone.  This is used | 
|  | 866 | * to play a tone when the peer puts the current call on hold.  Sent to Telecom via | 
| Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 867 | * {@link #sendConnectionEvent(String, Bundle)}. | 
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 868 | */ | 
|  | 869 | public static final String EVENT_ON_HOLD_TONE_START = | 
|  | 870 | "android.telecom.event.ON_HOLD_TONE_START"; | 
|  | 871 |  | 
|  | 872 | /** | 
|  | 873 | * Connection event used to inform Telecom that it should stop the on hold tone.  This is used | 
|  | 874 | * to stop a tone when the peer puts the current call on hold.  Sent to Telecom via | 
| Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 875 | * {@link #sendConnectionEvent(String, Bundle)}. | 
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 876 | */ | 
|  | 877 | public static final String EVENT_ON_HOLD_TONE_END = | 
|  | 878 | "android.telecom.event.ON_HOLD_TONE_END"; | 
|  | 879 |  | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 880 | /** | 
|  | 881 | * Connection event used to inform {@link InCallService}s when pulling of an external call has | 
|  | 882 | * failed.  The user interface should inform the user of the error. | 
|  | 883 | * <p> | 
|  | 884 | * Expected to be used by the {@link ConnectionService} when the {@link Call#pullExternalCall()} | 
|  | 885 | * API is called on a {@link Call} with the properties | 
|  | 886 | * {@link Call.Details#PROPERTY_IS_EXTERNAL_CALL} and | 
|  | 887 | * {@link Call.Details#CAPABILITY_CAN_PULL_CALL}, but the {@link ConnectionService} could not | 
|  | 888 | * pull the external call due to an error condition. | 
| Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 889 | * <p> | 
|  | 890 | * Sent via {@link #sendConnectionEvent(String, Bundle)}.  The {@link Bundle} parameter is | 
|  | 891 | * expected to be null when this connection event is used. | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 892 | */ | 
|  | 893 | public static final String EVENT_CALL_PULL_FAILED = "android.telecom.event.CALL_PULL_FAILED"; | 
|  | 894 |  | 
| Brad Ebinger | 2c1c1645 | 2016-05-27 15:58:10 -0700 | [diff] [blame] | 895 | /** | 
|  | 896 | * Connection event used to inform {@link InCallService}s when the merging of two calls has | 
|  | 897 | * failed. The User Interface should use this message to inform the user of the error. | 
| Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 898 | * <p> | 
|  | 899 | * Sent via {@link #sendConnectionEvent(String, Bundle)}.  The {@link Bundle} parameter is | 
|  | 900 | * expected to be null when this connection event is used. | 
| Brad Ebinger | 2c1c1645 | 2016-05-27 15:58:10 -0700 | [diff] [blame] | 901 | */ | 
|  | 902 | public static final String EVENT_CALL_MERGE_FAILED = "android.telecom.event.CALL_MERGE_FAILED"; | 
|  | 903 |  | 
| Tyler Gunn | b5ed860 | 2016-08-17 13:48:27 -0700 | [diff] [blame] | 904 | /** | 
| Hall Liu | 06ae75b | 2019-03-11 19:11:35 -0700 | [diff] [blame] | 905 | * Connection event used to inform Telecom when a hold operation on a call has failed. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 906 | * <p> | 
| Hall Liu | 06ae75b | 2019-03-11 19:11:35 -0700 | [diff] [blame] | 907 | * Sent via {@link #sendConnectionEvent(String, Bundle)}.  The {@link Bundle} parameter is | 
|  | 908 | * expected to be null when this connection event is used. | 
| Hall Liu | 06ae75b | 2019-03-11 19:11:35 -0700 | [diff] [blame] | 909 | */ | 
|  | 910 | public static final String EVENT_CALL_HOLD_FAILED = "android.telecom.event.CALL_HOLD_FAILED"; | 
|  | 911 |  | 
|  | 912 | /** | 
| Masaho Nishikawa | cb8fa74 | 2019-11-07 14:41:21 +0900 | [diff] [blame] | 913 | * Connection event used to inform Telecom when a switch operation on a call has failed. | 
|  | 914 | * <p> | 
|  | 915 | * Sent via {@link #sendConnectionEvent(String, Bundle)}.  The {@link Bundle} parameter is | 
|  | 916 | * expected to be null when this connection event is used. | 
|  | 917 | */ | 
|  | 918 | public static final String EVENT_CALL_SWITCH_FAILED = | 
|  | 919 | "android.telecom.event.CALL_SWITCH_FAILED"; | 
|  | 920 |  | 
|  | 921 | /** | 
| Tyler Gunn | 78da781 | 2017-05-09 14:34:57 -0700 | [diff] [blame] | 922 | * Connection event used to inform {@link InCallService}s when the process of merging a | 
|  | 923 | * Connection into a conference has begun. | 
|  | 924 | * <p> | 
|  | 925 | * Sent via {@link #sendConnectionEvent(String, Bundle)}.  The {@link Bundle} parameter is | 
|  | 926 | * expected to be null when this connection event is used. | 
| Tyler Gunn | 78da781 | 2017-05-09 14:34:57 -0700 | [diff] [blame] | 927 | */ | 
|  | 928 | public static final String EVENT_MERGE_START = "android.telecom.event.MERGE_START"; | 
|  | 929 |  | 
|  | 930 | /** | 
|  | 931 | * Connection event used to inform {@link InCallService}s when the process of merging a | 
|  | 932 | * Connection into a conference has completed. | 
|  | 933 | * <p> | 
|  | 934 | * Sent via {@link #sendConnectionEvent(String, Bundle)}.  The {@link Bundle} parameter is | 
|  | 935 | * expected to be null when this connection event is used. | 
| Tyler Gunn | 78da781 | 2017-05-09 14:34:57 -0700 | [diff] [blame] | 936 | */ | 
|  | 937 | public static final String EVENT_MERGE_COMPLETE = "android.telecom.event.MERGE_COMPLETE"; | 
|  | 938 |  | 
|  | 939 | /** | 
| Tyler Gunn | b5ed860 | 2016-08-17 13:48:27 -0700 | [diff] [blame] | 940 | * Connection event used to inform {@link InCallService}s when a call has been put on hold by | 
|  | 941 | * the remote party. | 
|  | 942 | * <p> | 
|  | 943 | * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the | 
|  | 944 | * call is being held locally on the device.  When a capable {@link ConnectionService} receives | 
|  | 945 | * signalling to indicate that the remote party has put the call on hold, it can send this | 
|  | 946 | * connection event. | 
| Tyler Gunn | b5ed860 | 2016-08-17 13:48:27 -0700 | [diff] [blame] | 947 | */ | 
|  | 948 | public static final String EVENT_CALL_REMOTELY_HELD = | 
|  | 949 | "android.telecom.event.CALL_REMOTELY_HELD"; | 
|  | 950 |  | 
|  | 951 | /** | 
|  | 952 | * Connection event used to inform {@link InCallService}s when a call which was remotely held | 
|  | 953 | * (see {@link #EVENT_CALL_REMOTELY_HELD}) has been un-held by the remote party. | 
|  | 954 | * <p> | 
|  | 955 | * This is different than the {@link Connection#STATE_HOLDING} state which indicates that the | 
|  | 956 | * call is being held locally on the device.  When a capable {@link ConnectionService} receives | 
|  | 957 | * signalling to indicate that the remote party has taken the call off hold, it can send this | 
|  | 958 | * connection event. | 
| Tyler Gunn | b5ed860 | 2016-08-17 13:48:27 -0700 | [diff] [blame] | 959 | */ | 
|  | 960 | public static final String EVENT_CALL_REMOTELY_UNHELD = | 
|  | 961 | "android.telecom.event.CALL_REMOTELY_UNHELD"; | 
|  | 962 |  | 
| Tyler Gunn | 9f6f047 | 2017-04-17 18:25:22 -0700 | [diff] [blame] | 963 | /** | 
|  | 964 | * Connection event used to inform an {@link InCallService} which initiated a call handover via | 
|  | 965 | * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has | 
|  | 966 | * successfully completed. | 
|  | 967 | * @hide | 
| Tyler Gunn | 1a505fa | 2018-09-14 13:36:38 -0700 | [diff] [blame] | 968 | * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated | 
|  | 969 | * APIs instead. | 
| Tyler Gunn | 9f6f047 | 2017-04-17 18:25:22 -0700 | [diff] [blame] | 970 | */ | 
|  | 971 | public static final String EVENT_HANDOVER_COMPLETE = | 
|  | 972 | "android.telecom.event.HANDOVER_COMPLETE"; | 
|  | 973 |  | 
|  | 974 | /** | 
|  | 975 | * Connection event used to inform an {@link InCallService} which initiated a call handover via | 
|  | 976 | * {@link Call#EVENT_REQUEST_HANDOVER} that the handover from this {@link Connection} has failed | 
|  | 977 | * to complete. | 
|  | 978 | * @hide | 
| Tyler Gunn | 1a505fa | 2018-09-14 13:36:38 -0700 | [diff] [blame] | 979 | * @deprecated Use {@link Call#handoverTo(PhoneAccountHandle, int, Bundle)} and its associated | 
|  | 980 | * APIs instead. | 
| Tyler Gunn | 9f6f047 | 2017-04-17 18:25:22 -0700 | [diff] [blame] | 981 | */ | 
|  | 982 | public static final String EVENT_HANDOVER_FAILED = | 
|  | 983 | "android.telecom.event.HANDOVER_FAILED"; | 
|  | 984 |  | 
| shilu | b7ec9a0 | 2018-11-09 15:52:04 -0800 | [diff] [blame] | 985 | /** | 
| Shi Lu | 528eb5b | 2019-02-08 05:09:11 +0000 | [diff] [blame] | 986 | * String Connection extra key used to store SIP invite fields for an incoming call for IMS call | 
| shilu | b7ec9a0 | 2018-11-09 15:52:04 -0800 | [diff] [blame] | 987 | */ | 
|  | 988 | public static final String EXTRA_SIP_INVITE = "android.telecom.extra.SIP_INVITE"; | 
|  | 989 |  | 
| Wileen Chiu | f2ec298 | 2018-07-01 14:21:50 -0700 | [diff] [blame] | 990 | /** | 
|  | 991 | * Connection event used to inform an {@link InCallService} that the RTT audio indication | 
|  | 992 | * has changed. | 
|  | 993 | */ | 
|  | 994 | public static final String EVENT_RTT_AUDIO_INDICATION_CHANGED = | 
|  | 995 | "android.telecom.event.RTT_AUDIO_INDICATION_CHANGED"; | 
|  | 996 |  | 
| Tyler Gunn | d582184 | 2021-02-05 11:12:57 -0800 | [diff] [blame] | 997 | /** | 
|  | 998 | * Connection event used to signal between the telephony {@link ConnectionService} and Telecom | 
|  | 999 | * when device to device messages are sent/received. | 
|  | 1000 | * <p> | 
|  | 1001 | * Device to device messages originating from the network are sent by telephony using | 
|  | 1002 | * {@link Connection#sendConnectionEvent(String, Bundle)} and are routed up to any active | 
|  | 1003 | * {@link CallDiagnosticService} implementation which is active. | 
|  | 1004 | * <p> | 
|  | 1005 | * Likewise, if a {@link CallDiagnosticService} sends a message using | 
| Tyler Gunn | 066de60 | 2021-03-16 09:58:07 -0700 | [diff] [blame] | 1006 | * {@link CallDiagnostics#sendDeviceToDeviceMessage(int, int)}, it will be routed to telephony | 
| Tyler Gunn | d582184 | 2021-02-05 11:12:57 -0800 | [diff] [blame] | 1007 | * via {@link Connection#onCallEvent(String, Bundle)}.  The telephony stack will relay the | 
|  | 1008 | * message to the other device. | 
|  | 1009 | * @hide | 
|  | 1010 | */ | 
|  | 1011 | @SystemApi | 
|  | 1012 | public static final String EVENT_DEVICE_TO_DEVICE_MESSAGE = | 
|  | 1013 | "android.telecom.event.DEVICE_TO_DEVICE_MESSAGE"; | 
|  | 1014 |  | 
|  | 1015 | /** | 
|  | 1016 | * Sent along with {@link #EVENT_DEVICE_TO_DEVICE_MESSAGE} to indicate the device to device | 
|  | 1017 | * message type. | 
|  | 1018 | * | 
| Tyler Gunn | 066de60 | 2021-03-16 09:58:07 -0700 | [diff] [blame] | 1019 | * See {@link CallDiagnostics} for more information. | 
| Tyler Gunn | d582184 | 2021-02-05 11:12:57 -0800 | [diff] [blame] | 1020 | * @hide | 
|  | 1021 | */ | 
|  | 1022 | @SystemApi | 
|  | 1023 | public static final String EXTRA_DEVICE_TO_DEVICE_MESSAGE_TYPE = | 
|  | 1024 | "android.telecom.extra.DEVICE_TO_DEVICE_MESSAGE_TYPE"; | 
|  | 1025 |  | 
|  | 1026 | /** | 
|  | 1027 | * Sent along with {@link #EVENT_DEVICE_TO_DEVICE_MESSAGE} to indicate the device to device | 
|  | 1028 | * message value. | 
|  | 1029 | * <p> | 
| Tyler Gunn | 066de60 | 2021-03-16 09:58:07 -0700 | [diff] [blame] | 1030 | * See {@link CallDiagnostics} for more information. | 
| Tyler Gunn | d582184 | 2021-02-05 11:12:57 -0800 | [diff] [blame] | 1031 | * @hide | 
|  | 1032 | */ | 
|  | 1033 | @SystemApi | 
|  | 1034 | public static final String EXTRA_DEVICE_TO_DEVICE_MESSAGE_VALUE = | 
|  | 1035 | "android.telecom.extra.DEVICE_TO_DEVICE_MESSAGE_VALUE"; | 
|  | 1036 |  | 
| Tyler Gunn | 0a1c6d1 | 2021-03-12 15:44:08 -0800 | [diff] [blame] | 1037 | /** | 
|  | 1038 | * Connection event used to communicate a {@link android.telephony.CallQuality} report from | 
|  | 1039 | * telephony to Telecom for relaying to | 
|  | 1040 | * {@link DiagnosticCall#onCallQualityReceived(CallQuality)}. | 
|  | 1041 | * @hide | 
|  | 1042 | */ | 
|  | 1043 | public static final String EVENT_CALL_QUALITY_REPORT = | 
|  | 1044 | "android.telecom.event.CALL_QUALITY_REPORT"; | 
|  | 1045 |  | 
|  | 1046 | /** | 
|  | 1047 | * Extra sent with {@link #EVENT_CALL_QUALITY_REPORT} containing the | 
|  | 1048 | * {@link android.telephony.CallQuality} data. | 
|  | 1049 | * @hide | 
|  | 1050 | */ | 
|  | 1051 | public static final String EXTRA_CALL_QUALITY_REPORT = | 
|  | 1052 | "android.telecom.extra.CALL_QUALITY_REPORT"; | 
|  | 1053 |  | 
| yongnamcha | 8ec5624 | 2022-11-28 06:23:02 +0000 | [diff] [blame] | 1054 | /** | 
|  | 1055 | * Key to obtain location as a result of ({@code queryLocationForEmergency} from Bundle | 
|  | 1056 | * @hide | 
|  | 1057 | */ | 
|  | 1058 | public static final String EXTRA_KEY_QUERY_LOCATION = | 
|  | 1059 | "android.telecom.extra.KEY_QUERY_LOCATION"; | 
|  | 1060 |  | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1061 | // Flag controlling whether PII is emitted into the logs | 
|  | 1062 | private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG); | 
|  | 1063 |  | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1064 | /** | 
| Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 1065 | * Renders a set of capability bits ({@code CAPABILITY_*}) as a human readable string. | 
|  | 1066 | * | 
|  | 1067 | * @param capabilities A capability bit field. | 
|  | 1068 | * @return A human readable string representation. | 
|  | 1069 | */ | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1070 | public static String capabilitiesToString(int capabilities) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1071 | return capabilitiesToStringInternal(capabilities, true /* isLong */); | 
|  | 1072 | } | 
|  | 1073 |  | 
|  | 1074 | /** | 
|  | 1075 | * Renders a set of capability bits ({@code CAPABILITY_*}) as a *short* human readable | 
|  | 1076 | * string. | 
|  | 1077 | * | 
|  | 1078 | * @param capabilities A capability bit field. | 
|  | 1079 | * @return A human readable string representation. | 
|  | 1080 | * @hide | 
|  | 1081 | */ | 
|  | 1082 | public static String capabilitiesToStringShort(int capabilities) { | 
|  | 1083 | return capabilitiesToStringInternal(capabilities, false /* isLong */); | 
|  | 1084 | } | 
|  | 1085 |  | 
|  | 1086 | private static String capabilitiesToStringInternal(int capabilities, boolean isLong) { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1087 | StringBuilder builder = new StringBuilder(); | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1088 | builder.append("["); | 
|  | 1089 | if (isLong) { | 
|  | 1090 | builder.append("Capabilities:"); | 
|  | 1091 | } | 
|  | 1092 |  | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1093 | if ((capabilities & CAPABILITY_HOLD) == CAPABILITY_HOLD) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1094 | builder.append(isLong ? " CAPABILITY_HOLD" : " hld"); | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1095 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1096 | if ((capabilities & CAPABILITY_SUPPORT_HOLD) == CAPABILITY_SUPPORT_HOLD) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1097 | builder.append(isLong ? " CAPABILITY_SUPPORT_HOLD" : " sup_hld"); | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1098 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1099 | if ((capabilities & CAPABILITY_MERGE_CONFERENCE) == CAPABILITY_MERGE_CONFERENCE) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1100 | builder.append(isLong ? " CAPABILITY_MERGE_CONFERENCE" : " mrg_cnf"); | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1101 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1102 | if ((capabilities & CAPABILITY_SWAP_CONFERENCE) == CAPABILITY_SWAP_CONFERENCE) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1103 | builder.append(isLong ? " CAPABILITY_SWAP_CONFERENCE" : " swp_cnf"); | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1104 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1105 | if ((capabilities & CAPABILITY_RESPOND_VIA_TEXT) == CAPABILITY_RESPOND_VIA_TEXT) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1106 | builder.append(isLong ? " CAPABILITY_RESPOND_VIA_TEXT" : " txt"); | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1107 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1108 | if ((capabilities & CAPABILITY_MUTE) == CAPABILITY_MUTE) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1109 | builder.append(isLong ? " CAPABILITY_MUTE" : " mut"); | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1110 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1111 | if ((capabilities & CAPABILITY_MANAGE_CONFERENCE) == CAPABILITY_MANAGE_CONFERENCE) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1112 | builder.append(isLong ? " CAPABILITY_MANAGE_CONFERENCE" : " mng_cnf"); | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1113 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1114 | if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_RX) == CAPABILITY_SUPPORTS_VT_LOCAL_RX) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1115 | builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_RX" : " VTlrx"); | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 1116 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1117 | if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_TX) == CAPABILITY_SUPPORTS_VT_LOCAL_TX) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1118 | builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_TX" : " VTltx"); | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 1119 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1120 | if ((capabilities & CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL) | 
|  | 1121 | == CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1122 | builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_LOCAL_BIDIRECTIONAL" : " VTlbi"); | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1123 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1124 | if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_RX) == CAPABILITY_SUPPORTS_VT_REMOTE_RX) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1125 | builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_RX" : " VTrrx"); | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 1126 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1127 | if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_TX) == CAPABILITY_SUPPORTS_VT_REMOTE_TX) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1128 | builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_TX" : " VTrtx"); | 
| Andrew Lee | 5e9e8bb | 2015-03-10 13:58:24 -0700 | [diff] [blame] | 1129 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1130 | if ((capabilities & CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL) | 
|  | 1131 | == CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1132 | builder.append(isLong ? " CAPABILITY_SUPPORTS_VT_REMOTE_BIDIRECTIONAL" : " VTrbi"); | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1133 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1134 | if ((capabilities & CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO) | 
|  | 1135 | == CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1136 | builder.append(isLong ? " CAPABILITY_CANNOT_DOWNGRADE_VIDEO_TO_AUDIO" : " !v2a"); | 
| Tyler Gunn | f97a009 | 2016-01-19 15:59:34 -0800 | [diff] [blame] | 1137 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1138 | if ((capabilities & CAPABILITY_SPEED_UP_MT_AUDIO) == CAPABILITY_SPEED_UP_MT_AUDIO) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1139 | builder.append(isLong ? " CAPABILITY_SPEED_UP_MT_AUDIO" : " spd_aud"); | 
| Dong Zhou | 89f41eb | 2015-03-15 11:59:49 -0500 | [diff] [blame] | 1140 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1141 | if ((capabilities & CAPABILITY_CAN_UPGRADE_TO_VIDEO) == CAPABILITY_CAN_UPGRADE_TO_VIDEO) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1142 | builder.append(isLong ? " CAPABILITY_CAN_UPGRADE_TO_VIDEO" : " a2v"); | 
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1143 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1144 | if ((capabilities & CAPABILITY_CAN_PAUSE_VIDEO) == CAPABILITY_CAN_PAUSE_VIDEO) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1145 | builder.append(isLong ? " CAPABILITY_CAN_PAUSE_VIDEO" : " paus_VT"); | 
| Tyler Gunn | b5e0cfb | 2015-04-07 16:10:51 -0700 | [diff] [blame] | 1146 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1147 | if ((capabilities & CAPABILITY_CONFERENCE_HAS_NO_CHILDREN) | 
|  | 1148 | == CAPABILITY_CONFERENCE_HAS_NO_CHILDREN) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1149 | builder.append(isLong ? " CAPABILITY_SINGLE_PARTY_CONFERENCE" : " 1p_cnf"); | 
| Tyler Gunn | d409173 | 2015-06-29 09:15:37 -0700 | [diff] [blame] | 1150 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1151 | if ((capabilities & CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION) | 
|  | 1152 | == CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1153 | builder.append(isLong ? " CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION" : " rsp_by_con"); | 
| Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 1154 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1155 | if ((capabilities & CAPABILITY_CAN_PULL_CALL) == CAPABILITY_CAN_PULL_CALL) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1156 | builder.append(isLong ? " CAPABILITY_CAN_PULL_CALL" : " pull"); | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1157 | } | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1158 | if ((capabilities & CAPABILITY_SUPPORT_DEFLECT) == CAPABILITY_SUPPORT_DEFLECT) { | 
| Pooja Jain | d34698d | 2017-12-28 14:15:31 +0530 | [diff] [blame] | 1159 | builder.append(isLong ? " CAPABILITY_SUPPORT_DEFLECT" : " sup_def"); | 
|  | 1160 | } | 
| Ravi Paluri | 404babb | 2020-01-23 19:02:44 +0530 | [diff] [blame] | 1161 | if ((capabilities & CAPABILITY_ADD_PARTICIPANT) == CAPABILITY_ADD_PARTICIPANT) { | 
|  | 1162 | builder.append(isLong ? " CAPABILITY_ADD_PARTICIPANT" : " add_participant"); | 
|  | 1163 | } | 
| Ravi Paluri | f4b38e7 | 2020-02-05 12:35:41 +0530 | [diff] [blame] | 1164 | if ((capabilities & CAPABILITY_TRANSFER) == CAPABILITY_TRANSFER) { | 
|  | 1165 | builder.append(isLong ? " CAPABILITY_TRANSFER" : " sup_trans"); | 
|  | 1166 | } | 
|  | 1167 | if ((capabilities & CAPABILITY_TRANSFER_CONSULTATIVE) | 
|  | 1168 | == CAPABILITY_TRANSFER_CONSULTATIVE) { | 
|  | 1169 | builder.append(isLong ? " CAPABILITY_TRANSFER_CONSULTATIVE" : " sup_cTrans"); | 
|  | 1170 | } | 
| Alvin Dey | 2f37d77 | 2018-05-18 23:16:10 +0530 | [diff] [blame] | 1171 | if ((capabilities & CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT) | 
|  | 1172 | == CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT) { | 
|  | 1173 | builder.append(isLong ? " CAPABILITY_REMOTE_PARTY_SUPPORTS_RTT" : " sup_rtt"); | 
|  | 1174 | } | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1175 | builder.append("]"); | 
|  | 1176 | return builder.toString(); | 
|  | 1177 | } | 
|  | 1178 |  | 
| Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 1179 | /** | 
|  | 1180 | * Renders a set of property bits ({@code PROPERTY_*}) as a human readable string. | 
|  | 1181 | * | 
|  | 1182 | * @param properties A property bit field. | 
|  | 1183 | * @return A human readable string representation. | 
|  | 1184 | */ | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1185 | public static String propertiesToString(int properties) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1186 | return propertiesToStringInternal(properties, true /* isLong */); | 
|  | 1187 | } | 
|  | 1188 |  | 
|  | 1189 | /** | 
|  | 1190 | * Renders a set of property bits ({@code PROPERTY_*}) as a *short* human readable string. | 
|  | 1191 | * | 
|  | 1192 | * @param properties A property bit field. | 
|  | 1193 | * @return A human readable string representation. | 
|  | 1194 | * @hide | 
|  | 1195 | */ | 
|  | 1196 | public static String propertiesToStringShort(int properties) { | 
|  | 1197 | return propertiesToStringInternal(properties, false /* isLong */); | 
|  | 1198 | } | 
|  | 1199 |  | 
|  | 1200 | private static String propertiesToStringInternal(int properties, boolean isLong) { | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1201 | StringBuilder builder = new StringBuilder(); | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1202 | builder.append("["); | 
|  | 1203 | if (isLong) { | 
|  | 1204 | builder.append("Properties:"); | 
|  | 1205 | } | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1206 |  | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1207 | if ((properties & PROPERTY_SELF_MANAGED) == PROPERTY_SELF_MANAGED) { | 
| Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 1208 | builder.append(isLong ? " PROPERTY_SELF_MANAGED" : " self_mng"); | 
|  | 1209 | } | 
|  | 1210 |  | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1211 | if ((properties & PROPERTY_EMERGENCY_CALLBACK_MODE) == PROPERTY_EMERGENCY_CALLBACK_MODE) { | 
| Hall Liu | 25c7c4d | 2016-08-30 13:41:02 -0700 | [diff] [blame] | 1212 | builder.append(isLong ? " PROPERTY_EMERGENCY_CALLBACK_MODE" : " ecbm"); | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1213 | } | 
|  | 1214 |  | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1215 | if ((properties & PROPERTY_HIGH_DEF_AUDIO) == PROPERTY_HIGH_DEF_AUDIO) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1216 | builder.append(isLong ? " PROPERTY_HIGH_DEF_AUDIO" : " HD"); | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1217 | } | 
|  | 1218 |  | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1219 | if ((properties & PROPERTY_WIFI) == PROPERTY_WIFI) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1220 | builder.append(isLong ? " PROPERTY_WIFI" : " wifi"); | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1221 | } | 
|  | 1222 |  | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1223 | if ((properties & PROPERTY_GENERIC_CONFERENCE) == PROPERTY_GENERIC_CONFERENCE) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1224 | builder.append(isLong ? " PROPERTY_GENERIC_CONFERENCE" : " gen_conf"); | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1225 | } | 
|  | 1226 |  | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1227 | if ((properties & PROPERTY_IS_EXTERNAL_CALL) == PROPERTY_IS_EXTERNAL_CALL) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1228 | builder.append(isLong ? " PROPERTY_IS_EXTERNAL_CALL" : " xtrnl"); | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1229 | } | 
|  | 1230 |  | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1231 | if ((properties & PROPERTY_HAS_CDMA_VOICE_PRIVACY) == PROPERTY_HAS_CDMA_VOICE_PRIVACY) { | 
| Santos Cordon | 1a74930 | 2016-07-26 16:08:53 -0700 | [diff] [blame] | 1232 | builder.append(isLong ? " PROPERTY_HAS_CDMA_VOICE_PRIVACY" : " priv"); | 
| Brad Ebinger | 1584707 | 2016-05-18 11:08:36 -0700 | [diff] [blame] | 1233 | } | 
|  | 1234 |  | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1235 | if ((properties & PROPERTY_IS_RTT) == PROPERTY_IS_RTT) { | 
| Hall Liu | d4d2a8a | 2018-01-29 17:22:02 -0800 | [diff] [blame] | 1236 | builder.append(isLong ? " PROPERTY_IS_RTT" : " rtt"); | 
|  | 1237 | } | 
|  | 1238 |  | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1239 | if ((properties & PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL) | 
|  | 1240 | == PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL) { | 
| Tyler Gunn | 5bd9085 | 2018-09-21 09:37:07 -0700 | [diff] [blame] | 1241 | builder.append(isLong ? " PROPERTY_NETWORK_IDENTIFIED_EMERGENCY_CALL" : " ecall"); | 
|  | 1242 | } | 
|  | 1243 |  | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 1244 | if ((properties & PROPERTY_REMOTELY_HOSTED) == PROPERTY_REMOTELY_HOSTED) { | 
| Tyler Gunn | ac60f95 | 2019-05-31 07:23:16 -0700 | [diff] [blame] | 1245 | builder.append(isLong ? " PROPERTY_REMOTELY_HOSTED" : " remote_hst"); | 
|  | 1246 | } | 
|  | 1247 |  | 
| Ravi Paluri | 80aa214 | 2019-12-02 11:57:37 +0530 | [diff] [blame] | 1248 | if ((properties & PROPERTY_IS_ADHOC_CONFERENCE) == PROPERTY_IS_ADHOC_CONFERENCE) { | 
|  | 1249 | builder.append(isLong ? " PROPERTY_IS_ADHOC_CONFERENCE" : " adhoc_conf"); | 
|  | 1250 | } | 
|  | 1251 |  | 
| Hall Liu | e0f787c | 2020-07-08 11:25:56 -0700 | [diff] [blame] | 1252 | if ((properties & PROPERTY_IS_DOWNGRADED_CONFERENCE) == PROPERTY_IS_DOWNGRADED_CONFERENCE) { | 
|  | 1253 | builder.append(isLong ? " PROPERTY_IS_DOWNGRADED_CONFERENCE" : " dngrd_conf"); | 
|  | 1254 | } | 
|  | 1255 |  | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1256 | builder.append("]"); | 
|  | 1257 | return builder.toString(); | 
|  | 1258 | } | 
|  | 1259 |  | 
| Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 1260 | /** @hide */ | 
| Tyler Gunn | 633e4c3 | 2019-10-24 15:40:48 -0700 | [diff] [blame] | 1261 | abstract static class Listener { | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1262 | public void onStateChanged(Connection c, int state) {} | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1263 | public void onAddressChanged(Connection c, Uri newAddress, int presentation) {} | 
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1264 | public void onCallerDisplayNameChanged( | 
|  | 1265 | Connection c, String callerDisplayName, int presentation) {} | 
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 1266 | public void onVideoStateChanged(Connection c, int videoState) {} | 
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 1267 | public void onDisconnected(Connection c, DisconnectCause disconnectCause) {} | 
| Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 1268 | public void onPostDialWait(Connection c, String remaining) {} | 
| Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 1269 | public void onPostDialChar(Connection c, char nextChar) {} | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 1270 | public void onRingbackRequested(Connection c, boolean ringback) {} | 
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 1271 | public void onDestroyed(Connection c) {} | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1272 | public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {} | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 1273 | public void onConnectionPropertiesChanged(Connection c, int properties) {} | 
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 1274 | public void onSupportedAudioRoutesChanged(Connection c, int supportedAudioRoutes) {} | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1275 | public void onVideoProviderChanged( | 
|  | 1276 | Connection c, VideoProvider videoProvider) {} | 
| Sailesh Nepal | 001bbbb | 2014-07-15 14:40:39 -0700 | [diff] [blame] | 1277 | public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {} | 
|  | 1278 | public void onStatusHintsChanged(Connection c, StatusHints statusHints) {} | 
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 1279 | public void onConferenceablesChanged( | 
| Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 1280 | Connection c, List<Conferenceable> conferenceables) {} | 
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1281 | public void onConferenceChanged(Connection c, Conference conference) {} | 
| Anthony Lee | 17455a3 | 2015-04-24 15:25:29 -0700 | [diff] [blame] | 1282 | public void onConferenceMergeFailed(Connection c) {} | 
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 1283 | public void onExtrasChanged(Connection c, Bundle extras) {} | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1284 | public void onExtrasRemoved(Connection c, List<String> keys) {} | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 1285 | public void onConnectionEvent(Connection c, String event, Bundle extras) {} | 
| Hall Liu | a98f58b5 | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 1286 | public void onAudioRouteChanged(Connection c, int audioRoute, String bluetoothAddress) {} | 
| Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 1287 | public void onRttInitiationSuccess(Connection c) {} | 
|  | 1288 | public void onRttInitiationFailure(Connection c, int reason) {} | 
|  | 1289 | public void onRttSessionRemotelyTerminated(Connection c) {} | 
|  | 1290 | public void onRemoteRttRequest(Connection c) {} | 
| Srikanth Chintala | fcb1501 | 2017-05-04 20:58:34 +0530 | [diff] [blame] | 1291 | /** @hide */ | 
|  | 1292 | public void onPhoneAccountChanged(Connection c, PhoneAccountHandle pHandle) {} | 
| Mengjun Leng | 2570774 | 2017-07-04 11:10:37 +0800 | [diff] [blame] | 1293 | public void onConnectionTimeReset(Connection c) {} | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 1294 | public void onEndpointChanged(Connection c, CallEndpoint endpoint, Executor executor, | 
|  | 1295 | OutcomeReceiver<Void, CallEndpointException> callback) {} | 
| yongnamcha | 8ec5624 | 2022-11-28 06:23:02 +0000 | [diff] [blame] | 1296 | public void onQueryLocation(Connection c, long timeoutMillis, @NonNull String provider, | 
|  | 1297 | @NonNull @CallbackExecutor Executor executor, | 
|  | 1298 | @NonNull OutcomeReceiver<Location, QueryLocationException> callback) {} | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 1299 | } | 
|  | 1300 |  | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1301 | /** | 
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1302 | * Provides methods to read and write RTT data to/from the in-call app. | 
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1303 | */ | 
|  | 1304 | public static final class RttTextStream { | 
|  | 1305 | private static final int READ_BUFFER_SIZE = 1000; | 
|  | 1306 | private final InputStreamReader mPipeFromInCall; | 
|  | 1307 | private final OutputStreamWriter mPipeToInCall; | 
| Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 1308 | private final ParcelFileDescriptor mFdFromInCall; | 
|  | 1309 | private final ParcelFileDescriptor mFdToInCall; | 
| Hall Liu | 17eb1bd | 2018-07-03 15:17:41 -0700 | [diff] [blame] | 1310 |  | 
|  | 1311 | private final FileInputStream mFromInCallFileInputStream; | 
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1312 | private char[] mReadBuffer = new char[READ_BUFFER_SIZE]; | 
|  | 1313 |  | 
|  | 1314 | /** | 
|  | 1315 | * @hide | 
|  | 1316 | */ | 
|  | 1317 | public RttTextStream(ParcelFileDescriptor toInCall, ParcelFileDescriptor fromInCall) { | 
| Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 1318 | mFdFromInCall = fromInCall; | 
|  | 1319 | mFdToInCall = toInCall; | 
| Hall Liu | 17eb1bd | 2018-07-03 15:17:41 -0700 | [diff] [blame] | 1320 | mFromInCallFileInputStream = new FileInputStream(fromInCall.getFileDescriptor()); | 
| Hall Liu | 730a259 | 2018-06-25 19:48:33 -0700 | [diff] [blame] | 1321 |  | 
|  | 1322 | // Wrap the FileInputStream in a Channel so that it's interruptible. | 
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1323 | mPipeFromInCall = new InputStreamReader( | 
| Hall Liu | 17eb1bd | 2018-07-03 15:17:41 -0700 | [diff] [blame] | 1324 | Channels.newInputStream(Channels.newChannel(mFromInCallFileInputStream))); | 
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1325 | mPipeToInCall = new OutputStreamWriter( | 
| Hall Liu | a549fed | 2018-02-09 16:40:03 -0800 | [diff] [blame] | 1326 | new FileOutputStream(toInCall.getFileDescriptor())); | 
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1327 | } | 
|  | 1328 |  | 
|  | 1329 | /** | 
|  | 1330 | * Writes the string {@param input} into the text stream to the UI for this RTT call. Since | 
|  | 1331 | * RTT transmits text in real-time, this method should be called as often as text snippets | 
|  | 1332 | * are received from the remote user, even if it is only one character. | 
| Hall Liu | a549fed | 2018-02-09 16:40:03 -0800 | [diff] [blame] | 1333 | * <p> | 
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1334 | * This method is not thread-safe -- calling it from multiple threads simultaneously may | 
|  | 1335 | * lead to interleaved text. | 
| Hall Liu | a549fed | 2018-02-09 16:40:03 -0800 | [diff] [blame] | 1336 | * | 
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1337 | * @param input The message to send to the in-call app. | 
|  | 1338 | */ | 
|  | 1339 | public void write(String input) throws IOException { | 
|  | 1340 | mPipeToInCall.write(input); | 
|  | 1341 | mPipeToInCall.flush(); | 
|  | 1342 | } | 
|  | 1343 |  | 
|  | 1344 |  | 
|  | 1345 | /** | 
|  | 1346 | * Reads a string from the in-call app, blocking if there is no data available. Returns | 
|  | 1347 | * {@code null} if the RTT conversation has been terminated and there is no further data | 
|  | 1348 | * to read. | 
| Hall Liu | a549fed | 2018-02-09 16:40:03 -0800 | [diff] [blame] | 1349 | * <p> | 
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1350 | * This method is not thread-safe -- calling it from multiple threads simultaneously may | 
|  | 1351 | * lead to interleaved text. | 
| Hall Liu | a549fed | 2018-02-09 16:40:03 -0800 | [diff] [blame] | 1352 | * | 
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1353 | * @return A string containing text entered by the user, or {@code null} if the | 
|  | 1354 | * conversation has been terminated or if there was an error while reading. | 
|  | 1355 | */ | 
| Hall Liu | ffa4a81 | 2017-03-02 16:11:00 -0800 | [diff] [blame] | 1356 | public String read() throws IOException { | 
|  | 1357 | int numRead = mPipeFromInCall.read(mReadBuffer, 0, READ_BUFFER_SIZE); | 
|  | 1358 | if (numRead < 0) { | 
|  | 1359 | return null; | 
|  | 1360 | } | 
|  | 1361 | return new String(mReadBuffer, 0, numRead); | 
|  | 1362 | } | 
|  | 1363 |  | 
|  | 1364 | /** | 
|  | 1365 | * Non-blocking version of {@link #read()}. Returns {@code null} if there is nothing to | 
|  | 1366 | * be read. | 
| Hall Liu | a549fed | 2018-02-09 16:40:03 -0800 | [diff] [blame] | 1367 | * | 
| Hall Liu | ffa4a81 | 2017-03-02 16:11:00 -0800 | [diff] [blame] | 1368 | * @return A string containing text entered by the user, or {@code null} if the user has | 
|  | 1369 | * not entered any new text yet. | 
|  | 1370 | */ | 
|  | 1371 | public String readImmediately() throws IOException { | 
| Hall Liu | 17eb1bd | 2018-07-03 15:17:41 -0700 | [diff] [blame] | 1372 | if (mFromInCallFileInputStream.available() > 0) { | 
| Hall Liu | ffa4a81 | 2017-03-02 16:11:00 -0800 | [diff] [blame] | 1373 | return read(); | 
|  | 1374 | } else { | 
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1375 | return null; | 
|  | 1376 | } | 
|  | 1377 | } | 
| Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 1378 |  | 
|  | 1379 | /** @hide */ | 
|  | 1380 | public ParcelFileDescriptor getFdFromInCall() { | 
|  | 1381 | return mFdFromInCall; | 
|  | 1382 | } | 
|  | 1383 |  | 
|  | 1384 | /** @hide */ | 
|  | 1385 | public ParcelFileDescriptor getFdToInCall() { | 
|  | 1386 | return mFdToInCall; | 
|  | 1387 | } | 
|  | 1388 | } | 
|  | 1389 |  | 
|  | 1390 | /** | 
|  | 1391 | * Provides constants to represent the results of responses to session modify requests sent via | 
|  | 1392 | * {@link Call#sendRttRequest()} | 
|  | 1393 | */ | 
|  | 1394 | public static final class RttModifyStatus { | 
| Hall Liu | 8dd4908 | 2017-04-21 14:33:12 -0700 | [diff] [blame] | 1395 | private RttModifyStatus() {} | 
| Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 1396 | /** | 
|  | 1397 | * Session modify request was successful. | 
|  | 1398 | */ | 
|  | 1399 | public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1; | 
|  | 1400 |  | 
|  | 1401 | /** | 
|  | 1402 | * Session modify request failed. | 
|  | 1403 | */ | 
|  | 1404 | public static final int SESSION_MODIFY_REQUEST_FAIL = 2; | 
|  | 1405 |  | 
|  | 1406 | /** | 
|  | 1407 | * Session modify request ignored due to invalid parameters. | 
|  | 1408 | */ | 
|  | 1409 | public static final int SESSION_MODIFY_REQUEST_INVALID = 3; | 
|  | 1410 |  | 
|  | 1411 | /** | 
|  | 1412 | * Session modify request timed out. | 
|  | 1413 | */ | 
|  | 1414 | public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4; | 
|  | 1415 |  | 
|  | 1416 | /** | 
|  | 1417 | * Session modify request rejected by remote user. | 
|  | 1418 | */ | 
|  | 1419 | public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5; | 
| Tyler Gunn | b9a0496 | 2022-02-17 08:23:54 -0800 | [diff] [blame] | 1420 |  | 
|  | 1421 |  | 
|  | 1422 | /**@hide*/ | 
|  | 1423 | @Retention(RetentionPolicy.SOURCE) | 
|  | 1424 | @IntDef(prefix = "SESSION_MODIFY_REQUEST_", value = { | 
|  | 1425 | SESSION_MODIFY_REQUEST_SUCCESS, | 
|  | 1426 | SESSION_MODIFY_REQUEST_FAIL, | 
|  | 1427 | SESSION_MODIFY_REQUEST_INVALID, | 
|  | 1428 | SESSION_MODIFY_REQUEST_TIMED_OUT, | 
|  | 1429 | SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE | 
|  | 1430 | }) | 
|  | 1431 | public @interface RttSessionModifyStatus {} | 
| Hall Liu | 95d5587 | 2017-01-25 17:12:49 -0800 | [diff] [blame] | 1432 | } | 
|  | 1433 |  | 
|  | 1434 | /** | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1435 | * Provides a means of controlling the video session associated with a {@link Connection}. | 
|  | 1436 | * <p> | 
|  | 1437 | * Implementations create a custom subclass of {@link VideoProvider} and the | 
|  | 1438 | * {@link ConnectionService} creates an instance sets it on the {@link Connection} using | 
|  | 1439 | * {@link Connection#setVideoProvider(VideoProvider)}.  Any connection which supports video | 
|  | 1440 | * should set the {@link VideoProvider}. | 
|  | 1441 | * <p> | 
|  | 1442 | * The {@link VideoProvider} serves two primary purposes: it provides a means for Telecom and | 
|  | 1443 | * {@link InCallService} implementations to issue requests related to the video session; | 
|  | 1444 | * it provides a means for the {@link ConnectionService} to report events and information | 
|  | 1445 | * related to the video session to Telecom and the {@link InCallService} implementations. | 
|  | 1446 | * <p> | 
|  | 1447 | * {@link InCallService} implementations interact with the {@link VideoProvider} via | 
|  | 1448 | * {@link android.telecom.InCallService.VideoCall}. | 
|  | 1449 | */ | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1450 | public static abstract class VideoProvider { | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1451 | /** | 
|  | 1452 | * Video is not being received (no protocol pause was issued). | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1453 | * @see #handleCallSessionEvent(int) | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1454 | */ | 
|  | 1455 | public static final int SESSION_EVENT_RX_PAUSE = 1; | 
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 1456 |  | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1457 | /** | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1458 | * Video reception has resumed after a {@link #SESSION_EVENT_RX_PAUSE}. | 
|  | 1459 | * @see #handleCallSessionEvent(int) | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1460 | */ | 
|  | 1461 | public static final int SESSION_EVENT_RX_RESUME = 2; | 
|  | 1462 |  | 
|  | 1463 | /** | 
|  | 1464 | * Video transmission has begun. This occurs after a negotiated start of video transmission | 
|  | 1465 | * when the underlying protocol has actually begun transmitting video to the remote party. | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1466 | * @see #handleCallSessionEvent(int) | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1467 | */ | 
|  | 1468 | public static final int SESSION_EVENT_TX_START = 3; | 
|  | 1469 |  | 
|  | 1470 | /** | 
|  | 1471 | * Video transmission has stopped. This occurs after a negotiated stop of video transmission | 
|  | 1472 | * when the underlying protocol has actually stopped transmitting video to the remote party. | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1473 | * @see #handleCallSessionEvent(int) | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1474 | */ | 
|  | 1475 | public static final int SESSION_EVENT_TX_STOP = 4; | 
|  | 1476 |  | 
|  | 1477 | /** | 
| Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 1478 | * A camera failure has occurred for the selected camera.  The {@link VideoProvider} can use | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1479 | * this as a cue to inform the user the camera is not available. | 
|  | 1480 | * @see #handleCallSessionEvent(int) | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1481 | */ | 
|  | 1482 | public static final int SESSION_EVENT_CAMERA_FAILURE = 5; | 
|  | 1483 |  | 
|  | 1484 | /** | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1485 | * Issued after {@link #SESSION_EVENT_CAMERA_FAILURE} when the camera is once again ready | 
| Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 1486 | * for operation.  The {@link VideoProvider} can use this as a cue to inform the user that | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1487 | * the camera has become available again. | 
|  | 1488 | * @see #handleCallSessionEvent(int) | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1489 | */ | 
|  | 1490 | public static final int SESSION_EVENT_CAMERA_READY = 6; | 
|  | 1491 |  | 
|  | 1492 | /** | 
| Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 1493 | * Session event raised by Telecom when | 
|  | 1494 | * {@link android.telecom.InCallService.VideoCall#setCamera(String)} is called and the | 
|  | 1495 | * caller does not have the necessary {@link android.Manifest.permission#CAMERA} permission. | 
|  | 1496 | * @see #handleCallSessionEvent(int) | 
|  | 1497 | */ | 
|  | 1498 | public static final int SESSION_EVENT_CAMERA_PERMISSION_ERROR = 7; | 
|  | 1499 |  | 
|  | 1500 | /** | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1501 | * Session modify request was successful. | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1502 | * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile) | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1503 | */ | 
|  | 1504 | public static final int SESSION_MODIFY_REQUEST_SUCCESS = 1; | 
|  | 1505 |  | 
|  | 1506 | /** | 
|  | 1507 | * Session modify request failed. | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1508 | * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile) | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1509 | */ | 
|  | 1510 | public static final int SESSION_MODIFY_REQUEST_FAIL = 2; | 
|  | 1511 |  | 
|  | 1512 | /** | 
|  | 1513 | * Session modify request ignored due to invalid parameters. | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1514 | * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile) | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1515 | */ | 
|  | 1516 | public static final int SESSION_MODIFY_REQUEST_INVALID = 3; | 
|  | 1517 |  | 
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1518 | /** | 
|  | 1519 | * Session modify request timed out. | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1520 | * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile) | 
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1521 | */ | 
|  | 1522 | public static final int SESSION_MODIFY_REQUEST_TIMED_OUT = 4; | 
|  | 1523 |  | 
|  | 1524 | /** | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1525 | * Session modify request rejected by remote user. | 
|  | 1526 | * @see #receiveSessionModifyResponse(int, VideoProfile, VideoProfile) | 
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1527 | */ | 
|  | 1528 | public static final int SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE = 5; | 
|  | 1529 |  | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1530 | private static final int MSG_ADD_VIDEO_CALLBACK = 1; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1531 | private static final int MSG_SET_CAMERA = 2; | 
|  | 1532 | private static final int MSG_SET_PREVIEW_SURFACE = 3; | 
|  | 1533 | private static final int MSG_SET_DISPLAY_SURFACE = 4; | 
|  | 1534 | private static final int MSG_SET_DEVICE_ORIENTATION = 5; | 
|  | 1535 | private static final int MSG_SET_ZOOM = 6; | 
|  | 1536 | private static final int MSG_SEND_SESSION_MODIFY_REQUEST = 7; | 
|  | 1537 | private static final int MSG_SEND_SESSION_MODIFY_RESPONSE = 8; | 
|  | 1538 | private static final int MSG_REQUEST_CAMERA_CAPABILITIES = 9; | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1539 | private static final int MSG_REQUEST_CONNECTION_DATA_USAGE = 10; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1540 | private static final int MSG_SET_PAUSE_IMAGE = 11; | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1541 | private static final int MSG_REMOVE_VIDEO_CALLBACK = 12; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1542 |  | 
| Tyler Gunn | 6f657ee | 2016-09-02 09:55:25 -0700 | [diff] [blame] | 1543 | private static final String SESSION_EVENT_RX_PAUSE_STR = "RX_PAUSE"; | 
|  | 1544 | private static final String SESSION_EVENT_RX_RESUME_STR = "RX_RESUME"; | 
|  | 1545 | private static final String SESSION_EVENT_TX_START_STR = "TX_START"; | 
|  | 1546 | private static final String SESSION_EVENT_TX_STOP_STR = "TX_STOP"; | 
|  | 1547 | private static final String SESSION_EVENT_CAMERA_FAILURE_STR = "CAMERA_FAIL"; | 
|  | 1548 | private static final String SESSION_EVENT_CAMERA_READY_STR = "CAMERA_READY"; | 
| Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 1549 | private static final String SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR = | 
|  | 1550 | "CAMERA_PERMISSION_ERROR"; | 
| Tyler Gunn | 6f657ee | 2016-09-02 09:55:25 -0700 | [diff] [blame] | 1551 | private static final String SESSION_EVENT_UNKNOWN_STR = "UNKNOWN"; | 
|  | 1552 |  | 
| Tyler Gunn | 4e9bbaf | 2015-05-22 15:43:28 -0700 | [diff] [blame] | 1553 | private VideoProvider.VideoProviderHandler mMessageHandler; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1554 | private final VideoProvider.VideoProviderBinder mBinder; | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1555 |  | 
|  | 1556 | /** | 
|  | 1557 | * Stores a list of the video callbacks, keyed by IBinder. | 
| Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1558 | * | 
|  | 1559 | * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is | 
|  | 1560 | * load factor before resizing, 1 means we only expect a single thread to | 
|  | 1561 | * access the map so make only a single shard | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1562 | */ | 
| Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1563 | private ConcurrentHashMap<IBinder, IVideoCallback> mVideoCallbacks = | 
|  | 1564 | new ConcurrentHashMap<IBinder, IVideoCallback>(8, 0.9f, 1); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1565 |  | 
|  | 1566 | /** | 
|  | 1567 | * Default handler used to consolidate binder method calls onto a single thread. | 
|  | 1568 | */ | 
|  | 1569 | private final class VideoProviderHandler extends Handler { | 
| Tyler Gunn | 4e9bbaf | 2015-05-22 15:43:28 -0700 | [diff] [blame] | 1570 | public VideoProviderHandler() { | 
|  | 1571 | super(); | 
|  | 1572 | } | 
|  | 1573 |  | 
|  | 1574 | public VideoProviderHandler(Looper looper) { | 
|  | 1575 | super(looper); | 
|  | 1576 | } | 
|  | 1577 |  | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1578 | @Override | 
|  | 1579 | public void handleMessage(Message msg) { | 
|  | 1580 | switch (msg.what) { | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1581 | case MSG_ADD_VIDEO_CALLBACK: { | 
|  | 1582 | IBinder binder = (IBinder) msg.obj; | 
|  | 1583 | IVideoCallback callback = IVideoCallback.Stub | 
|  | 1584 | .asInterface((IBinder) msg.obj); | 
| Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1585 | if (callback == null) { | 
|  | 1586 | Log.w(this, "addVideoProvider - skipped; callback is null."); | 
|  | 1587 | break; | 
|  | 1588 | } | 
|  | 1589 |  | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1590 | if (mVideoCallbacks.containsKey(binder)) { | 
|  | 1591 | Log.i(this, "addVideoProvider - skipped; already present."); | 
|  | 1592 | break; | 
|  | 1593 | } | 
|  | 1594 | mVideoCallbacks.put(binder, callback); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1595 | break; | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1596 | } | 
|  | 1597 | case MSG_REMOVE_VIDEO_CALLBACK: { | 
|  | 1598 | IBinder binder = (IBinder) msg.obj; | 
|  | 1599 | IVideoCallback callback = IVideoCallback.Stub | 
|  | 1600 | .asInterface((IBinder) msg.obj); | 
|  | 1601 | if (!mVideoCallbacks.containsKey(binder)) { | 
|  | 1602 | Log.i(this, "removeVideoProvider - skipped; not present."); | 
|  | 1603 | break; | 
|  | 1604 | } | 
|  | 1605 | mVideoCallbacks.remove(binder); | 
|  | 1606 | break; | 
|  | 1607 | } | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1608 | case MSG_SET_CAMERA: | 
| Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 1609 | { | 
|  | 1610 | SomeArgs args = (SomeArgs) msg.obj; | 
|  | 1611 | try { | 
|  | 1612 | onSetCamera((String) args.arg1); | 
|  | 1613 | onSetCamera((String) args.arg1, (String) args.arg2, args.argi1, | 
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 1614 | args.argi2, args.argi3); | 
| Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 1615 | } finally { | 
|  | 1616 | args.recycle(); | 
|  | 1617 | } | 
|  | 1618 | } | 
|  | 1619 | break; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1620 | case MSG_SET_PREVIEW_SURFACE: | 
|  | 1621 | onSetPreviewSurface((Surface) msg.obj); | 
|  | 1622 | break; | 
|  | 1623 | case MSG_SET_DISPLAY_SURFACE: | 
|  | 1624 | onSetDisplaySurface((Surface) msg.obj); | 
|  | 1625 | break; | 
|  | 1626 | case MSG_SET_DEVICE_ORIENTATION: | 
|  | 1627 | onSetDeviceOrientation(msg.arg1); | 
|  | 1628 | break; | 
|  | 1629 | case MSG_SET_ZOOM: | 
|  | 1630 | onSetZoom((Float) msg.obj); | 
|  | 1631 | break; | 
| Tyler Gunn | 4538216 | 2015-05-06 08:52:27 -0700 | [diff] [blame] | 1632 | case MSG_SEND_SESSION_MODIFY_REQUEST: { | 
|  | 1633 | SomeArgs args = (SomeArgs) msg.obj; | 
|  | 1634 | try { | 
|  | 1635 | onSendSessionModifyRequest((VideoProfile) args.arg1, | 
|  | 1636 | (VideoProfile) args.arg2); | 
|  | 1637 | } finally { | 
|  | 1638 | args.recycle(); | 
|  | 1639 | } | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1640 | break; | 
| Tyler Gunn | 4538216 | 2015-05-06 08:52:27 -0700 | [diff] [blame] | 1641 | } | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1642 | case MSG_SEND_SESSION_MODIFY_RESPONSE: | 
|  | 1643 | onSendSessionModifyResponse((VideoProfile) msg.obj); | 
|  | 1644 | break; | 
|  | 1645 | case MSG_REQUEST_CAMERA_CAPABILITIES: | 
|  | 1646 | onRequestCameraCapabilities(); | 
|  | 1647 | break; | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1648 | case MSG_REQUEST_CONNECTION_DATA_USAGE: | 
|  | 1649 | onRequestConnectionDataUsage(); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1650 | break; | 
|  | 1651 | case MSG_SET_PAUSE_IMAGE: | 
| Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 1652 | onSetPauseImage((Uri) msg.obj); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1653 | break; | 
|  | 1654 | default: | 
|  | 1655 | break; | 
|  | 1656 | } | 
|  | 1657 | } | 
|  | 1658 | } | 
|  | 1659 |  | 
|  | 1660 | /** | 
|  | 1661 | * IVideoProvider stub implementation. | 
|  | 1662 | */ | 
|  | 1663 | private final class VideoProviderBinder extends IVideoProvider.Stub { | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1664 | public void addVideoCallback(IBinder videoCallbackBinder) { | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1665 | mMessageHandler.obtainMessage( | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1666 | MSG_ADD_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget(); | 
|  | 1667 | } | 
|  | 1668 |  | 
|  | 1669 | public void removeVideoCallback(IBinder videoCallbackBinder) { | 
|  | 1670 | mMessageHandler.obtainMessage( | 
|  | 1671 | MSG_REMOVE_VIDEO_CALLBACK, videoCallbackBinder).sendToTarget(); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1672 | } | 
|  | 1673 |  | 
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 1674 | public void setCamera(String cameraId, String callingPackageName, | 
|  | 1675 | int targetSdkVersion) { | 
|  | 1676 |  | 
| Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 1677 | SomeArgs args = SomeArgs.obtain(); | 
|  | 1678 | args.arg1 = cameraId; | 
|  | 1679 | // Propagate the calling package; originally determined in | 
|  | 1680 | // android.telecom.InCallService.VideoCall#setCamera(String) from the calling | 
|  | 1681 | // process. | 
|  | 1682 | args.arg2 = callingPackageName; | 
|  | 1683 | // Pass along the uid and pid of the calling app; this gets lost when we put the | 
|  | 1684 | // message onto the handler.  These are required for Telecom to perform a permission | 
|  | 1685 | // check to see if the calling app is able to use the camera. | 
|  | 1686 | args.argi1 = Binder.getCallingUid(); | 
|  | 1687 | args.argi2 = Binder.getCallingPid(); | 
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 1688 | // Pass along the target SDK version of the calling InCallService.  This is used to | 
|  | 1689 | // maintain backwards compatibility of the API for older callers. | 
|  | 1690 | args.argi3 = targetSdkVersion; | 
| Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 1691 | mMessageHandler.obtainMessage(MSG_SET_CAMERA, args).sendToTarget(); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1692 | } | 
|  | 1693 |  | 
|  | 1694 | public void setPreviewSurface(Surface surface) { | 
|  | 1695 | mMessageHandler.obtainMessage(MSG_SET_PREVIEW_SURFACE, surface).sendToTarget(); | 
|  | 1696 | } | 
|  | 1697 |  | 
|  | 1698 | public void setDisplaySurface(Surface surface) { | 
|  | 1699 | mMessageHandler.obtainMessage(MSG_SET_DISPLAY_SURFACE, surface).sendToTarget(); | 
|  | 1700 | } | 
|  | 1701 |  | 
|  | 1702 | public void setDeviceOrientation(int rotation) { | 
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 1703 | mMessageHandler.obtainMessage( | 
|  | 1704 | MSG_SET_DEVICE_ORIENTATION, rotation, 0).sendToTarget(); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1705 | } | 
|  | 1706 |  | 
|  | 1707 | public void setZoom(float value) { | 
|  | 1708 | mMessageHandler.obtainMessage(MSG_SET_ZOOM, value).sendToTarget(); | 
|  | 1709 | } | 
|  | 1710 |  | 
| Tyler Gunn | 4538216 | 2015-05-06 08:52:27 -0700 | [diff] [blame] | 1711 | public void sendSessionModifyRequest(VideoProfile fromProfile, VideoProfile toProfile) { | 
|  | 1712 | SomeArgs args = SomeArgs.obtain(); | 
|  | 1713 | args.arg1 = fromProfile; | 
|  | 1714 | args.arg2 = toProfile; | 
|  | 1715 | mMessageHandler.obtainMessage(MSG_SEND_SESSION_MODIFY_REQUEST, args).sendToTarget(); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1716 | } | 
|  | 1717 |  | 
|  | 1718 | public void sendSessionModifyResponse(VideoProfile responseProfile) { | 
|  | 1719 | mMessageHandler.obtainMessage( | 
|  | 1720 | MSG_SEND_SESSION_MODIFY_RESPONSE, responseProfile).sendToTarget(); | 
|  | 1721 | } | 
|  | 1722 |  | 
|  | 1723 | public void requestCameraCapabilities() { | 
|  | 1724 | mMessageHandler.obtainMessage(MSG_REQUEST_CAMERA_CAPABILITIES).sendToTarget(); | 
|  | 1725 | } | 
|  | 1726 |  | 
|  | 1727 | public void requestCallDataUsage() { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1728 | mMessageHandler.obtainMessage(MSG_REQUEST_CONNECTION_DATA_USAGE).sendToTarget(); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1729 | } | 
|  | 1730 |  | 
| Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 1731 | public void setPauseImage(Uri uri) { | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1732 | mMessageHandler.obtainMessage(MSG_SET_PAUSE_IMAGE, uri).sendToTarget(); | 
|  | 1733 | } | 
|  | 1734 | } | 
|  | 1735 |  | 
|  | 1736 | public VideoProvider() { | 
|  | 1737 | mBinder = new VideoProvider.VideoProviderBinder(); | 
| Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1738 | mMessageHandler = new VideoProvider.VideoProviderHandler(Looper.getMainLooper()); | 
| Tyler Gunn | 4e9bbaf | 2015-05-22 15:43:28 -0700 | [diff] [blame] | 1739 | } | 
|  | 1740 |  | 
|  | 1741 | /** | 
|  | 1742 | * Creates an instance of the {@link VideoProvider}, specifying the looper to use. | 
|  | 1743 | * | 
|  | 1744 | * @param looper The looper. | 
|  | 1745 | * @hide | 
|  | 1746 | */ | 
| Mathew Inwood | 42346d1 | 2018-08-01 11:33:05 +0100 | [diff] [blame] | 1747 | @UnsupportedAppUsage | 
| Tyler Gunn | 4e9bbaf | 2015-05-22 15:43:28 -0700 | [diff] [blame] | 1748 | public VideoProvider(Looper looper) { | 
|  | 1749 | mBinder = new VideoProvider.VideoProviderBinder(); | 
|  | 1750 | mMessageHandler = new VideoProvider.VideoProviderHandler(looper); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1751 | } | 
|  | 1752 |  | 
|  | 1753 | /** | 
|  | 1754 | * Returns binder object which can be used across IPC methods. | 
|  | 1755 | * @hide | 
|  | 1756 | */ | 
|  | 1757 | public final IVideoProvider getInterface() { | 
|  | 1758 | return mBinder; | 
|  | 1759 | } | 
|  | 1760 |  | 
|  | 1761 | /** | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1762 | * Sets the camera to be used for the outgoing video. | 
|  | 1763 | * <p> | 
|  | 1764 | * The {@link VideoProvider} should respond by communicating the capabilities of the chosen | 
|  | 1765 | * camera via | 
|  | 1766 | * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}. | 
|  | 1767 | * <p> | 
|  | 1768 | * Sent from the {@link InCallService} via | 
|  | 1769 | * {@link InCallService.VideoCall#setCamera(String)}. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1770 | * | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1771 | * @param cameraId The id of the camera (use ids as reported by | 
|  | 1772 | * {@link CameraManager#getCameraIdList()}). | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1773 | */ | 
|  | 1774 | public abstract void onSetCamera(String cameraId); | 
|  | 1775 |  | 
|  | 1776 | /** | 
| Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 1777 | * Sets the camera to be used for the outgoing video. | 
|  | 1778 | * <p> | 
|  | 1779 | * The {@link VideoProvider} should respond by communicating the capabilities of the chosen | 
|  | 1780 | * camera via | 
|  | 1781 | * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}. | 
|  | 1782 | * <p> | 
|  | 1783 | * This prototype is used internally to ensure that the calling package name, UID and PID | 
|  | 1784 | * are sent to Telecom so that can perform a camera permission check on the caller. | 
|  | 1785 | * <p> | 
|  | 1786 | * Sent from the {@link InCallService} via | 
|  | 1787 | * {@link InCallService.VideoCall#setCamera(String)}. | 
|  | 1788 | * | 
|  | 1789 | * @param cameraId The id of the camera (use ids as reported by | 
|  | 1790 | * {@link CameraManager#getCameraIdList()}). | 
|  | 1791 | * @param callingPackageName The AppOpps package name of the caller. | 
|  | 1792 | * @param callingUid The UID of the caller. | 
|  | 1793 | * @param callingPid The PID of the caller. | 
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 1794 | * @param targetSdkVersion The target SDK version of the caller. | 
| Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 1795 | * @hide | 
|  | 1796 | */ | 
|  | 1797 | public void onSetCamera(String cameraId, String callingPackageName, int callingUid, | 
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 1798 | int callingPid, int targetSdkVersion) {} | 
| Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 1799 |  | 
|  | 1800 | /** | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1801 | * Sets the surface to be used for displaying a preview of what the user's camera is | 
|  | 1802 | * currently capturing.  When video transmission is enabled, this is the video signal which | 
|  | 1803 | * is sent to the remote device. | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1804 | * <p> | 
|  | 1805 | * Sent from the {@link InCallService} via | 
|  | 1806 | * {@link InCallService.VideoCall#setPreviewSurface(Surface)}. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1807 | * | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1808 | * @param surface The {@link Surface}. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1809 | */ | 
|  | 1810 | public abstract void onSetPreviewSurface(Surface surface); | 
|  | 1811 |  | 
|  | 1812 | /** | 
|  | 1813 | * Sets the surface to be used for displaying the video received from the remote device. | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1814 | * <p> | 
|  | 1815 | * Sent from the {@link InCallService} via | 
|  | 1816 | * {@link InCallService.VideoCall#setDisplaySurface(Surface)}. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1817 | * | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1818 | * @param surface The {@link Surface}. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1819 | */ | 
|  | 1820 | public abstract void onSetDisplaySurface(Surface surface); | 
|  | 1821 |  | 
|  | 1822 | /** | 
|  | 1823 | * Sets the device orientation, in degrees.  Assumes that a standard portrait orientation of | 
|  | 1824 | * the device is 0 degrees. | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1825 | * <p> | 
|  | 1826 | * Sent from the {@link InCallService} via | 
|  | 1827 | * {@link InCallService.VideoCall#setDeviceOrientation(int)}. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1828 | * | 
|  | 1829 | * @param rotation The device orientation, in degrees. | 
|  | 1830 | */ | 
|  | 1831 | public abstract void onSetDeviceOrientation(int rotation); | 
|  | 1832 |  | 
|  | 1833 | /** | 
| Tyler Gunn | c603b46 | 2021-06-14 17:24:40 -0700 | [diff] [blame] | 1834 | * Sets the camera zoom ratio. | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1835 | * <p> | 
|  | 1836 | * Sent from the {@link InCallService} via {@link InCallService.VideoCall#setZoom(float)}. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1837 | * | 
| Tyler Gunn | c603b46 | 2021-06-14 17:24:40 -0700 | [diff] [blame] | 1838 | * @param value The camera zoom ratio; for the current camera, should be a value in the | 
|  | 1839 | * range defined by | 
|  | 1840 | * {@link android.hardware.camera2.CameraCharacteristics#CONTROL_ZOOM_RATIO_RANGE}. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1841 | */ | 
|  | 1842 | public abstract void onSetZoom(float value); | 
|  | 1843 |  | 
|  | 1844 | /** | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1845 | * Issues a request to modify the properties of the current video session. | 
|  | 1846 | * <p> | 
|  | 1847 | * Example scenarios include: requesting an audio-only call to be upgraded to a | 
|  | 1848 | * bi-directional video call, turning on or off the user's camera, sending a pause signal | 
|  | 1849 | * when the {@link InCallService} is no longer the foreground application. | 
|  | 1850 | * <p> | 
|  | 1851 | * If the {@link VideoProvider} determines a request to be invalid, it should call | 
|  | 1852 | * {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)} to report the | 
|  | 1853 | * invalid request back to the {@link InCallService}. | 
|  | 1854 | * <p> | 
|  | 1855 | * Where a request requires confirmation from the user of the peer device, the | 
|  | 1856 | * {@link VideoProvider} must communicate the request to the peer device and handle the | 
|  | 1857 | * user's response.  {@link #receiveSessionModifyResponse(int, VideoProfile, VideoProfile)} | 
|  | 1858 | * is used to inform the {@link InCallService} of the result of the request. | 
|  | 1859 | * <p> | 
|  | 1860 | * Sent from the {@link InCallService} via | 
|  | 1861 | * {@link InCallService.VideoCall#sendSessionModifyRequest(VideoProfile)}. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1862 | * | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1863 | * @param fromProfile The video profile prior to the request. | 
|  | 1864 | * @param toProfile The video profile with the requested changes made. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1865 | */ | 
| Tyler Gunn | 4538216 | 2015-05-06 08:52:27 -0700 | [diff] [blame] | 1866 | public abstract void onSendSessionModifyRequest(VideoProfile fromProfile, | 
|  | 1867 | VideoProfile toProfile); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1868 |  | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1869 | /** | 
|  | 1870 | * Provides a response to a request to change the current video session properties. | 
|  | 1871 | * <p> | 
|  | 1872 | * For example, if the peer requests and upgrade from an audio-only call to a bi-directional | 
|  | 1873 | * video call, could decline the request and keep the call as audio-only. | 
|  | 1874 | * In such a scenario, the {@code responseProfile} would have a video state of | 
|  | 1875 | * {@link VideoProfile#STATE_AUDIO_ONLY}.  If the user had decided to accept the request, | 
|  | 1876 | * the video state would be {@link VideoProfile#STATE_BIDIRECTIONAL}. | 
|  | 1877 | * <p> | 
|  | 1878 | * Sent from the {@link InCallService} via | 
|  | 1879 | * {@link InCallService.VideoCall#sendSessionModifyResponse(VideoProfile)} in response to | 
|  | 1880 | * a {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)} | 
|  | 1881 | * callback. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1882 | * | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1883 | * @param responseProfile The response video profile. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1884 | */ | 
|  | 1885 | public abstract void onSendSessionModifyResponse(VideoProfile responseProfile); | 
|  | 1886 |  | 
|  | 1887 | /** | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1888 | * Issues a request to the {@link VideoProvider} to retrieve the camera capabilities. | 
|  | 1889 | * <p> | 
|  | 1890 | * The {@link VideoProvider} should respond by communicating the capabilities of the chosen | 
|  | 1891 | * camera via | 
|  | 1892 | * {@link VideoProvider#changeCameraCapabilities(VideoProfile.CameraCapabilities)}. | 
|  | 1893 | * <p> | 
|  | 1894 | * Sent from the {@link InCallService} via | 
|  | 1895 | * {@link InCallService.VideoCall#requestCameraCapabilities()}. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1896 | */ | 
|  | 1897 | public abstract void onRequestCameraCapabilities(); | 
|  | 1898 |  | 
|  | 1899 | /** | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1900 | * Issues a request to the {@link VideoProvider} to retrieve the current data usage for the | 
|  | 1901 | * video component of the current {@link Connection}. | 
|  | 1902 | * <p> | 
|  | 1903 | * The {@link VideoProvider} should respond by communicating current data usage, in bytes, | 
|  | 1904 | * via {@link VideoProvider#setCallDataUsage(long)}. | 
|  | 1905 | * <p> | 
|  | 1906 | * Sent from the {@link InCallService} via | 
|  | 1907 | * {@link InCallService.VideoCall#requestCallDataUsage()}. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1908 | */ | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 1909 | public abstract void onRequestConnectionDataUsage(); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1910 |  | 
|  | 1911 | /** | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1912 | * Provides the {@link VideoProvider} with the {@link Uri} of an image to be displayed to | 
|  | 1913 | * the peer device when the video signal is paused. | 
|  | 1914 | * <p> | 
|  | 1915 | * Sent from the {@link InCallService} via | 
|  | 1916 | * {@link InCallService.VideoCall#setPauseImage(Uri)}. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1917 | * | 
|  | 1918 | * @param uri URI of image to display. | 
|  | 1919 | */ | 
| Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 1920 | public abstract void onSetPauseImage(Uri uri); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1921 |  | 
|  | 1922 | /** | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1923 | * Used to inform listening {@link InCallService} implementations when the | 
|  | 1924 | * {@link VideoProvider} receives a session modification request. | 
|  | 1925 | * <p> | 
|  | 1926 | * Received by the {@link InCallService} via | 
|  | 1927 | * {@link InCallService.VideoCall.Callback#onSessionModifyRequestReceived(VideoProfile)}, | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1928 | * | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1929 | * @param videoProfile The requested video profile. | 
|  | 1930 | * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile) | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1931 | */ | 
|  | 1932 | public void receiveSessionModifyRequest(VideoProfile videoProfile) { | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1933 | if (mVideoCallbacks != null) { | 
| Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1934 | for (IVideoCallback callback : mVideoCallbacks.values()) { | 
|  | 1935 | try { | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1936 | callback.receiveSessionModifyRequest(videoProfile); | 
| Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1937 | } catch (RemoteException ignored) { | 
|  | 1938 | Log.w(this, "receiveSessionModifyRequest callback failed", ignored); | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1939 | } | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1940 | } | 
|  | 1941 | } | 
|  | 1942 | } | 
|  | 1943 |  | 
|  | 1944 | /** | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1945 | * Used to inform listening {@link InCallService} implementations when the | 
|  | 1946 | * {@link VideoProvider} receives a response to a session modification request. | 
|  | 1947 | * <p> | 
|  | 1948 | * Received by the {@link InCallService} via | 
|  | 1949 | * {@link InCallService.VideoCall.Callback#onSessionModifyResponseReceived(int, | 
|  | 1950 | * VideoProfile, VideoProfile)}. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1951 | * | 
|  | 1952 | * @param status Status of the session modify request.  Valid values are | 
|  | 1953 | *               {@link VideoProvider#SESSION_MODIFY_REQUEST_SUCCESS}, | 
|  | 1954 | *               {@link VideoProvider#SESSION_MODIFY_REQUEST_FAIL}, | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1955 | *               {@link VideoProvider#SESSION_MODIFY_REQUEST_INVALID}, | 
|  | 1956 | *               {@link VideoProvider#SESSION_MODIFY_REQUEST_TIMED_OUT}, | 
|  | 1957 | *               {@link VideoProvider#SESSION_MODIFY_REQUEST_REJECTED_BY_REMOTE} | 
|  | 1958 | * @param requestedProfile The original request which was sent to the peer device. | 
|  | 1959 | * @param responseProfile The actual profile changes agreed to by the peer device. | 
|  | 1960 | * @see #onSendSessionModifyRequest(VideoProfile, VideoProfile) | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1961 | */ | 
|  | 1962 | public void receiveSessionModifyResponse(int status, | 
|  | 1963 | VideoProfile requestedProfile, VideoProfile responseProfile) { | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1964 | if (mVideoCallbacks != null) { | 
| Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1965 | for (IVideoCallback callback : mVideoCallbacks.values()) { | 
|  | 1966 | try { | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1967 | callback.receiveSessionModifyResponse(status, requestedProfile, | 
|  | 1968 | responseProfile); | 
| Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1969 | } catch (RemoteException ignored) { | 
|  | 1970 | Log.w(this, "receiveSessionModifyResponse callback failed", ignored); | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1971 | } | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1972 | } | 
|  | 1973 | } | 
|  | 1974 | } | 
|  | 1975 |  | 
|  | 1976 | /** | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1977 | * Used to inform listening {@link InCallService} implementations when the | 
|  | 1978 | * {@link VideoProvider} reports a call session event. | 
|  | 1979 | * <p> | 
|  | 1980 | * Received by the {@link InCallService} via | 
|  | 1981 | * {@link InCallService.VideoCall.Callback#onCallSessionEvent(int)}. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1982 | * | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 1983 | * @param event The event.  Valid values are: {@link VideoProvider#SESSION_EVENT_RX_PAUSE}, | 
|  | 1984 | *      {@link VideoProvider#SESSION_EVENT_RX_RESUME}, | 
|  | 1985 | *      {@link VideoProvider#SESSION_EVENT_TX_START}, | 
|  | 1986 | *      {@link VideoProvider#SESSION_EVENT_TX_STOP}, | 
|  | 1987 | *      {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE}, | 
| Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 1988 | *      {@link VideoProvider#SESSION_EVENT_CAMERA_READY}, | 
|  | 1989 | *      {@link VideoProvider#SESSION_EVENT_CAMERA_FAILURE}. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1990 | */ | 
|  | 1991 | public void handleCallSessionEvent(int event) { | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1992 | if (mVideoCallbacks != null) { | 
| Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1993 | for (IVideoCallback callback : mVideoCallbacks.values()) { | 
|  | 1994 | try { | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1995 | callback.handleCallSessionEvent(event); | 
| Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 1996 | } catch (RemoteException ignored) { | 
|  | 1997 | Log.w(this, "handleCallSessionEvent callback failed", ignored); | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 1998 | } | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 1999 | } | 
|  | 2000 | } | 
|  | 2001 | } | 
|  | 2002 |  | 
|  | 2003 | /** | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 2004 | * Used to inform listening {@link InCallService} implementations when the dimensions of the | 
|  | 2005 | * peer's video have changed. | 
|  | 2006 | * <p> | 
|  | 2007 | * This could occur if, for example, the peer rotates their device, changing the aspect | 
|  | 2008 | * ratio of the video, or if the user switches between the back and front cameras. | 
|  | 2009 | * <p> | 
|  | 2010 | * Received by the {@link InCallService} via | 
|  | 2011 | * {@link InCallService.VideoCall.Callback#onPeerDimensionsChanged(int, int)}. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2012 | * | 
|  | 2013 | * @param width  The updated peer video width. | 
|  | 2014 | * @param height The updated peer video height. | 
|  | 2015 | */ | 
|  | 2016 | public void changePeerDimensions(int width, int height) { | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 2017 | if (mVideoCallbacks != null) { | 
| Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 2018 | for (IVideoCallback callback : mVideoCallbacks.values()) { | 
|  | 2019 | try { | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 2020 | callback.changePeerDimensions(width, height); | 
| Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 2021 | } catch (RemoteException ignored) { | 
|  | 2022 | Log.w(this, "changePeerDimensions callback failed", ignored); | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 2023 | } | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2024 | } | 
|  | 2025 | } | 
|  | 2026 | } | 
|  | 2027 |  | 
|  | 2028 | /** | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 2029 | * Used to inform listening {@link InCallService} implementations when the data usage of the | 
|  | 2030 | * video associated with the current {@link Connection} has changed. | 
|  | 2031 | * <p> | 
|  | 2032 | * This could be in response to a preview request via | 
|  | 2033 | * {@link #onRequestConnectionDataUsage()}, or as a periodic update by the | 
| Tyler Gunn | 295f5d7 | 2015-06-04 11:08:54 -0700 | [diff] [blame] | 2034 | * {@link VideoProvider}.  Where periodic updates of data usage are provided, they should be | 
|  | 2035 | * provided at most for every 1 MB of data transferred and no more than once every 10 sec. | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 2036 | * <p> | 
|  | 2037 | * Received by the {@link InCallService} via | 
|  | 2038 | * {@link InCallService.VideoCall.Callback#onCallDataUsageChanged(long)}. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2039 | * | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 2040 | * @param dataUsage The updated data usage (in bytes).  Reported as the cumulative bytes | 
|  | 2041 | *                  used since the start of the call. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2042 | */ | 
| Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 2043 | public void setCallDataUsage(long dataUsage) { | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 2044 | if (mVideoCallbacks != null) { | 
| Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 2045 | for (IVideoCallback callback : mVideoCallbacks.values()) { | 
|  | 2046 | try { | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 2047 | callback.changeCallDataUsage(dataUsage); | 
| Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 2048 | } catch (RemoteException ignored) { | 
|  | 2049 | Log.w(this, "setCallDataUsage callback failed", ignored); | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 2050 | } | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2051 | } | 
|  | 2052 | } | 
|  | 2053 | } | 
|  | 2054 |  | 
|  | 2055 | /** | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 2056 | * @see #setCallDataUsage(long) | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2057 | * | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 2058 | * @param dataUsage The updated data usage (in byes). | 
| Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 2059 | * @deprecated - Use {@link #setCallDataUsage(long)} instead. | 
|  | 2060 | * @hide | 
|  | 2061 | */ | 
|  | 2062 | public void changeCallDataUsage(long dataUsage) { | 
|  | 2063 | setCallDataUsage(dataUsage); | 
|  | 2064 | } | 
|  | 2065 |  | 
|  | 2066 | /** | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 2067 | * Used to inform listening {@link InCallService} implementations when the capabilities of | 
|  | 2068 | * the current camera have changed. | 
|  | 2069 | * <p> | 
|  | 2070 | * The {@link VideoProvider} should call this in response to | 
|  | 2071 | * {@link VideoProvider#onRequestCameraCapabilities()}, or when the current camera is | 
|  | 2072 | * changed via {@link VideoProvider#onSetCamera(String)}. | 
|  | 2073 | * <p> | 
|  | 2074 | * Received by the {@link InCallService} via | 
|  | 2075 | * {@link InCallService.VideoCall.Callback#onCameraCapabilitiesChanged( | 
|  | 2076 | * VideoProfile.CameraCapabilities)}. | 
| Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 2077 | * | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 2078 | * @param cameraCapabilities The new camera capabilities. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2079 | */ | 
| Yorke Lee | 400470f | 2015-05-12 13:31:25 -0700 | [diff] [blame] | 2080 | public void changeCameraCapabilities(VideoProfile.CameraCapabilities cameraCapabilities) { | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 2081 | if (mVideoCallbacks != null) { | 
| Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 2082 | for (IVideoCallback callback : mVideoCallbacks.values()) { | 
|  | 2083 | try { | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 2084 | callback.changeCameraCapabilities(cameraCapabilities); | 
| Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 2085 | } catch (RemoteException ignored) { | 
|  | 2086 | Log.w(this, "changeCameraCapabilities callback failed", ignored); | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 2087 | } | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2088 | } | 
|  | 2089 | } | 
|  | 2090 | } | 
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 2091 |  | 
|  | 2092 | /** | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 2093 | * Used to inform listening {@link InCallService} implementations when the video quality | 
|  | 2094 | * of the call has changed. | 
|  | 2095 | * <p> | 
|  | 2096 | * Received by the {@link InCallService} via | 
|  | 2097 | * {@link InCallService.VideoCall.Callback#onVideoQualityChanged(int)}. | 
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 2098 | * | 
| Tyler Gunn | b702ef8 | 2015-05-29 11:51:53 -0700 | [diff] [blame] | 2099 | * @param videoQuality The updated video quality.  Valid values: | 
|  | 2100 | *      {@link VideoProfile#QUALITY_HIGH}, | 
|  | 2101 | *      {@link VideoProfile#QUALITY_MEDIUM}, | 
|  | 2102 | *      {@link VideoProfile#QUALITY_LOW}, | 
|  | 2103 | *      {@link VideoProfile#QUALITY_DEFAULT}. | 
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 2104 | */ | 
|  | 2105 | public void changeVideoQuality(int videoQuality) { | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 2106 | if (mVideoCallbacks != null) { | 
| Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 2107 | for (IVideoCallback callback : mVideoCallbacks.values()) { | 
|  | 2108 | try { | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 2109 | callback.changeVideoQuality(videoQuality); | 
| Tyler Gunn | 84f381b | 2015-06-12 09:26:45 -0700 | [diff] [blame] | 2110 | } catch (RemoteException ignored) { | 
|  | 2111 | Log.w(this, "changeVideoQuality callback failed", ignored); | 
| Tyler Gunn | 7595842 | 2015-04-15 14:23:42 -0700 | [diff] [blame] | 2112 | } | 
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 2113 | } | 
|  | 2114 | } | 
|  | 2115 | } | 
| Tyler Gunn | 6f657ee | 2016-09-02 09:55:25 -0700 | [diff] [blame] | 2116 |  | 
|  | 2117 | /** | 
|  | 2118 | * Returns a string representation of a call session event. | 
|  | 2119 | * | 
|  | 2120 | * @param event A call session event passed to {@link #handleCallSessionEvent(int)}. | 
|  | 2121 | * @return String representation of the call session event. | 
|  | 2122 | * @hide | 
|  | 2123 | */ | 
|  | 2124 | public static String sessionEventToString(int event) { | 
|  | 2125 | switch (event) { | 
|  | 2126 | case SESSION_EVENT_CAMERA_FAILURE: | 
|  | 2127 | return SESSION_EVENT_CAMERA_FAILURE_STR; | 
|  | 2128 | case SESSION_EVENT_CAMERA_READY: | 
|  | 2129 | return SESSION_EVENT_CAMERA_READY_STR; | 
|  | 2130 | case SESSION_EVENT_RX_PAUSE: | 
|  | 2131 | return SESSION_EVENT_RX_PAUSE_STR; | 
|  | 2132 | case SESSION_EVENT_RX_RESUME: | 
|  | 2133 | return SESSION_EVENT_RX_RESUME_STR; | 
|  | 2134 | case SESSION_EVENT_TX_START: | 
|  | 2135 | return SESSION_EVENT_TX_START_STR; | 
|  | 2136 | case SESSION_EVENT_TX_STOP: | 
|  | 2137 | return SESSION_EVENT_TX_STOP_STR; | 
| Tyler Gunn | bf9c6fd | 2016-11-09 10:19:23 -0800 | [diff] [blame] | 2138 | case SESSION_EVENT_CAMERA_PERMISSION_ERROR: | 
|  | 2139 | return SESSION_EVENT_CAMERA_PERMISSION_ERROR_STR; | 
| Tyler Gunn | 6f657ee | 2016-09-02 09:55:25 -0700 | [diff] [blame] | 2140 | default: | 
|  | 2141 | return SESSION_EVENT_UNKNOWN_STR + " " + event; | 
|  | 2142 | } | 
|  | 2143 | } | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2144 | } | 
|  | 2145 |  | 
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2146 | private final Listener mConnectionDeathListener = new Listener() { | 
|  | 2147 | @Override | 
|  | 2148 | public void onDestroyed(Connection c) { | 
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2149 | if (mConferenceables.remove(c)) { | 
|  | 2150 | fireOnConferenceableConnectionsChanged(); | 
|  | 2151 | } | 
|  | 2152 | } | 
|  | 2153 | }; | 
|  | 2154 |  | 
|  | 2155 | private final Conference.Listener mConferenceDeathListener = new Conference.Listener() { | 
|  | 2156 | @Override | 
|  | 2157 | public void onDestroyed(Conference c) { | 
|  | 2158 | if (mConferenceables.remove(c)) { | 
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2159 | fireOnConferenceableConnectionsChanged(); | 
|  | 2160 | } | 
|  | 2161 | } | 
|  | 2162 | }; | 
|  | 2163 |  | 
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 2164 | /** | 
|  | 2165 | * ConcurrentHashMap constructor params: 8 is initial table size, 0.9f is | 
|  | 2166 | * load factor before resizing, 1 means we only expect a single thread to | 
|  | 2167 | * access the map so make only a single shard | 
|  | 2168 | */ | 
|  | 2169 | private final Set<Listener> mListeners = Collections.newSetFromMap( | 
|  | 2170 | new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1)); | 
| Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 2171 | private final List<Conferenceable> mConferenceables = new ArrayList<>(); | 
|  | 2172 | private final List<Conferenceable> mUnmodifiableConferenceables = | 
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2173 | Collections.unmodifiableList(mConferenceables); | 
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 2174 |  | 
| Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2175 | // The internal telecom call ID associated with this connection. | 
|  | 2176 | private String mTelecomCallId; | 
| Pengquan Meng | 70c988533 | 2017-10-02 18:09:03 -0700 | [diff] [blame] | 2177 | // The PhoneAccountHandle associated with this connection. | 
|  | 2178 | private PhoneAccountHandle mPhoneAccountHandle; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2179 | private int mState = STATE_NEW; | 
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 2180 | private CallAudioState mCallAudioState; | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 2181 | private CallEndpoint mCallEndpoint; | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 2182 | private Uri mAddress; | 
|  | 2183 | private int mAddressPresentation; | 
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 2184 | private String mCallerDisplayName; | 
|  | 2185 | private int mCallerDisplayNamePresentation; | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 2186 | private boolean mRingbackRequested = false; | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2187 | private int mConnectionCapabilities; | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 2188 | private int mConnectionProperties; | 
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 2189 | private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2190 | private VideoProvider mVideoProvider; | 
| Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 2191 | private boolean mAudioModeIsVoip; | 
| Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 2192 | private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED; | 
| Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 2193 | private long mConnectElapsedTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED; | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 2194 | private StatusHints mStatusHints; | 
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 2195 | private int mVideoState; | 
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 2196 | private DisconnectCause mDisconnectCause; | 
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2197 | private Conference mConference; | 
|  | 2198 | private ConnectionService mConnectionService; | 
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 2199 | private Bundle mExtras; | 
| Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 2200 | private final Object mExtrasLock = new Object(); | 
| Tyler Gunn | 6986a63 | 2019-06-25 13:45:32 -0700 | [diff] [blame] | 2201 | /** | 
|  | 2202 | * The direction of the connection; used where an existing connection is created and we need to | 
|  | 2203 | * communicate to Telecom whether its incoming or outgoing. | 
|  | 2204 | */ | 
|  | 2205 | private @Call.Details.CallDirection int mCallDirection = Call.Details.DIRECTION_UNKNOWN; | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2206 |  | 
|  | 2207 | /** | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2208 | * Tracks the key set for the extras bundle provided on the last invocation of | 
|  | 2209 | * {@link #setExtras(Bundle)}.  Used so that on subsequent invocations we can remove any extras | 
|  | 2210 | * keys which were set previously but are no longer present in the replacement Bundle. | 
|  | 2211 | */ | 
|  | 2212 | private Set<String> mPreviousExtraKeys; | 
|  | 2213 |  | 
|  | 2214 | /** | 
| Tyler Gunn | d57d76c | 2019-09-24 14:53:23 -0700 | [diff] [blame] | 2215 | * The verification status for an incoming call's phone number. | 
|  | 2216 | */ | 
|  | 2217 | private @VerificationStatus int mCallerNumberVerificationStatus; | 
|  | 2218 |  | 
|  | 2219 |  | 
|  | 2220 | /** | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2221 | * Create a new Connection. | 
|  | 2222 | */ | 
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 2223 | public Connection() {} | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2224 |  | 
|  | 2225 | /** | 
| Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2226 | * Returns the Telecom internal call ID associated with this connection.  Should only be used | 
|  | 2227 | * for debugging and tracing purposes. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2228 | * <p> | 
|  | 2229 | * Note: Access to the Telecom internal call ID is used for logging purposes only; this API is | 
|  | 2230 | * provided to facilitate debugging of the Telephony stack only. | 
| Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2231 | * | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2232 | * @return The Telecom call ID, or {@code null} if it was not set. | 
| Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2233 | * @hide | 
|  | 2234 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2235 | @SystemApi | 
|  | 2236 | public final @Nullable String getTelecomCallId() { | 
| Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2237 | return mTelecomCallId; | 
|  | 2238 | } | 
|  | 2239 |  | 
|  | 2240 | /** | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 2241 | * @return The address (e.g., phone number) to which this Connection is currently communicating. | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2242 | */ | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 2243 | public final Uri getAddress() { | 
|  | 2244 | return mAddress; | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2245 | } | 
|  | 2246 |  | 
|  | 2247 | /** | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 2248 | * @return The presentation requirements for the address. | 
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2249 | *         See {@link TelecomManager} for valid values. | 
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 2250 | */ | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 2251 | public final int getAddressPresentation() { | 
|  | 2252 | return mAddressPresentation; | 
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 2253 | } | 
|  | 2254 |  | 
|  | 2255 | /** | 
|  | 2256 | * @return The caller display name (CNAP). | 
|  | 2257 | */ | 
|  | 2258 | public final String getCallerDisplayName() { | 
|  | 2259 | return mCallerDisplayName; | 
|  | 2260 | } | 
|  | 2261 |  | 
|  | 2262 | /** | 
| Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 2263 | * @return The presentation requirements for the handle. | 
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2264 | *         See {@link TelecomManager} for valid values. | 
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 2265 | */ | 
|  | 2266 | public final int getCallerDisplayNamePresentation() { | 
|  | 2267 | return mCallerDisplayNamePresentation; | 
|  | 2268 | } | 
|  | 2269 |  | 
|  | 2270 | /** | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2271 | * @return The state of this Connection. | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2272 | */ | 
|  | 2273 | public final int getState() { | 
|  | 2274 | return mState; | 
|  | 2275 | } | 
|  | 2276 |  | 
|  | 2277 | /** | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2278 | * Returns the video state of the connection. | 
| Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 2279 | * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY}, | 
|  | 2280 | * {@link VideoProfile#STATE_BIDIRECTIONAL}, | 
|  | 2281 | * {@link VideoProfile#STATE_TX_ENABLED}, | 
|  | 2282 | * {@link VideoProfile#STATE_RX_ENABLED}. | 
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 2283 | * | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2284 | * @return The video state of the connection. | 
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 2285 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2286 | public final @VideoProfile.VideoState int getVideoState() { | 
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 2287 | return mVideoState; | 
|  | 2288 | } | 
|  | 2289 |  | 
|  | 2290 | /** | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2291 | * @return The audio state of the connection, describing how its audio is currently | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2292 | *         being routed by the system. This is {@code null} if this Connection | 
|  | 2293 | *         does not directly know about its audio state. | 
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 2294 | * @deprecated Use {@link #getCallAudioState()} instead. | 
|  | 2295 | * @hide | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2296 | */ | 
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 2297 | @SystemApi | 
|  | 2298 | @Deprecated | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2299 | public final AudioState getAudioState() { | 
| Sailesh Nepal | 000d38a | 2015-06-21 10:25:13 -0700 | [diff] [blame] | 2300 | if (mCallAudioState == null) { | 
|  | 2301 | return null; | 
|  | 2302 | } | 
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 2303 | return new AudioState(mCallAudioState); | 
|  | 2304 | } | 
|  | 2305 |  | 
|  | 2306 | /** | 
|  | 2307 | * @return The audio state of the connection, describing how its audio is currently | 
|  | 2308 | *         being routed by the system. This is {@code null} if this Connection | 
|  | 2309 | *         does not directly know about its audio state. | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 2310 | * @deprecated Use {@link #getCurrentCallEndpoint()}, | 
|  | 2311 | * {@link #onAvailableCallEndpointsChanged(List)} and | 
|  | 2312 | * {@link #onMuteStateChanged(boolean)} instead. | 
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 2313 | */ | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 2314 | @Deprecated | 
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 2315 | public final CallAudioState getCallAudioState() { | 
|  | 2316 | return mCallAudioState; | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2317 | } | 
|  | 2318 |  | 
|  | 2319 | /** | 
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2320 | * @return The conference that this connection is a part of.  Null if it is not part of any | 
|  | 2321 | *         conference. | 
|  | 2322 | */ | 
|  | 2323 | public final Conference getConference() { | 
|  | 2324 | return mConference; | 
|  | 2325 | } | 
|  | 2326 |  | 
|  | 2327 | /** | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 2328 | * Returns whether this connection is requesting that the system play a ringback tone | 
|  | 2329 | * on its behalf. | 
|  | 2330 | */ | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 2331 | public final boolean isRingbackRequested() { | 
|  | 2332 | return mRingbackRequested; | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 2333 | } | 
|  | 2334 |  | 
|  | 2335 | /** | 
| Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 2336 | * @return True if the connection's audio mode is VOIP. | 
|  | 2337 | */ | 
|  | 2338 | public final boolean getAudioModeIsVoip() { | 
|  | 2339 | return mAudioModeIsVoip; | 
|  | 2340 | } | 
|  | 2341 |  | 
|  | 2342 | /** | 
| Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 2343 | * Retrieves the connection start time of the {@code Connnection}, if specified.  A value of | 
|  | 2344 | * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the | 
|  | 2345 | * start time of the conference. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2346 | * <p> | 
|  | 2347 | * Note: This is an implementation detail specific to IMS conference calls over a mobile | 
|  | 2348 | * network. | 
| Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 2349 | * | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2350 | * @return The time at which the {@code Connnection} was connected. Will be a value as retrieved | 
|  | 2351 | * from {@link System#currentTimeMillis()}. | 
| Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 2352 | * | 
|  | 2353 | * @hide | 
|  | 2354 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2355 | @SystemApi | 
| Tyler Gunn | c9503d6 | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 2356 | public final @IntRange(from = 0) long getConnectTimeMillis() { | 
| Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 2357 | return mConnectTimeMillis; | 
|  | 2358 | } | 
|  | 2359 |  | 
|  | 2360 | /** | 
| Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 2361 | * Retrieves the connection start time of the {@link Connection}, if specified.  A value of | 
|  | 2362 | * {@link Conference#CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the | 
| Tyler Gunn | c9503d6 | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 2363 | * start time of the connection. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2364 | * <p> | 
| Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 2365 | * Based on the value of {@link SystemClock#elapsedRealtime()}, which ensures that wall-clock | 
|  | 2366 | * changes do not impact the call duration. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2367 | * <p> | 
|  | 2368 | * Used internally in Telephony when migrating conference participant data for IMS conferences. | 
| Tyler Gunn | c9503d6 | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 2369 | * <p> | 
|  | 2370 | * The value returned is the same one set using | 
|  | 2371 | * {@link #setConnectionStartElapsedRealtimeMillis(long)}.  This value is never updated from | 
|  | 2372 | * the Telecom framework, so no permission enforcement occurs when retrieving the value with | 
|  | 2373 | * this method. | 
| Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 2374 | * | 
|  | 2375 | * @return The time at which the {@link Connection} was connected. | 
|  | 2376 | * | 
|  | 2377 | * @hide | 
|  | 2378 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2379 | @SystemApi | 
| Tyler Gunn | c9503d6 | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 2380 | public final @ElapsedRealtimeLong long getConnectionStartElapsedRealtimeMillis() { | 
| Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 2381 | return mConnectElapsedTimeMillis; | 
|  | 2382 | } | 
|  | 2383 |  | 
|  | 2384 | /** | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 2385 | * @return The status hints for this connection. | 
|  | 2386 | */ | 
|  | 2387 | public final StatusHints getStatusHints() { | 
|  | 2388 | return mStatusHints; | 
|  | 2389 | } | 
|  | 2390 |  | 
|  | 2391 | /** | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2392 | * Returns the extras associated with this connection. | 
| Tyler Gunn | 2cbe2b5 | 2016-05-04 15:48:10 +0000 | [diff] [blame] | 2393 | * <p> | 
|  | 2394 | * Extras should be updated using {@link #putExtras(Bundle)}. | 
|  | 2395 | * <p> | 
|  | 2396 | * Telecom or an {@link InCallService} can also update the extras via | 
|  | 2397 | * {@link android.telecom.Call#putExtras(Bundle)}, and | 
|  | 2398 | * {@link Call#removeExtras(List)}. | 
|  | 2399 | * <p> | 
|  | 2400 | * The connection is notified of changes to the extras made by Telecom or an | 
|  | 2401 | * {@link InCallService} by {@link #onExtrasChanged(Bundle)}. | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 2402 | * | 
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 2403 | * @return The extras associated with this connection. | 
|  | 2404 | */ | 
|  | 2405 | public final Bundle getExtras() { | 
| Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 2406 | Bundle extras = null; | 
|  | 2407 | synchronized (mExtrasLock) { | 
|  | 2408 | if (mExtras != null) { | 
|  | 2409 | extras = new Bundle(mExtras); | 
|  | 2410 | } | 
|  | 2411 | } | 
|  | 2412 | return extras; | 
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 2413 | } | 
|  | 2414 |  | 
|  | 2415 | /** | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2416 | * Assign a listener to be notified of state changes. | 
|  | 2417 | * | 
|  | 2418 | * @param l A listener. | 
|  | 2419 | * @return This Connection. | 
|  | 2420 | * | 
|  | 2421 | * @hide | 
|  | 2422 | */ | 
| Tyler Gunn | 633e4c3 | 2019-10-24 15:40:48 -0700 | [diff] [blame] | 2423 | final Connection addConnectionListener(Listener l) { | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2424 | mListeners.add(l); | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2425 | return this; | 
|  | 2426 | } | 
|  | 2427 |  | 
|  | 2428 | /** | 
|  | 2429 | * Remove a previously assigned listener that was being notified of state changes. | 
|  | 2430 | * | 
|  | 2431 | * @param l A Listener. | 
|  | 2432 | * @return This Connection. | 
|  | 2433 | * | 
|  | 2434 | * @hide | 
|  | 2435 | */ | 
| Tyler Gunn | 633e4c3 | 2019-10-24 15:40:48 -0700 | [diff] [blame] | 2436 | final Connection removeConnectionListener(Listener l) { | 
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 2437 | if (l != null) { | 
|  | 2438 | mListeners.remove(l); | 
|  | 2439 | } | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2440 | return this; | 
|  | 2441 | } | 
|  | 2442 |  | 
|  | 2443 | /** | 
| Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 2444 | * @return The {@link DisconnectCause} for this connection. | 
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 2445 | */ | 
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 2446 | public final DisconnectCause getDisconnectCause() { | 
| Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 2447 | return mDisconnectCause; | 
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 2448 | } | 
|  | 2449 |  | 
|  | 2450 | /** | 
| Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2451 | * Sets the telecom call ID associated with this Connection.  The Telecom Call ID should be used | 
|  | 2452 | * ONLY for debugging purposes. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2453 | * <p> | 
|  | 2454 | * Note: Access to the Telecom internal call ID is used for logging purposes only; this API is | 
|  | 2455 | * provided to facilitate debugging of the Telephony stack only.  Changing the ID via this | 
|  | 2456 | * method does NOT change any functionality in Telephony or Telecom and impacts only logging. | 
| Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2457 | * | 
|  | 2458 | * @param callId The telecom call ID. | 
|  | 2459 | * @hide | 
|  | 2460 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2461 | @SystemApi | 
|  | 2462 | public void setTelecomCallId(@NonNull String callId) { | 
| Tyler Gunn | f0500bd | 2015-09-01 10:59:48 -0700 | [diff] [blame] | 2463 | mTelecomCallId = callId; | 
|  | 2464 | } | 
|  | 2465 |  | 
|  | 2466 | /** | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2467 | * Inform this Connection that the state of its audio output has been changed externally. | 
|  | 2468 | * | 
|  | 2469 | * @param state The new audio state. | 
| Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 2470 | * @hide | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2471 | */ | 
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 2472 | final void setCallAudioState(CallAudioState state) { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2473 | checkImmutable(); | 
| Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 2474 | Log.d(this, "setAudioState %s", state); | 
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 2475 | mCallAudioState = state; | 
|  | 2476 | onAudioStateChanged(getAudioState()); | 
|  | 2477 | onCallAudioStateChanged(state); | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2478 | } | 
|  | 2479 |  | 
|  | 2480 | /** | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 2481 | * Inform this Connection that the audio endpoint has been changed. | 
|  | 2482 | * | 
|  | 2483 | * @param endpoint The new call endpoint. | 
|  | 2484 | * @hide | 
|  | 2485 | */ | 
|  | 2486 | final void setCallEndpoint(CallEndpoint endpoint) { | 
|  | 2487 | checkImmutable(); | 
|  | 2488 | Log.d(this, "setCallEndpoint %s", endpoint); | 
|  | 2489 | mCallEndpoint = endpoint; | 
|  | 2490 | onCallEndpointChanged(endpoint); | 
|  | 2491 | } | 
|  | 2492 |  | 
|  | 2493 | /** | 
|  | 2494 | * Inform this Connection that the available call endpoints have been changed. | 
|  | 2495 | * | 
|  | 2496 | * @param availableEndpoints The available call endpoints. | 
|  | 2497 | * @hide | 
|  | 2498 | */ | 
|  | 2499 | final void setAvailableCallEndpoints(List<CallEndpoint> availableEndpoints) { | 
|  | 2500 | checkImmutable(); | 
|  | 2501 | Log.d(this, "setAvailableCallEndpoints"); | 
|  | 2502 | onAvailableCallEndpointsChanged(availableEndpoints); | 
|  | 2503 | } | 
|  | 2504 |  | 
|  | 2505 | /** | 
|  | 2506 | * Inform this Connection that its audio mute state has been changed. | 
|  | 2507 | * | 
|  | 2508 | * @param isMuted The new mute state. | 
|  | 2509 | * @hide | 
|  | 2510 | */ | 
|  | 2511 | final void setMuteState(boolean isMuted) { | 
|  | 2512 | checkImmutable(); | 
|  | 2513 | Log.d(this, "setMuteState %s", isMuted); | 
|  | 2514 | onMuteStateChanged(isMuted); | 
|  | 2515 | } | 
|  | 2516 |  | 
|  | 2517 | /** | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2518 | * @param state An integer value of a {@code STATE_*} constant. | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2519 | * @return A string representation of the value. | 
|  | 2520 | */ | 
|  | 2521 | public static String stateToString(int state) { | 
|  | 2522 | switch (state) { | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2523 | case STATE_INITIALIZING: | 
| Yorke Lee | e911c8d | 2015-07-14 11:39:36 -0700 | [diff] [blame] | 2524 | return "INITIALIZING"; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2525 | case STATE_NEW: | 
| Yorke Lee | e911c8d | 2015-07-14 11:39:36 -0700 | [diff] [blame] | 2526 | return "NEW"; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2527 | case STATE_RINGING: | 
| Yorke Lee | e911c8d | 2015-07-14 11:39:36 -0700 | [diff] [blame] | 2528 | return "RINGING"; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2529 | case STATE_DIALING: | 
| Yorke Lee | e911c8d | 2015-07-14 11:39:36 -0700 | [diff] [blame] | 2530 | return "DIALING"; | 
| Tyler Gunn | c96b5e0 | 2016-07-07 22:53:57 -0700 | [diff] [blame] | 2531 | case STATE_PULLING_CALL: | 
|  | 2532 | return "PULLING_CALL"; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2533 | case STATE_ACTIVE: | 
| Yorke Lee | e911c8d | 2015-07-14 11:39:36 -0700 | [diff] [blame] | 2534 | return "ACTIVE"; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2535 | case STATE_HOLDING: | 
| Yorke Lee | e911c8d | 2015-07-14 11:39:36 -0700 | [diff] [blame] | 2536 | return "HOLDING"; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2537 | case STATE_DISCONNECTED: | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2538 | return "DISCONNECTED"; | 
|  | 2539 | default: | 
| Ihab Awad | 60ac30b | 2014-05-20 22:32:12 -0700 | [diff] [blame] | 2540 | Log.wtf(Connection.class, "Unknown state %d", state); | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2541 | return "UNKNOWN"; | 
|  | 2542 | } | 
|  | 2543 | } | 
|  | 2544 |  | 
|  | 2545 | /** | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2546 | * Returns the connection's capabilities, as a bit mask of the {@code CAPABILITY_*} constants. | 
| Ihab Awad | 52a28f6 | 2014-06-18 10:26:34 -0700 | [diff] [blame] | 2547 | */ | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2548 | public final int getConnectionCapabilities() { | 
|  | 2549 | return mConnectionCapabilities; | 
| Ihab Awad | 52a28f6 | 2014-06-18 10:26:34 -0700 | [diff] [blame] | 2550 | } | 
|  | 2551 |  | 
|  | 2552 | /** | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 2553 | * Returns the connection's properties, as a bit mask of the {@code PROPERTY_*} constants. | 
|  | 2554 | */ | 
|  | 2555 | public final int getConnectionProperties() { | 
|  | 2556 | return mConnectionProperties; | 
|  | 2557 | } | 
|  | 2558 |  | 
|  | 2559 | /** | 
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 2560 | * Returns the connection's supported audio routes. | 
|  | 2561 | * | 
|  | 2562 | * @hide | 
|  | 2563 | */ | 
|  | 2564 | public final int getSupportedAudioRoutes() { | 
|  | 2565 | return mSupportedAudioRoutes; | 
|  | 2566 | } | 
|  | 2567 |  | 
|  | 2568 | /** | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 2569 | * Sets the value of the {@link #getAddress()} property. | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2570 | * | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 2571 | * @param address The new address. | 
|  | 2572 | * @param presentation The presentation requirements for the address. | 
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2573 | *        See {@link TelecomManager} for valid values. | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2574 | */ | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 2575 | public final void setAddress(Uri address, int presentation) { | 
|  | 2576 | Log.d(this, "setAddress %s", address); | 
|  | 2577 | mAddress = address; | 
|  | 2578 | mAddressPresentation = presentation; | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2579 | for (Listener l : mListeners) { | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 2580 | l.onAddressChanged(this, address, presentation); | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2581 | } | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2582 | } | 
|  | 2583 |  | 
|  | 2584 | /** | 
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 2585 | * Sets the caller display name (CNAP). | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 2586 | * | 
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 2587 | * @param callerDisplayName The new display name. | 
| Nancy Chen | 9d568c0 | 2014-09-08 14:17:59 -0700 | [diff] [blame] | 2588 | * @param presentation The presentation requirements for the handle. | 
| Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 2589 | *        See {@link TelecomManager} for valid values. | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 2590 | */ | 
| Sailesh Nepal | 6120386 | 2014-07-11 14:50:13 -0700 | [diff] [blame] | 2591 | public final void setCallerDisplayName(String callerDisplayName, int presentation) { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2592 | checkImmutable(); | 
| Edgar Arriaga | 2db19d2 | 2022-10-14 14:25:14 -0700 | [diff] [blame] | 2593 | boolean nameChanged = !Objects.equals(mCallerDisplayName, callerDisplayName); | 
|  | 2594 | boolean presentationChanged = mCallerDisplayNamePresentation != presentation; | 
|  | 2595 | if (nameChanged) { | 
|  | 2596 | // Ensure the new name is not clobbering the old one with a null value due to the caller | 
|  | 2597 | // wanting to only set the presentation and not knowing the display name. | 
|  | 2598 | mCallerDisplayName = callerDisplayName; | 
|  | 2599 | } | 
|  | 2600 | if (presentationChanged) { | 
|  | 2601 | mCallerDisplayNamePresentation = presentation; | 
|  | 2602 | } | 
|  | 2603 | if (nameChanged || presentationChanged) { | 
|  | 2604 | for (Listener l : mListeners) { | 
|  | 2605 | l.onCallerDisplayNameChanged(this, mCallerDisplayName, | 
|  | 2606 | mCallerDisplayNamePresentation); | 
|  | 2607 | } | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2608 | } | 
| Sailesh Nepal | 2a46b90 | 2014-07-04 17:21:07 -0700 | [diff] [blame] | 2609 | } | 
|  | 2610 |  | 
|  | 2611 | /** | 
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 2612 | * Set the video state for the connection. | 
| Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 2613 | * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY}, | 
|  | 2614 | * {@link VideoProfile#STATE_BIDIRECTIONAL}, | 
|  | 2615 | * {@link VideoProfile#STATE_TX_ENABLED}, | 
|  | 2616 | * {@link VideoProfile#STATE_RX_ENABLED}. | 
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 2617 | * | 
|  | 2618 | * @param videoState The new video state. | 
|  | 2619 | */ | 
|  | 2620 | public final void setVideoState(int videoState) { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2621 | checkImmutable(); | 
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 2622 | Log.d(this, "setVideoState %d", videoState); | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2623 | mVideoState = videoState; | 
|  | 2624 | for (Listener l : mListeners) { | 
|  | 2625 | l.onVideoStateChanged(this, mVideoState); | 
|  | 2626 | } | 
| Tyler Gunn | aa07df8 | 2014-07-17 07:50:22 -0700 | [diff] [blame] | 2627 | } | 
|  | 2628 |  | 
|  | 2629 | /** | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2630 | * Sets state to active (e.g., an ongoing connection where two or more parties can actively | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2631 | * communicate). | 
|  | 2632 | */ | 
| Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 2633 | public final void setActive() { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2634 | checkImmutable(); | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 2635 | setRingbackRequested(false); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2636 | setState(STATE_ACTIVE); | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2637 | } | 
|  | 2638 |  | 
|  | 2639 | /** | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2640 | * Sets state to ringing (e.g., an inbound ringing connection). | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2641 | */ | 
| Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 2642 | public final void setRinging() { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2643 | checkImmutable(); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2644 | setState(STATE_RINGING); | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2645 | } | 
|  | 2646 |  | 
|  | 2647 | /** | 
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 2648 | * Sets state to initializing (this Connection is not yet ready to be used). | 
|  | 2649 | */ | 
|  | 2650 | public final void setInitializing() { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2651 | checkImmutable(); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2652 | setState(STATE_INITIALIZING); | 
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 2653 | } | 
|  | 2654 |  | 
|  | 2655 | /** | 
|  | 2656 | * Sets state to initialized (the Connection has been set up and is now ready to be used). | 
|  | 2657 | */ | 
|  | 2658 | public final void setInitialized() { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2659 | checkImmutable(); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2660 | setState(STATE_NEW); | 
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 2661 | } | 
|  | 2662 |  | 
|  | 2663 | /** | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2664 | * Sets state to dialing (e.g., dialing an outbound connection). | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2665 | */ | 
| Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 2666 | public final void setDialing() { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2667 | checkImmutable(); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2668 | setState(STATE_DIALING); | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2669 | } | 
|  | 2670 |  | 
|  | 2671 | /** | 
| Tyler Gunn | c242ceb | 2016-06-29 22:35:45 -0700 | [diff] [blame] | 2672 | * Sets state to pulling (e.g. the connection is being pulled to the local device from another | 
|  | 2673 | * device).  Only applicable for {@link Connection}s with | 
|  | 2674 | * {@link Connection#PROPERTY_IS_EXTERNAL_CALL} and {@link Connection#CAPABILITY_CAN_PULL_CALL}. | 
|  | 2675 | */ | 
|  | 2676 | public final void setPulling() { | 
|  | 2677 | checkImmutable(); | 
|  | 2678 | setState(STATE_PULLING_CALL); | 
|  | 2679 | } | 
|  | 2680 |  | 
|  | 2681 | /** | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2682 | * Sets state to be on hold. | 
|  | 2683 | */ | 
| Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 2684 | public final void setOnHold() { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2685 | checkImmutable(); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2686 | setState(STATE_HOLDING); | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2687 | } | 
|  | 2688 |  | 
|  | 2689 | /** | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2690 | * Sets the video connection provider. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2691 | * @param videoProvider The video provider. | 
| Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 2692 | */ | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2693 | public final void setVideoProvider(VideoProvider videoProvider) { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2694 | checkImmutable(); | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2695 | mVideoProvider = videoProvider; | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2696 | for (Listener l : mListeners) { | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2697 | l.onVideoProviderChanged(this, videoProvider); | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2698 | } | 
| Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 2699 | } | 
|  | 2700 |  | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2701 | public final VideoProvider getVideoProvider() { | 
|  | 2702 | return mVideoProvider; | 
| Andrew Lee | a27a193 | 2014-07-09 17:07:13 -0700 | [diff] [blame] | 2703 | } | 
|  | 2704 |  | 
| Andrew Lee | 5ffbe8b8 | 2014-06-20 16:29:33 -0700 | [diff] [blame] | 2705 | /** | 
| Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 2706 | * Sets state to disconnected. | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2707 | * | 
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 2708 | * @param disconnectCause The reason for the disconnection, as specified by | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2709 | *         {@link DisconnectCause}. | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2710 | */ | 
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 2711 | public final void setDisconnected(DisconnectCause disconnectCause) { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2712 | checkImmutable(); | 
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 2713 | mDisconnectCause = disconnectCause; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2714 | setState(STATE_DISCONNECTED); | 
| mike dooley | f34519b | 2014-09-16 17:33:40 -0700 | [diff] [blame] | 2715 | Log.d(this, "Disconnected with cause %s", disconnectCause); | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2716 | for (Listener l : mListeners) { | 
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 2717 | l.onDisconnected(this, disconnectCause); | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2718 | } | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 2719 | } | 
|  | 2720 |  | 
|  | 2721 | /** | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2722 | * Informs listeners that this {@code Connection} is in a post-dial wait state. This is done | 
|  | 2723 | * when (a) the {@code Connection} is issuing a DTMF sequence; (b) it has encountered a "wait" | 
|  | 2724 | * character; and (c) it wishes to inform the In-Call app that it is waiting for the end-user | 
|  | 2725 | * to send an {@link #onPostDialContinue(boolean)} signal. | 
|  | 2726 | * | 
|  | 2727 | * @param remaining The DTMF character sequence remaining to be emitted once the | 
|  | 2728 | *         {@link #onPostDialContinue(boolean)} is received, including any "wait" characters | 
|  | 2729 | *         that remaining sequence may contain. | 
| Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 2730 | */ | 
|  | 2731 | public final void setPostDialWait(String remaining) { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2732 | checkImmutable(); | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2733 | for (Listener l : mListeners) { | 
|  | 2734 | l.onPostDialWait(this, remaining); | 
|  | 2735 | } | 
| Sailesh Nepal | 091768c | 2014-06-30 15:15:23 -0700 | [diff] [blame] | 2736 | } | 
|  | 2737 |  | 
|  | 2738 | /** | 
| Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 2739 | * Informs listeners that this {@code Connection} has processed a character in the post-dial | 
|  | 2740 | * started state. This is done when (a) the {@code Connection} is issuing a DTMF sequence; | 
| Sailesh Nepal | 1ed8561 | 2015-01-31 15:17:19 -0800 | [diff] [blame] | 2741 | * and (b) it wishes to signal Telecom to play the corresponding DTMF tone locally. | 
| Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 2742 | * | 
|  | 2743 | * @param nextChar The DTMF character that was just processed by the {@code Connection}. | 
| Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 2744 | */ | 
| Sailesh Nepal | 1ed8561 | 2015-01-31 15:17:19 -0800 | [diff] [blame] | 2745 | public final void setNextPostDialChar(char nextChar) { | 
| Nancy Chen | 27d1c2d | 2014-12-15 16:12:50 -0800 | [diff] [blame] | 2746 | checkImmutable(); | 
|  | 2747 | for (Listener l : mListeners) { | 
|  | 2748 | l.onPostDialChar(this, nextChar); | 
|  | 2749 | } | 
|  | 2750 | } | 
|  | 2751 |  | 
|  | 2752 | /** | 
| Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 2753 | * Requests that the framework play a ringback tone. This is to be invoked by implementations | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2754 | * that do not play a ringback tone themselves in the connection's audio stream. | 
| Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 2755 | * | 
|  | 2756 | * @param ringback Whether the ringback tone is to be played. | 
|  | 2757 | */ | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 2758 | public final void setRingbackRequested(boolean ringback) { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2759 | checkImmutable(); | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 2760 | if (mRingbackRequested != ringback) { | 
|  | 2761 | mRingbackRequested = ringback; | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2762 | for (Listener l : mListeners) { | 
| Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 2763 | l.onRingbackRequested(this, ringback); | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2764 | } | 
|  | 2765 | } | 
| Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 2766 | } | 
|  | 2767 |  | 
|  | 2768 | /** | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2769 | * Sets the connection's capabilities as a bit mask of the {@code CAPABILITY_*} constants. | 
| Sailesh Nepal | 1a7061b | 2014-07-09 21:03:20 -0700 | [diff] [blame] | 2770 | * | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2771 | * @param connectionCapabilities The new connection capabilities. | 
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 2772 | */ | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2773 | public final void setConnectionCapabilities(int connectionCapabilities) { | 
|  | 2774 | checkImmutable(); | 
|  | 2775 | if (mConnectionCapabilities != connectionCapabilities) { | 
|  | 2776 | mConnectionCapabilities = connectionCapabilities; | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2777 | for (Listener l : mListeners) { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2778 | l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities); | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2779 | } | 
|  | 2780 | } | 
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 2781 | } | 
|  | 2782 |  | 
|  | 2783 | /** | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 2784 | * Sets the connection's properties as a bit mask of the {@code PROPERTY_*} constants. | 
|  | 2785 | * | 
|  | 2786 | * @param connectionProperties The new connection properties. | 
|  | 2787 | */ | 
|  | 2788 | public final void setConnectionProperties(int connectionProperties) { | 
|  | 2789 | checkImmutable(); | 
|  | 2790 | if (mConnectionProperties != connectionProperties) { | 
|  | 2791 | mConnectionProperties = connectionProperties; | 
|  | 2792 | for (Listener l : mListeners) { | 
|  | 2793 | l.onConnectionPropertiesChanged(this, mConnectionProperties); | 
|  | 2794 | } | 
|  | 2795 | } | 
|  | 2796 | } | 
|  | 2797 |  | 
|  | 2798 | /** | 
| Christine Hallstrom | 2830ce9 | 2016-11-30 16:06:42 -0800 | [diff] [blame] | 2799 | * Sets the supported audio routes. | 
|  | 2800 | * | 
|  | 2801 | * @param supportedAudioRoutes the supported audio routes as a bitmask. | 
|  | 2802 | *                             See {@link CallAudioState} | 
|  | 2803 | * @hide | 
|  | 2804 | */ | 
|  | 2805 | public final void setSupportedAudioRoutes(int supportedAudioRoutes) { | 
|  | 2806 | if ((supportedAudioRoutes | 
|  | 2807 | & (CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_SPEAKER)) == 0) { | 
|  | 2808 | throw new IllegalArgumentException( | 
|  | 2809 | "supported audio routes must include either speaker or earpiece"); | 
|  | 2810 | } | 
|  | 2811 |  | 
|  | 2812 | if (mSupportedAudioRoutes != supportedAudioRoutes) { | 
|  | 2813 | mSupportedAudioRoutes = supportedAudioRoutes; | 
|  | 2814 | for (Listener l : mListeners) { | 
|  | 2815 | l.onSupportedAudioRoutesChanged(this, mSupportedAudioRoutes); | 
|  | 2816 | } | 
|  | 2817 | } | 
|  | 2818 | } | 
|  | 2819 |  | 
|  | 2820 | /** | 
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2821 | * Tears down the Connection object. | 
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 2822 | */ | 
| Evan Charlton | 36a7134 | 2014-07-19 16:31:02 -0700 | [diff] [blame] | 2823 | public final void destroy() { | 
| Jay Shrauner | 229e382 | 2014-08-15 09:23:07 -0700 | [diff] [blame] | 2824 | for (Listener l : mListeners) { | 
|  | 2825 | l.onDestroyed(this); | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2826 | } | 
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 2827 | } | 
|  | 2828 |  | 
|  | 2829 | /** | 
| Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 2830 | * Requests that the framework use VOIP audio mode for this connection. | 
|  | 2831 | * | 
|  | 2832 | * @param isVoip True if the audio mode is VOIP. | 
|  | 2833 | */ | 
|  | 2834 | public final void setAudioModeIsVoip(boolean isVoip) { | 
| Thomas Stuart | b83cc19 | 2022-07-06 10:59:41 -0700 | [diff] [blame] | 2835 | if (!isVoip && (mConnectionProperties & PROPERTY_SELF_MANAGED) == PROPERTY_SELF_MANAGED) { | 
|  | 2836 | Log.i(this, | 
|  | 2837 | "setAudioModeIsVoip: Ignored request to set a self-managed connection's" | 
|  | 2838 | + " audioModeIsVoip to false. Doing so can cause unwanted behavior."); | 
|  | 2839 | return; | 
|  | 2840 | } | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2841 | checkImmutable(); | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2842 | mAudioModeIsVoip = isVoip; | 
|  | 2843 | for (Listener l : mListeners) { | 
|  | 2844 | l.onAudioModeIsVoipChanged(this, isVoip); | 
|  | 2845 | } | 
| Sailesh Nepal | 33aaae4 | 2014-07-07 22:49:44 -0700 | [diff] [blame] | 2846 | } | 
|  | 2847 |  | 
|  | 2848 | /** | 
| Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 2849 | * Sets the time at which a call became active on this Connection. This is set only | 
|  | 2850 | * when a conference call becomes active on this connection. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2851 | * <p> | 
| Tyler Gunn | c9503d6 | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 2852 | * This time corresponds to the date/time of connection and is stored in the call log in | 
|  | 2853 | * {@link android.provider.CallLog.Calls#DATE}. | 
|  | 2854 | * <p> | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2855 | * Used by telephony to maintain calls associated with an IMS Conference. | 
| Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 2856 | * | 
| Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 2857 | * @param connectTimeMillis The connection time, in milliseconds.  Should be set using a value | 
|  | 2858 | *                          obtained from {@link System#currentTimeMillis()}. | 
| Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 2859 | * | 
|  | 2860 | * @hide | 
|  | 2861 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2862 | @SystemApi | 
| Tyler Gunn | c9503d6 | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 2863 | @RequiresPermission(MODIFY_PHONE_STATE) | 
|  | 2864 | public final void setConnectTimeMillis(@IntRange(from = 0) long connectTimeMillis) { | 
| Roshan Pius | e927ec0 | 2015-07-15 15:47:21 -0700 | [diff] [blame] | 2865 | mConnectTimeMillis = connectTimeMillis; | 
|  | 2866 | } | 
|  | 2867 |  | 
|  | 2868 | /** | 
| Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 2869 | * Sets the time at which a call became active on this Connection. This is set only | 
|  | 2870 | * when a conference call becomes active on this connection. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2871 | * <p> | 
| Tyler Gunn | c9503d6 | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 2872 | * This time is used to establish the duration of a call.  It uses | 
|  | 2873 | * {@link SystemClock#elapsedRealtime()} to ensure that the call duration is not impacted by | 
|  | 2874 | * time zone changes during a call.  The difference between the current | 
|  | 2875 | * {@link SystemClock#elapsedRealtime()} and the value set at the connection start time is used | 
|  | 2876 | * to populate {@link android.provider.CallLog.Calls#DURATION} in the call log. | 
|  | 2877 | * <p> | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2878 | * Used by telephony to maintain calls associated with an IMS Conference. | 
| Tyler Gunn | c9503d6 | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 2879 | * | 
| Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 2880 | * @param connectElapsedTimeMillis The connection time, in milliseconds.  Stored in the format | 
|  | 2881 | *                              {@link SystemClock#elapsedRealtime()}. | 
| Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 2882 | * @hide | 
|  | 2883 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2884 | @SystemApi | 
| Tyler Gunn | c9503d6 | 2020-01-27 10:30:51 -0800 | [diff] [blame] | 2885 | @RequiresPermission(MODIFY_PHONE_STATE) | 
|  | 2886 | public final void setConnectionStartElapsedRealtimeMillis( | 
|  | 2887 | @ElapsedRealtimeLong long connectElapsedTimeMillis) { | 
| Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 2888 | mConnectElapsedTimeMillis = connectElapsedTimeMillis; | 
|  | 2889 | } | 
|  | 2890 |  | 
|  | 2891 | /** | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 2892 | * Sets the label and icon status to display in the in-call UI. | 
|  | 2893 | * | 
|  | 2894 | * @param statusHints The status label and icon to set. | 
|  | 2895 | */ | 
|  | 2896 | public final void setStatusHints(StatusHints statusHints) { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2897 | checkImmutable(); | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 2898 | mStatusHints = statusHints; | 
|  | 2899 | for (Listener l : mListeners) { | 
|  | 2900 | l.onStatusHintsChanged(this, statusHints); | 
|  | 2901 | } | 
| Sailesh Nepal | e7ef59a | 2014-07-08 21:48:22 -0700 | [diff] [blame] | 2902 | } | 
|  | 2903 |  | 
|  | 2904 | /** | 
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2905 | * Sets the connections with which this connection can be conferenced. | 
|  | 2906 | * | 
|  | 2907 | * @param conferenceableConnections The set of connections this connection can conference with. | 
|  | 2908 | */ | 
|  | 2909 | public final void setConferenceableConnections(List<Connection> conferenceableConnections) { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2910 | checkImmutable(); | 
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2911 | clearConferenceableList(); | 
|  | 2912 | for (Connection c : conferenceableConnections) { | 
|  | 2913 | // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a | 
|  | 2914 | // small amount of items here. | 
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2915 | if (!mConferenceables.contains(c)) { | 
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2916 | c.addConnectionListener(mConnectionDeathListener); | 
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2917 | mConferenceables.add(c); | 
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 2918 | } | 
|  | 2919 | } | 
|  | 2920 | fireOnConferenceableConnectionsChanged(); | 
|  | 2921 | } | 
|  | 2922 |  | 
|  | 2923 | /** | 
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2924 | * Similar to {@link #setConferenceableConnections(java.util.List)}, sets a list of connections | 
|  | 2925 | * or conferences with which this connection can be conferenced. | 
|  | 2926 | * | 
|  | 2927 | * @param conferenceables The conferenceables. | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2928 | */ | 
| Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 2929 | public final void setConferenceables(List<Conferenceable> conferenceables) { | 
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2930 | clearConferenceableList(); | 
| Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 2931 | for (Conferenceable c : conferenceables) { | 
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2932 | // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a | 
|  | 2933 | // small amount of items here. | 
|  | 2934 | if (!mConferenceables.contains(c)) { | 
|  | 2935 | if (c instanceof Connection) { | 
|  | 2936 | Connection connection = (Connection) c; | 
|  | 2937 | connection.addConnectionListener(mConnectionDeathListener); | 
|  | 2938 | } else if (c instanceof Conference) { | 
|  | 2939 | Conference conference = (Conference) c; | 
|  | 2940 | conference.addListener(mConferenceDeathListener); | 
|  | 2941 | } | 
|  | 2942 | mConferenceables.add(c); | 
|  | 2943 | } | 
|  | 2944 | } | 
|  | 2945 | fireOnConferenceableConnectionsChanged(); | 
|  | 2946 | } | 
|  | 2947 |  | 
|  | 2948 | /** | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2949 | * Resets the CDMA connection time. | 
|  | 2950 | * <p> | 
|  | 2951 | * This is an implementation detail specific to legacy CDMA calls on mobile networks. | 
| Mengjun Leng | 2570774 | 2017-07-04 11:10:37 +0800 | [diff] [blame] | 2952 | * @hide | 
| Mengjun Leng | 2570774 | 2017-07-04 11:10:37 +0800 | [diff] [blame] | 2953 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 2954 | @SystemApi | 
| Mengjun Leng | 2570774 | 2017-07-04 11:10:37 +0800 | [diff] [blame] | 2955 | public final void resetConnectionTime() { | 
|  | 2956 | for (Listener l : mListeners) { | 
|  | 2957 | l.onConnectionTimeReset(this); | 
|  | 2958 | } | 
|  | 2959 | } | 
|  | 2960 |  | 
|  | 2961 | /** | 
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2962 | * Returns the connections or conferences with which this connection can be conferenced. | 
|  | 2963 | */ | 
| Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 2964 | public final List<Conferenceable> getConferenceables() { | 
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 2965 | return mUnmodifiableConferenceables; | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 2966 | } | 
|  | 2967 |  | 
| Yorke Lee | 5346396 | 2015-08-04 16:07:19 -0700 | [diff] [blame] | 2968 | /** | 
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2969 | * @hide | 
|  | 2970 | */ | 
|  | 2971 | public final void setConnectionService(ConnectionService connectionService) { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2972 | checkImmutable(); | 
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2973 | if (mConnectionService != null) { | 
|  | 2974 | Log.e(this, new Exception(), "Trying to set ConnectionService on a connection " + | 
|  | 2975 | "which is already associated with another ConnectionService."); | 
|  | 2976 | } else { | 
|  | 2977 | mConnectionService = connectionService; | 
|  | 2978 | } | 
|  | 2979 | } | 
|  | 2980 |  | 
|  | 2981 | /** | 
|  | 2982 | * @hide | 
|  | 2983 | */ | 
|  | 2984 | public final void unsetConnectionService(ConnectionService connectionService) { | 
|  | 2985 | if (mConnectionService != connectionService) { | 
|  | 2986 | Log.e(this, new Exception(), "Trying to remove ConnectionService from a Connection " + | 
|  | 2987 | "that does not belong to the ConnectionService."); | 
|  | 2988 | } else { | 
|  | 2989 | mConnectionService = null; | 
|  | 2990 | } | 
|  | 2991 | } | 
|  | 2992 |  | 
|  | 2993 | /** | 
|  | 2994 | * Sets the conference that this connection is a part of. This will fail if the connection is | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 2995 | * already part of a conference. {@link #resetConference} to un-set the conference first. | 
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 2996 | * | 
|  | 2997 | * @param conference The conference. | 
|  | 2998 | * @return {@code true} if the conference was successfully set. | 
|  | 2999 | * @hide | 
|  | 3000 | */ | 
|  | 3001 | public final boolean setConference(Conference conference) { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 3002 | checkImmutable(); | 
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 3003 | // We check to see if it is already part of another conference. | 
| Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 3004 | if (mConference == null) { | 
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 3005 | mConference = conference; | 
| Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 3006 | if (mConnectionService != null && mConnectionService.containsConference(conference)) { | 
|  | 3007 | fireConferenceChanged(); | 
|  | 3008 | } | 
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 3009 | return true; | 
|  | 3010 | } | 
|  | 3011 | return false; | 
|  | 3012 | } | 
|  | 3013 |  | 
|  | 3014 | /** | 
|  | 3015 | * Resets the conference that this connection is a part of. | 
|  | 3016 | * @hide | 
|  | 3017 | */ | 
|  | 3018 | public final void resetConference() { | 
|  | 3019 | if (mConference != null) { | 
| Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 3020 | Log.d(this, "Conference reset"); | 
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 3021 | mConference = null; | 
|  | 3022 | fireConferenceChanged(); | 
|  | 3023 | } | 
|  | 3024 | } | 
|  | 3025 |  | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 3026 | /** | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 3027 | * Set some extras that can be associated with this {@code Connection}. | 
|  | 3028 | * <p> | 
|  | 3029 | * New or existing keys are replaced in the {@code Connection} extras.  Keys which are no longer | 
|  | 3030 | * in the new extras, but were present the last time {@code setExtras} was called are removed. | 
|  | 3031 | * <p> | 
| Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 3032 | * Alternatively you may use the {@link #putExtras(Bundle)}, and | 
|  | 3033 | * {@link #removeExtras(String...)} methods to modify the extras. | 
|  | 3034 | * <p> | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 3035 | * No assumptions should be made as to how an In-Call UI or service will handle these extras. | 
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 3036 | * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts. | 
|  | 3037 | * | 
|  | 3038 | * @param extras The extras associated with this {@code Connection}. | 
|  | 3039 | */ | 
|  | 3040 | public final void setExtras(@Nullable Bundle extras) { | 
|  | 3041 | checkImmutable(); | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 3042 |  | 
|  | 3043 | // Add/replace any new or changed extras values. | 
|  | 3044 | putExtras(extras); | 
|  | 3045 |  | 
|  | 3046 | // If we have used "setExtras" in the past, compare the key set from the last invocation to | 
|  | 3047 | // the current one and remove any keys that went away. | 
|  | 3048 | if (mPreviousExtraKeys != null) { | 
|  | 3049 | List<String> toRemove = new ArrayList<String>(); | 
|  | 3050 | for (String oldKey : mPreviousExtraKeys) { | 
| Tyler Gunn | a8fb8ab | 2016-03-29 10:24:22 -0700 | [diff] [blame] | 3051 | if (extras == null || !extras.containsKey(oldKey)) { | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 3052 | toRemove.add(oldKey); | 
|  | 3053 | } | 
|  | 3054 | } | 
|  | 3055 | if (!toRemove.isEmpty()) { | 
|  | 3056 | removeExtras(toRemove); | 
|  | 3057 | } | 
|  | 3058 | } | 
|  | 3059 |  | 
|  | 3060 | // Track the keys the last time set called setExtras.  This way, the next time setExtras is | 
|  | 3061 | // called we can see if the caller has removed any extras values. | 
|  | 3062 | if (mPreviousExtraKeys == null) { | 
|  | 3063 | mPreviousExtraKeys = new ArraySet<String>(); | 
|  | 3064 | } | 
|  | 3065 | mPreviousExtraKeys.clear(); | 
| Tyler Gunn | a8fb8ab | 2016-03-29 10:24:22 -0700 | [diff] [blame] | 3066 | if (extras != null) { | 
|  | 3067 | mPreviousExtraKeys.addAll(extras.keySet()); | 
|  | 3068 | } | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 3069 | } | 
|  | 3070 |  | 
|  | 3071 | /** | 
|  | 3072 | * Adds some extras to this {@code Connection}.  Existing keys are replaced and new ones are | 
|  | 3073 | * added. | 
|  | 3074 | * <p> | 
|  | 3075 | * No assumptions should be made as to how an In-Call UI or service will handle these extras. | 
|  | 3076 | * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts. | 
|  | 3077 | * | 
|  | 3078 | * @param extras The extras to add. | 
|  | 3079 | */ | 
|  | 3080 | public final void putExtras(@NonNull Bundle extras) { | 
|  | 3081 | checkImmutable(); | 
|  | 3082 | if (extras == null) { | 
|  | 3083 | return; | 
|  | 3084 | } | 
| Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 3085 | // Creating a duplicate bundle so we don't have to synchronize on mExtrasLock while calling | 
|  | 3086 | // the listeners. | 
|  | 3087 | Bundle listenerExtras; | 
|  | 3088 | synchronized (mExtrasLock) { | 
|  | 3089 | if (mExtras == null) { | 
|  | 3090 | mExtras = new Bundle(); | 
|  | 3091 | } | 
|  | 3092 | mExtras.putAll(extras); | 
|  | 3093 | listenerExtras = new Bundle(mExtras); | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 3094 | } | 
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 3095 | for (Listener l : mListeners) { | 
| Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 3096 | // Create a new clone of the extras for each listener so that they don't clobber | 
|  | 3097 | // each other | 
|  | 3098 | l.onExtrasChanged(this, new Bundle(listenerExtras)); | 
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 3099 | } | 
|  | 3100 | } | 
|  | 3101 |  | 
|  | 3102 | /** | 
| Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 3103 | * Removes extras from this {@code Connection}. | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 3104 | * | 
| Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 3105 | * @param keys The keys of the extras to remove. | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 3106 | */ | 
|  | 3107 | public final void removeExtras(List<String> keys) { | 
| Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 3108 | synchronized (mExtrasLock) { | 
|  | 3109 | if (mExtras != null) { | 
|  | 3110 | for (String key : keys) { | 
|  | 3111 | mExtras.remove(key); | 
|  | 3112 | } | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 3113 | } | 
|  | 3114 | } | 
| Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 3115 | List<String> unmodifiableKeys = Collections.unmodifiableList(keys); | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 3116 | for (Listener l : mListeners) { | 
| Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 3117 | l.onExtrasRemoved(this, unmodifiableKeys); | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 3118 | } | 
|  | 3119 | } | 
|  | 3120 |  | 
|  | 3121 | /** | 
| Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 3122 | * Removes extras from this {@code Connection}. | 
|  | 3123 | * | 
|  | 3124 | * @param keys The keys of the extras to remove. | 
|  | 3125 | */ | 
|  | 3126 | public final void removeExtras(String ... keys) { | 
|  | 3127 | removeExtras(Arrays.asList(keys)); | 
|  | 3128 | } | 
|  | 3129 |  | 
|  | 3130 | /** | 
| Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 3131 | * Sets the audio route (speaker, bluetooth, etc...).  When this request is honored, there will | 
|  | 3132 | * be change to the {@link #getCallAudioState()}. | 
|  | 3133 | * <p> | 
|  | 3134 | * Used by self-managed {@link ConnectionService}s which wish to change the audio route for a | 
|  | 3135 | * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.) | 
|  | 3136 | * <p> | 
|  | 3137 | * See also {@link InCallService#setAudioRoute(int)}. | 
|  | 3138 | * | 
|  | 3139 | * @param route The audio route to use (one of {@link CallAudioState#ROUTE_BLUETOOTH}, | 
|  | 3140 | *              {@link CallAudioState#ROUTE_EARPIECE}, {@link CallAudioState#ROUTE_SPEAKER}, or | 
|  | 3141 | *              {@link CallAudioState#ROUTE_WIRED_HEADSET}). | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 3142 | * @deprecated Use {@link #requestCallEndpointChange(CallEndpoint, Executor, OutcomeReceiver)} | 
|  | 3143 | * instead. | 
| Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 3144 | */ | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 3145 | @Deprecated | 
| Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 3146 | public final void setAudioRoute(int route) { | 
|  | 3147 | for (Listener l : mListeners) { | 
| Hall Liu | a98f58b5 | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 3148 | l.onAudioRouteChanged(this, route, null); | 
|  | 3149 | } | 
|  | 3150 | } | 
|  | 3151 |  | 
|  | 3152 | /** | 
| Hall Liu | a98f58b5 | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 3153 | * Request audio routing to a specific bluetooth device. Calling this method may result in | 
|  | 3154 | * the device routing audio to a different bluetooth device than the one specified if the | 
|  | 3155 | * bluetooth stack is unable to route audio to the requested device. | 
|  | 3156 | * A list of available devices can be obtained via | 
|  | 3157 | * {@link CallAudioState#getSupportedBluetoothDevices()} | 
|  | 3158 | * | 
|  | 3159 | * <p> | 
|  | 3160 | * Used by self-managed {@link ConnectionService}s which wish to use bluetooth audio for a | 
|  | 3161 | * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.) | 
|  | 3162 | * <p> | 
| Hall Liu | 2b6a6a3 | 2018-04-02 13:52:57 -0700 | [diff] [blame] | 3163 | * See also {@link InCallService#requestBluetoothAudio(BluetoothDevice)} | 
|  | 3164 | * @param bluetoothDevice The bluetooth device to connect to. | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 3165 | * @deprecated Use {@link #requestCallEndpointChange(CallEndpoint, Executor, OutcomeReceiver)} | 
|  | 3166 | * instead. | 
| Hall Liu | a98f58b5 | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 3167 | */ | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 3168 | @Deprecated | 
| Hall Liu | 2b6a6a3 | 2018-04-02 13:52:57 -0700 | [diff] [blame] | 3169 | public void requestBluetoothAudio(@NonNull BluetoothDevice bluetoothDevice) { | 
| Hall Liu | a98f58b5 | 2017-11-07 17:59:28 -0800 | [diff] [blame] | 3170 | for (Listener l : mListeners) { | 
| Hall Liu | 2b6a6a3 | 2018-04-02 13:52:57 -0700 | [diff] [blame] | 3171 | l.onAudioRouteChanged(this, CallAudioState.ROUTE_BLUETOOTH, | 
|  | 3172 | bluetoothDevice.getAddress()); | 
| Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 3173 | } | 
|  | 3174 | } | 
|  | 3175 |  | 
|  | 3176 | /** | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 3177 | * Request audio routing to a specific CallEndpoint. Clients should not define their own | 
|  | 3178 | * CallEndpoint when requesting a change. Instead, the new endpoint should be one of the valid | 
|  | 3179 | * endpoints provided by {@link #onAvailableCallEndpointsChanged(List)}. | 
|  | 3180 | * When this request is honored, there will be change to the {@link #getCurrentCallEndpoint()}. | 
|  | 3181 | * <p> | 
|  | 3182 | * Used by self-managed {@link ConnectionService}s which wish to change the CallEndpoint for a | 
|  | 3183 | * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.) | 
|  | 3184 | * <p> | 
|  | 3185 | * See also | 
|  | 3186 | * {@link InCallService#requestCallEndpointChange(CallEndpoint, Executor, OutcomeReceiver)}. | 
|  | 3187 | * | 
|  | 3188 | * @param endpoint The call endpoint to use. | 
|  | 3189 | * @param executor The executor of where the callback will execute. | 
|  | 3190 | * @param callback The callback to notify the result of the endpoint change. | 
|  | 3191 | */ | 
|  | 3192 | public final void requestCallEndpointChange(@NonNull CallEndpoint endpoint, | 
|  | 3193 | @NonNull @CallbackExecutor Executor executor, | 
|  | 3194 | @NonNull OutcomeReceiver<Void, CallEndpointException> callback) { | 
|  | 3195 | for (Listener l : mListeners) { | 
|  | 3196 | l.onEndpointChanged(this, endpoint, executor, callback); | 
|  | 3197 | } | 
|  | 3198 | } | 
|  | 3199 |  | 
|  | 3200 | /** | 
|  | 3201 | * Obtains the current CallEndpoint. | 
|  | 3202 | * | 
|  | 3203 | * @return An object encapsulating the CallEndpoint. | 
|  | 3204 | */ | 
|  | 3205 | @NonNull | 
|  | 3206 | public final CallEndpoint getCurrentCallEndpoint() { | 
|  | 3207 | return mCallEndpoint; | 
|  | 3208 | } | 
|  | 3209 |  | 
|  | 3210 | /** | 
| Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 3211 | * Informs listeners that a previously requested RTT session via | 
|  | 3212 | * {@link ConnectionRequest#isRequestingRtt()} or | 
| Hall Liu | 37dfdb0 | 2017-12-04 14:19:30 -0800 | [diff] [blame] | 3213 | * {@link #onStartRtt(RttTextStream)} has succeeded. | 
| Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 3214 | */ | 
|  | 3215 | public final void sendRttInitiationSuccess() { | 
|  | 3216 | mListeners.forEach((l) -> l.onRttInitiationSuccess(Connection.this)); | 
|  | 3217 | } | 
|  | 3218 |  | 
|  | 3219 | /** | 
|  | 3220 | * Informs listeners that a previously requested RTT session via | 
| Hall Liu | 37dfdb0 | 2017-12-04 14:19:30 -0800 | [diff] [blame] | 3221 | * {@link ConnectionRequest#isRequestingRtt()} or {@link #onStartRtt(RttTextStream)} | 
| Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 3222 | * has failed. | 
|  | 3223 | * @param reason One of the reason codes defined in {@link RttModifyStatus}, with the | 
|  | 3224 | *               exception of {@link RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}. | 
| Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 3225 | */ | 
|  | 3226 | public final void sendRttInitiationFailure(int reason) { | 
|  | 3227 | mListeners.forEach((l) -> l.onRttInitiationFailure(Connection.this, reason)); | 
|  | 3228 | } | 
|  | 3229 |  | 
|  | 3230 | /** | 
|  | 3231 | * Informs listeners that a currently active RTT session has been terminated by the remote | 
|  | 3232 | * side of the coll. | 
| Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 3233 | */ | 
|  | 3234 | public final void sendRttSessionRemotelyTerminated() { | 
|  | 3235 | mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this)); | 
|  | 3236 | } | 
|  | 3237 |  | 
|  | 3238 | /** | 
|  | 3239 | * Informs listeners that the remote side of the call has requested an upgrade to include an | 
|  | 3240 | * RTT session in the call. | 
| Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 3241 | */ | 
|  | 3242 | public final void sendRemoteRttRequest() { | 
|  | 3243 | mListeners.forEach((l) -> l.onRemoteRttRequest(Connection.this)); | 
|  | 3244 | } | 
|  | 3245 |  | 
|  | 3246 | /** | 
| yongnamcha | 8ec5624 | 2022-11-28 06:23:02 +0000 | [diff] [blame] | 3247 | * Query the device's location in order to place an Emergency Call. | 
|  | 3248 | * Only SIM call managers can call this method for Connections representing Emergency calls. | 
|  | 3249 | * If a previous location query request is not completed, the new location query request will | 
|  | 3250 | * be rejected and return a QueryLocationException with | 
|  | 3251 | * {@code QueryLocationException#ERROR_PREVIOUS_REQUEST_EXISTS} | 
|  | 3252 | * | 
|  | 3253 | * @param timeoutMillis long: Timeout in millis waiting for query response (MAX:5000, MIN:100). | 
|  | 3254 | * @param provider String: the location provider name, This value cannot be null. | 
|  | 3255 | *                 It is the caller's responsibility to select an enabled provider. The caller | 
|  | 3256 | *                 can use {@link android.location.LocationManager#getProviders(boolean)} | 
|  | 3257 | *                 to choose one of the enabled providers and pass it in. | 
|  | 3258 | * @param executor The executor of where the callback will execute. | 
|  | 3259 | * @param callback The callback to notify the result of queryLocation. | 
|  | 3260 | */ | 
|  | 3261 | public final void queryLocationForEmergency( | 
|  | 3262 | @IntRange(from = 100, to = 5000) long timeoutMillis, | 
|  | 3263 | @NonNull String provider, | 
|  | 3264 | @NonNull @CallbackExecutor Executor executor, | 
|  | 3265 | @NonNull OutcomeReceiver<Location, QueryLocationException> callback) { | 
|  | 3266 | if (provider == null || executor == null || callback == null) { | 
|  | 3267 | throw new IllegalArgumentException("There are arguments that must not be null"); | 
|  | 3268 | } | 
|  | 3269 | if (timeoutMillis < 100 || timeoutMillis > 5000) { | 
|  | 3270 | throw new IllegalArgumentException("The timeoutMillis should be min 100, max 5000"); | 
|  | 3271 | } | 
|  | 3272 | mListeners.forEach((l) -> | 
|  | 3273 | l.onQueryLocation(this, timeoutMillis, provider, executor, callback)); | 
|  | 3274 | } | 
|  | 3275 |  | 
|  | 3276 | /** | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 3277 | * Notifies this Connection that the {@link #getAudioState()} property has a new value. | 
| Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 3278 | * | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 3279 | * @param state The new connection audio state. | 
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 3280 | * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead. | 
|  | 3281 | * @hide | 
| Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 3282 | */ | 
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 3283 | @SystemApi | 
|  | 3284 | @Deprecated | 
| Nancy Chen | 354b2bd | 2014-09-08 18:27:26 -0700 | [diff] [blame] | 3285 | public void onAudioStateChanged(AudioState state) {} | 
| Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 3286 |  | 
|  | 3287 | /** | 
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 3288 | * Notifies this Connection that the {@link #getCallAudioState()} property has a new value. | 
|  | 3289 | * | 
|  | 3290 | * @param state The new connection audio state. | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 3291 | * @deprecated Use {@link #onCallEndpointChanged(CallEndpoint)}, | 
|  | 3292 | * {@link #onAvailableCallEndpointsChanged(List)} and | 
|  | 3293 | * {@link #onMuteStateChanged(boolean)} instead. | 
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 3294 | */ | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 3295 | @Deprecated | 
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 3296 | public void onCallAudioStateChanged(CallAudioState state) {} | 
|  | 3297 |  | 
|  | 3298 | /** | 
| Junho | edf3d82 | 2022-11-24 09:26:37 +0000 | [diff] [blame] | 3299 | * Notifies this Connection that the audio endpoint has been changed. | 
|  | 3300 | * | 
|  | 3301 | * @param callEndpoint The current CallEndpoint. | 
|  | 3302 | */ | 
|  | 3303 | public void onCallEndpointChanged(@NonNull CallEndpoint callEndpoint) {} | 
|  | 3304 |  | 
|  | 3305 | /** | 
|  | 3306 | * Notifies this Connection that the available call endpoints have been changed. | 
|  | 3307 | * | 
|  | 3308 | * @param availableEndpoints The set of available CallEndpoint. | 
|  | 3309 | */ | 
|  | 3310 | public void onAvailableCallEndpointsChanged(@NonNull List<CallEndpoint> availableEndpoints) {} | 
|  | 3311 |  | 
|  | 3312 | /** | 
|  | 3313 | * Notifies this Connection that its audio mute state has been changed. | 
|  | 3314 | * | 
|  | 3315 | * @param isMuted The current mute state. | 
|  | 3316 | */ | 
|  | 3317 | public void onMuteStateChanged(boolean isMuted) {} | 
|  | 3318 |  | 
|  | 3319 | /** | 
| Grace Jia | e99fde9 | 2021-01-19 14:58:01 -0800 | [diff] [blame] | 3320 | * Inform this Connection when it will or will not be tracked by an {@link InCallService} which | 
|  | 3321 | * can provide an InCall UI. | 
|  | 3322 | * This is primarily intended for use by Connections reported by self-managed | 
|  | 3323 | * {@link ConnectionService} which typically maintain their own UI. | 
|  | 3324 | * | 
|  | 3325 | * @param isUsingAlternativeUi Indicates whether an InCallService that can provide InCall UI is | 
|  | 3326 | *                             currently tracking the self-managed call. | 
|  | 3327 | */ | 
|  | 3328 | public void onUsingAlternativeUi(boolean isUsingAlternativeUi) {} | 
|  | 3329 |  | 
|  | 3330 | /** | 
|  | 3331 | * Inform this Conenection when it will or will not be tracked by an non-UI | 
|  | 3332 | * {@link InCallService}. | 
|  | 3333 | * | 
|  | 3334 | * @param isTracked Indicates whether an non-UI InCallService is currently tracking the | 
|  | 3335 | *                 self-managed call. | 
|  | 3336 | */ | 
|  | 3337 | public void onTrackedByNonUiService(boolean isTracked) {} | 
|  | 3338 |  | 
|  | 3339 | /** | 
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 3340 | * Notifies this Connection of an internal state change. This method is called after the | 
|  | 3341 | * state is changed. | 
| Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 3342 | * | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 3343 | * @param state The new state, one of the {@code STATE_*} constants. | 
| Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 3344 | */ | 
| Nancy Chen | 354b2bd | 2014-09-08 18:27:26 -0700 | [diff] [blame] | 3345 | public void onStateChanged(int state) {} | 
| Ihab Awad | f835897 | 2014-05-28 16:46:42 -0700 | [diff] [blame] | 3346 |  | 
|  | 3347 | /** | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 3348 | * Notifies this Connection of a request to play a DTMF tone. | 
|  | 3349 | * | 
|  | 3350 | * @param c A DTMF character. | 
|  | 3351 | */ | 
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 3352 | public void onPlayDtmfTone(char c) {} | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 3353 |  | 
|  | 3354 | /** | 
|  | 3355 | * Notifies this Connection of a request to stop any currently playing DTMF tones. | 
|  | 3356 | */ | 
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 3357 | public void onStopDtmfTone() {} | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 3358 |  | 
|  | 3359 | /** | 
|  | 3360 | * Notifies this Connection of a request to disconnect. | 
|  | 3361 | */ | 
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 3362 | public void onDisconnect() {} | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 3363 |  | 
|  | 3364 | /** | 
| Tyler Gunn | 3b4b1dc | 2014-11-04 14:53:37 -0800 | [diff] [blame] | 3365 | * Notifies this Connection of a request to disconnect a participant of the conference managed | 
|  | 3366 | * by the connection. | 
|  | 3367 | * | 
|  | 3368 | * @param endpoint the {@link Uri} of the participant to disconnect. | 
|  | 3369 | * @hide | 
|  | 3370 | */ | 
|  | 3371 | public void onDisconnectConferenceParticipant(Uri endpoint) {} | 
|  | 3372 |  | 
|  | 3373 | /** | 
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 3374 | * Notifies this Connection of a request to separate from its parent conference. | 
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 3375 | */ | 
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 3376 | public void onSeparate() {} | 
| Santos Cordon | b693998 | 2014-06-04 20:20:58 -0700 | [diff] [blame] | 3377 |  | 
|  | 3378 | /** | 
| Tyler Gunn | 0c62ef0 | 2020-02-11 14:39:43 -0800 | [diff] [blame] | 3379 | * Supports initiation of a conference call by directly adding participants to an ongoing call. | 
| Ravi Paluri | 404babb | 2020-01-23 19:02:44 +0530 | [diff] [blame] | 3380 | * | 
|  | 3381 | * @param participants with which conference call will be formed. | 
|  | 3382 | */ | 
|  | 3383 | public void onAddConferenceParticipants(@NonNull List<Uri> participants) {} | 
|  | 3384 |  | 
|  | 3385 | /** | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 3386 | * Notifies this Connection of a request to abort. | 
|  | 3387 | */ | 
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 3388 | public void onAbort() {} | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 3389 |  | 
|  | 3390 | /** | 
| Thomas Stuart | 792a50a | 2023-08-14 11:07:17 -0700 | [diff] [blame^] | 3391 | * Notifies this Connection of a request to hold. {@link Connection#setOnHold} should be within | 
|  | 3392 | * the onHold() body in order to transition the call state to {@link Connection#STATE_HOLDING}. | 
|  | 3393 | * <p> | 
|  | 3394 | * Note: If the Connection does not transition to  {@link Connection#STATE_HOLDING} within 2 | 
|  | 3395 | * seconds, the call will be disconnected. | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 3396 | */ | 
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 3397 | public void onHold() {} | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 3398 |  | 
|  | 3399 | /** | 
|  | 3400 | * Notifies this Connection of a request to exit a hold state. | 
|  | 3401 | */ | 
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 3402 | public void onUnhold() {} | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 3403 |  | 
|  | 3404 | /** | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 3405 | * Notifies this Connection, which is in {@link #STATE_RINGING}, of | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 3406 | * a request to accept. | 
| Tyler Gunn | 7c3ddcf | 2018-02-08 11:28:33 -0800 | [diff] [blame] | 3407 | * <p> | 
|  | 3408 | * For managed {@link ConnectionService}s, this will be called when the user answers a call via | 
|  | 3409 | * the default dialer's {@link InCallService}. | 
|  | 3410 | * <p> | 
|  | 3411 | * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the | 
|  | 3412 | * Telecom framework may request that the call is answered in the following circumstances: | 
|  | 3413 | * <ul> | 
|  | 3414 | *     <li>The user chooses to answer an incoming call via a Bluetooth device.</li> | 
|  | 3415 | *     <li>A car mode {@link InCallService} is in use which has declared | 
|  | 3416 | *     {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest.  Such an | 
|  | 3417 | *     {@link InCallService} will be able to see calls from self-managed | 
|  | 3418 | *     {@link ConnectionService}s, and will be able to display an incoming call UI on their | 
|  | 3419 | *     behalf.</li> | 
|  | 3420 | * </ul> | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 3421 | * @param videoState The video state in which to answer the connection. | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 3422 | */ | 
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 3423 | public void onAnswer(int videoState) {} | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 3424 |  | 
|  | 3425 | /** | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 3426 | * Notifies this Connection, which is in {@link #STATE_RINGING}, of | 
| Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 3427 | * a request to accept. | 
| Tyler Gunn | 7c3ddcf | 2018-02-08 11:28:33 -0800 | [diff] [blame] | 3428 | * <p> | 
|  | 3429 | * For managed {@link ConnectionService}s, this will be called when the user answers a call via | 
|  | 3430 | * the default dialer's {@link InCallService}. | 
|  | 3431 | * <p> | 
|  | 3432 | * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the | 
|  | 3433 | * Telecom framework may request that the call is answered in the following circumstances: | 
|  | 3434 | * <ul> | 
|  | 3435 | *     <li>The user chooses to answer an incoming call via a Bluetooth device.</li> | 
|  | 3436 | *     <li>A car mode {@link InCallService} is in use which has declared | 
|  | 3437 | *     {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest.  Such an | 
|  | 3438 | *     {@link InCallService} will be able to see calls from self-managed | 
|  | 3439 | *     {@link ConnectionService}s, and will be able to display an incoming call UI on their | 
|  | 3440 | *     behalf.</li> | 
|  | 3441 | * </ul> | 
| Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 3442 | */ | 
|  | 3443 | public void onAnswer() { | 
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 3444 | onAnswer(VideoProfile.STATE_AUDIO_ONLY); | 
| Tyler Gunn | be74de0 | 2014-08-29 14:51:48 -0700 | [diff] [blame] | 3445 | } | 
|  | 3446 |  | 
|  | 3447 | /** | 
|  | 3448 | * Notifies this Connection, which is in {@link #STATE_RINGING}, of | 
| Pooja Jain | d34698d | 2017-12-28 14:15:31 +0530 | [diff] [blame] | 3449 | * a request to deflect. | 
|  | 3450 | */ | 
|  | 3451 | public void onDeflect(Uri address) {} | 
|  | 3452 |  | 
|  | 3453 | /** | 
|  | 3454 | * Notifies this Connection, which is in {@link #STATE_RINGING}, of | 
| Santos Cordon | d34e571 | 2014-08-05 18:54:03 +0000 | [diff] [blame] | 3455 | * a request to reject. | 
| Tyler Gunn | 7c3ddcf | 2018-02-08 11:28:33 -0800 | [diff] [blame] | 3456 | * <p> | 
|  | 3457 | * For managed {@link ConnectionService}s, this will be called when the user rejects a call via | 
|  | 3458 | * the default dialer's {@link InCallService}. | 
|  | 3459 | * <p> | 
|  | 3460 | * Although a self-managed {@link ConnectionService} provides its own incoming call UI, the | 
|  | 3461 | * Telecom framework may request that the call is rejected in the following circumstances: | 
|  | 3462 | * <ul> | 
|  | 3463 | *     <li>The user chooses to reject an incoming call via a Bluetooth device.</li> | 
|  | 3464 | *     <li>A car mode {@link InCallService} is in use which has declared | 
|  | 3465 | *     {@link TelecomManager#METADATA_INCLUDE_SELF_MANAGED_CALLS} in its manifest.  Such an | 
|  | 3466 | *     {@link InCallService} will be able to see calls from self-managed | 
|  | 3467 | *     {@link ConnectionService}s, and will be able to display an incoming call UI on their | 
|  | 3468 | *     behalf.</li> | 
|  | 3469 | * </ul> | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 3470 | */ | 
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 3471 | public void onReject() {} | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 3472 |  | 
| Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 3473 | /** | 
| Tyler Gunn | facfdee | 2020-01-23 13:10:37 -0800 | [diff] [blame] | 3474 | * Notifies this Connection, which is in {@link #STATE_RINGING}, of a request to reject. | 
|  | 3475 | * <p> | 
|  | 3476 | * For managed {@link ConnectionService}s, this will be called when the user rejects a call via | 
|  | 3477 | * the default dialer's {@link InCallService} using {@link Call#reject(int)}. | 
|  | 3478 | * @param rejectReason the reason the user provided for rejecting the call. | 
|  | 3479 | */ | 
|  | 3480 | public void onReject(@android.telecom.Call.RejectReason int rejectReason) { | 
|  | 3481 | // to be implemented by ConnectionService. | 
|  | 3482 | } | 
|  | 3483 |  | 
|  | 3484 | /** | 
| Hall Liu | 712acbe | 2016-03-14 16:38:56 -0700 | [diff] [blame] | 3485 | * Notifies this Connection, which is in {@link #STATE_RINGING}, of | 
|  | 3486 | * a request to reject with a message. | 
| Bryce Lee | 8190168 | 2015-08-28 16:38:02 -0700 | [diff] [blame] | 3487 | */ | 
|  | 3488 | public void onReject(String replyMessage) {} | 
|  | 3489 |  | 
|  | 3490 | /** | 
| Ravi Paluri | f4b38e7 | 2020-02-05 12:35:41 +0530 | [diff] [blame] | 3491 | * Notifies this Connection, a request to transfer to a target number. | 
|  | 3492 | * @param number the number to transfer this {@link Connection} to. | 
|  | 3493 | * @param isConfirmationRequired when {@code true}, the {@link ConnectionService} | 
|  | 3494 | * should wait until the transfer has successfully completed before disconnecting | 
|  | 3495 | * the current {@link Connection}. | 
|  | 3496 | * When {@code false}, the {@link ConnectionService} should signal the network to | 
|  | 3497 | * perform the transfer, but should immediately disconnect the call regardless of | 
|  | 3498 | * the outcome of the transfer. | 
|  | 3499 | * @hide | 
|  | 3500 | */ | 
|  | 3501 | public void onTransfer(@NonNull Uri number, boolean isConfirmationRequired) {} | 
|  | 3502 |  | 
|  | 3503 | /** | 
|  | 3504 | * Notifies this Connection, a request to transfer to another Connection. | 
|  | 3505 | * @param otherConnection the {@link Connection} to transfer this call to. | 
|  | 3506 | * @hide | 
|  | 3507 | */ | 
|  | 3508 | public void onTransfer(@NonNull Connection otherConnection) {} | 
|  | 3509 |  | 
|  | 3510 | /** | 
| Tyler Gunn | 06f0616 | 2018-06-18 11:24:15 -0700 | [diff] [blame] | 3511 | * Notifies this Connection of a request to silence the ringer. | 
|  | 3512 | * <p> | 
|  | 3513 | * The ringer may be silenced by any of the following methods: | 
|  | 3514 | * <ul> | 
|  | 3515 | *     <li>{@link TelecomManager#silenceRinger()}</li> | 
|  | 3516 | *     <li>The user presses the volume-down button while a call is ringing.</li> | 
|  | 3517 | * </ul> | 
|  | 3518 | * <p> | 
|  | 3519 | * Self-managed {@link ConnectionService} implementations should override this method in their | 
|  | 3520 | * {@link Connection} implementation and implement logic to silence their app's ringtone.  If | 
|  | 3521 | * your app set the ringtone as part of the incoming call {@link Notification} (see | 
|  | 3522 | * {@link #onShowIncomingCallUi()}), it should re-post the notification now, except call | 
|  | 3523 | * {@link android.app.Notification.Builder#setOnlyAlertOnce(boolean)} with {@code true}.  This | 
|  | 3524 | * will ensure the ringtone sound associated with your {@link android.app.NotificationChannel} | 
|  | 3525 | * stops playing. | 
| Bryce Lee | cac5077 | 2015-11-17 15:13:29 -0800 | [diff] [blame] | 3526 | */ | 
|  | 3527 | public void onSilence() {} | 
|  | 3528 |  | 
|  | 3529 | /** | 
| Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 3530 | * Notifies this Connection whether the user wishes to proceed with the post-dial DTMF codes. | 
|  | 3531 | */ | 
| Santos Cordon | f295110 | 2014-07-20 19:06:29 -0700 | [diff] [blame] | 3532 | public void onPostDialContinue(boolean proceed) {} | 
| Evan Charlton | 6dea4ac | 2014-06-03 14:07:13 -0700 | [diff] [blame] | 3533 |  | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 3534 | /** | 
|  | 3535 | * Notifies this Connection of a request to pull an external call to the local device. | 
|  | 3536 | * <p> | 
|  | 3537 | * The {@link InCallService} issues a request to pull an external call to the local device via | 
|  | 3538 | * {@link Call#pullExternalCall()}. | 
|  | 3539 | * <p> | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 3540 | * For a Connection to be pulled, both the {@link Connection#CAPABILITY_CAN_PULL_CALL} | 
|  | 3541 | * capability and {@link Connection#PROPERTY_IS_EXTERNAL_CALL} property bits must be set. | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 3542 | * <p> | 
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 3543 | * For more information on external calls, see {@link Connection#PROPERTY_IS_EXTERNAL_CALL}. | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 3544 | */ | 
|  | 3545 | public void onPullExternalCall() {} | 
|  | 3546 |  | 
|  | 3547 | /** | 
|  | 3548 | * Notifies this Connection of a {@link Call} event initiated from an {@link InCallService}. | 
|  | 3549 | * <p> | 
|  | 3550 | * The {@link InCallService} issues a Call event via {@link Call#sendCallEvent(String, Bundle)}. | 
|  | 3551 | * <p> | 
| Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 3552 | * Where possible, the Connection should make an attempt to handle {@link Call} events which | 
|  | 3553 | * are part of the {@code android.telecom.*} namespace.  The Connection should ignore any events | 
|  | 3554 | * it does not wish to handle.  Unexpected events should be handled gracefully, as it is | 
|  | 3555 | * possible that a {@link InCallService} has defined its own Call events which a Connection is | 
|  | 3556 | * not aware of. | 
|  | 3557 | * <p> | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 3558 | * See also {@link Call#sendCallEvent(String, Bundle)}. | 
|  | 3559 | * | 
|  | 3560 | * @param event The call event. | 
|  | 3561 | * @param extras Extras associated with the call event. | 
|  | 3562 | */ | 
|  | 3563 | public void onCallEvent(String event, Bundle extras) {} | 
|  | 3564 |  | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 3565 | /** | 
| Tyler Gunn | 79bc1ec | 2018-01-22 15:17:54 -0800 | [diff] [blame] | 3566 | * Notifies this {@link Connection} that a handover has completed. | 
|  | 3567 | * <p> | 
|  | 3568 | * A handover is initiated with {@link android.telecom.Call#handoverTo(PhoneAccountHandle, int, | 
|  | 3569 | * Bundle)} on the initiating side of the handover, and | 
|  | 3570 | * {@link TelecomManager#acceptHandover(Uri, int, PhoneAccountHandle)}. | 
|  | 3571 | */ | 
|  | 3572 | public void onHandoverComplete() {} | 
|  | 3573 |  | 
|  | 3574 | /** | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 3575 | * Notifies this {@link Connection} of a change to the extras made outside the | 
|  | 3576 | * {@link ConnectionService}. | 
|  | 3577 | * <p> | 
|  | 3578 | * These extras changes can originate from Telecom itself, or from an {@link InCallService} via | 
|  | 3579 | * the {@link android.telecom.Call#putExtras(Bundle)} and | 
|  | 3580 | * {@link Call#removeExtras(List)}. | 
|  | 3581 | * | 
|  | 3582 | * @param extras The new extras bundle. | 
|  | 3583 | */ | 
|  | 3584 | public void onExtrasChanged(Bundle extras) {} | 
|  | 3585 |  | 
| Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 3586 | /** | 
|  | 3587 | * Notifies this {@link Connection} that its {@link ConnectionService} is responsible for | 
|  | 3588 | * displaying its incoming call user interface for the {@link Connection}. | 
|  | 3589 | * <p> | 
|  | 3590 | * Will only be called for incoming calls added via a self-managed {@link ConnectionService} | 
|  | 3591 | * (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}), where the {@link ConnectionService} | 
|  | 3592 | * should show its own incoming call user interface. | 
|  | 3593 | * <p> | 
|  | 3594 | * Where there are ongoing calls in other self-managed {@link ConnectionService}s, or in a | 
| Tyler Gunn | 7c3ddcf | 2018-02-08 11:28:33 -0800 | [diff] [blame] | 3595 | * regular {@link ConnectionService}, and it is not possible to hold these other calls, the | 
|  | 3596 | * Telecom framework will display its own incoming call user interface to allow the user to | 
|  | 3597 | * choose whether to answer the new incoming call and disconnect other ongoing calls, or to | 
|  | 3598 | * reject the new incoming call. | 
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 3599 | * <p> | 
|  | 3600 | * You should trigger the display of the incoming call user interface for your application by | 
|  | 3601 | * showing a {@link Notification} with a full-screen {@link Intent} specified. | 
| Tyler Gunn | 06f0616 | 2018-06-18 11:24:15 -0700 | [diff] [blame] | 3602 | * | 
|  | 3603 | * In your application code, you should create a {@link android.app.NotificationChannel} for | 
|  | 3604 | * incoming call notifications from your app: | 
|  | 3605 | * <pre><code> | 
|  | 3606 | * NotificationChannel channel = new NotificationChannel(YOUR_CHANNEL_ID, "Incoming Calls", | 
|  | 3607 | *          NotificationManager.IMPORTANCE_MAX); | 
|  | 3608 | * // other channel setup stuff goes here. | 
|  | 3609 | * | 
|  | 3610 | * // We'll use the default system ringtone for our incoming call notification channel.  You can | 
|  | 3611 | * // use your own audio resource here. | 
|  | 3612 | * Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE); | 
|  | 3613 | * channel.setSound(ringtoneUri, new AudioAttributes.Builder() | 
|  | 3614 | *          // Setting the AudioAttributes is important as it identifies the purpose of your | 
|  | 3615 | *          // notification sound. | 
|  | 3616 | *          .setUsage(AudioAttributes.USAGE_NOTIFICATION_RINGTONE) | 
|  | 3617 | *          .setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION) | 
|  | 3618 | *      .build()); | 
|  | 3619 | * | 
|  | 3620 | * NotificationManager mgr = getSystemService(NotificationManager.class); | 
|  | 3621 | * mgr.createNotificationChannel(channel); | 
|  | 3622 | * </code></pre> | 
|  | 3623 | * When it comes time to post a notification for your incoming call, ensure it uses your | 
|  | 3624 | * incoming call {@link android.app.NotificationChannel}. | 
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 3625 | * <pre><code> | 
|  | 3626 | *     // Create an intent which triggers your fullscreen incoming call user interface. | 
|  | 3627 | *     Intent intent = new Intent(Intent.ACTION_MAIN, null); | 
|  | 3628 | *     intent.setFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_ACTIVITY_NEW_TASK); | 
|  | 3629 | *     intent.setClass(context, YourIncomingCallActivity.class); | 
| Ashwini Oruganti | f8191e8 | 2021-01-07 12:04:25 -0800 | [diff] [blame] | 3630 | *     PendingIntent pendingIntent = PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_MUTABLE_UNAUDITED); | 
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 3631 | * | 
|  | 3632 | *     // Build the notification as an ongoing high priority item; this ensures it will show as | 
|  | 3633 | *     // a heads up notification which slides down over top of the current content. | 
|  | 3634 | *     final Notification.Builder builder = new Notification.Builder(context); | 
|  | 3635 | *     builder.setOngoing(true); | 
|  | 3636 | *     builder.setPriority(Notification.PRIORITY_HIGH); | 
|  | 3637 | * | 
|  | 3638 | *     // Set notification content intent to take user to fullscreen UI if user taps on the | 
|  | 3639 | *     // notification body. | 
|  | 3640 | *     builder.setContentIntent(pendingIntent); | 
|  | 3641 | *     // Set full screen intent to trigger display of the fullscreen UI when the notification | 
|  | 3642 | *     // manager deems it appropriate. | 
|  | 3643 | *     builder.setFullScreenIntent(pendingIntent, true); | 
|  | 3644 | * | 
|  | 3645 | *     // Setup notification content. | 
|  | 3646 | *     builder.setSmallIcon( yourIconResourceId ); | 
|  | 3647 | *     builder.setContentTitle("Your notification title"); | 
|  | 3648 | *     builder.setContentText("Your notification content."); | 
|  | 3649 | * | 
| Tyler Gunn | 06f0616 | 2018-06-18 11:24:15 -0700 | [diff] [blame] | 3650 | *     // Set notification as insistent to cause your ringtone to loop. | 
|  | 3651 | *     Notification notification = builder.build(); | 
|  | 3652 | *     notification.flags |= Notification.FLAG_INSISTENT; | 
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 3653 | * | 
| Tyler Gunn | 06f0616 | 2018-06-18 11:24:15 -0700 | [diff] [blame] | 3654 | *     // Use builder.addAction(..) to add buttons to answer or reject the call. | 
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 3655 | *     NotificationManager notificationManager = mContext.getSystemService( | 
|  | 3656 | *         NotificationManager.class); | 
| Tyler Gunn | 06f0616 | 2018-06-18 11:24:15 -0700 | [diff] [blame] | 3657 | *     notificationManager.notify(YOUR_CHANNEL_ID, YOUR_TAG, YOUR_ID, notification); | 
| Tyler Gunn | 159f35c | 2017-03-02 09:28:37 -0800 | [diff] [blame] | 3658 | * </code></pre> | 
| Tyler Gunn | f503543 | 2017-01-09 09:43:12 -0800 | [diff] [blame] | 3659 | */ | 
|  | 3660 | public void onShowIncomingCallUi() {} | 
|  | 3661 |  | 
| Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 3662 | /** | 
|  | 3663 | * Notifies this {@link Connection} that the user has requested an RTT session. | 
|  | 3664 | * The connection service should call {@link #sendRttInitiationSuccess} or | 
|  | 3665 | * {@link #sendRttInitiationFailure} to inform Telecom of the success or failure of the | 
|  | 3666 | * request, respectively. | 
|  | 3667 | * @param rttTextStream The object that should be used to send text to or receive text from | 
|  | 3668 | *                      the in-call app. | 
| Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 3669 | */ | 
|  | 3670 | public void onStartRtt(@NonNull RttTextStream rttTextStream) {} | 
|  | 3671 |  | 
|  | 3672 | /** | 
|  | 3673 | * Notifies this {@link Connection} that it should terminate any existing RTT communication | 
|  | 3674 | * channel. No response to Telecom is needed for this method. | 
| Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 3675 | */ | 
|  | 3676 | public void onStopRtt() {} | 
|  | 3677 |  | 
|  | 3678 | /** | 
|  | 3679 | * Notifies this connection of a response to a previous remotely-initiated RTT upgrade | 
|  | 3680 | * request sent via {@link #sendRemoteRttRequest}. Acceptance of the request is | 
|  | 3681 | * indicated by the supplied {@link RttTextStream} being non-null, and rejection is | 
|  | 3682 | * indicated by {@code rttTextStream} being {@code null} | 
| Hall Liu | b64ac4c | 2017-02-06 10:49:48 -0800 | [diff] [blame] | 3683 | * @param rttTextStream The object that should be used to send text to or receive text from | 
|  | 3684 | *                      the in-call app. | 
|  | 3685 | */ | 
|  | 3686 | public void handleRttUpgradeResponse(@Nullable RttTextStream rttTextStream) {} | 
|  | 3687 |  | 
| Hall Liu | 49cabcc | 2021-01-15 11:41:48 -0800 | [diff] [blame] | 3688 | /** | 
| Hall Liu | 7390314 | 2021-02-18 18:41:41 -0800 | [diff] [blame] | 3689 | * Information provided to a {@link Connection} upon completion of call filtering in Telecom. | 
|  | 3690 | * | 
|  | 3691 | * @hide | 
|  | 3692 | */ | 
|  | 3693 | @SystemApi | 
|  | 3694 | public static final class CallFilteringCompletionInfo implements Parcelable { | 
|  | 3695 | private final boolean mIsBlocked; | 
|  | 3696 | private final boolean mIsInContacts; | 
|  | 3697 | private final CallScreeningService.CallResponse mCallResponse; | 
|  | 3698 | private final ComponentName mCallScreeningComponent; | 
|  | 3699 |  | 
|  | 3700 | /** | 
|  | 3701 | * Constructor for {@link CallFilteringCompletionInfo} | 
|  | 3702 | * | 
|  | 3703 | * @param isBlocked Whether any part of the call filtering process indicated that this call | 
|  | 3704 | *                  should be blocked. | 
|  | 3705 | * @param isInContacts Whether the caller is in the user's contacts. | 
|  | 3706 | * @param callResponse The instance of {@link CallScreeningService.CallResponse} provided | 
|  | 3707 | *                     by the {@link CallScreeningService} that processed this call, or | 
|  | 3708 | *                     {@code null} if no call screening service ran. | 
|  | 3709 | * @param callScreeningComponent The component of the {@link CallScreeningService} | 
|  | 3710 | *                                 that processed this call, or {@link null} if no | 
|  | 3711 | *                                 call screening service ran. | 
|  | 3712 | */ | 
|  | 3713 | public CallFilteringCompletionInfo(boolean isBlocked, boolean isInContacts, | 
|  | 3714 | @Nullable CallScreeningService.CallResponse callResponse, | 
|  | 3715 | @Nullable ComponentName callScreeningComponent) { | 
|  | 3716 | mIsBlocked = isBlocked; | 
|  | 3717 | mIsInContacts = isInContacts; | 
|  | 3718 | mCallResponse = callResponse; | 
|  | 3719 | mCallScreeningComponent = callScreeningComponent; | 
|  | 3720 | } | 
|  | 3721 |  | 
|  | 3722 | /** @hide */ | 
|  | 3723 | protected CallFilteringCompletionInfo(Parcel in) { | 
|  | 3724 | mIsBlocked = in.readByte() != 0; | 
|  | 3725 | mIsInContacts = in.readByte() != 0; | 
|  | 3726 | CallScreeningService.ParcelableCallResponse response | 
| Bernardo Rufino | 90bb370 | 2021-12-07 20:01:45 +0000 | [diff] [blame] | 3727 | = in.readParcelable(CallScreeningService.class.getClassLoader(), android.telecom.CallScreeningService.ParcelableCallResponse.class); | 
| Hall Liu | 7390314 | 2021-02-18 18:41:41 -0800 | [diff] [blame] | 3728 | mCallResponse = response == null ? null : response.toCallResponse(); | 
| Bernardo Rufino | 90bb370 | 2021-12-07 20:01:45 +0000 | [diff] [blame] | 3729 | mCallScreeningComponent = in.readParcelable(ComponentName.class.getClassLoader(), android.content.ComponentName.class); | 
| Hall Liu | 7390314 | 2021-02-18 18:41:41 -0800 | [diff] [blame] | 3730 | } | 
|  | 3731 |  | 
|  | 3732 | @NonNull | 
|  | 3733 | public static final Creator<CallFilteringCompletionInfo> CREATOR = | 
|  | 3734 | new Creator<CallFilteringCompletionInfo>() { | 
|  | 3735 | @Override | 
|  | 3736 | public CallFilteringCompletionInfo createFromParcel(Parcel in) { | 
|  | 3737 | return new CallFilteringCompletionInfo(in); | 
|  | 3738 | } | 
|  | 3739 |  | 
|  | 3740 | @Override | 
|  | 3741 | public CallFilteringCompletionInfo[] newArray(int size) { | 
|  | 3742 | return new CallFilteringCompletionInfo[size]; | 
|  | 3743 | } | 
|  | 3744 | }; | 
|  | 3745 |  | 
|  | 3746 | /** | 
|  | 3747 | * @return Whether any part of the call filtering process indicated that this call should be | 
|  | 3748 | *         blocked. | 
|  | 3749 | */ | 
|  | 3750 | public boolean isBlocked() { | 
|  | 3751 | return mIsBlocked; | 
|  | 3752 | } | 
|  | 3753 |  | 
|  | 3754 | /** | 
|  | 3755 | * @return Whether the caller is in the user's contacts. | 
|  | 3756 | */ | 
|  | 3757 | public boolean isInContacts() { | 
|  | 3758 | return mIsInContacts; | 
|  | 3759 | } | 
|  | 3760 |  | 
|  | 3761 | /** | 
|  | 3762 | * @return The instance of {@link CallScreeningService.CallResponse} provided | 
|  | 3763 | *         by the {@link CallScreeningService} that processed this | 
|  | 3764 | *         call, or {@code null} if no call screening service ran. | 
|  | 3765 | */ | 
|  | 3766 | public @Nullable CallScreeningService.CallResponse getCallResponse() { | 
|  | 3767 | return mCallResponse; | 
|  | 3768 | } | 
|  | 3769 |  | 
|  | 3770 | /** | 
|  | 3771 | * @return The component of the {@link CallScreeningService} | 
|  | 3772 | *         that processed this call, or {@code null} if no call screening service ran. | 
|  | 3773 | */ | 
|  | 3774 | public @Nullable ComponentName getCallScreeningComponent() { | 
|  | 3775 | return mCallScreeningComponent; | 
|  | 3776 | } | 
|  | 3777 |  | 
|  | 3778 | @Override | 
|  | 3779 | public int describeContents() { | 
|  | 3780 | return 0; | 
|  | 3781 | } | 
|  | 3782 |  | 
|  | 3783 | @Override | 
|  | 3784 | public String toString() { | 
|  | 3785 | return "CallFilteringCompletionInfo{" + | 
|  | 3786 | "mIsBlocked=" + mIsBlocked + | 
|  | 3787 | ", mIsInContacts=" + mIsInContacts + | 
|  | 3788 | ", mCallResponse=" + mCallResponse + | 
|  | 3789 | ", mCallScreeningPackageName='" + mCallScreeningComponent + '\'' + | 
|  | 3790 | '}'; | 
|  | 3791 | } | 
|  | 3792 |  | 
|  | 3793 | /** @hide */ | 
|  | 3794 | @Override | 
|  | 3795 | public void writeToParcel(Parcel dest, int flags) { | 
|  | 3796 | dest.writeByte((byte) (mIsBlocked ? 1 : 0)); | 
|  | 3797 | dest.writeByte((byte) (mIsInContacts ? 1 : 0)); | 
|  | 3798 | dest.writeParcelable(mCallResponse == null ? null : mCallResponse.toParcelable(), 0); | 
|  | 3799 | dest.writeParcelable(mCallScreeningComponent, 0); | 
|  | 3800 | } | 
|  | 3801 | } | 
|  | 3802 |  | 
|  | 3803 | /** | 
| Hall Liu | 49cabcc | 2021-01-15 11:41:48 -0800 | [diff] [blame] | 3804 | * Indicates that call filtering in Telecom is complete | 
|  | 3805 | * | 
|  | 3806 | * This method is called for a connection created via | 
|  | 3807 | * {@link ConnectionService#onCreateIncomingConnection} when call filtering completes in | 
|  | 3808 | * Telecom, including checking the blocked number db, per-contact settings, and custom call | 
|  | 3809 | * filtering apps. | 
|  | 3810 | * | 
| Hall Liu | 7390314 | 2021-02-18 18:41:41 -0800 | [diff] [blame] | 3811 | * @param callFilteringCompletionInfo Info provided by Telecom on the results of call filtering. | 
| Hall Liu | 49cabcc | 2021-01-15 11:41:48 -0800 | [diff] [blame] | 3812 | * @hide | 
|  | 3813 | */ | 
|  | 3814 | @SystemApi | 
|  | 3815 | @RequiresPermission(Manifest.permission.READ_CONTACTS) | 
| Hall Liu | 7390314 | 2021-02-18 18:41:41 -0800 | [diff] [blame] | 3816 | public void onCallFilteringCompleted( | 
|  | 3817 | @NonNull CallFilteringCompletionInfo callFilteringCompletionInfo) { } | 
| Hall Liu | 49cabcc | 2021-01-15 11:41:48 -0800 | [diff] [blame] | 3818 |  | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 3819 | static String toLogSafePhoneNumber(String number) { | 
|  | 3820 | // For unknown number, log empty string. | 
|  | 3821 | if (number == null) { | 
|  | 3822 | return ""; | 
|  | 3823 | } | 
|  | 3824 |  | 
|  | 3825 | if (PII_DEBUG) { | 
|  | 3826 | // When PII_DEBUG is true we emit PII. | 
|  | 3827 | return number; | 
|  | 3828 | } | 
|  | 3829 |  | 
|  | 3830 | // Do exactly same thing as Uri#toSafeString() does, which will enable us to compare | 
|  | 3831 | // sanitized phone numbers. | 
|  | 3832 | StringBuilder builder = new StringBuilder(); | 
|  | 3833 | for (int i = 0; i < number.length(); i++) { | 
|  | 3834 | char c = number.charAt(i); | 
|  | 3835 | if (c == '-' || c == '@' || c == '.') { | 
|  | 3836 | builder.append(c); | 
|  | 3837 | } else { | 
|  | 3838 | builder.append('x'); | 
|  | 3839 | } | 
|  | 3840 | } | 
|  | 3841 | return builder.toString(); | 
|  | 3842 | } | 
|  | 3843 |  | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 3844 | private void setState(int state) { | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 3845 | checkImmutable(); | 
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 3846 | if (mState == STATE_DISCONNECTED && mState != state) { | 
|  | 3847 | Log.d(this, "Connection already DISCONNECTED; cannot transition out of this state."); | 
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 3848 | return; | 
| Sailesh Nepal | 400cc48 | 2014-06-26 12:04:00 -0700 | [diff] [blame] | 3849 | } | 
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 3850 | if (mState != state) { | 
|  | 3851 | Log.d(this, "setState: %s", stateToString(state)); | 
|  | 3852 | mState = state; | 
| Nancy Chen | 354b2bd | 2014-09-08 18:27:26 -0700 | [diff] [blame] | 3853 | onStateChanged(state); | 
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 3854 | for (Listener l : mListeners) { | 
|  | 3855 | l.onStateChanged(this, state); | 
|  | 3856 | } | 
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 3857 | } | 
|  | 3858 | } | 
|  | 3859 |  | 
| Sailesh Nepal | cf7020b | 2014-08-20 10:07:19 -0700 | [diff] [blame] | 3860 | private static class FailureSignalingConnection extends Connection { | 
| Ihab Awad | 90e34e3 | 2014-12-01 16:23:17 -0800 | [diff] [blame] | 3861 | private boolean mImmutable = false; | 
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 3862 | public FailureSignalingConnection(DisconnectCause disconnectCause) { | 
|  | 3863 | setDisconnected(disconnectCause); | 
| Tyler Gunn | 2915af7 | 2020-03-06 11:36:21 -0800 | [diff] [blame] | 3864 | mImmutable = true; | 
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 3865 | } | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 3866 |  | 
|  | 3867 | public void checkImmutable() { | 
| Ihab Awad | 90e34e3 | 2014-12-01 16:23:17 -0800 | [diff] [blame] | 3868 | if (mImmutable) { | 
|  | 3869 | throw new UnsupportedOperationException("Connection is immutable"); | 
|  | 3870 | } | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 3871 | } | 
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 3872 | } | 
|  | 3873 |  | 
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 3874 | /** | 
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 3875 | * Return a {@code Connection} which represents a failed connection attempt. The returned | 
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 3876 | * {@code Connection} will have a {@link android.telecom.DisconnectCause} and as specified, | 
|  | 3877 | * and a {@link #getState()} of {@link #STATE_DISCONNECTED}. | 
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 3878 | * <p> | 
|  | 3879 | * The returned {@code Connection} can be assumed to {@link #destroy()} itself when appropriate, | 
|  | 3880 | * so users of this method need not maintain a reference to its return value to destroy it. | 
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 3881 | * | 
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 3882 | * @param disconnectCause The disconnect cause, ({@see android.telecomm.DisconnectCause}). | 
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 3883 | * @return A {@code Connection} which indicates failure. | 
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 3884 | */ | 
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 3885 | public static Connection createFailedConnection(DisconnectCause disconnectCause) { | 
|  | 3886 | return new FailureSignalingConnection(disconnectCause); | 
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 3887 | } | 
|  | 3888 |  | 
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 3889 | /** | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 3890 | * Override to throw an {@link UnsupportedOperationException} if this {@code Connection} is | 
|  | 3891 | * not intended to be mutated, e.g., if it is a marker for failure. Only for framework use; | 
|  | 3892 | * this should never be un-@hide-den. | 
|  | 3893 | * | 
|  | 3894 | * @hide | 
|  | 3895 | */ | 
|  | 3896 | public void checkImmutable() {} | 
|  | 3897 |  | 
|  | 3898 | /** | 
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 3899 | * Return a {@code Connection} which represents a canceled connection attempt. The returned | 
|  | 3900 | * {@code Connection} will have state {@link #STATE_DISCONNECTED}, and cannot be moved out of | 
|  | 3901 | * that state. This connection should not be used for anything, and no other | 
|  | 3902 | * {@code Connection}s should be attempted. | 
|  | 3903 | * <p> | 
| Ihab Awad | 6107bab | 2014-08-18 09:23:25 -0700 | [diff] [blame] | 3904 | * so users of this method need not maintain a reference to its return value to destroy it. | 
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 3905 | * | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 3906 | * @return A {@code Connection} which indicates that the underlying connection should | 
|  | 3907 | * be canceled. | 
| Evan Charlton | bf11f98 | 2014-07-20 22:06:28 -0700 | [diff] [blame] | 3908 | */ | 
| Ihab Awad | b19a0bc | 2014-08-07 19:46:01 -0700 | [diff] [blame] | 3909 | public static Connection createCanceledConnection() { | 
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 3910 | return new FailureSignalingConnection(new DisconnectCause(DisconnectCause.CANCELED)); | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 3911 | } | 
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 3912 |  | 
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 3913 | private final void fireOnConferenceableConnectionsChanged() { | 
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 3914 | for (Listener l : mListeners) { | 
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 3915 | l.onConferenceablesChanged(this, getConferenceables()); | 
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 3916 | } | 
|  | 3917 | } | 
|  | 3918 |  | 
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 3919 | private final void fireConferenceChanged() { | 
|  | 3920 | for (Listener l : mListeners) { | 
|  | 3921 | l.onConferenceChanged(this, mConference); | 
|  | 3922 | } | 
|  | 3923 | } | 
|  | 3924 |  | 
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 3925 | private final void clearConferenceableList() { | 
| Tyler Gunn | df2cbc8 | 2015-04-20 09:13:01 -0700 | [diff] [blame] | 3926 | for (Conferenceable c : mConferenceables) { | 
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 3927 | if (c instanceof Connection) { | 
|  | 3928 | Connection connection = (Connection) c; | 
|  | 3929 | connection.removeConnectionListener(mConnectionDeathListener); | 
|  | 3930 | } else if (c instanceof Conference) { | 
|  | 3931 | Conference conference = (Conference) c; | 
|  | 3932 | conference.removeListener(mConferenceDeathListener); | 
|  | 3933 | } | 
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 3934 | } | 
| Tyler Gunn | 6d76ca0 | 2014-11-17 15:49:51 -0800 | [diff] [blame] | 3935 | mConferenceables.clear(); | 
| Santos Cordon | 7c7bc7f | 2014-07-28 18:15:48 -0700 | [diff] [blame] | 3936 | } | 
| Tyler Gunn | 3bffcf7 | 2014-10-28 13:51:27 -0700 | [diff] [blame] | 3937 |  | 
|  | 3938 | /** | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 3939 | * Handles a change to extras received from Telecom. | 
|  | 3940 | * | 
|  | 3941 | * @param extras The new extras. | 
|  | 3942 | * @hide | 
|  | 3943 | */ | 
|  | 3944 | final void handleExtrasChanged(Bundle extras) { | 
| Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 3945 | Bundle b = null; | 
|  | 3946 | synchronized (mExtrasLock) { | 
|  | 3947 | mExtras = extras; | 
|  | 3948 | if (mExtras != null) { | 
|  | 3949 | b = new Bundle(mExtras); | 
|  | 3950 | } | 
|  | 3951 | } | 
|  | 3952 | onExtrasChanged(b); | 
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 3953 | } | 
|  | 3954 |  | 
|  | 3955 | /** | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 3956 | * Called by a {@link ConnectionService} to notify Telecom that a {@link Conference#onMerge()} | 
|  | 3957 | * request failed. | 
| Anthony Lee | 17455a3 | 2015-04-24 15:25:29 -0700 | [diff] [blame] | 3958 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 3959 | public final void notifyConferenceMergeFailed() { | 
| Anthony Lee | 17455a3 | 2015-04-24 15:25:29 -0700 | [diff] [blame] | 3960 | for (Listener l : mListeners) { | 
|  | 3961 | l.onConferenceMergeFailed(this); | 
|  | 3962 | } | 
|  | 3963 | } | 
|  | 3964 |  | 
|  | 3965 | /** | 
| Srikanth Chintala | fcb1501 | 2017-05-04 20:58:34 +0530 | [diff] [blame] | 3966 | * Notifies listeners when phone account is changed. For example, when the PhoneAccount is | 
|  | 3967 | * changed due to an emergency call being redialed. | 
|  | 3968 | * @param pHandle The new PhoneAccountHandle for this connection. | 
|  | 3969 | * @hide | 
|  | 3970 | */ | 
|  | 3971 | public void notifyPhoneAccountChanged(PhoneAccountHandle pHandle) { | 
|  | 3972 | for (Listener l : mListeners) { | 
|  | 3973 | l.onPhoneAccountChanged(this, pHandle); | 
|  | 3974 | } | 
|  | 3975 | } | 
|  | 3976 |  | 
|  | 3977 | /** | 
| Pengquan Meng | 70c988533 | 2017-10-02 18:09:03 -0700 | [diff] [blame] | 3978 | * Sets the {@link PhoneAccountHandle} associated with this connection. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 3979 | * <p> | 
|  | 3980 | * Used by the Telephony {@link ConnectionService} to handle changes to the {@link PhoneAccount} | 
|  | 3981 | * which take place after call initiation (important for emergency calling scenarios). | 
| Pengquan Meng | 70c988533 | 2017-10-02 18:09:03 -0700 | [diff] [blame] | 3982 | * | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 3983 | * @param phoneAccountHandle the phone account handle to set. | 
| Pengquan Meng | 70c988533 | 2017-10-02 18:09:03 -0700 | [diff] [blame] | 3984 | * @hide | 
|  | 3985 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 3986 | @SystemApi | 
|  | 3987 | public void setPhoneAccountHandle(@NonNull PhoneAccountHandle phoneAccountHandle) { | 
| Pengquan Meng | 70c988533 | 2017-10-02 18:09:03 -0700 | [diff] [blame] | 3988 | if (mPhoneAccountHandle != phoneAccountHandle) { | 
|  | 3989 | mPhoneAccountHandle = phoneAccountHandle; | 
|  | 3990 | notifyPhoneAccountChanged(phoneAccountHandle); | 
|  | 3991 | } | 
|  | 3992 | } | 
|  | 3993 |  | 
|  | 3994 | /** | 
|  | 3995 | * Returns the {@link PhoneAccountHandle} associated with this connection. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 3996 | * <p> | 
|  | 3997 | * Used by the Telephony {@link ConnectionService} to handle changes to the {@link PhoneAccount} | 
|  | 3998 | * which take place after call initiation (important for emergency calling scenarios). | 
| Pengquan Meng | 70c988533 | 2017-10-02 18:09:03 -0700 | [diff] [blame] | 3999 | * | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 4000 | * @return the phone account handle specified via | 
|  | 4001 | * {@link #setPhoneAccountHandle(PhoneAccountHandle)}, or {@code null} if none was set. | 
| Pengquan Meng | 70c988533 | 2017-10-02 18:09:03 -0700 | [diff] [blame] | 4002 | * @hide | 
|  | 4003 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 4004 | @SystemApi | 
|  | 4005 | public @Nullable PhoneAccountHandle getPhoneAccountHandle() { | 
| Pengquan Meng | 70c988533 | 2017-10-02 18:09:03 -0700 | [diff] [blame] | 4006 | return mPhoneAccountHandle; | 
|  | 4007 | } | 
|  | 4008 |  | 
|  | 4009 | /** | 
| Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 4010 | * Sends an event associated with this {@code Connection} with associated event extras to the | 
|  | 4011 | * {@link InCallService}. | 
|  | 4012 | * <p> | 
|  | 4013 | * Connection events are used to communicate point in time information from a | 
|  | 4014 | * {@link ConnectionService} to a {@link InCallService} implementations.  An example of a | 
|  | 4015 | * custom connection event includes notifying the UI when a WIFI call has been handed over to | 
|  | 4016 | * LTE, which the InCall UI might use to inform the user that billing charges may apply.  The | 
|  | 4017 | * Android Telephony framework will send the {@link #EVENT_CALL_MERGE_FAILED} connection event | 
|  | 4018 | * when a call to {@link Call#mergeConference()} has failed to complete successfully.  A | 
|  | 4019 | * connection event could also be used to trigger UI in the {@link InCallService} which prompts | 
|  | 4020 | * the user to make a choice (e.g. whether they want to incur roaming costs for making a call), | 
|  | 4021 | * which is communicated back via {@link Call#sendCallEvent(String, Bundle)}. | 
|  | 4022 | * <p> | 
|  | 4023 | * Events are exposed to {@link InCallService} implementations via | 
|  | 4024 | * {@link Call.Callback#onConnectionEvent(Call, String, Bundle)}. | 
|  | 4025 | * <p> | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 4026 | * No assumptions should be made as to how an In-Call UI or service will handle these events. | 
| Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 4027 | * The {@link ConnectionService} must assume that the In-Call UI could even chose to ignore | 
|  | 4028 | * some events altogether. | 
|  | 4029 | * <p> | 
|  | 4030 | * Events should be fully qualified (e.g. {@code com.example.event.MY_EVENT}) to avoid | 
|  | 4031 | * conflicts between {@link ConnectionService} implementations.  Further, custom | 
|  | 4032 | * {@link ConnectionService} implementations shall not re-purpose events in the | 
|  | 4033 | * {@code android.*} namespace, nor shall they define new event types in this namespace.  When | 
|  | 4034 | * defining a custom event type, ensure the contents of the extras {@link Bundle} is clearly | 
|  | 4035 | * defined.  Extra keys for this bundle should be named similar to the event type (e.g. | 
|  | 4036 | * {@code com.example.extra.MY_EXTRA}). | 
|  | 4037 | * <p> | 
|  | 4038 | *  When defining events and the associated extras, it is important to keep their behavior | 
|  | 4039 | * consistent when the associated {@link ConnectionService} is updated.  Support for deprecated | 
|  | 4040 | * events/extras should me maintained to ensure backwards compatibility with older | 
|  | 4041 | * {@link InCallService} implementations which were built to support the older behavior. | 
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 4042 | * | 
|  | 4043 | * @param event The connection event. | 
| Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 4044 | * @param extras Optional bundle containing extra information associated with the event. | 
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 4045 | */ | 
| Tyler Gunn | 876dbfb | 2016-03-14 15:18:07 -0700 | [diff] [blame] | 4046 | public void sendConnectionEvent(String event, Bundle extras) { | 
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 4047 | for (Listener l : mListeners) { | 
| Tyler Gunn | a8fb8ab | 2016-03-29 10:24:22 -0700 | [diff] [blame] | 4048 | l.onConnectionEvent(this, event, extras); | 
| Tyler Gunn | bd1eb1f | 2016-02-16 14:36:20 -0800 | [diff] [blame] | 4049 | } | 
|  | 4050 | } | 
| Tyler Gunn | 6986a63 | 2019-06-25 13:45:32 -0700 | [diff] [blame] | 4051 |  | 
|  | 4052 | /** | 
|  | 4053 | * @return The direction of the call. | 
|  | 4054 | * @hide | 
|  | 4055 | */ | 
|  | 4056 | public final @Call.Details.CallDirection int getCallDirection() { | 
|  | 4057 | return mCallDirection; | 
|  | 4058 | } | 
|  | 4059 |  | 
|  | 4060 | /** | 
|  | 4061 | * Sets the direction of this connection. | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 4062 | * <p> | 
|  | 4063 | * Used when calling {@link ConnectionService#addExistingConnection} to specify the existing | 
|  | 4064 | * call direction. | 
|  | 4065 | * | 
| Tyler Gunn | 6986a63 | 2019-06-25 13:45:32 -0700 | [diff] [blame] | 4066 | * @param callDirection The direction of this connection. | 
|  | 4067 | * @hide | 
|  | 4068 | */ | 
| Tyler Gunn | c63f908 | 2019-10-15 13:19:26 -0700 | [diff] [blame] | 4069 | @SystemApi | 
| Tyler Gunn | 6986a63 | 2019-06-25 13:45:32 -0700 | [diff] [blame] | 4070 | public void setCallDirection(@Call.Details.CallDirection int callDirection) { | 
|  | 4071 | mCallDirection = callDirection; | 
|  | 4072 | } | 
| Tyler Gunn | d57d76c | 2019-09-24 14:53:23 -0700 | [diff] [blame] | 4073 |  | 
|  | 4074 | /** | 
|  | 4075 | * Gets the verification status for the phone number of an incoming call as identified in | 
|  | 4076 | * ATIS-1000082. | 
|  | 4077 | * @return the verification status. | 
|  | 4078 | */ | 
| Tyler Gunn | a131d6e | 2020-02-13 14:53:28 -0800 | [diff] [blame] | 4079 | public final @VerificationStatus int getCallerNumberVerificationStatus() { | 
| Tyler Gunn | d57d76c | 2019-09-24 14:53:23 -0700 | [diff] [blame] | 4080 | return mCallerNumberVerificationStatus; | 
|  | 4081 | } | 
|  | 4082 |  | 
|  | 4083 | /** | 
|  | 4084 | * Sets the verification status for the phone number of an incoming call as identified in | 
|  | 4085 | * ATIS-1000082. | 
|  | 4086 | * <p> | 
|  | 4087 | * This property can only be set at the time of creation of a {@link Connection} being returned | 
|  | 4088 | * by | 
|  | 4089 | * {@link ConnectionService#onCreateIncomingConnection(PhoneAccountHandle, ConnectionRequest)}. | 
|  | 4090 | */ | 
| Tyler Gunn | a131d6e | 2020-02-13 14:53:28 -0800 | [diff] [blame] | 4091 | public final void setCallerNumberVerificationStatus( | 
| Tyler Gunn | d57d76c | 2019-09-24 14:53:23 -0700 | [diff] [blame] | 4092 | @VerificationStatus int callerNumberVerificationStatus) { | 
|  | 4093 | mCallerNumberVerificationStatus = callerNumberVerificationStatus; | 
|  | 4094 | } | 
| Ihab Awad | 542e0ea | 2014-05-16 10:22:16 -0700 | [diff] [blame] | 4095 | } |