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

Commit 78aa4843 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Correct FocusManager issue which prevented swapping calls.

Where a conference call is active and a standalone call is dialed, the
focus manager would not allow swapping between the two calls.
The underlying issue was that the focus manager would try to focus on one
of the child calls of the conference.
Updated the focus manger interface to add an "isFocusable" method which
is used to indicate that external calls and child calls can't be focused.
Added unit test to verify this scenario.

Test: Manually tested conference scenario, added unit test to capture case.
Bug: 74375021
Change-Id: Ie6d1b9957b9dde81dbba0e7ab5dddcf4a61cfd2e
parent ec9d18e9
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -801,6 +801,18 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        return mState;
    }

    /**
     * Determines if this {@link Call} can receive call focus via the
     * {@link ConnectionServiceFocusManager}.
     * Only top-level calls and non-external calls are eligible.
     * @return {@code true} if this call is focusable, {@code false} otherwise.
     */
    @Override
    public boolean isFocusable() {
        boolean isChild = getParentCall() != null;
        return !isChild && !isExternalCall();
    }

    private boolean shouldContinueProcessingAfterDisconnect() {
        // Stop processing once the call is active.
        if (!CreateConnectionTimeout.isCallBeingPlaced(this)) {
+7 −1
Original line number Diff line number Diff line
@@ -112,6 +112,11 @@ public class ConnectionServiceFocusManager {
         * @see {@link CallState}
         */
        int getState();

        /**
         * @return {@code True} if this call can receive focus, {@code false} otherwise.
         */
        boolean isFocusable();
    }

    /** Interface define a call back for focus request event. */
@@ -330,7 +335,8 @@ public class ConnectionServiceFocusManager {

        List<CallFocus> calls = mCalls
                .stream()
                .filter(call -> mCurrentFocus.equals(call.getConnectionServiceWrapper()))
                .filter(call -> mCurrentFocus.equals(call.getConnectionServiceWrapper())
                        && call.isFocusable())
                .collect(Collectors.toList());

        for (int i = 0; i < PRIORITY_FOCUS_CALL_STATE.length; i++) {
+15 −0
Original line number Diff line number Diff line
@@ -307,6 +307,20 @@ public class ConnectionServiceFocusManagerTest extends TelecomTestCase {
        assertTrue(mFocusManagerUT.getAllCall().contains(mActiveCall));
    }

    @SmallTest
    @Test
    public void testNonFocusableDoesntChangeFocus() {
        // GIVEN the ConnectionServiceFocusManager with the focus ConnectionService
        requestFocus(mActiveCall, null);

        // WHEN a new non-focusable call is added.
        when(mNewCall.isFocusable()).thenReturn(false);
        mCallsManagerListener.onCallAdded((Call) mNewCall);

        // THEN the call focus isn't changed.
        assertEquals(mActiveCall, mFocusManagerUT.getCurrentFocusCall());
    }

    private void requestFocus(CallFocus call, RequestFocusCallback callback) {
        mCallsManagerListener.onCallAdded((Call) call);
        mFocusManagerUT.requestFocus(call, callback);
@@ -344,6 +358,7 @@ public class ConnectionServiceFocusManagerTest extends TelecomTestCase {
        Call call = Mockito.mock(Call.class);
        when(call.getConnectionServiceWrapper()).thenReturn(connSvr);
        when(call.getState()).thenReturn(state);
        when(call.isFocusable()).thenReturn(true);
        return call;
    }
}