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

Commit 85a5b246 authored by donaldahn's avatar donaldahn Committed by Automerger Merge Worker
Browse files

Add support for message in KEY_IMS_REASONINFO_MAPPING_STRING_ARRAY am: 15cc4653 am: f69b4372

parents eab929ba f69b4372
Loading
Loading
Loading
Loading
+57 −5
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import static com.android.internal.telephony.Phone.CS_FALLBACK;

import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.usage.NetworkStatsManager;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.BroadcastReceiver;
@@ -929,8 +930,10 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
     * {@code ImsReasonInfo#CODE_*} value.
     *
     * See {@link CarrierConfigManager#KEY_IMS_REASONINFO_MAPPING_STRING_ARRAY}.
     * This ImsReasonInfoKeyPair with this key stating will consider getExtraMessage a match
     * if the carrier config messages starts with getExtraMessage result.
     */
    private Map<Pair<Integer, String>, Integer> mImsReasonCodeMap = new ArrayMap<>();
    private Map<ImsReasonInfoKeyPair, Integer> mImsReasonCodeMap = new ArrayMap<>();


    /**
@@ -988,6 +991,54 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
    // Used for important operational related events for logging.
    private final LocalLog mOperationLocalLog = new LocalLog(64);

    /**
     * Container to ease passing around a tuple of two objects. This object provides a sensible
     * implementation of equals(), returning true/false using equals() for one object (Integer)
     * and startsWith() for another object (String). Also the startsWith() in this equals() method
     * will return true for A.startsWith(B) if B.second starts with A.second.
     */
    private static class ImsReasonInfoKeyPair extends Pair<Integer, String> {

        /**
         * Constructor for a ImsReasonInfoKeyPair.
         *
         * @param first Integer in the ImsReasonInfoKeyPair
         * @param second String in the ImsReasonInfoKeyPair
         */
        private ImsReasonInfoKeyPair(Integer first, String second) {
            super(first, second);
        }

        /**
         * Checks the two objects for equality by delegating to their respective
         * {@link Object#equals(Object)} methods.
         *
         * @param o the {@link com.android.internal.telephony.imsphone.ImsReasonInfoKeyPair} to
         *         which this one is to be checked for equality
         * @return true if the underlying objects of the ImsReasonInfoKeyPair are
         * considered equal and startsWith
         */
        @Override
        public boolean equals(@Nullable Object o) {
            if (!(o instanceof ImsReasonInfoKeyPair)) {
                return false;
            }
            ImsReasonInfoKeyPair p = (ImsReasonInfoKeyPair) o;

            return Objects.equals(p.first, first)
                    && Objects.toString(second).startsWith(Objects.toString(p.second));
        }

        /**
         * Compute a hash code using the hash code of the Integer key
         *
         * @return a hashcode of the first
         */
        @Override
        public int hashCode() {
            return (first == null ? 0 : first.hashCode());
        }
    }
    //***** Events


@@ -2805,7 +2856,7 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        if (message != null) {
            message = message.toLowerCase(Locale.ROOT);
        }
        mImsReasonCodeMap.put(new Pair<>(fromCode, message), toCode);
        mImsReasonCodeMap.put(new ImsReasonInfoKeyPair(fromCode, message), toCode);
    }

    /**
@@ -2828,9 +2879,10 @@ public class ImsPhoneCallTracker extends CallTracker implements ImsPullCall {
        }
        log("maybeRemapReasonCode : fromCode = " + reasonInfo.getCode() + " ; message = "
                + reason);
        Pair<Integer, String> toCheck = new Pair<>(code, reason);
        Pair<Integer, String> wildcardToCheck = new Pair<>(null, reason);
        Pair<Integer, String> wildcardMessageToCheck = new Pair<>(code, null);
        ImsReasonInfoKeyPair toCheck = new ImsReasonInfoKeyPair(code, reason);
        ImsReasonInfoKeyPair wildcardToCheck = new ImsReasonInfoKeyPair(null, reason);
        ImsReasonInfoKeyPair wildcardMessageToCheck = new ImsReasonInfoKeyPair(code, null);

        if (mImsReasonCodeMap.containsKey(toCheck)) {
            int toCode = mImsReasonCodeMap.get(toCheck);

+5 −0
Original line number Diff line number Diff line
@@ -1006,7 +1006,9 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
        PersistableBundle bundle = new PersistableBundle();
        String[] mappings = new String[]{
                "1014|call completed elsewhere|1014",
                "1014|Call Rejected By User|510",
                "1014|*|510",
                "510|Call completed elsewhere|1014",
                };
        bundle.putStringArray(CarrierConfigManager.KEY_IMS_REASONINFO_MAPPING_STRING_ARRAY,
                mappings);
@@ -1024,6 +1026,9 @@ public class ImsPhoneCallTrackerTest extends TelephonyTest {
                new ImsReasonInfo(1014, 200, "Call Rejected By User"))); // 1014 -> 510
        assertEquals(ImsReasonInfo.CODE_ANSWERED_ELSEWHERE, mCTUT.maybeRemapReasonCode(
                new ImsReasonInfo(1014, 200, "Call completed elsewhere"))); // 1014 -> 1014
        assertEquals(ImsReasonInfo.CODE_ANSWERED_ELSEWHERE, mCTUT.maybeRemapReasonCode(
                new ImsReasonInfo(510, 200,
                        "Call completed elsewhere by instance urn:gsma:imei:xxx"))); // 510 -> 1014

        // Simulate that after SIM swap the new carrier config doesn't have the mapping for 1014
        loadReasonCodeRemapCarrierConfig();