| 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; |
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 22 | import android.os.Bundle; |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 23 | import android.telecom.Connection.VideoProvider; |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 24 | import android.util.ArraySet; |
| Evan Charlton | 0e094d9 | 2014-11-08 15:49:16 -0800 | [diff] [blame] | 25 | |
| Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 26 | import java.util.ArrayList; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 27 | import java.util.Collections; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 28 | import java.util.List; |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 29 | import java.util.Locale; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 30 | import java.util.Set; |
| 31 | import java.util.concurrent.CopyOnWriteArrayList; |
| 32 | import java.util.concurrent.CopyOnWriteArraySet; |
| 33 | |
| 34 | /** |
| 35 | * Represents a conference call which can contain any number of {@link Connection} objects. |
| 36 | */ |
| Yorke Lee | abfcfdc | 2015-05-13 18:55:18 -0700 | [diff] [blame] | 37 | public abstract class Conference extends Conferenceable { |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 38 | |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 39 | /** |
| 40 | * Used to indicate that the conference connection time is not specified. If not specified, |
| 41 | * Telecom will set the connect time. |
| 42 | */ |
| Jay Shrauner | 164a0ac | 2015-04-14 18:16:10 -0700 | [diff] [blame] | 43 | public static final long CONNECT_TIME_NOT_SPECIFIED = 0; |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 44 | |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 45 | /** @hide */ |
| 46 | public abstract static class Listener { |
| 47 | public void onStateChanged(Conference conference, int oldState, int newState) {} |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 48 | public void onDisconnected(Conference conference, DisconnectCause disconnectCause) {} |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 49 | public void onConnectionAdded(Conference conference, Connection connection) {} |
| 50 | public void onConnectionRemoved(Conference conference, Connection connection) {} |
| Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 51 | public void onConferenceableConnectionsChanged( |
| 52 | Conference conference, List<Connection> conferenceableConnections) {} |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 53 | public void onDestroyed(Conference conference) {} |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 54 | public void onConnectionCapabilitiesChanged( |
| 55 | Conference conference, int connectionCapabilities) {} |
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 56 | public void onConnectionPropertiesChanged( |
| 57 | Conference conference, int connectionProperties) {} |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 58 | public void onVideoStateChanged(Conference c, int videoState) { } |
| 59 | public void onVideoProviderChanged(Conference c, Connection.VideoProvider videoProvider) {} |
| Andrew Lee | edc625f | 2015-04-14 13:38:12 -0700 | [diff] [blame] | 60 | public void onStatusHintsChanged(Conference conference, StatusHints statusHints) {} |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 61 | public void onExtrasChanged(Conference c, Bundle extras) {} |
| 62 | public void onExtrasRemoved(Conference c, List<String> keys) {} |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | private final Set<Listener> mListeners = new CopyOnWriteArraySet<>(); |
| 66 | private final List<Connection> mChildConnections = new CopyOnWriteArrayList<>(); |
| Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 67 | private final List<Connection> mUnmodifiableChildConnections = |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 68 | Collections.unmodifiableList(mChildConnections); |
| Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 69 | private final List<Connection> mConferenceableConnections = new ArrayList<>(); |
| 70 | private final List<Connection> mUnmodifiableConferenceableConnections = |
| 71 | Collections.unmodifiableList(mConferenceableConnections); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 72 | |
| Jack Yu | 6714030 | 2015-12-10 12:27:58 -0800 | [diff] [blame] | 73 | private String mTelecomCallId; |
| Jay Shrauner | 164a0ac | 2015-04-14 18:16:10 -0700 | [diff] [blame] | 74 | private PhoneAccountHandle mPhoneAccount; |
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 75 | private CallAudioState mCallAudioState; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 76 | private int mState = Connection.STATE_NEW; |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 77 | private DisconnectCause mDisconnectCause; |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 78 | private int mConnectionCapabilities; |
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 79 | private int mConnectionProperties; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 80 | private String mDisconnectMessage; |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 81 | private long mConnectTimeMillis = CONNECT_TIME_NOT_SPECIFIED; |
| Andrew Lee | edc625f | 2015-04-14 13:38:12 -0700 | [diff] [blame] | 82 | private StatusHints mStatusHints; |
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 83 | private Bundle mExtras; |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 84 | private Set<String> mPreviousExtraKeys; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 85 | |
| Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 86 | private final Connection.Listener mConnectionDeathListener = new Connection.Listener() { |
| 87 | @Override |
| 88 | public void onDestroyed(Connection c) { |
| 89 | if (mConferenceableConnections.remove(c)) { |
| 90 | fireOnConferenceableConnectionsChanged(); |
| 91 | } |
| 92 | } |
| 93 | }; |
| 94 | |
| Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 95 | /** |
| 96 | * Constructs a new Conference with a mandatory {@link PhoneAccountHandle} |
| 97 | * |
| 98 | * @param phoneAccount The {@code PhoneAccountHandle} associated with the conference. |
| 99 | */ |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 100 | public Conference(PhoneAccountHandle phoneAccount) { |
| 101 | mPhoneAccount = phoneAccount; |
| 102 | } |
| 103 | |
| Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 104 | /** |
| Jack Yu | 6714030 | 2015-12-10 12:27:58 -0800 | [diff] [blame] | 105 | * Returns the telecom internal call ID associated with this conference. |
| 106 | * |
| 107 | * @return The telecom call ID. |
| 108 | * @hide |
| 109 | */ |
| 110 | public final String getTelecomCallId() { |
| 111 | return mTelecomCallId; |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Sets the telecom internal call ID associated with this conference. |
| 116 | * |
| 117 | * @param telecomCallId The telecom call ID. |
| 118 | * @hide |
| 119 | */ |
| 120 | public final void setTelecomCallId(String telecomCallId) { |
| 121 | mTelecomCallId = telecomCallId; |
| 122 | } |
| 123 | |
| 124 | /** |
| Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 125 | * Returns the {@link PhoneAccountHandle} the conference call is being placed through. |
| 126 | * |
| 127 | * @return A {@code PhoneAccountHandle} object representing the PhoneAccount of the conference. |
| 128 | */ |
| Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 129 | public final PhoneAccountHandle getPhoneAccountHandle() { |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 130 | return mPhoneAccount; |
| 131 | } |
| 132 | |
| Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 133 | /** |
| 134 | * Returns the list of connections currently associated with the conference call. |
| 135 | * |
| 136 | * @return A list of {@code Connection} objects which represent the children of the conference. |
| 137 | */ |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 138 | public final List<Connection> getConnections() { |
| Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 139 | return mUnmodifiableChildConnections; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 140 | } |
| 141 | |
| Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 142 | /** |
| 143 | * Gets the state of the conference call. See {@link Connection} for valid values. |
| 144 | * |
| 145 | * @return A constant representing the state the conference call is currently in. |
| 146 | */ |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 147 | public final int getState() { |
| 148 | return mState; |
| 149 | } |
| 150 | |
| Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 151 | /** |
| Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 152 | * Returns the capabilities of the conference. See {@code CAPABILITY_*} constants in class |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 153 | * {@link Connection} for valid values. |
| Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 154 | * |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 155 | * @return A bitmask of the capabilities of the conference call. |
| Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 156 | */ |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 157 | public final int getConnectionCapabilities() { |
| 158 | return mConnectionCapabilities; |
| 159 | } |
| 160 | |
| 161 | /** |
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 162 | * Returns the properties of the conference. See {@code PROPERTY_*} constants in class |
| 163 | * {@link Connection} for valid values. |
| 164 | * |
| 165 | * @return A bitmask of the properties of the conference call. |
| Tyler Gunn | 1bf206b | 2016-04-15 11:28:44 -0700 | [diff] [blame^] | 166 | * @hide |
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 167 | */ |
| 168 | public final int getConnectionProperties() { |
| 169 | return mConnectionProperties; |
| 170 | } |
| 171 | |
| 172 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 173 | * Whether the given capabilities support the specified capability. |
| 174 | * |
| 175 | * @param capabilities A capability bit field. |
| 176 | * @param capability The capability to check capabilities for. |
| 177 | * @return Whether the specified capability is supported. |
| 178 | * @hide |
| 179 | */ |
| 180 | public static boolean can(int capabilities, int capability) { |
| 181 | return (capabilities & capability) != 0; |
| 182 | } |
| 183 | |
| 184 | /** |
| 185 | * Whether the capabilities of this {@code Connection} supports the specified capability. |
| 186 | * |
| 187 | * @param capability The capability to check capabilities for. |
| 188 | * @return Whether the specified capability is supported. |
| 189 | * @hide |
| 190 | */ |
| 191 | public boolean can(int capability) { |
| 192 | return can(mConnectionCapabilities, capability); |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Removes the specified capability from the set of capabilities of this {@code Conference}. |
| 197 | * |
| 198 | * @param capability The capability to remove from the set. |
| 199 | * @hide |
| 200 | */ |
| 201 | public void removeCapability(int capability) { |
| Omkar Kolangade | a0f46a9 | 2015-03-23 17:51:16 -0700 | [diff] [blame] | 202 | int newCapabilities = mConnectionCapabilities; |
| 203 | newCapabilities &= ~capability; |
| 204 | |
| 205 | setConnectionCapabilities(newCapabilities); |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | /** |
| 209 | * Adds the specified capability to the set of capabilities of this {@code Conference}. |
| 210 | * |
| 211 | * @param capability The capability to add to the set. |
| 212 | * @hide |
| 213 | */ |
| 214 | public void addCapability(int capability) { |
| Omkar Kolangade | a0f46a9 | 2015-03-23 17:51:16 -0700 | [diff] [blame] | 215 | int newCapabilities = mConnectionCapabilities; |
| 216 | newCapabilities |= capability; |
| 217 | |
| 218 | setConnectionCapabilities(newCapabilities); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | /** |
| Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 222 | * @return The audio state of the conference, describing how its audio is currently |
| 223 | * being routed by the system. This is {@code null} if this Conference |
| 224 | * does not directly know about its audio state. |
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 225 | * @deprecated Use {@link #getCallAudioState()} instead. |
| 226 | * @hide |
| Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 227 | */ |
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 228 | @Deprecated |
| 229 | @SystemApi |
| Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 230 | public final AudioState getAudioState() { |
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 231 | return new AudioState(mCallAudioState); |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * @return The audio state of the conference, describing how its audio is currently |
| 236 | * being routed by the system. This is {@code null} if this Conference |
| 237 | * does not directly know about its audio state. |
| 238 | */ |
| 239 | public final CallAudioState getCallAudioState() { |
| 240 | return mCallAudioState; |
| Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | /** |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 244 | * Returns VideoProvider of the primary call. This can be null. |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 245 | */ |
| 246 | public VideoProvider getVideoProvider() { |
| 247 | return null; |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * Returns video state of the primary call. |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 252 | */ |
| 253 | public int getVideoState() { |
| Tyler Gunn | 87b73f3 | 2015-06-03 10:09:59 -0700 | [diff] [blame] | 254 | return VideoProfile.STATE_AUDIO_ONLY; |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | /** |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 258 | * Invoked when the Conference and all it's {@link Connection}s should be disconnected. |
| 259 | */ |
| 260 | public void onDisconnect() {} |
| 261 | |
| 262 | /** |
| 263 | * Invoked when the specified {@link Connection} should be separated from the conference call. |
| 264 | * |
| 265 | * @param connection The connection to separate. |
| 266 | */ |
| 267 | public void onSeparate(Connection connection) {} |
| 268 | |
| 269 | /** |
| Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 270 | * Invoked when the specified {@link Connection} should merged with the conference call. |
| 271 | * |
| 272 | * @param connection The {@code Connection} to merge. |
| 273 | */ |
| 274 | public void onMerge(Connection connection) {} |
| 275 | |
| 276 | /** |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 277 | * Invoked when the conference should be put on hold. |
| 278 | */ |
| 279 | public void onHold() {} |
| 280 | |
| 281 | /** |
| 282 | * Invoked when the conference should be moved from hold to active. |
| 283 | */ |
| 284 | public void onUnhold() {} |
| 285 | |
| 286 | /** |
| Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 287 | * Invoked when the child calls should be merged. Only invoked if the conference contains the |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 288 | * capability {@link Connection#CAPABILITY_MERGE_CONFERENCE}. |
| Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 289 | */ |
| 290 | public void onMerge() {} |
| 291 | |
| 292 | /** |
| 293 | * Invoked when the child calls should be swapped. Only invoked if the conference contains the |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 294 | * capability {@link Connection#CAPABILITY_SWAP_CONFERENCE}. |
| Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 295 | */ |
| 296 | public void onSwap() {} |
| 297 | |
| 298 | /** |
| Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 299 | * Notifies this conference of a request to play a DTMF tone. |
| 300 | * |
| 301 | * @param c A DTMF character. |
| 302 | */ |
| 303 | public void onPlayDtmfTone(char c) {} |
| 304 | |
| 305 | /** |
| 306 | * Notifies this conference of a request to stop any currently playing DTMF tones. |
| 307 | */ |
| 308 | public void onStopDtmfTone() {} |
| 309 | |
| 310 | /** |
| 311 | * Notifies this conference that the {@link #getAudioState()} property has a new value. |
| 312 | * |
| 313 | * @param state The new call audio state. |
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 314 | * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState)} instead. |
| 315 | * @hide |
| Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 316 | */ |
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 317 | @SystemApi |
| 318 | @Deprecated |
| Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 319 | public void onAudioStateChanged(AudioState state) {} |
| 320 | |
| 321 | /** |
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 322 | * Notifies this conference that the {@link #getCallAudioState()} property has a new value. |
| 323 | * |
| 324 | * @param state The new call audio state. |
| 325 | */ |
| 326 | public void onCallAudioStateChanged(CallAudioState state) {} |
| 327 | |
| 328 | /** |
| Andrew Lee | 46f7f5d | 2014-11-06 17:00:25 -0800 | [diff] [blame] | 329 | * Notifies this conference that a connection has been added to it. |
| 330 | * |
| 331 | * @param connection The newly added connection. |
| 332 | */ |
| 333 | public void onConnectionAdded(Connection connection) {} |
| 334 | |
| 335 | /** |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 336 | * Sets state to be on hold. |
| 337 | */ |
| 338 | public final void setOnHold() { |
| 339 | setState(Connection.STATE_HOLDING); |
| 340 | } |
| 341 | |
| 342 | /** |
| Tyler Gunn | d46595a | 2015-06-01 14:29:11 -0700 | [diff] [blame] | 343 | * Sets state to be dialing. |
| 344 | */ |
| 345 | public final void setDialing() { |
| 346 | setState(Connection.STATE_DIALING); |
| 347 | } |
| 348 | |
| 349 | /** |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 350 | * Sets state to be active. |
| 351 | */ |
| 352 | public final void setActive() { |
| 353 | setState(Connection.STATE_ACTIVE); |
| 354 | } |
| 355 | |
| 356 | /** |
| 357 | * Sets state to disconnected. |
| 358 | * |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 359 | * @param disconnectCause The reason for the disconnection, as described by |
| 360 | * {@link android.telecom.DisconnectCause}. |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 361 | */ |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 362 | public final void setDisconnected(DisconnectCause disconnectCause) { |
| 363 | mDisconnectCause = disconnectCause;; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 364 | setState(Connection.STATE_DISCONNECTED); |
| 365 | for (Listener l : mListeners) { |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 366 | l.onDisconnected(this, mDisconnectCause); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 367 | } |
| 368 | } |
| 369 | |
| 370 | /** |
| mike dooley | 1cf14ac | 2014-11-04 10:59:53 -0800 | [diff] [blame] | 371 | * @return The {@link DisconnectCause} for this connection. |
| 372 | */ |
| 373 | public final DisconnectCause getDisconnectCause() { |
| 374 | return mDisconnectCause; |
| 375 | } |
| 376 | |
| 377 | /** |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 378 | * Sets the capabilities of a conference. See {@code CAPABILITY_*} constants of class |
| 379 | * {@link Connection} for valid values. |
| Nancy Chen | 56fc25d | 2014-09-09 12:24:51 -0700 | [diff] [blame] | 380 | * |
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 381 | * @param connectionCapabilities A bitmask of the {@code Capabilities} of the conference call. |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 382 | */ |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 383 | public final void setConnectionCapabilities(int connectionCapabilities) { |
| 384 | if (connectionCapabilities != mConnectionCapabilities) { |
| 385 | mConnectionCapabilities = connectionCapabilities; |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 386 | |
| 387 | for (Listener l : mListeners) { |
| Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 388 | l.onConnectionCapabilitiesChanged(this, mConnectionCapabilities); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 389 | } |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | /** |
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 394 | * Sets the properties of a conference. See {@code PROPERTY_*} constants of class |
| 395 | * {@link Connection} for valid values. |
| 396 | * |
| 397 | * @param connectionProperties A bitmask of the {@code Properties} of the conference call. |
| Tyler Gunn | 1bf206b | 2016-04-15 11:28:44 -0700 | [diff] [blame^] | 398 | * @hide |
| Tyler Gunn | 720c664 | 2016-03-22 09:02:47 -0700 | [diff] [blame] | 399 | */ |
| 400 | public final void setConnectionProperties(int connectionProperties) { |
| 401 | if (connectionProperties != mConnectionProperties) { |
| 402 | mConnectionProperties = connectionProperties; |
| 403 | |
| 404 | for (Listener l : mListeners) { |
| 405 | l.onConnectionPropertiesChanged(this, mConnectionProperties); |
| 406 | } |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | /** |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 411 | * Adds the specified connection as a child of this conference. |
| 412 | * |
| 413 | * @param connection The connection to add. |
| 414 | * @return True if the connection was successfully added. |
| 415 | */ |
| Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 416 | public final boolean addConnection(Connection connection) { |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 417 | Log.d(this, "Connection=%s, connection=", connection); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 418 | if (connection != null && !mChildConnections.contains(connection)) { |
| 419 | if (connection.setConference(this)) { |
| 420 | mChildConnections.add(connection); |
| Andrew Lee | 46f7f5d | 2014-11-06 17:00:25 -0800 | [diff] [blame] | 421 | onConnectionAdded(connection); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 422 | for (Listener l : mListeners) { |
| 423 | l.onConnectionAdded(this, connection); |
| 424 | } |
| 425 | return true; |
| 426 | } |
| 427 | } |
| 428 | return false; |
| 429 | } |
| 430 | |
| 431 | /** |
| 432 | * Removes the specified connection as a child of this conference. |
| 433 | * |
| 434 | * @param connection The connection to remove. |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 435 | */ |
| Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 436 | public final void removeConnection(Connection connection) { |
| Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 437 | Log.d(this, "removing %s from %s", connection, mChildConnections); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 438 | if (connection != null && mChildConnections.remove(connection)) { |
| 439 | connection.resetConference(); |
| 440 | for (Listener l : mListeners) { |
| 441 | l.onConnectionRemoved(this, connection); |
| 442 | } |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | /** |
| Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 447 | * Sets the connections with which this connection can be conferenced. |
| 448 | * |
| 449 | * @param conferenceableConnections The set of connections this connection can conference with. |
| 450 | */ |
| 451 | public final void setConferenceableConnections(List<Connection> conferenceableConnections) { |
| 452 | clearConferenceableList(); |
| 453 | for (Connection c : conferenceableConnections) { |
| 454 | // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a |
| 455 | // small amount of items here. |
| 456 | if (!mConferenceableConnections.contains(c)) { |
| 457 | c.addConnectionListener(mConnectionDeathListener); |
| 458 | mConferenceableConnections.add(c); |
| 459 | } |
| 460 | } |
| 461 | fireOnConferenceableConnectionsChanged(); |
| 462 | } |
| 463 | |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 464 | /** |
| 465 | * Set the video state for the conference. |
| Yorke Lee | 32f2473 | 2015-05-12 16:18:03 -0700 | [diff] [blame] | 466 | * Valid values: {@link VideoProfile#STATE_AUDIO_ONLY}, |
| 467 | * {@link VideoProfile#STATE_BIDIRECTIONAL}, |
| 468 | * {@link VideoProfile#STATE_TX_ENABLED}, |
| 469 | * {@link VideoProfile#STATE_RX_ENABLED}. |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 470 | * |
| 471 | * @param videoState The new video state. |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 472 | */ |
| 473 | public final void setVideoState(Connection c, int videoState) { |
| 474 | Log.d(this, "setVideoState Conference: %s Connection: %s VideoState: %s", |
| 475 | this, c, videoState); |
| 476 | for (Listener l : mListeners) { |
| 477 | l.onVideoStateChanged(this, videoState); |
| 478 | } |
| 479 | } |
| 480 | |
| 481 | /** |
| 482 | * Sets the video connection provider. |
| 483 | * |
| 484 | * @param videoProvider The video provider. |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 485 | */ |
| 486 | public final void setVideoProvider(Connection c, Connection.VideoProvider videoProvider) { |
| 487 | Log.d(this, "setVideoProvider Conference: %s Connection: %s VideoState: %s", |
| 488 | this, c, videoProvider); |
| 489 | for (Listener l : mListeners) { |
| 490 | l.onVideoProviderChanged(this, videoProvider); |
| 491 | } |
| 492 | } |
| 493 | |
| Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 494 | private final void fireOnConferenceableConnectionsChanged() { |
| 495 | for (Listener l : mListeners) { |
| 496 | l.onConferenceableConnectionsChanged(this, getConferenceableConnections()); |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | /** |
| 501 | * Returns the connections with which this connection can be conferenced. |
| 502 | */ |
| 503 | public final List<Connection> getConferenceableConnections() { |
| 504 | return mUnmodifiableConferenceableConnections; |
| 505 | } |
| 506 | |
| 507 | /** |
| Nancy Chen | ea38cca | 2014-09-05 16:38:49 -0700 | [diff] [blame] | 508 | * Tears down the conference object and any of its current connections. |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 509 | */ |
| Santos Cordon | a486804 | 2014-09-04 17:39:22 -0700 | [diff] [blame] | 510 | public final void destroy() { |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 511 | Log.d(this, "destroying conference : %s", this); |
| 512 | // Tear down the children. |
| Santos Cordon | 0159ac0 | 2014-08-21 14:28:11 -0700 | [diff] [blame] | 513 | for (Connection connection : mChildConnections) { |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 514 | Log.d(this, "removing connection %s", connection); |
| 515 | removeConnection(connection); |
| 516 | } |
| 517 | |
| 518 | // If not yet disconnected, set the conference call as disconnected first. |
| 519 | if (mState != Connection.STATE_DISCONNECTED) { |
| 520 | Log.d(this, "setting to disconnected"); |
| Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 521 | setDisconnected(new DisconnectCause(DisconnectCause.LOCAL)); |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | // ...and notify. |
| 525 | for (Listener l : mListeners) { |
| 526 | l.onDestroyed(this); |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | /** |
| 531 | * Add a listener to be notified of a state change. |
| 532 | * |
| 533 | * @param listener The new listener. |
| 534 | * @return This conference. |
| 535 | * @hide |
| 536 | */ |
| 537 | public final Conference addListener(Listener listener) { |
| 538 | mListeners.add(listener); |
| 539 | return this; |
| 540 | } |
| 541 | |
| 542 | /** |
| 543 | * Removes the specified listener. |
| 544 | * |
| 545 | * @param listener The listener to remove. |
| 546 | * @return This conference. |
| 547 | * @hide |
| 548 | */ |
| 549 | public final Conference removeListener(Listener listener) { |
| 550 | mListeners.remove(listener); |
| 551 | return this; |
| 552 | } |
| 553 | |
| Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 554 | /** |
| Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 555 | * Retrieves the primary connection associated with the conference. The primary connection is |
| 556 | * the connection from which the conference will retrieve its current state. |
| 557 | * |
| 558 | * @return The primary connection. |
| Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 559 | * @hide |
| Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 560 | */ |
| Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 561 | @SystemApi |
| Santos Cordon | 4055d64 | 2015-05-12 14:19:24 -0700 | [diff] [blame] | 562 | public Connection getPrimaryConnection() { |
| Tyler Gunn | 4a57b9b | 2014-10-30 14:27:48 -0700 | [diff] [blame] | 563 | if (mUnmodifiableChildConnections == null || mUnmodifiableChildConnections.isEmpty()) { |
| 564 | return null; |
| 565 | } |
| 566 | return mUnmodifiableChildConnections.get(0); |
| 567 | } |
| 568 | |
| 569 | /** |
| Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 570 | * @hide |
| 571 | * @deprecated Use {@link #setConnectionTime}. |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 572 | */ |
| Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 573 | @Deprecated |
| 574 | @SystemApi |
| 575 | public final void setConnectTimeMillis(long connectTimeMillis) { |
| 576 | setConnectionTime(connectTimeMillis); |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | /** |
| Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 580 | * Sets the connection start time of the {@code Conference}. |
| 581 | * |
| 582 | * @param connectionTimeMillis The connection time, in milliseconds. |
| 583 | */ |
| 584 | public final void setConnectionTime(long connectionTimeMillis) { |
| 585 | mConnectTimeMillis = connectionTimeMillis; |
| 586 | } |
| 587 | |
| 588 | /** |
| 589 | * @hide |
| 590 | * @deprecated Use {@link #getConnectionTime}. |
| 591 | */ |
| 592 | @Deprecated |
| 593 | @SystemApi |
| 594 | public final long getConnectTimeMillis() { |
| 595 | return getConnectionTime(); |
| 596 | } |
| 597 | |
| 598 | /** |
| 599 | * 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] | 600 | * {@link #CONNECT_TIME_NOT_SPECIFIED} indicates that Telecom should determine the start time |
| 601 | * of the conference. |
| 602 | * |
| Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 603 | * @return The time at which the {@code Conference} was connected. |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 604 | */ |
| Santos Cordon | 5d2e4f2 | 2015-05-12 12:32:51 -0700 | [diff] [blame] | 605 | public final long getConnectionTime() { |
| Tyler Gunn | cd5d33c | 2015-01-12 09:02:01 -0800 | [diff] [blame] | 606 | return mConnectTimeMillis; |
| 607 | } |
| 608 | |
| 609 | /** |
| Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 610 | * Inform this Conference that the state of its audio output has been changed externally. |
| 611 | * |
| 612 | * @param state The new audio state. |
| 613 | * @hide |
| 614 | */ |
| Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 615 | final void setCallAudioState(CallAudioState state) { |
| 616 | Log.d(this, "setCallAudioState %s", state); |
| 617 | mCallAudioState = state; |
| 618 | onAudioStateChanged(getAudioState()); |
| 619 | onCallAudioStateChanged(state); |
| Yorke Lee | a0d3ca9 | 2014-09-15 19:18:13 -0700 | [diff] [blame] | 620 | } |
| 621 | |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 622 | private void setState(int newState) { |
| 623 | if (newState != Connection.STATE_ACTIVE && |
| 624 | newState != Connection.STATE_HOLDING && |
| 625 | newState != Connection.STATE_DISCONNECTED) { |
| 626 | Log.w(this, "Unsupported state transition for Conference call.", |
| 627 | Connection.stateToString(newState)); |
| 628 | return; |
| 629 | } |
| 630 | |
| 631 | if (mState != newState) { |
| 632 | int oldState = mState; |
| 633 | mState = newState; |
| 634 | for (Listener l : mListeners) { |
| 635 | l.onStateChanged(this, oldState, newState); |
| 636 | } |
| 637 | } |
| 638 | } |
| Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 639 | |
| 640 | private final void clearConferenceableList() { |
| 641 | for (Connection c : mConferenceableConnections) { |
| 642 | c.removeConnectionListener(mConnectionDeathListener); |
| 643 | } |
| 644 | mConferenceableConnections.clear(); |
| 645 | } |
| Rekha Kumar | 0736681 | 2015-03-24 16:42:31 -0700 | [diff] [blame] | 646 | |
| 647 | @Override |
| 648 | public String toString() { |
| 649 | return String.format(Locale.US, |
| 650 | "[State: %s,Capabilites: %s, VideoState: %s, VideoProvider: %s, ThisObject %s]", |
| 651 | Connection.stateToString(mState), |
| 652 | Call.Details.capabilitiesToString(mConnectionCapabilities), |
| 653 | getVideoState(), |
| 654 | getVideoProvider(), |
| 655 | super.toString()); |
| 656 | } |
| Andrew Lee | 0f51da3 | 2015-04-16 13:11:55 -0700 | [diff] [blame] | 657 | |
| Andrew Lee | edc625f | 2015-04-14 13:38:12 -0700 | [diff] [blame] | 658 | /** |
| 659 | * Sets the label and icon status to display in the InCall UI. |
| 660 | * |
| 661 | * @param statusHints The status label and icon to set. |
| 662 | */ |
| 663 | public final void setStatusHints(StatusHints statusHints) { |
| 664 | mStatusHints = statusHints; |
| 665 | for (Listener l : mListeners) { |
| 666 | l.onStatusHintsChanged(this, statusHints); |
| 667 | } |
| 668 | } |
| 669 | |
| 670 | /** |
| 671 | * @return The status hints for this conference. |
| 672 | */ |
| 673 | public final StatusHints getStatusHints() { |
| 674 | return mStatusHints; |
| 675 | } |
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 676 | |
| 677 | /** |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 678 | * Replaces all the extras associated with this {@code Conference}. |
| 679 | * <p> |
| 680 | * New or existing keys are replaced in the {@code Conference} extras. Keys which are no longer |
| 681 | * in the new extras, but were present the last time {@code setExtras} was called are removed. |
| 682 | * <p> |
| 683 | * 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] | 684 | * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts. |
| 685 | * |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 686 | * @param extras The extras associated with this {@code Conference}. |
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 687 | */ |
| 688 | public final void setExtras(@Nullable Bundle extras) { |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 689 | // Add/replace any new or changed extras values. |
| 690 | putExtras(extras); |
| 691 | |
| 692 | // If we have used "setExtras" in the past, compare the key set from the last invocation to |
| 693 | // the current one and remove any keys that went away. |
| 694 | if (mPreviousExtraKeys != null) { |
| 695 | List<String> toRemove = new ArrayList<String>(); |
| 696 | for (String oldKey : mPreviousExtraKeys) { |
| Tyler Gunn | a8fb8ab | 2016-03-29 10:24:22 -0700 | [diff] [blame] | 697 | if (extras == null || !extras.containsKey(oldKey)) { |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 698 | toRemove.add(oldKey); |
| 699 | } |
| 700 | } |
| 701 | |
| 702 | if (!toRemove.isEmpty()) { |
| 703 | removeExtras(toRemove); |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | // Track the keys the last time set called setExtras. This way, the next time setExtras is |
| 708 | // called we can see if the caller has removed any extras values. |
| 709 | if (mPreviousExtraKeys == null) { |
| 710 | mPreviousExtraKeys = new ArraySet<String>(); |
| 711 | } |
| 712 | mPreviousExtraKeys.clear(); |
| Tyler Gunn | a8fb8ab | 2016-03-29 10:24:22 -0700 | [diff] [blame] | 713 | if (extras != null) { |
| 714 | mPreviousExtraKeys.addAll(extras.keySet()); |
| 715 | } |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 716 | } |
| 717 | |
| 718 | /** |
| 719 | * Adds some extras to this {@link Conference}. Existing keys are replaced and new ones are |
| 720 | * added. |
| 721 | * <p> |
| 722 | * No assumptions should be made as to how an In-Call UI or service will handle these extras. |
| 723 | * Keys should be fully qualified (e.g., com.example.MY_EXTRA) to avoid conflicts. |
| 724 | * |
| 725 | * @param extras The extras to add. |
| Tyler Gunn | 1bf206b | 2016-04-15 11:28:44 -0700 | [diff] [blame^] | 726 | * @hide |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 727 | */ |
| 728 | public final void putExtras(@NonNull Bundle extras) { |
| 729 | if (extras == null) { |
| 730 | return; |
| 731 | } |
| 732 | |
| 733 | if (mExtras == null) { |
| 734 | mExtras = new Bundle(); |
| 735 | } |
| 736 | mExtras.putAll(extras); |
| 737 | |
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 738 | for (Listener l : mListeners) { |
| 739 | l.onExtrasChanged(this, extras); |
| 740 | } |
| 741 | } |
| 742 | |
| 743 | /** |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 744 | * Adds a boolean extra to this {@link Conference}. |
| 745 | * |
| 746 | * @param key The extra key. |
| 747 | * @param value The value. |
| 748 | * @hide |
| 749 | */ |
| 750 | public final void putExtra(String key, boolean value) { |
| 751 | Bundle newExtras = new Bundle(); |
| 752 | newExtras.putBoolean(key, value); |
| 753 | putExtras(newExtras); |
| 754 | } |
| 755 | |
| 756 | /** |
| 757 | * Adds an integer extra to this {@link Conference}. |
| 758 | * |
| 759 | * @param key The extra key. |
| 760 | * @param value The value. |
| 761 | * @hide |
| 762 | */ |
| 763 | public final void putExtra(String key, int value) { |
| 764 | Bundle newExtras = new Bundle(); |
| 765 | newExtras.putInt(key, value); |
| 766 | putExtras(newExtras); |
| 767 | } |
| 768 | |
| 769 | /** |
| 770 | * Adds a string extra to this {@link Conference}. |
| 771 | * |
| 772 | * @param key The extra key. |
| 773 | * @param value The value. |
| 774 | * @hide |
| 775 | */ |
| 776 | public final void putExtra(String key, String value) { |
| 777 | Bundle newExtras = new Bundle(); |
| 778 | newExtras.putString(key, value); |
| 779 | putExtras(newExtras); |
| 780 | } |
| 781 | |
| 782 | /** |
| 783 | * Removes an extra from this {@link Conference}. |
| 784 | * |
| 785 | * @param keys The key of the extra key to remove. |
| Tyler Gunn | 1bf206b | 2016-04-15 11:28:44 -0700 | [diff] [blame^] | 786 | * @hide |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 787 | */ |
| 788 | public final void removeExtras(List<String> keys) { |
| 789 | if (keys == null || keys.isEmpty()) { |
| 790 | return; |
| 791 | } |
| 792 | |
| 793 | if (mExtras != null) { |
| 794 | for (String key : keys) { |
| 795 | mExtras.remove(key); |
| 796 | } |
| 797 | if (mExtras.size() == 0) { |
| 798 | mExtras = null; |
| 799 | } |
| 800 | } |
| 801 | |
| 802 | for (Listener l : mListeners) { |
| 803 | l.onExtrasRemoved(this, keys); |
| 804 | } |
| 805 | } |
| 806 | |
| 807 | /** |
| 808 | * Returns the extras associated with this conference. |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 809 | * |
| 810 | * @return The extras associated with this connection. |
| Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame] | 811 | */ |
| 812 | public final Bundle getExtras() { |
| 813 | return mExtras; |
| 814 | } |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 815 | |
| 816 | /** |
| 817 | * Notifies this {@link Conference} of a change to the extras made outside the |
| 818 | * {@link ConnectionService}. |
| 819 | * <p> |
| 820 | * These extras changes can originate from Telecom itself, or from an {@link InCallService} via |
| 821 | * {@link android.telecom.Call#putExtras(Bundle)}, and |
| 822 | * {@link Call#removeExtras(List)}. |
| 823 | * |
| 824 | * @param extras The new extras bundle. |
| Tyler Gunn | 1bf206b | 2016-04-15 11:28:44 -0700 | [diff] [blame^] | 825 | * @hide |
| Tyler Gunn | dee56a8 | 2016-03-23 16:06:34 -0700 | [diff] [blame] | 826 | */ |
| 827 | public void onExtrasChanged(Bundle extras) {} |
| 828 | |
| 829 | /** |
| 830 | * Handles a change to extras received from Telecom. |
| 831 | * |
| 832 | * @param extras The new extras. |
| 833 | * @hide |
| 834 | */ |
| 835 | final void handleExtrasChanged(Bundle extras) { |
| 836 | mExtras = extras; |
| 837 | onExtrasChanged(mExtras); |
| 838 | } |
| Santos Cordon | 823fd3c | 2014-08-07 18:35:18 -0700 | [diff] [blame] | 839 | } |