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

Commit 45ba491a authored by Arun Voddu's avatar Arun Voddu Committed by Android (Google) Code Review
Browse files

Merge "[CarrierLock] Provided fallback support for Old API to read the carrier...

Merge "[CarrierLock] Provided fallback support for Old API to read the carrier lock info." into main
parents 1f9665be 3b06412f
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -4131,6 +4131,34 @@ public class RILUtils {
        return carrierInfoList;
    }

    /**
     * This API is for fallback to support getAllowedCarriers too.
     *
     * Convert an array of CarrierInfo defined in
     * radio/aidl/android/hardware/radio/sim/CarrierInfo.aidl to a list of CarrierIdentifiers.
     *
     * @param carrierInfos array of CarrierInfo defined in
     *                     radio/aidl/android/hardware/radio/sim/CarrierInfo.aidl
     * @return The converted list of CarrierIdentifiers
     */
    public static List<CarrierIdentifier> convertAidlCarrierInfoListToHalCarrierList(
            android.hardware.radio.sim.CarrierInfo[] carrierInfos) {
        List<CarrierIdentifier> ret = new ArrayList<>();
        if (carrierInfos == null) {
            return ret;
        }
        for (android.hardware.radio.sim.CarrierInfo carrierInfo : carrierInfos) {
            String mcc = carrierInfo.mcc;
            String mnc = carrierInfo.mnc;
            String spn = carrierInfo.spn;
            String imsi = carrierInfo.imsiPrefix;
            String gid1 = carrierInfo.gid1;
            String gid2 = carrierInfo.gid2;
            ret.add(new CarrierIdentifier(mcc, mnc, spn, imsi, gid1, gid2));
        }
        return ret;
    }

    /**
     * Convert the sim policy defined in
     * radio/aidl/android/hardware/radio/sim/SimLockMultiSimPolicy.aidl to the equivalent sim
+28 −13
Original line number Diff line number Diff line
@@ -123,19 +123,34 @@ public class SimResponse extends IRadioSimResponse.Stub {
        if (!carrierRestrictions.allowedCarriersPrioritized) {
            carrierRestrictionDefault = CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_ALLOWED;
        }

        CarrierRestrictionRules ret = CarrierRestrictionRules.newBuilder().setAllowedCarriers(
                RILUtils.convertHalCarrierList(
                        carrierRestrictions.allowedCarriers)).setExcludedCarriers(
                RILUtils.convertHalCarrierList(
                        carrierRestrictions.excludedCarriers)).setDefaultCarrierRestriction(
                carrierRestrictionDefault).setMultiSimPolicy(policy).setCarrierRestrictionStatus(
        CarrierRestrictionRules ret = null;
        if (carrierLockInfoSupported) {
            // In order to support the old API { @link TelephonyManager#getAllowedCarriers() } we
            // are parsing the allowedCarrierInfoList to CarrierIdentifier List also along with
            // CarrierInfo List
            ret = CarrierRestrictionRules.newBuilder().setAllowedCarriers(
                    RILUtils.convertAidlCarrierInfoListToHalCarrierList(
                            carrierRestrictions.allowedCarrierInfoList)).setExcludedCarriers(
                    RILUtils.convertAidlCarrierInfoListToHalCarrierList(
                            carrierRestrictions.excludedCarrierInfoList)).
                    setDefaultCarrierRestriction(
                    carrierRestrictionDefault).setMultiSimPolicy(
                    policy).setCarrierRestrictionStatus(
                    carrierRestrictions.status).setAllowedCarrierInfo(
                    RILUtils.convertAidlCarrierInfoList(
                            carrierRestrictions.allowedCarrierInfoList)).setExcludedCarrierInfo(
                    RILUtils.convertAidlCarrierInfoList(
                            carrierRestrictions.excludedCarrierInfoList)).setCarrierLockInfoFeature(
                carrierLockInfoSupported).build();
                            true).build();
        } else {
            ret = CarrierRestrictionRules.newBuilder().setAllowedCarriers(
                    RILUtils.convertHalCarrierList(
                            carrierRestrictions.allowedCarriers)).setExcludedCarriers(
                    RILUtils.convertHalCarrierList(
                            carrierRestrictions.excludedCarriers)).setDefaultCarrierRestriction(
                    carrierRestrictionDefault).setMultiSimPolicy(
                    policy).build();
        }
        if (responseInfo.error == RadioError.NONE) {
            RadioResponse.sendMessageResponse(rr.mResult, ret);
        }