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

Commit 874f5bc6 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Add support for remapping ImsReasonInfo codes with no message.

There was an assumption that the KEY_IMS_REASONINFO_MAPPING_STRING_ARRAY
reason codes would always remap a pair of code and message to a new
ImsReasonInfo code.

This change relaxes that restriction to support straight remapping of
ImsReasonInfo codes for a carrier where the message is empty/null.

Test: Added unit test to cover new functionality.
Bug: 110068190
Change-Id: I07e4ce8b9f4c64a18e76737b313f270cd8c7531e
parent ac0125d1
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);
@@ -2027,22 +2030,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>() {