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