Framework fixes to support VoLTE conf calls via RemoteConnectionServices.

am: 2282bb97e7

Change-Id: Ibc446de0822d379bc367d6bc410e9830b65d5d20
This commit is contained in:
Tyler Gunn
2016-10-20 01:06:48 +00:00
committed by android-build-merger
5 changed files with 76 additions and 8 deletions

View File

@@ -419,6 +419,31 @@ public abstract class Connection extends Conferenceable {
public static final String EXTRA_DISABLE_ADD_CALL =
"android.telecom.extra.DISABLE_ADD_CALL";
/**
* String connection extra key on a {@link Connection} or {@link Conference} which contains the
* original Connection ID associated with the connection. Used in
* {@link RemoteConnectionService} to track the Connection ID which was originally assigned to a
* connection/conference added via
* {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)} and
* {@link ConnectionService#addConference(Conference)} APIs. This is important to pass to
* Telecom for when it deals with RemoteConnections. When the ConnectionManager wraps the
* {@link RemoteConnection} and {@link RemoteConference} and adds it to Telecom, there needs to
* be a way to ensure that we don't add the connection again as a duplicate.
* <p>
* For example, the TelephonyCS calls addExistingConnection for a Connection with ID
* {@code TelephonyCS@1}. The ConnectionManager learns of this via
* {@link ConnectionService#onRemoteExistingConnectionAdded(RemoteConnection)}, and wraps this
* in a new {@link Connection} which it adds to Telecom via
* {@link ConnectionService#addExistingConnection(PhoneAccountHandle, Connection)}. As part of
* this process, the wrapped RemoteConnection gets assigned a new ID (e.g. {@code ConnMan@1}).
* The TelephonyCS will ALSO try to add the existing connection to Telecom, except with the
* ID it originally referred to the connection as. Thus Telecom needs to know that the
* Connection with ID {@code ConnMan@1} is really the same as {@code TelephonyCS@1}.
* @hide
*/
public static final String EXTRA_ORIGINAL_CONNECTION_ID =
"android.telecom.extra.ORIGINAL_CONNECTION_ID";
/**
* Connection event used to inform Telecom that it should play the on hold tone. This is used
* to play a tone when the peer puts the current call on hold. Sent to Telecom via

View File

@@ -1347,7 +1347,13 @@ public abstract class ConnectionService extends Service {
*/
private String addExistingConnectionInternal(PhoneAccountHandle handle, Connection connection) {
String id;
if (handle == null) {
if (connection.getExtras() != null && connection.getExtras()
.containsKey(Connection.EXTRA_ORIGINAL_CONNECTION_ID)) {
id = connection.getExtras().getString(Connection.EXTRA_ORIGINAL_CONNECTION_ID);
Log.d(this, "addExistingConnectionInternal - conn %s reusing original id %s",
connection.getTelecomCallId(), id);
} else if (handle == null) {
// If no phone account handle was provided, we cannot be sure the call ID is unique,
// so just use a random UUID.
id = UUID.randomUUID().toString();
@@ -1381,13 +1387,21 @@ public abstract class ConnectionService extends Service {
}
private String addConferenceInternal(Conference conference) {
String originalId = null;
if (conference.getExtras() != null && conference.getExtras()
.containsKey(Connection.EXTRA_ORIGINAL_CONNECTION_ID)) {
originalId = conference.getExtras().getString(Connection.EXTRA_ORIGINAL_CONNECTION_ID);
Log.d(this, "addConferenceInternal: conf %s reusing original id %s",
conference.getTelecomCallId(),
originalId);
}
if (mIdByConference.containsKey(conference)) {
Log.w(this, "Re-adding an existing conference: %s.", conference);
} else if (conference != null) {
// Conferences do not (yet) have a PhoneAccountHandle associated with them, so we
// cannot determine a ConnectionService class name to associate with the ID, so use
// a unique UUID (for now).
String id = UUID.randomUUID().toString();
String id = originalId == null ? UUID.randomUUID().toString() : originalId;
mConferenceById.put(id, conference);
mIdByConference.put(conference, id);
conference.addListener(mConferenceListener);

View File

@@ -311,6 +311,9 @@ public final class RemoteConference {
/** @hide */
void putExtras(final Bundle extras) {
if (extras == null) {
return;
}
if (mExtras == null) {
mExtras = new Bundle();
}

View File

@@ -651,6 +651,14 @@ public final class RemoteConnection {
mCallerDisplayName = connection.getCallerDisplayName();
mCallerDisplayNamePresentation = connection.getCallerDisplayNamePresentation();
mConference = null;
putExtras(connection.getExtras());
// Stash the original connection ID as it exists in the source ConnectionService.
// Telecom will use this to avoid adding duplicates later.
// See comments on Connection.EXTRA_ORIGINAL_CONNECTION_ID for more information.
Bundle newExtras = new Bundle();
newExtras.putString(Connection.EXTRA_ORIGINAL_CONNECTION_ID, callId);
putExtras(newExtras);
}
/**
@@ -1348,6 +1356,9 @@ public final class RemoteConnection {
/** @hide */
void putExtras(final Bundle extras) {
if (extras == null) {
return;
}
if (mExtras == null) {
mExtras = new Bundle();
}

View File

@@ -214,18 +214,27 @@ final class RemoteConnectionService {
conference.addConnection(c);
}
}
if (conference.getConnections().size() == 0) {
// A conference was created, but none of its connections are ones that have been
// created by, and therefore being tracked by, this remote connection service. It
// is of no interest to us.
Log.d(this, "addConferenceCall - skipping");
return;
}
conference.setState(parcel.getState());
conference.setConnectionCapabilities(parcel.getConnectionCapabilities());
conference.setConnectionProperties(parcel.getConnectionProperties());
conference.putExtras(parcel.getExtras());
mConferenceById.put(callId, conference);
// Stash the original connection ID as it exists in the source ConnectionService.
// Telecom will use this to avoid adding duplicates later.
// See comments on Connection.EXTRA_ORIGINAL_CONNECTION_ID for more information.
Bundle newExtras = new Bundle();
newExtras.putString(Connection.EXTRA_ORIGINAL_CONNECTION_ID, callId);
conference.putExtras(newExtras);
conference.registerCallback(new RemoteConference.Callback() {
@Override
public void onDestroyed(RemoteConference c) {
@@ -331,12 +340,18 @@ final class RemoteConnectionService {
}
@Override
public void addExistingConnection(String callId, ParcelableConnection connection) {
// TODO: add contents of this method
RemoteConnection remoteConnction = new RemoteConnection(callId,
public void addExistingConnection(final String callId, ParcelableConnection connection) {
RemoteConnection remoteConnection = new RemoteConnection(callId,
mOutgoingConnectionServiceRpc, connection);
mOurConnectionServiceImpl.addRemoteExistingConnection(remoteConnction);
mConnectionById.put(callId, remoteConnection);
remoteConnection.registerCallback(new RemoteConnection.Callback() {
@Override
public void onDestroyed(RemoteConnection connection) {
mConnectionById.remove(callId);
maybeDisconnectAdapter();
}
});
mOurConnectionServiceImpl.addRemoteExistingConnection(remoteConnection);
}
@Override