diff options
author | Tyler Gunn <tgunn@google.com> | 2014-11-17 15:49:51 -0800 |
---|---|---|
committer | Tyler Gunn <tgunn@google.com> | 2014-11-17 15:49:51 -0800 |
commit | 6d76ca0438c2cb7a7d5d91992db819c063c0a57b (patch) | |
tree | 74a11f2f8b5c7d736a3ff816c31d9a998f21cada /telecomm/java/android/telecom/Connection.java | |
parent | 5aadd5b6fa8ee9f09cd4870c8f104c1e611aebcd (diff) | |
download | frameworks_base-6d76ca0438c2cb7a7d5d91992db819c063c0a57b.zip frameworks_base-6d76ca0438c2cb7a7d5d91992db819c063c0a57b.tar.gz frameworks_base-6d76ca0438c2cb7a7d5d91992db819c063c0a57b.tar.bz2 |
Change Connections to allow setting conferenceable with conferences.
- Added IConferenceable interface used so that connections and conferences
can both be considered candidates as "conferenceable" with a connection.
- Fixed ConnectionService#conference to support cases where either call 1
or call 2 is a conference and the other is a connection. Previously did
not support cases where call 2 is a conference.
Bug: 18200934
Change-Id: I32a8dd30a154d6280f2ae89fd147817235998465
Diffstat (limited to 'telecomm/java/android/telecom/Connection.java')
-rw-r--r-- | telecomm/java/android/telecom/Connection.java | 72 |
1 files changed, 56 insertions, 16 deletions
diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java index 63b44a6..fb63c85 100644 --- a/telecomm/java/android/telecom/Connection.java +++ b/telecomm/java/android/telecom/Connection.java @@ -47,7 +47,7 @@ import java.util.concurrent.ConcurrentHashMap; * @hide */ @SystemApi -public abstract class Connection { +public abstract class Connection implements IConferenceable { public static final int STATE_INITIALIZING = 0; @@ -82,8 +82,8 @@ public abstract class Connection { Connection c, VideoProvider videoProvider) {} public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {} public void onStatusHintsChanged(Connection c, StatusHints statusHints) {} - public void onConferenceableConnectionsChanged( - Connection c, List<Connection> conferenceableConnections) {} + public void onConferenceablesChanged( + Connection c, List<IConferenceable> conferenceables) {} public void onConferenceChanged(Connection c, Conference conference) {} /** @hide */ public void onConferenceParticipantsChanged(Connection c, @@ -449,7 +449,16 @@ public abstract class Connection { private final Listener mConnectionDeathListener = new Listener() { @Override public void onDestroyed(Connection c) { - if (mConferenceableConnections.remove(c)) { + if (mConferenceables.remove(c)) { + fireOnConferenceableConnectionsChanged(); + } + } + }; + + private final Conference.Listener mConferenceDeathListener = new Conference.Listener() { + @Override + public void onDestroyed(Conference c) { + if (mConferenceables.remove(c)) { fireOnConferenceableConnectionsChanged(); } } @@ -462,9 +471,9 @@ public abstract class Connection { */ private final Set<Listener> mListeners = Collections.newSetFromMap( new ConcurrentHashMap<Listener, Boolean>(8, 0.9f, 1)); - private final List<Connection> mConferenceableConnections = new ArrayList<>(); - private final List<Connection> mUnmodifiableConferenceableConnections = - Collections.unmodifiableList(mConferenceableConnections); + private final List<IConferenceable> mConferenceables = new ArrayList<>(); + private final List<IConferenceable> mUnmodifiableConferenceables = + Collections.unmodifiableList(mConferenceables); private int mState = STATE_NEW; private AudioState mAudioState; @@ -864,19 +873,44 @@ public abstract class Connection { 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)) { + if (!mConferenceables.contains(c)) { c.addConnectionListener(mConnectionDeathListener); - mConferenceableConnections.add(c); + mConferenceables.add(c); } } fireOnConferenceableConnectionsChanged(); } /** - * Returns the connections with which this connection can be conferenced. + * Similar to {@link #setConferenceableConnections(java.util.List)}, sets a list of connections + * or conferences with which this connection can be conferenced. + * + * @param conferenceables The conferenceables. */ - public final List<Connection> getConferenceableConnections() { - return mUnmodifiableConferenceableConnections; + public final void setConferenceables(List<IConferenceable> conferenceables) { + clearConferenceableList(); + for (IConferenceable c : conferenceables) { + // If statement checks for duplicates in input. It makes it N^2 but we're dealing with a + // small amount of items here. + if (!mConferenceables.contains(c)) { + if (c instanceof Connection) { + Connection connection = (Connection) c; + connection.addConnectionListener(mConnectionDeathListener); + } else if (c instanceof Conference) { + Conference conference = (Conference) c; + conference.addListener(mConferenceDeathListener); + } + mConferenceables.add(c); + } + } + fireOnConferenceableConnectionsChanged(); + } + + /** + * Returns the connections or conferences with which this connection can be conferenced. + */ + public final List<IConferenceable> getConferenceables() { + return mUnmodifiableConferenceables; } /* @@ -1109,7 +1143,7 @@ public abstract class Connection { private final void fireOnConferenceableConnectionsChanged() { for (Listener l : mListeners) { - l.onConferenceableConnectionsChanged(this, getConferenceableConnections()); + l.onConferenceablesChanged(this, getConferenceables()); } } @@ -1120,10 +1154,16 @@ public abstract class Connection { } private final void clearConferenceableList() { - for (Connection c : mConferenceableConnections) { - c.removeConnectionListener(mConnectionDeathListener); + for (IConferenceable c : mConferenceables) { + if (c instanceof Connection) { + Connection connection = (Connection) c; + connection.removeConnectionListener(mConnectionDeathListener); + } else if (c instanceof Conference) { + Conference conference = (Conference) c; + conference.removeListener(mConferenceDeathListener); + } } - mConferenceableConnections.clear(); + mConferenceables.clear(); } /** |