Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0159ac0c authored by Santos Cordon's avatar Santos Cordon
Browse files

Additional changes for Conference.

1) Connection.setConference() checked to see if the conference was valid
before setting it.  This prevented us from populating child connections
on a new conference until it was added.  Now we allow it but dont sent
the update unless the conference has already been sent.
2) removed unnecessary ArrayList<>() wrappers on CopyOnWriteLists.
3) Updated disconnect/hold/unhold so that they are sent to Conference
objects as well as Connection objects.
4) Added support for separating a child conference call.
5) Additional Logging

Bug: 15621105
Bug: 17136172
Change-Id: I939c36bc9694b9d81f0ff582e2fbe335006aa485
parent c54a76cb
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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);
        }
+5 −3
Original line number Diff line number Diff line
@@ -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;
            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();
        }
+35 −4
Original line number Diff line number Diff line
@@ -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);
        if (mConnectionById.containsKey(callId)) {
            findConnectionForAction(callId, "disconnect").onDisconnect();
        } else {
            findConferenceForAction(callId, "disconnect").onDisconnect();
        }
    }

    private void hold(String callId) {
        Log.d(this, "hold %s", callId);
        if (mConnectionById.containsKey(callId)) {
            findConnectionForAction(callId, "hold").onHold();
        } else {
            findConferenceForAction(callId, "hold").onHold();
        }
    }

    private void unhold(String callId) {
        Log.d(this, "unhold %s", callId);
        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;
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -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) {
            }