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