diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java index 8ba934ccdb8bb..3fdc25e3a0d17 100644 --- a/telecomm/java/android/telecom/Connection.java +++ b/telecomm/java/android/telecom/Connection.java @@ -1683,6 +1683,8 @@ public abstract class Connection extends Conferenceable { // The internal telecom call ID associated with this connection. private String mTelecomCallId; + // The PhoneAccountHandle associated with this connection. + private PhoneAccountHandle mPhoneAccountHandle; private int mState = STATE_NEW; private CallAudioState mCallAudioState; private Uri mAddress; @@ -3075,6 +3077,27 @@ public abstract class Connection extends Conferenceable { } } + /** + * Sets the {@link PhoneAccountHandle} associated with this connection. + * + * @hide + */ + public void setPhoneAccountHandle(PhoneAccountHandle phoneAccountHandle) { + if (mPhoneAccountHandle != phoneAccountHandle) { + mPhoneAccountHandle = phoneAccountHandle; + notifyPhoneAccountChanged(phoneAccountHandle); + } + } + + /** + * Returns the {@link PhoneAccountHandle} associated with this connection. + * + * @hide + */ + public PhoneAccountHandle getPhoneAccountHandle() { + return mPhoneAccountHandle; + } + /** * Sends an event associated with this {@code Connection} with associated event extras to the * {@link InCallService}. diff --git a/telecomm/java/android/telecom/ConnectionService.java b/telecomm/java/android/telecom/ConnectionService.java index a81fba95c4ed2..bb4019d6db45e 100644 --- a/telecomm/java/android/telecom/ConnectionService.java +++ b/telecomm/java/android/telecom/ConnectionService.java @@ -1382,7 +1382,7 @@ public abstract class ConnectionService extends Service { connection.setTelecomCallId(callId); if (connection.getState() != Connection.STATE_DISCONNECTED) { - addConnection(callId, connection); + addConnection(request.getAccountHandle(), callId, connection); } Uri address = connection.getAddress(); @@ -1846,6 +1846,7 @@ public abstract class ConnectionService extends Service { mAdapter.setIsConferenced(connectionId, id); } } + onConferenceAdded(conference); } } @@ -2055,6 +2056,30 @@ public abstract class ConnectionService extends Service { */ public void onConference(Connection connection1, Connection connection2) {} + /** + * Called when a connection is added. + * @hide + */ + public void onConnectionAdded(Connection connection) {} + + /** + * Called when a connection is removed. + * @hide + */ + public void onConnectionRemoved(Connection connection) {} + + /** + * Called when a conference is added. + * @hide + */ + public void onConferenceAdded(Conference conference) {} + + /** + * Called when a conference is removed. + * @hide + */ + public void onConferenceRemoved(Conference conference) {} + /** * Indicates that a remote conference has been created for existing {@link RemoteConnection}s. * When this method is invoked, this {@link ConnectionService} should create its own @@ -2122,16 +2147,18 @@ public abstract class ConnectionService extends Service { // prefix for a unique incremental call ID. id = handle.getComponentName().getClassName() + "@" + getNextCallId(); } - addConnection(id, connection); + addConnection(handle, id, connection); return id; } - private void addConnection(String callId, Connection connection) { + private void addConnection(PhoneAccountHandle handle, String callId, Connection connection) { connection.setTelecomCallId(callId); mConnectionById.put(callId, connection); mIdByConnection.put(connection, callId); connection.addConnectionListener(mConnectionListener); connection.setConnectionService(this); + connection.setPhoneAccountHandle(handle); + onConnectionAdded(connection); } /** {@hide} */ @@ -2143,6 +2170,7 @@ public abstract class ConnectionService extends Service { mConnectionById.remove(id); mIdByConnection.remove(connection); mAdapter.removeCall(id); + onConnectionRemoved(connection); } } @@ -2179,6 +2207,8 @@ public abstract class ConnectionService extends Service { mConferenceById.remove(id); mIdByConference.remove(conference); mAdapter.removeCall(id); + + onConferenceRemoved(conference); } }