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