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