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

Commit 3590fa4d authored by Michele's avatar Michele
Browse files

Add check for slot index value

Verify that slot index passed in setAllowedCarrier() and in
getAllowedCarrier() has a valid value or return error code.

Bug: 123097251
Test: compilation
Change-Id: I322ecd11c49301a7d5bf5edb75d32a72a9f813c3
parent b3f282da
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -8919,6 +8919,9 @@ public class TelephonyManager {
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    public int setAllowedCarriers(int slotIndex, List<CarrierIdentifier> carriers) {
        if (carriers == null || !SubscriptionManager.isValidPhoneId(slotIndex)) {
            return -1;
        }
        // Execute the method setCarrierRestrictionRules with an empty excluded list and
        // indicating priority for the allowed list.
        CarrierRestrictionRules carrierRestrictionRules = CarrierRestrictionRules.newBuilder()
@@ -8929,7 +8932,7 @@ public class TelephonyManager {

        int result = setCarrierRestrictionRules(carrierRestrictionRules);

        // Convert boolean result into int, as required by this method.
        // Convert result into int, as required by this method.
        if (result == SET_CARRIER_RESTRICTION_SUCCESS) {
            return carriers.size();
        } else {
@@ -9022,10 +9025,12 @@ public class TelephonyManager {
    @SystemApi
    @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
    public List<CarrierIdentifier> getAllowedCarriers(int slotIndex) {
        if (SubscriptionManager.isValidPhoneId(slotIndex)) {
            CarrierRestrictionRules carrierRestrictionRule = getCarrierRestrictionRules();
            if (carrierRestrictionRule != null) {
                return carrierRestrictionRule.getAllowedCarriers();
            }
        }
        return new ArrayList<CarrierIdentifier>(0);
    }