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

Commit 329c218f authored by Tyler Gunn's avatar Tyler Gunn Committed by Gerrit Code Review
Browse files

Merge "Add support for remapping ImsReasonInfo codes with no message."

parents 02ff35f8 874f5bc6
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -1170,6 +1170,9 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
                        fromCode = Integer.parseInt(values[0]);
                    }
                    String message = values[1];
                    if (message == null) {
                        message = "";
                    }
                    int toCode = Integer.parseInt(values[2]);

                    addReasonCodeRemapping(fromCode, message, toCode);
@@ -2023,22 +2026,29 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
    @VisibleForTesting
    public int maybeRemapReasonCode(ImsReasonInfo reasonInfo) {
        int code = reasonInfo.getCode();

        Pair<Integer, String> toCheck = new Pair<>(code, reasonInfo.getExtraMessage());
        Pair<Integer, String> wildcardToCheck = new Pair<>(null, reasonInfo.getExtraMessage());
        String reason = reasonInfo.getExtraMessage();
        if (reason == null) {
            reason = "";
        }
        log("maybeRemapReasonCode : fromCode = " + reasonInfo.getCode() + " ; message = "
                + reason);
        Pair<Integer, String> toCheck = new Pair<>(code, reason);
        Pair<Integer, String> wildcardToCheck = new Pair<>(null, reason);
        if (mImsReasonCodeMap.containsKey(toCheck)) {
            int toCode = mImsReasonCodeMap.get(toCheck);

            log("maybeRemapReasonCode : fromCode = " + reasonInfo.getCode() + " ; message = "
                    + reasonInfo.getExtraMessage() + " ; toCode = " + toCode);
                    + reason + " ; toCode = " + toCode);
            return toCode;
        } else if (mImsReasonCodeMap.containsKey(wildcardToCheck)) {
        } else if (!reason.isEmpty() && mImsReasonCodeMap.containsKey(wildcardToCheck)) {
            // Handle the case where a wildcard is specified for the fromCode; in this case we will
            // match without caring about the fromCode.
            // If the reason is empty, we won't do wildcard remapping; otherwise we'd basically be
            // able to remap all ImsReasonInfo codes to a single code, which is not desirable.
            int toCode = mImsReasonCodeMap.get(wildcardToCheck);

            log("maybeRemapReasonCode : fromCode(wildcard) = " + reasonInfo.getCode() +
                    " ; message = " + reasonInfo.getExtraMessage() + " ; toCode = " + toCode);
                    " ; message = " + reason + " ; toCode = " + toCode);
            return toCode;
        }
        return code;
+11 −0
Original line number Diff line number Diff line
@@ -115,6 +115,8 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
                    ImsReasonInfo.CODE_ANSWERED_ELSEWHERE);
            mCTUT.addReasonCodeRemapping(510, "Call answered elsewhere.",
                    ImsReasonInfo.CODE_ANSWERED_ELSEWHERE);
            mCTUT.addReasonCodeRemapping(ImsReasonInfo.CODE_USER_TERMINATED_BY_REMOTE, "",
                    ImsReasonInfo.CODE_SIP_FORBIDDEN);
            mCTUT.setDataEnabled(true);
            mCTHander = new Handler(mCTUT.getLooper());
            setReady(true);
@@ -902,6 +904,15 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
        Assert.fail("Expected CallStateException");
    }

    @Test
    @SmallTest
    public void testNumericOnlyRemap() {
        assertEquals(ImsReasonInfo.CODE_SIP_FORBIDDEN, mCTUT.maybeRemapReasonCode(
                new ImsReasonInfo(ImsReasonInfo.CODE_USER_TERMINATED_BY_REMOTE, 0)));
        assertEquals(ImsReasonInfo.CODE_SIP_FORBIDDEN, mCTUT.maybeRemapReasonCode(
                new ImsReasonInfo(ImsReasonInfo.CODE_USER_TERMINATED_BY_REMOTE, 0, "")));
    }

    private void placeCallAndMakeActive() {
        try {
            doAnswer(new Answer<ImsCall>() {