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