• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.telephony;
18 
19 import static android.text.TextUtils.formatSimple;
20 
21 import android.annotation.FlaggedApi;
22 import android.annotation.NonNull;
23 import android.annotation.Nullable;
24 import android.annotation.SystemApi;
25 import android.content.Context;
26 import android.content.pm.PackageInfo;
27 import android.content.pm.PackageManager;
28 import android.graphics.Bitmap;
29 import android.graphics.BitmapFactory;
30 import android.graphics.Canvas;
31 import android.graphics.Color;
32 import android.graphics.Paint;
33 import android.graphics.PorterDuff;
34 import android.graphics.PorterDuffColorFilter;
35 import android.graphics.Rect;
36 import android.graphics.Typeface;
37 import android.os.Parcel;
38 import android.os.ParcelUuid;
39 import android.os.Parcelable;
40 import android.telephony.SubscriptionManager.ProfileClass;
41 import android.telephony.SubscriptionManager.SimDisplayNameSource;
42 import android.telephony.SubscriptionManager.SubscriptionType;
43 import android.telephony.SubscriptionManager.TransferStatus;
44 import android.telephony.SubscriptionManager.UsageSetting;
45 import android.text.TextUtils;
46 import android.util.DisplayMetrics;
47 import android.util.Log;
48 
49 import com.android.internal.telephony.flags.Flags;
50 import com.android.internal.telephony.util.TelephonyUtils;
51 import com.android.telephony.Rlog;
52 
53 import java.util.ArrayList;
54 import java.util.Arrays;
55 import java.util.Collections;
56 import java.util.List;
57 import java.util.Objects;
58 import java.util.Set;
59 
60 /**
61  * A Parcelable class for Subscription Information.
62  */
63 public class SubscriptionInfo implements Parcelable {
64     /**
65      * Size of text to render on the icon.
66      */
67     private static final int TEXT_SIZE = 16;
68 
69     /**
70      * Subscription Identifier, this is a device unique number
71      * and not an index into an array
72      */
73     private final int mId;
74 
75     /**
76      * The ICCID of the SIM that is associated with this subscription, empty if unknown.
77      */
78     @NonNull
79     private final String mIccId;
80 
81     /**
82      * The index of the SIM slot that currently contains the subscription and not necessarily unique
83      * and maybe {@link SubscriptionManager#INVALID_SIM_SLOT_INDEX} if unknown or the subscription
84      * is inactive.
85      */
86     private final int mSimSlotIndex;
87 
88     /**
89      * The name displayed to the user that identifies this subscription. This name is used
90      * in Settings page and can be renamed by the user.
91      */
92     @NonNull
93     private final CharSequence mDisplayName;
94 
95     /**
96      * The name displayed to the user that identifies subscription provider name. This name is the
97      * SPN displayed in status bar and many other places. Can't be renamed by the user.
98      */
99     @NonNull
100     private final CharSequence mCarrierName;
101 
102     /**
103      * The source of the {@link #mDisplayName}.
104      */
105     @SimDisplayNameSource
106     private final int mDisplayNameSource;
107 
108     /**
109      * The color to be used for tinting the icon when displaying to the user.
110      */
111     private final int mIconTint;
112 
113     /**
114      * The number presented to the user identify this subscription.
115      */
116     @NonNull
117     private final String mNumber;
118 
119     /**
120      * Whether user enables data roaming for this subscription or not. Either
121      * {@link SubscriptionManager#DATA_ROAMING_ENABLE} or
122      * {@link SubscriptionManager#DATA_ROAMING_DISABLE}.
123      */
124     private final int mDataRoaming;
125 
126     /**
127      * Mobile Country Code.
128      */
129     @Nullable
130     private final String mMcc;
131 
132     /**
133      * Mobile Network Code.
134      */
135     @Nullable
136     private final String mMnc;
137 
138     /**
139      * EHPLMNs associated with the subscription.
140      */
141     @NonNull
142     private final String[] mEhplmns;
143 
144     /**
145      * HPLMNs associated with the subscription.
146      */
147     @NonNull
148     private final String[] mHplmns;
149 
150     /**
151      * Whether the subscription is from eSIM.
152      */
153     private final boolean mIsEmbedded;
154 
155     /**
156      * The string ID of the SIM card. It is the ICCID of the active profile for a UICC card and the
157      * EID for an eUICC card.
158      */
159     @NonNull
160     private final String mCardString;
161 
162     /**
163      * The access rules for this subscription, if it is embedded and defines any. This does not
164      * include access rules for non-embedded subscriptions.
165      */
166     @Nullable
167     private final UiccAccessRule[] mNativeAccessRules;
168 
169     /**
170      * The carrier certificates for this subscription that are saved in carrier configs.
171      * This does not include access rules from the Uicc, whether embedded or non-embedded.
172      */
173     @Nullable
174     private final UiccAccessRule[] mCarrierConfigAccessRules;
175 
176     /**
177      * Whether the subscription is opportunistic.
178      */
179     private final boolean mIsOpportunistic;
180 
181     /**
182      * A UUID assigned to the subscription group. {@code null} if not assigned.
183      *
184      * @see SubscriptionManager#createSubscriptionGroup(List)
185      */
186     @Nullable
187     private final ParcelUuid mGroupUuid;
188 
189     /**
190      * ISO Country code for the subscription's provider.
191      */
192     @NonNull
193     private final String mCountryIso;
194 
195     /**
196      * The subscription carrier id.
197      *
198      * @see TelephonyManager#getSimCarrierId()
199      */
200     private final int mCarrierId;
201 
202     /**
203      * The profile class populated from the profile metadata if present. Otherwise,
204      * the profile class defaults to {@link SubscriptionManager#PROFILE_CLASS_UNSET} if there is no
205      * profile metadata or the subscription is not on an eUICC ({@link #isEmbedded} returns
206      * {@code false}).
207      */
208     @ProfileClass
209     private final int mProfileClass;
210 
211     /**
212      * Type of the subscription.
213      */
214     @SubscriptionType
215     private final int mType;
216 
217     /**
218      * A package name that specifies who created the group. Empty if not available.
219      */
220     @NonNull
221     private final String mGroupOwner;
222 
223     /**
224      * Whether uicc applications are configured to enable or disable.
225      * By default it's true.
226      */
227     private final boolean mAreUiccApplicationsEnabled;
228 
229     /**
230      * The port index of the Uicc card.
231      */
232     private final int mPortIndex;
233 
234     /**
235      * Subscription's preferred usage setting.
236      */
237     @UsageSetting
238     private final int mUsageSetting;
239 
240     /**
241      * Subscription's transfer status
242      */
243     private final int mTransferStatus;
244 
245     // Below are the fields that do not exist in the database.
246 
247     /**
248      * SIM icon bitmap cache.
249      */
250     @Nullable
251     private Bitmap mIconBitmap;
252 
253     /**
254      * The card ID of the SIM card. This maps uniquely to {@link #mCardString}.
255      */
256     private final int mCardId;
257 
258     /**
259      * Whether group of the subscription is disabled. This is only useful if it's a grouped
260      * opportunistic subscription. In this case, if all primary (non-opportunistic) subscriptions
261      * in the group are deactivated (unplugged pSIM or deactivated eSIM profile), we should disable
262      * this opportunistic subscription.
263      */
264     private final boolean mIsGroupDisabled;
265 
266     /**
267      * Whether this subscription is used for communicating with non-terrestrial networks.
268      */
269     private final boolean mIsOnlyNonTerrestrialNetwork;
270 
271     /**
272      * The service capabilities (in the form of bitmask combination) the subscription supports.
273      */
274     private final int mServiceCapabilities;
275 
276     /**
277      * Whether the carrier roaming to satellite is using ESOS for emergency messaging.
278      */
279     private final boolean mIsSatelliteESOSSupported;
280 
281     /**
282      * @hide
283      *
284      * @deprecated Use {@link SubscriptionInfo.Builder}.
285      */
286     // TODO: Clean up after external usages moved to builder model.
287     @Deprecated
SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName, CharSequence carrierName, int nameSource, int iconTint, String number, int roaming, Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded, @Nullable UiccAccessRule[] nativeAccessRules, String cardString)288     public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName,
289             CharSequence carrierName, int nameSource, int iconTint, String number, int roaming,
290             Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
291             @Nullable UiccAccessRule[] nativeAccessRules, String cardString) {
292         this(id, iccId, simSlotIndex, displayName, carrierName, nameSource, iconTint, number,
293                 roaming, icon, mcc, mnc, countryIso, isEmbedded, nativeAccessRules, cardString, -1,
294                 false, null, false, TelephonyManager.UNKNOWN_CARRIER_ID,
295                 SubscriptionManager.PROFILE_CLASS_UNSET,
296                 SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, null, null, true);
297     }
298 
299     /**
300      * @hide
301      *
302      * @deprecated Use {@link SubscriptionInfo.Builder}.
303      */
304     // TODO: Clean up after external usages moved to builder model.
305     @Deprecated
SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName, CharSequence carrierName, int nameSource, int iconTint, String number, int roaming, Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded, @Nullable UiccAccessRule[] nativeAccessRules, String cardString, boolean isOpportunistic, @Nullable String groupUUID, int carrierId, int profileClass)306     public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName,
307             CharSequence carrierName, int nameSource, int iconTint, String number, int roaming,
308             Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
309             @Nullable UiccAccessRule[] nativeAccessRules, String cardString,
310             boolean isOpportunistic, @Nullable String groupUUID, int carrierId, int profileClass) {
311         this(id, iccId, simSlotIndex, displayName, carrierName, nameSource, iconTint, number,
312                 roaming, icon, mcc, mnc, countryIso, isEmbedded, nativeAccessRules, cardString, -1,
313                 isOpportunistic, groupUUID, false, carrierId, profileClass,
314                 SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM, null, null, true);
315     }
316 
317     /**
318      * @hide
319      *
320      * @deprecated Use {@link SubscriptionInfo.Builder}.
321      */
322     // TODO: Clean up after external usages moved to builder model.
323     @Deprecated
SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName, CharSequence carrierName, int nameSource, int iconTint, String number, int roaming, Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded, @Nullable UiccAccessRule[] nativeAccessRules, String cardString, int cardId, boolean isOpportunistic, @Nullable String groupUUID, boolean isGroupDisabled, int carrierId, int profileClass, int subType, @Nullable String groupOwner, @Nullable UiccAccessRule[] carrierConfigAccessRules, boolean areUiccApplicationsEnabled)324     public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName,
325             CharSequence carrierName, int nameSource, int iconTint, String number, int roaming,
326             Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
327             @Nullable UiccAccessRule[] nativeAccessRules, String cardString, int cardId,
328             boolean isOpportunistic, @Nullable String groupUUID, boolean isGroupDisabled,
329             int carrierId, int profileClass, int subType, @Nullable String groupOwner,
330             @Nullable UiccAccessRule[] carrierConfigAccessRules,
331             boolean areUiccApplicationsEnabled) {
332         this(id, iccId, simSlotIndex, displayName, carrierName, nameSource, iconTint, number,
333                 roaming, icon, mcc, mnc, countryIso, isEmbedded, nativeAccessRules, cardString,
334                 cardId, isOpportunistic, groupUUID, isGroupDisabled, carrierId, profileClass,
335                 subType, groupOwner, carrierConfigAccessRules, areUiccApplicationsEnabled, 0);
336     }
337 
338     /**
339      * @hide
340      *
341      * @deprecated Use {@link SubscriptionInfo.Builder}.
342      */
343     // TODO: Clean up after external usages moved to builder model.
344     @Deprecated
SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName, CharSequence carrierName, int displayNameSource, int iconTint, String number, int roaming, Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded, @Nullable UiccAccessRule[] nativeAccessRules, String cardString, int cardId, boolean isOpportunistic, @Nullable String groupUUID, boolean isGroupDisabled, int carrierId, int profileClass, int subType, @Nullable String groupOwner, @Nullable UiccAccessRule[] carrierConfigAccessRules, boolean areUiccApplicationsEnabled, int portIndex)345     public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName,
346             CharSequence carrierName, int displayNameSource, int iconTint, String number,
347             int roaming, Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
348             @Nullable UiccAccessRule[] nativeAccessRules, String cardString, int cardId,
349             boolean isOpportunistic, @Nullable String groupUUID, boolean isGroupDisabled,
350             int carrierId, int profileClass, int subType, @Nullable String groupOwner,
351             @Nullable UiccAccessRule[] carrierConfigAccessRules,
352             boolean areUiccApplicationsEnabled, int portIndex) {
353         this(id, iccId, simSlotIndex, displayName, carrierName, displayNameSource, iconTint, number,
354                 roaming, icon, mcc, mnc, countryIso, isEmbedded, nativeAccessRules, cardString,
355                 cardId, isOpportunistic, groupUUID, isGroupDisabled, carrierId, profileClass,
356                 subType, groupOwner, carrierConfigAccessRules, areUiccApplicationsEnabled,
357                 portIndex, SubscriptionManager.USAGE_SETTING_DEFAULT);
358     }
359 
360     /**
361      * @hide
362      *
363      * @deprecated Use {@link SubscriptionInfo.Builder}.
364      */
365     // TODO: Clean up after external usages moved to builder model.
366     @Deprecated
SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName, CharSequence carrierName, int nameSource, int iconTint, String number, int roaming, Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded, @Nullable UiccAccessRule[] nativeAccessRules, String cardString, int cardId, boolean isOpportunistic, @Nullable String groupUuid, boolean isGroupDisabled, int carrierId, int profileClass, int subType, @Nullable String groupOwner, @Nullable UiccAccessRule[] carrierConfigAccessRules, boolean areUiccApplicationsEnabled, int portIndex, @UsageSetting int usageSetting)367     public SubscriptionInfo(int id, String iccId, int simSlotIndex, CharSequence displayName,
368             CharSequence carrierName, int nameSource, int iconTint, String number, int roaming,
369             Bitmap icon, String mcc, String mnc, String countryIso, boolean isEmbedded,
370             @Nullable UiccAccessRule[] nativeAccessRules, String cardString, int cardId,
371             boolean isOpportunistic, @Nullable String groupUuid, boolean isGroupDisabled,
372             int carrierId, int profileClass, int subType, @Nullable String groupOwner,
373             @Nullable UiccAccessRule[] carrierConfigAccessRules,
374             boolean areUiccApplicationsEnabled, int portIndex, @UsageSetting int usageSetting) {
375         this.mId = id;
376         this.mIccId = iccId;
377         this.mSimSlotIndex = simSlotIndex;
378         this.mDisplayName =  displayName;
379         this.mCarrierName = carrierName;
380         this.mDisplayNameSource = nameSource;
381         this.mIconTint = iconTint;
382         this.mNumber = number;
383         this.mDataRoaming = roaming;
384         this.mIconBitmap = icon;
385         this.mMcc = TextUtils.emptyIfNull(mcc);
386         this.mMnc = TextUtils.emptyIfNull(mnc);
387         this.mHplmns = null;
388         this.mEhplmns = null;
389         this.mCountryIso = TextUtils.emptyIfNull(countryIso);
390         this.mIsEmbedded = isEmbedded;
391         this.mNativeAccessRules = nativeAccessRules;
392         this.mCardString = TextUtils.emptyIfNull(cardString);
393         this.mCardId = cardId;
394         this.mIsOpportunistic = isOpportunistic;
395         this.mGroupUuid = groupUuid == null ? null : ParcelUuid.fromString(groupUuid);
396         this.mIsGroupDisabled = isGroupDisabled;
397         this.mCarrierId = carrierId;
398         this.mProfileClass = profileClass;
399         this.mType = subType;
400         this.mGroupOwner = TextUtils.emptyIfNull(groupOwner);
401         this.mCarrierConfigAccessRules = carrierConfigAccessRules;
402         this.mAreUiccApplicationsEnabled = areUiccApplicationsEnabled;
403         this.mPortIndex = portIndex;
404         this.mUsageSetting = usageSetting;
405         this.mIsOnlyNonTerrestrialNetwork = false;
406         this.mServiceCapabilities = 0;
407         this.mTransferStatus = 0;
408         this.mIsSatelliteESOSSupported = false;
409     }
410 
411     /**
412      * Constructor from builder.
413      *
414      * @param builder Builder of {@link SubscriptionInfo}.
415      */
SubscriptionInfo(@onNull Builder builder)416     private SubscriptionInfo(@NonNull Builder builder) {
417         this.mId = builder.mId;
418         this.mIccId = builder.mIccId;
419         this.mSimSlotIndex = builder.mSimSlotIndex;
420         this.mDisplayName = builder.mDisplayName;
421         this.mCarrierName = builder.mCarrierName;
422         this.mDisplayNameSource = builder.mDisplayNameSource;
423         this.mIconTint = builder.mIconTint;
424         this.mNumber = builder.mNumber;
425         this.mDataRoaming = builder.mDataRoaming;
426         this.mIconBitmap = builder.mIconBitmap;
427         this.mMcc = builder.mMcc;
428         this.mMnc = builder.mMnc;
429         this.mEhplmns = builder.mEhplmns;
430         this.mHplmns = builder.mHplmns;
431         this.mCountryIso = builder.mCountryIso;
432         this.mIsEmbedded = builder.mIsEmbedded;
433         this.mNativeAccessRules = builder.mNativeAccessRules;
434         this.mCardString = builder.mCardString;
435         this.mCardId = builder.mCardId;
436         this.mIsOpportunistic = builder.mIsOpportunistic;
437         this.mGroupUuid = builder.mGroupUuid;
438         this.mIsGroupDisabled = builder.mIsGroupDisabled;
439         this.mCarrierId = builder.mCarrierId;
440         this.mProfileClass = builder.mProfileClass;
441         this.mType = builder.mType;
442         this.mGroupOwner = builder.mGroupOwner;
443         this.mCarrierConfigAccessRules = builder.mCarrierConfigAccessRules;
444         this.mAreUiccApplicationsEnabled = builder.mAreUiccApplicationsEnabled;
445         this.mPortIndex = builder.mPortIndex;
446         this.mUsageSetting = builder.mUsageSetting;
447         this.mIsOnlyNonTerrestrialNetwork = builder.mIsOnlyNonTerrestrialNetwork;
448         this.mServiceCapabilities = builder.mServiceCapabilities;
449         this.mTransferStatus = builder.mTransferStatus;
450         this.mIsSatelliteESOSSupported = builder.mIsSatelliteESOSSupported;
451     }
452 
453     /**
454      * @return The subscription ID.
455      */
getSubscriptionId()456     public int getSubscriptionId() {
457         return mId;
458     }
459 
460     /**
461      * Returns the ICC ID.
462      *
463      * Starting with API level 29 Security Patch 2021-04-05, returns the ICC ID if the calling app
464      * has been granted the READ_PRIVILEGED_PHONE_STATE permission, has carrier privileges (see
465      * {@link TelephonyManager#hasCarrierPrivileges}), or is a device owner or profile owner that
466      * has been granted the READ_PHONE_STATE permission. The profile owner is an app that owns a
467      * managed profile on the device; for more details see <a
468      * href="https://developer.android.com/work/managed-profiles">Work profiles</a>. Profile
469      * owner access is deprecated and will be removed in a future release.
470      *
471      * @return the ICC ID, or an empty string if one of these requirements is not met
472      */
getIccId()473     public String getIccId() {
474         return mIccId;
475     }
476 
477     /**
478      * @return The index of the SIM slot that currently contains the subscription and not
479      * necessarily unique and maybe {@link SubscriptionManager#INVALID_SIM_SLOT_INDEX} if unknown or
480      * the subscription is inactive.
481      */
getSimSlotIndex()482     public int getSimSlotIndex() {
483         return mSimSlotIndex;
484     }
485 
486     /**
487      * @return The carrier id of this subscription carrier.
488      *
489      * @see TelephonyManager#getSimCarrierId()
490      */
getCarrierId()491     public int getCarrierId() {
492         return mCarrierId;
493     }
494 
495     /**
496      * @return The name displayed to the user that identifies this subscription. This name is
497      * used in Settings page and can be renamed by the user.
498      *
499      * @see #getCarrierName()
500      */
getDisplayName()501     public CharSequence getDisplayName() {
502         return mDisplayName;
503     }
504 
505     /**
506      * @return The name displayed to the user that identifies subscription provider name. This name
507      * is the SPN displayed in status bar and many other places. Can't be renamed by the user.
508      *
509      * @see #getDisplayName()
510      */
getCarrierName()511     public CharSequence getCarrierName() {
512         return mCarrierName;
513     }
514 
515     /**
516      * @return The source of the {@link #getDisplayName()}.
517      *
518      * @hide
519      */
520     @SimDisplayNameSource
getDisplayNameSource()521     public int getDisplayNameSource() {
522         return mDisplayNameSource;
523     }
524 
525     /**
526      * Creates and returns an icon {@code Bitmap} to represent this {@code SubscriptionInfo} in a
527      * user interface.
528      *
529      * @param context A {@code Context} to get the {@code DisplayMetrics}s from.
530      *
531      * @return A bitmap icon for this {@code SubscriptionInfo}.
532      */
createIconBitmap(Context context)533     public Bitmap createIconBitmap(Context context) {
534         if (mIconBitmap == null) {
535             mIconBitmap = BitmapFactory.decodeResource(context.getResources(),
536                     com.android.internal.R.drawable.ic_sim_card_multi_24px_clr);
537         }
538         int width = mIconBitmap.getWidth();
539         int height = mIconBitmap.getHeight();
540         DisplayMetrics metrics = context.getResources().getDisplayMetrics();
541 
542         // Create a new bitmap of the same size because it will be modified.
543         Bitmap workingBitmap = Bitmap.createBitmap(metrics, width, height, mIconBitmap.getConfig());
544 
545         Canvas canvas = new Canvas(workingBitmap);
546         Paint paint = new Paint();
547 
548         // Tint the icon with the color.
549         paint.setColorFilter(new PorterDuffColorFilter(mIconTint, PorterDuff.Mode.SRC_ATOP));
550         canvas.drawBitmap(mIconBitmap, 0, 0, paint);
551         paint.setColorFilter(null);
552 
553         // Write the sim slot index.
554         paint.setAntiAlias(true);
555         paint.setTypeface(Typeface.create("sans-serif", Typeface.NORMAL));
556         paint.setColor(Color.WHITE);
557         // Set text size scaled by density
558         paint.setTextSize(TEXT_SIZE * metrics.density);
559         // Convert sim slot index to localized string
560         final String index = formatSimple("%d", mSimSlotIndex + 1);
561         final Rect textBound = new Rect();
562         paint.getTextBounds(index, 0, 1, textBound);
563         final float xOffset = (width / 2.f) - textBound.centerX();
564         final float yOffset = (height / 2.f) - textBound.centerY();
565         canvas.drawText(index, xOffset, yOffset, paint);
566 
567         return workingBitmap;
568     }
569 
570     /**
571      * A highlight color to use in displaying information about this {@code PhoneAccount}.
572      *
573      * @return A hexadecimal color value.
574      */
getIconTint()575     public int getIconTint() {
576         return mIconTint;
577     }
578 
579     /**
580      * Returns the number of this subscription.
581      *
582      * Starting with API level 30, returns the number of this subscription if the calling app meets
583      * at least one of the following requirements:
584      * <ul>
585      *     <li>If the calling app's target SDK is API level 29 or lower and the app has been granted
586      *     the READ_PHONE_STATE permission.
587      *     <li>If the calling app has been granted any of READ_PRIVILEGED_PHONE_STATE,
588      *     READ_PHONE_NUMBERS, or READ_SMS.
589      *     <li>If the calling app has carrier privileges (see {@link
590      *     TelephonyManager#hasCarrierPrivileges}).
591      *     <li>If the calling app is the default SMS role holder.
592      * </ul>
593      *
594      * @return the number of this subscription, or an empty string if none of the requirements
595      * are met.
596      * @deprecated use {@link SubscriptionManager#getPhoneNumber(int)} instead, which takes a
597      *             {@link #getSubscriptionId() subscription ID}.
598      */
599     @Deprecated
getNumber()600     public String getNumber() {
601         return mNumber;
602     }
603 
604     /**
605      * Whether user enables data roaming for this subscription or not. Either
606      * {@link SubscriptionManager#DATA_ROAMING_ENABLE} or
607      * {@link SubscriptionManager#DATA_ROAMING_DISABLE}.
608      */
getDataRoaming()609     public int getDataRoaming() {
610         return mDataRoaming;
611     }
612 
613     /**
614      * @return The mobile country code.
615      *
616      * @deprecated Use {@link #getMccString()} instead.
617      */
618     @Deprecated
getMcc()619     public int getMcc() {
620         try {
621             return TextUtils.isEmpty(mMcc) ? 0 : Integer.parseInt(mMcc);
622         } catch (NumberFormatException e) {
623             Log.w(SubscriptionInfo.class.getSimpleName(), "MCC string is not a number: " + mMcc);
624             return 0;
625         }
626     }
627 
628     /**
629      * @return The mobile network code.
630      *
631      * @deprecated Use {@link #getMncString()} instead.
632      */
633     @Deprecated
getMnc()634     public int getMnc() {
635         try {
636             return TextUtils.isEmpty(mMnc) ? 0 : Integer.parseInt(mMnc);
637         } catch (NumberFormatException e) {
638             Log.w(SubscriptionInfo.class.getSimpleName(), "MNC string is not a number: " + mMnc);
639             return 0;
640         }
641     }
642 
643     /**
644      * @return The mobile country code.
645      */
646     @Nullable
getMccString()647     public String getMccString() {
648         return mMcc;
649     }
650 
651     /**
652      * @return The mobile network code.
653      */
654     @Nullable
getMncString()655     public String getMncString() {
656         return mMnc;
657     }
658 
659     /**
660      * @return The ISO country code. Empty if not available.
661      */
getCountryIso()662     public String getCountryIso() {
663         return mCountryIso;
664     }
665 
666     /**
667      * @return {@code true} if the subscription is from eSIM.
668      */
isEmbedded()669     public boolean isEmbedded() {
670         return mIsEmbedded;
671     }
672 
673     /**
674      * An opportunistic subscription connects to a network that is
675      * limited in functionality and / or coverage.
676      *
677      * @return Whether subscription is opportunistic.
678      */
isOpportunistic()679     public boolean isOpportunistic() {
680         return mIsOpportunistic;
681     }
682 
683     /**
684      * @return {@code true} if the subscription is from the actively used SIM.
685      *
686      * @hide
687      */
isActive()688     public boolean isActive() {
689         return mSimSlotIndex >= 0 || mType == SubscriptionManager.SUBSCRIPTION_TYPE_REMOTE_SIM;
690     }
691 
692     /**
693      * Used in scenarios where different subscriptions are bundled as a group.
694      * It's typically a primary and an opportunistic subscription. (see {@link #isOpportunistic()})
695      * Such that those subscriptions will have some affiliated behaviors such as opportunistic
696      * subscription may be invisible to the user.
697      *
698      * @return Group UUID a String of group UUID if it belongs to a group. Otherwise
699      * {@code null}.
700      */
701     @Nullable
getGroupUuid()702     public ParcelUuid getGroupUuid() {
703         return mGroupUuid;
704     }
705 
706     /**
707      * @hide
708      */
709     @NonNull
getEhplmns()710     public List<String> getEhplmns() {
711         return Collections.unmodifiableList(mEhplmns == null
712                 ? Collections.emptyList() : Arrays.asList(mEhplmns));
713     }
714 
715     /**
716      * @hide
717      */
718     @NonNull
getHplmns()719     public List<String> getHplmns() {
720         return Collections.unmodifiableList(mHplmns == null
721                 ? Collections.emptyList() : Arrays.asList(mHplmns));
722     }
723 
724     /**
725      * @return The owner package of group the subscription belongs to.
726      *
727      * @hide
728      */
729     @NonNull
getGroupOwner()730     public String getGroupOwner() {
731         return mGroupOwner;
732     }
733 
734     /**
735      * @return The profile class populated from the profile metadata if present. Otherwise,
736      * the profile class defaults to {@link SubscriptionManager#PROFILE_CLASS_UNSET} if there is no
737      * profile metadata or the subscription is not on an eUICC ({@link #isEmbedded} return
738      * {@code false}).
739      *
740      * @hide
741      */
742     @SystemApi
743     @ProfileClass
getProfileClass()744     public int getProfileClass() {
745         return mProfileClass;
746     }
747 
748     /**
749      * This method returns the type of a subscription. It can be
750      * {@link SubscriptionManager#SUBSCRIPTION_TYPE_LOCAL_SIM} or
751      * {@link SubscriptionManager#SUBSCRIPTION_TYPE_REMOTE_SIM}.
752      *
753      * @return The type of the subscription.
754      */
755     @SubscriptionType
getSubscriptionType()756     public int getSubscriptionType() {
757         return mType;
758     }
759 
760     /**
761      * Checks whether the app with the given context is authorized to manage this subscription
762      * according to its metadata. Only supported for embedded subscriptions (if {@link #isEmbedded}
763      * returns true).
764      *
765      * @param context Context of the application to check.
766      * @return Whether the app is authorized to manage this subscription per its metadata.
767      * @hide
768      * @deprecated - Do not use.
769      */
770     @Deprecated
canManageSubscription(Context context)771     public boolean canManageSubscription(Context context) {
772         return canManageSubscription(context, context.getPackageName());
773     }
774 
775     /**
776      * Checks whether the given app is authorized to manage this subscription according to its
777      * metadata. Only supported for embedded subscriptions (if {@link #isEmbedded} returns true).
778      *
779      * @param context Any context.
780      * @param packageName Package name of the app to check.
781      * @return whether the app is authorized to manage this subscription per its metadata.
782      * @hide
783      * @deprecated - Do not use.
784      */
785     @Deprecated
canManageSubscription(Context context, String packageName)786     public boolean canManageSubscription(Context context, String packageName) {
787         List<UiccAccessRule> allAccessRules = getAccessRules();
788         if (allAccessRules == null) {
789             return false;
790         }
791         PackageManager packageManager = context.getPackageManager();
792         PackageInfo packageInfo;
793         try {
794             packageInfo = packageManager.getPackageInfo(packageName,
795                 PackageManager.GET_SIGNING_CERTIFICATES);
796         } catch (PackageManager.NameNotFoundException e) {
797             Log.d("SubscriptionInfo", "canManageSubscription: Unknown package: " + packageName, e);
798             return false;
799         }
800         for (UiccAccessRule rule : allAccessRules) {
801             if (rule.getCarrierPrivilegeStatus(packageInfo)
802                     == TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
803                 return true;
804             }
805         }
806         return false;
807     }
808 
809     /**
810      * @return The {@link UiccAccessRule}s that are stored in Uicc, dictating who is authorized to
811      * manage this subscription.
812      *
813      * @hide
814      */
815     @SystemApi
816     @Nullable
getAccessRules()817     public List<UiccAccessRule> getAccessRules() {
818         List<UiccAccessRule> merged = new ArrayList<>();
819         if (mNativeAccessRules != null) {
820             merged.addAll(Arrays.asList(mNativeAccessRules));
821         }
822         if (mCarrierConfigAccessRules != null) {
823             merged.addAll(Arrays.asList(mCarrierConfigAccessRules));
824         }
825         return merged.isEmpty() ? null : Collections.unmodifiableList(merged);
826     }
827 
828     /**
829      * Returns the card string of the SIM card which contains the subscription.
830      *
831      * Starting with API level 29 Security Patch 2021-04-05, returns the card string if the calling
832      * app has been granted the READ_PRIVILEGED_PHONE_STATE permission, has carrier privileges (see
833      * {@link TelephonyManager#hasCarrierPrivileges}), or is a device owner or profile owner that
834      * has been granted the READ_PHONE_STATE permission. The profile owner is an app that owns a
835      * managed profile on the device; for more details see <a
836      * href="https://developer.android.com/work/managed-profiles">Work profiles</a>. Profile
837      * owner access is deprecated and will be removed in a future release.
838      *
839      * @return The card string of the SIM card which contains the subscription or an empty string
840      * if these requirements are not met. The card string is the ICCID for UICCs or the EID for
841      * eUICCs.
842      *
843      * @hide
844      */
845     @NonNull
getCardString()846     public String getCardString() {
847         return mCardString;
848     }
849 
850     /**
851      * @return The card ID of the SIM card which contains the subscription.
852      *
853      * @see UiccCardInfo#getCardId().
854      */
getCardId()855     public int getCardId() {
856         return mCardId;
857     }
858     /**
859      * @return The port index of the SIM card which contains the subscription.
860      */
getPortIndex()861     public int getPortIndex() {
862         return mPortIndex;
863     }
864 
865     /**
866      * @return {@code true} if the group of the subscription is disabled. This is only useful if
867      * it's a grouped opportunistic subscription. In this case, if all primary (non-opportunistic)
868      * subscriptions in the group are deactivated (unplugged pSIM or deactivated eSIM profile), we
869      * should disable this opportunistic subscription.
870      *
871      * @hide
872      */
873     @SystemApi
isGroupDisabled()874     public boolean isGroupDisabled() {
875         return mIsGroupDisabled;
876     }
877 
878     /**
879      * @return {@code true} if Uicc applications are set to be enabled or disabled.
880      * @hide
881      */
882     @SystemApi
areUiccApplicationsEnabled()883     public boolean areUiccApplicationsEnabled() {
884         return mAreUiccApplicationsEnabled;
885     }
886 
887     /**
888      * Get the usage setting for this subscription.
889      *
890      * @return The usage setting used for this subscription.
891      */
892     @UsageSetting
getUsageSetting()893     public int getUsageSetting() {
894         return mUsageSetting;
895     }
896 
897     /**
898      * Check if the subscription is exclusively for non-terrestrial networks.
899      *
900      * @return {@code true} if it is a non-terrestrial network subscription, {@code false}
901      * otherwise.
902      */
isOnlyNonTerrestrialNetwork()903     public boolean isOnlyNonTerrestrialNetwork() {
904         return mIsOnlyNonTerrestrialNetwork;
905     }
906 
907 
908     /**
909      * Checks if the subscription is supported ESOS over Carrier Roaming NB-IOT Satellite.
910      *
911      * @return {@code true} if the subscription supports ESOS over Carrier Roaming NB-IOT Satellite,
912      * {@code false} otherwise.
913      * @hide
914      */
915     @FlaggedApi(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN)
isSatelliteESOSSupported()916     public boolean isSatelliteESOSSupported() {
917         return mIsSatelliteESOSSupported;
918     }
919 
920     // TODO(b/316183370): replace @code with @link in javadoc after feature is released
921     /**
922      * Retrieves the service capabilities for the current subscription.
923      *
924      * <p>These capabilities are hint to system components and applications, allowing them to
925      * enhance user experience. For instance, a Dialer application can inform the user that the
926      * current subscription is incapable of making voice calls if the voice service is not
927      * available.
928      *
929      * <p>Correct usage of these service capabilities must also consider the device's overall
930      * service capabilities. For example, even if the subscription supports voice calls, a voice
931      * call might not be feasible on a device that only supports data services. To determine the
932      * device's capabilities for voice and SMS services, refer to
933      * {@code TelephonyManager#isDeviceVoiceCapable()} and
934      * {@code TelephonyManager#isDeviceSmsCapable()}.
935      *
936      * <p>Emergency service availability may not directly correlate with the subscription or
937      * device's general service capabilities. In some cases, emergency calls might be possible
938      * even if the subscription or device does not typically support voice services.
939      *
940      * @return A set of integer representing the subscription's service capabilities,
941      * defined by {@code SubscriptionManager#SERVICE_CAPABILITY_VOICE},
942      * {@code SubscriptionManager#SERVICE_CAPABILITY_SMS}
943      * and {@code SubscriptionManager#SERVICE_CAPABILITY_DATA}.
944      *
945      * @see TelephonyManager#isDeviceVoiceCapable()
946      * @see TelephonyManager#isDeviceSmsCapable()
947      * @see CarrierConfigManager#KEY_CELLULAR_SERVICE_CAPABILITIES_INT_ARRAY
948      * @see SubscriptionManager#SERVICE_CAPABILITY_VOICE
949      * @see SubscriptionManager#SERVICE_CAPABILITY_SMS
950      * @see SubscriptionManager#SERVICE_CAPABILITY_DATA
951      */
952     @NonNull
getServiceCapabilities()953     public @SubscriptionManager.ServiceCapability Set<Integer> getServiceCapabilities() {
954         return SubscriptionManager.getServiceCapabilitiesSet(mServiceCapabilities);
955     }
956 
957     /**
958      * Get the transfer status for this subscription.
959      *
960      * @return The transfer status for this subscription.
961      *
962      * @hide
963      */
964     @FlaggedApi(Flags.FLAG_SUPPORT_PSIM_TO_ESIM_CONVERSION)
965     @SystemApi
getTransferStatus()966     public @TransferStatus int getTransferStatus() {
967         return mTransferStatus;
968     }
969 
970     @NonNull
971     public static final Parcelable.Creator<SubscriptionInfo> CREATOR =
972             new Parcelable.Creator<SubscriptionInfo>() {
973         @Override
974         public SubscriptionInfo createFromParcel(Parcel source) {
975             return new Builder()
976                     .setId(source.readInt())
977                     .setIccId(source.readString())
978                     .setSimSlotIndex(source.readInt())
979                     .setDisplayName(TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source))
980                     .setCarrierName(TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(source))
981                     .setDisplayNameSource(source.readInt())
982                     .setIconTint(source.readInt())
983                     .setNumber(source.readString())
984                     .setDataRoaming(source.readInt())
985                     .setMcc(source.readString())
986                     .setMnc(source.readString())
987                     .setCountryIso(source.readString())
988                     .setEmbedded(source.readBoolean())
989                     .setNativeAccessRules(source.createTypedArray(UiccAccessRule.CREATOR))
990                     .setCardString(source.readString())
991                     .setCardId(source.readInt())
992                     .setPortIndex(source.readInt())
993                     .setOpportunistic(source.readBoolean())
994                     .setGroupUuid(source.readString8())
995                     .setGroupDisabled(source.readBoolean())
996                     .setCarrierId(source.readInt())
997                     .setProfileClass(source.readInt())
998                     .setType(source.readInt())
999                     .setEhplmns(source.createStringArray())
1000                     .setHplmns(source.createStringArray())
1001                     .setGroupOwner(source.readString())
1002                     .setCarrierConfigAccessRules(source.createTypedArray(
1003                             UiccAccessRule.CREATOR))
1004                     .setUiccApplicationsEnabled(source.readBoolean())
1005                     .setUsageSetting(source.readInt())
1006                     .setOnlyNonTerrestrialNetwork(source.readBoolean())
1007                     .setServiceCapabilities(
1008                             SubscriptionManager.getServiceCapabilitiesSet(source.readInt()))
1009                     .setTransferStatus(source.readInt())
1010                     .setSatelliteESOSSupported(source.readBoolean())
1011                     .build();
1012         }
1013 
1014         @Override
1015         public SubscriptionInfo[] newArray(int size) {
1016             return new SubscriptionInfo[size];
1017         }
1018     };
1019 
1020     @Override
writeToParcel(Parcel dest, int flags)1021     public void writeToParcel(Parcel dest, int flags) {
1022         dest.writeInt(mId);
1023         dest.writeString(mIccId);
1024         dest.writeInt(mSimSlotIndex);
1025         TextUtils.writeToParcel(mDisplayName, dest, 0);
1026         TextUtils.writeToParcel(mCarrierName, dest, 0);
1027         dest.writeInt(mDisplayNameSource);
1028         dest.writeInt(mIconTint);
1029         dest.writeString(mNumber);
1030         dest.writeInt(mDataRoaming);
1031         dest.writeString(mMcc);
1032         dest.writeString(mMnc);
1033         dest.writeString(mCountryIso);
1034         // Do not write mIconBitmap since it should be lazily loaded on first usage
1035         dest.writeBoolean(mIsEmbedded);
1036         dest.writeTypedArray(mNativeAccessRules, flags);
1037         dest.writeString(mCardString);
1038         dest.writeInt(mCardId);
1039         dest.writeInt(mPortIndex);
1040         dest.writeBoolean(mIsOpportunistic);
1041         dest.writeString8(mGroupUuid == null ? null : mGroupUuid.toString());
1042         dest.writeBoolean(mIsGroupDisabled);
1043         dest.writeInt(mCarrierId);
1044         dest.writeInt(mProfileClass);
1045         dest.writeInt(mType);
1046         dest.writeStringArray(mEhplmns);
1047         dest.writeStringArray(mHplmns);
1048         dest.writeString(mGroupOwner);
1049         dest.writeTypedArray(mCarrierConfigAccessRules, flags);
1050         dest.writeBoolean(mAreUiccApplicationsEnabled);
1051         dest.writeInt(mUsageSetting);
1052         dest.writeBoolean(mIsOnlyNonTerrestrialNetwork);
1053         dest.writeInt(mServiceCapabilities);
1054         dest.writeInt(mTransferStatus);
1055         dest.writeBoolean(mIsSatelliteESOSSupported);
1056     }
1057 
1058     @Override
describeContents()1059     public int describeContents() {
1060         return 0;
1061     }
1062 
1063     /**
1064      * Get stripped PII information from the id.
1065      *
1066      * @param id The raw id (e.g. ICCID, IMSI, etc...).
1067      * @return The stripped string.
1068      *
1069      * @hide
1070      */
1071     @Nullable
getPrintableId(@ullable String id)1072     public static String getPrintableId(@Nullable String id) {
1073         String idToPrint = null;
1074         if (id != null) {
1075             if (id.length() > 9 && !TelephonyUtils.IS_DEBUGGABLE) {
1076                 idToPrint = id.substring(0, 9) + Rlog.pii(false, id.substring(9));
1077             } else {
1078                 idToPrint = id;
1079             }
1080         }
1081         return idToPrint;
1082     }
1083 
1084     @Override
toString()1085     public String toString() {
1086         String iccIdToPrint = getPrintableId(mIccId);
1087         String cardStringToPrint = getPrintableId(mCardString);
1088         return "[SubscriptionInfo: id=" + mId
1089                 + " iccId=" + iccIdToPrint
1090                 + " simSlotIndex=" + mSimSlotIndex
1091                 + " portIndex=" + mPortIndex
1092                 + " isEmbedded=" + mIsEmbedded
1093                 + " carrierId=" + mCarrierId
1094                 + " displayName=" + mDisplayName
1095                 + " carrierName=" + mCarrierName
1096                 + " isOpportunistic=" + mIsOpportunistic
1097                 + " groupUuid=" + mGroupUuid
1098                 + " groupOwner=" + mGroupOwner
1099                 + " isGroupDisabled=" + mIsGroupDisabled
1100                 + " displayNameSource="
1101                 + SubscriptionManager.displayNameSourceToString(mDisplayNameSource)
1102                 + " iconTint=" + mIconTint
1103                 + " number=" + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, mNumber)
1104                 + " dataRoaming=" + mDataRoaming
1105                 + " mcc=" + mMcc
1106                 + " mnc=" + mMnc
1107                 + " ehplmns=" + Arrays.toString(mEhplmns)
1108                 + " hplmns=" + Arrays.toString(mHplmns)
1109                 + " cardString=" + cardStringToPrint
1110                 + " cardId=" + mCardId
1111                 + " nativeAccessRules=" + Arrays.toString(mNativeAccessRules)
1112                 + " carrierConfigAccessRules=" + Arrays.toString(mCarrierConfigAccessRules)
1113                 + " countryIso=" + mCountryIso
1114                 + " profileClass=" + mProfileClass
1115                 + " mType=" + SubscriptionManager.subscriptionTypeToString(mType)
1116                 + " areUiccApplicationsEnabled=" + mAreUiccApplicationsEnabled
1117                 + " usageSetting=" + SubscriptionManager.usageSettingToString(mUsageSetting)
1118                 + " isOnlyNonTerrestrialNetwork=" + mIsOnlyNonTerrestrialNetwork
1119                 + " serviceCapabilities=" + SubscriptionManager.getServiceCapabilitiesSet(
1120                 mServiceCapabilities).toString()
1121                 + " transferStatus=" + mTransferStatus
1122                 + " isSatelliteESOSSupported=" + mIsSatelliteESOSSupported
1123                 + "]";
1124     }
1125 
1126     @Override
equals(Object o)1127     public boolean equals(Object o) {
1128         if (this == o) return true;
1129         if (o == null || getClass() != o.getClass()) return false;
1130         SubscriptionInfo that = (SubscriptionInfo) o;
1131         return mId == that.mId && mSimSlotIndex == that.mSimSlotIndex
1132                 && mDisplayNameSource == that.mDisplayNameSource && mIconTint == that.mIconTint
1133                 && mDataRoaming == that.mDataRoaming && mIsEmbedded == that.mIsEmbedded
1134                 && mIsOpportunistic == that.mIsOpportunistic && mCarrierId == that.mCarrierId
1135                 && mProfileClass == that.mProfileClass && mType == that.mType
1136                 && mAreUiccApplicationsEnabled == that.mAreUiccApplicationsEnabled
1137                 && mPortIndex == that.mPortIndex && mUsageSetting == that.mUsageSetting
1138                 && mCardId == that.mCardId && mIsGroupDisabled == that.mIsGroupDisabled
1139                 && mIccId.equals(that.mIccId) && mDisplayName.equals(that.mDisplayName)
1140                 && mCarrierName.equals(that.mCarrierName) && mNumber.equals(that.mNumber)
1141                 && Objects.equals(mMcc, that.mMcc) && Objects.equals(mMnc,
1142                 that.mMnc) && Arrays.equals(mEhplmns, that.mEhplmns)
1143                 && Arrays.equals(mHplmns, that.mHplmns) && mCardString.equals(
1144                 that.mCardString) && Arrays.equals(mNativeAccessRules,
1145                 that.mNativeAccessRules) && Arrays.equals(mCarrierConfigAccessRules,
1146                 that.mCarrierConfigAccessRules) && Objects.equals(mGroupUuid, that.mGroupUuid)
1147                 && mCountryIso.equals(that.mCountryIso) && mGroupOwner.equals(that.mGroupOwner)
1148                 && mIsOnlyNonTerrestrialNetwork == that.mIsOnlyNonTerrestrialNetwork
1149                 && mServiceCapabilities == that.mServiceCapabilities
1150                 && mTransferStatus == that.mTransferStatus
1151                 && mIsSatelliteESOSSupported == that.mIsSatelliteESOSSupported;
1152     }
1153 
1154     @Override
hashCode()1155     public int hashCode() {
1156         int result = Objects.hash(mId, mIccId, mSimSlotIndex, mDisplayName, mCarrierName,
1157                 mDisplayNameSource, mIconTint, mNumber, mDataRoaming, mMcc, mMnc, mIsEmbedded,
1158                 mCardString, mIsOpportunistic, mGroupUuid, mCountryIso, mCarrierId, mProfileClass,
1159                 mType, mGroupOwner, mAreUiccApplicationsEnabled, mPortIndex, mUsageSetting, mCardId,
1160                 mIsGroupDisabled, mIsOnlyNonTerrestrialNetwork, mServiceCapabilities,
1161                 mTransferStatus, mIsSatelliteESOSSupported);
1162         result = 31 * result + Arrays.hashCode(mEhplmns);
1163         result = 31 * result + Arrays.hashCode(mHplmns);
1164         result = 31 * result + Arrays.hashCode(mNativeAccessRules);
1165         result = 31 * result + Arrays.hashCode(mCarrierConfigAccessRules);
1166         return result;
1167     }
1168 
1169     /**
1170      * The builder class of {@link SubscriptionInfo}.
1171      *
1172      * @hide
1173      */
1174     public static class Builder {
1175         /**
1176          * The subscription id.
1177          */
1178         private int mId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
1179 
1180         /**
1181          * The ICCID of the SIM that is associated with this subscription, empty if unknown.
1182          */
1183         @NonNull
1184         private String mIccId = "";
1185 
1186         /**
1187          * The index of the SIM slot that currently contains the subscription and not necessarily
1188          * unique and maybe {@link SubscriptionManager#INVALID_SIM_SLOT_INDEX} if unknown or the
1189          * subscription is inactive.
1190          */
1191         private int mSimSlotIndex = SubscriptionManager.INVALID_SIM_SLOT_INDEX;
1192 
1193         /**
1194          * The name displayed to the user that identifies this subscription. This name is used
1195          * in Settings page and can be renamed by the user.
1196          */
1197         @NonNull
1198         private CharSequence mDisplayName = "";
1199 
1200         /**
1201          * The name displayed to the user that identifies subscription provider name. This name
1202          * is the SPN displayed in status bar and many other places. Can't be renamed by the user.
1203          */
1204         @NonNull
1205         private CharSequence mCarrierName = "";
1206 
1207         /**
1208          * The source of the display name.
1209          */
1210         @SimDisplayNameSource
1211         private int mDisplayNameSource = SubscriptionManager.NAME_SOURCE_UNKNOWN;
1212 
1213         /**
1214          * The color to be used for tinting the icon when displaying to the user.
1215          */
1216         private int mIconTint = 0;
1217 
1218         /**
1219          * The number presented to the user identify this subscription.
1220          */
1221         @NonNull
1222         private String mNumber = "";
1223 
1224         /**
1225          * Whether user enables data roaming for this subscription or not. Either
1226          * {@link SubscriptionManager#DATA_ROAMING_ENABLE} or
1227          * {@link SubscriptionManager#DATA_ROAMING_DISABLE}.
1228          */
1229         private int mDataRoaming = SubscriptionManager.DATA_ROAMING_DISABLE;
1230 
1231         /**
1232          * SIM icon bitmap cache.
1233          */
1234         @Nullable
1235         private Bitmap mIconBitmap = null;
1236 
1237         /**
1238          * The mobile country code.
1239          */
1240         @Nullable
1241         private String mMcc = null;
1242 
1243         /**
1244          * The mobile network code.
1245          */
1246         @Nullable
1247         private String mMnc = null;
1248 
1249         /**
1250          * EHPLMNs associated with the subscription.
1251          */
1252         @NonNull
1253         private String[] mEhplmns = new String[0];
1254 
1255         /**
1256          * HPLMNs associated with the subscription.
1257          */
1258         @NonNull
1259         private String[] mHplmns = new String[0];
1260 
1261         /**
1262          * The ISO Country code for the subscription's provider.
1263          */
1264         @NonNull
1265         private String mCountryIso = "";
1266 
1267         /**
1268          * Whether the subscription is from eSIM.
1269          */
1270         private boolean mIsEmbedded = false;
1271 
1272         /**
1273          * The native access rules for this subscription, if it is embedded and defines any. This
1274          * does not include access rules for non-embedded subscriptions.
1275          */
1276         @Nullable
1277         private UiccAccessRule[] mNativeAccessRules = null;
1278 
1279         /**
1280          * The card string of the SIM card.
1281          */
1282         @NonNull
1283         private String mCardString = "";
1284 
1285         /**
1286          * The card ID of the SIM card which contains the subscription.
1287          */
1288         private int mCardId = TelephonyManager.UNINITIALIZED_CARD_ID;
1289 
1290         /**
1291          * Whether the subscription is opportunistic or not.
1292          */
1293         private boolean mIsOpportunistic = false;
1294 
1295         /**
1296          * The group UUID of the subscription group.
1297          */
1298         @Nullable
1299         private ParcelUuid mGroupUuid = null;
1300 
1301         /**
1302          * Whether group of the subscription is disabled. This is only useful if it's a grouped
1303          * opportunistic subscription. In this case, if all primary (non-opportunistic)
1304          * subscriptions in the group are deactivated (unplugged pSIM or deactivated eSIM profile),
1305          * we should disable this opportunistic subscription.
1306          */
1307         private boolean mIsGroupDisabled = false;
1308 
1309         /**
1310          * The carrier id.
1311          *
1312          * @see TelephonyManager#getSimCarrierId()
1313          */
1314         private int mCarrierId = TelephonyManager.UNKNOWN_CARRIER_ID;
1315 
1316         /**
1317          * The profile class populated from the profile metadata if present. Otherwise, the profile
1318          * class defaults to {@link SubscriptionManager#PROFILE_CLASS_UNSET} if there is no profile
1319          * metadata or the subscription is not on an eUICC ({@link #isEmbedded} returns
1320          * {@code false}).
1321          */
1322         @ProfileClass
1323         private int mProfileClass = SubscriptionManager.PROFILE_CLASS_UNSET;
1324 
1325         /**
1326          * The subscription type.
1327          */
1328         @SubscriptionType
1329         private int mType = SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM;
1330 
1331         /**
1332          * The owner package of group the subscription belongs to.
1333          */
1334         @NonNull
1335         private String mGroupOwner = "";
1336 
1337         /**
1338          * The carrier certificates for this subscription that are saved in carrier configs.
1339          * This does not include access rules from the Uicc, whether embedded or non-embedded.
1340          */
1341         @Nullable
1342         private UiccAccessRule[] mCarrierConfigAccessRules = null;
1343 
1344         /**
1345          * Whether Uicc applications are configured to enable or not.
1346          */
1347         private boolean mAreUiccApplicationsEnabled = true;
1348 
1349         /**
1350          * the port index of the Uicc card.
1351          */
1352         private int mPortIndex = TelephonyManager.INVALID_PORT_INDEX;
1353 
1354         /**
1355          * Subscription's preferred usage setting.
1356          */
1357         @UsageSetting
1358         private int mUsageSetting = SubscriptionManager.USAGE_SETTING_UNKNOWN;
1359 
1360         /**
1361          * {@code true} if it is a non-terrestrial network subscription, {@code false} otherwise.
1362          */
1363         private boolean mIsOnlyNonTerrestrialNetwork = false;
1364 
1365         private int mTransferStatus = 0;
1366 
1367         /**
1368          * Service capabilities bitmasks the subscription supports.
1369          */
1370         private int mServiceCapabilities = 0;
1371         /**
1372          * {@code true} if the subscription supports ESOS over Carrier Roaming NB-IOT Satellite.
1373          * {@code false} otherwise.
1374          */
1375         private boolean mIsSatelliteESOSSupported = false;
1376 
1377         /**
1378          * Default constructor.
1379          */
Builder()1380         public Builder() {
1381         }
1382 
1383         /**
1384          * Constructor from {@link SubscriptionInfo}.
1385          *
1386          * @param info The subscription info.
1387          */
Builder(@onNull SubscriptionInfo info)1388         public Builder(@NonNull SubscriptionInfo info) {
1389             mId = info.mId;
1390             mIccId = info.mIccId;
1391             mSimSlotIndex = info.mSimSlotIndex;
1392             mDisplayName = info.mDisplayName;
1393             mCarrierName = info.mCarrierName;
1394             mDisplayNameSource = info.mDisplayNameSource;
1395             mIconTint = info.mIconTint;
1396             mNumber = info.mNumber;
1397             mDataRoaming = info.mDataRoaming;
1398             mIconBitmap = info.mIconBitmap;
1399             mMcc = info.mMcc;
1400             mMnc = info.mMnc;
1401             mEhplmns = info.mEhplmns;
1402             mHplmns = info.mHplmns;
1403             mCountryIso = info.mCountryIso;
1404             mIsEmbedded = info.mIsEmbedded;
1405             mNativeAccessRules = info.mNativeAccessRules;
1406             mCardString = info.mCardString;
1407             mCardId = info.mCardId;
1408             mIsOpportunistic = info.mIsOpportunistic;
1409             mGroupUuid = info.mGroupUuid;
1410             mIsGroupDisabled = info.mIsGroupDisabled;
1411             mCarrierId = info.mCarrierId;
1412             mProfileClass = info.mProfileClass;
1413             mType = info.mType;
1414             mGroupOwner = info.mGroupOwner;
1415             mCarrierConfigAccessRules = info.mCarrierConfigAccessRules;
1416             mAreUiccApplicationsEnabled = info.mAreUiccApplicationsEnabled;
1417             mPortIndex = info.mPortIndex;
1418             mUsageSetting = info.mUsageSetting;
1419             mIsOnlyNonTerrestrialNetwork = info.mIsOnlyNonTerrestrialNetwork;
1420             mServiceCapabilities = info.mServiceCapabilities;
1421             mTransferStatus = info.mTransferStatus;
1422             mIsSatelliteESOSSupported = info.mIsSatelliteESOSSupported;
1423         }
1424 
1425         /**
1426          * Set the subscription id.
1427          *
1428          * @param id The subscription id.
1429          * @return The builder.
1430          */
1431         @NonNull
setId(int id)1432         public Builder setId(int id) {
1433             mId = id;
1434             return this;
1435         }
1436 
1437         /**
1438          * Set the ICCID of the SIM that is associated with this subscription.
1439          *
1440          * @param iccId The ICCID of the SIM that is associated with this subscription.
1441          * @return The builder.
1442          */
1443         @NonNull
setIccId(@ullable String iccId)1444         public Builder setIccId(@Nullable String iccId) {
1445             mIccId = TextUtils.emptyIfNull(iccId);
1446             return this;
1447         }
1448 
1449         /**
1450          * Set the SIM index of the slot that currently contains the subscription. Set to
1451          * {@link SubscriptionManager#INVALID_SIM_SLOT_INDEX} if the subscription is inactive.
1452          *
1453          * @param simSlotIndex The SIM slot index.
1454          * @return The builder.
1455          */
1456         @NonNull
setSimSlotIndex(int simSlotIndex)1457         public Builder setSimSlotIndex(int simSlotIndex) {
1458             mSimSlotIndex = simSlotIndex;
1459             return this;
1460         }
1461 
1462         /**
1463          * The name displayed to the user that identifies this subscription. This name is used
1464          * in Settings page and can be renamed by the user.
1465          *
1466          * @param displayName The display name.
1467          * @return The builder.
1468          */
1469         @NonNull
setDisplayName(@ullable CharSequence displayName)1470         public Builder setDisplayName(@Nullable CharSequence displayName) {
1471             mDisplayName = displayName == null ? "" : displayName;
1472             return this;
1473         }
1474 
1475         /**
1476          * The name displayed to the user that identifies subscription provider name. This name
1477          * is the SPN displayed in status bar and many other places. Can't be renamed by the user.
1478          *
1479          * @param carrierName The carrier name.
1480          * @return The builder.
1481          */
1482         @NonNull
setCarrierName(@ullable CharSequence carrierName)1483         public Builder setCarrierName(@Nullable CharSequence carrierName) {
1484             mCarrierName = carrierName == null ? "" : carrierName;
1485             return this;
1486         }
1487 
1488         /**
1489          * Set the source of the display name.
1490          *
1491          * @param displayNameSource The source of the display name.
1492          * @return The builder.
1493          *
1494          * @see SubscriptionInfo#getDisplayName()
1495          */
1496         @NonNull
setDisplayNameSource(@imDisplayNameSource int displayNameSource)1497         public Builder setDisplayNameSource(@SimDisplayNameSource int displayNameSource) {
1498             mDisplayNameSource = displayNameSource;
1499             return this;
1500         }
1501 
1502         /**
1503          * Set the color to be used for tinting the icon when displaying to the user.
1504          *
1505          * @param iconTint The color to be used for tinting the icon when displaying to the user.
1506          * @return The builder.
1507          */
1508         @NonNull
setIconTint(int iconTint)1509         public Builder setIconTint(int iconTint) {
1510             mIconTint = iconTint;
1511             return this;
1512         }
1513 
1514         /**
1515          * Set the number presented to the user identify this subscription.
1516          *
1517          * @param number the number presented to the user identify this subscription.
1518          * @return The builder.
1519          */
1520         @NonNull
setNumber(@ullable String number)1521         public Builder setNumber(@Nullable String number) {
1522             mNumber = TextUtils.emptyIfNull(number);
1523             return this;
1524         }
1525 
1526         /**
1527          * Set whether user enables data roaming for this subscription or not.
1528          *
1529          * @param dataRoaming Data roaming mode. Either
1530          * {@link SubscriptionManager#DATA_ROAMING_ENABLE} or
1531          * {@link SubscriptionManager#DATA_ROAMING_DISABLE}
1532          * @return The builder.
1533          */
1534         @NonNull
setDataRoaming(int dataRoaming)1535         public Builder setDataRoaming(int dataRoaming) {
1536             mDataRoaming = dataRoaming;
1537             return this;
1538         }
1539 
1540         /**
1541          * Set SIM icon bitmap cache.
1542          *
1543          * @param iconBitmap SIM icon bitmap cache.
1544          * @return The builder.
1545          */
1546         @NonNull
setIcon(@ullable Bitmap iconBitmap)1547         public Builder setIcon(@Nullable Bitmap iconBitmap) {
1548             mIconBitmap = iconBitmap;
1549             return this;
1550         }
1551 
1552         /**
1553          * Set the mobile country code.
1554          *
1555          * @param mcc The mobile country code.
1556          * @return The builder.
1557          */
1558         @NonNull
setMcc(@ullable String mcc)1559         public Builder setMcc(@Nullable String mcc) {
1560             mMcc = mcc;
1561             return this;
1562         }
1563 
1564         /**
1565          * Set the mobile network code.
1566          *
1567          * @param mnc Mobile network code.
1568          * @return The builder.
1569          */
1570         @NonNull
setMnc(@ullable String mnc)1571         public Builder setMnc(@Nullable String mnc) {
1572             mMnc = mnc;
1573             return this;
1574         }
1575 
1576         /**
1577          * Set EHPLMNs associated with the subscription.
1578          *
1579          * @param ehplmns EHPLMNs associated with the subscription.
1580          * @return The builder.
1581          */
1582         @NonNull
setEhplmns(@ullable String[] ehplmns)1583         public Builder setEhplmns(@Nullable String[] ehplmns) {
1584             mEhplmns = ehplmns == null ? new String[0] : ehplmns;
1585             return this;
1586         }
1587 
1588         /**
1589          * Set HPLMNs associated with the subscription.
1590          *
1591          * @param hplmns HPLMNs associated with the subscription.
1592          * @return The builder.
1593          */
1594         @NonNull
setHplmns(@ullable String[] hplmns)1595         public Builder setHplmns(@Nullable String[] hplmns) {
1596             mHplmns = hplmns == null ? new String[0] : hplmns;
1597             return this;
1598         }
1599 
1600         /**
1601          * Set the ISO country code for the subscription's provider.
1602          *
1603          * @param countryIso The ISO country code for the subscription's provider.
1604          * @return The builder.
1605          */
1606         @NonNull
setCountryIso(@ullable String countryIso)1607         public Builder setCountryIso(@Nullable String countryIso) {
1608             mCountryIso = TextUtils.emptyIfNull(countryIso);
1609             return this;
1610         }
1611 
1612         /**
1613          * Set whether the subscription is from eSIM or not.
1614          *
1615          * @param isEmbedded {@code true} if the subscription is from eSIM.
1616          * @return The builder.
1617          */
1618         @NonNull
setEmbedded(boolean isEmbedded)1619         public Builder setEmbedded(boolean isEmbedded) {
1620             mIsEmbedded = isEmbedded;
1621             return this;
1622         }
1623 
1624         /**
1625          * Set the native access rules for this subscription, if it is embedded and defines any.
1626          * This does not include access rules for non-embedded subscriptions.
1627          *
1628          * @param nativeAccessRules The native access rules for this subscription.
1629          * @return The builder.
1630          */
1631         @NonNull
setNativeAccessRules(@ullable UiccAccessRule[] nativeAccessRules)1632         public Builder setNativeAccessRules(@Nullable UiccAccessRule[] nativeAccessRules) {
1633             mNativeAccessRules = nativeAccessRules;
1634             return this;
1635         }
1636 
1637         /**
1638          * Set the card string of the SIM card.
1639          *
1640          * @param cardString The card string of the SIM card.
1641          * @return The builder.
1642          *
1643          * @see #getCardString()
1644          */
1645         @NonNull
setCardString(@ullable String cardString)1646         public Builder setCardString(@Nullable String cardString) {
1647             mCardString = TextUtils.emptyIfNull(cardString);
1648             return this;
1649         }
1650 
1651         /**
1652          * Set the card ID of the SIM card which contains the subscription.
1653          *
1654          * @param cardId The card ID of the SIM card which contains the subscription.
1655          * @return The builder.
1656          */
1657         @NonNull
setCardId(int cardId)1658         public Builder setCardId(int cardId) {
1659             mCardId = cardId;
1660             return this;
1661         }
1662 
1663         /**
1664          * Set whether the subscription is opportunistic or not.
1665          *
1666          * @param isOpportunistic {@code true} if the subscription is opportunistic.
1667          * @return The builder.
1668          */
1669         @NonNull
setOpportunistic(boolean isOpportunistic)1670         public Builder setOpportunistic(boolean isOpportunistic) {
1671             mIsOpportunistic = isOpportunistic;
1672             return this;
1673         }
1674 
1675         /**
1676          * Set the group UUID of the subscription group.
1677          *
1678          * @param groupUuid The group UUID.
1679          * @return The builder.
1680          *
1681          * @see #getGroupUuid()
1682          */
1683         @NonNull
setGroupUuid(@ullable String groupUuid)1684         public Builder setGroupUuid(@Nullable String groupUuid) {
1685             mGroupUuid = TextUtils.isEmpty(groupUuid) ? null : ParcelUuid.fromString(groupUuid);
1686             return this;
1687         }
1688 
1689         /**
1690          * Whether group of the subscription is disabled. This is only useful if it's a grouped
1691          * opportunistic subscription. In this case, if all primary (non-opportunistic)
1692          * subscriptions in the group are deactivated (unplugged pSIM or deactivated eSIM profile),
1693          * we should disable this opportunistic subscription.
1694          *
1695          * @param isGroupDisabled {@code true} if group of the subscription is disabled.
1696          * @return The builder.
1697          */
1698         @NonNull
setGroupDisabled(boolean isGroupDisabled)1699         public Builder setGroupDisabled(boolean isGroupDisabled) {
1700             mIsGroupDisabled = isGroupDisabled;
1701             return this;
1702         }
1703 
1704         /**
1705          * Set the subscription carrier id.
1706          *
1707          * @param carrierId The carrier id.
1708          * @return The builder
1709          *
1710          * @see TelephonyManager#getSimCarrierId()
1711          */
1712         @NonNull
setCarrierId(int carrierId)1713         public Builder setCarrierId(int carrierId) {
1714             mCarrierId = carrierId;
1715             return this;
1716         }
1717 
1718         /**
1719          * Set the profile class populated from the profile metadata if present.
1720          *
1721          * @param profileClass the profile class populated from the profile metadata if present.
1722          * @return The builder
1723          *
1724          * @see #getProfileClass()
1725          */
1726         @NonNull
setProfileClass(@rofileClass int profileClass)1727         public Builder setProfileClass(@ProfileClass int profileClass) {
1728             mProfileClass = profileClass;
1729             return this;
1730         }
1731 
1732         /**
1733          * Set the subscription type.
1734          *
1735          * @param type Subscription type.
1736          * @return The builder.
1737          */
1738         @NonNull
setType(@ubscriptionType int type)1739         public Builder setType(@SubscriptionType int type) {
1740             mType = type;
1741             return this;
1742         }
1743 
1744         /**
1745          * Set the owner package of group the subscription belongs to.
1746          *
1747          * @param groupOwner Owner package of group the subscription belongs to.
1748          * @return The builder.
1749          */
1750         @NonNull
setGroupOwner(@ullable String groupOwner)1751         public Builder setGroupOwner(@Nullable String groupOwner) {
1752             mGroupOwner = TextUtils.emptyIfNull(groupOwner);
1753             return this;
1754         }
1755 
1756         /**
1757          * Set the carrier certificates for this subscription that are saved in carrier configs.
1758          * This does not include access rules from the Uicc, whether embedded or non-embedded.
1759          *
1760          * @param carrierConfigAccessRules The carrier certificates for this subscription.
1761          * @return The builder.
1762          */
1763         @NonNull
setCarrierConfigAccessRules( @ullable UiccAccessRule[] carrierConfigAccessRules)1764         public Builder setCarrierConfigAccessRules(
1765                 @Nullable UiccAccessRule[] carrierConfigAccessRules) {
1766             mCarrierConfigAccessRules = carrierConfigAccessRules;
1767             return this;
1768         }
1769 
1770         /**
1771          * Set whether Uicc applications are configured to enable or not.
1772          *
1773          * @param uiccApplicationsEnabled {@code true} if Uicc applications are configured to
1774          * enable.
1775          * @return The builder.
1776          */
1777         @NonNull
setUiccApplicationsEnabled(boolean uiccApplicationsEnabled)1778         public Builder setUiccApplicationsEnabled(boolean uiccApplicationsEnabled) {
1779             mAreUiccApplicationsEnabled = uiccApplicationsEnabled;
1780             return this;
1781         }
1782 
1783         /**
1784          * Set the port index of the Uicc card.
1785          *
1786          * @param portIndex The port index of the Uicc card.
1787          * @return The builder.
1788          */
1789         @NonNull
setPortIndex(int portIndex)1790         public Builder setPortIndex(int portIndex) {
1791             mPortIndex = portIndex;
1792             return this;
1793         }
1794 
1795         /**
1796          * Set subscription's preferred usage setting.
1797          *
1798          * @param usageSetting Subscription's preferred usage setting.
1799          * @return The builder.
1800          */
1801         @NonNull
setUsageSetting(@sageSetting int usageSetting)1802         public Builder setUsageSetting(@UsageSetting int usageSetting) {
1803             mUsageSetting = usageSetting;
1804             return this;
1805         }
1806 
1807         /**
1808          * Set whether the subscription is exclusively used for non-terrestrial networks or not.
1809          *
1810          * @param isOnlyNonTerrestrialNetwork {@code true} if the subscription is for NTN,
1811          * {@code false} otherwise.
1812          * @return The builder.
1813          */
1814         @NonNull
setOnlyNonTerrestrialNetwork(boolean isOnlyNonTerrestrialNetwork)1815         public Builder setOnlyNonTerrestrialNetwork(boolean isOnlyNonTerrestrialNetwork) {
1816             mIsOnlyNonTerrestrialNetwork = isOnlyNonTerrestrialNetwork;
1817             return this;
1818         }
1819 
1820         /**
1821          * Set the service capabilities that the subscription supports.
1822          *
1823          * @param capabilities Bitmask combination of SubscriptionManager
1824          *                     .SERVICE_CAPABILITY_XXX.
1825          * @return The builder.
1826          *
1827          * @throws IllegalArgumentException when any capability is not supported.
1828          */
1829         @NonNull
setServiceCapabilities( @onNull @ubscriptionManager.ServiceCapability Set<Integer> capabilities)1830         public Builder setServiceCapabilities(
1831                 @NonNull @SubscriptionManager.ServiceCapability Set<Integer> capabilities) {
1832             int combinedCapabilities = 0;
1833             for (int capability : capabilities) {
1834                 if (capability < SubscriptionManager.SERVICE_CAPABILITY_VOICE
1835                         || capability > SubscriptionManager.SERVICE_CAPABILITY_MAX) {
1836                     throw new IllegalArgumentException(
1837                             "Invalid service capability value: " + capability);
1838                 }
1839                 combinedCapabilities |= SubscriptionManager.serviceCapabilityToBitmask(capability);
1840             }
1841             mServiceCapabilities = combinedCapabilities;
1842             return this;
1843         }
1844          /**
1845          * Set subscription's transfer status
1846          *
1847          * @param status Subscription's transfer status
1848          * @return The builder.
1849          */
1850         @FlaggedApi(Flags.FLAG_SUPPORT_PSIM_TO_ESIM_CONVERSION)
1851         @NonNull
setTransferStatus(@ransferStatus int status)1852         public Builder setTransferStatus(@TransferStatus int status) {
1853             mTransferStatus = status;
1854             return this;
1855         }
1856 
1857         /**
1858          * Set whether the subscription is supported ESOS over Carrier Roaming NB-IOT Satellite or
1859          * not.
1860          *
1861          * @param isSatelliteESOSSupported {@code true} if the subscription supports ESOS over
1862          * Carrier Roaming NB-IOT Satellite, {@code false} otherwise.
1863          * @return The builder.
1864          */
1865         @FlaggedApi(Flags.FLAG_CARRIER_ROAMING_NB_IOT_NTN)
1866         @NonNull
setSatelliteESOSSupported(boolean isSatelliteESOSSupported)1867         public Builder setSatelliteESOSSupported(boolean isSatelliteESOSSupported) {
1868             mIsSatelliteESOSSupported = isSatelliteESOSSupported;
1869             return this;
1870         }
1871 
1872         /**
1873          * Build the {@link SubscriptionInfo}.
1874          *
1875          * @return The {@link SubscriptionInfo} instance.
1876          */
build()1877         public SubscriptionInfo build() {
1878             return new SubscriptionInfo(this);
1879         }
1880     }
1881 }
1882