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

Commit 3fc649c2 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Translate ANSWERED to ACTIVE for ICS updates" into main

parents dac8dcf8 56731283
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -1482,8 +1482,10 @@ public class InCallController extends CallsManagerListenerBase implements
                        true /* includeVideoProvider */,
                        mCallsManager.getPhoneAccountRegistrar(),
                        info.isExternalCallsSupported(), includeRttCall,
                        info.getType() == IN_CALL_SERVICE_TYPE_SYSTEM_UI ||
                                info.getType() == IN_CALL_SERVICE_TYPE_NON_UI);
                        info.getType() == IN_CALL_SERVICE_TYPE_SYSTEM_UI
                                || info.getType() == IN_CALL_SERVICE_TYPE_NON_UI
                                || info.getType() == IN_CALL_SERVICE_TYPE_BLUETOOTH,
                        info.getType() == IN_CALL_SERVICE_TYPE_BLUETOOTH);
                try {
                    inCallService.addCall(
                            sanitizeParcelableCallForService(info, parcelableCall));
@@ -1669,7 +1671,9 @@ public class InCallController extends CallsManagerListenerBase implements
                        true /* includeVideoProvider */, mCallsManager.getPhoneAccountRegistrar(),
                        info.isExternalCallsSupported(), includeRttCall,
                        info.getType() == IN_CALL_SERVICE_TYPE_SYSTEM_UI
                                || info.getType() == IN_CALL_SERVICE_TYPE_NON_UI);
                                || info.getType() == IN_CALL_SERVICE_TYPE_NON_UI
                                || info.getType() == IN_CALL_SERVICE_TYPE_BLUETOOTH,
                        info.getType() == IN_CALL_SERVICE_TYPE_BLUETOOTH);
                try {
                    inCallService.addCall(sanitizeParcelableCallForService(info, parcelableCall));
                    updateCallTracking(call, info, true /* isAdd */);
@@ -1704,6 +1708,8 @@ public class InCallController extends CallsManagerListenerBase implements
                            false /* includeRttCall */,
                            info.getType() == IN_CALL_SERVICE_TYPE_SYSTEM_UI
                                    || info.getType() == IN_CALL_SERVICE_TYPE_NON_UI
                                    || info.getType() == IN_CALL_SERVICE_TYPE_BLUETOOTH,
                            info.getType() == IN_CALL_SERVICE_TYPE_BLUETOOTH
                    );

                    try {
@@ -2699,8 +2705,10 @@ public class InCallController extends CallsManagerListenerBase implements
                    mCallsManager.getPhoneAccountRegistrar(),
                    info.isExternalCallsSupported(),
                    includeRttCall,
                    info.getType() == IN_CALL_SERVICE_TYPE_SYSTEM_UI ||
                            info.getType() == IN_CALL_SERVICE_TYPE_NON_UI);
                    info.getType() == IN_CALL_SERVICE_TYPE_SYSTEM_UI
                            || info.getType() == IN_CALL_SERVICE_TYPE_NON_UI
                            || info.getType() == IN_CALL_SERVICE_TYPE_BLUETOOTH,
                    info.getType() == IN_CALL_SERVICE_TYPE_BLUETOOTH);
            if (mFeatureFlags.doNotSendCallToNullIcs()) {
                if (inCallService != null) {
                    inCallService.addCall(sanitizeParcelableCallForService(info, parcelableCall));
@@ -2802,8 +2810,10 @@ public class InCallController extends CallsManagerListenerBase implements
                        info.isExternalCallsSupported(),
                        rttInfoChanged && info.equals(
                                mInCallServiceConnections.get(userFromCall).getInfo()),
                        info.getType() == IN_CALL_SERVICE_TYPE_SYSTEM_UI ||
                        info.getType() == IN_CALL_SERVICE_TYPE_NON_UI);
                        info.getType() == IN_CALL_SERVICE_TYPE_SYSTEM_UI
                                || info.getType() == IN_CALL_SERVICE_TYPE_NON_UI
                                || info.getType() == IN_CALL_SERVICE_TYPE_BLUETOOTH,
                        info.getType() == IN_CALL_SERVICE_TYPE_BLUETOOTH);
                IInCallService inCallService = entry.getValue();
                boolean isDisconnectingBtIcs = info.getType() == IN_CALL_SERVICE_TYPE_BLUETOOTH
                        && call.getState() == CallState.DISCONNECTED;
