Merge "Handle setAllowedCarriers() with empty list of carriers"

This commit is contained in:
Treehugger Robot
2022-02-11 18:20:43 +00:00
committed by Gerrit Code Review

View File

@@ -12111,12 +12111,15 @@ public class TelephonyManager {
if (carriers == null || !SubscriptionManager.isValidPhoneId(slotIndex)) { if (carriers == null || !SubscriptionManager.isValidPhoneId(slotIndex)) {
return -1; return -1;
} }
// Execute the method setCarrierRestrictionRules with an empty excluded list and // Execute the method setCarrierRestrictionRules with an empty excluded list.
// indicating priority for the allowed list. // If the allowed list is empty, it means that all carriers are allowed (default allowed),
// otherwise it means that only specified carriers are allowed (default not allowed).
CarrierRestrictionRules carrierRestrictionRules = CarrierRestrictionRules.newBuilder() CarrierRestrictionRules carrierRestrictionRules = CarrierRestrictionRules.newBuilder()
.setAllowedCarriers(carriers) .setAllowedCarriers(carriers)
.setDefaultCarrierRestriction( .setDefaultCarrierRestriction(
CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED) carriers.isEmpty()
? CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_ALLOWED
: CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED)
.build(); .build();
int result = setCarrierRestrictionRules(carrierRestrictionRules); int result = setCarrierRestrictionRules(carrierRestrictionRules);