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