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