Handle setAllowedCarriers() with empty list of carriers

Bug: 204136145
Test: unit testing
Merged-In: I9779180ff1c3e926f97e010ca6026c5fb950046d
Change-Id: I9779180ff1c3e926f97e010ca6026c5fb950046d
(cherry picked from commit 898e2b53a7)
This commit is contained in:
Michele Berionne
2022-01-12 22:37:44 +00:00
parent a31dc6da2a
commit 47ceccd912

View File

@@ -12111,12 +12111,15 @@ public class TelephonyManager {
if (carriers == null || !SubscriptionManager.isValidPhoneId(slotIndex)) {
return -1;
}
// Execute the method setCarrierRestrictionRules with an empty excluded list and
// indicating priority for the allowed list.
// Execute the method setCarrierRestrictionRules with an empty excluded 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()
.setAllowedCarriers(carriers)
.setDefaultCarrierRestriction(
CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED)
carriers.isEmpty()
? CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_ALLOWED
: CarrierRestrictionRules.CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED)
.build();
int result = setCarrierRestrictionRules(carrierRestrictionRules);