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

Commit 6a51c683 authored by Tyler Gunn's avatar Tyler Gunn Committed by Android (Google) Code Review
Browse files

Merge "Add support for ignoring CEP on conference peer." into rvc-dev

parents 9efd060b eeab8e27
Loading
Loading
Loading
Loading
+30 −12
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import com.android.internal.telephony.gsm.SuppServiceNotification;
import com.android.internal.telephony.imsphone.ImsExternalCallTracker;
import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhoneCall;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
import com.android.internal.telephony.test.TestConferenceEventPackageParser;
import com.android.internal.telephony.util.TelephonyUtils;
import com.android.telephony.Rlog;
@@ -76,6 +77,15 @@ public class TelephonyTester {
            "com.android.internal.telephony.TestDialogEventPackage";

    private static final String EXTRA_FILENAME = "filename";
    /**
     * Used to inject the conference event package by bypassing the ImsCall and doing the
     * injection via ImsPhoneCallTracker.  This is useful in scenarios where the
     * adb shell cmd phone ims conference-event-package disable
     * command is used to disable network CEP data and it is desired to still inject CEP data.
     * Where the network CEP data is not explicitly disabled using the command above, it is not
     * necessary to bypass the ImsCall.
     */
    private static final String EXTRA_BYPASS_IMSCALL = "bypassImsCall";
    private static final String EXTRA_STARTPACKAGE = "startPackage";
    private static final String EXTRA_SENDPACKAGE = "sendPackage";
    private static final String EXTRA_DIALOGID = "dialogId";
@@ -162,7 +172,8 @@ public class TelephonyTester {
                } else if (action.equals(ACTION_TEST_CONFERENCE_EVENT_PACKAGE)) {
                    log("inject simulated conference event package");
                    handleTestConferenceEventPackage(context,
                            intent.getStringExtra(EXTRA_FILENAME));
                            intent.getStringExtra(EXTRA_FILENAME),
                            intent.getBooleanExtra(EXTRA_BYPASS_IMSCALL, false));
                } else if (action.equals(ACTION_TEST_DIALOG_EVENT_PACKAGE)) {
                    log("handle test dialog event package intent");
                    handleTestDialogEventPackageIntent(intent);
@@ -277,22 +288,15 @@ public class TelephonyTester {
     * @param context The context.
     * @param fileName The name of the test conference event package file to read.
     */
    private void handleTestConferenceEventPackage(Context context, String fileName) {
    private void handleTestConferenceEventPackage(Context context, String fileName,
            boolean isBypassingImsCall) {
        // Attempt to get the active IMS call before parsing the test XML file.
        ImsPhone imsPhone = (ImsPhone) mPhone;
        if (imsPhone == null) {
            return;
        }

        ImsPhoneCall imsPhoneCall = imsPhone.getForegroundCall();
        if (imsPhoneCall == null) {
            return;
        }

        ImsCall imsCall = imsPhoneCall.getImsCall();
        if (imsCall == null) {
            return;
        }
        ImsPhoneCallTracker tracker = (ImsPhoneCallTracker) imsPhone.getCallTracker();

        File packageFile = new File(context.getFilesDir(), fileName);
        final FileInputStream is;
@@ -309,8 +313,22 @@ public class TelephonyTester {
            return;
        }

        if (isBypassingImsCall) {
            tracker.injectTestConferenceState(imsConferenceState);
        } else {
            ImsPhoneCall imsPhoneCall = imsPhone.getForegroundCall();
            if (imsPhoneCall == null) {
                return;
            }

            ImsCall imsCall = imsPhoneCall.getImsCall();
            if (imsCall == null) {
                return;
            }

            imsCall.conferenceStateUpdated(imsConferenceState);
        }
    }

    /**
     * Handles intents containing test dialog event package data.
+26 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.emergency.EmergencyNumber;
import android.telephony.ims.ImsCallProfile;
import android.telephony.ims.ImsConferenceState;
import android.telephony.ims.ImsMmTelManager;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.ImsStreamMediaProfile;
@@ -506,6 +507,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
    private boolean mIsViLteDataMetered = false;
    private boolean mAlwaysPlayRemoteHoldTone = false;
    private boolean mAutoRetryFailedWifiEmergencyCall = false;
    private boolean mSupportCepOnPeer = true;
    // Tracks the state of our background/foreground calls while a call hold/swap operation is
    // in progress. Values listed above.
    private HoldSwapState mHoldSwitchingState = HoldSwapState.INACTIVE;
@@ -1391,6 +1393,8 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                CarrierConfigManager.KEY_ALWAYS_PLAY_REMOTE_HOLD_TONE_BOOL);
        mAutoRetryFailedWifiEmergencyCall = carrierConfig.getBoolean(
                CarrierConfigManager.KEY_AUTO_RETRY_FAILED_WIFI_EMERGENCY_CALL);
        mSupportCepOnPeer = carrierConfig.getBoolean(
                CarrierConfigManager.KEY_SUPPORT_IMS_CONFERENCE_EVENT_PACKAGE_ON_PEER_BOOL);

        String[] mappings = carrierConfig
                .getStringArray(CarrierConfigManager.KEY_IMS_REASONINFO_MAPPING_STRING_ARRAY);
@@ -3325,6 +3329,11 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                return;
            }

            if (!mSupportCepOnPeer && !call.isConferenceHost()) {
                logi("onConferenceParticipantsStateChanged - ignore CEP on peer");
                return;
            }

            ImsPhoneConnection conn = findConnection(call);
            if (conn != null) {
                updateConferenceParticipantsTiming(participants);
@@ -4142,6 +4151,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        pw.println(" mCallQualityMetrics=" + mCallQualityMetrics);
        pw.println(" mCallQualityMetricsHistory=" + mCallQualityMetricsHistory);
        pw.println(" mIsConferenceEventPackageHandlingEnabled=" + mIsConferenceEventPackageEnabled);
        pw.println(" mSupportCepOnPeer=" + mSupportCepOnPeer);
        pw.println(" Event Log:");
        pw.increaseIndent();
        mOperationLocalLog.dump(pw);
@@ -4826,6 +4836,22 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        return mPhone;
    }

    @VisibleForTesting
    public void setSupportCepOnPeer(boolean isSupported) {
        mSupportCepOnPeer = isSupported;
    }

    /**
     * Injects a test conference state into an ongoing IMS call.
     * @param state The injected state.
     */
    public void injectTestConferenceState(@NonNull ImsConferenceState state) {
        List<ConferenceParticipant> participants = ImsCall.parseConferenceState(state);
        for (ImsPhoneConnection connection : getConnections()) {
            connection.updateConferenceParticipants(participants);
        }
    }

    /**
     * Sets whether CEP handling is enabled or disabled.
     * @param isEnabled
+43 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@ import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.telephony.ims.ImsCallProfile;
import android.telephony.ims.ImsCallSession;
import android.telephony.ims.ImsConferenceState;
import android.telephony.ims.ImsMmTelManager;
import android.telephony.ims.ImsReasonInfo;
import android.telephony.ims.ImsStreamMediaProfile;
@@ -370,6 +371,48 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
        assertEquals(1, mCTUT.mForegroundCall.getConnections().size());
    }

    @Test
    @SmallTest
    public void testImsCepOnPeer() throws Exception {
        testImsMTCallAccept();
        doReturn(false).when(mImsCall).isConferenceHost();
        doReturn(true).when(mImsCall).isMultiparty();

        injectConferenceState();

        verify(mImsPhoneConnectionListener).onConferenceParticipantsChanged(any());
    }

    @Test
    @SmallTest
    public void testImsNoCepOnPeer() throws Exception {
        mCTUT.setSupportCepOnPeer(false);

        testImsMTCallAccept();
        doReturn(false).when(mImsCall).isConferenceHost();
        doReturn(true).when(mImsCall).isMultiparty();

        injectConferenceState();

        verify(mImsPhoneConnectionListener, never()).onConferenceParticipantsChanged(any());
    }

    private void injectConferenceState() {
        ImsPhoneConnection connection = mCTUT.getConnections().get(0);
        connection.addListener(mImsPhoneConnectionListener);

        ImsConferenceState state = new ImsConferenceState();
        // Yuck
        Bundle participant = new Bundle();
        participant.putString(ImsConferenceState.USER, "sip:6505551212@fakeims.com");
        participant.putString(ImsConferenceState.DISPLAY_TEXT, "yuck");
        participant.putString(ImsConferenceState.ENDPOINT, "sip:6505551212@fakeims.com");
        participant.putString(ImsConferenceState.STATUS, "connected");
        state.mParticipants.put("sip:6505551212@fakeims.com", participant);

        mImsCall.conferenceStateUpdated(state);
    }

    @Test
    @SmallTest
    public void testImsHoldException() throws Exception {