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

Commit 0a1bccfc authored by Jack Yu's avatar Jack Yu
Browse files

Fixed potential string conversion issues

Replaced all toLowerCase() with toLowerCase(Locale.ROOT).
Replaced all toUpperCase() with toUpperCase(Locale.ROOT).

Fix: 250048156
Test: atest FrameworksTelephonyTests + Basic testing
Change-Id: Ib932631b8b2fc2b18d24a0295496c2a581295265
parent 44d1af82
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -1107,7 +1107,8 @@ public final class SmsApplication {
    }
    }


    /**
    /**
     * Returns whether need to write the SMS message to SMS database for this package.
     * Returns whether need to wrgetIncomingUserIdite the SMS message to SMS database for this
     * package.
     * <p>
     * <p>
     * Caller must pass in the correct user context if calling from a singleton service.
     * Caller must pass in the correct user context if calling from a singleton service.
     */
     */
+3 −2
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.List;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Objects;


/**
/**
@@ -276,8 +277,8 @@ public final class CarrierRestrictionRules implements Parcelable {
        if (str.length() != pattern.length()) {
        if (str.length() != pattern.length()) {
            return false;
            return false;
        }
        }
        String lowerCaseStr = str.toLowerCase();
        String lowerCaseStr = str.toLowerCase(Locale.ROOT);
        String lowerCasePattern = pattern.toLowerCase();
        String lowerCasePattern = pattern.toLowerCase(Locale.ROOT);


        for (int i = 0; i < lowerCasePattern.length(); i++) {
        for (int i = 0; i < lowerCasePattern.length(); i++) {
            if (lowerCasePattern.charAt(i) != lowerCaseStr.charAt(i)
            if (lowerCasePattern.charAt(i) != lowerCaseStr.charAt(i)
+1 −2
Original line number Original line Diff line number Diff line
@@ -27,7 +27,6 @@ import android.content.Intent;
import android.content.res.Resources;
import android.content.res.Resources;
import android.database.Cursor;
import android.database.Cursor;
import android.net.Uri;
import android.net.Uri;
import android.os.Build;
import android.os.PersistableBundle;
import android.os.PersistableBundle;
import android.provider.Contacts;
import android.provider.Contacts;
import android.provider.ContactsContract;
import android.provider.ContactsContract;
@@ -2901,7 +2900,7 @@ public class PhoneNumberUtils {
        PhoneNumberUtil util = PhoneNumberUtil.getInstance();
        PhoneNumberUtil util = PhoneNumberUtil.getInstance();
        PhoneNumber n1;
        PhoneNumber n1;
        PhoneNumber n2;
        PhoneNumber n2;
        defaultCountryIso = defaultCountryIso.toUpperCase();
        defaultCountryIso = defaultCountryIso.toUpperCase(Locale.ROOT);
        try {
        try {
            n1 = util.parseAndKeepRawInput(number1, defaultCountryIso);
            n1 = util.parseAndKeepRawInput(number1, defaultCountryIso);
            n2 = util.parseAndKeepRawInput(number2, defaultCountryIso);
            n2 = util.parseAndKeepRawInput(number2, defaultCountryIso);
+3 −1
Original line number Original line Diff line number Diff line
@@ -24,6 +24,8 @@ import android.telephony.TelephonyManager.PrefNetworkMode;


import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.RILConstants;


import java.util.Locale;



/**
/**
 * Object to indicate the phone radio type and access technology.
 * Object to indicate the phone radio type and access technology.
@@ -367,7 +369,7 @@ public class RadioAccessFamily implements Parcelable {
    }
    }


    public static int rafTypeFromString(String rafList) {
    public static int rafTypeFromString(String rafList) {
        rafList = rafList.toUpperCase();
        rafList = rafList.toUpperCase(Locale.ROOT);
        String[] rafs = rafList.split("\\|");
        String[] rafs = rafList.split("\\|");
        int result = 0;
        int result = 0;
        for(String raf : rafs) {
        for(String raf : rafs) {
+5 −3
Original line number Original line Diff line number Diff line
@@ -43,6 +43,7 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.List;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map;
import java.util.Objects;
import java.util.Objects;


@@ -1442,7 +1443,7 @@ public class ApnSetting implements Parcelable {
     */
     */
    @SystemApi
    @SystemApi
    public static @ApnType int getApnTypeInt(@NonNull @ApnTypeString String apnType) {
    public static @ApnType int getApnTypeInt(@NonNull @ApnTypeString String apnType) {
        return APN_TYPE_STRING_MAP.getOrDefault(apnType.toLowerCase(), 0);
        return APN_TYPE_STRING_MAP.getOrDefault(apnType.toLowerCase(Locale.ROOT), 0);
    }
    }


    /**
    /**
@@ -1457,7 +1458,7 @@ public class ApnSetting implements Parcelable {
        } else {
        } else {
            int result = 0;
            int result = 0;
            for (String str : types.split(",")) {
            for (String str : types.split(",")) {
                Integer type = APN_TYPE_STRING_MAP.get(str.toLowerCase());
                Integer type = APN_TYPE_STRING_MAP.get(str.toLowerCase(Locale.ROOT));
                if (type != null) {
                if (type != null) {
                    result |= type;
                    result |= type;
                }
                }
@@ -1468,7 +1469,8 @@ public class ApnSetting implements Parcelable {


    /** @hide */
    /** @hide */
    public static int getMvnoTypeIntFromString(String mvnoType) {
    public static int getMvnoTypeIntFromString(String mvnoType) {
        String mvnoTypeString = TextUtils.isEmpty(mvnoType) ? mvnoType : mvnoType.toLowerCase();
        String mvnoTypeString = TextUtils.isEmpty(mvnoType)
                ? mvnoType : mvnoType.toLowerCase(Locale.ROOT);
        Integer mvnoTypeInt = MVNO_TYPE_STRING_MAP.get(mvnoTypeString);
        Integer mvnoTypeInt = MVNO_TYPE_STRING_MAP.get(mvnoTypeString);
        return  mvnoTypeInt == null ? UNSPECIFIED_INT : mvnoTypeInt;
        return  mvnoTypeInt == null ? UNSPECIFIED_INT : mvnoTypeInt;
    }
    }
Loading