summaryrefslogtreecommitdiffstats
path: root/telecomm/java/android/telecom/Conference.java
diff options
context:
space:
mode:
authorIhab Awad <ihab@google.com>2014-10-01 14:31:01 -0700
committerIhab Awad <ihab@google.com>2014-10-01 14:31:01 -0700
commit12a4df2b66fccbc1e4293e8f56217e1064b2e8ea (patch)
tree22c74f18cddcc93f92a6961c5527226a622bfbed /telecomm/java/android/telecom/Conference.java
parent3867e4d0c08ad74ee16dfde70e81c77f09e0e0ff (diff)
parentead63f02006039655e3f2733ba27e19d158da432 (diff)
downloadframeworks_base-12a4df2b66fccbc1e4293e8f56217e1064b2e8ea.zip
frameworks_base-12a4df2b66fccbc1e4293e8f56217e1064b2e8ea.tar.gz
frameworks_base-12a4df2b66fccbc1e4293e8f56217e1064b2e8ea.tar.bz2
resolved conflicts for merge of ead63f02 to lmp-mr1-dev
Change-Id: I20d5f9d8aae82f0cb6f0ebf2ac1cb0af05eb8c9b
Diffstat (limited to 'telecomm/java/android/telecom/Conference.java')
-rw-r--r--telecomm/java/android/telecom/Conference.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/telecomm/java/android/telecom/Conference.java b/telecomm/java/android/telecom/Conference.java
index 9b350c1..15cb786 100644
--- a/telecomm/java/android/telecom/Conference.java
+++ b/telecomm/java/android/telecom/Conference.java
@@ -16,6 +16,7 @@
package android.telecom;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
@@ -33,6 +34,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) {}
}
@@ -41,6 +44,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;
@@ -49,6 +55,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}
*
@@ -116,6 +131,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() {}
@@ -234,6 +256,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() {
@@ -309,4 +362,11 @@ public abstract class Conference {
}
}
}
+
+ private final void clearConferenceableList() {
+ for (Connection c : mConferenceableConnections) {
+ c.removeConnectionListener(mConnectionDeathListener);
+ }
+ mConferenceableConnections.clear();
+ }
}