• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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  * Copyright (C) 2022 The Android Open Source Project
18  *
19  * Licensed under the Apache License, Version 2.0 (the "License");
20  * you may not use this file except in compliance with the License.
21  * You may obtain a copy of the License at
22  *
23  *      http://www.apache.org/licenses/LICENSE-2.0
24  *
25  * Unless required by applicable law or agreed to in writing, software
26  * distributed under the License is distributed on an "AS IS" BASIS,
27  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28  * See the License for the specific language governing permissions and
29  * limitations under the License.
30  */
31 
32 package com.android.internal.telephony.subscription;
33 
34 import android.annotation.ColorInt;
35 import android.annotation.NonNull;
36 import android.annotation.UserIdInt;
37 import android.os.UserHandle;
38 import android.provider.Telephony.SimInfo;
39 import android.telephony.SubscriptionInfo;
40 import android.telephony.SubscriptionManager;
41 import android.telephony.SubscriptionManager.DeviceToDeviceStatusSharingPreference;
42 import android.telephony.SubscriptionManager.ProfileClass;
43 import android.telephony.SubscriptionManager.SimDisplayNameSource;
44 import android.telephony.SubscriptionManager.SubscriptionType;
45 import android.telephony.SubscriptionManager.UsageSetting;
46 import android.telephony.TelephonyManager;
47 import android.telephony.UiccAccessRule;
48 import android.telephony.ims.ImsMmTelManager;
49 import android.text.TextUtils;
50 
51 import com.android.internal.telephony.uicc.IccUtils;
52 import com.android.internal.telephony.util.TelephonyUtils;
53 import com.android.telephony.Rlog;
54 
55 import java.util.Arrays;
56 import java.util.List;
57 import java.util.Objects;
58 
59 /**
60  * The class represents a single row of {@link SimInfo} table. All columns (excepts unused columns)
61  * in the database have a corresponding field in this class.
62  *
63  * The difference between {@link SubscriptionInfo} and this class is that {@link SubscriptionInfo}
64  * is a subset of this class. This is intended to solve the problem that some database fields
65  * required higher permission like
66  * {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE} to access while
67  * {@link SubscriptionManager#getActiveSubscriptionIdList()} only requires
68  * {@link android.Manifest.permission#READ_PHONE_STATE} to access. Sometimes blanking out fields in
69  * {@link SubscriptionInfo} creates ambiguity for clients hard to distinguish between insufficient
70  * permission versus true failure.
71  *
72  * Also the fields in this class match the format used in database. For example, boolean values
73  * are stored as integer, or string arrays are stored as a single comma separated string.
74  */
75 public class SubscriptionInfoInternal {
76     /**
77      * Subscription Identifier, this is a device unique number
78      * and not an index into an array
79      */
80     private final int mId;
81 
82     /**
83      * The ICCID of the SIM that is associated with this subscription, empty if unknown.
84      */
85     @NonNull
86     private final String mIccId;
87 
88     /**
89      * The index of the SIM slot that currently contains the subscription and not necessarily unique
90      * and maybe {@link SubscriptionManager#INVALID_SIM_SLOT_INDEX} if unknown or the subscription
91      * is inactive.
92      */
93     private final int mSimSlotIndex;
94 
95     /**
96      * The name displayed to the user that identifies this subscription. This name is used
97      * in Settings page and can be renamed by the user.
98      */
99     @NonNull
100     private final String mDisplayName;
101 
102     /**
103      * The name displayed to the user that identifies subscription provider name. This name is the
104      * SPN displayed in status bar and many other places. Can't be renamed by the user.
105      */
106     @NonNull
107     private final String mCarrierName;
108 
109     /**
110      * The source of the {@link #mDisplayName}.
111      */
112     @SimDisplayNameSource
113     private final int mDisplayNameSource;
114 
115     /**
116      * The color to be used for tinting the icon when displaying to the user.
117      */
118     @ColorInt
119     private final int mIconTint;
120 
121     /**
122      * The number presented to the user identify this subscription.
123      */
124     @NonNull
125     private final String mNumber;
126 
127     /**
128      * Whether user enables data roaming for this subscription or not. Either
129      * {@link SubscriptionManager#DATA_ROAMING_ENABLE} or
130      * {@link SubscriptionManager#DATA_ROAMING_DISABLE}.
131      */
132     private final int mDataRoaming;
133 
134     /**
135      * Mobile Country Code.
136      */
137     @NonNull
138     private final String mMcc;
139 
140     /**
141      * Mobile Network Code.
142      */
143     @NonNull
144     private final String mMnc;
145 
146     /**
147      * EHPLMNs associated with the subscription.
148      */
149     @NonNull
150     private final String mEhplmns;
151 
152     /**
153      * HPLMNs associated with the subscription.
154      */
155     @NonNull
156     private final String mHplmns;
157 
158     /**
159      * Whether the subscription is from eSIM. It is intended to use integer to fit the database
160      * format.
161      */
162     private final int mIsEmbedded;
163 
164     /**
165      * The string ID of the SIM card. It is the ICCID of the active profile for a UICC card and the
166      * EID for an eUICC card.
167      */
168     @NonNull
169     private final String mCardString;
170 
171     /**
172      * The access rules for this subscription, if it is embedded and defines any. This does not
173      * include access rules for non-embedded subscriptions.
174      */
175     @NonNull
176     private final byte[] mNativeAccessRules;
177 
178     /**
179      * The carrier certificates for this subscription that are saved in carrier configs.
180      * This does not include access rules from the Uicc, whether embedded or non-embedded.
181      */
182     @NonNull
183     private final byte[] mCarrierConfigAccessRules;
184 
185     /**
186      * Whether an embedded subscription is on a removable card. Such subscriptions are marked
187      * inaccessible as soon as the current card is removed. Otherwise, they will remain accessible
188      * unless explicitly deleted. Only meaningful when {@link #getEmbedded()} is {@code 1}. It
189      * is intended to use integer to fit the database format.
190      */
191     private final int mIsRemovableEmbedded;
192 
193     /**
194      * Whether cell broadcast extreme threat alert is enabled by the user or not.
195      */
196     private int mIsExtremeThreatAlertEnabled;
197 
198     /**
199      * Whether cell broadcast severe threat alert is enabled by the user or not.
200      */
201     private int mIsSevereThreatAlertEnabled;
202 
203     /**
204      * Whether cell broadcast amber alert is enabled by the user or not.
205      */
206     private int mIsAmberAlertEnabled;
207 
208     /**
209      * Whether cell broadcast emergency alert is enabled by the user or not.
210      */
211     private int mIsEmergencyAlertEnabled;
212 
213     /**
214      * Cell broadcast alert sound duration in seconds.
215      */
216     private int mAlertSoundDuration;
217 
218     /**
219      * Cell broadcast alert reminder interval in minutes.
220      */
221     private int mReminderInterval;
222 
223     /**
224      * Whether cell broadcast alert vibration is enabled by the user or not.
225      */
226     private int mIsAlertVibrationEnabled;
227 
228     /**
229      * Whether cell broadcast alert speech is enabled by the user or not.
230      */
231     private int mIsAlertSpeechEnabled;
232 
233     /**
234      * Whether ETWS test alert is enabled by the user or not.
235      */
236     private int mIsEtwsTestAlertEnabled;
237 
238     /**
239      * Whether area info message is enabled by the user or not.
240      */
241     private int mIsAreaInfoMessageEnabled;
242 
243     /**
244      * Whether cell broadcast test alert is enabled by the user or not.
245      */
246     private int mIsTestAlertEnabled;
247 
248     /**
249      * Whether cell broadcast opt-out dialog should be shown or not.
250      */
251     private int mIsOptOutDialogEnabled;
252 
253     /**
254      * Whether enhanced 4G mode is enabled by the user or not. It is intended to use integer to fit
255      * the database format.
256      */
257     private final int mIsEnhanced4GModeEnabled;
258 
259     /**
260      * Whether video telephony is enabled by the user or not. It is intended to use integer to fit
261      * the database format.
262      */
263     private final int mIsVideoTelephonyEnabled;
264 
265     /**
266      * Whether Wi-Fi calling is enabled by the user or not when the device is not roaming. It is
267      * intended to use integer to fit the database format.
268      */
269     private final int mIsWifiCallingEnabled;
270 
271     /**
272      * Wi-Fi calling mode when the device is not roaming.
273      */
274     @ImsMmTelManager.WiFiCallingMode
275     private final int mWifiCallingMode;
276 
277     /**
278      * Wi-Fi calling mode when the device is roaming.
279      */
280     @ImsMmTelManager.WiFiCallingMode
281     private final int mWifiCallingModeForRoaming;
282 
283     /**
284      * Whether Wi-Fi calling is enabled by the user or not when the device is roaming. It is
285      * intended to use integer to fit the database format.
286      */
287     private final int mIsWifiCallingEnabledForRoaming;
288 
289     /**
290      * Whether the subscription is opportunistic. It is intended to use integer to fit the database
291      * format.
292      */
293     private final int mIsOpportunistic;
294 
295     /**
296      * A UUID assigned to the subscription group in string format.
297      *
298      * @see SubscriptionManager#createSubscriptionGroup(List)
299      */
300     @NonNull
301     private final String mGroupUuid;
302 
303     /**
304      * ISO Country code for the subscription's provider.
305      */
306     @NonNull
307     private final String mCountryIso;
308 
309     /**
310      * The subscription carrier id.
311      *
312      * @see TelephonyManager#getSimCarrierId()
313      */
314     private final int mCarrierId;
315 
316     /**
317      * The profile class populated from the profile metadata if present. Otherwise,
318      * the profile class defaults to {@link SubscriptionManager#PROFILE_CLASS_UNSET} if there is no
319      * profile metadata or the subscription is not on an eUICC ({@link #getEmbedded} returns
320      * {@code 0}).
321      */
322     @ProfileClass
323     private final int mProfileClass;
324 
325     /**
326      * Type of the subscription.
327      */
328     @SubscriptionType
329     private final int mType;
330 
331     /**
332      * A package name that specifies who created the group. Empty if not available.
333      */
334     @NonNull
335     private final String mGroupOwner;
336 
337     /**
338      * The enabled mobile data policies in string format.
339      */
340     @NonNull
341     private final String mEnabledMobileDataPolicies;
342 
343     /**
344      * The IMSI (International Mobile Subscriber Identity) of the subscription.
345      */
346     @NonNull
347     private final String mImsi;
348 
349     /**
350      * Whether uicc applications are configured to enable or disable.
351      * By default it's true. It is intended to use integer to fit the database format.
352      */
353     private final int mAreUiccApplicationsEnabled;
354 
355     /**
356      * Whether the user has enabled IMS RCS User Capability Exchange (UCE) for this subscription.
357      * It is intended to use integer to fit the database format.
358      */
359     private final int mIsRcsUceEnabled;
360 
361     /**
362      * Whether the user has enabled cross SIM calling for this subscription. It is intended to
363      * use integer to fit the database format.
364      */
365     private final int mIsCrossSimCallingEnabled;
366 
367     /**
368      * The RCS configuration.
369      */
370     @NonNull
371     private final byte[] mRcsConfig;
372 
373     /**
374      * The allowed network types for reasons in string format. The format is
375      * "[reason]=[network types bitmask], [reason]=[network types bitmask], ..."
376      *
377      * For example, "user=1239287394, thermal=298791239, carrier=3456812312".
378      */
379     @NonNull
380     private final String mAllowedNetworkTypesForReasons;
381 
382     /**
383      * Device to device sharing status.
384      */
385     @DeviceToDeviceStatusSharingPreference
386     private final int mDeviceToDeviceStatusSharingPreference;
387 
388     /**
389      * Whether the user has opted-in voice over IMS. It is intended to use integer to fit the
390      * database format.
391      */
392     private final int mIsVoImsOptInEnabled;
393 
394     /**
395      * Contacts information that allow device to device sharing.
396      */
397     @NonNull
398     private final String mDeviceToDeviceStatusSharingContacts;
399 
400     /**
401      * Whether the user has enabled NR advanced calling. It is intended to use integer to fit the
402      * database format.
403      */
404     private final int mIsNrAdvancedCallingEnabled;
405 
406     /**
407      * The phone number retrieved from carrier.
408      */
409     @NonNull
410     private final String mNumberFromCarrier;
411 
412     /**
413      * The phone number retrieved from IMS.
414      */
415     @NonNull
416     private final String mNumberFromIms;
417 
418     /**
419      * The port index of the Uicc card.
420      */
421     private final int mPortIndex;
422 
423     /**
424      * Subscription's preferred usage setting.
425      */
426     @UsageSetting
427     private final int mUsageSetting;
428 
429     /**
430      * Last used TP message reference.
431      */
432     private final int mLastUsedTPMessageReference;
433 
434     /**
435      * The user id associated with this subscription.
436      */
437     private final int mUserId;
438 
439     /**
440      * Whether satellite is enabled or disabled.
441      * By default, its disabled. It is intended to use integer to fit the database format.
442      */
443     private final int mIsSatelliteEnabled;
444 
445     // Below are the fields that do not exist in the SimInfo table.
446     /**
447      * The card ID of the SIM card. This maps uniquely to {@link #mCardString}.
448      */
449     private final int mCardId;
450 
451     /**
452      * Whether group of the subscription is disabled. This is only useful if it's a grouped
453      * opportunistic subscription. In this case, if all primary (non-opportunistic) subscriptions
454      * in the group are deactivated (unplugged pSIM or deactivated eSIM profile), we should disable
455      * this opportunistic subscription. It is intended to use integer to fit the database format.
456      */
457     private final boolean mIsGroupDisabled;
458 
459     /**
460      * Constructor from builder.
461      *
462      * @param builder Builder of {@link SubscriptionInfoInternal}.
463      */
SubscriptionInfoInternal(@onNull Builder builder)464     private SubscriptionInfoInternal(@NonNull Builder builder) {
465         this.mId = builder.mId;
466         this.mIccId = builder.mIccId;
467         this.mSimSlotIndex = builder.mSimSlotIndex;
468         this.mDisplayName = builder.mDisplayName;
469         this.mCarrierName = builder.mCarrierName;
470         this.mDisplayNameSource = builder.mDisplayNameSource;
471         this.mIconTint = builder.mIconTint;
472         this.mNumber = builder.mNumber;
473         this.mDataRoaming = builder.mDataRoaming;
474         this.mMcc = builder.mMcc;
475         this.mMnc = builder.mMnc;
476         this.mEhplmns = builder.mEhplmns;
477         this.mHplmns = builder.mHplmns;
478         this.mIsEmbedded = builder.mIsEmbedded;
479         this.mCardString = builder.mCardString;
480         this.mNativeAccessRules = builder.mNativeAccessRules;
481         this.mCarrierConfigAccessRules = builder.mCarrierConfigAccessRules;
482         this.mIsRemovableEmbedded = builder.mIsRemovableEmbedded;
483         this.mIsExtremeThreatAlertEnabled = builder.mIsExtremeThreatAlertEnabled;
484         this.mIsSevereThreatAlertEnabled = builder.mIsSevereThreatAlertEnabled;
485         this.mIsAmberAlertEnabled = builder.mIsAmberAlertEnabled;
486         this.mIsEmergencyAlertEnabled = builder.mIsEmergencyAlertEnabled;
487         this.mAlertSoundDuration = builder.mAlertSoundDuration;
488         this.mReminderInterval = builder.mReminderInterval;
489         this.mIsAlertVibrationEnabled = builder.mIsAlertVibrationEnabled;
490         this.mIsAlertSpeechEnabled = builder.mIsAlertSpeechEnabled;
491         this.mIsEtwsTestAlertEnabled = builder.mIsEtwsTestAlertEnabled;
492         this.mIsAreaInfoMessageEnabled = builder.mIsAreaInfoMessageEnabled;
493         this.mIsTestAlertEnabled = builder.mIsTestAlertEnabled;
494         this.mIsOptOutDialogEnabled = builder.mIsOptOutDialogEnabled;
495         this.mIsEnhanced4GModeEnabled = builder.mIsEnhanced4GModeEnabled;
496         this.mIsVideoTelephonyEnabled = builder.mIsVideoTelephonyEnabled;
497         this.mIsWifiCallingEnabled = builder.mIsWifiCallingEnabled;
498         this.mWifiCallingMode = builder.mWifiCallingMode;
499         this.mWifiCallingModeForRoaming = builder.mWifiCallingModeForRoaming;
500         this.mIsWifiCallingEnabledForRoaming = builder.mIsWifiCallingEnabledForRoaming;
501         this.mIsOpportunistic = builder.mIsOpportunistic;
502         this.mGroupUuid = builder.mGroupUuid;
503         this.mCountryIso = builder.mCountryIso;
504         this.mCarrierId = builder.mCarrierId;
505         this.mProfileClass = builder.mProfileClass;
506         this.mType = builder.mType;
507         this.mGroupOwner = builder.mGroupOwner;
508         this.mEnabledMobileDataPolicies = builder.mEnabledMobileDataPolicies;
509         this.mImsi = builder.mImsi;
510         this.mAreUiccApplicationsEnabled = builder.mAreUiccApplicationsEnabled;
511         this.mIsRcsUceEnabled = builder.mIsRcsUceEnabled;
512         this.mIsCrossSimCallingEnabled = builder.mIsCrossSimCallingEnabled;
513         this.mRcsConfig = builder.mRcsConfig;
514         this.mAllowedNetworkTypesForReasons = builder.mAllowedNetworkTypesForReasons;
515         this.mDeviceToDeviceStatusSharingPreference =
516                 builder.mDeviceToDeviceStatusSharingPreference;
517         this.mIsVoImsOptInEnabled = builder.mIsVoImsOptInEnabled;
518         this.mDeviceToDeviceStatusSharingContacts = builder.mDeviceToDeviceStatusSharingContacts;
519         this.mIsNrAdvancedCallingEnabled = builder.mIsNrAdvancedCallingEnabled;
520         this.mNumberFromCarrier = builder.mNumberFromCarrier;
521         this.mNumberFromIms = builder.mNumberFromIms;
522         this.mPortIndex = builder.mPortIndex;
523         this.mUsageSetting = builder.mUsageSetting;
524         this.mLastUsedTPMessageReference = builder.mLastUsedTPMessageReference;
525         this.mUserId = builder.mUserId;
526         this.mIsSatelliteEnabled = builder.mIsSatelliteEnabled;
527 
528         // Below are the fields that do not exist in the SimInfo table.
529         this.mCardId = builder.mCardId;
530         this.mIsGroupDisabled = builder.mIsGroupDisabled;
531     }
532 
533     /**
534      * @return The subscription ID.
535      */
getSubscriptionId()536     public int getSubscriptionId() {
537         return mId;
538     }
539 
540     /**
541      * Returns the ICC ID.
542      *
543      * @return the ICC ID, or an empty string if one of these requirements is not met
544      */
545     @NonNull
getIccId()546     public String getIccId() {
547         return mIccId;
548     }
549 
550     /**
551      * @return The index of the SIM slot that currently contains the subscription and not
552      * necessarily unique and maybe {@link SubscriptionManager#INVALID_SIM_SLOT_INDEX} if unknown or
553      * the subscription is inactive.
554      */
getSimSlotIndex()555     public int getSimSlotIndex() {
556         return mSimSlotIndex;
557     }
558 
559     /**
560      * @return The name displayed to the user that identifies this subscription. This name is
561      * used in Settings page and can be renamed by the user.
562      *
563      * @see #getCarrierName()
564      */
565     @NonNull
getDisplayName()566     public String getDisplayName() {
567         return mDisplayName;
568     }
569 
570     /**
571      * @return The name displayed to the user that identifies subscription provider name. This name
572      * is the SPN displayed in status bar and many other places. Can't be renamed by the user.
573      *
574      * @see #getDisplayName()
575      */
576     @NonNull
getCarrierName()577     public String getCarrierName() {
578         return mCarrierName;
579     }
580 
581     /**
582      * @return The source of the {@link #getDisplayName()}.
583      */
584     @SimDisplayNameSource
getDisplayNameSource()585     public int getDisplayNameSource() {
586         return mDisplayNameSource;
587     }
588 
589     /**
590      * A highlight color to use in displaying information about this {@code PhoneAccount}.
591      *
592      * @return A hexadecimal color value.
593      */
594     @ColorInt
getIconTint()595     public int getIconTint() {
596         return mIconTint;
597     }
598 
599     /**
600      * @return the number of this subscription.
601      */
getNumber()602     public String getNumber() {
603         return mNumber;
604     }
605 
606     /**
607      * Whether user enables data roaming for this subscription or not. Either
608      * {@link SubscriptionManager#DATA_ROAMING_ENABLE} or
609      * {@link SubscriptionManager#DATA_ROAMING_DISABLE}.
610      */
getDataRoaming()611     public int getDataRoaming() {
612         return mDataRoaming;
613     }
614 
615     /**
616      * @return The mobile country code.
617      */
618     @NonNull
getMcc()619     public String getMcc() {
620         return mMcc;
621     }
622 
623     /**
624      * @return The mobile network code.
625      */
626     @NonNull
getMnc()627     public String getMnc() {
628         return mMnc;
629     }
630 
631     /**
632      * @return Extended home PLMNs associated with this subscription.
633      */
634     @NonNull
getEhplmns()635     public String getEhplmns() {
636         return mEhplmns;
637     }
638 
639     /**
640      * @return Home PLMNs associated with this subscription.
641      */
642     @NonNull
getHplmns()643     public String getHplmns() {
644         return mHplmns;
645     }
646 
647     /**
648      * @return {@code true} if the subscription is from eSIM.
649      */
isEmbedded()650     public boolean isEmbedded() {
651         return mIsEmbedded != 0;
652     }
653 
654     /**
655      * @return {@code 1} if the subscription is from eSIM.
656      */
getEmbedded()657     public int getEmbedded() {
658         return mIsEmbedded;
659     }
660 
661     /**
662      * Returns the card string of the SIM card which contains the subscription.
663      *
664      * @return The card string of the SIM card which contains the subscription. The card string is
665      * the ICCID for UICCs or the EID for
666      * eUICCs.
667      */
668     @NonNull
getCardString()669     public String getCardString() {
670         return mCardString;
671     }
672 
673     /**
674      * @return The access rules for this subscription, if it is embedded and defines any. This
675      * does not include access rules for non-embedded subscriptions. This is the raw string
676      * stored in the database.
677      */
678     @NonNull
getNativeAccessRules()679     public byte[] getNativeAccessRules() {
680         return mNativeAccessRules;
681     }
682 
683     /**
684      * @return The carrier certificates for this subscription that are saved in carrier configs.
685      * This does not include access rules from the Uicc, whether embedded or non-embedded. This
686      * is the raw string stored in the database.
687      */
getCarrierConfigAccessRules()688     public byte[] getCarrierConfigAccessRules() {
689         return mCarrierConfigAccessRules;
690     }
691 
692     /**
693      * @return {@code true} if an embedded subscription is on a removable card. Such subscriptions
694      * are marked inaccessible as soon as the current card is removed. Otherwise, they will remain
695      * accessible unless explicitly deleted. Only meaningful when {@link #getEmbedded()} is 1.
696      */
isRemovableEmbedded()697     public boolean isRemovableEmbedded() {
698         return mIsRemovableEmbedded != 0;
699     }
700 
701     /**
702      * @return {@code 1} if an embedded subscription is on a removable card. Such subscriptions are
703      * marked inaccessible as soon as the current card is removed. Otherwise, they will remain
704      * accessible unless explicitly deleted. Only meaningful when {@link #getEmbedded()} is 1.
705      */
getRemovableEmbedded()706     public int getRemovableEmbedded() {
707         return mIsRemovableEmbedded;
708     }
709 
710     /**
711      * @return {@code 1} if cell broadcast extreme threat alert is enabled by the user.
712      */
getCellBroadcastExtremeThreatAlertEnabled()713     public int getCellBroadcastExtremeThreatAlertEnabled() {
714         return mIsExtremeThreatAlertEnabled;
715     }
716 
717     /**
718      * @return {@code 1} if cell broadcast amber alert is enabled by the user.
719      */
getCellBroadcastSevereThreatAlertEnabled()720     public int getCellBroadcastSevereThreatAlertEnabled() {
721         return mIsSevereThreatAlertEnabled;
722     }
723 
724     /**
725      * @return {@code 1} if cell broadcast emergency alert is enabled by the user.
726      */
getCellBroadcastAmberAlertEnabled()727     public int getCellBroadcastAmberAlertEnabled() {
728         return mIsAmberAlertEnabled;
729     }
730 
731     /**
732      * @return {@code 1} if cell broadcast emergency alert is enabled by the user.
733      */
getCellBroadcastEmergencyAlertEnabled()734     public int getCellBroadcastEmergencyAlertEnabled() {
735         return mIsEmergencyAlertEnabled;
736     }
737 
738     /**
739      * @return {@code 1} if cell broadcast alert sound duration in seconds.
740      */
getCellBroadcastAlertSoundDuration()741     public int getCellBroadcastAlertSoundDuration() {
742         return mAlertSoundDuration;
743     }
744 
745     /**
746      * @return Cell broadcast alert reminder interval in minutes.
747      */
getCellBroadcastAlertReminderInterval()748     public int getCellBroadcastAlertReminderInterval() {
749         return mReminderInterval;
750     }
751 
752     /**
753      * @return {@code 1} if cell broadcast alert vibration is enabled by the user.
754      */
getCellBroadcastAlertVibrationEnabled()755     public int getCellBroadcastAlertVibrationEnabled() {
756         return mIsAlertVibrationEnabled;
757     }
758 
759     /**
760      * @return {@code 1} if cell broadcast alert speech is enabled by the user.
761      */
getCellBroadcastAlertSpeechEnabled()762     public int getCellBroadcastAlertSpeechEnabled() {
763         return mIsAlertSpeechEnabled;
764     }
765 
766     /**
767      * @return {@code 1} if ETWS test alert is enabled by the user.
768      */
getCellBroadcastEtwsTestAlertEnabled()769     public int getCellBroadcastEtwsTestAlertEnabled() {
770         return mIsEtwsTestAlertEnabled;
771     }
772 
773     /**
774      * @return {@code 1} if area info message is enabled by the user.
775      */
getCellBroadcastAreaInfoMessageEnabled()776     public int getCellBroadcastAreaInfoMessageEnabled() {
777         return mIsAreaInfoMessageEnabled;
778     }
779 
780     /**
781      * @return {@code 1} if cell broadcast test alert is enabled by the user.
782      */
getCellBroadcastTestAlertEnabled()783     public int getCellBroadcastTestAlertEnabled() {
784         return mIsTestAlertEnabled;
785     }
786 
787     /**
788      * @return {@code 1} if cell broadcast opt-out dialog should be shown.
789      */
getCellBroadcastOptOutDialogEnabled()790     public int getCellBroadcastOptOutDialogEnabled() {
791         return mIsOptOutDialogEnabled;
792     }
793 
794     /**
795      * @return {@code true} if enhanced 4G mode is enabled by the user or not.
796      */
isEnhanced4GModeEnabled()797     public boolean isEnhanced4GModeEnabled() {
798         return mIsEnhanced4GModeEnabled == 1;
799     }
800 
801     /**
802      * @return {@code 1} if enhanced 4G mode is enabled by the user or not. {@code 0} if disabled.
803      * {@code -1} if the user did not change any setting.
804      */
getEnhanced4GModeEnabled()805     public int getEnhanced4GModeEnabled() {
806         return mIsEnhanced4GModeEnabled;
807     }
808 
809     /**
810      * @return {@code true} if video telephony is enabled by the user or not.
811      */
isVideoTelephonyEnabled()812     public boolean isVideoTelephonyEnabled() {
813         return mIsVideoTelephonyEnabled != 0;
814     }
815 
816     /**
817      * @return {@code 1} if video telephony is enabled by the user or not.
818      */
getVideoTelephonyEnabled()819     public int getVideoTelephonyEnabled() {
820         return mIsVideoTelephonyEnabled;
821     }
822 
823     /**
824      * @return {@code true} if Wi-Fi calling is enabled by the user or not when the device is not
825      * roaming.
826      */
isWifiCallingEnabled()827     public boolean isWifiCallingEnabled() {
828         return mIsWifiCallingEnabled == 1;
829     }
830 
831     /**
832      * @return {@code 1} if Wi-Fi calling is enabled by the user or not when the device is not
833      * roaming. {@code 0} if disabled. {@code -1} if the user did not change any setting.
834      */
getWifiCallingEnabled()835     public int getWifiCallingEnabled() {
836         return mIsWifiCallingEnabled;
837     }
838 
839     /**
840      * @return Wi-Fi calling mode when the device is not roaming.
841      */
842     @ImsMmTelManager.WiFiCallingMode
getWifiCallingMode()843     public int getWifiCallingMode() {
844         return mWifiCallingMode;
845     }
846 
847     /**
848      * @return Wi-Fi calling mode when the device is roaming.
849      */
850     @ImsMmTelManager.WiFiCallingMode
getWifiCallingModeForRoaming()851     public int getWifiCallingModeForRoaming() {
852         return mWifiCallingModeForRoaming;
853     }
854 
855     /**
856      * @return {@code true} if Wi-Fi calling is enabled by the user or not when the device is
857      * roaming. {@code 0} if disabled. {@code -1} if the user did not change any setting.
858      */
isWifiCallingEnabledForRoaming()859     public boolean isWifiCallingEnabledForRoaming() {
860         return mIsWifiCallingEnabledForRoaming == 1;
861     }
862 
863     /**
864      * @return {@code 1} if Wi-Fi calling is enabled by the user or not when the device is roaming.
865      */
getWifiCallingEnabledForRoaming()866     public int getWifiCallingEnabledForRoaming() {
867         return mIsWifiCallingEnabledForRoaming;
868     }
869 
870     /**
871      * An opportunistic subscription connects to a network that is
872      * limited in functionality and / or coverage.
873      *
874      * @return {@code true} if subscription is opportunistic.
875      */
isOpportunistic()876     public boolean isOpportunistic() {
877         return mIsOpportunistic != 0;
878     }
879 
880     /**
881      * An opportunistic subscription connects to a network that is
882      * limited in functionality and / or coverage.
883      *
884      * @return {@code 1} if subscription is opportunistic.
885      */
getOpportunistic()886     public int getOpportunistic() {
887         return mIsOpportunistic;
888     }
889 
890     /**
891      * Used in scenarios where different subscriptions are bundled as a group.
892      * It's typically a primary and an opportunistic subscription. (see {@link #getOpportunistic()})
893      * Such that those subscriptions will have some affiliated behaviors such as opportunistic
894      * subscription may be invisible to the user.
895      *
896      * @return Group UUID in string format.
897      */
898     @NonNull
getGroupUuid()899     public String getGroupUuid() {
900         return mGroupUuid;
901     }
902 
903     /**
904      * @return The ISO country code. Empty if not available.
905      */
getCountryIso()906     public String getCountryIso() {
907         return mCountryIso;
908     }
909 
910     /**
911      * @return The carrier id of this subscription carrier.
912      *
913      * @see TelephonyManager#getSimCarrierId()
914      */
getCarrierId()915     public int getCarrierId() {
916         return mCarrierId;
917     }
918 
919     /**
920      * @return The profile class populated from the profile metadata if present. Otherwise,
921      * the profile class defaults to {@link SubscriptionManager#PROFILE_CLASS_UNSET} if there is no
922      * profile metadata or the subscription is not on an eUICC ({@link #getEmbedded} return
923      * {@code 0}).
924      */
925     @ProfileClass
getProfileClass()926     public int getProfileClass() {
927         return mProfileClass;
928     }
929 
930     /**
931      * This method returns the type of a subscription. It can be
932      * {@link SubscriptionManager#SUBSCRIPTION_TYPE_LOCAL_SIM} or
933      * {@link SubscriptionManager#SUBSCRIPTION_TYPE_REMOTE_SIM}.
934      *
935      * @return The type of the subscription.
936      */
937     @SubscriptionType
getSubscriptionType()938     public int getSubscriptionType() {
939         return mType;
940     }
941 
942     /**
943      * @return The owner package of group the subscription belongs to.
944      */
945     @NonNull
getGroupOwner()946     public String getGroupOwner() {
947         return mGroupOwner;
948     }
949 
950     /**
951      * @return The enabled mobile data policies in string format.
952      *
953      * @see com.android.internal.telephony.data.DataSettingsManager#getMobileDataPolicyEnabled
954      */
955     @NonNull
getEnabledMobileDataPolicies()956     public String getEnabledMobileDataPolicies() {
957         return mEnabledMobileDataPolicies;
958     }
959 
960     /**
961      * @return The IMSI (International Mobile Subscriber Identity) of the subscription.
962      */
963     @NonNull
getImsi()964     public String getImsi() {
965         return mImsi;
966     }
967 
968     /**
969      * @return {@code true} if Uicc applications are set to be enabled or disabled.
970      */
areUiccApplicationsEnabled()971     public boolean areUiccApplicationsEnabled() {
972         return mAreUiccApplicationsEnabled != 0;
973     }
974 
975     /**
976      * @return {@code 1} if Uicc applications are set to be enabled or disabled.
977      */
getUiccApplicationsEnabled()978     public int getUiccApplicationsEnabled() {
979         return mAreUiccApplicationsEnabled;
980     }
981 
982     /**
983      * @return {@code true} if the user has enabled IMS RCS User Capability Exchange (UCE) for this
984      * subscription.
985      */
isRcsUceEnabled()986     public boolean isRcsUceEnabled() {
987         return mIsRcsUceEnabled != 0;
988     }
989 
990     /**
991      * @return {@code 1} if the user has enabled IMS RCS User Capability Exchange (UCE) for this
992      * subscription.
993      */
getRcsUceEnabled()994     public int getRcsUceEnabled() {
995         return mIsRcsUceEnabled;
996     }
997 
998     /**
999      * @return {@code true} if the user has enabled cross SIM calling for this subscription.
1000      */
isCrossSimCallingEnabled()1001     public boolean isCrossSimCallingEnabled() {
1002         return mIsCrossSimCallingEnabled != 0;
1003     }
1004 
1005     /**
1006      * @return {@code 1} if the user has enabled cross SIM calling for this subscription.
1007      */
getCrossSimCallingEnabled()1008     public int getCrossSimCallingEnabled() {
1009         return mIsCrossSimCallingEnabled;
1010     }
1011 
1012     /**
1013      * @return The RCS configuration.
1014      */
1015     @NonNull
getRcsConfig()1016     public byte[] getRcsConfig() {
1017         return mRcsConfig;
1018     }
1019 
1020     /**
1021      * The allowed network types for reasons in string format. The format is
1022      * "[reason]=[network types bitmask], [reason]=[network types bitmask], ..."
1023      *
1024      * For example, "user=1239287394, thermal=298791239, carrier=3456812312".
1025      */
1026     @NonNull
getAllowedNetworkTypesForReasons()1027     public String getAllowedNetworkTypesForReasons() {
1028         return mAllowedNetworkTypesForReasons;
1029     }
1030 
1031     /**
1032      * @return Device to device sharing status.
1033      */
1034     @DeviceToDeviceStatusSharingPreference
getDeviceToDeviceStatusSharingPreference()1035     public int getDeviceToDeviceStatusSharingPreference() {
1036         return mDeviceToDeviceStatusSharingPreference;
1037     }
1038 
1039     /**
1040      * @return {@code true} if the user has opted-in voice over IMS.
1041      */
isVoImsOptInEnabled()1042     public boolean isVoImsOptInEnabled() {
1043         return mIsVoImsOptInEnabled != 0;
1044     }
1045 
1046     /**
1047      * @return {@code 1} if the user has opted-in voice over IMS.
1048      */
getVoImsOptInEnabled()1049     public int getVoImsOptInEnabled() {
1050         return mIsVoImsOptInEnabled;
1051     }
1052 
1053     /**
1054      * @return Contacts information that allow device to device sharing.
1055      */
1056     @NonNull
getDeviceToDeviceStatusSharingContacts()1057     public String getDeviceToDeviceStatusSharingContacts() {
1058         return mDeviceToDeviceStatusSharingContacts;
1059     }
1060 
1061     /**
1062      * @return {@code true} if the user has enabled NR advanced calling.
1063      */
isNrAdvancedCallingEnabled()1064     public boolean isNrAdvancedCallingEnabled() {
1065         return mIsNrAdvancedCallingEnabled == 1;
1066     }
1067 
1068     /**
1069      * @return {@code 1} if the user has enabled NR advanced calling. {code 0} if disabled.
1070      * {code -1} if the user did not change any setting.
1071      */
getNrAdvancedCallingEnabled()1072     public int getNrAdvancedCallingEnabled() {
1073         return mIsNrAdvancedCallingEnabled;
1074     }
1075 
1076     /**
1077      * @return Get the phone number retrieved from carrier.
1078      */
1079     @NonNull
getNumberFromCarrier()1080     public String getNumberFromCarrier() {
1081         return mNumberFromCarrier;
1082     }
1083 
1084     /**
1085      * @return Get the phone number retrieved from IMS.
1086      */
1087     @NonNull
getNumberFromIms()1088     public String getNumberFromIms() {
1089         return mNumberFromIms;
1090     }
1091 
1092     /**
1093      * @return The port index of the SIM card which contains the subscription.
1094      */
getPortIndex()1095     public int getPortIndex() {
1096         return mPortIndex;
1097     }
1098 
1099     /**
1100      * Get the usage setting for this subscription.
1101      *
1102      * @return The usage setting used for this subscription.
1103      */
1104     @UsageSetting
getUsageSetting()1105     public int getUsageSetting() {
1106         return mUsageSetting;
1107     }
1108 
1109     /**
1110      * @return Last used TP message reference.
1111      */
getLastUsedTPMessageReference()1112     public int getLastUsedTPMessageReference() {
1113         return mLastUsedTPMessageReference;
1114     }
1115 
1116     /**
1117      * @return The user id associated with this subscription.
1118      */
1119     @UserIdInt
getUserId()1120     public int getUserId() {
1121         return mUserId;
1122     }
1123 
1124     /**
1125      * @return {@code 1} if satellite is enabled.
1126      */
getSatelliteEnabled()1127     public int getSatelliteEnabled() {
1128         return mIsSatelliteEnabled;
1129     }
1130 
1131     // Below are the fields that do not exist in SimInfo table.
1132     /**
1133      * @return The card ID of the SIM card which contains the subscription.
1134      *
1135      * @see android.telephony.UiccCardInfo#getCardId().
1136      */
getCardId()1137     public int getCardId() {
1138         return mCardId;
1139     }
1140 
1141     /**
1142      * @return {@code true} if the group of the subscription is disabled. This is only useful if
1143      * it's a grouped opportunistic subscription. In this case, if all primary (non-opportunistic)
1144      * subscriptions in the group are deactivated (unplugged pSIM or deactivated eSIM profile), we
1145      * should disable this opportunistic subscription.
1146      */
isGroupDisabled()1147     public boolean isGroupDisabled() {
1148         return mIsGroupDisabled;
1149     }
1150 
1151     /**
1152      * @return {@code true} if the subscription is from the actively used SIM.
1153      */
isActive()1154     public boolean isActive() {
1155         return mSimSlotIndex >= 0 || mType == SubscriptionManager.SUBSCRIPTION_TYPE_REMOTE_SIM;
1156     }
1157 
1158     /**
1159      * @return {@code true} if the subscription is visible to the user.
1160      */
isVisible()1161     public boolean isVisible() {
1162         return !isOpportunistic() || TextUtils.isEmpty(mGroupUuid);
1163     }
1164 
1165     /** @return converted {@link SubscriptionInfo}. */
1166     @NonNull
toSubscriptionInfo()1167     public SubscriptionInfo toSubscriptionInfo() {
1168         return new SubscriptionInfo.Builder()
1169                 .setId(mId)
1170                 .setIccId(mIccId)
1171                 .setSimSlotIndex(mSimSlotIndex)
1172                 .setDisplayName(mDisplayName)
1173                 .setCarrierName(mCarrierName)
1174                 .setDisplayNameSource(mDisplayNameSource)
1175                 .setIconTint(mIconTint)
1176                 .setNumber(mNumber)
1177                 .setDataRoaming(mDataRoaming)
1178                 .setMcc(mMcc)
1179                 .setMnc(mMnc)
1180                 .setEhplmns(TextUtils.isEmpty(mEhplmns) ? null : mEhplmns.split(","))
1181                 .setHplmns(TextUtils.isEmpty(mHplmns) ? null : mHplmns.split(","))
1182                 .setCountryIso(mCountryIso)
1183                 .setEmbedded(mIsEmbedded != 0)
1184                 .setNativeAccessRules(mNativeAccessRules.length == 0
1185                         ? null : UiccAccessRule.decodeRules(mNativeAccessRules))
1186                 .setCardString(mCardString)
1187                 .setCardId(mCardId)
1188                 .setOpportunistic(mIsOpportunistic != 0)
1189                 .setGroupUuid(mGroupUuid)
1190                 .setGroupDisabled(mIsGroupDisabled)
1191                 .setCarrierId(mCarrierId)
1192                 .setProfileClass(mProfileClass)
1193                 .setType(mType)
1194                 .setGroupOwner(mGroupOwner)
1195                 .setCarrierConfigAccessRules(mCarrierConfigAccessRules.length == 0
1196                         ? null : UiccAccessRule.decodeRules(mCarrierConfigAccessRules))
1197                 .setUiccApplicationsEnabled(mAreUiccApplicationsEnabled != 0)
1198                 .setPortIndex(mPortIndex)
1199                 .setUsageSetting(mUsageSetting)
1200                 .build();
1201     }
1202 
1203     @Override
toString()1204     public String toString() {
1205         return "[SubscriptionInfoInternal: id=" + mId
1206                 + " iccId=" + SubscriptionInfo.getPrintableId(mIccId)
1207                 + " simSlotIndex=" + mSimSlotIndex
1208                 + " portIndex=" + mPortIndex
1209                 + " isEmbedded=" + mIsEmbedded
1210                 + " isRemovableEmbedded=" + mIsRemovableEmbedded
1211                 + " carrierId=" + mCarrierId
1212                 + " displayName=" + mDisplayName
1213                 + " carrierName=" + mCarrierName
1214                 + " isOpportunistic=" + mIsOpportunistic
1215                 + " groupUuid=" + mGroupUuid
1216                 + " groupOwner=" + mGroupOwner
1217                 + " displayNameSource="
1218                 + SubscriptionManager.displayNameSourceToString(mDisplayNameSource)
1219                 + " iconTint=" + mIconTint
1220                 + " number=" + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, mNumber)
1221                 + " dataRoaming=" + mDataRoaming
1222                 + " mcc=" + mMcc
1223                 + " mnc=" + mMnc
1224                 + " ehplmns=" + mEhplmns
1225                 + " hplmns=" + mHplmns
1226                 + " cardString=" + SubscriptionInfo.getPrintableId(mCardString)
1227                 + " cardId=" + mCardId
1228                 + " nativeAccessRules=" + IccUtils.bytesToHexString(mNativeAccessRules)
1229                 + " carrierConfigAccessRules=" + IccUtils.bytesToHexString(
1230                         mCarrierConfigAccessRules)
1231                 + " countryIso=" + mCountryIso
1232                 + " profileClass=" + mProfileClass
1233                 + " type=" + SubscriptionManager.subscriptionTypeToString(mType)
1234                 + " areUiccApplicationsEnabled=" + mAreUiccApplicationsEnabled
1235                 + " usageSetting=" + SubscriptionManager.usageSettingToString(mUsageSetting)
1236                 + " isEnhanced4GModeEnabled=" + mIsEnhanced4GModeEnabled
1237                 + " isVideoTelephonyEnabled=" + mIsVideoTelephonyEnabled
1238                 + " isWifiCallingEnabled=" + mIsWifiCallingEnabled
1239                 + " isWifiCallingEnabledForRoaming=" + mIsWifiCallingEnabledForRoaming
1240                 + " wifiCallingMode=" + ImsMmTelManager.wifiCallingModeToString(mWifiCallingMode)
1241                 + " wifiCallingModeForRoaming="
1242                 + ImsMmTelManager.wifiCallingModeToString(mWifiCallingModeForRoaming)
1243                 + " enabledMobileDataPolicies=" + mEnabledMobileDataPolicies
1244                 + " imsi=" + SubscriptionInfo.getPrintableId(mImsi)
1245                 + " rcsUceEnabled=" + mIsRcsUceEnabled
1246                 + " crossSimCallingEnabled=" + mIsCrossSimCallingEnabled
1247                 + " rcsConfig=" + IccUtils.bytesToHexString(mRcsConfig)
1248                 + " allowedNetworkTypesForReasons=" + mAllowedNetworkTypesForReasons
1249                 + " deviceToDeviceStatusSharingPreference=" + mDeviceToDeviceStatusSharingPreference
1250                 + " isVoImsOptInEnabled=" + mIsVoImsOptInEnabled
1251                 + " deviceToDeviceStatusSharingContacts=" + mDeviceToDeviceStatusSharingContacts
1252                 + " numberFromCarrier=" + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, mNumberFromCarrier)
1253                 + " numberFromIms=" + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, mNumberFromIms)
1254                 + " userId=" + mUserId
1255                 + " isSatelliteEnabled=" + mIsSatelliteEnabled
1256                 + " isGroupDisabled=" + mIsGroupDisabled
1257                 + "]";
1258     }
1259 
1260     @Override
equals(Object o)1261     public boolean equals(Object o) {
1262         if (this == o) return true;
1263         if (o == null || getClass() != o.getClass()) return false;
1264         SubscriptionInfoInternal that = (SubscriptionInfoInternal) o;
1265         return mId == that.mId && mSimSlotIndex == that.mSimSlotIndex
1266                 && mDisplayNameSource == that.mDisplayNameSource && mIconTint == that.mIconTint
1267                 && mDataRoaming == that.mDataRoaming && mIsEmbedded == that.mIsEmbedded
1268                 && mIsRemovableEmbedded == that.mIsRemovableEmbedded
1269                 && mIsExtremeThreatAlertEnabled == that.mIsExtremeThreatAlertEnabled
1270                 && mIsSevereThreatAlertEnabled == that.mIsSevereThreatAlertEnabled
1271                 && mIsAmberAlertEnabled == that.mIsAmberAlertEnabled
1272                 && mIsEmergencyAlertEnabled == that.mIsEmergencyAlertEnabled
1273                 && mAlertSoundDuration == that.mAlertSoundDuration
1274                 && mReminderInterval == that.mReminderInterval
1275                 && mIsAlertVibrationEnabled == that.mIsAlertVibrationEnabled
1276                 && mIsAlertSpeechEnabled == that.mIsAlertSpeechEnabled
1277                 && mIsEtwsTestAlertEnabled == that.mIsEtwsTestAlertEnabled
1278                 && mIsAreaInfoMessageEnabled == that.mIsAreaInfoMessageEnabled
1279                 && mIsEnhanced4GModeEnabled == that.mIsEnhanced4GModeEnabled
1280                 && mIsVideoTelephonyEnabled == that.mIsVideoTelephonyEnabled
1281                 && mIsWifiCallingEnabled == that.mIsWifiCallingEnabled
1282                 && mWifiCallingMode == that.mWifiCallingMode
1283                 && mWifiCallingModeForRoaming == that.mWifiCallingModeForRoaming
1284                 && mIsWifiCallingEnabledForRoaming == that.mIsWifiCallingEnabledForRoaming
1285                 && mIsOpportunistic == that.mIsOpportunistic && mCarrierId == that.mCarrierId
1286                 && mProfileClass == that.mProfileClass && mType == that.mType
1287                 && mAreUiccApplicationsEnabled == that.mAreUiccApplicationsEnabled
1288                 && mIsRcsUceEnabled == that.mIsRcsUceEnabled
1289                 && mIsCrossSimCallingEnabled == that.mIsCrossSimCallingEnabled
1290                 && mDeviceToDeviceStatusSharingPreference
1291                 == that.mDeviceToDeviceStatusSharingPreference
1292                 && mIsVoImsOptInEnabled == that.mIsVoImsOptInEnabled
1293                 && mIsNrAdvancedCallingEnabled == that.mIsNrAdvancedCallingEnabled
1294                 && mPortIndex == that.mPortIndex && mUsageSetting == that.mUsageSetting
1295                 && mLastUsedTPMessageReference == that.mLastUsedTPMessageReference
1296                 && mUserId == that.mUserId && mIsSatelliteEnabled == that.mIsSatelliteEnabled
1297                 && mCardId == that.mCardId && mIsGroupDisabled == that.mIsGroupDisabled
1298                 && mIccId.equals(that.mIccId) && mDisplayName.equals(that.mDisplayName)
1299                 && mCarrierName.equals(that.mCarrierName) && mNumber.equals(that.mNumber)
1300                 && mMcc.equals(that.mMcc) && mMnc.equals(that.mMnc) && mEhplmns.equals(
1301                 that.mEhplmns)
1302                 && mHplmns.equals(that.mHplmns) && mCardString.equals(that.mCardString)
1303                 && Arrays.equals(mNativeAccessRules, that.mNativeAccessRules)
1304                 && Arrays.equals(mCarrierConfigAccessRules, that.mCarrierConfigAccessRules)
1305                 && mGroupUuid.equals(that.mGroupUuid) && mCountryIso.equals(that.mCountryIso)
1306                 && mGroupOwner.equals(that.mGroupOwner) && mEnabledMobileDataPolicies.equals(
1307                 that.mEnabledMobileDataPolicies) && mImsi.equals(that.mImsi) && Arrays.equals(
1308                 mRcsConfig, that.mRcsConfig) && mAllowedNetworkTypesForReasons.equals(
1309                 that.mAllowedNetworkTypesForReasons) && mDeviceToDeviceStatusSharingContacts.equals(
1310                 that.mDeviceToDeviceStatusSharingContacts) && mNumberFromCarrier.equals(
1311                 that.mNumberFromCarrier) && mNumberFromIms.equals(that.mNumberFromIms);
1312     }
1313 
1314     @Override
hashCode()1315     public int hashCode() {
1316         int result = Objects.hash(mId, mIccId, mSimSlotIndex, mDisplayName, mCarrierName,
1317                 mDisplayNameSource, mIconTint, mNumber, mDataRoaming, mMcc, mMnc, mEhplmns, mHplmns,
1318                 mIsEmbedded, mCardString, mIsRemovableEmbedded, mIsExtremeThreatAlertEnabled,
1319                 mIsSevereThreatAlertEnabled, mIsAmberAlertEnabled, mIsEmergencyAlertEnabled,
1320                 mAlertSoundDuration, mReminderInterval, mIsAlertVibrationEnabled,
1321                 mIsAlertSpeechEnabled,
1322                 mIsEtwsTestAlertEnabled, mIsAreaInfoMessageEnabled, mIsEnhanced4GModeEnabled,
1323                 mIsVideoTelephonyEnabled, mIsWifiCallingEnabled, mWifiCallingMode,
1324                 mWifiCallingModeForRoaming, mIsWifiCallingEnabledForRoaming, mIsOpportunistic,
1325                 mGroupUuid, mCountryIso, mCarrierId, mProfileClass, mType, mGroupOwner,
1326                 mEnabledMobileDataPolicies, mImsi, mAreUiccApplicationsEnabled, mIsRcsUceEnabled,
1327                 mIsCrossSimCallingEnabled, mAllowedNetworkTypesForReasons,
1328                 mDeviceToDeviceStatusSharingPreference, mIsVoImsOptInEnabled,
1329                 mDeviceToDeviceStatusSharingContacts, mIsNrAdvancedCallingEnabled,
1330                 mNumberFromCarrier,
1331                 mNumberFromIms, mPortIndex, mUsageSetting, mLastUsedTPMessageReference, mUserId,
1332                 mIsSatelliteEnabled, mCardId, mIsGroupDisabled);
1333         result = 31 * result + Arrays.hashCode(mNativeAccessRules);
1334         result = 31 * result + Arrays.hashCode(mCarrierConfigAccessRules);
1335         result = 31 * result + Arrays.hashCode(mRcsConfig);
1336         return result;
1337     }
1338 
1339     /**
1340      * The builder class of {@link SubscriptionInfoInternal}.
1341      */
1342     public static class Builder {
1343         /**
1344          * The subscription id.
1345          */
1346         private int mId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
1347 
1348         /**
1349          * The ICCID of the SIM that is associated with this subscription, empty if unknown.
1350          */
1351         @NonNull
1352         private String mIccId = "";
1353 
1354         /**
1355          * The index of the SIM slot that currently contains the subscription and not necessarily
1356          * unique and maybe {@link SubscriptionManager#INVALID_SIM_SLOT_INDEX} if unknown or the
1357          * subscription is inactive.
1358          */
1359         private int mSimSlotIndex = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
1360 
1361         /**
1362          * The name displayed to the user that identifies this subscription. This name is used
1363          * in Settings page and can be renamed by the user.
1364          */
1365         @NonNull
1366         private String mDisplayName = "";
1367 
1368         /**
1369          * The name displayed to the user that identifies subscription provider name. This name
1370          * is the SPN displayed in status bar and many other places. Can't be renamed by the user.
1371          */
1372         @NonNull
1373         private String mCarrierName = "";
1374 
1375         /**
1376          * The source of the display name.
1377          */
1378         @SimDisplayNameSource
1379         private int mDisplayNameSource = SubscriptionManager.NAME_SOURCE_UNKNOWN;
1380 
1381         /**
1382          * The color to be used for tinting the icon when displaying to the user.
1383          */
1384         private int mIconTint = 0;
1385 
1386         /**
1387          * The number presented to the user identify this subscription.
1388          */
1389         @NonNull
1390         private String mNumber = "";
1391 
1392         /**
1393          * Whether user enables data roaming for this subscription or not. Either
1394          * {@link SubscriptionManager#DATA_ROAMING_ENABLE} or
1395          * {@link SubscriptionManager#DATA_ROAMING_DISABLE}.
1396          */
1397         private int mDataRoaming = SubscriptionManager.DATA_ROAMING_DISABLE;
1398 
1399         /**
1400          * The mobile country code.
1401          */
1402         @NonNull
1403         private String mMcc = "";
1404 
1405         /**
1406          * The mobile network code.
1407          */
1408         @NonNull
1409         private String mMnc = "";
1410 
1411         /**
1412          * EHPLMNs associated with the subscription.
1413          */
1414         @NonNull
1415         private String mEhplmns = "";
1416 
1417         /**
1418          * HPLMNs associated with the subscription.
1419          */
1420         @NonNull
1421         private String mHplmns = "";
1422 
1423         /**
1424          * Whether the subscription is from eSIM.
1425          */
1426         private int mIsEmbedded = 0;
1427 
1428         /**
1429          * The card string of the SIM card.
1430          */
1431         @NonNull
1432         private String mCardString = "";
1433 
1434         /**
1435          * The native access rules for this subscription, if it is embedded and defines any. This
1436          * does not include access rules for non-embedded subscriptions.
1437          */
1438         @NonNull
1439         private byte[] mNativeAccessRules = new byte[0];
1440 
1441         /**
1442          * The carrier certificates for this subscription that are saved in carrier configs.
1443          * This does not include access rules from the Uicc, whether embedded or non-embedded.
1444          */
1445         @NonNull
1446         private byte[] mCarrierConfigAccessRules = new byte[0];
1447 
1448         /**
1449          * Whether an embedded subscription is on a removable card. Such subscriptions are marked
1450          * inaccessible as soon as the current card is removed. Otherwise, they will remain
1451          * accessible unless explicitly deleted. Only meaningful when {@link #getEmbedded()} is
1452          * {@code 1}.
1453          */
1454         private int mIsRemovableEmbedded = 0;
1455 
1456         /**
1457          * Whether cell broadcast extreme threat alert is enabled by the user or not.
1458          */
1459         private int mIsExtremeThreatAlertEnabled = 1;
1460 
1461         /**
1462          * Whether cell broadcast severe threat alert is enabled by the user or not.
1463          */
1464         private int mIsSevereThreatAlertEnabled = 1;
1465 
1466         /**
1467          * Whether cell broadcast amber alert is enabled by the user or not.
1468          */
1469         private int mIsAmberAlertEnabled = 1;
1470 
1471         /**
1472          * Whether cell broadcast emergency alert is enabled by the user or not.
1473          */
1474         private int mIsEmergencyAlertEnabled = 1;
1475 
1476         /**
1477          * Cell broadcast alert sound duration in seconds.
1478          */
1479         private int mAlertSoundDuration = 4;
1480 
1481         /**
1482          * Cell broadcast alert reminder interval in minutes.
1483          */
1484         private int mReminderInterval = 0;
1485 
1486         /**
1487          * Whether cell broadcast alert vibration is enabled by the user or not.
1488          */
1489         private int mIsAlertVibrationEnabled = 1;
1490 
1491         /**
1492          * Whether cell broadcast alert speech is enabled by the user or not.
1493          */
1494         private int mIsAlertSpeechEnabled = 1;
1495 
1496         /**
1497          * Whether ETWS test alert is enabled by the user or not.
1498          */
1499         private int mIsEtwsTestAlertEnabled = 0;
1500 
1501         /**
1502          * Whether area info message is enabled by the user or not.
1503          */
1504         private int mIsAreaInfoMessageEnabled = 1;
1505 
1506         /**
1507          * Whether cell broadcast test alert is enabled by the user or not.
1508          */
1509         private int mIsTestAlertEnabled = 0;
1510 
1511         /**
1512          * Whether cell broadcast opt-out dialog should be shown or not.
1513          */
1514         private int mIsOptOutDialogEnabled = 1;
1515 
1516         /**
1517          * Whether enhanced 4G mode is enabled by the user or not.
1518          */
1519         private int mIsEnhanced4GModeEnabled = -1;
1520 
1521         /**
1522          * Whether video telephony is enabled by the user or not.
1523          */
1524         private int mIsVideoTelephonyEnabled = -1;
1525 
1526         /**
1527          * Whether Wi-Fi calling is enabled by the user or not when the device is not roaming.
1528          */
1529         private int mIsWifiCallingEnabled = -1;
1530 
1531         /**
1532          * Wi-Fi calling mode when the device is not roaming.
1533          */
1534         @ImsMmTelManager.WiFiCallingMode
1535         private int mWifiCallingMode = ImsMmTelManager.WIFI_MODE_UNKNOWN;
1536 
1537         /**
1538          * Wi-Fi calling mode when the device is roaming.
1539          */
1540         @ImsMmTelManager.WiFiCallingMode
1541         private int mWifiCallingModeForRoaming = ImsMmTelManager.WIFI_MODE_UNKNOWN;
1542 
1543         /**
1544          * Whether Wi-Fi calling is enabled by the user or not when the device is roaming.
1545          */
1546         private int mIsWifiCallingEnabledForRoaming = -1;
1547 
1548         /**
1549          * Whether the subscription is opportunistic or not.
1550          */
1551         private int mIsOpportunistic = 0;
1552 
1553         /**
1554          * The group UUID of the subscription group in string format.
1555          */
1556         @NonNull
1557         private String mGroupUuid = "";
1558 
1559         /**
1560          * The ISO Country code for the subscription's provider.
1561          */
1562         @NonNull
1563         private String mCountryIso = "";
1564 
1565         /**
1566          * The carrier id.
1567          *
1568          * @see TelephonyManager#getSimCarrierId()
1569          */
1570         private int mCarrierId = TelephonyManager.UNKNOWN_CARRIER_ID;
1571 
1572         /**
1573          * The profile class populated from the profile metadata if present. Otherwise, the profile
1574          * class defaults to {@link SubscriptionManager#PROFILE_CLASS_UNSET} if there is no profile
1575          * metadata or the subscription is not on an eUICC ({@link #getEmbedded} returns
1576          * {@code 0}).
1577          */
1578         @ProfileClass
1579         private int mProfileClass = SubscriptionManager.PROFILE_CLASS_UNSET;
1580 
1581         /**
1582          * The subscription type.
1583          */
1584         @SubscriptionType
1585         private int mType = SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM;
1586 
1587         /**
1588          * The owner package of group the subscription belongs to.
1589          */
1590         @NonNull
1591         private String mGroupOwner = "";
1592 
1593         /**
1594          * The enabled mobile data policies in string format.
1595          */
1596         @NonNull
1597         private String mEnabledMobileDataPolicies = "";
1598 
1599         /**
1600          * The IMSI (International Mobile Subscriber Identity) of the subscription.
1601          */
1602         @NonNull
1603         private String mImsi = "";
1604 
1605         /**
1606          * Whether Uicc applications are configured to enable or not.
1607          */
1608         private int mAreUiccApplicationsEnabled = 1;
1609 
1610         /**
1611          * Whether the user has enabled IMS RCS User Capability Exchange (UCE) for this
1612          * subscription.
1613          */
1614         private int mIsRcsUceEnabled = 0;
1615 
1616         /**
1617          * Whether the user has enabled cross SIM calling for this subscription.
1618          */
1619         private int mIsCrossSimCallingEnabled = 0;
1620 
1621         /**
1622          * The RCS configuration.
1623          */
1624         private byte[] mRcsConfig = new byte[0];
1625 
1626         /**
1627          * The allowed network types for reasons in string format. The format is
1628          * "[reason]=[network types bitmask], [reason]=[network types bitmask], ..."
1629          *
1630          * For example, "user=1239287394, thermal=298791239, carrier=3456812312".
1631          */
1632         private String mAllowedNetworkTypesForReasons = "";
1633 
1634         /**
1635          * Device to device sharing status.
1636          */
1637         @DeviceToDeviceStatusSharingPreference
1638         private int mDeviceToDeviceStatusSharingPreference =
1639                 SubscriptionManager.D2D_SHARING_DISABLED;
1640 
1641         /**
1642          * Whether the user has opted-in voice over IMS.
1643          */
1644         private int mIsVoImsOptInEnabled = 0;
1645 
1646         /**
1647          * Contacts information that allow device to device sharing.
1648          */
1649         @NonNull
1650         private String mDeviceToDeviceStatusSharingContacts = "";
1651 
1652         /**
1653          * Whether the user has enabled NR advanced calling.
1654          */
1655         private int mIsNrAdvancedCallingEnabled = -1;
1656 
1657         /**
1658          * The phone number retrieved from carrier.
1659          */
1660         @NonNull
1661         private String mNumberFromCarrier = "";
1662 
1663         /**
1664          * The phone number retrieved from IMS.
1665          */
1666         @NonNull
1667         private String mNumberFromIms = "";
1668 
1669         /**
1670          * the port index of the Uicc card.
1671          */
1672         private int mPortIndex = TelephonyManager.INVALID_PORT_INDEX;
1673 
1674         /**
1675          * Subscription's preferred usage setting.
1676          */
1677         @UsageSetting
1678         private int mUsageSetting = SubscriptionManager.USAGE_SETTING_UNKNOWN;
1679 
1680         /**
1681          * Last used TP message reference.
1682          */
1683         private int mLastUsedTPMessageReference = -1;
1684 
1685         /**
1686          * The user id associated with this subscription.
1687          */
1688         private int mUserId = UserHandle.USER_NULL;
1689 
1690         /**
1691          * Whether satellite is enabled or not.
1692          */
1693         private int mIsSatelliteEnabled = -1;
1694 
1695         // The following fields do not exist in the SimInfo table.
1696         /**
1697          * The card ID of the SIM card which contains the subscription.
1698          */
1699         private int mCardId = TelephonyManager.UNINITIALIZED_CARD_ID;
1700 
1701         /**
1702          * Whether group of the subscription is disabled. This is only useful if it's a grouped
1703          * opportunistic subscription. In this case, if all primary (non-opportunistic)
1704          * subscriptions in the group are deactivated (unplugged pSIM or deactivated eSIM profile),
1705          * we should disable this opportunistic subscription.
1706          */
1707         private boolean mIsGroupDisabled;
1708 
1709         /**
1710          * Default constructor.
1711          */
Builder()1712         public Builder() {
1713         }
1714 
1715         /**
1716          * Constructor from {@link SubscriptionInfoInternal}.
1717          *
1718          * @param info The subscription info.
1719          */
Builder(@onNull SubscriptionInfoInternal info)1720         public Builder(@NonNull SubscriptionInfoInternal info) {
1721             mId = info.mId;
1722             mIccId = info.mIccId;
1723             mSimSlotIndex = info.mSimSlotIndex;
1724             mDisplayName = info.mDisplayName;
1725             mCarrierName = info.mCarrierName;
1726             mDisplayNameSource = info.mDisplayNameSource;
1727             mIconTint = info.mIconTint;
1728             mNumber = info.mNumber;
1729             mDataRoaming = info.mDataRoaming;
1730             mMcc = info.mMcc;
1731             mMnc = info.mMnc;
1732             mEhplmns = info.mEhplmns;
1733             mHplmns = info.mHplmns;
1734             mIsEmbedded = info.mIsEmbedded;
1735             mCardString = info.mCardString;
1736             mNativeAccessRules = info.mNativeAccessRules;
1737             mCarrierConfigAccessRules = info.mCarrierConfigAccessRules;
1738             mIsRemovableEmbedded = info.mIsRemovableEmbedded;
1739             mIsExtremeThreatAlertEnabled = info.mIsExtremeThreatAlertEnabled;
1740             mIsSevereThreatAlertEnabled = info.mIsSevereThreatAlertEnabled;
1741             mIsAmberAlertEnabled = info.mIsAmberAlertEnabled;
1742             mIsEmergencyAlertEnabled = info.mIsEmergencyAlertEnabled;
1743             mAlertSoundDuration = info.mAlertSoundDuration;
1744             mReminderInterval = info.mReminderInterval;
1745             mIsAlertVibrationEnabled = info.mIsAlertVibrationEnabled;
1746             mIsAlertSpeechEnabled = info.mIsAlertSpeechEnabled;
1747             mIsEtwsTestAlertEnabled = info.mIsEtwsTestAlertEnabled;
1748             mIsAreaInfoMessageEnabled = info.mIsAreaInfoMessageEnabled;
1749             mIsTestAlertEnabled = info.mIsTestAlertEnabled;
1750             mIsOptOutDialogEnabled = info.mIsOptOutDialogEnabled;
1751             mIsEnhanced4GModeEnabled = info.mIsEnhanced4GModeEnabled;
1752             mIsVideoTelephonyEnabled = info.mIsVideoTelephonyEnabled;
1753             mIsWifiCallingEnabled = info.mIsWifiCallingEnabled;
1754             mWifiCallingMode = info.mWifiCallingMode;
1755             mWifiCallingModeForRoaming = info.mWifiCallingModeForRoaming;
1756             mIsWifiCallingEnabledForRoaming = info.mIsWifiCallingEnabledForRoaming;
1757             mIsOpportunistic = info.mIsOpportunistic;
1758             mGroupUuid = info.mGroupUuid;
1759             mCountryIso = info.mCountryIso;
1760             mCarrierId = info.mCarrierId;
1761             mProfileClass = info.mProfileClass;
1762             mType = info.mType;
1763             mGroupOwner = info.mGroupOwner;
1764             mEnabledMobileDataPolicies = info.mEnabledMobileDataPolicies;
1765             mImsi = info.mImsi;
1766             mAreUiccApplicationsEnabled = info.mAreUiccApplicationsEnabled;
1767             mIsRcsUceEnabled = info.mIsRcsUceEnabled;
1768             mIsCrossSimCallingEnabled = info.mIsCrossSimCallingEnabled;
1769             mRcsConfig = info.mRcsConfig;
1770             mAllowedNetworkTypesForReasons = info.mAllowedNetworkTypesForReasons;
1771             mDeviceToDeviceStatusSharingPreference = info.mDeviceToDeviceStatusSharingPreference;
1772             mIsVoImsOptInEnabled = info.mIsVoImsOptInEnabled;
1773             mDeviceToDeviceStatusSharingContacts = info.mDeviceToDeviceStatusSharingContacts;
1774             mIsNrAdvancedCallingEnabled = info.mIsNrAdvancedCallingEnabled;
1775             mNumberFromCarrier = info.mNumberFromCarrier;
1776             mNumberFromIms = info.mNumberFromIms;
1777             mPortIndex = info.mPortIndex;
1778             mUsageSetting = info.mUsageSetting;
1779             mLastUsedTPMessageReference = info.getLastUsedTPMessageReference();
1780             mUserId = info.mUserId;
1781             mIsSatelliteEnabled = info.mIsSatelliteEnabled;
1782             // Below are the fields that do not exist in the SimInfo table.
1783             mCardId = info.mCardId;
1784             mIsGroupDisabled = info.mIsGroupDisabled;
1785         }
1786 
1787         /**
1788          * Set the subscription id.
1789          *
1790          * @param id The subscription id.
1791          *
1792          * @return The builder.
1793          */
1794         @NonNull
setId(int id)1795         public Builder setId(int id) {
1796             mId = id;
1797             return this;
1798         }
1799 
1800         /**
1801          * Set the ICCID of the SIM that is associated with this subscription.
1802          *
1803          * @param iccId The ICCID of the SIM that is associated with this subscription.
1804          *
1805          * @return The builder.
1806          */
1807         @NonNull
setIccId(@onNull String iccId)1808         public Builder setIccId(@NonNull String iccId) {
1809             Objects.requireNonNull(iccId);
1810             mIccId = iccId;
1811             return this;
1812         }
1813 
1814         /**
1815          * Set the SIM index of the slot that currently contains the subscription. Set to
1816          * {@link SubscriptionManager#INVALID_SIM_SLOT_INDEX} if the subscription is inactive.
1817          *
1818          * @param simSlotIndex The SIM slot index.
1819          *
1820          * @return The builder.
1821          */
1822         @NonNull
setSimSlotIndex(int simSlotIndex)1823         public Builder setSimSlotIndex(int simSlotIndex) {
1824             mSimSlotIndex = simSlotIndex;
1825             return this;
1826         }
1827 
1828         /**
1829          * The name displayed to the user that identifies this subscription. This name is used
1830          * in Settings page and can be renamed by the user.
1831          *
1832          * @param displayName The display name.
1833          *
1834          * @return The builder.
1835          */
1836         @NonNull
setDisplayName(@onNull String displayName)1837         public Builder setDisplayName(@NonNull String displayName) {
1838             Objects.requireNonNull(displayName);
1839             mDisplayName = displayName;
1840             return this;
1841         }
1842 
1843         /**
1844          * The name displayed to the user that identifies subscription provider name. This name
1845          * is the SPN displayed in status bar and many other places. Can't be renamed by the user.
1846          *
1847          * @param carrierName The carrier name.
1848          *
1849          * @return The builder.
1850          */
1851         @NonNull
setCarrierName(@onNull String carrierName)1852         public Builder setCarrierName(@NonNull String carrierName) {
1853             Objects.requireNonNull(carrierName);
1854             mCarrierName = carrierName;
1855             return this;
1856         }
1857 
1858         /**
1859          * Set the source of the display name.
1860          *
1861          * @param displayNameSource The source of the display name.
1862          * @return The builder.
1863          *
1864          * @see SubscriptionInfoInternal#getDisplayName()
1865          */
1866         @NonNull
setDisplayNameSource(@imDisplayNameSource int displayNameSource)1867         public Builder setDisplayNameSource(@SimDisplayNameSource int displayNameSource) {
1868             mDisplayNameSource = displayNameSource;
1869             return this;
1870         }
1871 
1872         /**
1873          * Set the color to be used for tinting the icon when displaying to the user.
1874          *
1875          * @param iconTint The color to be used for tinting the icon when displaying to the user.
1876          *
1877          * @return The builder.
1878          */
1879         @NonNull
setIconTint(int iconTint)1880         public Builder setIconTint(int iconTint) {
1881             mIconTint = iconTint;
1882             return this;
1883         }
1884 
1885         /**
1886          * Set the number presented to the user identify this subscription.
1887          *
1888          * @param number the number presented to the user identify this subscription.
1889          *
1890          * @return The builder.
1891          */
1892         @NonNull
setNumber(@onNull String number)1893         public Builder setNumber(@NonNull String number) {
1894             Objects.requireNonNull(number);
1895             mNumber = number;
1896             return this;
1897         }
1898 
1899         /**
1900          * Set whether user enables data roaming for this subscription or not.
1901          *
1902          * @param dataRoaming Data roaming mode. Either
1903          * {@link SubscriptionManager#DATA_ROAMING_ENABLE} or
1904          * {@link SubscriptionManager#DATA_ROAMING_DISABLE}
1905          *
1906          * @return The builder.
1907          */
1908         @NonNull
setDataRoaming(int dataRoaming)1909         public Builder setDataRoaming(int dataRoaming) {
1910             mDataRoaming = dataRoaming;
1911             return this;
1912         }
1913 
1914         /**
1915          * Set the mobile country code.
1916          *
1917          * @param mcc The mobile country code.
1918          *
1919          * @return The builder.
1920          */
1921         @NonNull
setMcc(@onNull String mcc)1922         public Builder setMcc(@NonNull String mcc) {
1923             Objects.requireNonNull(mcc);
1924             mMcc = mcc;
1925             return this;
1926         }
1927 
1928         /**
1929          * Set the mobile network code.
1930          *
1931          * @param mnc Mobile network code.
1932          *
1933          * @return The builder.
1934          */
1935         @NonNull
setMnc(@onNull String mnc)1936         public Builder setMnc(@NonNull String mnc) {
1937             Objects.requireNonNull(mnc);
1938             mMnc = mnc;
1939             return this;
1940         }
1941 
1942         /**
1943          * Set EHPLMNs associated with the subscription.
1944          *
1945          * @param ehplmns EHPLMNs associated with the subscription.
1946          *
1947          * @return The builder.
1948          */
1949         @NonNull
setEhplmns(@onNull String ehplmns)1950         public Builder setEhplmns(@NonNull String ehplmns) {
1951             Objects.requireNonNull(ehplmns);
1952             mEhplmns = ehplmns;
1953             return this;
1954         }
1955 
1956         /**
1957          * Set HPLMNs associated with the subscription.
1958          *
1959          * @param hplmns HPLMNs associated with the subscription.
1960          *
1961          * @return The builder.
1962          */
1963         @NonNull
setHplmns(@onNull String hplmns)1964         public Builder setHplmns(@NonNull String hplmns) {
1965             Objects.requireNonNull(hplmns);
1966             mHplmns = hplmns;
1967             return this;
1968         }
1969 
1970         /**
1971          * Set whether the subscription is from eSIM or not.
1972          *
1973          * @param isEmbedded {@code 1} if the subscription is from eSIM.
1974          *
1975          * @return The builder.
1976          */
1977         @NonNull
setEmbedded(int isEmbedded)1978         public Builder setEmbedded(int isEmbedded) {
1979             mIsEmbedded = isEmbedded;
1980             return this;
1981         }
1982 
1983         /**
1984          * Set the card string of the SIM card.
1985          *
1986          * @param cardString The card string of the SIM card.
1987          *
1988          * @return The builder.
1989          *
1990          * @see #getCardString()
1991          */
1992         @NonNull
setCardString(@onNull String cardString)1993         public Builder setCardString(@NonNull String cardString) {
1994             Objects.requireNonNull(cardString);
1995             mCardString = cardString;
1996             return this;
1997         }
1998 
1999         /**
2000          * Set the native access rules for this subscription, if it is embedded and defines any.
2001          * This does not include access rules for non-embedded subscriptions.
2002          *
2003          * @param nativeAccessRules The native access rules for this subscription.
2004          *
2005          * @return The builder.
2006          */
2007         @NonNull
setNativeAccessRules(@onNull byte[] nativeAccessRules)2008         public Builder setNativeAccessRules(@NonNull byte[] nativeAccessRules) {
2009             Objects.requireNonNull(nativeAccessRules);
2010             mNativeAccessRules = nativeAccessRules;
2011             return this;
2012         }
2013 
2014         /**
2015          * Set the native access rules for this subscription, if it is embedded and defines any.
2016          * This does not include access rules for non-embedded subscriptions.
2017          *
2018          * @param nativeAccessRules The native access rules for this subscription.
2019          *
2020          * @return The builder.
2021          */
2022         @NonNull
setNativeAccessRules(@onNull List<UiccAccessRule> nativeAccessRules)2023         public Builder setNativeAccessRules(@NonNull List<UiccAccessRule> nativeAccessRules) {
2024             Objects.requireNonNull(nativeAccessRules);
2025             if (!nativeAccessRules.isEmpty()) {
2026                 mNativeAccessRules = UiccAccessRule.encodeRules(
2027                         nativeAccessRules.toArray(new UiccAccessRule[0]));
2028             }
2029             return this;
2030         }
2031 
2032         /**
2033          * Set the carrier certificates for this subscription that are saved in carrier configs.
2034          * This does not include access rules from the Uicc, whether embedded or non-embedded.
2035          *
2036          * @param carrierConfigAccessRules The carrier certificates for this subscription.
2037          *
2038          * @return The builder.
2039          */
2040         @NonNull
setCarrierConfigAccessRules(@onNull byte[] carrierConfigAccessRules)2041         public Builder setCarrierConfigAccessRules(@NonNull byte[] carrierConfigAccessRules) {
2042             Objects.requireNonNull(carrierConfigAccessRules);
2043             mCarrierConfigAccessRules = carrierConfigAccessRules;
2044             return this;
2045         }
2046 
2047         /**
2048          * Set whether an embedded subscription is on a removable card. Such subscriptions are
2049          * marked inaccessible as soon as the current card is removed. Otherwise, they will remain
2050          * accessible unless explicitly deleted. Only meaningful when {@link #getEmbedded()} is
2051          * {@code 1}.
2052          *
2053          * @param isRemovableEmbedded {@code true} if the subscription is from the removable
2054          * embedded SIM.
2055          *
2056          * @return The builder.
2057          */
2058         @NonNull
setRemovableEmbedded(boolean isRemovableEmbedded)2059         public Builder setRemovableEmbedded(boolean isRemovableEmbedded) {
2060             mIsRemovableEmbedded = isRemovableEmbedded ? 1 : 0;
2061             return this;
2062         }
2063 
2064         /**
2065          * Set whether an embedded subscription is on a removable card. Such subscriptions are
2066          * marked inaccessible as soon as the current card is removed. Otherwise, they will remain
2067          * accessible unless explicitly deleted. Only meaningful when {@link #getEmbedded()} is
2068          * {@code 1}.
2069          *
2070          * @param isRemovableEmbedded {@code 1} if the subscription is from the removable
2071          * embedded SIM.
2072          *
2073          * @return The builder.
2074          */
2075         @NonNull
setRemovableEmbedded(int isRemovableEmbedded)2076         public Builder setRemovableEmbedded(int isRemovableEmbedded) {
2077             mIsRemovableEmbedded = isRemovableEmbedded;
2078             return this;
2079         }
2080 
2081         /**
2082          * Set whether cell broadcast extreme threat alert is enabled by the user or not.
2083          *
2084          * @param isExtremeThreatAlertEnabled whether cell broadcast extreme threat alert is enabled
2085          * by the user or not.
2086          *
2087          * @return The builder.
2088          */
2089         @NonNull
setCellBroadcastExtremeThreatAlertEnabled(int isExtremeThreatAlertEnabled)2090         public Builder setCellBroadcastExtremeThreatAlertEnabled(int isExtremeThreatAlertEnabled) {
2091             mIsExtremeThreatAlertEnabled = isExtremeThreatAlertEnabled;
2092             return this;
2093         }
2094 
2095         /**
2096          * Set whether cell broadcast severe threat alert is enabled by the user or not.
2097          *
2098          * @param isSevereThreatAlertEnabled whether cell broadcast severe threat alert is enabled
2099          * by the user or not.
2100          *
2101          * @return The builder.
2102          */
2103         @NonNull
setCellBroadcastSevereThreatAlertEnabled(int isSevereThreatAlertEnabled)2104         public Builder setCellBroadcastSevereThreatAlertEnabled(int isSevereThreatAlertEnabled) {
2105             mIsSevereThreatAlertEnabled = isSevereThreatAlertEnabled;
2106             return this;
2107         }
2108 
2109         /**
2110          * Set whether cell broadcast amber alert is enabled by the user or not.
2111          *
2112          * @param isAmberAlertEnabled whether cell broadcast amber alert is enabled by the user or
2113          * not.
2114          *
2115          * @return The builder.
2116          */
2117         @NonNull
setCellBroadcastAmberAlertEnabled(int isAmberAlertEnabled)2118         public Builder setCellBroadcastAmberAlertEnabled(int isAmberAlertEnabled) {
2119             mIsAmberAlertEnabled = isAmberAlertEnabled;
2120             return this;
2121         }
2122 
2123         /**
2124          * Set whether cell broadcast emergency alert is enabled by the user or not.
2125          *
2126          * @param isEmergencyAlertEnabled whether cell broadcast emergency alert is enabled by the
2127          * user or not.
2128          *
2129          * @return The builder.
2130          */
2131         @NonNull
setCellBroadcastEmergencyAlertEnabled(int isEmergencyAlertEnabled)2132         public Builder setCellBroadcastEmergencyAlertEnabled(int isEmergencyAlertEnabled) {
2133             mIsEmergencyAlertEnabled = isEmergencyAlertEnabled;
2134             return this;
2135         }
2136 
2137         /**
2138          * Set cell broadcast alert sound duration.
2139          *
2140          * @param alertSoundDuration Alert sound duration in seconds.
2141          *
2142          * @return The builder.
2143          */
2144         @NonNull
setCellBroadcastAlertSoundDuration(int alertSoundDuration)2145         public Builder setCellBroadcastAlertSoundDuration(int alertSoundDuration) {
2146             mAlertSoundDuration = alertSoundDuration;
2147             return this;
2148         }
2149 
2150         /**
2151          * Set cell broadcast alert reminder interval in minutes.
2152          *
2153          * @param reminderInterval Alert reminder interval in minutes.
2154          *
2155          * @return The builder.
2156          */
setCellBroadcastAlertReminderInterval(int reminderInterval)2157         public Builder setCellBroadcastAlertReminderInterval(int reminderInterval) {
2158             mReminderInterval = reminderInterval;
2159             return this;
2160         }
2161 
2162         /**
2163          * Set whether cell broadcast alert vibration is enabled by the user or not.
2164          *
2165          * @param isAlertVibrationEnabled whether cell broadcast alert vibration is enabled by the
2166          * user or not.
2167          *
2168          * @return The builder.
2169          */
2170         @NonNull
setCellBroadcastAlertVibrationEnabled(int isAlertVibrationEnabled)2171         public Builder setCellBroadcastAlertVibrationEnabled(int isAlertVibrationEnabled) {
2172             mIsAlertVibrationEnabled = isAlertVibrationEnabled;
2173             return this;
2174         }
2175 
2176         /**
2177          * Set whether cell broadcast alert speech is enabled by the user or not.
2178          *
2179          * @param isAlertSpeechEnabled whether cell broadcast alert speech is enabled by the user or
2180          * not.
2181          *
2182          * @return The builder.
2183          */
2184         @NonNull
setCellBroadcastAlertSpeechEnabled(int isAlertSpeechEnabled)2185         public Builder setCellBroadcastAlertSpeechEnabled(int isAlertSpeechEnabled) {
2186             mIsAlertSpeechEnabled = isAlertSpeechEnabled;
2187             return this;
2188         }
2189 
2190         /**
2191          * Set whether ETWS test alert is enabled by the user or not.
2192          *
2193          * @param isEtwsTestAlertEnabled whether cell broadcast ETWS test alert is enabled by the
2194          * user or not.
2195          *
2196          * @return The builder.
2197          */
2198         @NonNull
setCellBroadcastEtwsTestAlertEnabled(int isEtwsTestAlertEnabled)2199         public Builder setCellBroadcastEtwsTestAlertEnabled(int isEtwsTestAlertEnabled) {
2200             mIsEtwsTestAlertEnabled = isEtwsTestAlertEnabled;
2201             return this;
2202         }
2203 
2204         /**
2205          * Set whether area info message is enabled by the user or not.
2206          *
2207          * @param isAreaInfoMessageEnabled whether cell broadcast area info message is enabled by
2208          * the user or not.
2209          *
2210          * @return The builder.
2211          */
2212         @NonNull
setCellBroadcastAreaInfoMessageEnabled(int isAreaInfoMessageEnabled)2213         public Builder setCellBroadcastAreaInfoMessageEnabled(int isAreaInfoMessageEnabled) {
2214             mIsAreaInfoMessageEnabled = isAreaInfoMessageEnabled;
2215             return this;
2216         }
2217 
2218         /**
2219          * Set whether cell broadcast test alert is enabled by the user or not.
2220          *
2221          * @param isTestAlertEnabled whether cell broadcast test alert is enabled by the user or
2222          * not.
2223          *
2224          * @return The builder.
2225          */
2226         @NonNull
setCellBroadcastTestAlertEnabled(int isTestAlertEnabled)2227         public Builder setCellBroadcastTestAlertEnabled(int isTestAlertEnabled) {
2228             mIsTestAlertEnabled = isTestAlertEnabled;
2229             return this;
2230         }
2231 
2232         /**
2233          * Set whether cell broadcast opt-out dialog should be shown or not.
2234          *
2235          * @param isOptOutDialogEnabled whether cell broadcast opt-out dialog should be shown or
2236          * not.
2237          *
2238          * @return The builder.
2239          */
2240         @NonNull
setCellBroadcastOptOutDialogEnabled(int isOptOutDialogEnabled)2241         public Builder setCellBroadcastOptOutDialogEnabled(int isOptOutDialogEnabled) {
2242             mIsOptOutDialogEnabled = isOptOutDialogEnabled;
2243             return this;
2244         }
2245 
2246         /**
2247          * Set whether enhanced 4G mode is enabled by the user or not.
2248          *
2249          * @param isEnhanced4GModeEnabled whether enhanced 4G mode is enabled by the user or not.
2250          *
2251          * @return The builder.
2252          */
2253         @NonNull
setEnhanced4GModeEnabled(int isEnhanced4GModeEnabled)2254         public Builder setEnhanced4GModeEnabled(int isEnhanced4GModeEnabled) {
2255             mIsEnhanced4GModeEnabled = isEnhanced4GModeEnabled;
2256             return this;
2257         }
2258 
2259         /**
2260          * Set whether video telephony is enabled by the user or not.
2261          *
2262          * @param isVideoTelephonyEnabled whether video telephony is enabled by the user or not.
2263          *
2264          * @return The builder.
2265          */
2266         @NonNull
setVideoTelephonyEnabled(int isVideoTelephonyEnabled)2267         public Builder setVideoTelephonyEnabled(int isVideoTelephonyEnabled) {
2268             mIsVideoTelephonyEnabled = isVideoTelephonyEnabled;
2269             return this;
2270         }
2271 
2272         /**
2273          * Set whether Wi-Fi calling is enabled by the user or not when the device is not roaming.
2274          *
2275          * @param isWifiCallingEnabled whether Wi-Fi calling is enabled by the user or not when
2276          * the device is not roaming.
2277          *
2278          * @return The builder.
2279          */
2280         @NonNull
setWifiCallingEnabled(int isWifiCallingEnabled)2281         public Builder setWifiCallingEnabled(int isWifiCallingEnabled) {
2282             mIsWifiCallingEnabled = isWifiCallingEnabled;
2283             return this;
2284         }
2285 
2286         /**
2287          * Set Wi-Fi calling mode when the device is not roaming.
2288          *
2289          * @param wifiCallingMode Wi-Fi calling mode when the device is not roaming.
2290          *
2291          * @return The builder.
2292          */
2293         @NonNull
setWifiCallingMode(@msMmTelManager.WiFiCallingMode int wifiCallingMode)2294         public Builder setWifiCallingMode(@ImsMmTelManager.WiFiCallingMode int wifiCallingMode) {
2295             mWifiCallingMode = wifiCallingMode;
2296             return this;
2297         }
2298 
2299         /**
2300          * Set Wi-Fi calling mode when the device is roaming.
2301          *
2302          * @param wifiCallingModeForRoaming Wi-Fi calling mode when the device is roaming.
2303          *
2304          * @return The builder.
2305          */
2306         @NonNull
setWifiCallingModeForRoaming( @msMmTelManager.WiFiCallingMode int wifiCallingModeForRoaming)2307         public Builder setWifiCallingModeForRoaming(
2308                 @ImsMmTelManager.WiFiCallingMode int wifiCallingModeForRoaming) {
2309             mWifiCallingModeForRoaming = wifiCallingModeForRoaming;
2310             return this;
2311         }
2312 
2313         /**
2314          * Set whether Wi-Fi calling is enabled by the user or not when the device is roaming.
2315          *
2316          * @param wifiCallingEnabledForRoaming whether Wi-Fi calling is enabled by the user or not
2317          * when the device is roaming.
2318          *
2319          * @return The builder.
2320          */
2321         @NonNull
setWifiCallingEnabledForRoaming(int wifiCallingEnabledForRoaming)2322         public Builder setWifiCallingEnabledForRoaming(int wifiCallingEnabledForRoaming) {
2323             mIsWifiCallingEnabledForRoaming = wifiCallingEnabledForRoaming;
2324             return this;
2325         }
2326 
2327         /**
2328          * Set whether the subscription is opportunistic or not.
2329          *
2330          * @param isOpportunistic {@code 1} if the subscription is opportunistic.
2331          * @return The builder.
2332          */
2333         @NonNull
setOpportunistic(int isOpportunistic)2334         public Builder setOpportunistic(int isOpportunistic) {
2335             mIsOpportunistic = isOpportunistic;
2336             return this;
2337         }
2338 
2339         /**
2340          * Set the group UUID of the subscription group.
2341          *
2342          * @param groupUuid The group UUID.
2343          * @return The builder.
2344          *
2345          */
2346         @NonNull
setGroupUuid(@onNull String groupUuid)2347         public Builder setGroupUuid(@NonNull String groupUuid) {
2348             Objects.requireNonNull(groupUuid);
2349             mGroupUuid = groupUuid;
2350             return this;
2351         }
2352 
2353         /**
2354          * Set the ISO country code for the subscription's provider.
2355          *
2356          * @param countryIso The ISO country code for the subscription's provider.
2357          * @return The builder.
2358          */
2359         @NonNull
setCountryIso(@onNull String countryIso)2360         public Builder setCountryIso(@NonNull String countryIso) {
2361             Objects.requireNonNull(countryIso);
2362             mCountryIso = countryIso;
2363             return this;
2364         }
2365 
2366         /**
2367          * Set the subscription carrier id.
2368          *
2369          * @param carrierId The carrier id.
2370          * @return The builder
2371          *
2372          * @see TelephonyManager#getSimCarrierId()
2373          */
2374         @NonNull
setCarrierId(int carrierId)2375         public Builder setCarrierId(int carrierId) {
2376             mCarrierId = carrierId;
2377             return this;
2378         }
2379 
2380         /**
2381          * Set the profile class populated from the profile metadata if present.
2382          *
2383          * @param profileClass the profile class populated from the profile metadata if present.
2384          * @return The builder
2385          *
2386          * @see #getProfileClass()
2387          */
2388         @NonNull
setProfileClass(@rofileClass int profileClass)2389         public Builder setProfileClass(@ProfileClass int profileClass) {
2390             mProfileClass = profileClass;
2391             return this;
2392         }
2393 
2394         /**
2395          * Set the subscription type.
2396          *
2397          * @param type Subscription type.
2398          * @return The builder.
2399          */
2400         @NonNull
setType(@ubscriptionType int type)2401         public Builder setType(@SubscriptionType int type) {
2402             mType = type;
2403             return this;
2404         }
2405 
2406         /**
2407          * Set the owner package of group the subscription belongs to.
2408          *
2409          * @param groupOwner Owner package of group the subscription belongs to.
2410          * @return The builder.
2411          */
2412         @NonNull
setGroupOwner(@onNull String groupOwner)2413         public Builder setGroupOwner(@NonNull String groupOwner) {
2414             Objects.requireNonNull(groupOwner);
2415             mGroupOwner = groupOwner;
2416             return this;
2417         }
2418 
2419         /**
2420          * Set the enabled mobile data policies.
2421          *
2422          * @param enabledMobileDataPolicies The enabled mobile data policies.
2423          * @return The builder.
2424          */
2425         @NonNull
setEnabledMobileDataPolicies(@onNull String enabledMobileDataPolicies)2426         public Builder setEnabledMobileDataPolicies(@NonNull String enabledMobileDataPolicies) {
2427             Objects.requireNonNull(enabledMobileDataPolicies);
2428             mEnabledMobileDataPolicies = enabledMobileDataPolicies;
2429             return this;
2430         }
2431 
2432         /**
2433          * Set the IMSI (International Mobile Subscriber Identity) of the subscription.
2434          *
2435          * @param imsi The IMSI.
2436          * @return The builder.
2437          */
2438         @NonNull
setImsi(@onNull String imsi)2439         public Builder setImsi(@NonNull String imsi) {
2440             Objects.requireNonNull(imsi);
2441             mImsi = imsi;
2442             return this;
2443         }
2444 
2445         /**
2446          * Set whether Uicc applications are configured to enable or not.
2447          *
2448          * @param areUiccApplicationsEnabled {@code 1} if Uicc applications are configured to
2449          * enable.
2450          * @return The builder.
2451          */
2452         @NonNull
setUiccApplicationsEnabled(int areUiccApplicationsEnabled)2453         public Builder setUiccApplicationsEnabled(int areUiccApplicationsEnabled) {
2454             mAreUiccApplicationsEnabled = areUiccApplicationsEnabled;
2455             return this;
2456         }
2457 
2458         /**
2459          * Set whether the user has enabled IMS RCS User Capability Exchange (UCE) for this
2460          * subscription.
2461          *
2462          * @param isRcsUceEnabled If the user enabled RCS UCE for this subscription.
2463          * @return The builder.
2464          */
2465         @NonNull
setRcsUceEnabled(int isRcsUceEnabled)2466         public Builder setRcsUceEnabled(int isRcsUceEnabled) {
2467             mIsRcsUceEnabled = isRcsUceEnabled;
2468             return this;
2469         }
2470 
2471         /**
2472          * Set whether the user has enabled cross SIM calling for this subscription.
2473          *
2474          * @param isCrossSimCallingEnabled If the user enabled cross SIM calling for this
2475          * subscription.
2476          * @return The builder.
2477          */
2478         @NonNull
setCrossSimCallingEnabled(int isCrossSimCallingEnabled)2479         public Builder setCrossSimCallingEnabled(int isCrossSimCallingEnabled) {
2480             mIsCrossSimCallingEnabled = isCrossSimCallingEnabled;
2481             return this;
2482         }
2483 
2484         /**
2485          * Set the RCS config for this subscription.
2486          *
2487          * @param rcsConfig The RCS config for this subscription.
2488          * @return The builder.
2489          */
2490         @NonNull
setRcsConfig(byte[] rcsConfig)2491         public Builder setRcsConfig(byte[] rcsConfig) {
2492             Objects.requireNonNull(rcsConfig);
2493             mRcsConfig = rcsConfig;
2494             return this;
2495         }
2496 
2497         /**
2498          * Set the allowed network types for reasons.
2499          *
2500          * @param allowedNetworkTypesForReasons The allowed network types for reasons in string
2501          * format. The format is
2502          * "[reason]=[network types bitmask], [reason]=[network types bitmask], ..."
2503          *
2504          * For example, "user=1239287394, thermal=298791239, carrier=3456812312".
2505          *
2506          * @return The builder.
2507          */
setAllowedNetworkTypesForReasons( @onNull String allowedNetworkTypesForReasons)2508         public Builder setAllowedNetworkTypesForReasons(
2509                 @NonNull String allowedNetworkTypesForReasons) {
2510             Objects.requireNonNull(allowedNetworkTypesForReasons);
2511             mAllowedNetworkTypesForReasons = allowedNetworkTypesForReasons;
2512             return this;
2513         }
2514 
2515         /**
2516          * Set device to device sharing status.
2517          *
2518          * @param deviceToDeviceStatusSharingPreference Device to device sharing status.
2519          * @return The builder.
2520          */
setDeviceToDeviceStatusSharingPreference( @eviceToDeviceStatusSharingPreference int deviceToDeviceStatusSharingPreference)2521         public Builder setDeviceToDeviceStatusSharingPreference(
2522                 @DeviceToDeviceStatusSharingPreference int deviceToDeviceStatusSharingPreference) {
2523             mDeviceToDeviceStatusSharingPreference = deviceToDeviceStatusSharingPreference;
2524             return this;
2525         }
2526 
2527         /**
2528          * Set whether the user has opted-in voice over IMS.
2529          *
2530          * @param isVoImsOptInEnabled Whether the user has opted-in voice over IMS.
2531          * @return The builder.
2532          */
2533         @NonNull
setVoImsOptInEnabled(int isVoImsOptInEnabled)2534         public Builder setVoImsOptInEnabled(int isVoImsOptInEnabled) {
2535             mIsVoImsOptInEnabled = isVoImsOptInEnabled;
2536             return this;
2537         }
2538 
2539         /**
2540          * Set contacts information that allow device to device sharing.
2541          *
2542          * @param deviceToDeviceStatusSharingContacts contacts information that allow device to
2543          * device sharing.
2544          * @return The builder.
2545          */
2546         @NonNull
setDeviceToDeviceStatusSharingContacts( @onNull String deviceToDeviceStatusSharingContacts)2547         public Builder setDeviceToDeviceStatusSharingContacts(
2548                 @NonNull String deviceToDeviceStatusSharingContacts) {
2549             Objects.requireNonNull(deviceToDeviceStatusSharingContacts);
2550             mDeviceToDeviceStatusSharingContacts = deviceToDeviceStatusSharingContacts;
2551             return this;
2552         }
2553 
2554         /**
2555          * Set whether the user has enabled NR advanced calling.
2556          *
2557          * @param isNrAdvancedCallingEnabled Whether the user has enabled NR advanced calling.
2558          * @return The builder.
2559          */
2560         @NonNull
setNrAdvancedCallingEnabled(int isNrAdvancedCallingEnabled)2561         public Builder setNrAdvancedCallingEnabled(int isNrAdvancedCallingEnabled) {
2562             mIsNrAdvancedCallingEnabled = isNrAdvancedCallingEnabled;
2563             return this;
2564         }
2565 
2566         /**
2567          * Set the phone number retrieved from carrier.
2568          *
2569          * @param numberFromCarrier The phone number retrieved from carrier.
2570          * @return The builder.
2571          */
2572         @NonNull
setNumberFromCarrier(@onNull String numberFromCarrier)2573         public Builder setNumberFromCarrier(@NonNull String numberFromCarrier) {
2574             Objects.requireNonNull(numberFromCarrier);
2575             mNumberFromCarrier = numberFromCarrier;
2576             return this;
2577         }
2578 
2579         /**
2580          * Set the phone number retrieved from IMS.
2581          *
2582          * @param numberFromIms The phone number retrieved from IMS.
2583          * @return The builder.
2584          */
2585         @NonNull
setNumberFromIms(@onNull String numberFromIms)2586         public Builder setNumberFromIms(@NonNull String numberFromIms) {
2587             Objects.requireNonNull(numberFromIms);
2588             mNumberFromIms = numberFromIms;
2589             return this;
2590         }
2591 
2592         /**
2593          * Set the port index of the Uicc card.
2594          *
2595          * @param portIndex The port index of the Uicc card.
2596          * @return The builder.
2597          */
2598         @NonNull
setPortIndex(int portIndex)2599         public Builder setPortIndex(int portIndex) {
2600             mPortIndex = portIndex;
2601             return this;
2602         }
2603 
2604         /**
2605          * Set subscription's preferred usage setting.
2606          *
2607          * @param usageSetting Subscription's preferred usage setting.
2608          * @return The builder.
2609          */
2610         @NonNull
setUsageSetting(@sageSetting int usageSetting)2611         public Builder setUsageSetting(@UsageSetting int usageSetting) {
2612             mUsageSetting = usageSetting;
2613             return this;
2614         }
2615 
2616         /**
2617          * Set last used TP message reference.
2618          *
2619          * @param lastUsedTPMessageReference Last used TP message reference.
2620          * @return The builder.
2621          */
2622         @NonNull
setLastUsedTPMessageReference( int lastUsedTPMessageReference)2623         public Builder setLastUsedTPMessageReference(
2624                 int lastUsedTPMessageReference) {
2625             mLastUsedTPMessageReference = lastUsedTPMessageReference;
2626             return this;
2627         }
2628 
2629         /**
2630          * Set the user id associated with this subscription.
2631          *
2632          * @param userId The user id associated with this subscription.
2633          * @return The builder.
2634          */
2635         @NonNull
setUserId(@serIdInt int userId)2636         public Builder setUserId(@UserIdInt int userId) {
2637             mUserId = userId;
2638             return this;
2639         }
2640 
2641         /**
2642          * Set whether satellite is enabled or not.
2643          * @param isSatelliteEnabled {@code 1} if satellite is enabled.
2644          * @return The builder.
2645          */
2646         @NonNull
setSatelliteEnabled(int isSatelliteEnabled)2647         public Builder setSatelliteEnabled(int isSatelliteEnabled) {
2648             mIsSatelliteEnabled = isSatelliteEnabled;
2649             return this;
2650         }
2651 
2652         // Below are the fields that do not exist in the SimInfo table.
2653         /**
2654          * Set the card ID of the SIM card which contains the subscription.
2655          *
2656          * @param cardId The card ID of the SIM card which contains the subscription.
2657          * @return The builder.
2658          */
2659         @NonNull
setCardId(int cardId)2660         public Builder setCardId(int cardId) {
2661             mCardId = cardId;
2662             return this;
2663         }
2664 
2665         /**
2666          * Whether group of the subscription is disabled. This is only useful if it's a grouped
2667          * opportunistic subscription. In this case, if all primary (non-opportunistic)
2668          * subscriptions in the group are deactivated (unplugged pSIM or deactivated eSIM profile),
2669          * we should disable this opportunistic subscription.
2670          *
2671          * @param isGroupDisabled {@code 1} if group of the subscription is disabled.
2672          * @return The builder.
2673          */
2674         @NonNull
setGroupDisabled(boolean isGroupDisabled)2675         public Builder setGroupDisabled(boolean isGroupDisabled) {
2676             mIsGroupDisabled = isGroupDisabled;
2677             return this;
2678         }
2679 
2680         /**
2681          * Build the {@link SubscriptionInfoInternal}.
2682          *
2683          * @return The {@link SubscriptionInfoInternal} instance.
2684          */
build()2685         public SubscriptionInfoInternal build() {
2686             return new SubscriptionInfoInternal(this);
2687         }
2688     }
2689 }
2690