Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -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; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 18 | |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 19 | import android.annotation.NonNull; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 20 | import android.annotation.Nullable; |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 21 | import android.annotation.SystemApi; |
Tyler Gunn | 6c14a699 | 2019-02-04 15:12:06 -0800 | [diff] [blame] | 22 | import android.annotation.TestApi; |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 23 | import android.net.Uri; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 24 | import android.os.Bundle; |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 25 | import android.os.SystemClock; |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 26 | import android.telecom.Connection.VideoProvider; |
Chen Xu | f85cf99 | 2019-10-02 00:20:43 -0700 | [diff] [blame] | 27 | import android.telephony.Annotation.RilRadioTechnology; |
Wei Huang | 7f7f72e | 2018-05-30 19:21:36 +0800 | [diff] [blame] | 28 | import android.telephony.ServiceState; |
| 29 | import android.telephony.TelephonyManager; |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 30 | import android.util.ArraySet; |
Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 31 | |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 32 | import java.util.ArrayList; |
Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 33 | import java.util.Arrays; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 34 | import java.util.Collections; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 35 | import java.util.List; |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 36 | import java.util.Locale; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 37 | import java.util.Set; |
| 38 | import java.util.concurrent.CopyOnWriteArrayList; |
| 39 | import java.util.concurrent.CopyOnWriteArraySet; |
| 40 | |
| 41 | /** |
| 42 | * Represents a conference call which can contain any number of {@link Connection} objects. |
| 43 | */ |
Yorke Lee | abfcfdc | 2015-05-13 18:55:18 -0700 | [diff] [blame] | 44 | public abstract class Conference extends Conferenceable { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 45 | |
Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 46 | /** |
| 47 | * Used to indicate that the conference connection time is not specified. If not specified, |
| 48 | * Telecom will set the connect time. |
| 49 | */ |
Jay Shrauner | 164a0ac | 2015-04-14 18:16:10 -0700 | [diff] [blame] | 50 | public static final long CONNECT_TIME_NOT_SPECIFIED = 0; |
Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 51 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 52 | /** @hide */ |
| 53 | public abstract static class Listener { |
| 54 | public void onStateChanged(Conference conference, int oldState, int newState) {} |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 55 | public void onDisconnected(Conference conference, DisconnectCause disconnectCause) {} |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 56 | public void onConnectionAdded(Conference conference, Connection connection) {} |
| 57 | public void onConnectionRemoved(Conference conference, Connection connection) {} |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 58 | public void onConferenceableConnectionsChanged( |
| 59 | Conference conference, List<Connection> conferenceableConnections) {} |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 60 | public void onDestroyed(Conference conference) {} |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 61 | public void onConnectionCapabilitiesChanged( |
| 62 | Conference conference, int connectionCapabilities) {} |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 63 | public void onConnectionPropertiesChanged( |
| 64 | Conference conference, int connectionProperties) {} |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 65 | public void onVideoStateChanged(Conference c, int videoState) { } |
| 66 | public void onVideoProviderChanged(Conference c, Connection.VideoProvider videoProvider) {} |
Andrew Lee | edc625f | 2015-04-14 13:38:12 -0700 | [diff] [blame] | 67 | public void onStatusHintsChanged(Conference conference, StatusHints statusHints) {} |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 68 | public void onExtrasChanged(Conference c, Bundle extras) {} |
| 69 | public void onExtrasRemoved(Conference c, List<String> keys) {} |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 70 | public void onConferenceStateChanged(Conference c, boolean isConference) {} |
| 71 | public void onAddressChanged(Conference c, Uri newAddress, int presentation) {} |
Hall Liu | c9bc1c6 | 2019-04-16 14:00:55 -0700 | [diff] [blame] | 72 | public void onConnectionEvent(Conference c, String event, Bundle extras) {} |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 73 | public void onCallerDisplayNameChanged( |
| 74 | Conference c, String callerDisplayName, int presentation) {} |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | private final Set<Listener> mListeners = new CopyOnWriteArraySet<>(); |
| 78 | private final List<Connection> mChildConnections = new CopyOnWriteArrayList<>(); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 79 | private final List<Connection> mUnmodifiableChildConnections = |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 80 | Collections.unmodifiableList(mChildConnections); |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 81 | private final List<Connection> mConferenceableConnections = new ArrayList<>(); |
| 82 | private final List<Connection> mUnmodifiableConferenceableConnections = |
| 83 | Collections.unmodifiableList(mConferenceableConnections); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 84 | |
Jack Yu | 6714030 | 2015-12-10 12:27:58 -0800 | [diff] [blame] | 85 | private String mTelecomCallId; |
Jay Shrauner | 164a0ac | 2015-04-14 18:16:10 -0700 | [diff] [blame] | 86 | private PhoneAccountHandle mPhoneAccount; |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 87 | private CallAudioState mCallAudioState; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 88 | private int mState = Connection.STATE_NEW; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 89 | private DisconnectCause mDisconnectCause; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 90 | private int mConnectionCapabilities; |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 91 | private int mConnectionProperties; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 92 | private String mDisconnectMessage; |
Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 93 | private long mConnectTimeMillis = CONNECT_TIME_NOT_SPECIFIED; |
Tyler Gunn | 1754139 | 2018-02-01 08:58:38 -0800 | [diff] [blame] | 94 | private long mConnectionStartElapsedRealTime = CONNECT_TIME_NOT_SPECIFIED; |
Andrew Lee | edc625f | 2015-04-14 13:38:12 -0700 | [diff] [blame] | 95 | private StatusHints mStatusHints; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 96 | private Bundle mExtras; |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 97 | private Set<String> mPreviousExtraKeys; |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 98 | private final Object mExtrasLock = new Object(); |
Tyler Gunn | ac60f95 | 2019-05-31 07:23:16 -0700 | [diff] [blame] | 99 | private Uri mAddress; |
| 100 | private int mAddressPresentation; |
| 101 | private String mCallerDisplayName; |
| 102 | private int mCallerDisplayNamePresentation; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 103 | |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 104 | private final Connection.Listener mConnectionDeathListener = new Connection.Listener() { |
| 105 | @Override |
| 106 | public void onDestroyed(Connection c) { |
| 107 | if (mConferenceableConnections.remove(c)) { |
| 108 | fireOnConferenceableConnectionsChanged(); |
| 109 | } |
| 110 | } |
| 111 | }; |
| 112 | |
Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 113 | /** |
| 114 | * Constructs a new Conference with a mandatory {@link PhoneAccountHandle} |
| 115 | * |
| 116 | * @param phoneAccount The {@code PhoneAccountHandle} associated with the conference. |
| 117 | */ |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 118 | public Conference(PhoneAccountHandle phoneAccount) { |
| 119 | mPhoneAccount = phoneAccount; |
| 120 | } |
| 121 | |
Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 122 | /** |
Jack Yu | 6714030 | 2015-12-10 12:27:58 -0800 | [diff] [blame] | 123 | * Returns the telecom internal call ID associated with this conference. |
| 124 | * |
| 125 | * @return The telecom call ID. |
| 126 | * @hide |
| 127 | */ |
| 128 | public final String getTelecomCallId() { |
| 129 | return mTelecomCallId; |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * Sets the telecom internal call ID associated with this conference. |
| 134 | * |
| 135 | * @param telecomCallId The telecom call ID. |
| 136 | * @hide |
| 137 | */ |
| 138 | public final void setTelecomCallId(String telecomCallId) { |
| 139 | mTelecomCallId = telecomCallId; |
| 140 | } |
| 141 | |
| 142 | /** |
Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 143 | * Returns the {@link PhoneAccountHandle} the conference call is being placed through. |
| 144 | * |
| 145 | * @return A {@code PhoneAccountHandle} object representing the PhoneAccount of the conference. |
| 146 | */ |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 147 | public final PhoneAccountHandle getPhoneAccountHandle() { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 148 | return mPhoneAccount; |
| 149 | } |
| 150 | |
Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 151 | /** |
| 152 | * Returns the list of connections currently associated with the conference call. |
| 153 | * |
| 154 | * @return A list of {@code Connection} objects which represent the children of the conference. |
| 155 | */ |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 156 | public final List<Connection> getConnections() { |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 157 | return mUnmodifiableChildConnections; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 158 | } |
| 159 | |
Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 160 | /** |
| 161 | * Gets the state of the conference call. See {@link Connection} for valid values. |
| 162 | * |
| 163 | * @return A constant representing the state the conference call is currently in. |
| 164 | */ |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 165 | public final int getState() { |
| 166 | return mState; |
| 167 | } |
| 168 | |
Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 169 | /** |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 170 | * Returns the capabilities of the conference. See {@code CAPABILITY_*} constants in class |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 171 | * {@link Connection} for valid values. |
Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 172 | * |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 173 | * @return A bitmask of the capabilities of the conference call. |
Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 174 | */ |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 175 | public final int getConnectionCapabilities() { |
| 176 | return mConnectionCapabilities; |
| 177 | } |
| 178 | |
| 179 | /** |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 180 | * Returns the properties of the conference. See {@code PROPERTY_*} constants in class |
| 181 | * {@link Connection} for valid values. |
| 182 | * |
| 183 | * @return A bitmask of the properties of the conference call. |
| 184 | */ |
| 185 | public final int getConnectionProperties() { |
| 186 | return mConnectionProperties; |
| 187 | } |
| 188 | |
| 189 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 190 | * Whether the given capabilities support the specified capability. |
| 191 | * |
| 192 | * @param capabilities A capability bit field. |
| 193 | * @param capability The capability to check capabilities for. |
| 194 | * @return Whether the specified capability is supported. |
| 195 | * @hide |
| 196 | */ |
| 197 | public static boolean can(int capabilities, int capability) { |
| 198 | return (capabilities & capability) != 0; |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * Whether the capabilities of this {@code Connection} supports the specified capability. |
| 203 | * |
| 204 | * @param capability The capability to check capabilities for. |
| 205 | * @return Whether the specified capability is supported. |
| 206 | * @hide |
| 207 | */ |
| 208 | public boolean can(int capability) { |
| 209 | return can(mConnectionCapabilities, capability); |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * Removes the specified capability from the set of capabilities of this {@code Conference}. |
| 214 | * |
| 215 | * @param capability The capability to remove from the set. |
| 216 | * @hide |
| 217 | */ |
| 218 | public void removeCapability(int capability) { |
Omkar Kolangade | a0f46a9 | 2015-03-23 17:51:16 -0700 | [diff] [blame] | 219 | int newCapabilities = mConnectionCapabilities; |
| 220 | newCapabilities &= ~capability; |
| 221 | |
| 222 | setConnectionCapabilities(newCapabilities); |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | /** |
| 226 | * Adds the specified capability to the set of capabilities of this {@code Conference}. |
| 227 | * |
| 228 | * @param capability The capability to add to the set. |
| 229 | * @hide |
| 230 | */ |
| 231 | public void addCapability(int capability) { |
Omkar Kolangade | a0f46a9 | 2015-03-23 17:51:16 -0700 | [diff] [blame] | 232 | int newCapabilities = mConnectionCapabilities; |
| 233 | newCapabilities |= capability; |
| 234 | |
| 235 | setConnectionCapabilities(newCapabilities); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | /** |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 239 | * @return The audio state of the conference, describing how its audio is currently |
| 240 | * being routed by the system. This is {@code null} if this Conference |
| 241 | * does not directly know about its audio state. |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 242 | * @deprecated Use {@link #getCallAudioState()} instead. |
| 243 | * @hide |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 244 | */ |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 245 | @Deprecated |
| 246 | @SystemApi |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 247 | public final AudioState getAudioState() { |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 248 | return new AudioState(mCallAudioState); |
| 249 | } |
| 250 | |
| 251 | /** |
| 252 | * @return The audio state of the conference, describing how its audio is currently |
| 253 | * being routed by the system. This is {@code null} if this Conference |
| 254 | * does not directly know about its audio state. |
| 255 | */ |
| 256 | public final CallAudioState getCallAudioState() { |
| 257 | return mCallAudioState; |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | /** |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 261 | * Returns VideoProvider of the primary call. This can be null. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 262 | */ |
| 263 | public VideoProvider getVideoProvider() { |
| 264 | return null; |
| 265 | } |
| 266 | |
| 267 | /** |
| 268 | * Returns video state of the primary call. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 269 | */ |
| 270 | public int getVideoState() { |
Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 271 | return VideoProfile.STATE_AUDIO_ONLY; |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 275 | * Notifies the {@link Conference} when the Conference and all it's {@link Connection}s should |
| 276 | * be disconnected. |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 277 | */ |
| 278 | public void onDisconnect() {} |
| 279 | |
| 280 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 281 | * Notifies the {@link Conference} when the specified {@link Connection} should be separated |
| 282 | * from the conference call. |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 283 | * |
| 284 | * @param connection The connection to separate. |
| 285 | */ |
| 286 | public void onSeparate(Connection connection) {} |
| 287 | |
| 288 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 289 | * Notifies the {@link Conference} when the specified {@link Connection} should merged with the |
| 290 | * conference call. |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 291 | * |
| 292 | * @param connection The {@code Connection} to merge. |
| 293 | */ |
| 294 | public void onMerge(Connection connection) {} |
| 295 | |
| 296 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 297 | * Notifies the {@link Conference} when it should be put on hold. |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 298 | */ |
| 299 | public void onHold() {} |
| 300 | |
| 301 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 302 | * Notifies the {@link Conference} when it should be moved from a held to active state. |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 303 | */ |
| 304 | public void onUnhold() {} |
| 305 | |
| 306 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 307 | * Notifies the {@link Conference} when the child calls should be merged. Only invoked if the |
| 308 | * conference contains the capability {@link Connection#CAPABILITY_MERGE_CONFERENCE}. |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 309 | */ |
| 310 | public void onMerge() {} |
| 311 | |
| 312 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 313 | * Notifies the {@link Conference} when the child calls should be swapped. Only invoked if the |
| 314 | * conference contains the capability {@link Connection#CAPABILITY_SWAP_CONFERENCE}. |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 315 | */ |
| 316 | public void onSwap() {} |
| 317 | |
| 318 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 319 | * Notifies the {@link Conference} of a request to play a DTMF tone. |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 320 | * |
| 321 | * @param c A DTMF character. |
| 322 | */ |
| 323 | public void onPlayDtmfTone(char c) {} |
| 324 | |
| 325 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 326 | * Notifies the {@link Conference} of a request to stop any currently playing DTMF tones. |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 327 | */ |
| 328 | public void onStopDtmfTone() {} |
| 329 | |
| 330 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 331 | * Notifies the {@link Conference} that the {@link #getAudioState()} property has a new value. |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 332 | * |
| 333 | * @param state The new call audio state. |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 334 | * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead. |
| 335 | * @hide |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 336 | */ |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 337 | @SystemApi |
| 338 | @Deprecated |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 339 | public void onAudioStateChanged(AudioState state) {} |
| 340 | |
| 341 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 342 | * Notifies the {@link Conference} that the {@link #getCallAudioState()} property has a new |
| 343 | * value. |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 344 | * |
| 345 | * @param state The new call audio state. |
| 346 | */ |
| 347 | public void onCallAudioStateChanged(CallAudioState state) {} |
| 348 | |
| 349 | /** |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 350 | * Notifies the {@link Conference} that a {@link Connection} has been added to it. |
Andrew Lee | 46f7f5d | 2014-11-06 17:00:25 -0800 | [diff] [blame] | 351 | * |
| 352 | * @param connection The newly added connection. |
| 353 | */ |
| 354 | public void onConnectionAdded(Connection connection) {} |
| 355 | |
| 356 | /** |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 357 | * Sets state to be on hold. |
| 358 | */ |
| 359 | public final void setOnHold() { |
| 360 | setState(Connection.STATE_HOLDING); |
| 361 | } |
| 362 | |
| 363 | /** |
Tyler Gunn | d46595a | 2015-06-01 14:29:11 -0700 | [diff] [blame] | 364 | * Sets state to be dialing. |
| 365 | */ |
| 366 | public final void setDialing() { |
| 367 | setState(Connection.STATE_DIALING); |
| 368 | } |
| 369 | |
| 370 | /** |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 371 | * Sets state to be active. |
| 372 | */ |
| 373 | public final void setActive() { |
| 374 | setState(Connection.STATE_ACTIVE); |
| 375 | } |
| 376 | |
| 377 | /** |
| 378 | * Sets state to disconnected. |
| 379 | * |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 380 | * @param disconnectCause The reason for the disconnection, as described by |
| 381 | * {@link android.telecom.DisconnectCause}. |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 382 | */ |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 383 | public final void setDisconnected(DisconnectCause disconnectCause) { |
| 384 | mDisconnectCause = disconnectCause;; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 385 | setState(Connection.STATE_DISCONNECTED); |
| 386 | for (Listener l : mListeners) { |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 387 | l.onDisconnected(this, mDisconnectCause); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 388 | } |
| 389 | } |
| 390 | |
| 391 | /** |
mike dooley | 1cf14ac | 2014-11-04 10:59:53 -0800 | [diff] [blame] | 392 | * @return The {@link DisconnectCause} for this connection. |
| 393 | */ |
| 394 | public final DisconnectCause getDisconnectCause() { |
| 395 | return mDisconnectCause; |
| 396 | } |
| 397 | |
| 398 | /** |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 399 | * Sets the capabilities of a conference. See {@code CAPABILITY_*} constants of class |
| 400 | * {@link Connection} for valid values. |
Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 401 | * |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 402 | * @param connectionCapabilities A bitmask of the {@code Capabilities} of the conference call. |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 403 | */ |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 404 | public final void setConnectionCapabilities(int connectionCapabilities) { |
| 405 | if (connectionCapabilities != mConnectionCapabilities) { |
| 406 | mConnectionCapabilities = connectionCapabilities; |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 407 | |
| 408 | for (Listener l : mListeners) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 409 | l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 410 | } |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | /** |
Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 415 | * Sets the properties of a conference. See {@code PROPERTY_*} constants of class |
| 416 | * {@link Connection} for valid values. |
| 417 | * |
| 418 | * @param connectionProperties A bitmask of the {@code Properties} of the conference call. |
| 419 | */ |
| 420 | public final void setConnectionProperties(int connectionProperties) { |
| 421 | if (connectionProperties != mConnectionProperties) { |
| 422 | mConnectionProperties = connectionProperties; |
| 423 | |
| 424 | for (Listener l : mListeners) { |
| 425 | l.onConnectionPropertiesChanged(this, mConnectionProperties); |
| 426 | } |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | /** |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 431 | * Adds the specified connection as a child of this conference. |
| 432 | * |
| 433 | * @param connection The connection to add. |
| 434 | * @return True if the connection was successfully added. |
| 435 | */ |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 436 | public final boolean addConnection(Connection connection) { |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 437 | Log.d(this, "Connection=%s, connection=", connection); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 438 | if (connection != null && !mChildConnections.contains(connection)) { |
| 439 | if (connection.setConference(this)) { |
| 440 | mChildConnections.add(connection); |
Andrew Lee | 46f7f5d | 2014-11-06 17:00:25 -0800 | [diff] [blame] | 441 | onConnectionAdded(connection); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 442 | for (Listener l : mListeners) { |
| 443 | l.onConnectionAdded(this, connection); |
| 444 | } |
| 445 | return true; |
| 446 | } |
| 447 | } |
| 448 | return false; |
| 449 | } |
| 450 | |
| 451 | /** |
| 452 | * Removes the specified connection as a child of this conference. |
| 453 | * |
| 454 | * @param connection The connection to remove. |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 455 | */ |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 456 | public final void removeConnection(Connection connection) { |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 457 | Log.d(this, "removing %s from %s", connection, mChildConnections); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 458 | if (connection != null && mChildConnections.remove(connection)) { |
| 459 | connection.resetConference(); |
| 460 | for (Listener l : mListeners) { |
| 461 | l.onConnectionRemoved(this, connection); |
| 462 | } |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | /** |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 467 | * Sets the connections with which this connection can be conferenced. |
| 468 | * |
| 469 | * @param conferenceableConnections The set of connections this connection can conference with. |
| 470 | */ |
| 471 | public final void setConferenceableConnections(List<Connection> conferenceableConnections) { |
| 472 | clearConferenceableList(); |
| 473 | for (Connection c : conferenceableConnections) { |
| 474 | // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a |
| 475 | // small amount of items here. |
| 476 | if (!mConferenceableConnections.contains(c)) { |
| 477 | c.addConnectionListener(mConnectionDeathListener); |
| 478 | mConferenceableConnections.add(c); |
| 479 | } |
| 480 | } |
| 481 | fireOnConferenceableConnectionsChanged(); |
| 482 | } |
| 483 | |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 484 | /** |
| 485 | * Set the video state for the conference. |
Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 486 | * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY}, |
| 487 | * {@link VideoProfile#STATE_BIDIRECTIONAL}, |
| 488 | * {@link VideoProfile#STATE_TX_ENABLED}, |
| 489 | * {@link VideoProfile#STATE_RX_ENABLED}. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 490 | * |
| 491 | * @param videoState The new video state. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 492 | */ |
| 493 | public final void setVideoState(Connection c, int videoState) { |
| 494 | Log.d(this, "setVideoState Conference: %s Connection: %s VideoState: %s", |
| 495 | this, c, videoState); |
| 496 | for (Listener l : mListeners) { |
| 497 | l.onVideoStateChanged(this, videoState); |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | /** |
| 502 | * Sets the video connection provider. |
| 503 | * |
| 504 | * @param videoProvider The video provider. |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 505 | */ |
| 506 | public final void setVideoProvider(Connection c, Connection.VideoProvider videoProvider) { |
| 507 | Log.d(this, "setVideoProvider Conference: %s Connection: %s VideoState: %s", |
| 508 | this, c, videoProvider); |
| 509 | for (Listener l : mListeners) { |
| 510 | l.onVideoProviderChanged(this, videoProvider); |
| 511 | } |
| 512 | } |
| 513 | |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 514 | private final void fireOnConferenceableConnectionsChanged() { |
| 515 | for (Listener l : mListeners) { |
| 516 | l.onConferenceableConnectionsChanged(this, getConferenceableConnections()); |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | /** |
| 521 | * Returns the connections with which this connection can be conferenced. |
| 522 | */ |
| 523 | public final List<Connection> getConferenceableConnections() { |
| 524 | return mUnmodifiableConferenceableConnections; |
| 525 | } |
| 526 | |
| 527 | /** |
Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 528 | * Tears down the conference object and any of its current connections. |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 529 | */ |
Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 530 | public final void destroy() { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 531 | Log.d(this, "destroying conference : %s", this); |
| 532 | // Tear down the children. |
Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 533 | for (Connection connection : mChildConnections) { |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 534 | Log.d(this, "removing connection %s", connection); |
| 535 | removeConnection(connection); |
| 536 | } |
| 537 | |
| 538 | // If not yet disconnected, set the conference call as disconnected first. |
| 539 | if (mState != Connection.STATE_DISCONNECTED) { |
| 540 | Log.d(this, "setting to disconnected"); |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 541 | setDisconnected(new DisconnectCause(DisconnectCause.LOCAL)); |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 542 | } |
| 543 | |
| 544 | // ...and notify. |
| 545 | for (Listener l : mListeners) { |
| 546 | l.onDestroyed(this); |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | /** |
| 551 | * Add a listener to be notified of a state change. |
| 552 | * |
| 553 | * @param listener The new listener. |
| 554 | * @return This conference. |
| 555 | * @hide |
| 556 | */ |
| 557 | public final Conference addListener(Listener listener) { |
| 558 | mListeners.add(listener); |
| 559 | return this; |
| 560 | } |
| 561 | |
| 562 | /** |
| 563 | * Removes the specified listener. |
| 564 | * |
| 565 | * @param listener The listener to remove. |
| 566 | * @return This conference. |
| 567 | * @hide |
| 568 | */ |
| 569 | public final Conference removeListener(Listener listener) { |
| 570 | mListeners.remove(listener); |
| 571 | return this; |
| 572 | } |
| 573 | |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 574 | /** |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 575 | * Retrieves the primary connection associated with the conference. The primary connection is |
| 576 | * the connection from which the conference will retrieve its current state. |
| 577 | * |
| 578 | * @return The primary connection. |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 579 | * @hide |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 580 | */ |
Tyler Gunn | 6c14a699 | 2019-02-04 15:12:06 -0800 | [diff] [blame] | 581 | @TestApi |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 582 | @SystemApi |
Santos Cordon | 4055d64 | 2015-05-12 14:19:24 -0700 | [diff] [blame] | 583 | public Connection getPrimaryConnection() { |
Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 584 | if (mUnmodifiableChildConnections == null || mUnmodifiableChildConnections.isEmpty()) { |
| 585 | return null; |
| 586 | } |
| 587 | return mUnmodifiableChildConnections.get(0); |
| 588 | } |
| 589 | |
| 590 | /** |
Wei Huang | 7f7f72e | 2018-05-30 19:21:36 +0800 | [diff] [blame] | 591 | * Updates RIL voice radio technology used for current conference after its creation. |
| 592 | * |
| 593 | * @hide |
| 594 | */ |
| 595 | public void updateCallRadioTechAfterCreation() { |
| 596 | final Connection primaryConnection = getPrimaryConnection(); |
| 597 | if (primaryConnection != null) { |
| 598 | setCallRadioTech(primaryConnection.getCallRadioTech()); |
| 599 | } else { |
| 600 | Log.w(this, "No primary connection found while updateCallRadioTechAfterCreation"); |
| 601 | } |
| 602 | } |
| 603 | |
| 604 | /** |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 605 | * @hide |
| 606 | * @deprecated Use {@link #setConnectionTime}. |
Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 607 | */ |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 608 | @Deprecated |
| 609 | @SystemApi |
| 610 | public final void setConnectTimeMillis(long connectTimeMillis) { |
| 611 | setConnectionTime(connectTimeMillis); |
Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | /** |
Tyler Gunn | 1754139 | 2018-02-01 08:58:38 -0800 | [diff] [blame] | 615 | * Sets the connection start time of the {@code Conference}. This is used in the call log to |
| 616 | * indicate the date and time when the conference took place. |
| 617 | * <p> |
| 618 | * Should be specified in wall-clock time returned by {@link System#currentTimeMillis()}. |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 619 | * <p> |
| 620 | * When setting the connection time, you should always set the connection elapsed time via |
Tyler Gunn | 1754139 | 2018-02-01 08:58:38 -0800 | [diff] [blame] | 621 | * {@link #setConnectionStartElapsedRealTime(long)} to ensure the duration is reflected. |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 622 | * |
Tyler Gunn | 1754139 | 2018-02-01 08:58:38 -0800 | [diff] [blame] | 623 | * @param connectionTimeMillis The connection time, in milliseconds, as returned by |
| 624 | * {@link System#currentTimeMillis()}. |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 625 | */ |
| 626 | public final void setConnectionTime(long connectionTimeMillis) { |
| 627 | mConnectTimeMillis = connectionTimeMillis; |
| 628 | } |
| 629 | |
| 630 | /** |
Tyler Gunn | 1754139 | 2018-02-01 08:58:38 -0800 | [diff] [blame] | 631 | * Sets the start time of the {@link Conference} which is the basis for the determining the |
| 632 | * duration of the {@link Conference}. |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 633 | * <p> |
Tyler Gunn | 1754139 | 2018-02-01 08:58:38 -0800 | [diff] [blame] | 634 | * You should use a value returned by {@link SystemClock#elapsedRealtime()} to ensure that time |
| 635 | * zone changes do not impact the conference duration. |
| 636 | * <p> |
| 637 | * When setting this, you should also set the connection time via |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 638 | * {@link #setConnectionTime(long)}. |
| 639 | * |
Tyler Gunn | 1754139 | 2018-02-01 08:58:38 -0800 | [diff] [blame] | 640 | * @param connectionStartElapsedRealTime The connection time, as measured by |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 641 | * {@link SystemClock#elapsedRealtime()}. |
| 642 | */ |
Tyler Gunn | 1754139 | 2018-02-01 08:58:38 -0800 | [diff] [blame] | 643 | public final void setConnectionStartElapsedRealTime(long connectionStartElapsedRealTime) { |
| 644 | mConnectionStartElapsedRealTime = connectionStartElapsedRealTime; |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 645 | } |
| 646 | |
| 647 | /** |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 648 | * @hide |
| 649 | * @deprecated Use {@link #getConnectionTime}. |
| 650 | */ |
| 651 | @Deprecated |
| 652 | @SystemApi |
| 653 | public final long getConnectTimeMillis() { |
| 654 | return getConnectionTime(); |
| 655 | } |
| 656 | |
| 657 | /** |
| 658 | * Retrieves the connection start time of the {@code Conference}, if specified. A value of |
Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 659 | * {@link #CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the start time |
| 660 | * of the conference. |
| 661 | * |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 662 | * @return The time at which the {@code Conference} was connected. |
Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 663 | */ |
Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 664 | public final long getConnectionTime() { |
Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 665 | return mConnectTimeMillis; |
| 666 | } |
| 667 | |
| 668 | /** |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 669 | * Retrieves the connection start time of the {@link Conference}, if specified. A value of |
| 670 | * {@link #CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the start time |
| 671 | * of the conference. |
| 672 | * |
| 673 | * This is based on the value of {@link SystemClock#elapsedRealtime()} to ensure that it is not |
| 674 | * impacted by wall clock changes (user initiated, network initiated, time zone change, etc). |
| 675 | * |
| 676 | * @return The elapsed time at which the {@link Conference} was connected. |
| 677 | * @hide |
| 678 | */ |
Tyler Gunn | 1754139 | 2018-02-01 08:58:38 -0800 | [diff] [blame] | 679 | public final long getConnectionStartElapsedRealTime() { |
| 680 | return mConnectionStartElapsedRealTime; |
Tyler Gunn | 3fa819c | 2017-08-04 09:27:26 -0700 | [diff] [blame] | 681 | } |
| 682 | |
| 683 | /** |
Wei Huang | 7f7f72e | 2018-05-30 19:21:36 +0800 | [diff] [blame] | 684 | * Sets RIL voice radio technology used for current conference. |
| 685 | * |
| 686 | * @param vrat the RIL voice radio technology used for current conference, |
| 687 | * see {@code RIL_RADIO_TECHNOLOGY_*} in {@link android.telephony.ServiceState}. |
| 688 | * |
| 689 | * @hide |
| 690 | */ |
Chen Xu | f85cf99 | 2019-10-02 00:20:43 -0700 | [diff] [blame] | 691 | public final void setCallRadioTech(@RilRadioTechnology int vrat) { |
Wei Huang | 7f7f72e | 2018-05-30 19:21:36 +0800 | [diff] [blame] | 692 | putExtra(TelecomManager.EXTRA_CALL_NETWORK_TYPE, |
| 693 | ServiceState.rilRadioTechnologyToNetworkType(vrat)); |
| 694 | } |
| 695 | |
| 696 | /** |
| 697 | * Returns RIL voice radio technology used for current conference. |
| 698 | * |
| 699 | * @return the RIL voice radio technology used for current conference, |
| 700 | * see {@code RIL_RADIO_TECHNOLOGY_*} in {@link android.telephony.ServiceState}. |
| 701 | * |
| 702 | * @hide |
| 703 | */ |
Chen Xu | f85cf99 | 2019-10-02 00:20:43 -0700 | [diff] [blame] | 704 | public final @RilRadioTechnology int getCallRadioTech() { |
Wei Huang | 7f7f72e | 2018-05-30 19:21:36 +0800 | [diff] [blame] | 705 | int voiceNetworkType = TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 706 | Bundle extras = getExtras(); |
| 707 | if (extras != null) { |
| 708 | voiceNetworkType = extras.getInt(TelecomManager.EXTRA_CALL_NETWORK_TYPE, |
| 709 | TelephonyManager.NETWORK_TYPE_UNKNOWN); |
| 710 | } |
| 711 | return ServiceState.networkTypeToRilRadioTechnology(voiceNetworkType); |
| 712 | } |
| 713 | |
| 714 | /** |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 715 | * Inform this Conference that the state of its audio output has been changed externally. |
| 716 | * |
| 717 | * @param state The new audio state. |
| 718 | * @hide |
| 719 | */ |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 720 | final void setCallAudioState(CallAudioState state) { |
| 721 | Log.d(this, "setCallAudioState %s", state); |
| 722 | mCallAudioState = state; |
| 723 | onAudioStateChanged(getAudioState()); |
| 724 | onCallAudioStateChanged(state); |
Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 725 | } |
| 726 | |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 727 | private void setState(int newState) { |
| 728 | if (newState != Connection.STATE_ACTIVE && |
| 729 | newState != Connection.STATE_HOLDING && |
| 730 | newState != Connection.STATE_DISCONNECTED) { |
| 731 | Log.w(this, "Unsupported state transition for Conference call.", |
| 732 | Connection.stateToString(newState)); |
| 733 | return; |
| 734 | } |
| 735 | |
| 736 | if (mState != newState) { |
| 737 | int oldState = mState; |
| 738 | mState = newState; |
| 739 | for (Listener l : mListeners) { |
| 740 | l.onStateChanged(this, oldState, newState); |
| 741 | } |
| 742 | } |
| 743 | } |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 744 | |
| 745 | private final void clearConferenceableList() { |
| 746 | for (Connection c : mConferenceableConnections) { |
| 747 | c.removeConnectionListener(mConnectionDeathListener); |
| 748 | } |
| 749 | mConferenceableConnections.clear(); |
| 750 | } |
Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 751 | |
| 752 | @Override |
| 753 | public String toString() { |
| 754 | return String.format(Locale.US, |
| 755 | "[State: %s,Capabilites: %s, VideoState: %s, VideoProvider: %s, ThisObject %s]", |
| 756 | Connection.stateToString(mState), |
| 757 | Call.Details.capabilitiesToString(mConnectionCapabilities), |
| 758 | getVideoState(), |
| 759 | getVideoProvider(), |
| 760 | super.toString()); |
| 761 | } |
Andrew Lee | 0f51da3 | 2015-04-16 13:11:55 -0700 | [diff] [blame] | 762 | |
Andrew Lee | edc625f | 2015-04-14 13:38:12 -0700 | [diff] [blame] | 763 | /** |
| 764 | * Sets the label and icon status to display in the InCall UI. |
| 765 | * |
| 766 | * @param statusHints The status label and icon to set. |
| 767 | */ |
| 768 | public final void setStatusHints(StatusHints statusHints) { |
| 769 | mStatusHints = statusHints; |
| 770 | for (Listener l : mListeners) { |
| 771 | l.onStatusHintsChanged(this, statusHints); |
| 772 | } |
| 773 | } |
| 774 | |
| 775 | /** |
| 776 | * @return The status hints for this conference. |
| 777 | */ |
| 778 | public final StatusHints getStatusHints() { |
| 779 | return mStatusHints; |
| 780 | } |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 781 | |
| 782 | /** |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 783 | * Replaces all the extras associated with this {@code Conference}. |
| 784 | * <p> |
| 785 | * New or existing keys are replaced in the {@code Conference} extras. Keys which are no longer |
| 786 | * in the new extras, but were present the last time {@code setExtras} was called are removed. |
| 787 | * <p> |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 788 | * Alternatively you may use the {@link #putExtras(Bundle)}, and |
| 789 | * {@link #removeExtras(String...)} methods to modify the extras. |
| 790 | * <p> |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 791 | * No assumptions should be made as to how an In-Call UI or service will handle these extras. |
Tyler Gunn | 9c0eb0b | 2016-06-29 11:23:25 -0700 | [diff] [blame] | 792 | * Keys should be fully qualified (e.g., com.example.extras.MY_EXTRA) to avoid conflicts. |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 793 | * |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 794 | * @param extras The extras associated with this {@code Conference}. |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 795 | */ |
| 796 | public final void setExtras(@Nullable Bundle extras) { |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 797 | // Keeping putExtras and removeExtras in the same lock so that this operation happens as a |
| 798 | // block instead of letting other threads put/remove while this method is running. |
| 799 | synchronized (mExtrasLock) { |
| 800 | // Add/replace any new or changed extras values. |
| 801 | putExtras(extras); |
| 802 | // If we have used "setExtras" in the past, compare the key set from the last invocation |
| 803 | // to the current one and remove any keys that went away. |
| 804 | if (mPreviousExtraKeys != null) { |
| 805 | List<String> toRemove = new ArrayList<String>(); |
| 806 | for (String oldKey : mPreviousExtraKeys) { |
| 807 | if (extras == null || !extras.containsKey(oldKey)) { |
| 808 | toRemove.add(oldKey); |
| 809 | } |
| 810 | } |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 811 | |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 812 | if (!toRemove.isEmpty()) { |
| 813 | removeExtras(toRemove); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 814 | } |
| 815 | } |
| 816 | |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 817 | // Track the keys the last time set called setExtras. This way, the next time setExtras |
| 818 | // is called we can see if the caller has removed any extras values. |
| 819 | if (mPreviousExtraKeys == null) { |
| 820 | mPreviousExtraKeys = new ArraySet<String>(); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 821 | } |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 822 | mPreviousExtraKeys.clear(); |
| 823 | if (extras != null) { |
| 824 | mPreviousExtraKeys.addAll(extras.keySet()); |
| 825 | } |
Tyler Gunn | a8fb8ab | 2016-03-29 10:24:22 -0700 | [diff] [blame] | 826 | } |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 827 | } |
| 828 | |
| 829 | /** |
| 830 | * Adds some extras to this {@link Conference}. Existing keys are replaced and new ones are |
| 831 | * added. |
| 832 | * <p> |
| 833 | * No assumptions should be made as to how an In-Call UI or service will handle these extras. |
| 834 | * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts. |
| 835 | * |
| 836 | * @param extras The extras to add. |
| 837 | */ |
| 838 | public final void putExtras(@NonNull Bundle extras) { |
| 839 | if (extras == null) { |
| 840 | return; |
| 841 | } |
| 842 | |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 843 | // Creating a Bundle clone so we don't have to synchronize on mExtrasLock while calling |
| 844 | // onExtrasChanged. |
| 845 | Bundle listenersBundle; |
| 846 | synchronized (mExtrasLock) { |
| 847 | if (mExtras == null) { |
| 848 | mExtras = new Bundle(); |
| 849 | } |
| 850 | mExtras.putAll(extras); |
| 851 | listenersBundle = new Bundle(mExtras); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 852 | } |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 853 | |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 854 | for (Listener l : mListeners) { |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 855 | l.onExtrasChanged(this, new Bundle(listenersBundle)); |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 856 | } |
| 857 | } |
| 858 | |
| 859 | /** |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 860 | * Adds a boolean extra to this {@link Conference}. |
| 861 | * |
| 862 | * @param key The extra key. |
| 863 | * @param value The value. |
| 864 | * @hide |
| 865 | */ |
| 866 | public final void putExtra(String key, boolean value) { |
| 867 | Bundle newExtras = new Bundle(); |
| 868 | newExtras.putBoolean(key, value); |
| 869 | putExtras(newExtras); |
| 870 | } |
| 871 | |
| 872 | /** |
| 873 | * Adds an integer extra to this {@link Conference}. |
| 874 | * |
| 875 | * @param key The extra key. |
| 876 | * @param value The value. |
| 877 | * @hide |
| 878 | */ |
| 879 | public final void putExtra(String key, int value) { |
| 880 | Bundle newExtras = new Bundle(); |
| 881 | newExtras.putInt(key, value); |
| 882 | putExtras(newExtras); |
| 883 | } |
| 884 | |
| 885 | /** |
| 886 | * Adds a string extra to this {@link Conference}. |
| 887 | * |
| 888 | * @param key The extra key. |
| 889 | * @param value The value. |
| 890 | * @hide |
| 891 | */ |
| 892 | public final void putExtra(String key, String value) { |
| 893 | Bundle newExtras = new Bundle(); |
| 894 | newExtras.putString(key, value); |
| 895 | putExtras(newExtras); |
| 896 | } |
| 897 | |
| 898 | /** |
Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 899 | * Removes extras from this {@link Conference}. |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 900 | * |
Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 901 | * @param keys The keys of the extras to remove. |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 902 | */ |
| 903 | public final void removeExtras(List<String> keys) { |
| 904 | if (keys == null || keys.isEmpty()) { |
| 905 | return; |
| 906 | } |
| 907 | |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 908 | synchronized (mExtrasLock) { |
| 909 | if (mExtras != null) { |
| 910 | for (String key : keys) { |
| 911 | mExtras.remove(key); |
| 912 | } |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 913 | } |
| 914 | } |
| 915 | |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 916 | List<String> unmodifiableKeys = Collections.unmodifiableList(keys); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 917 | for (Listener l : mListeners) { |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 918 | l.onExtrasRemoved(this, unmodifiableKeys); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 919 | } |
| 920 | } |
| 921 | |
| 922 | /** |
Tyler Gunn | 071be6f | 2016-05-10 14:52:33 -0700 | [diff] [blame] | 923 | * Removes extras from this {@link Conference}. |
| 924 | * |
| 925 | * @param keys The keys of the extras to remove. |
| 926 | */ |
| 927 | public final void removeExtras(String ... keys) { |
| 928 | removeExtras(Arrays.asList(keys)); |
| 929 | } |
| 930 | |
| 931 | /** |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 932 | * Returns the extras associated with this conference. |
Tyler Gunn | 2cbe2b5 | 2016-05-04 15:48:10 +0000 | [diff] [blame] | 933 | * <p> |
| 934 | * Extras should be updated using {@link #putExtras(Bundle)} and {@link #removeExtras(List)}. |
| 935 | * <p> |
| 936 | * Telecom or an {@link InCallService} can also update the extras via |
| 937 | * {@link android.telecom.Call#putExtras(Bundle)}, and |
| 938 | * {@link Call#removeExtras(List)}. |
| 939 | * <p> |
| 940 | * The conference is notified of changes to the extras made by Telecom or an |
| 941 | * {@link InCallService} by {@link #onExtrasChanged(Bundle)}. |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 942 | * |
| 943 | * @return The extras associated with this connection. |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 944 | */ |
| 945 | public final Bundle getExtras() { |
| 946 | return mExtras; |
| 947 | } |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 948 | |
| 949 | /** |
| 950 | * Notifies this {@link Conference} of a change to the extras made outside the |
| 951 | * {@link ConnectionService}. |
| 952 | * <p> |
| 953 | * These extras changes can originate from Telecom itself, or from an {@link InCallService} via |
| 954 | * {@link android.telecom.Call#putExtras(Bundle)}, and |
| 955 | * {@link Call#removeExtras(List)}. |
| 956 | * |
| 957 | * @param extras The new extras bundle. |
| 958 | */ |
| 959 | public void onExtrasChanged(Bundle extras) {} |
| 960 | |
| 961 | /** |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 962 | * Set whether Telecom should treat this {@link Conference} as a conference call or if it |
| 963 | * should treat it as a single-party call. |
| 964 | * This method is used as part of a workaround regarding IMS conference calls and user |
| 965 | * expectation. In IMS, once a conference is formed, the UE is connected to an IMS conference |
| 966 | * server. If all participants of the conference drop out of the conference except for one, the |
| 967 | * UE is still connected to the IMS conference server. At this point, the user logically |
| 968 | * assumes they're no longer in a conference, yet the underlying network actually is. |
| 969 | * To help provide a better user experiece, IMS conference calls can pretend to actually be a |
| 970 | * single-party call when the participant count drops to 1. Although the dialer/phone app |
| 971 | * could perform this trickery, it makes sense to do this in Telephony since a fix there will |
| 972 | * ensure that bluetooth head units, auto and wearable apps all behave consistently. |
| 973 | * |
| 974 | * @param isConference {@code true} if this {@link Conference} should be treated like a |
| 975 | * conference call, {@code false} if it should be treated like a single-party call. |
| 976 | * @hide |
| 977 | */ |
| 978 | public void setConferenceState(boolean isConference) { |
| 979 | for (Listener l : mListeners) { |
| 980 | l.onConferenceStateChanged(this, isConference); |
| 981 | } |
| 982 | } |
| 983 | |
| 984 | /** |
| 985 | * Sets the address of this {@link Conference}. Used when {@link #setConferenceState(boolean)} |
| 986 | * is called to mark a conference temporarily as NOT a conference. |
| 987 | * |
| 988 | * @param address The new address. |
| 989 | * @param presentation The presentation requirements for the address. |
| 990 | * See {@link TelecomManager} for valid values. |
| 991 | * @hide |
| 992 | */ |
| 993 | public final void setAddress(Uri address, int presentation) { |
| 994 | Log.d(this, "setAddress %s", address); |
Tyler Gunn | ac60f95 | 2019-05-31 07:23:16 -0700 | [diff] [blame] | 995 | mAddress = address; |
| 996 | mAddressPresentation = presentation; |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 997 | for (Listener l : mListeners) { |
| 998 | l.onAddressChanged(this, address, presentation); |
| 999 | } |
| 1000 | } |
| 1001 | |
| 1002 | /** |
Tyler Gunn | ac60f95 | 2019-05-31 07:23:16 -0700 | [diff] [blame] | 1003 | * Returns the "address" associated with the conference. This is applicable in two cases: |
| 1004 | * <ol> |
| 1005 | * <li>When {@link #setConferenceState(boolean)} is used to mark a conference as |
| 1006 | * temporarily "not a conference"; we need to present the correct address in the in-call |
| 1007 | * UI.</li> |
| 1008 | * <li>When the conference is not hosted on the current device, we need to know the address |
| 1009 | * information for the purpose of showing the original address to the user, as well as for |
| 1010 | * logging to the call log.</li> |
| 1011 | * </ol> |
| 1012 | * @return The address of the conference, or {@code null} if not applicable. |
| 1013 | * @hide |
| 1014 | */ |
| 1015 | public final Uri getAddress() { |
| 1016 | return mAddress; |
| 1017 | } |
| 1018 | |
| 1019 | /** |
| 1020 | * Returns the address presentation associated with the conference. |
| 1021 | * <p> |
| 1022 | * This is applicable in two cases: |
| 1023 | * <ol> |
| 1024 | * <li>When {@link #setConferenceState(boolean)} is used to mark a conference as |
| 1025 | * temporarily "not a conference"; we need to present the correct address in the in-call |
| 1026 | * UI.</li> |
| 1027 | * <li>When the conference is not hosted on the current device, we need to know the address |
| 1028 | * information for the purpose of showing the original address to the user, as well as for |
| 1029 | * logging to the call log.</li> |
| 1030 | * </ol> |
| 1031 | * @return The address of the conference, or {@code null} if not applicable. |
| 1032 | * @hide |
| 1033 | */ |
| 1034 | public final int getAddressPresentation() { |
| 1035 | return mAddressPresentation; |
| 1036 | } |
| 1037 | |
| 1038 | /** |
| 1039 | * @return The caller display name (CNAP). |
| 1040 | * @hide |
| 1041 | */ |
| 1042 | public final String getCallerDisplayName() { |
| 1043 | return mCallerDisplayName; |
| 1044 | } |
| 1045 | |
| 1046 | /** |
| 1047 | * @return The presentation requirements for the handle. |
| 1048 | * See {@link TelecomManager} for valid values. |
| 1049 | * @hide |
| 1050 | */ |
| 1051 | public final int getCallerDisplayNamePresentation() { |
| 1052 | return mCallerDisplayNamePresentation; |
| 1053 | } |
| 1054 | |
| 1055 | /** |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 1056 | * Sets the caller display name (CNAP) of this {@link Conference}. Used when |
| 1057 | * {@link #setConferenceState(boolean)} is called to mark a conference temporarily as NOT a |
| 1058 | * conference. |
| 1059 | * |
| 1060 | * @param callerDisplayName The new display name. |
| 1061 | * @param presentation The presentation requirements for the handle. |
| 1062 | * See {@link TelecomManager} for valid values. |
| 1063 | * @hide |
| 1064 | */ |
| 1065 | public final void setCallerDisplayName(String callerDisplayName, int presentation) { |
| 1066 | Log.d(this, "setCallerDisplayName %s", callerDisplayName); |
Tyler Gunn | ac60f95 | 2019-05-31 07:23:16 -0700 | [diff] [blame] | 1067 | mCallerDisplayName = callerDisplayName; |
| 1068 | mCallerDisplayNamePresentation = presentation; |
Tyler Gunn | 68a73a4 | 2018-10-03 15:38:57 -0700 | [diff] [blame] | 1069 | for (Listener l : mListeners) { |
| 1070 | l.onCallerDisplayNameChanged(this, callerDisplayName, presentation); |
| 1071 | } |
| 1072 | } |
| 1073 | |
| 1074 | /** |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1075 | * Handles a change to extras received from Telecom. |
| 1076 | * |
| 1077 | * @param extras The new extras. |
| 1078 | * @hide |
| 1079 | */ |
| 1080 | final void handleExtrasChanged(Bundle extras) { |
Brad Ebinger | 4fa6a01 | 2016-06-14 17:04:01 -0700 | [diff] [blame] | 1081 | Bundle b = null; |
| 1082 | synchronized (mExtrasLock) { |
| 1083 | mExtras = extras; |
| 1084 | if (mExtras != null) { |
| 1085 | b = new Bundle(mExtras); |
| 1086 | } |
| 1087 | } |
| 1088 | onExtrasChanged(b); |
Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 1089 | } |
Hall Liu | c9bc1c6 | 2019-04-16 14:00:55 -0700 | [diff] [blame] | 1090 | |
| 1091 | /** |
| 1092 | * See {@link Connection#sendConnectionEvent(String, Bundle)} |
| 1093 | * @hide |
| 1094 | */ |
| 1095 | public void sendConnectionEvent(String event, Bundle extras) { |
| 1096 | for (Listener l : mListeners) { |
| 1097 | l.onConnectionEvent(this, event, extras); |
| 1098 | } |
| 1099 | } |
Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 1100 | } |