+55 −7
Original line number Diff line number Diff line
@@ -80,6 +80,42 @@ public class ParcelableCallUtils {
        }
    }

    /**
     * Parcels all information for a {@link Call} into a new {@link ParcelableCall} instance.
     *
     * @param call The {@link Call} to parcel.
     * @param includeVideoProvider {@code true} if the video provider should be parcelled with the
     *      {@link Call}, {@code false} otherwise.  Since the {@link ParcelableCall#getVideoCall()}
     *      method creates a {@link VideoCallImpl} instance on access it is important for the
     *      recipient of the {@link ParcelableCall} to know if the video provider changed.
     * @param phoneAccountRegistrar The {@link PhoneAccountRegistrar}.
     * @param supportsExternalCalls Indicates whether the call should be parcelled for an
     *      {@link InCallService} which supports external calls or not.
     * @param includeRttCall {@code true} if the RTT call should be included, {@code false}
     *      otherwise.
     * @param isForSystemInCallService {@code true} if this call is being parcelled for the system incallservice,
     *      {@code false} otherwise.  When parceling for the system incallservice, the entire call extras
     *      is included.  When parceling for anything other than the system incallservice, some extra key
     *      values will be stripped for privacy sake.
     * @param isBluetoothInCallService {@code true} if this call is being parcelled for the BT ICS.
     *      {@code false} otherwise. When we receive an ANSWERING call state, we will translate it
     *      to {@link android.telecom.Call#STATE_ACTIVE}. If it's not the BT ICS, we will continue
     *      to translate it to {@link android.telecom.Call#STATE_RINGING} to preserve backwards
     *      compatibility.
     */
    public static ParcelableCall toParcelableCall(
            Call call,
            boolean includeVideoProvider,
            PhoneAccountRegistrar phoneAccountRegistrar,
            boolean supportsExternalCalls,
            boolean includeRttCall,
            boolean isForSystemInCallService,
            boolean isBluetoothInCallService) {
        return toParcelableCall(call, includeVideoProvider, phoneAccountRegistrar,
                supportsExternalCalls, CALL_STATE_OVERRIDE_NONE /* overrideState */,
                includeRttCall, isForSystemInCallService, isBluetoothInCallService);
    }

    /**
     * Parcels all information for a {@link Call} into a new {@link ParcelableCall} instance.
     *
@@ -107,7 +143,7 @@ public class ParcelableCallUtils {
            boolean isForSystemInCallService) {
        return toParcelableCall(call, includeVideoProvider, phoneAccountRegistrar,
                supportsExternalCalls, CALL_STATE_OVERRIDE_NONE /* overrideState */,
                includeRttCall, isForSystemInCallService);
                includeRttCall, isForSystemInCallService, false /* isBluetoothInCallService */);
    }

    /**
@@ -127,6 +163,12 @@ public class ParcelableCallUtils {
     *      {@code false} otherwise.  When parceling for the system incallservice, the entire call extras
     *      is included.  When parceling for anything other than the system incallservice, some extra key
     *      values will be stripped for privacy sake.
     * @param isBluetoothInCallService {@code true} if this call is being parcelled for the BT ICS.
     *      {@code false} otherwise. When we receive an ANSWERING call state, we will translate it
     *      to {@link android.telecom.Call#STATE_ACTIVE}. If it's not the BT ICS, we will continue
     *      to translate it to {@link android.telecom.Call#STATE_RINGING} to preserve backwards
     *      compatibility.
     *
     * @return The {@link ParcelableCall} containing all call information from the {@link Call}.
     */
    public static ParcelableCall toParcelableCall(
@@ -136,10 +178,11 @@ public class ParcelableCallUtils {
            boolean supportsExternalCalls,
            int overrideState,
            boolean includeRttCall,
            boolean isForSystemInCallService) {
            boolean isForSystemInCallService,
            boolean isBluetoothInCallService) {
        int state;
        if (overrideState == CALL_STATE_OVERRIDE_NONE) {
            state = getParcelableState(call, supportsExternalCalls);
            state = getParcelableState(call, supportsExternalCalls, isBluetoothInCallService);
        } else {
            state = overrideState;
        }
@@ -310,7 +353,8 @@ public class ParcelableCallUtils {

        return new ParcelableCall.ParcelableCallBuilder()
                .setId(call.getId())
                .setState(getParcelableState(call, false /* supportsExternalCalls */))
                .setState(getParcelableState(call, false /* supportsExternalCalls */,
                        false /* isBluetoothInCallService */))
                .setDisconnectCause(new DisconnectCause(DisconnectCause.UNKNOWN))
                .setCannedSmsResponses(null)
                .setCapabilities(0)
@@ -390,7 +434,8 @@ public class ParcelableCallUtils {
        return extras;
    }

    private static int getParcelableState(Call call, boolean supportsExternalCalls) {
    private static int getParcelableState(Call call, boolean supportsExternalCalls,
            boolean isBluetoothInCallService) {
        int state = CallState.NEW;
        switch (call.getParcelableCallState()) {
            case CallState.ABORTED:
@@ -429,8 +474,6 @@ public class ParcelableCallUtils {
                state = android.telecom.Call.STATE_HOLDING;
                break;
            case CallState.RINGING:
            case CallState.ANSWERED:
                // TODO: does in-call UI need to see ANSWERED?
                state = android.telecom.Call.STATE_RINGING;
                break;
            case CallState.SELECT_PHONE_ACCOUNT:
@@ -442,6 +485,11 @@ public class ParcelableCallUtils {
            case CallState.SIMULATED_RINGING:
                state = android.telecom.Call.STATE_SIMULATED_RINGING;
                break;
            case CallState.ANSWERED:
                state = isBluetoothInCallService
                        ? android.telecom.Call.STATE_ACTIVE
                        : android.telecom.Call.STATE_RINGING;
                break;
        }

        return state;
+28 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.telephony.ims.ImsCallProfile;
import androidx.test.filters.SmallTest;

import com.android.server.telecom.Call;
import com.android.server.telecom.CallState;
import com.android.server.telecom.CallerInfoLookupHelper;
import com.android.server.telecom.CallsManager;
import com.android.server.telecom.ClockProxy;
@@ -174,6 +175,33 @@ public class ParcelableCallUtilsTest extends TelecomTestCase {
        checkVerStatParcelingForDialer(Connection.VERIFICATION_STATUS_FAILED, true);
    }

    @SmallTest
    @Test
    public void testTreatCallStateAnsweredAsActive() {
        int prevCallState = mCall.getState();
        mCall.setState(CallState.ANSWERED, null);
        // Verify that if we're parceling the call for the BT ICS that we translate the call state
        // to ACTIVE.
        ParcelableCall call = ParcelableCallUtils.toParcelableCall(mCall,
                false /* includeVideoProvider */, null /* phoneAccountRegistrar */,
                false /* supportsExternalCalls */, -1 /* overrideState */,
                false /* includeRttCall */, false /* isForSystemInCallService */,
                true /* isBluetoothInCallService */);
        // Verify that setting call state to ANSWERED is processed as ACTIVE from telecom fwk
        assertEquals(call.getState(), android.telecom.Call.STATE_ACTIVE);
        // Now verify that if we're not parceling the call for the BT ICS that we continue to
        // translate the call state to RINGING.
        ParcelableCall call2 = ParcelableCallUtils.toParcelableCall(mCall,
                false /* includeVideoProvider */, null /* phoneAccountRegistrar */,
                false /* supportsExternalCalls */, -1 /* overrideState */,
                false /* includeRttCall */, false /* isForSystemInCallService */,
                false /* isBluetoothInCallService */);
        // Verify that setting call state to ANSWERED is processed as RINGING from telecom fwk
        assertEquals(call2.getState(), android.telecom.Call.STATE_RINGING);
        // Restore call state after test verification
        mCall.setState(prevCallState, null);
    }

    private void checkVerStatParcelingForCallScreening(int connectionVerificationStatus,
            boolean isForSystemDialer) {
        mCall.setCallerNumberVerificationStatus(connectionVerificationStatus);