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