diff --git a/telecomm/java/android/telecomm/Conference.java b/telecomm/java/android/telecomm/Conference.java index 34b9dae7d83ad..44accb78fc5ee 100644 --- a/telecomm/java/android/telecomm/Conference.java +++ b/telecomm/java/android/telecomm/Conference.java @@ -163,6 +163,7 @@ public abstract class Conference { * @return True if the connection was successfully removed. */ public void removeConnection(Connection connection) { + Log.d(this, "removing %s from %s", connection, mChildConnections); if (connection != null && mChildConnections.remove(connection)) { connection.resetConference(); for (Listener l : mListeners) { @@ -177,7 +178,7 @@ public abstract class Conference { public void destroy() { Log.d(this, "destroying conference : %s", this); // Tear down the children. - for (Connection connection : new ArrayList<>(mChildConnections)) { + for (Connection connection : mChildConnections) { Log.d(this, "removing connection %s", connection); removeConnection(connection); } diff --git a/telecomm/java/android/telecomm/Connection.java b/telecomm/java/android/telecomm/Connection.java index c307a25aa5fcf..3aa4bafaecd9a 100644 --- a/telecomm/java/android/telecomm/Connection.java +++ b/telecomm/java/android/telecomm/Connection.java @@ -914,10 +914,11 @@ public abstract class Connection { */ public final boolean setConference(Conference conference) { // We check to see if it is already part of another conference. - if (mConference == null && mConnectionService != null && - mConnectionService.containsConference(conference)) { + if (mConference == null) { mConference = conference; - fireConferenceChanged(); + if (mConnectionService != null && mConnectionService.containsConference(conference)) { + fireConferenceChanged(); + } return true; } return false; @@ -929,6 +930,7 @@ public abstract class Connection { */ public final void resetConference() { if (mConference != null) { + Log.d(this, "Conference reset"); mConference = null; fireConferenceChanged(); } diff --git a/telecomm/java/android/telecomm/ConnectionService.java b/telecomm/java/android/telecomm/ConnectionService.java index c80597808e372..b77bb18515505 100644 --- a/telecomm/java/android/telecomm/ConnectionService.java +++ b/telecomm/java/android/telecomm/ConnectionService.java @@ -84,6 +84,7 @@ public abstract class ConnectionService extends Service { private final ConnectionServiceAdapter mAdapter = new ConnectionServiceAdapter(); private boolean mAreAccountsInitialized = false; + private Conference sNullConference; private final IBinder mBinder = new IConnectionService.Stub() { @Override @@ -561,17 +562,29 @@ public abstract class ConnectionService extends Service { private void disconnect(String callId) { Log.d(this, "disconnect %s", callId); - findConnectionForAction(callId, "disconnect").onDisconnect(); + if (mConnectionById.containsKey(callId)) { + findConnectionForAction(callId, "disconnect").onDisconnect(); + } else { + findConferenceForAction(callId, "disconnect").onDisconnect(); + } } private void hold(String callId) { Log.d(this, "hold %s", callId); - findConnectionForAction(callId, "hold").onHold(); + if (mConnectionById.containsKey(callId)) { + findConnectionForAction(callId, "hold").onHold(); + } else { + findConferenceForAction(callId, "hold").onHold(); + } } private void unhold(String callId) { Log.d(this, "unhold %s", callId); - findConnectionForAction(callId, "unhold").onUnhold(); + if (mConnectionById.containsKey(callId)) { + findConnectionForAction(callId, "unhold").onUnhold(); + } else { + findConferenceForAction(callId, "unhold").onUnhold(); + } } private void onAudioStateChanged(String callId, AudioState audioState) { @@ -616,7 +629,10 @@ public abstract class ConnectionService extends Service { return; } - // TODO: Find existing conference call and invoke split(connection). + Conference conference = connection.getConference(); + if (conference != null) { + conference.onSeparate(connection); + } } private void onPostDialContinue(String callId, boolean proceed) { @@ -885,4 +901,19 @@ public abstract class ConnectionService extends Service { } return sNullConnection; } + + private Conference findConferenceForAction(String conferenceId, String action) { + if (mConferenceById.containsKey(conferenceId)) { + return mConferenceById.get(conferenceId); + } + Log.w(this, "%s - Cannot find conference %s", action, conferenceId); + return getNullConference(); + } + + private Conference getNullConference() { + if (sNullConference == null) { + sNullConference = new Conference(null) {}; + } + return sNullConference; + } } diff --git a/telecomm/java/android/telecomm/ConnectionServiceAdapter.java b/telecomm/java/android/telecomm/ConnectionServiceAdapter.java index 41c6360461bbd..cb6364660a687 100644 --- a/telecomm/java/android/telecomm/ConnectionServiceAdapter.java +++ b/telecomm/java/android/telecomm/ConnectionServiceAdapter.java @@ -197,6 +197,7 @@ final class ConnectionServiceAdapter implements DeathRecipient { void setIsConferenced(String callId, String conferenceCallId) { for (IConnectionServiceAdapter adapter : mAdapters) { try { + Log.d(this, "sending connection %s with conference %s", callId, conferenceCallId); adapter.setIsConferenced(callId, conferenceCallId); } catch (RemoteException ignored) { }