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