Merge "Refine implementation of GSM conferences (1/3)" into lmp-dev
This commit is contained in:
@@ -18,6 +18,7 @@ package android.telecom;
|
|||||||
|
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -37,6 +38,8 @@ public abstract class Conference {
|
|||||||
public void onDisconnected(Conference conference, DisconnectCause disconnectCause) {}
|
public void onDisconnected(Conference conference, DisconnectCause disconnectCause) {}
|
||||||
public void onConnectionAdded(Conference conference, Connection connection) {}
|
public void onConnectionAdded(Conference conference, Connection connection) {}
|
||||||
public void onConnectionRemoved(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 onDestroyed(Conference conference) {}
|
||||||
public void onCapabilitiesChanged(Conference conference, int capabilities) {}
|
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> mChildConnections = new CopyOnWriteArrayList<>();
|
||||||
private final List<Connection> mUnmodifiableChildConnections =
|
private final List<Connection> mUnmodifiableChildConnections =
|
||||||
Collections.unmodifiableList(mChildConnections);
|
Collections.unmodifiableList(mChildConnections);
|
||||||
|
private final List<Connection> mConferenceableConnections = new ArrayList<>();
|
||||||
|
private final List<Connection> mUnmodifiableConferenceableConnections =
|
||||||
|
Collections.unmodifiableList(mConferenceableConnections);
|
||||||
|
|
||||||
private PhoneAccountHandle mPhoneAccount;
|
private PhoneAccountHandle mPhoneAccount;
|
||||||
private AudioState mAudioState;
|
private AudioState mAudioState;
|
||||||
@@ -53,6 +59,15 @@ public abstract class Conference {
|
|||||||
private int mCapabilities;
|
private int mCapabilities;
|
||||||
private String mDisconnectMessage;
|
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}
|
* Constructs a new Conference with a mandatory {@link PhoneAccountHandle}
|
||||||
*
|
*
|
||||||
@@ -119,6 +134,13 @@ public abstract class Conference {
|
|||||||
*/
|
*/
|
||||||
public void onSeparate(Connection connection) {}
|
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.
|
* Invoked when the conference should be put on hold.
|
||||||
*/
|
*/
|
||||||
@@ -237,6 +259,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.
|
* Tears down the conference object and any of its current connections.
|
||||||
*/
|
*/
|
||||||
@@ -313,4 +366,11 @@ public abstract class Conference {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final void clearConferenceableList() {
|
||||||
|
for (Connection c : mConferenceableConnections) {
|
||||||
|
c.removeConnectionListener(mConnectionDeathListener);
|
||||||
|
}
|
||||||
|
mConferenceableConnections.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -870,7 +870,7 @@ public abstract class Connection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtains the connections with which this connection can be conferenced.
|
* Returns the connections with which this connection can be conferenced.
|
||||||
*/
|
*/
|
||||||
public final List<Connection> getConferenceableConnections() {
|
public final List<Connection> getConferenceableConnections() {
|
||||||
return mUnmodifiableConferenceableConnections;
|
return mUnmodifiableConferenceableConnections;
|
||||||
@@ -1100,7 +1100,7 @@ public abstract class Connection {
|
|||||||
|
|
||||||
private final void fireOnConferenceableConnectionsChanged() {
|
private final void fireOnConferenceableConnectionsChanged() {
|
||||||
for (Listener l : mListeners) {
|
for (Listener l : mListeners) {
|
||||||
l.onConferenceableConnectionsChanged(this, mConferenceableConnections);
|
l.onConferenceableConnectionsChanged(this, getConferenceableConnections());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -359,6 +359,14 @@ public abstract class ConnectionService extends Service {
|
|||||||
public void onConnectionRemoved(Conference conference, Connection connection) {
|
public void onConnectionRemoved(Conference conference, Connection connection) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConferenceableConnectionsChanged(
|
||||||
|
Conference conference, List<Connection> conferenceableConnections) {
|
||||||
|
mAdapter.setConferenceableConnections(
|
||||||
|
mIdByConference.get(conference),
|
||||||
|
createConnectionIdList(conferenceableConnections));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyed(Conference conference) {
|
public void onDestroyed(Conference conference) {
|
||||||
removeConference(conference);
|
removeConference(conference);
|
||||||
@@ -638,20 +646,26 @@ public abstract class ConnectionService extends Service {
|
|||||||
private void conference(String callId1, String callId2) {
|
private void conference(String callId1, String callId2) {
|
||||||
Log.d(this, "conference %s, %s", callId1, callId2);
|
Log.d(this, "conference %s, %s", callId1, callId2);
|
||||||
|
|
||||||
Connection connection1 = findConnectionForAction(callId1, "conference");
|
|
||||||
if (connection1 == getNullConnection()) {
|
|
||||||
Log.w(this, "Connection1 missing in conference request %s.", callId1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Connection connection2 = findConnectionForAction(callId2, "conference");
|
Connection connection2 = findConnectionForAction(callId2, "conference");
|
||||||
if (connection2 == getNullConnection()) {
|
if (connection2 == getNullConnection()) {
|
||||||
Log.w(this, "Connection2 missing in conference request %s.", callId2);
|
Log.w(this, "Connection2 missing in conference request %s.", callId2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connection connection1 = findConnectionForAction(callId1, "conference");
|
||||||
|
if (connection1 == getNullConnection()) {
|
||||||
|
Conference conference1 = findConferenceForAction(callId1, "addConnection");
|
||||||
|
if (conference1 == getNullConference()) {
|
||||||
|
Log.w(this,
|
||||||
|
"Connection1 or Conference1 missing in conference request %s.",
|
||||||
|
callId1);
|
||||||
|
} else {
|
||||||
|
conference1.onMerge(connection2);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
onConference(connection1, connection2);
|
onConference(connection1, connection2);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void splitFromConference(String callId) {
|
private void splitFromConference(String callId) {
|
||||||
Log.d(this, "splitFromConference(%s)", callId);
|
Log.d(this, "splitFromConference(%s)", callId);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.android.internal.telecom.IConnectionService;
|
|||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -40,6 +41,9 @@ public final class RemoteConference {
|
|||||||
public void onConnectionAdded(RemoteConference conference, RemoteConnection connection) {}
|
public void onConnectionAdded(RemoteConference conference, RemoteConnection connection) {}
|
||||||
public void onConnectionRemoved(RemoteConference conference, RemoteConnection connection) {}
|
public void onConnectionRemoved(RemoteConference conference, RemoteConnection connection) {}
|
||||||
public void onCapabilitiesChanged(RemoteConference conference, int capabilities) {}
|
public void onCapabilitiesChanged(RemoteConference conference, int capabilities) {}
|
||||||
|
public void onConferenceableConnectionsChanged(
|
||||||
|
RemoteConference conference,
|
||||||
|
List<RemoteConnection> conferenceableConnections) {}
|
||||||
public void onDestroyed(RemoteConference conference) {}
|
public void onDestroyed(RemoteConference conference) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,6 +54,9 @@ public final class RemoteConference {
|
|||||||
private final List<RemoteConnection> mChildConnections = new CopyOnWriteArrayList<>();
|
private final List<RemoteConnection> mChildConnections = new CopyOnWriteArrayList<>();
|
||||||
private final List<RemoteConnection> mUnmodifiableChildConnections =
|
private final List<RemoteConnection> mUnmodifiableChildConnections =
|
||||||
Collections.unmodifiableList(mChildConnections);
|
Collections.unmodifiableList(mChildConnections);
|
||||||
|
private final List<RemoteConnection> mConferenceableConnections = new ArrayList<>();
|
||||||
|
private final List<RemoteConnection> mUnmodifiableConferenceableConnections =
|
||||||
|
Collections.unmodifiableList(mConferenceableConnections);
|
||||||
|
|
||||||
private int mState = Connection.STATE_NEW;
|
private int mState = Connection.STATE_NEW;
|
||||||
private DisconnectCause mDisconnectCause;
|
private DisconnectCause mDisconnectCause;
|
||||||
@@ -127,6 +134,15 @@ public final class RemoteConference {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
void setConferenceableConnections(List<RemoteConnection> conferenceableConnections) {
|
||||||
|
mConferenceableConnections.clear();
|
||||||
|
mConferenceableConnections.addAll(conferenceableConnections);
|
||||||
|
for (Callback c : mCallbacks) {
|
||||||
|
c.onConferenceableConnectionsChanged(this, mUnmodifiableConferenceableConnections);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
void setDisconnected(DisconnectCause disconnectCause) {
|
void setDisconnected(DisconnectCause disconnectCause) {
|
||||||
if (mState != Connection.STATE_DISCONNECTED) {
|
if (mState != Connection.STATE_DISCONNECTED) {
|
||||||
@@ -219,6 +235,10 @@ public final class RemoteConference {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<RemoteConnection> getConferenceableConnections() {
|
||||||
|
return mUnmodifiableConferenceableConnections;
|
||||||
|
}
|
||||||
|
|
||||||
public final void registerCallback(Callback callback) {
|
public final void registerCallback(Callback callback) {
|
||||||
mCallbacks.add(callback);
|
mCallbacks.add(callback);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -278,8 +278,13 @@ final class RemoteConnectionService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasConnection(callId)) {
|
||||||
findConnectionForAction(callId, "setConferenceableConnections")
|
findConnectionForAction(callId, "setConferenceableConnections")
|
||||||
.setConferenceableConnections(conferenceable);
|
.setConferenceableConnections(conferenceable);
|
||||||
|
} else {
|
||||||
|
findConferenceForAction(callId, "setConferenceableConnections")
|
||||||
|
.setConferenceableConnections(conferenceable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -358,6 +363,10 @@ final class RemoteConnectionService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean hasConnection(String callId) {
|
||||||
|
return mConferenceById.containsKey(callId);
|
||||||
|
}
|
||||||
|
|
||||||
private RemoteConnection findConnectionForAction(
|
private RemoteConnection findConnectionForAction(
|
||||||
String callId, String action) {
|
String callId, String action) {
|
||||||
if (mConnectionById.containsKey(callId)) {
|
if (mConnectionById.containsKey(callId)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user