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