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