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

Commit 6c5977d9 authored by Jin Jeong's avatar Jin Jeong Committed by Android (Google) Code Review
Browse files

Merge "Fix: Mismatch carrier Id" into main

parents 03ece839 e27f182c
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -1023,6 +1023,20 @@ public class CarrierResolver extends Handler {
     */
    public static int getCarrierIdFromIdentifier(@NonNull Context context,
            @NonNull CarrierIdentifier carrierIdentifier) {
        return getCarrierIdFromIdentifier(context, carrierIdentifier, false);
    }

    /**
     * a util function to convert carrierIdentifier to the best matching carrier id.
     *
     * @param useParentCid {@code true} to indicate that the parent carrier ID is required to be
     *                     returned if it has valid value.
     *
     * @return the best matching carrier id.
     */

    public static int getCarrierIdFromIdentifier(@NonNull Context context,
            @NonNull CarrierIdentifier carrierIdentifier, boolean useParentCid) {
        final String mccmnc = carrierIdentifier.getMcc() + carrierIdentifier.getMnc();
        final String gid1 = carrierIdentifier.getGid1();
        final String gid2 = carrierIdentifier.getGid2();
@@ -1051,9 +1065,13 @@ public class CarrierResolver extends Handler {
            rule.match(targetRule);
            if (rule.mScore > maxScore) {
                maxScore = rule.mScore;
                if (useParentCid && rule.mParentCid != TelephonyManager.UNKNOWN_CARRIER_ID) {
                    carrierId = rule.mParentCid;
                } else {
                    carrierId = rule.mCid;
                }
            }
        }
        return carrierId;
    }