1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.telephony;
18 
19 import android.annotation.FlaggedApi;
20 import android.annotation.IntDef;
21 import android.annotation.NonNull;
22 import android.annotation.SystemApi;
23 import android.os.Parcel;
24 import android.os.Parcelable;
25 import android.service.carrier.CarrierIdentifier;
26 import android.telephony.TelephonyManager.CarrierRestrictionStatus;
27 
28 import com.android.internal.telephony.flags.Flags;
29 
30 import java.lang.annotation.Retention;
31 import java.lang.annotation.RetentionPolicy;
32 import java.util.ArrayList;
33 import java.util.List;
34 import java.util.Locale;
35 import java.util.Objects;
36 
37 /**
38  * Contains the list of carrier restrictions.
39  * Allowed list: it indicates the list of carriers that are allowed.
40  * Excluded list: it indicates the list of carriers that are excluded.
41  * Default carrier restriction: it indicates the default behavior and the priority between the two
42  * lists:
43  *  - not allowed: the device only allows usage of carriers that are present in the allowed list
44  *    and not present in the excluded list. This implies that if a carrier is not present in either
45  *    list, it is not allowed.
46  *  - allowed: the device allows all carriers, except those present in the excluded list and not
47  *    present in the allowed list. This implies that if a carrier is not present in either list,
48  *    it is allowed.
49  * MultiSim policy: it indicates the behavior in case of devices with two or more SIM cards.
50  *  - MULTISIM_POLICY_NONE: the same configuration is applied to all SIM slots independently. This
51  *    is the default value if none is set.
52  *  - MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT: it indicates that any SIM card can be used
53  *    as far as one SIM card matching the configuration is present in the device.
54  *
55  * Both lists support the character '?' as wild character. For example, an entry indicating
56  * MCC=310 and MNC=??? will match all networks with MCC=310.
57  *
58  * Example 1: Allowed list contains MCC and MNC of operator A. Excluded list contains operator B,
59  *            which has same MCC and MNC, but also GID1 value. The priority allowed list is set
60  *            to true. Only SIM cards of operator A are allowed, but not those of B or any other
61  *            operator.
62  * Example 2: Allowed list contains MCC and MNC of operator A. Excluded list contains an entry
63  *            with same MCC, and '???' as MNC. The priority allowed list is set to false.
64  *            SIM cards of operator A and all SIM cards with a different MCC value are allowed.
65  *            SIM cards of operators with same MCC value and different MNC are not allowed.
66  * @hide
67  */
68 @SystemApi
69 public final class CarrierRestrictionRules implements Parcelable {
70     /**
71      * The device only allows usage of carriers that are present in the allowed list and not
72      * present in the excluded list. This implies that if a carrier is not present in either list,
73      * it is not allowed.
74      */
75     public static final int CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED = 0;
76 
77     /**
78      * The device allows all carriers, except those present in the excluded list and not present
79      * in the allowed list. This implies that if a carrier is not present in either list, it is
80      * allowed.
81      */
82     public static final int CARRIER_RESTRICTION_DEFAULT_ALLOWED = 1;
83 
84     /** The same configuration is applied to all SIM slots independently. */
85     public static final int MULTISIM_POLICY_NONE = 0;
86 
87     /**
88      * Indicates that any SIM card can be used as far as one valid card is present in the device.
89      * For the modem, a SIM card is valid when its content (i.e. MCC, MNC, GID, SPN) matches the
90      * carrier restriction configuration.
91      */
92     public static final int MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT = 1;
93 
94     /**
95      * Indicates that the SIM lock policy applies uniformly to all sim slots.
96      * @hide
97      */
98     public static final int MULTISIM_POLICY_APPLY_TO_ALL_SLOTS = 2;
99 
100     /**
101      * The SIM lock configuration applies exclusively to sim slot 1, leaving
102      * all other sim slots unlocked irrespective of the SIM card in slot 1
103      * @hide
104      */
105     public static final int MULTISIM_POLICY_APPLY_TO_ONLY_SLOT_1 = 3;
106 
107     /**
108      * Valid sim cards must be present on sim slot1 in order
109      * to use other sim slots.
110      * @hide
111      */
112     public static final int MULTISIM_POLICY_VALID_SIM_MUST_PRESENT_ON_SLOT_1 = 4;
113 
114     /**
115      * Valid sim card must be present on slot1 and it must be in full service
116      * in order to use other sim slots.
117      * @hide
118      */
119     public static final int MULTISIM_POLICY_ACTIVE_SERVICE_ON_SLOT_1_TO_UNBLOCK_OTHER_SLOTS = 5;
120 
121     /**
122      * Valid sim card be present on any slot and it must be in full service
123      * in order to use other sim slots.
124      * @hide
125      */
126     public static final int MULTISIM_POLICY_ACTIVE_SERVICE_ON_ANY_SLOT_TO_UNBLOCK_OTHER_SLOTS = 6;
127 
128     /**
129      * Valid sim cards must be present on all slots. If any SIM cards become
130      * invalid then device would set other SIM cards as invalid as well.
131      * @hide
132      */
133     public static final int MULTISIM_POLICY_ALL_SIMS_MUST_BE_VALID = 7;
134 
135     /**
136      * In case there is no match policy listed above.
137      * @hide
138      */
139     public static final int MULTISIM_POLICY_SLOT_POLICY_OTHER = 8;
140 
141 
142 
143     /** @hide */
144     @Retention(RetentionPolicy.SOURCE)
145     @IntDef(prefix = "MULTISIM_POLICY_",
146             value = {MULTISIM_POLICY_NONE,
147                     MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT,
148                     MULTISIM_POLICY_APPLY_TO_ALL_SLOTS,
149                     MULTISIM_POLICY_APPLY_TO_ONLY_SLOT_1,
150                     MULTISIM_POLICY_VALID_SIM_MUST_PRESENT_ON_SLOT_1,
151                     MULTISIM_POLICY_ACTIVE_SERVICE_ON_SLOT_1_TO_UNBLOCK_OTHER_SLOTS,
152                     MULTISIM_POLICY_ACTIVE_SERVICE_ON_ANY_SLOT_TO_UNBLOCK_OTHER_SLOTS,
153                     MULTISIM_POLICY_ALL_SIMS_MUST_BE_VALID,
154                     MULTISIM_POLICY_SLOT_POLICY_OTHER
155             })
156     public @interface MultiSimPolicy {}
157 
158     /** @hide */
159     @Retention(RetentionPolicy.SOURCE)
160     @IntDef(prefix = "CARRIER_RESTRICTION_DEFAULT_",
161             value = {CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED, CARRIER_RESTRICTION_DEFAULT_ALLOWED})
162     public @interface CarrierRestrictionDefault {}
163 
164     /* Wild character for comparison */
165     private static final char WILD_CHARACTER = '?';
166 
167     private List<CarrierIdentifier> mAllowedCarriers;
168     private List<CarrierIdentifier> mExcludedCarriers;
169     private List<CarrierInfo> mAllowedCarrierInfo;
170     private List<CarrierInfo> mExcludedCarrierInfo;
171     @CarrierRestrictionDefault
172     private int mCarrierRestrictionDefault;
173     @MultiSimPolicy
174     private int mMultiSimPolicy;
175     @CarrierRestrictionStatus
176     private int mCarrierRestrictionStatus;
177     private boolean mUseCarrierLockInfo;
178 
CarrierRestrictionRules()179     private CarrierRestrictionRules() {
180         mAllowedCarriers = new ArrayList<CarrierIdentifier>();
181         mExcludedCarriers = new ArrayList<CarrierIdentifier>();
182         mAllowedCarrierInfo = new ArrayList<CarrierInfo>();
183         mExcludedCarrierInfo = new ArrayList<CarrierInfo>();
184         mCarrierRestrictionDefault = CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED;
185         mMultiSimPolicy = MULTISIM_POLICY_NONE;
186         mCarrierRestrictionStatus = TelephonyManager.CARRIER_RESTRICTION_STATUS_UNKNOWN;
187         mUseCarrierLockInfo = false;
188     }
189 
CarrierRestrictionRules(Parcel in)190     private CarrierRestrictionRules(Parcel in) {
191         mAllowedCarriers = new ArrayList<CarrierIdentifier>();
192         mExcludedCarriers = new ArrayList<CarrierIdentifier>();
193         mAllowedCarrierInfo = new ArrayList<CarrierInfo>();
194         mExcludedCarrierInfo = new ArrayList<CarrierInfo>();
195         in.readTypedList(mAllowedCarriers, CarrierIdentifier.CREATOR);
196         in.readTypedList(mExcludedCarriers, CarrierIdentifier.CREATOR);
197         mCarrierRestrictionDefault = in.readInt();
198         mMultiSimPolicy = in.readInt();
199         mCarrierRestrictionStatus = in.readInt();
200         if (Flags.carrierRestrictionRulesEnhancement()) {
201             in.readTypedList(mAllowedCarrierInfo, CarrierInfo.CREATOR);
202             in.readTypedList(mExcludedCarrierInfo, CarrierInfo.CREATOR);
203             mUseCarrierLockInfo = in.readBoolean();
204         }
205     }
206 
207     /**
208      * Creates a new builder for this class
209      * @hide
210      */
newBuilder()211     public static Builder newBuilder() {
212         return new Builder();
213     }
214 
215     /**
216      * Indicates if all carriers are allowed
217      */
isAllCarriersAllowed()218     public boolean isAllCarriersAllowed() {
219         if (Flags.carrierRestrictionStatus() && mCarrierRestrictionStatus
220                 == TelephonyManager.CARRIER_RESTRICTION_STATUS_NOT_RESTRICTED) {
221             return true;
222         }
223         if (Flags.carrierRestrictionRulesEnhancement() && mUseCarrierLockInfo) {
224             return (mAllowedCarrierInfo.isEmpty() && mExcludedCarrierInfo.isEmpty()
225                     && mCarrierRestrictionDefault == CARRIER_RESTRICTION_DEFAULT_ALLOWED);
226         }
227         return (mAllowedCarriers.isEmpty() && mExcludedCarriers.isEmpty()
228                 && mCarrierRestrictionDefault == CARRIER_RESTRICTION_DEFAULT_ALLOWED);
229     }
230 
231     /**
232      * Retrieves list of allowed carriers
233      *
234      * @return the list of allowed carriers
235      */
getAllowedCarriers()236     public @NonNull List<CarrierIdentifier> getAllowedCarriers() {
237         return mAllowedCarriers;
238     }
239 
240     /**
241      * Retrieves list of excluded carriers
242      *
243      * @return the list of excluded carriers
244      */
getExcludedCarriers()245     public @NonNull List<CarrierIdentifier> getExcludedCarriers() {
246         return mExcludedCarriers;
247     }
248 
249     /**
250      * Retrieves list of excluded carrierInfos
251      *
252      * @return the list of excluded carrierInfos
253      * @hide
254      */
getExcludedCarriersInfoList()255     public @NonNull List<CarrierInfo> getExcludedCarriersInfoList() {
256         return mExcludedCarrierInfo;
257     }
258 
259     /**
260      * Retrieves list of excluded carrierInfos
261      *
262      * @return the list of excluded carrierInfos
263      * @hide
264      */
getAllowedCarriersInfoList()265     public @NonNull List<CarrierInfo> getAllowedCarriersInfoList() {
266         return mAllowedCarrierInfo;
267     }
268     /**
269      * Retrieves the default behavior of carrier restrictions
270      */
getDefaultCarrierRestriction()271     public @CarrierRestrictionDefault int getDefaultCarrierRestriction() {
272         return mCarrierRestrictionDefault;
273     }
274 
275     /**
276      * @return The policy used for multi-SIM devices
277      */
getMultiSimPolicy()278     public @MultiSimPolicy int getMultiSimPolicy() {
279         return mMultiSimPolicy;
280     }
281 
282     /**
283      * Tests an array of carriers with the carrier restriction configuration. The list of carrier
284      * ids passed as argument does not need to be the same as currently present in the device.
285      *
286      * @param carrierIds list of {@link CarrierIdentifier}, one for each SIM slot on the device
287      * @return a list of boolean with the same size as input, indicating if each
288      * {@link CarrierIdentifier} is allowed or not.
289      */
areCarrierIdentifiersAllowed( @onNull List<CarrierIdentifier> carrierIds)290     public @NonNull List<Boolean> areCarrierIdentifiersAllowed(
291             @NonNull List<CarrierIdentifier> carrierIds) {
292         ArrayList<Boolean> result = new ArrayList<>(carrierIds.size());
293 
294         // First calculate the result for each slot independently
295         for (int i = 0; i < carrierIds.size(); i++) {
296             boolean inAllowedList = isCarrierIdInList(carrierIds.get(i), mAllowedCarriers);
297             boolean inExcludedList = isCarrierIdInList(carrierIds.get(i), mExcludedCarriers);
298             if (mCarrierRestrictionDefault == CARRIER_RESTRICTION_DEFAULT_NOT_ALLOWED) {
299                 result.add((inAllowedList && !inExcludedList) ? true : false);
300             } else {
301                 result.add((inExcludedList && !inAllowedList) ? false : true);
302             }
303         }
304         // Apply the multi-slot policy, if needed.
305         if (mMultiSimPolicy == MULTISIM_POLICY_ONE_VALID_SIM_MUST_BE_PRESENT) {
306             for (boolean b : result) {
307                 if (b) {
308                     result.replaceAll(x -> true);
309                     break;
310                 }
311             }
312         }
313         return result;
314     }
315 
316     /**
317      * Indicates if a certain carrier {@code id} is present inside a {@code list}
318      *
319      * @return true if the carrier {@code id} is present, false otherwise
320      */
isCarrierIdInList(CarrierIdentifier id, List<CarrierIdentifier> list)321     private static boolean isCarrierIdInList(CarrierIdentifier id, List<CarrierIdentifier> list) {
322         for (CarrierIdentifier listItem : list) {
323             // Compare MCC and MNC
324             if (!patternMatch(id.getMcc(), listItem.getMcc())
325                     || !patternMatch(id.getMnc(), listItem.getMnc())) {
326                 continue;
327             }
328 
329             // Compare SPN. Comparison is on the complete strings, case insensitive and with wild
330             // characters.
331             String listItemValue = convertNullToEmpty(listItem.getSpn());
332             String idValue = convertNullToEmpty(id.getSpn());
333             if (!listItemValue.isEmpty()) {
334                 if (!patternMatch(idValue, listItemValue)) {
335                     continue;
336                 }
337             }
338 
339             // The IMSI of the configuration can be shorter than actual IMSI in the SIM card.
340             listItemValue = convertNullToEmpty(listItem.getImsi());
341             idValue = convertNullToEmpty(id.getImsi());
342             if (!patternMatch(
343                     idValue.substring(0, Math.min(idValue.length(), listItemValue.length())),
344                     listItemValue)) {
345                 continue;
346             }
347 
348             // The GID1 of the configuration can be shorter than actual GID1 in the SIM card.
349             listItemValue = convertNullToEmpty(listItem.getGid1());
350             idValue = convertNullToEmpty(id.getGid1());
351             if (!patternMatch(
352                     idValue.substring(0, Math.min(idValue.length(), listItemValue.length())),
353                     listItemValue)) {
354                 continue;
355             }
356 
357             // The GID2 of the configuration can be shorter than actual GID2 in the SIM card.
358             listItemValue = convertNullToEmpty(listItem.getGid2());
359             idValue = convertNullToEmpty(id.getGid2());
360             if (!patternMatch(
361                     idValue.substring(0, Math.min(idValue.length(), listItemValue.length())),
362                     listItemValue)) {
363                 continue;
364             }
365 
366             // Valid match was found in the list
367             return true;
368         }
369         return false;
370     }
371 
convertNullToEmpty(String value)372     private static String convertNullToEmpty(String value) {
373         return Objects.toString(value, "");
374     }
375 
376     /**
377      * Performs a case insensitive string comparison against a given pattern. The character '?'
378      * is used in the pattern as wild character in the comparison. The string must have the same
379      * length as the pattern.
380      *
381      * @param str string to match
382      * @param pattern string containing the pattern
383      * @return true in case of match, false otherwise
384      */
patternMatch(String str, String pattern)385     private static boolean patternMatch(String str, String pattern) {
386         if (str.length() != pattern.length()) {
387             return false;
388         }
389         String lowerCaseStr = str.toLowerCase(Locale.ROOT);
390         String lowerCasePattern = pattern.toLowerCase(Locale.ROOT);
391 
392         for (int i = 0; i < lowerCasePattern.length(); i++) {
393             if (lowerCasePattern.charAt(i) != lowerCaseStr.charAt(i)
394                     && lowerCasePattern.charAt(i) != WILD_CHARACTER) {
395                 return false;
396             }
397         }
398         return true;
399     }
400 
401     /**
402      * Get the carrier restriction status of the device.
403      * The return value of the API is as follows.
404      * <ul>
405      *      <li>return {@link TelephonyManager#CARRIER_RESTRICTION_STATUS_RESTRICTED_TO_CALLER}
406      *      if the caller and the device locked by the network are same</li>
407      *      <li>return {@link TelephonyManager#CARRIER_RESTRICTION_STATUS_RESTRICTED} if the
408      *      caller and the device locked by the network are different</li>
409      *      <li>return {@link TelephonyManager#CARRIER_RESTRICTION_STATUS_NOT_RESTRICTED} if the
410      *      device is not locked</li>
411      *      <li>return {@link TelephonyManager#CARRIER_RESTRICTION_STATUS_UNKNOWN} if the device
412      *      locking state is unavailable or radio does not supports the feature</li>
413      * </ul>
414      */
415     @FlaggedApi(Flags.FLAG_CARRIER_RESTRICTION_STATUS)
getCarrierRestrictionStatus()416     public @CarrierRestrictionStatus int getCarrierRestrictionStatus() {
417         return mCarrierRestrictionStatus;
418     }
419 
420     /**
421      * {@link Parcelable#writeToParcel}
422      */
423     @Override
writeToParcel(Parcel out, int flags)424     public void writeToParcel(Parcel out, int flags) {
425         out.writeTypedList(mAllowedCarriers);
426         out.writeTypedList(mExcludedCarriers);
427         out.writeInt(mCarrierRestrictionDefault);
428         out.writeInt(mMultiSimPolicy);
429         out.writeInt(mCarrierRestrictionStatus);
430         if (Flags.carrierRestrictionRulesEnhancement()) {
431             out.writeTypedList(mAllowedCarrierInfo);
432             out.writeTypedList(mExcludedCarrierInfo);
433             out.writeBoolean(mUseCarrierLockInfo);
434         }
435     }
436 
437     /**
438      * {@link Parcelable#describeContents}
439      */
440     @Override
describeContents()441     public int describeContents() {
442         return 0;
443     }
444 
445     /**
446      * {@link Parcelable.Creator}
447      */
448     public static final @android.annotation.NonNull Creator<CarrierRestrictionRules> CREATOR =
449             new Creator<CarrierRestrictionRules>() {
450         @Override
451         public CarrierRestrictionRules createFromParcel(Parcel in) {
452             return new CarrierRestrictionRules(in);
453         }
454 
455         @Override
456         public CarrierRestrictionRules[] newArray(int size) {
457             return new CarrierRestrictionRules[size];
458         }
459     };
460 
461     @NonNull
462     @Override
toString()463     public String toString() {
464         return "CarrierRestrictionRules(allowed:" + mAllowedCarriers + ", excluded:"
465                 + mExcludedCarriers + ", default:" + mCarrierRestrictionDefault
466                 + ", MultiSim policy:" + mMultiSimPolicy + getCarrierInfoList() +
467                 "  mIsCarrierLockInfoSupported = " + mUseCarrierLockInfo + ")";
468     }
469 
getCarrierInfoList()470     private String getCarrierInfoList() {
471         if (Flags.carrierRestrictionRulesEnhancement()) {
472             return ",  allowedCarrierInfoList:" + mAllowedCarrierInfo
473                     + ", excludedCarrierInfoList:" + mExcludedCarrierInfo;
474         } else {
475             return "";
476         }
477     }
478 
479     /**
480      * Builder for a {@link CarrierRestrictionRules}.
481      */
482     public static final class Builder {
483         private final CarrierRestrictionRules mRules;
484 
Builder()485         public Builder() {
486             mRules = new CarrierRestrictionRules();
487         }
488 
489         /** build command */
build()490         public @NonNull CarrierRestrictionRules build() {
491             return mRules;
492         }
493 
494         /**
495          * Indicate that all carriers are allowed.
496          */
setAllCarriersAllowed()497         public @NonNull Builder setAllCarriersAllowed() {
498             mRules.mAllowedCarriers.clear();
499             mRules.mExcludedCarriers.clear();
500             mRules.mCarrierRestrictionDefault = CARRIER_RESTRICTION_DEFAULT_ALLOWED;
501             if (Flags.carrierRestrictionRulesEnhancement()) {
502                 mRules.mCarrierRestrictionStatus =
503                         TelephonyManager.CARRIER_RESTRICTION_STATUS_NOT_RESTRICTED;
504                 mRules.mAllowedCarrierInfo.clear();
505                 mRules.mExcludedCarrierInfo.clear();
506                 mRules.mUseCarrierLockInfo = false;
507             }
508             return this;
509         }
510 
511         /**
512          * Set list of allowed carriers.
513          *
514          * @param allowedCarriers list of allowed carriers
515          */
setAllowedCarriers( @onNull List<CarrierIdentifier> allowedCarriers)516         public @NonNull Builder setAllowedCarriers(
517                 @NonNull List<CarrierIdentifier> allowedCarriers) {
518             mRules.mAllowedCarriers = new ArrayList<CarrierIdentifier>(allowedCarriers);
519             return this;
520         }
521 
522         /**
523          * Set list of excluded carriers.
524          *
525          * @param excludedCarriers list of excluded carriers
526          */
setExcludedCarriers( @onNull List<CarrierIdentifier> excludedCarriers)527         public @NonNull Builder setExcludedCarriers(
528                 @NonNull List<CarrierIdentifier> excludedCarriers) {
529             mRules.mExcludedCarriers = new ArrayList<CarrierIdentifier>(excludedCarriers);
530             return this;
531         }
532 
533         /**
534          * Set the default behavior of the carrier restrictions
535          *
536          * @param carrierRestrictionDefault prioritized carrier list
537          */
setDefaultCarrierRestriction( @arrierRestrictionDefault int carrierRestrictionDefault)538         public @NonNull Builder setDefaultCarrierRestriction(
539                 @CarrierRestrictionDefault int carrierRestrictionDefault) {
540             mRules.mCarrierRestrictionDefault = carrierRestrictionDefault;
541             return this;
542         }
543 
544         /**
545          * Set the policy to be used for multi-SIM devices
546          *
547          * @param multiSimPolicy multi SIM policy
548          */
setMultiSimPolicy(@ultiSimPolicy int multiSimPolicy)549         public @NonNull Builder setMultiSimPolicy(@MultiSimPolicy int multiSimPolicy) {
550             mRules.mMultiSimPolicy = multiSimPolicy;
551             return this;
552         }
553 
554         /**
555          * Set the device's carrier restriction status
556          *
557          * @param carrierRestrictionStatus device restriction status
558          */
559         public @NonNull
560         @FlaggedApi(Flags.FLAG_SET_CARRIER_RESTRICTION_STATUS)
setCarrierRestrictionStatus( @arrierRestrictionStatus int carrierRestrictionStatus)561         Builder setCarrierRestrictionStatus(
562                 @CarrierRestrictionStatus int carrierRestrictionStatus) {
563             mRules.mCarrierRestrictionStatus = carrierRestrictionStatus;
564             return this;
565         }
566 
567         /**
568          * Set list of allowed carrierInfo
569          *
570          * @param allowedCarrierInfo list of allowed CarrierInfo
571          * @hide
572          */
setAllowedCarrierInfo( @onNull List<CarrierInfo> allowedCarrierInfo)573         public @NonNull Builder setAllowedCarrierInfo(
574                 @NonNull List<CarrierInfo> allowedCarrierInfo) {
575             mRules.mAllowedCarrierInfo = new ArrayList<CarrierInfo>(allowedCarrierInfo);
576             return this;
577         }
578 
579         /**
580          * Set list of allowed carrierInfo
581          *
582          * @param excludedCarrierInfo list of allowed CarrierInfo
583          * @hide
584          */
setExcludedCarrierInfo( @onNull List<CarrierInfo> excludedCarrierInfo)585         public @NonNull Builder setExcludedCarrierInfo(
586                 @NonNull List<CarrierInfo> excludedCarrierInfo) {
587             mRules.mExcludedCarrierInfo = new ArrayList<CarrierInfo>(excludedCarrierInfo);
588             return this;
589         }
590 
591         /**
592          * set whether the HAL radio supports the advanced carrier lock features or not.
593          *
594          * @param carrierLockInfoSupported advanced carrierInfo changes supported or not
595          * @hide
596          */
setCarrierLockInfoFeature(boolean carrierLockInfoSupported)597         public @NonNull Builder setCarrierLockInfoFeature(boolean carrierLockInfoSupported) {
598             mRules.mUseCarrierLockInfo = carrierLockInfoSupported;
599             return this;
600         }
601     }
602 }
603