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

Commit 32f1b0b7 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Use the two digital number pattern from carrier config instead." into...

Merge "Use the two digital number pattern from carrier config instead." into rvc-dev am: 1591e841 am: 4646513f am: db0a7c27

Change-Id: I9dd7032b0bc62ed46fef76b485e95c44bee854aa
parents 6eb68e40 db0a7c27
Loading
Loading
Loading
Loading
+27 −5
Original line number Diff line number Diff line
@@ -271,7 +271,7 @@ public final class GsmMmiCode extends Handler implements MmiCode {

            ret = new GsmMmiCode(phone, app);
            ret.mPoundString = dialString;
        } else if (isTwoDigitShortCode(phone.getContext(), dialString)) {
        } else if (isTwoDigitShortCode(phone.getContext(), phone.getSubId(), dialString)) {
            //Is a country-specific exception to short codes as defined in TS 22.030, 6.5.3.2
            ret = null;
        } else if (isShortCode(dialString, phone)) {
@@ -703,15 +703,16 @@ public final class GsmMmiCode extends Handler implements MmiCode {
        return mPoundString;
    }

    static private boolean
    isTwoDigitShortCode(Context context, String dialString) {
    /**
     * Check if the dial string match the two digital number pattern which defined by Carrier.
     */
    public static boolean isTwoDigitShortCode(Context context, int subId, String dialString) {
        Rlog.d(LOG_TAG, "isTwoDigitShortCode");

        if (dialString == null || dialString.length() > 2) return false;

        if (sTwoDigitNumberPattern == null) {
            sTwoDigitNumberPattern = context.getResources().getStringArray(
                    com.android.internal.R.array.config_twoDigitNumberPattern);
            sTwoDigitNumberPattern = getTwoDigitNumberPattern(context, subId);
        }

        for (String dialnumber : sTwoDigitNumberPattern) {
@@ -725,6 +726,27 @@ public final class GsmMmiCode extends Handler implements MmiCode {
        return false;
    }

    private static String[] getTwoDigitNumberPattern(Context context, int subId) {
        Rlog.d(LOG_TAG, "Get two digit number pattern: subId=" + subId);
        String[] twoDigitNumberPattern = null;
        CarrierConfigManager configManager = (CarrierConfigManager)
                context.getSystemService(Context.CARRIER_CONFIG_SERVICE);
        if (configManager != null) {
            PersistableBundle bundle = configManager.getConfigForSubId(subId);
            if (bundle != null) {
                Rlog.d(LOG_TAG, "Two Digit Number Pattern from carrir config");
                twoDigitNumberPattern = bundle.getStringArray(CarrierConfigManager
                        .KEY_MMI_TWO_DIGIT_NUMBER_PATTERN_STRING_ARRAY);
            }
        }

        // Do NOT return null array
        if (twoDigitNumberPattern == null) {
            twoDigitNumberPattern = new String[0];
        }
        return twoDigitNumberPattern;
    }

    /**
     * Helper function for newFromDialString. Returns true if dialString appears
     * to be a short code AND conditions are correct for it to be treated as
+3 −23
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import com.android.internal.telephony.CommandException;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.MmiCode;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.gsm.GsmMmiCode;
import com.android.internal.telephony.uicc.IccRecords;
import com.android.telephony.Rlog;

@@ -294,7 +295,8 @@ public final class ImsPhoneMmiCode extends Handler implements MmiCode {

            ret = new ImsPhoneMmiCode(phone);
            ret.mPoundString = dialString;
        } else if (isTwoDigitShortCode(phone.getContext(), dialString)) {
        } else if (GsmMmiCode.isTwoDigitShortCode(phone.getContext(), phone.getSubId(),
                dialString)) {
            //Is a country-specific exception to short codes as defined in TS 22.030, 6.5.3.2
            ret = null;
        } else if (isShortCode(dialString, phone)) {
@@ -584,28 +586,6 @@ public final class ImsPhoneMmiCode extends Handler implements MmiCode {
        return mPoundString;
    }

    static private boolean
    isTwoDigitShortCode(Context context, String dialString) {
        Rlog.d(LOG_TAG, "isTwoDigitShortCode");

        if (dialString == null || dialString.length() > 2) return false;

        if (sTwoDigitNumberPattern == null) {
            sTwoDigitNumberPattern = context.getResources().getStringArray(
                    com.android.internal.R.array.config_twoDigitNumberPattern);
        }

        for (String dialnumber : sTwoDigitNumberPattern) {
            Rlog.d(LOG_TAG, "Two Digit Number Pattern " + dialnumber);
            if (dialString.equals(dialnumber)) {
                Rlog.d(LOG_TAG, "Two Digit Number Pattern -true");
                return true;
            }
        }
        Rlog.d(LOG_TAG, "Two Digit Number Pattern -false");
        return false;
    }

    /**
     * Helper function for newFromDialString. Returns true if dialString appears
     * to be a short code AND conditions are correct for it to be treated as