Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 17 | package android.telecom; |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 18 | |
Tyler Gunn | ef9f6f9 | 2014-09-12 22:16:17 -0700 | [diff] [blame] | 19 | import com.android.internal.telecom.IConnectionService; |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 20 | |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame^] | 21 | import android.annotation.Nullable; |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 22 | import android.annotation.SystemApi; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame^] | 23 | import android.os.Bundle; |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 24 | import android.os.Handler; |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 25 | import android.os.RemoteException; |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 26 | |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 27 | import java.util.ArrayList; |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 28 | import java.util.Collections; |
| 29 | import java.util.List; |
| 30 | import java.util.Set; |
| 31 | import java.util.concurrent.CopyOnWriteArrayList; |
| 32 | import java.util.concurrent.CopyOnWriteArraySet; |
| 33 | |
| 34 | /** |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 35 | * A conference provided to a {@link ConnectionService} by another {@code ConnectionService} |
| 36 | * running in a different process. |
| 37 | * |
| 38 | * @see ConnectionService#onRemoteConferenceAdded |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 39 | */ |
| 40 | public final class RemoteConference { |
| 41 | |
Nancy Chen | 1d834f5 | 2014-09-05 11:03:21 -0700 | [diff] [blame] | 42 | public abstract static class Callback { |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 43 | public void onStateChanged(RemoteConference conference, int oldState, int newState) {} |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 44 | public void onDisconnected(RemoteConference conference, DisconnectCause disconnectCause) {} |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 45 | public void onConnectionAdded(RemoteConference conference, RemoteConnection connection) {} |
| 46 | public void onConnectionRemoved(RemoteConference conference, RemoteConnection connection) {} |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 47 | public void onConnectionCapabilitiesChanged( |
| 48 | RemoteConference conference, |
| 49 | int connectionCapabilities) {} |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 50 | public void onConferenceableConnectionsChanged( |
| 51 | RemoteConference conference, |
| 52 | List<RemoteConnection> conferenceableConnections) {} |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 53 | public void onDestroyed(RemoteConference conference) {} |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame^] | 54 | public void onExtrasChanged(RemoteConference conference, @Nullable Bundle extras) {} |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | private final String mId; |
| 58 | private final IConnectionService mConnectionService; |
| 59 | |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 60 | private final Set<CallbackRecord<Callback>> mCallbackRecords = new CopyOnWriteArraySet<>(); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 61 | private final List<RemoteConnection> mChildConnections = new CopyOnWriteArrayList<>(); |
| 62 | private final List<RemoteConnection> mUnmodifiableChildConnections = |
| 63 | Collections.unmodifiableList(mChildConnections); |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 64 | private final List<RemoteConnection> mConferenceableConnections = new ArrayList<>(); |
| 65 | private final List<RemoteConnection> mUnmodifiableConferenceableConnections = |
| 66 | Collections.unmodifiableList(mConferenceableConnections); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 67 | |
| 68 | private int mState = Connection.STATE_NEW; |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 69 | private DisconnectCause mDisconnectCause; |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 70 | private int mConnectionCapabilities; |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame^] | 71 | private Bundle mExtras; |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 72 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 73 | /** @hide */ |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 74 | RemoteConference(String id, IConnectionService connectionService) { |
| 75 | mId = id; |
| 76 | mConnectionService = connectionService; |
| 77 | } |
| 78 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 79 | /** @hide */ |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 80 | String getId() { |
| 81 | return mId; |
| 82 | } |
| 83 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 84 | /** @hide */ |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 85 | void setDestroyed() { |
| 86 | for (RemoteConnection connection : mChildConnections) { |
| 87 | connection.setConference(null); |
| 88 | } |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 89 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 90 | final RemoteConference conference = this; |
| 91 | final Callback callback = record.getCallback(); |
| 92 | record.getHandler().post(new Runnable() { |
| 93 | @Override |
| 94 | public void run() { |
| 95 | callback.onDestroyed(conference); |
| 96 | } |
| 97 | }); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 98 | } |
| 99 | } |
| 100 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 101 | /** @hide */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 102 | void setState(final int newState) { |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 103 | if (newState != Connection.STATE_ACTIVE && |
| 104 | newState != Connection.STATE_HOLDING && |
| 105 | newState != Connection.STATE_DISCONNECTED) { |
| 106 | Log.w(this, "Unsupported state transition for Conference call.", |
| 107 | Connection.stateToString(newState)); |
| 108 | return; |
| 109 | } |
| 110 | |
| 111 | if (mState != newState) { |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 112 | final int oldState = mState; |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 113 | mState = newState; |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 114 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 115 | final RemoteConference conference = this; |
| 116 | final Callback callback = record.getCallback(); |
| 117 | record.getHandler().post(new Runnable() { |
| 118 | @Override |
| 119 | public void run() { |
| 120 | callback.onStateChanged(conference, oldState, newState); |
| 121 | } |
| 122 | }); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 123 | } |
| 124 | } |
| 125 | } |
| 126 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 127 | /** @hide */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 128 | void addConnection(final RemoteConnection connection) { |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 129 | if (!mChildConnections.contains(connection)) { |
| 130 | mChildConnections.add(connection); |
| 131 | connection.setConference(this); |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 132 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 133 | final RemoteConference conference = this; |
| 134 | final Callback callback = record.getCallback(); |
| 135 | record.getHandler().post(new Runnable() { |
| 136 | @Override |
| 137 | public void run() { |
| 138 | callback.onConnectionAdded(conference, connection); |
| 139 | } |
| 140 | }); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 145 | /** @hide */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 146 | void removeConnection(final RemoteConnection connection) { |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 147 | if (mChildConnections.contains(connection)) { |
| 148 | mChildConnections.remove(connection); |
| 149 | connection.setConference(null); |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 150 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 151 | final RemoteConference conference = this; |
| 152 | final Callback callback = record.getCallback(); |
| 153 | record.getHandler().post(new Runnable() { |
| 154 | @Override |
| 155 | public void run() { |
| 156 | callback.onConnectionRemoved(conference, connection); |
| 157 | } |
| 158 | }); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 163 | /** @hide */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 164 | void setConnectionCapabilities(final int connectionCapabilities) { |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 165 | if (mConnectionCapabilities != connectionCapabilities) { |
| 166 | mConnectionCapabilities = connectionCapabilities; |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 167 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 168 | final RemoteConference conference = this; |
| 169 | final Callback callback = record.getCallback(); |
| 170 | record.getHandler().post(new Runnable() { |
| 171 | @Override |
| 172 | public void run() { |
| 173 | callback.onConnectionCapabilitiesChanged( |
| 174 | conference, mConnectionCapabilities); |
| 175 | } |
| 176 | }); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 177 | } |
| 178 | } |
| 179 | } |
| 180 | |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 181 | /** @hide */ |
| 182 | void setConferenceableConnections(List<RemoteConnection> conferenceableConnections) { |
| 183 | mConferenceableConnections.clear(); |
| 184 | mConferenceableConnections.addAll(conferenceableConnections); |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 185 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 186 | final RemoteConference conference = this; |
| 187 | final Callback callback = record.getCallback(); |
| 188 | record.getHandler().post(new Runnable() { |
| 189 | @Override |
| 190 | public void run() { |
| 191 | callback.onConferenceableConnectionsChanged( |
| 192 | conference, mUnmodifiableConferenceableConnections); |
| 193 | } |
| 194 | }); |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 195 | } |
| 196 | } |
| 197 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 198 | /** @hide */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 199 | void setDisconnected(final DisconnectCause disconnectCause) { |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 200 | if (mState != Connection.STATE_DISCONNECTED) { |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 201 | mDisconnectCause = disconnectCause; |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 202 | setState(Connection.STATE_DISCONNECTED); |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 203 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 204 | final RemoteConference conference = this; |
| 205 | final Callback callback = record.getCallback(); |
| 206 | record.getHandler().post(new Runnable() { |
| 207 | @Override |
| 208 | public void run() { |
| 209 | callback.onDisconnected(conference, disconnectCause); |
| 210 | } |
| 211 | }); |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 212 | } |
| 213 | } |
| 214 | } |
| 215 | |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame^] | 216 | /** @hide */ |
| 217 | void setExtras(final Bundle extras) { |
| 218 | mExtras = extras; |
| 219 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 220 | final RemoteConference conference = this; |
| 221 | final Callback callback = record.getCallback(); |
| 222 | record.getHandler().post(new Runnable() { |
| 223 | @Override |
| 224 | public void run() { |
| 225 | callback.onExtrasChanged(conference, extras); |
| 226 | } |
| 227 | }); |
| 228 | } |
| 229 | } |
| 230 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 231 | /** |
| 232 | * Returns the list of {@link RemoteConnection}s contained in this conference. |
| 233 | * |
| 234 | * @return A list of child connections. |
| 235 | */ |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 236 | public final List<RemoteConnection> getConnections() { |
| 237 | return mUnmodifiableChildConnections; |
| 238 | } |
| 239 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 240 | /** |
| 241 | * Gets the state of the conference call. See {@link Connection} for valid values. |
| 242 | * |
| 243 | * @return A constant representing the state the conference call is currently in. |
| 244 | */ |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 245 | public final int getState() { |
| 246 | return mState; |
| 247 | } |
| 248 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 249 | /** |
| 250 | * Returns the capabilities of the conference. See {@code CAPABILITY_*} constants in class |
| 251 | * {@link Connection} for valid values. |
| 252 | * |
| 253 | * @return A bitmask of the capabilities of the conference call. |
| 254 | */ |
Ihab Awad | 5c9c86e | 2014-11-12 13:41:16 -0800 | [diff] [blame] | 255 | public final int getConnectionCapabilities() { |
| 256 | return mConnectionCapabilities; |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 257 | } |
| 258 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 259 | /** |
Santos Cordon | 6b7f955 | 2015-05-27 17:21:45 -0700 | [diff] [blame^] | 260 | * Obtain the extras associated with this {@code RemoteConnection}. |
| 261 | * |
| 262 | * @return The extras for this connection. |
| 263 | */ |
| 264 | public final Bundle getExtras() { |
| 265 | return mExtras; |
| 266 | } |
| 267 | |
| 268 | /** |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 269 | * Disconnects the conference call as well as the child {@link RemoteConnection}s. |
| 270 | */ |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 271 | public void disconnect() { |
| 272 | try { |
| 273 | mConnectionService.disconnect(mId); |
| 274 | } catch (RemoteException e) { |
| 275 | } |
| 276 | } |
| 277 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 278 | /** |
| 279 | * Removes the specified {@link RemoteConnection} from the conference. This causes the |
| 280 | * {@link RemoteConnection} to become a standalone connection. This is a no-op if the |
| 281 | * {@link RemoteConnection} does not belong to this conference. |
| 282 | * |
| 283 | * @param connection The remote-connection to remove. |
| 284 | */ |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 285 | public void separate(RemoteConnection connection) { |
| 286 | if (mChildConnections.contains(connection)) { |
| 287 | try { |
| 288 | mConnectionService.splitFromConference(connection.getId()); |
| 289 | } catch (RemoteException e) { |
| 290 | } |
| 291 | } |
| 292 | } |
| 293 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 294 | /** |
| 295 | * Merges all {@link RemoteConnection}s of this conference into a single call. This should be |
| 296 | * invoked only if the conference contains the capability |
| 297 | * {@link Connection#CAPABILITY_MERGE_CONFERENCE}, otherwise it is a no-op. The presence of said |
| 298 | * capability indicates that the connections of this conference, despite being part of the |
| 299 | * same conference object, are yet to have their audio streams merged; this is a common pattern |
| 300 | * for CDMA conference calls, but the capability is not used for GSM and SIP conference calls. |
| 301 | * Invoking this method will cause the unmerged child connections to merge their audio |
| 302 | * streams. |
| 303 | */ |
mike dooley | 95ea576 | 2014-09-25 14:49:21 -0700 | [diff] [blame] | 304 | public void merge() { |
| 305 | try { |
| 306 | mConnectionService.mergeConference(mId); |
| 307 | } catch (RemoteException e) { |
| 308 | } |
| 309 | } |
| 310 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 311 | /** |
| 312 | * Swaps the active audio stream between the conference's child {@link RemoteConnection}s. |
| 313 | * This should be invoked only if the conference contains the capability |
| 314 | * {@link Connection#CAPABILITY_SWAP_CONFERENCE}, otherwise it is a no-op. This is only used by |
| 315 | * {@link ConnectionService}s that create conferences for connections that do not yet have |
| 316 | * their audio streams merged; this is a common pattern for CDMA conference calls, but the |
| 317 | * capability is not used for GSM and SIP conference calls. Invoking this method will change the |
| 318 | * active audio stream to a different child connection. |
| 319 | */ |
mike dooley | 95ea576 | 2014-09-25 14:49:21 -0700 | [diff] [blame] | 320 | public void swap() { |
| 321 | try { |
| 322 | mConnectionService.swapConference(mId); |
| 323 | } catch (RemoteException e) { |
| 324 | } |
| 325 | } |
| 326 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 327 | /** |
| 328 | * Puts the conference on hold. |
| 329 | */ |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 330 | public void hold() { |
| 331 | try { |
| 332 | mConnectionService.hold(mId); |
| 333 | } catch (RemoteException e) { |
| 334 | } |
| 335 | } |
| 336 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 337 | /** |
| 338 | * Unholds the conference call. |
| 339 | */ |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 340 | public void unhold() { |
| 341 | try { |
| 342 | mConnectionService.unhold(mId); |
| 343 | } catch (RemoteException e) { |
| 344 | } |
| 345 | } |
| 346 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 347 | /** |
| 348 | * Returns the {@link DisconnectCause} for the conference if it is in the state |
| 349 | * {@link Connection#STATE_DISCONNECTED}. If the conference is not disconnected, this will |
| 350 | * return null. |
| 351 | * |
| 352 | * @return The disconnect cause. |
| 353 | */ |
Andrew Lee | 7f3d41f | 2014-09-11 17:33:16 -0700 | [diff] [blame] | 354 | public DisconnectCause getDisconnectCause() { |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 355 | return mDisconnectCause; |
| 356 | } |
| 357 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 358 | /** |
| 359 | * Requests that the conference start playing the specified DTMF tone. |
| 360 | * |
| 361 | * @param digit The digit for which to play a DTMF tone. |
| 362 | */ |
Yorke Lee | 58bacc5 | 2014-09-16 10:43:06 -0700 | [diff] [blame] | 363 | public void playDtmfTone(char digit) { |
| 364 | try { |
| 365 | mConnectionService.playDtmfTone(mId, digit); |
| 366 | } catch (RemoteException e) { |
| 367 | } |
| 368 | } |
| 369 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 370 | /** |
| 371 | * Stops the most recent request to play a DTMF tone. |
| 372 | * |
| 373 | * @see #playDtmfTone |
| 374 | */ |
Yorke Lee | 58bacc5 | 2014-09-16 10:43:06 -0700 | [diff] [blame] | 375 | public void stopDtmfTone() { |
| 376 | try { |
| 377 | mConnectionService.stopDtmfTone(mId); |
| 378 | } catch (RemoteException e) { |
| 379 | } |
| 380 | } |
| 381 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 382 | /** |
| 383 | * Request to change the conference's audio routing to the specified state. The specified state |
| 384 | * can include audio routing (Bluetooth, Speaker, etc) and muting state. |
| 385 | * |
| 386 | * @see android.telecom.AudioState |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 387 | * @deprecated Use {@link #setCallAudioState(CallAudioState)} instead. |
| 388 | * @hide |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 389 | */ |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 390 | @SystemApi |
| 391 | @Deprecated |
Yorke Lee | 58bacc5 | 2014-09-16 10:43:06 -0700 | [diff] [blame] | 392 | public void setAudioState(AudioState state) { |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 393 | setCallAudioState(new CallAudioState(state)); |
| 394 | } |
| 395 | |
| 396 | /** |
| 397 | * Request to change the conference's audio routing to the specified state. The specified state |
| 398 | * can include audio routing (Bluetooth, Speaker, etc) and muting state. |
| 399 | */ |
| 400 | public void setCallAudioState(CallAudioState state) { |
Yorke Lee | 58bacc5 | 2014-09-16 10:43:06 -0700 | [diff] [blame] | 401 | try { |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 402 | mConnectionService.onCallAudioStateChanged(mId, state); |
Yorke Lee | 58bacc5 | 2014-09-16 10:43:06 -0700 | [diff] [blame] | 403 | } catch (RemoteException e) { |
| 404 | } |
| 405 | } |
| 406 | |
Yorke Lee | 4af5935 | 2015-05-13 14:14:54 -0700 | [diff] [blame] | 407 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 408 | /** |
| 409 | * Returns a list of independent connections that can me merged with this conference. |
| 410 | * |
| 411 | * @return A list of conferenceable connections. |
| 412 | */ |
Ihab Awad | 50e3506 | 2014-09-30 09:17:03 -0700 | [diff] [blame] | 413 | public List<RemoteConnection> getConferenceableConnections() { |
| 414 | return mUnmodifiableConferenceableConnections; |
| 415 | } |
| 416 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 417 | /** |
| 418 | * Register a callback through which to receive state updates for this conference. |
| 419 | * |
| 420 | * @param callback The callback to notify of state changes. |
| 421 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 422 | public final void registerCallback(Callback callback) { |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 423 | registerCallback(callback, new Handler()); |
| 424 | } |
| 425 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 426 | /** |
| 427 | * Registers a callback through which to receive state updates for this conference. |
| 428 | * Callbacks will be notified using the specified handler, if provided. |
| 429 | * |
| 430 | * @param callback The callback to notify of state changes. |
| 431 | * @param handler The handler on which to execute the callbacks. |
| 432 | */ |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 433 | public final void registerCallback(Callback callback, Handler handler) { |
| 434 | unregisterCallback(callback); |
| 435 | if (callback != null && handler != null) { |
| 436 | mCallbackRecords.add(new CallbackRecord(callback, handler)); |
| 437 | } |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 438 | } |
| 439 | |
Santos Cordon | b804f8d | 2015-05-12 12:09:47 -0700 | [diff] [blame] | 440 | /** |
| 441 | * Unregisters a previously registered callback. |
| 442 | * |
| 443 | * @see #registerCallback |
| 444 | * |
| 445 | * @param callback The callback to unregister. |
| 446 | */ |
Andrew Lee | 100e293 | 2014-09-08 15:34:24 -0700 | [diff] [blame] | 447 | public final void unregisterCallback(Callback callback) { |
Andrew Lee | 011728f | 2015-04-23 15:47:06 -0700 | [diff] [blame] | 448 | if (callback != null) { |
| 449 | for (CallbackRecord<Callback> record : mCallbackRecords) { |
| 450 | if (record.getCallback() == callback) { |
| 451 | mCallbackRecords.remove(record); |
| 452 | break; |
| 453 | } |
| 454 | } |
| 455 | } |
Ihab Awad | b8e85c7 | 2014-08-23 20:34:57 -0700 | [diff] [blame] | 456 | } |
| 457 | } |