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

Commit ce0d10c1 authored by Tyler Gunn's avatar Tyler Gunn Committed by Automerger Merge Worker
Browse files

Merge "Fix issue where >2 party conference connect time is wrong on child...

Merge "Fix issue where >2 party conference connect time is wrong on child drop." into rvc-dev am: f44235f0 am: 8427c6a7

Change-Id: I97e5b6e0714228f529dd6caf143d992a9ce2b72e
parents 25cca792 8427c6a7
Loading
Loading
Loading
Loading
+32 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.telecom;

import android.annotation.NonNull;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
@@ -1642,7 +1643,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        mCreationTimeMillis = time;
    }

    long getConnectTimeMillis() {
    public long getConnectTimeMillis() {
        return mConnectTimeMillis;
    }

@@ -2806,7 +2807,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
     * ensure the InCall UI is updated with the change in parent.
     * @param parentCall The new parent for this call.
     */
    void setChildOf(Call parentCall) {
    public void setChildOf(Call parentCall) {
        if (parentCall != null && !parentCall.getChildCalls().contains(this)) {
            parentCall.addChildCall(this);
        }
@@ -2844,6 +2845,11 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
            mConferenceLevelActiveCall = call;
            mChildCalls.add(call);

            // When adding a child, we will potentially adjust the various times from the calls
            // based on the children being added.  This ensures the parent of the conference has a
            // connect time reflective of all the children added.
            maybeAdjustConnectTime(call);

            Log.addEvent(this, LogUtils.Events.ADD_CHILD, call);

            for (Listener l : mListeners) {
@@ -2852,6 +2858,30 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        }
    }

    /**
     * Potentially adjust the connect and creation time of this call based on another one.
     * Ensures that if the other call has an earlier connect time that we adjust the connect time of
     * this call to match.
     * <p>
     * This is important for conference calls; as we add children to the conference we need to
     * ensure that earlier connect time is reflected on the conference.  In the past this
     * was just done in {@link ParcelableCallUtils} when parceling the calls to the UI, but that
     * approach would not reflect the right time on the parent as children disconnect.
     *
     * @param call the call to potentially use to adjust connect time.
     */
    private void maybeAdjustConnectTime(@NonNull Call call) {
        long childConnectTimeMillis = call.getConnectTimeMillis();
        long currentConnectTimeMillis = getConnectTimeMillis();
        // Conference calls typically have a 0 connect time, so we will replace the current connect
        // time if its zero also.
        if (childConnectTimeMillis != 0
                && (currentConnectTimeMillis == 0
                || childConnectTimeMillis < getConnectTimeMillis())) {
            setConnectTimeMillis(childConnectTimeMillis);
        }
    }

    private void removeChildCall(Call call) {
        if (mChildCalls.remove(call)) {
            Log.addEvent(this, LogUtils.Events.REMOVE_CHILD, call);
+1 −11
Original line number Diff line number Diff line
@@ -181,22 +181,12 @@ public class ParcelableCallUtils {
            parentCallId = parentCall.getId();
        }

        long connectTimeMillis = call.getConnectTimeMillis();
        List<Call> childCalls = call.getChildCalls();
        List<String> childCallIds = new ArrayList<>();
        if (!childCalls.isEmpty()) {
            long childConnectTimeMillis = Long.MAX_VALUE;
            for (Call child : childCalls) {
                if (child.getConnectTimeMillis() > 0) {
                    childConnectTimeMillis = Math.min(child.getConnectTimeMillis(),
                            childConnectTimeMillis);
                }
                childCallIds.add(child.getId());
            }

            if (childConnectTimeMillis != Long.MAX_VALUE) {
                connectTimeMillis = childConnectTimeMillis;
            }
        }

        Uri handle = call.getHandlePresentation() == TelecomManager.PRESENTATION_ALLOWED ?
@@ -240,7 +230,7 @@ public class ParcelableCallUtils {
                .setCapabilities(capabilities)
                .setProperties(properties)
                .setSupportedAudioRoutes(supportedAudioRoutes)
                .setConnectTimeMillis(connectTimeMillis)
                .setConnectTimeMillis(call.getConnectTimeMillis())
                .setHandle(handle)
                .setHandlePresentation(call.getHandlePresentation())
                .setCallerDisplayName(callerDisplayName)
+28 −0
Original line number Diff line number Diff line
@@ -1217,6 +1217,34 @@ public class CallsManagerTest extends TelecomTestCase {
        assertFalse(outgoingCall.getStartWithSpeakerphoneOn());
    }

    /**
     * Verify that a parent call will inherit the connect time of its children.
     * @throws Exception
     */
    @SmallTest
    @Test
    public void testParentInheritsChildConnectTime() throws Exception {
        Call callSim1 = createCall(SIM_1_HANDLE, null, CallState.ACTIVE);
        Call callSim2 = createCall(SIM_1_HANDLE, null, CallState.ACTIVE);
        callSim1.setConnectTimeMillis(100);

        // Pretend it is a conference made later.
        callSim2.setConnectTimeMillis(0);

        // Make the first call a child of the second (pretend conference).
        callSim1.setChildOf(callSim2);

        assertEquals(100, callSim2.getConnectTimeMillis());

        // Add another later call.
        Call callSim3 = createCall(SIM_1_HANDLE, null, CallState.ACTIVE);
        callSim3.setConnectTimeMillis(200);
        callSim3.setChildOf(callSim2);

        // Later call shouldn't impact parent.
        assertEquals(100, callSim2.getConnectTimeMillis());
    }

    /**
     * Make sure that CallsManager handles a screening result that has both
     * silence and screen-further set to true as a request to screen further.