diff options
author | Ihab Awad <ihab@google.com> | 2014-09-30 09:17:03 -0700 |
---|---|---|
committer | Ihab Awad <ihab@google.com> | 2014-09-30 16:46:39 -0700 |
commit | 50e3506533478fa273cbc92c2919470d1889f1ed (patch) | |
tree | 2427095ce136a68b7ee48827bd9bac8bed934dcd /telecomm/java/android/telecom/Conference.java | |
parent | 9cf01b63cb0023aec0e05b1ce050ff572532b876 (diff) | |
download | frameworks_base-50e3506533478fa273cbc92c2919470d1889f1ed.zip frameworks_base-50e3506533478fa273cbc92c2919470d1889f1ed.tar.gz frameworks_base-50e3506533478fa273cbc92c2919470d1889f1ed.tar.bz2 |
Refine implementation of GSM conferences (1/3)
Bug: 17684223
Change-Id: I05d05b594803ea2c1da4247111b70ad5f870ac46
Diffstat (limited to 'telecomm/java/android/telecom/Conference.java')
-rw-r--r-- | telecomm/java/android/telecom/Conference.java | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/telecomm/java/android/telecom/Conference.java b/telecomm/java/android/telecom/Conference.java index e47d9d1..b7b98bf 100644 --- a/telecomm/java/android/telecom/Conference.java +++ b/telecomm/java/android/telecom/Conference.java @@ -18,6 +18,7 @@ package android.telecom; import android.annotation.SystemApi; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; @@ -37,6 +38,8 @@ public abstract class Conference { public void onDisconnected(Conference conference, DisconnectCause disconnectCause) {} public void onConnectionAdded(Conference conference, Connection connection) {} public void onConnectionRemoved(Conference conference, Connection connection) {} + public void onConferenceableConnectionsChanged( + Conference conference, List<Connection> conferenceableConnections) {} public void onDestroyed(Conference conference) {} public void onCapabilitiesChanged(Conference conference, int capabilities) {} } @@ -45,6 +48,9 @@ public abstract class Conference { private final List<Connection> mChildConnections = new CopyOnWriteArrayList<>(); private final List<Connection> mUnmodifiableChildConnections = Collections.unmodifiableList(mChildConnections); + private final List<Connection> mConferenceableConnections = new ArrayList<>(); + private final List<Connection> mUnmodifiableConferenceableConnections = + Collections.unmodifiableList(mConferenceableConnections); private PhoneAccountHandle mPhoneAccount; private AudioState mAudioState; @@ -53,6 +59,15 @@ public abstract class Conference { private int mCapabilities; private String mDisconnectMessage; + private final Connection.Listener mConnectionDeathListener = new Connection.Listener() { + @Override + public void onDestroyed(Connection c) { + if (mConferenceableConnections.remove(c)) { + fireOnConferenceableConnectionsChanged(); + } + } + }; + /** * Constructs a new Conference with a mandatory {@link PhoneAccountHandle} * @@ -120,6 +135,13 @@ public abstract class Conference { public void onSeparate(Connection connection) {} /** + * Invoked when the specified {@link Connection} should merged with the conference call. + * + * @param connection The {@code Connection} to merge. + */ + public void onMerge(Connection connection) {} + + /** * Invoked when the conference should be put on hold. */ public void onHold() {} @@ -238,6 +260,37 @@ public abstract class Conference { } /** + * Sets the connections with which this connection can be conferenced. + * + * @param conferenceableConnections The set of connections this connection can conference with. + */ + public final void setConferenceableConnections(List<Connection> conferenceableConnections) { + clearConferenceableList(); + for (Connection c : conferenceableConnections) { + // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a + // small amount of items here. + if (!mConferenceableConnections.contains(c)) { + c.addConnectionListener(mConnectionDeathListener); + mConferenceableConnections.add(c); + } + } + fireOnConferenceableConnectionsChanged(); + } + + private final void fireOnConferenceableConnectionsChanged() { + for (Listener l : mListeners) { + l.onConferenceableConnectionsChanged(this, getConferenceableConnections()); + } + } + + /** + * Returns the connections with which this connection can be conferenced. + */ + public final List<Connection> getConferenceableConnections() { + return mUnmodifiableConferenceableConnections; + } + + /** * Tears down the conference object and any of its current connections. */ public final void destroy() { @@ -313,4 +366,11 @@ public abstract class Conference { } } } + + private final void clearConferenceableList() { + for (Connection c : mConferenceableConnections) { + c.removeConnectionListener(mConnectionDeathListener); + } + mConferenceableConnections.clear(); + } } |