Merge "Framework fixes to support VoLTE conf calls via RemoteConnectionServices." into nyc-mr1-dev
This commit is contained in:
@@ -419,6 +419,31 @@ public abstract class Connection extends Conferenceable {
|
|||||||
public static final String EXTRA_DISABLE_ADD_CALL =
|
public static final String EXTRA_DISABLE_ADD_CALL =
|
||||||
"android.telecom.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
|
* 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
|
* to play a tone when the peer puts the current call on hold. Sent to Telecom via
|
||||||
|
|||||||
@@ -1347,7 +1347,13 @@ public abstract class ConnectionService extends Service {
|
|||||||
*/
|
*/
|
||||||
private String addExistingConnectionInternal(PhoneAccountHandle handle, Connection connection) {
|
private String addExistingConnectionInternal(PhoneAccountHandle handle, Connection connection) {
|
||||||
String id;
|
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,
|
// If no phone account handle was provided, we cannot be sure the call ID is unique,
|
||||||
// so just use a random UUID.
|
// so just use a random UUID.
|
||||||
id = UUID.randomUUID().toString();
|
id = UUID.randomUUID().toString();
|
||||||
@@ -1381,13 +1387,21 @@ public abstract class ConnectionService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String addConferenceInternal(Conference conference) {
|
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)) {
|
if (mIdByConference.containsKey(conference)) {
|
||||||
Log.w(this, "Re-adding an existing conference: %s.", conference);
|
Log.w(this, "Re-adding an existing conference: %s.", conference);
|
||||||
} else if (conference != null) {
|
} else if (conference != null) {
|
||||||
// Conferences do not (yet) have a PhoneAccountHandle associated with them, so we
|
// 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
|
// cannot determine a ConnectionService class name to associate with the ID, so use
|
||||||
// a unique UUID (for now).
|
// a unique UUID (for now).
|
||||||
String id = UUID.randomUUID().toString();
|
String id = originalId == null ? UUID.randomUUID().toString() : originalId;
|
||||||
mConferenceById.put(id, conference);
|
mConferenceById.put(id, conference);
|
||||||
mIdByConference.put(conference, id);
|
mIdByConference.put(conference, id);
|
||||||
conference.addListener(mConferenceListener);
|
conference.addListener(mConferenceListener);
|
||||||
|
|||||||
@@ -311,6 +311,9 @@ public final class RemoteConference {
|
|||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
void putExtras(final Bundle extras) {
|
void putExtras(final Bundle extras) {
|
||||||
|
if (extras == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mExtras == null) {
|
if (mExtras == null) {
|
||||||
mExtras = new Bundle();
|
mExtras = new Bundle();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -651,6 +651,14 @@ public final class RemoteConnection {
|
|||||||
mCallerDisplayName = connection.getCallerDisplayName();
|
mCallerDisplayName = connection.getCallerDisplayName();
|
||||||
mCallerDisplayNamePresentation = connection.getCallerDisplayNamePresentation();
|
mCallerDisplayNamePresentation = connection.getCallerDisplayNamePresentation();
|
||||||
mConference = null;
|
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 */
|
/** @hide */
|
||||||
void putExtras(final Bundle extras) {
|
void putExtras(final Bundle extras) {
|
||||||
|
if (extras == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (mExtras == null) {
|
if (mExtras == null) {
|
||||||
mExtras = new Bundle();
|
mExtras = new Bundle();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,18 +214,27 @@ final class RemoteConnectionService {
|
|||||||
conference.addConnection(c);
|
conference.addConnection(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conference.getConnections().size() == 0) {
|
if (conference.getConnections().size() == 0) {
|
||||||
// A conference was created, but none of its connections are ones that have been
|
// 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
|
// created by, and therefore being tracked by, this remote connection service. It
|
||||||
// is of no interest to us.
|
// is of no interest to us.
|
||||||
|
Log.d(this, "addConferenceCall - skipping");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
conference.setState(parcel.getState());
|
conference.setState(parcel.getState());
|
||||||
conference.setConnectionCapabilities(parcel.getConnectionCapabilities());
|
conference.setConnectionCapabilities(parcel.getConnectionCapabilities());
|
||||||
conference.setConnectionProperties(parcel.getConnectionProperties());
|
conference.setConnectionProperties(parcel.getConnectionProperties());
|
||||||
|
conference.putExtras(parcel.getExtras());
|
||||||
mConferenceById.put(callId, conference);
|
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() {
|
conference.registerCallback(new RemoteConference.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyed(RemoteConference c) {
|
public void onDestroyed(RemoteConference c) {
|
||||||
@@ -331,12 +340,18 @@ final class RemoteConnectionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addExistingConnection(String callId, ParcelableConnection connection) {
|
public void addExistingConnection(final String callId, ParcelableConnection connection) {
|
||||||
// TODO: add contents of this method
|
RemoteConnection remoteConnection = new RemoteConnection(callId,
|
||||||
RemoteConnection remoteConnction = new RemoteConnection(callId,
|
|
||||||
mOutgoingConnectionServiceRpc, connection);
|
mOutgoingConnectionServiceRpc, connection);
|
||||||
|
mConnectionById.put(callId, remoteConnection);
|
||||||
mOurConnectionServiceImpl.addRemoteExistingConnection(remoteConnction);
|
remoteConnection.registerCallback(new RemoteConnection.Callback() {
|
||||||
|
@Override
|
||||||
|
public void onDestroyed(RemoteConnection connection) {
|
||||||
|
mConnectionById.remove(callId);
|
||||||
|
maybeDisconnectAdapter();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mOurConnectionServiceImpl.addRemoteExistingConnection(remoteConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user