Merge "Support for Telecom Call IDs."
This commit is contained in:
@@ -65,6 +65,7 @@ public abstract class Conference extends Conferenceable {
|
||||
private final List<Connection> mUnmodifiableConferenceableConnections =
|
||||
Collections.unmodifiableList(mConferenceableConnections);
|
||||
|
||||
private String mTelecomCallId;
|
||||
private PhoneAccountHandle mPhoneAccount;
|
||||
private CallAudioState mCallAudioState;
|
||||
private int mState = Connection.STATE_NEW;
|
||||
@@ -93,6 +94,26 @@ public abstract class Conference extends Conferenceable {
|
||||
mPhoneAccount = phoneAccount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the telecom internal call ID associated with this conference.
|
||||
*
|
||||
* @return The telecom call ID.
|
||||
* @hide
|
||||
*/
|
||||
public final String getTelecomCallId() {
|
||||
return mTelecomCallId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the telecom internal call ID associated with this conference.
|
||||
*
|
||||
* @param telecomCallId The telecom call ID.
|
||||
* @hide
|
||||
*/
|
||||
public final void setTelecomCallId(String telecomCallId) {
|
||||
mTelecomCallId = telecomCallId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link PhoneAccountHandle} the conference call is being placed through.
|
||||
*
|
||||
|
||||
@@ -1074,6 +1074,8 @@ public abstract class Connection extends Conferenceable {
|
||||
private final List<Conferenceable> mUnmodifiableConferenceables =
|
||||
Collections.unmodifiableList(mConferenceables);
|
||||
|
||||
// The internal telecom call ID associated with this connection.
|
||||
private String mTelecomCallId;
|
||||
private int mState = STATE_NEW;
|
||||
private CallAudioState mCallAudioState;
|
||||
private Uri mAddress;
|
||||
@@ -1097,6 +1099,17 @@ public abstract class Connection extends Conferenceable {
|
||||
*/
|
||||
public Connection() {}
|
||||
|
||||
/**
|
||||
* Returns the Telecom internal call ID associated with this connection. Should only be used
|
||||
* for debugging and tracing purposes.
|
||||
*
|
||||
* @return The Telecom call ID.
|
||||
* @hide
|
||||
*/
|
||||
public final String getTelecomCallId() {
|
||||
return mTelecomCallId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The address (e.g., phone number) to which this Connection is currently communicating.
|
||||
*/
|
||||
@@ -1258,6 +1271,17 @@ public abstract class Connection extends Conferenceable {
|
||||
return mDisconnectCause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the telecom call ID associated with this Connection. The Telecom Call ID should be used
|
||||
* ONLY for debugging purposes.
|
||||
*
|
||||
* @param callId The telecom call ID.
|
||||
* @hide
|
||||
*/
|
||||
public void setTelecomCallId(String callId) {
|
||||
mTelecomCallId = callId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform this Connection that the state of its audio output has been changed externally.
|
||||
*
|
||||
|
||||
@@ -32,6 +32,7 @@ public final class ConnectionRequest implements Parcelable {
|
||||
private final Uri mAddress;
|
||||
private final Bundle mExtras;
|
||||
private final int mVideoState;
|
||||
private final String mTelecomCallId;
|
||||
|
||||
/**
|
||||
* @param accountHandle The accountHandle which should be used to place the call.
|
||||
@@ -42,7 +43,7 @@ public final class ConnectionRequest implements Parcelable {
|
||||
PhoneAccountHandle accountHandle,
|
||||
Uri handle,
|
||||
Bundle extras) {
|
||||
this(accountHandle, handle, extras, VideoProfile.STATE_AUDIO_ONLY);
|
||||
this(accountHandle, handle, extras, VideoProfile.STATE_AUDIO_ONLY, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,10 +57,28 @@ public final class ConnectionRequest implements Parcelable {
|
||||
Uri handle,
|
||||
Bundle extras,
|
||||
int videoState) {
|
||||
this(accountHandle, handle, extras, videoState, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param accountHandle The accountHandle which should be used to place the call.
|
||||
* @param handle The handle (e.g., phone number) to which the {@link Connection} is to connect.
|
||||
* @param extras Application-specific extra data.
|
||||
* @param videoState Determines the video state for the connection.
|
||||
* @param telecomCallId The telecom call ID.
|
||||
* @hide
|
||||
*/
|
||||
public ConnectionRequest(
|
||||
PhoneAccountHandle accountHandle,
|
||||
Uri handle,
|
||||
Bundle extras,
|
||||
int videoState,
|
||||
String telecomCallId) {
|
||||
mAccountHandle = accountHandle;
|
||||
mAddress = handle;
|
||||
mExtras = extras;
|
||||
mVideoState = videoState;
|
||||
mTelecomCallId = telecomCallId;
|
||||
}
|
||||
|
||||
private ConnectionRequest(Parcel in) {
|
||||
@@ -67,6 +86,7 @@ public final class ConnectionRequest implements Parcelable {
|
||||
mAddress = in.readParcelable(getClass().getClassLoader());
|
||||
mExtras = in.readParcelable(getClass().getClassLoader());
|
||||
mVideoState = in.readInt();
|
||||
mTelecomCallId = in.readString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,6 +119,16 @@ public final class ConnectionRequest implements Parcelable {
|
||||
return mVideoState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the internal Telecom ID associated with the connection request.
|
||||
*
|
||||
* @return The Telecom ID.
|
||||
* @hide
|
||||
*/
|
||||
public String getTelecomCallId() {
|
||||
return mTelecomCallId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("ConnectionRequest %s %s",
|
||||
@@ -134,5 +164,6 @@ public final class ConnectionRequest implements Parcelable {
|
||||
destination.writeParcelable(mAddress, 0);
|
||||
destination.writeParcelable(mExtras, 0);
|
||||
destination.writeInt(mVideoState);
|
||||
destination.writeString(mTelecomCallId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,6 +116,8 @@ public abstract class ConnectionService extends Service {
|
||||
|
||||
private boolean mAreAccountsInitialized = false;
|
||||
private Conference sNullConference;
|
||||
private Object mIdSyncRoot = new Object();
|
||||
private int mId = 0;
|
||||
|
||||
private final IBinder mBinder = new IConnectionService.Stub() {
|
||||
@Override
|
||||
@@ -629,7 +631,8 @@ public abstract class ConnectionService extends Service {
|
||||
boolean isIncoming,
|
||||
boolean isUnknown) {
|
||||
Log.d(this, "createConnection, callManagerAccount: %s, callId: %s, request: %s, " +
|
||||
"isIncoming: %b, isUnknown: %b", callManagerAccount, callId, request, isIncoming,
|
||||
"isIncoming: %b, isUnknown: %b", callManagerAccount, callId, request,
|
||||
isIncoming,
|
||||
isUnknown);
|
||||
|
||||
Connection connection = isUnknown ? onCreateUnknownConnection(callManagerAccount, request)
|
||||
@@ -641,6 +644,7 @@ public abstract class ConnectionService extends Service {
|
||||
new DisconnectCause(DisconnectCause.ERROR));
|
||||
}
|
||||
|
||||
connection.setTelecomCallId(callId);
|
||||
if (connection.getState() != Connection.STATE_DISCONNECTED) {
|
||||
addConnection(callId, connection);
|
||||
}
|
||||
@@ -953,6 +957,7 @@ public abstract class ConnectionService extends Service {
|
||||
connectionIds.add(mIdByConnection.get(connection));
|
||||
}
|
||||
}
|
||||
conference.setTelecomCallId(id);
|
||||
ParcelableConference parcelableConference = new ParcelableConference(
|
||||
conference.getPhoneAccountHandle(),
|
||||
conference.getState(),
|
||||
@@ -989,7 +994,7 @@ public abstract class ConnectionService extends Service {
|
||||
public final void addExistingConnection(PhoneAccountHandle phoneAccountHandle,
|
||||
Connection connection) {
|
||||
|
||||
String id = addExistingConnectionInternal(connection);
|
||||
String id = addExistingConnectionInternal(phoneAccountHandle, connection);
|
||||
if (id != null) {
|
||||
List<String> emptyList = new ArrayList<>(0);
|
||||
|
||||
@@ -1151,18 +1156,29 @@ public abstract class ConnectionService extends Service {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an existing connection to the list of connections, identified by a new UUID.
|
||||
* Adds an existing connection to the list of connections, identified by a new call ID unique
|
||||
* to this connection service.
|
||||
*
|
||||
* @param connection The connection.
|
||||
* @return The UUID of the connection (e.g. the call-id).
|
||||
* @return The ID of the connection (e.g. the call-id).
|
||||
*/
|
||||
private String addExistingConnectionInternal(Connection connection) {
|
||||
String id = UUID.randomUUID().toString();
|
||||
private String addExistingConnectionInternal(PhoneAccountHandle handle, Connection connection) {
|
||||
String id;
|
||||
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();
|
||||
} else {
|
||||
// Phone account handle was provided, so use the ConnectionService class name as a
|
||||
// prefix for a unique incremental call ID.
|
||||
id = handle.getComponentName().getClassName() + "@" + getNextCallId();
|
||||
}
|
||||
addConnection(id, connection);
|
||||
return id;
|
||||
}
|
||||
|
||||
private void addConnection(String callId, Connection connection) {
|
||||
connection.setTelecomCallId(callId);
|
||||
mConnectionById.put(callId, connection);
|
||||
mIdByConnection.put(connection, callId);
|
||||
connection.addConnectionListener(mConnectionListener);
|
||||
@@ -1183,6 +1199,9 @@ public abstract class ConnectionService extends Service {
|
||||
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();
|
||||
mConferenceById.put(id, conference);
|
||||
mIdByConference.put(conference, id);
|
||||
@@ -1284,4 +1303,15 @@ public abstract class ConnectionService extends Service {
|
||||
conference.onDisconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the next call ID as maintainted by the connection service.
|
||||
*
|
||||
* @return The call ID.
|
||||
*/
|
||||
private int getNextCallId() {
|
||||
synchronized(mIdSyncRoot) {
|
||||
return ++mId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user