summaryrefslogtreecommitdiff
path: root/telephony/java
diff options
context:
space:
mode:
authorMichele Berionne <mberionne@google.com>2022-01-12 22:37:44 +0000
committerMaria Yang <mariay@google.com>2022-01-13 22:02:39 +0000
commit898e2b53a7d095ed5b0fd5a17f4557021ed56e31 (patch)
tree32091637bc4081fdfcc17491c50e8a2336076bc6 /telephony/java
parent95aa9b3447a08d99b27c9f19421022220ff7adcb (diff)
Handle setAllowedCarriers() with empty list of carriers
Bug: 204136145 Test: unit testing Change-Id: I9779180ff1c3e926f97e010ca6026c5fb950046d
Diffstat (limited to 'telephony/java')
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 989663406a6b..8bc4d381e2dd 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -11898,12 +11898,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);