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 /** 446 * Whether satellite attach for carrier is enabled or disabled by user. 447 * By default, its enabled. It is intended to use integer to fit the database format. 448 */ 449 private final int mIsSatelliteAttachEnabledForCarrier; 450 451 /** 452 * Whether this subscription is used for communicating with non-terrestrial networks. 453 * By default, its disabled. It is intended to use integer to fit the database format. 454 */ 455 private final int mIsOnlyNonTerrestrialNetwork; 456 457 // This field does not exist in the SimInfo table. 458 /** 459 * The card ID of the SIM card. This maps uniquely to {@link #mCardString}. 460 */ 461 private final int mCardId; 462 463 // This field does not exist in the SimInfo table. 464 /** 465 * Whether group of the subscription is disabled. This is only useful if it's a grouped 466 * opportunistic subscription. In this case, if all primary (non-opportunistic) subscriptions 467 * in the group are deactivated (unplugged pSIM or deactivated eSIM profile), we should disable 468 * this opportunistic subscription. It is intended to use integer to fit the database format. 469 */ 470 private final boolean mIsGroupDisabled; 471 472 /** 473 * Service capabilities (in the form of bitmask combination) the subscription supports. 474 */ 475 private final int mServiceCapabilities; 476 477 /** 478 * The transfer status of the subscription 479 */ 480 private final int mTransferStatus; 481 482 /** 483 * Whether satellite entitlement status is enabled or disabled by the entitlement query result. 484 * By default, its disabled. It is intended to use integer to fit the database format. 485 */ 486 private final int mIsSatelliteEntitlementStatus; 487 488 /** 489 * The satellite entitlement plmns based on the entitlement query results 490 * By default, its empty. It is intended to use string to fit the database format. 491 */ 492 @NonNull private final String mSatelliteEntitlementPlmns; 493 494 /** 495 * Constructor from builder. 496 * 497 * @param builder Builder of {@link SubscriptionInfoInternal}. 498 */ SubscriptionInfoInternal(@onNull Builder builder)499 private SubscriptionInfoInternal(@NonNull Builder builder) { 500 this.mId = builder.mId; 501 this.mIccId = builder.mIccId; 502 this.mSimSlotIndex = builder.mSimSlotIndex; 503 this.mDisplayName = builder.mDisplayName; 504 this.mCarrierName = builder.mCarrierName; 505 this.mDisplayNameSource = builder.mDisplayNameSource; 506 this.mIconTint = builder.mIconTint; 507 this.mNumber = builder.mNumber; 508 this.mDataRoaming = builder.mDataRoaming; 509 this.mMcc = builder.mMcc; 510 this.mMnc = builder.mMnc; 511 this.mEhplmns = builder.mEhplmns; 512 this.mHplmns = builder.mHplmns; 513 this.mIsEmbedded = builder.mIsEmbedded; 514 this.mCardString = builder.mCardString; 515 this.mNativeAccessRules = builder.mNativeAccessRules; 516 this.mCarrierConfigAccessRules = builder.mCarrierConfigAccessRules; 517 this.mIsRemovableEmbedded = builder.mIsRemovableEmbedded; 518 this.mIsExtremeThreatAlertEnabled = builder.mIsExtremeThreatAlertEnabled; 519 this.mIsSevereThreatAlertEnabled = builder.mIsSevereThreatAlertEnabled; 520 this.mIsAmberAlertEnabled = builder.mIsAmberAlertEnabled; 521 this.mIsEmergencyAlertEnabled = builder.mIsEmergencyAlertEnabled; 522 this.mAlertSoundDuration = builder.mAlertSoundDuration; 523 this.mReminderInterval = builder.mReminderInterval; 524 this.mIsAlertVibrationEnabled = builder.mIsAlertVibrationEnabled; 525 this.mIsAlertSpeechEnabled = builder.mIsAlertSpeechEnabled; 526 this.mIsEtwsTestAlertEnabled = builder.mIsEtwsTestAlertEnabled; 527 this.mIsAreaInfoMessageEnabled = builder.mIsAreaInfoMessageEnabled; 528 this.mIsTestAlertEnabled = builder.mIsTestAlertEnabled; 529 this.mIsOptOutDialogEnabled = builder.mIsOptOutDialogEnabled; 530 this.mIsEnhanced4GModeEnabled = builder.mIsEnhanced4GModeEnabled; 531 this.mIsVideoTelephonyEnabled = builder.mIsVideoTelephonyEnabled; 532 this.mIsWifiCallingEnabled = builder.mIsWifiCallingEnabled; 533 this.mWifiCallingMode = builder.mWifiCallingMode; 534 this.mWifiCallingModeForRoaming = builder.mWifiCallingModeForRoaming; 535 this.mIsWifiCallingEnabledForRoaming = builder.mIsWifiCallingEnabledForRoaming; 536 this.mIsOpportunistic = builder.mIsOpportunistic; 537 this.mGroupUuid = builder.mGroupUuid; 538 this.mCountryIso = builder.mCountryIso; 539 this.mCarrierId = builder.mCarrierId; 540 this.mProfileClass = builder.mProfileClass; 541 this.mType = builder.mType; 542 this.mGroupOwner = builder.mGroupOwner; 543 this.mEnabledMobileDataPolicies = builder.mEnabledMobileDataPolicies; 544 this.mImsi = builder.mImsi; 545 this.mAreUiccApplicationsEnabled = builder.mAreUiccApplicationsEnabled; 546 this.mIsRcsUceEnabled = builder.mIsRcsUceEnabled; 547 this.mIsCrossSimCallingEnabled = builder.mIsCrossSimCallingEnabled; 548 this.mRcsConfig = builder.mRcsConfig; 549 this.mAllowedNetworkTypesForReasons = builder.mAllowedNetworkTypesForReasons; 550 this.mDeviceToDeviceStatusSharingPreference = 551 builder.mDeviceToDeviceStatusSharingPreference; 552 this.mIsVoImsOptInEnabled = builder.mIsVoImsOptInEnabled; 553 this.mDeviceToDeviceStatusSharingContacts = builder.mDeviceToDeviceStatusSharingContacts; 554 this.mIsNrAdvancedCallingEnabled = builder.mIsNrAdvancedCallingEnabled; 555 this.mNumberFromCarrier = builder.mNumberFromCarrier; 556 this.mNumberFromIms = builder.mNumberFromIms; 557 this.mPortIndex = builder.mPortIndex; 558 this.mUsageSetting = builder.mUsageSetting; 559 this.mLastUsedTPMessageReference = builder.mLastUsedTPMessageReference; 560 this.mUserId = builder.mUserId; 561 this.mIsSatelliteEnabled = builder.mIsSatelliteEnabled; 562 this.mIsSatelliteAttachEnabledForCarrier = 563 builder.mIsSatelliteAttachEnabledForCarrier; 564 this.mIsOnlyNonTerrestrialNetwork = builder.mIsOnlyNonTerrestrialNetwork; 565 566 // Below are the fields that do not exist in the SimInfo table. 567 this.mCardId = builder.mCardId; 568 this.mIsGroupDisabled = builder.mIsGroupDisabled; 569 this.mServiceCapabilities = builder.mServiceCapabilities; 570 this.mTransferStatus = builder.mTransferStatus; 571 this.mIsSatelliteEntitlementStatus = builder.mIsSatelliteEntitlementStatus; 572 this.mSatelliteEntitlementPlmns = builder.mSatelliteEntitlementPlmns; 573 } 574 575 /** 576 * @return The subscription ID. 577 */ getSubscriptionId()578 public int getSubscriptionId() { 579 return mId; 580 } 581 582 /** 583 * Returns the ICC ID. 584 * 585 * @return the ICC ID, or an empty string if one of these requirements is not met 586 */ 587 @NonNull getIccId()588 public String getIccId() { 589 return mIccId; 590 } 591 592 /** 593 * @return The index of the SIM slot that currently contains the subscription and not 594 * necessarily unique and maybe {@link SubscriptionManager#INVALID_SIM_SLOT_INDEX} if unknown or 595 * the subscription is inactive. 596 */ getSimSlotIndex()597 public int getSimSlotIndex() { 598 return mSimSlotIndex; 599 } 600 601 /** 602 * @return The name displayed to the user that identifies this subscription. This name is 603 * used in Settings page and can be renamed by the user. 604 * 605 * @see #getCarrierName() 606 */ 607 @NonNull getDisplayName()608 public String getDisplayName() { 609 return mDisplayName; 610 } 611 612 /** 613 * @return The name displayed to the user that identifies subscription provider name. This name 614 * is the SPN displayed in status bar and many other places. Can't be renamed by the user. 615 * 616 * @see #getDisplayName() 617 */ 618 @NonNull getCarrierName()619 public String getCarrierName() { 620 return mCarrierName; 621 } 622 623 /** 624 * @return The source of the {@link #getDisplayName()}. 625 */ 626 @SimDisplayNameSource getDisplayNameSource()627 public int getDisplayNameSource() { 628 return mDisplayNameSource; 629 } 630 631 /** 632 * A highlight color to use in displaying information about this {@code PhoneAccount}. 633 * 634 * @return A hexadecimal color value. 635 */ 636 @ColorInt getIconTint()637 public int getIconTint() { 638 return mIconTint; 639 } 640 641 /** 642 * @return the number of this subscription. 643 */ getNumber()644 public String getNumber() { 645 if (TextUtils.isEmpty(mNumberFromCarrier)) return mNumber; 646 return mNumberFromCarrier; 647 } 648 649 /** 650 * Whether user enables data roaming for this subscription or not. Either 651 * {@link SubscriptionManager#DATA_ROAMING_ENABLE} or 652 * {@link SubscriptionManager#DATA_ROAMING_DISABLE}. 653 */ getDataRoaming()654 public int getDataRoaming() { 655 return mDataRoaming; 656 } 657 658 /** 659 * @return The mobile country code. 660 */ 661 @NonNull getMcc()662 public String getMcc() { 663 return mMcc; 664 } 665 666 /** 667 * @return The mobile network code. 668 */ 669 @NonNull getMnc()670 public String getMnc() { 671 return mMnc; 672 } 673 674 /** 675 * @return Extended home PLMNs associated with this subscription. 676 */ 677 @NonNull getEhplmns()678 public String getEhplmns() { 679 return mEhplmns; 680 } 681 682 /** 683 * @return Home PLMNs associated with this subscription. 684 */ 685 @NonNull getHplmns()686 public String getHplmns() { 687 return mHplmns; 688 } 689 690 /** 691 * @return {@code true} if the subscription is from eSIM. 692 */ isEmbedded()693 public boolean isEmbedded() { 694 return mIsEmbedded != 0; 695 } 696 697 /** 698 * @return {@code 1} if the subscription is from eSIM. 699 */ getEmbedded()700 public int getEmbedded() { 701 return mIsEmbedded; 702 } 703 704 /** 705 * Returns the card string of the SIM card which contains the subscription. 706 * 707 * @return The card string of the SIM card which contains the subscription. The card string is 708 * the ICCID for UICCs or the EID for 709 * eUICCs. 710 */ 711 @NonNull getCardString()712 public String getCardString() { 713 return mCardString; 714 } 715 716 /** 717 * @return The access rules for this subscription, if it is embedded and defines any. This 718 * does not include access rules for non-embedded subscriptions. This is the raw string 719 * stored in the database. 720 */ 721 @NonNull getNativeAccessRules()722 public byte[] getNativeAccessRules() { 723 return mNativeAccessRules; 724 } 725 726 /** 727 * @return The carrier certificates for this subscription that are saved in carrier configs. 728 * This does not include access rules from the Uicc, whether embedded or non-embedded. This 729 * is the raw string stored in the database. 730 */ getCarrierConfigAccessRules()731 public byte[] getCarrierConfigAccessRules() { 732 return mCarrierConfigAccessRules; 733 } 734 735 /** 736 * @return {@code true} if an embedded subscription is on a removable card. Such subscriptions 737 * are marked inaccessible as soon as the current card is removed. Otherwise, they will remain 738 * accessible unless explicitly deleted. Only meaningful when {@link #getEmbedded()} is 1. 739 */ isRemovableEmbedded()740 public boolean isRemovableEmbedded() { 741 return mIsRemovableEmbedded != 0; 742 } 743 744 /** 745 * @return {@code 1} if an embedded subscription is on a removable card. Such subscriptions are 746 * marked inaccessible as soon as the current card is removed. Otherwise, they will remain 747 * accessible unless explicitly deleted. Only meaningful when {@link #getEmbedded()} is 1. 748 */ getRemovableEmbedded()749 public int getRemovableEmbedded() { 750 return mIsRemovableEmbedded; 751 } 752 753 /** 754 * @return {@code 1} if cell broadcast extreme threat alert is enabled by the user. 755 */ getCellBroadcastExtremeThreatAlertEnabled()756 public int getCellBroadcastExtremeThreatAlertEnabled() { 757 return mIsExtremeThreatAlertEnabled; 758 } 759 760 /** 761 * @return {@code 1} if cell broadcast amber alert is enabled by the user. 762 */ getCellBroadcastSevereThreatAlertEnabled()763 public int getCellBroadcastSevereThreatAlertEnabled() { 764 return mIsSevereThreatAlertEnabled; 765 } 766 767 /** 768 * @return {@code 1} if cell broadcast emergency alert is enabled by the user. 769 */ getCellBroadcastAmberAlertEnabled()770 public int getCellBroadcastAmberAlertEnabled() { 771 return mIsAmberAlertEnabled; 772 } 773 774 /** 775 * @return {@code 1} if cell broadcast emergency alert is enabled by the user. 776 */ getCellBroadcastEmergencyAlertEnabled()777 public int getCellBroadcastEmergencyAlertEnabled() { 778 return mIsEmergencyAlertEnabled; 779 } 780 781 /** 782 * @return {@code 1} if cell broadcast alert sound duration in seconds. 783 */ getCellBroadcastAlertSoundDuration()784 public int getCellBroadcastAlertSoundDuration() { 785 return mAlertSoundDuration; 786 } 787 788 /** 789 * @return Cell broadcast alert reminder interval in minutes. 790 */ getCellBroadcastAlertReminderInterval()791 public int getCellBroadcastAlertReminderInterval() { 792 return mReminderInterval; 793 } 794 795 /** 796 * @return {@code 1} if cell broadcast alert vibration is enabled by the user. 797 */ getCellBroadcastAlertVibrationEnabled()798 public int getCellBroadcastAlertVibrationEnabled() { 799 return mIsAlertVibrationEnabled; 800 } 801 802 /** 803 * @return {@code 1} if cell broadcast alert speech is enabled by the user. 804 */ getCellBroadcastAlertSpeechEnabled()805 public int getCellBroadcastAlertSpeechEnabled() { 806 return mIsAlertSpeechEnabled; 807 } 808 809 /** 810 * @return {@code 1} if ETWS test alert is enabled by the user. 811 */ getCellBroadcastEtwsTestAlertEnabled()812 public int getCellBroadcastEtwsTestAlertEnabled() { 813 return mIsEtwsTestAlertEnabled; 814 } 815 816 /** 817 * @return {@code 1} if area info message is enabled by the user. 818 */ getCellBroadcastAreaInfoMessageEnabled()819 public int getCellBroadcastAreaInfoMessageEnabled() { 820 return mIsAreaInfoMessageEnabled; 821 } 822 823 /** 824 * @return {@code 1} if cell broadcast test alert is enabled by the user. 825 */ getCellBroadcastTestAlertEnabled()826 public int getCellBroadcastTestAlertEnabled() { 827 return mIsTestAlertEnabled; 828 } 829 830 /** 831 * @return {@code 1} if cell broadcast opt-out dialog should be shown. 832 */ getCellBroadcastOptOutDialogEnabled()833 public int getCellBroadcastOptOutDialogEnabled() { 834 return mIsOptOutDialogEnabled; 835 } 836 837 /** 838 * @return {@code true} if enhanced 4G mode is enabled by the user or not. 839 */ isEnhanced4GModeEnabled()840 public boolean isEnhanced4GModeEnabled() { 841 return mIsEnhanced4GModeEnabled == 1; 842 } 843 844 /** 845 * @return {@code 1} if enhanced 4G mode is enabled by the user or not. {@code 0} if disabled. 846 * {@code -1} if the user did not change any setting. 847 */ getEnhanced4GModeEnabled()848 public int getEnhanced4GModeEnabled() { 849 return mIsEnhanced4GModeEnabled; 850 } 851 852 /** 853 * @return {@code true} if video telephony is enabled by the user or not. 854 */ isVideoTelephonyEnabled()855 public boolean isVideoTelephonyEnabled() { 856 return mIsVideoTelephonyEnabled != 0; 857 } 858 859 /** 860 * @return {@code 1} if video telephony is enabled by the user or not. 861 */ getVideoTelephonyEnabled()862 public int getVideoTelephonyEnabled() { 863 return mIsVideoTelephonyEnabled; 864 } 865 866 /** 867 * @return {@code true} if Wi-Fi calling is enabled by the user or not when the device is not 868 * roaming. 869 */ isWifiCallingEnabled()870 public boolean isWifiCallingEnabled() { 871 return mIsWifiCallingEnabled == 1; 872 } 873 874 /** 875 * @return {@code 1} if Wi-Fi calling is enabled by the user or not when the device is not 876 * roaming. {@code 0} if disabled. {@code -1} if the user did not change any setting. 877 */ getWifiCallingEnabled()878 public int getWifiCallingEnabled() { 879 return mIsWifiCallingEnabled; 880 } 881 882 /** 883 * @return Wi-Fi calling mode when the device is not roaming. 884 */ 885 @ImsMmTelManager.WiFiCallingMode getWifiCallingMode()886 public int getWifiCallingMode() { 887 return mWifiCallingMode; 888 } 889 890 /** 891 * @return Wi-Fi calling mode when the device is roaming. 892 */ 893 @ImsMmTelManager.WiFiCallingMode getWifiCallingModeForRoaming()894 public int getWifiCallingModeForRoaming() { 895 return mWifiCallingModeForRoaming; 896 } 897 898 /** 899 * @return {@code true} if Wi-Fi calling is enabled by the user or not when the device is 900 * roaming. {@code 0} if disabled. {@code -1} if the user did not change any setting. 901 */ isWifiCallingEnabledForRoaming()902 public boolean isWifiCallingEnabledForRoaming() { 903 return mIsWifiCallingEnabledForRoaming == 1; 904 } 905 906 /** 907 * @return {@code 1} if Wi-Fi calling is enabled by the user or not when the device is roaming. 908 */ getWifiCallingEnabledForRoaming()909 public int getWifiCallingEnabledForRoaming() { 910 return mIsWifiCallingEnabledForRoaming; 911 } 912 913 /** 914 * An opportunistic subscription connects to a network that is 915 * limited in functionality and / or coverage. 916 * 917 * @return {@code true} if subscription is opportunistic. 918 */ isOpportunistic()919 public boolean isOpportunistic() { 920 return mIsOpportunistic != 0; 921 } 922 923 /** 924 * An opportunistic subscription connects to a network that is 925 * limited in functionality and / or coverage. 926 * 927 * @return {@code 1} if subscription is opportunistic. 928 */ getOpportunistic()929 public int getOpportunistic() { 930 return mIsOpportunistic; 931 } 932 933 /** 934 * Used in scenarios where different subscriptions are bundled as a group. 935 * It's typically a primary and an opportunistic subscription. (see {@link #getOpportunistic()}) 936 * Such that those subscriptions will have some affiliated behaviors such as opportunistic 937 * subscription may be invisible to the user. 938 * 939 * @return Group UUID in string format. 940 */ 941 @NonNull getGroupUuid()942 public String getGroupUuid() { 943 return mGroupUuid; 944 } 945 946 /** 947 * @return The ISO country code. Empty if not available. 948 */ getCountryIso()949 public String getCountryIso() { 950 return mCountryIso; 951 } 952 953 /** 954 * @return The carrier id of this subscription carrier. 955 * 956 * @see TelephonyManager#getSimCarrierId() 957 */ getCarrierId()958 public int getCarrierId() { 959 return mCarrierId; 960 } 961 962 /** 963 * @return The profile class populated from the profile metadata if present. Otherwise, 964 * the profile class defaults to {@link SubscriptionManager#PROFILE_CLASS_UNSET} if there is no 965 * profile metadata or the subscription is not on an eUICC ({@link #getEmbedded} return 966 * {@code 0}). 967 */ 968 @ProfileClass getProfileClass()969 public int getProfileClass() { 970 return mProfileClass; 971 } 972 973 /** 974 * This method returns the type of a subscription. It can be 975 * {@link SubscriptionManager#SUBSCRIPTION_TYPE_LOCAL_SIM} or 976 * {@link SubscriptionManager#SUBSCRIPTION_TYPE_REMOTE_SIM}. 977 * 978 * @return The type of the subscription. 979 */ 980 @SubscriptionType getSubscriptionType()981 public int getSubscriptionType() { 982 return mType; 983 } 984 985 /** 986 * @return The owner package of group the subscription belongs to. 987 */ 988 @NonNull getGroupOwner()989 public String getGroupOwner() { 990 return mGroupOwner; 991 } 992 993 /** 994 * @return The enabled mobile data policies in string format. 995 * 996 * @see com.android.internal.telephony.data.DataSettingsManager#getMobileDataPolicyEnabled 997 */ 998 @NonNull getEnabledMobileDataPolicies()999 public String getEnabledMobileDataPolicies() { 1000 return mEnabledMobileDataPolicies; 1001 } 1002 1003 /** 1004 * @return The IMSI (International Mobile Subscriber Identity) of the subscription. 1005 */ 1006 @NonNull getImsi()1007 public String getImsi() { 1008 return mImsi; 1009 } 1010 1011 /** 1012 * @return {@code true} if Uicc applications are set to be enabled or disabled. 1013 */ areUiccApplicationsEnabled()1014 public boolean areUiccApplicationsEnabled() { 1015 return mAreUiccApplicationsEnabled != 0; 1016 } 1017 1018 /** 1019 * @return {@code 1} if Uicc applications are set to be enabled or disabled. 1020 */ getUiccApplicationsEnabled()1021 public int getUiccApplicationsEnabled() { 1022 return mAreUiccApplicationsEnabled; 1023 } 1024 1025 /** 1026 * @return {@code true} if the user has enabled IMS RCS User Capability Exchange (UCE) for this 1027 * subscription. 1028 */ isRcsUceEnabled()1029 public boolean isRcsUceEnabled() { 1030 return mIsRcsUceEnabled != 0; 1031 } 1032 1033 /** 1034 * @return {@code 1} if the user has enabled IMS RCS User Capability Exchange (UCE) for this 1035 * subscription. 1036 */ getRcsUceEnabled()1037 public int getRcsUceEnabled() { 1038 return mIsRcsUceEnabled; 1039 } 1040 1041 /** 1042 * @return {@code true} if the user has enabled cross SIM calling for this subscription. 1043 */ isCrossSimCallingEnabled()1044 public boolean isCrossSimCallingEnabled() { 1045 return mIsCrossSimCallingEnabled != 0; 1046 } 1047 1048 /** 1049 * @return {@code 1} if the user has enabled cross SIM calling for this subscription. 1050 */ getCrossSimCallingEnabled()1051 public int getCrossSimCallingEnabled() { 1052 return mIsCrossSimCallingEnabled; 1053 } 1054 1055 /** 1056 * @return The RCS configuration. 1057 */ 1058 @NonNull getRcsConfig()1059 public byte[] getRcsConfig() { 1060 return mRcsConfig; 1061 } 1062 1063 /** 1064 * The allowed network types for reasons in string format. The format is 1065 * "[reason]=[network types bitmask], [reason]=[network types bitmask], ..." 1066 * 1067 * For example, "user=1239287394, thermal=298791239, carrier=3456812312". 1068 */ 1069 @NonNull getAllowedNetworkTypesForReasons()1070 public String getAllowedNetworkTypesForReasons() { 1071 return mAllowedNetworkTypesForReasons; 1072 } 1073 1074 /** 1075 * @return Device to device sharing status. 1076 */ 1077 @DeviceToDeviceStatusSharingPreference getDeviceToDeviceStatusSharingPreference()1078 public int getDeviceToDeviceStatusSharingPreference() { 1079 return mDeviceToDeviceStatusSharingPreference; 1080 } 1081 1082 /** 1083 * @return {@code true} if the user has opted-in voice over IMS. 1084 */ isVoImsOptInEnabled()1085 public boolean isVoImsOptInEnabled() { 1086 return mIsVoImsOptInEnabled != 0; 1087 } 1088 1089 /** 1090 * @return {@code 1} if the user has opted-in voice over IMS. 1091 */ getVoImsOptInEnabled()1092 public int getVoImsOptInEnabled() { 1093 return mIsVoImsOptInEnabled; 1094 } 1095 1096 /** 1097 * @return Contacts information that allow device to device sharing. 1098 */ 1099 @NonNull getDeviceToDeviceStatusSharingContacts()1100 public String getDeviceToDeviceStatusSharingContacts() { 1101 return mDeviceToDeviceStatusSharingContacts; 1102 } 1103 1104 /** 1105 * @return {@code true} if the user has enabled NR advanced calling. 1106 */ isNrAdvancedCallingEnabled()1107 public boolean isNrAdvancedCallingEnabled() { 1108 return mIsNrAdvancedCallingEnabled == 1; 1109 } 1110 1111 /** 1112 * @return {@code 1} if the user has enabled NR advanced calling. {code 0} if disabled. 1113 * {code -1} if the user did not change any setting. 1114 */ getNrAdvancedCallingEnabled()1115 public int getNrAdvancedCallingEnabled() { 1116 return mIsNrAdvancedCallingEnabled; 1117 } 1118 1119 /** 1120 * @return Get the phone number retrieved from carrier. 1121 */ 1122 @NonNull getNumberFromCarrier()1123 public String getNumberFromCarrier() { 1124 return mNumberFromCarrier; 1125 } 1126 1127 /** 1128 * @return Get the phone number retrieved from IMS. 1129 */ 1130 @NonNull getNumberFromIms()1131 public String getNumberFromIms() { 1132 return mNumberFromIms; 1133 } 1134 1135 /** 1136 * @return The port index of the SIM card which contains the subscription. 1137 */ getPortIndex()1138 public int getPortIndex() { 1139 return mPortIndex; 1140 } 1141 1142 /** 1143 * Get the usage setting for this subscription. 1144 * 1145 * @return The usage setting used for this subscription. 1146 */ 1147 @UsageSetting getUsageSetting()1148 public int getUsageSetting() { 1149 return mUsageSetting; 1150 } 1151 1152 /** 1153 * @return Last used TP message reference. 1154 */ getLastUsedTPMessageReference()1155 public int getLastUsedTPMessageReference() { 1156 return mLastUsedTPMessageReference; 1157 } 1158 1159 /** 1160 * @return The user id associated with this subscription. 1161 */ 1162 @UserIdInt getUserId()1163 public int getUserId() { 1164 return mUserId; 1165 } 1166 1167 /** 1168 * @return {@code 1} if satellite is enabled. 1169 */ getSatelliteEnabled()1170 public int getSatelliteEnabled() { 1171 return mIsSatelliteEnabled; 1172 } 1173 1174 /** 1175 * @return {@code 1} if satellite attach for carrier is enabled by user. 1176 */ getSatelliteAttachEnabledForCarrier()1177 public int getSatelliteAttachEnabledForCarrier() { 1178 return mIsSatelliteAttachEnabledForCarrier; 1179 } 1180 1181 /** 1182 * An NTN subscription connects to non-terrestrial networks. 1183 * 1184 * @return {@code 1} if the subscription is for non-terrestrial networks. {@code 0} otherwise. 1185 */ getOnlyNonTerrestrialNetwork()1186 public int getOnlyNonTerrestrialNetwork() { 1187 return mIsOnlyNonTerrestrialNetwork; 1188 } 1189 1190 // Below are the fields that do not exist in SimInfo table. 1191 /** 1192 * @return The card ID of the SIM card which contains the subscription. 1193 * 1194 * @see android.telephony.UiccCardInfo#getCardId(). 1195 */ getCardId()1196 public int getCardId() { 1197 return mCardId; 1198 } 1199 1200 /** 1201 * @return {@code true} if the group of the subscription is disabled. This is only useful if 1202 * it's a grouped opportunistic subscription. In this case, if all primary (non-opportunistic) 1203 * subscriptions in the group are deactivated (unplugged pSIM or deactivated eSIM profile), we 1204 * should disable this opportunistic subscription. 1205 */ isGroupDisabled()1206 public boolean isGroupDisabled() { 1207 return mIsGroupDisabled; 1208 } 1209 1210 /** 1211 * @return {@code true} if the subscription is from the actively used SIM. 1212 */ isActive()1213 public boolean isActive() { 1214 return mSimSlotIndex >= 0 || mType == SubscriptionManager.SUBSCRIPTION_TYPE_REMOTE_SIM; 1215 } 1216 1217 /** 1218 * @return {@code true} if the subscription is visible to the user. 1219 */ isVisible()1220 public boolean isVisible() { 1221 // Provisioning profile 1222 if (getProfileClass() == SubscriptionManager.PROFILE_CLASS_PROVISIONING) { 1223 return false; 1224 } 1225 1226 // Satellite profile 1227 if (getOnlyNonTerrestrialNetwork() == 1) { 1228 return false; 1229 } 1230 1231 // Opportunistic profile 1232 if (isOpportunistic() && !TextUtils.isEmpty(mGroupUuid)) { 1233 return false; 1234 } 1235 1236 return true; 1237 } 1238 1239 /** 1240 * Return the service capabilities bitmasks the subscription supports. 1241 */ getServiceCapabilities()1242 public int getServiceCapabilities() { 1243 return mServiceCapabilities; 1244 } 1245 /** 1246 * @return Transfer status. 1247 */ getTransferStatus()1248 public int getTransferStatus() { 1249 return mTransferStatus; 1250 } 1251 1252 /** 1253 * @return {@code 1} if satellite entitlement status is enabled by entitlement query result. 1254 */ getSatelliteEntitlementStatus()1255 public int getSatelliteEntitlementStatus() { 1256 return mIsSatelliteEntitlementStatus; 1257 } 1258 1259 /** 1260 * @return Satellite entitlement plmns is empty or not by entitlement query result. 1261 * 1262 * For example, "123123, 12310" or "" 1263 */ 1264 @NonNull getSatelliteEntitlementPlmns()1265 public String getSatelliteEntitlementPlmns() { 1266 return mSatelliteEntitlementPlmns; 1267 } 1268 1269 /** @return converted {@link SubscriptionInfo}. */ 1270 @NonNull toSubscriptionInfo()1271 public SubscriptionInfo toSubscriptionInfo() { 1272 return new SubscriptionInfo.Builder() 1273 .setId(mId) 1274 .setIccId(mIccId) 1275 .setSimSlotIndex(mSimSlotIndex) 1276 .setDisplayName(mDisplayName) 1277 .setCarrierName(mCarrierName) 1278 .setDisplayNameSource(mDisplayNameSource) 1279 .setIconTint(mIconTint) 1280 .setNumber(getNumber()) 1281 .setDataRoaming(mDataRoaming) 1282 .setMcc(mMcc) 1283 .setMnc(mMnc) 1284 .setEhplmns(TextUtils.isEmpty(mEhplmns) ? null : mEhplmns.split(",")) 1285 .setHplmns(TextUtils.isEmpty(mHplmns) ? null : mHplmns.split(",")) 1286 .setCountryIso(mCountryIso) 1287 .setEmbedded(mIsEmbedded != 0) 1288 .setNativeAccessRules(mNativeAccessRules.length == 0 1289 ? null : UiccAccessRule.decodeRules(mNativeAccessRules)) 1290 .setCardString(mCardString) 1291 .setCardId(mCardId) 1292 .setOpportunistic(mIsOpportunistic != 0) 1293 .setGroupUuid(mGroupUuid) 1294 .setGroupDisabled(mIsGroupDisabled) 1295 .setCarrierId(mCarrierId) 1296 .setProfileClass(mProfileClass) 1297 .setType(mType) 1298 .setGroupOwner(mGroupOwner) 1299 .setCarrierConfigAccessRules(mCarrierConfigAccessRules.length == 0 1300 ? null : UiccAccessRule.decodeRules(mCarrierConfigAccessRules)) 1301 .setUiccApplicationsEnabled(mAreUiccApplicationsEnabled != 0) 1302 .setPortIndex(mPortIndex) 1303 .setUsageSetting(mUsageSetting) 1304 .setOnlyNonTerrestrialNetwork(mIsOnlyNonTerrestrialNetwork == 1) 1305 .setServiceCapabilities( 1306 SubscriptionManager.getServiceCapabilitiesSet(mServiceCapabilities)) 1307 .setTransferStatus(mTransferStatus) 1308 .build(); 1309 } 1310 1311 @Override toString()1312 public String toString() { 1313 return "[SubscriptionInfoInternal: id=" + mId 1314 + " iccId=" + SubscriptionInfo.getPrintableId(mIccId) 1315 + " simSlotIndex=" + mSimSlotIndex 1316 + " portIndex=" + mPortIndex 1317 + " isEmbedded=" + mIsEmbedded 1318 + " isRemovableEmbedded=" + mIsRemovableEmbedded 1319 + " carrierId=" + mCarrierId 1320 + " displayName=" + mDisplayName 1321 + " carrierName=" + mCarrierName 1322 + " isOpportunistic=" + mIsOpportunistic 1323 + " groupUuid=" + mGroupUuid 1324 + " groupOwner=" + mGroupOwner 1325 + " displayNameSource=" 1326 + SubscriptionManager.displayNameSourceToString(mDisplayNameSource) 1327 + " iconTint=" + mIconTint 1328 + " number=" + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, getNumber()) 1329 + " dataRoaming=" + mDataRoaming 1330 + " mcc=" + mMcc 1331 + " mnc=" + mMnc 1332 + " ehplmns=" + mEhplmns 1333 + " hplmns=" + mHplmns 1334 + " cardString=" + SubscriptionInfo.getPrintableId(mCardString) 1335 + " cardId=" + mCardId 1336 + " nativeAccessRules=" + IccUtils.bytesToHexString(mNativeAccessRules) 1337 + " carrierConfigAccessRules=" + IccUtils.bytesToHexString( 1338 mCarrierConfigAccessRules) 1339 + " countryIso=" + mCountryIso 1340 + " profileClass=" + mProfileClass 1341 + " type=" + SubscriptionManager.subscriptionTypeToString(mType) 1342 + " areUiccApplicationsEnabled=" + mAreUiccApplicationsEnabled 1343 + " usageSetting=" + SubscriptionManager.usageSettingToString(mUsageSetting) 1344 + " isEnhanced4GModeEnabled=" + mIsEnhanced4GModeEnabled 1345 + " isVideoTelephonyEnabled=" + mIsVideoTelephonyEnabled 1346 + " isWifiCallingEnabled=" + mIsWifiCallingEnabled 1347 + " isWifiCallingEnabledForRoaming=" + mIsWifiCallingEnabledForRoaming 1348 + " wifiCallingMode=" + ImsMmTelManager.wifiCallingModeToString(mWifiCallingMode) 1349 + " wifiCallingModeForRoaming=" 1350 + ImsMmTelManager.wifiCallingModeToString(mWifiCallingModeForRoaming) 1351 + " enabledMobileDataPolicies=" + mEnabledMobileDataPolicies 1352 + " imsi=" + SubscriptionInfo.getPrintableId(mImsi) 1353 + " rcsUceEnabled=" + mIsRcsUceEnabled 1354 + " crossSimCallingEnabled=" + mIsCrossSimCallingEnabled 1355 + " rcsConfig=" + IccUtils.bytesToHexString(mRcsConfig) 1356 + " allowedNetworkTypesForReasons=" + mAllowedNetworkTypesForReasons 1357 + " deviceToDeviceStatusSharingPreference=" + mDeviceToDeviceStatusSharingPreference 1358 + " isVoImsOptInEnabled=" + mIsVoImsOptInEnabled 1359 + " deviceToDeviceStatusSharingContacts=" + mDeviceToDeviceStatusSharingContacts 1360 + " numberFromCarrier=" + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, mNumberFromCarrier) 1361 + " numberFromIms=" + Rlog.pii(TelephonyUtils.IS_DEBUGGABLE, mNumberFromIms) 1362 + " userId=" + mUserId 1363 + " isSatelliteEnabled=" + mIsSatelliteEnabled 1364 + " satellite_attach_enabled_for_carrier=" + mIsSatelliteAttachEnabledForCarrier 1365 + " getOnlyNonTerrestrialNetwork=" + mIsOnlyNonTerrestrialNetwork 1366 + " isGroupDisabled=" + mIsGroupDisabled 1367 + " serviceCapabilities=" + mServiceCapabilities 1368 + " transferStatus=" + mTransferStatus 1369 + " satelliteEntitlementStatus=" + mIsSatelliteEntitlementStatus 1370 + " satelliteEntitlementPlmns=" + mSatelliteEntitlementPlmns 1371 + "]"; 1372 } 1373 1374 /** 1375 * Campare only the columns existing in the SimInfo table and the mapped variables to see if 1376 * they are equal. 1377 * 1378 * @param that SubscriptionInfoInternal to be compared 1379 * @return {@code true} if equals. 1380 */ equalsDbItemsOnly(@onNull SubscriptionInfoInternal that)1381 public boolean equalsDbItemsOnly(@NonNull SubscriptionInfoInternal that) { 1382 return mId == that.mId && mSimSlotIndex == that.mSimSlotIndex 1383 && mDisplayNameSource == that.mDisplayNameSource && mIconTint == that.mIconTint 1384 && mDataRoaming == that.mDataRoaming && mIsEmbedded == that.mIsEmbedded 1385 && mIsRemovableEmbedded == that.mIsRemovableEmbedded 1386 && mIsExtremeThreatAlertEnabled == that.mIsExtremeThreatAlertEnabled 1387 && mIsSevereThreatAlertEnabled == that.mIsSevereThreatAlertEnabled 1388 && mIsAmberAlertEnabled == that.mIsAmberAlertEnabled 1389 && mIsEmergencyAlertEnabled == that.mIsEmergencyAlertEnabled 1390 && mAlertSoundDuration == that.mAlertSoundDuration 1391 && mReminderInterval == that.mReminderInterval 1392 && mIsAlertVibrationEnabled == that.mIsAlertVibrationEnabled 1393 && mIsAlertSpeechEnabled == that.mIsAlertSpeechEnabled 1394 && mIsEtwsTestAlertEnabled == that.mIsEtwsTestAlertEnabled 1395 && mIsAreaInfoMessageEnabled == that.mIsAreaInfoMessageEnabled 1396 && mIsEnhanced4GModeEnabled == that.mIsEnhanced4GModeEnabled 1397 && mIsVideoTelephonyEnabled == that.mIsVideoTelephonyEnabled 1398 && mIsWifiCallingEnabled == that.mIsWifiCallingEnabled 1399 && mWifiCallingMode == that.mWifiCallingMode 1400 && mWifiCallingModeForRoaming == that.mWifiCallingModeForRoaming 1401 && mIsWifiCallingEnabledForRoaming == that.mIsWifiCallingEnabledForRoaming 1402 && mIsOpportunistic == that.mIsOpportunistic && mCarrierId == that.mCarrierId 1403 && mProfileClass == that.mProfileClass && mType == that.mType 1404 && mAreUiccApplicationsEnabled == that.mAreUiccApplicationsEnabled 1405 && mIsRcsUceEnabled == that.mIsRcsUceEnabled 1406 && mIsCrossSimCallingEnabled == that.mIsCrossSimCallingEnabled 1407 && mDeviceToDeviceStatusSharingPreference 1408 == that.mDeviceToDeviceStatusSharingPreference 1409 && mIsVoImsOptInEnabled == that.mIsVoImsOptInEnabled 1410 && mIsNrAdvancedCallingEnabled == that.mIsNrAdvancedCallingEnabled 1411 && mPortIndex == that.mPortIndex && mUsageSetting == that.mUsageSetting 1412 && mLastUsedTPMessageReference == that.mLastUsedTPMessageReference 1413 && mUserId == that.mUserId && mIsSatelliteEnabled == that.mIsSatelliteEnabled 1414 && mIccId.equals(that.mIccId) && mDisplayName.equals(that.mDisplayName) 1415 && mCarrierName.equals(that.mCarrierName) && mNumber.equals(that.mNumber) 1416 && mMcc.equals(that.mMcc) && mMnc.equals(that.mMnc) && mEhplmns.equals( 1417 that.mEhplmns) 1418 && mHplmns.equals(that.mHplmns) && mCardString.equals(that.mCardString) 1419 && Arrays.equals(mNativeAccessRules, that.mNativeAccessRules) 1420 && Arrays.equals(mCarrierConfigAccessRules, that.mCarrierConfigAccessRules) 1421 && mGroupUuid.equals(that.mGroupUuid) && mCountryIso.equals(that.mCountryIso) 1422 && mGroupOwner.equals(that.mGroupOwner) && mEnabledMobileDataPolicies.equals( 1423 that.mEnabledMobileDataPolicies) && mImsi.equals(that.mImsi) && Arrays.equals( 1424 mRcsConfig, that.mRcsConfig) && mAllowedNetworkTypesForReasons.equals( 1425 that.mAllowedNetworkTypesForReasons) && mDeviceToDeviceStatusSharingContacts.equals( 1426 that.mDeviceToDeviceStatusSharingContacts) && mNumberFromCarrier.equals( 1427 that.mNumberFromCarrier) && mNumberFromIms.equals(that.mNumberFromIms) 1428 && mIsSatelliteAttachEnabledForCarrier == that.mIsSatelliteAttachEnabledForCarrier 1429 && mIsOnlyNonTerrestrialNetwork == that.mIsOnlyNonTerrestrialNetwork 1430 && mServiceCapabilities == that.mServiceCapabilities 1431 && mTransferStatus == that.mTransferStatus 1432 && mIsSatelliteEntitlementStatus == that.mIsSatelliteEntitlementStatus 1433 && mSatelliteEntitlementPlmns == that.mSatelliteEntitlementPlmns; 1434 } 1435 1436 @Override equals(Object o)1437 public boolean equals(Object o) { 1438 if (this == o) return true; 1439 if (o == null || getClass() != o.getClass()) return false; 1440 SubscriptionInfoInternal that = (SubscriptionInfoInternal) o; 1441 return equalsDbItemsOnly(that) 1442 && mCardId == that.mCardId && mIsGroupDisabled == that.mIsGroupDisabled; 1443 } 1444 1445 @Override hashCode()1446 public int hashCode() { 1447 int result = Objects.hash(mId, mIccId, mSimSlotIndex, mDisplayName, mCarrierName, 1448 mDisplayNameSource, mIconTint, mNumber, mDataRoaming, mMcc, mMnc, mEhplmns, mHplmns, 1449 mIsEmbedded, mCardString, mIsRemovableEmbedded, mIsExtremeThreatAlertEnabled, 1450 mIsSevereThreatAlertEnabled, mIsAmberAlertEnabled, mIsEmergencyAlertEnabled, 1451 mAlertSoundDuration, mReminderInterval, mIsAlertVibrationEnabled, 1452 mIsAlertSpeechEnabled, 1453 mIsEtwsTestAlertEnabled, mIsAreaInfoMessageEnabled, mIsEnhanced4GModeEnabled, 1454 mIsVideoTelephonyEnabled, mIsWifiCallingEnabled, mWifiCallingMode, 1455 mWifiCallingModeForRoaming, mIsWifiCallingEnabledForRoaming, mIsOpportunistic, 1456 mGroupUuid, mCountryIso, mCarrierId, mProfileClass, mType, mGroupOwner, 1457 mEnabledMobileDataPolicies, mImsi, mAreUiccApplicationsEnabled, mIsRcsUceEnabled, 1458 mIsCrossSimCallingEnabled, mAllowedNetworkTypesForReasons, 1459 mDeviceToDeviceStatusSharingPreference, mIsVoImsOptInEnabled, 1460 mDeviceToDeviceStatusSharingContacts, mIsNrAdvancedCallingEnabled, 1461 mNumberFromCarrier, 1462 mNumberFromIms, mPortIndex, mUsageSetting, mLastUsedTPMessageReference, mUserId, 1463 mIsSatelliteEnabled, mCardId, mIsGroupDisabled, 1464 mIsSatelliteAttachEnabledForCarrier, mIsOnlyNonTerrestrialNetwork, 1465 mServiceCapabilities, mTransferStatus, mIsSatelliteEntitlementStatus, 1466 mSatelliteEntitlementPlmns); 1467 result = 31 * result + Arrays.hashCode(mNativeAccessRules); 1468 result = 31 * result + Arrays.hashCode(mCarrierConfigAccessRules); 1469 result = 31 * result + Arrays.hashCode(mRcsConfig); 1470 return result; 1471 } 1472 1473 /** 1474 * The builder class of {@link SubscriptionInfoInternal}. 1475 */ 1476 public static class Builder { 1477 /** 1478 * The subscription id. 1479 */ 1480 private int mId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; 1481 1482 /** 1483 * The ICCID of the SIM that is associated with this subscription, empty if unknown. 1484 */ 1485 @NonNull 1486 private String mIccId = ""; 1487 1488 /** 1489 * The index of the SIM slot that currently contains the subscription and not necessarily 1490 * unique and maybe {@link SubscriptionManager#INVALID_SIM_SLOT_INDEX} if unknown or the 1491 * subscription is inactive. 1492 */ 1493 private int mSimSlotIndex = SubscriptionManager.INVALID_SIM_SLOT_INDEX; 1494 1495 /** 1496 * The name displayed to the user that identifies this subscription. This name is used 1497 * in Settings page and can be renamed by the user. 1498 */ 1499 @NonNull 1500 private String mDisplayName = ""; 1501 1502 /** 1503 * The name displayed to the user that identifies subscription provider name. This name 1504 * is the SPN displayed in status bar and many other places. Can't be renamed by the user. 1505 */ 1506 @NonNull 1507 private String mCarrierName = ""; 1508 1509 /** 1510 * The source of the display name. 1511 */ 1512 @SimDisplayNameSource 1513 private int mDisplayNameSource = SubscriptionManager.NAME_SOURCE_UNKNOWN; 1514 1515 /** 1516 * The color to be used for tinting the icon when displaying to the user. 1517 */ 1518 private int mIconTint = 0; 1519 1520 /** 1521 * The number presented to the user identify this subscription. 1522 */ 1523 @NonNull 1524 private String mNumber = ""; 1525 1526 /** 1527 * Whether user enables data roaming for this subscription or not. Either 1528 * {@link SubscriptionManager#DATA_ROAMING_ENABLE} or 1529 * {@link SubscriptionManager#DATA_ROAMING_DISABLE}. 1530 */ 1531 private int mDataRoaming = SubscriptionManager.DATA_ROAMING_DISABLE; 1532 1533 /** 1534 * The mobile country code. 1535 */ 1536 @NonNull 1537 private String mMcc = ""; 1538 1539 /** 1540 * The mobile network code. 1541 */ 1542 @NonNull 1543 private String mMnc = ""; 1544 1545 /** 1546 * EHPLMNs associated with the subscription. 1547 */ 1548 @NonNull 1549 private String mEhplmns = ""; 1550 1551 /** 1552 * HPLMNs associated with the subscription. 1553 */ 1554 @NonNull 1555 private String mHplmns = ""; 1556 1557 /** 1558 * Whether the subscription is from eSIM. 1559 */ 1560 private int mIsEmbedded = 0; 1561 1562 /** 1563 * The card string of the SIM card. 1564 */ 1565 @NonNull 1566 private String mCardString = ""; 1567 1568 /** 1569 * The native access rules for this subscription, if it is embedded and defines any. This 1570 * does not include access rules for non-embedded subscriptions. 1571 */ 1572 @NonNull 1573 private byte[] mNativeAccessRules = new byte[0]; 1574 1575 /** 1576 * The carrier certificates for this subscription that are saved in carrier configs. 1577 * This does not include access rules from the Uicc, whether embedded or non-embedded. 1578 */ 1579 @NonNull 1580 private byte[] mCarrierConfigAccessRules = new byte[0]; 1581 1582 /** 1583 * Whether an embedded subscription is on a removable card. Such subscriptions are marked 1584 * inaccessible as soon as the current card is removed. Otherwise, they will remain 1585 * accessible unless explicitly deleted. Only meaningful when {@link #getEmbedded()} is 1586 * {@code 1}. 1587 */ 1588 private int mIsRemovableEmbedded = 0; 1589 1590 /** 1591 * Whether cell broadcast extreme threat alert is enabled by the user or not. 1592 */ 1593 private int mIsExtremeThreatAlertEnabled = 1; 1594 1595 /** 1596 * Whether cell broadcast severe threat alert is enabled by the user or not. 1597 */ 1598 private int mIsSevereThreatAlertEnabled = 1; 1599 1600 /** 1601 * Whether cell broadcast amber alert is enabled by the user or not. 1602 */ 1603 private int mIsAmberAlertEnabled = 1; 1604 1605 /** 1606 * Whether cell broadcast emergency alert is enabled by the user or not. 1607 */ 1608 private int mIsEmergencyAlertEnabled = 1; 1609 1610 /** 1611 * Cell broadcast alert sound duration in seconds. 1612 */ 1613 private int mAlertSoundDuration = 4; 1614 1615 /** 1616 * Cell broadcast alert reminder interval in minutes. 1617 */ 1618 private int mReminderInterval = 0; 1619 1620 /** 1621 * Whether cell broadcast alert vibration is enabled by the user or not. 1622 */ 1623 private int mIsAlertVibrationEnabled = 1; 1624 1625 /** 1626 * Whether cell broadcast alert speech is enabled by the user or not. 1627 */ 1628 private int mIsAlertSpeechEnabled = 1; 1629 1630 /** 1631 * Whether ETWS test alert is enabled by the user or not. 1632 */ 1633 private int mIsEtwsTestAlertEnabled = 0; 1634 1635 /** 1636 * Whether area info message is enabled by the user or not. 1637 */ 1638 private int mIsAreaInfoMessageEnabled = 1; 1639 1640 /** 1641 * Whether cell broadcast test alert is enabled by the user or not. 1642 */ 1643 private int mIsTestAlertEnabled = 0; 1644 1645 /** 1646 * Whether cell broadcast opt-out dialog should be shown or not. 1647 */ 1648 private int mIsOptOutDialogEnabled = 1; 1649 1650 /** 1651 * Whether enhanced 4G mode is enabled by the user or not. 1652 */ 1653 private int mIsEnhanced4GModeEnabled = -1; 1654 1655 /** 1656 * Whether video telephony is enabled by the user or not. 1657 */ 1658 private int mIsVideoTelephonyEnabled = -1; 1659 1660 /** 1661 * Whether Wi-Fi calling is enabled by the user or not when the device is not roaming. 1662 */ 1663 private int mIsWifiCallingEnabled = -1; 1664 1665 /** 1666 * Wi-Fi calling mode when the device is not roaming. 1667 */ 1668 @ImsMmTelManager.WiFiCallingMode 1669 private int mWifiCallingMode = ImsMmTelManager.WIFI_MODE_UNKNOWN; 1670 1671 /** 1672 * Wi-Fi calling mode when the device is roaming. 1673 */ 1674 @ImsMmTelManager.WiFiCallingMode 1675 private int mWifiCallingModeForRoaming = ImsMmTelManager.WIFI_MODE_UNKNOWN; 1676 1677 /** 1678 * Whether Wi-Fi calling is enabled by the user or not when the device is roaming. 1679 */ 1680 private int mIsWifiCallingEnabledForRoaming = -1; 1681 1682 /** 1683 * Whether the subscription is opportunistic or not. 1684 */ 1685 private int mIsOpportunistic = 0; 1686 1687 /** 1688 * The group UUID of the subscription group in string format. 1689 */ 1690 @NonNull 1691 private String mGroupUuid = ""; 1692 1693 /** 1694 * The ISO Country code for the subscription's provider. 1695 */ 1696 @NonNull 1697 private String mCountryIso = ""; 1698 1699 /** 1700 * The carrier id. 1701 * 1702 * @see TelephonyManager#getSimCarrierId() 1703 */ 1704 private int mCarrierId = TelephonyManager.UNKNOWN_CARRIER_ID; 1705 1706 /** 1707 * The profile class populated from the profile metadata if present. Otherwise, the profile 1708 * class defaults to {@link SubscriptionManager#PROFILE_CLASS_UNSET} if there is no profile 1709 * metadata or the subscription is not on an eUICC ({@link #getEmbedded} returns 1710 * {@code 0}). 1711 */ 1712 @ProfileClass 1713 private int mProfileClass = SubscriptionManager.PROFILE_CLASS_UNSET; 1714 1715 /** 1716 * The subscription type. 1717 */ 1718 @SubscriptionType 1719 private int mType = SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM; 1720 1721 /** 1722 * The owner package of group the subscription belongs to. 1723 */ 1724 @NonNull 1725 private String mGroupOwner = ""; 1726 1727 /** 1728 * The enabled mobile data policies in string format. 1729 */ 1730 @NonNull 1731 private String mEnabledMobileDataPolicies = ""; 1732 1733 /** 1734 * The IMSI (International Mobile Subscriber Identity) of the subscription. 1735 */ 1736 @NonNull 1737 private String mImsi = ""; 1738 1739 /** 1740 * Whether Uicc applications are configured to enable or not. 1741 */ 1742 private int mAreUiccApplicationsEnabled = 1; 1743 1744 /** 1745 * Whether the user has enabled IMS RCS User Capability Exchange (UCE) for this 1746 * subscription. 1747 */ 1748 private int mIsRcsUceEnabled = 0; 1749 1750 /** 1751 * Whether the user has enabled cross SIM calling for this subscription. 1752 */ 1753 private int mIsCrossSimCallingEnabled = 0; 1754 1755 /** 1756 * The RCS configuration. 1757 */ 1758 private byte[] mRcsConfig = new byte[0]; 1759 1760 /** 1761 * The allowed network types for reasons in string format. The format is 1762 * "[reason]=[network types bitmask], [reason]=[network types bitmask], ..." 1763 * 1764 * For example, "user=1239287394, thermal=298791239, carrier=3456812312". 1765 */ 1766 private String mAllowedNetworkTypesForReasons = ""; 1767 1768 /** 1769 * Device to device sharing status. 1770 */ 1771 @DeviceToDeviceStatusSharingPreference 1772 private int mDeviceToDeviceStatusSharingPreference = 1773 SubscriptionManager.D2D_SHARING_DISABLED; 1774 1775 /** 1776 * Whether the user has opted-in voice over IMS. 1777 */ 1778 private int mIsVoImsOptInEnabled = 0; 1779 1780 /** 1781 * Contacts information that allow device to device sharing. 1782 */ 1783 @NonNull 1784 private String mDeviceToDeviceStatusSharingContacts = ""; 1785 1786 /** 1787 * Whether the user has enabled NR advanced calling. 1788 */ 1789 private int mIsNrAdvancedCallingEnabled = -1; 1790 1791 /** 1792 * The phone number retrieved from carrier. 1793 */ 1794 @NonNull 1795 private String mNumberFromCarrier = ""; 1796 1797 /** 1798 * The phone number retrieved from IMS. 1799 */ 1800 @NonNull 1801 private String mNumberFromIms = ""; 1802 1803 /** 1804 * the port index of the Uicc card. 1805 */ 1806 private int mPortIndex = TelephonyManager.INVALID_PORT_INDEX; 1807 1808 /** 1809 * Subscription's preferred usage setting. 1810 */ 1811 @UsageSetting 1812 private int mUsageSetting = SubscriptionManager.USAGE_SETTING_UNKNOWN; 1813 1814 /** 1815 * Last used TP message reference. 1816 */ 1817 private int mLastUsedTPMessageReference = -1; 1818 1819 /** 1820 * The user id associated with this subscription. 1821 */ 1822 private int mUserId = UserHandle.USER_NULL; 1823 1824 /** 1825 * Whether satellite is enabled or not. 1826 */ 1827 private int mIsSatelliteEnabled = 0; 1828 1829 /** 1830 * Whether satellite attach for carrier is enabled by user. 1831 */ 1832 private int mIsSatelliteAttachEnabledForCarrier = 1; 1833 1834 /** 1835 * Whether this subscription is used for communicating with non-terrestrial network or not. 1836 */ 1837 private int mIsOnlyNonTerrestrialNetwork = 0; 1838 1839 // The following fields do not exist in the SimInfo table. 1840 /** 1841 * The card ID of the SIM card which contains the subscription. 1842 */ 1843 private int mCardId = TelephonyManager.UNINITIALIZED_CARD_ID; 1844 1845 /** 1846 * Whether group of the subscription is disabled. This is only useful if it's a grouped 1847 * opportunistic subscription. In this case, if all primary (non-opportunistic) 1848 * subscriptions in the group are deactivated (unplugged pSIM or deactivated eSIM profile), 1849 * we should disable this opportunistic subscription. 1850 */ 1851 private boolean mIsGroupDisabled; 1852 1853 /** 1854 * Service capabilities the subscription supports 1855 */ 1856 private int mServiceCapabilities; 1857 1858 /** 1859 * The transfer status of the subscription 1860 */ 1861 private int mTransferStatus; 1862 1863 /** 1864 * Whether satellite entitlement status is enabled by entitlement query result. 1865 */ 1866 private int mIsSatelliteEntitlementStatus = 0; 1867 1868 /** 1869 * Whether satellite entitlement plmns is empty or not by entitlement query result. 1870 */ 1871 @NonNull 1872 private String mSatelliteEntitlementPlmns = ""; 1873 1874 /** 1875 * Default constructor. 1876 */ Builder()1877 public Builder() { 1878 } 1879 1880 /** 1881 * Constructor from {@link SubscriptionInfoInternal}. 1882 * 1883 * @param info The subscription info. 1884 */ Builder(@onNull SubscriptionInfoInternal info)1885 public Builder(@NonNull SubscriptionInfoInternal info) { 1886 mId = info.mId; 1887 mIccId = info.mIccId; 1888 mSimSlotIndex = info.mSimSlotIndex; 1889 mDisplayName = info.mDisplayName; 1890 mCarrierName = info.mCarrierName; 1891 mDisplayNameSource = info.mDisplayNameSource; 1892 mIconTint = info.mIconTint; 1893 mNumber = info.mNumber; 1894 mDataRoaming = info.mDataRoaming; 1895 mMcc = info.mMcc; 1896 mMnc = info.mMnc; 1897 mEhplmns = info.mEhplmns; 1898 mHplmns = info.mHplmns; 1899 mIsEmbedded = info.mIsEmbedded; 1900 mCardString = info.mCardString; 1901 mNativeAccessRules = info.mNativeAccessRules; 1902 mCarrierConfigAccessRules = info.mCarrierConfigAccessRules; 1903 mIsRemovableEmbedded = info.mIsRemovableEmbedded; 1904 mIsExtremeThreatAlertEnabled = info.mIsExtremeThreatAlertEnabled; 1905 mIsSevereThreatAlertEnabled = info.mIsSevereThreatAlertEnabled; 1906 mIsAmberAlertEnabled = info.mIsAmberAlertEnabled; 1907 mIsEmergencyAlertEnabled = info.mIsEmergencyAlertEnabled; 1908 mAlertSoundDuration = info.mAlertSoundDuration; 1909 mReminderInterval = info.mReminderInterval; 1910 mIsAlertVibrationEnabled = info.mIsAlertVibrationEnabled; 1911 mIsAlertSpeechEnabled = info.mIsAlertSpeechEnabled; 1912 mIsEtwsTestAlertEnabled = info.mIsEtwsTestAlertEnabled; 1913 mIsAreaInfoMessageEnabled = info.mIsAreaInfoMessageEnabled; 1914 mIsTestAlertEnabled = info.mIsTestAlertEnabled; 1915 mIsOptOutDialogEnabled = info.mIsOptOutDialogEnabled; 1916 mIsEnhanced4GModeEnabled = info.mIsEnhanced4GModeEnabled; 1917 mIsVideoTelephonyEnabled = info.mIsVideoTelephonyEnabled; 1918 mIsWifiCallingEnabled = info.mIsWifiCallingEnabled; 1919 mWifiCallingMode = info.mWifiCallingMode; 1920 mWifiCallingModeForRoaming = info.mWifiCallingModeForRoaming; 1921 mIsWifiCallingEnabledForRoaming = info.mIsWifiCallingEnabledForRoaming; 1922 mIsOpportunistic = info.mIsOpportunistic; 1923 mGroupUuid = info.mGroupUuid; 1924 mCountryIso = info.mCountryIso; 1925 mCarrierId = info.mCarrierId; 1926 mProfileClass = info.mProfileClass; 1927 mType = info.mType; 1928 mGroupOwner = info.mGroupOwner; 1929 mEnabledMobileDataPolicies = info.mEnabledMobileDataPolicies; 1930 mImsi = info.mImsi; 1931 mAreUiccApplicationsEnabled = info.mAreUiccApplicationsEnabled; 1932 mIsRcsUceEnabled = info.mIsRcsUceEnabled; 1933 mIsCrossSimCallingEnabled = info.mIsCrossSimCallingEnabled; 1934 mRcsConfig = info.mRcsConfig; 1935 mAllowedNetworkTypesForReasons = info.mAllowedNetworkTypesForReasons; 1936 mDeviceToDeviceStatusSharingPreference = info.mDeviceToDeviceStatusSharingPreference; 1937 mIsVoImsOptInEnabled = info.mIsVoImsOptInEnabled; 1938 mDeviceToDeviceStatusSharingContacts = info.mDeviceToDeviceStatusSharingContacts; 1939 mIsNrAdvancedCallingEnabled = info.mIsNrAdvancedCallingEnabled; 1940 mNumberFromCarrier = info.mNumberFromCarrier; 1941 mNumberFromIms = info.mNumberFromIms; 1942 mPortIndex = info.mPortIndex; 1943 mUsageSetting = info.mUsageSetting; 1944 mLastUsedTPMessageReference = info.getLastUsedTPMessageReference(); 1945 mUserId = info.mUserId; 1946 mIsSatelliteEnabled = info.mIsSatelliteEnabled; 1947 mIsSatelliteAttachEnabledForCarrier = info.mIsSatelliteAttachEnabledForCarrier; 1948 mIsOnlyNonTerrestrialNetwork = info.mIsOnlyNonTerrestrialNetwork; 1949 // Below are the fields that do not exist in the SimInfo table. 1950 mCardId = info.mCardId; 1951 mIsGroupDisabled = info.mIsGroupDisabled; 1952 mServiceCapabilities = info.mServiceCapabilities; 1953 mTransferStatus = info.mTransferStatus; 1954 mIsSatelliteEntitlementStatus = info.mIsSatelliteEntitlementStatus; 1955 mSatelliteEntitlementPlmns = info.mSatelliteEntitlementPlmns; 1956 } 1957 1958 /** 1959 * Set the subscription id. 1960 * 1961 * @param id The subscription id. 1962 * 1963 * @return The builder. 1964 */ 1965 @NonNull setId(int id)1966 public Builder setId(int id) { 1967 mId = id; 1968 return this; 1969 } 1970 1971 /** 1972 * Set the ICCID of the SIM that is associated with this subscription. 1973 * 1974 * @param iccId The ICCID of the SIM that is associated with this subscription. 1975 * 1976 * @return The builder. 1977 */ 1978 @NonNull setIccId(@onNull String iccId)1979 public Builder setIccId(@NonNull String iccId) { 1980 Objects.requireNonNull(iccId); 1981 mIccId = iccId; 1982 return this; 1983 } 1984 1985 /** 1986 * Set the SIM index of the slot that currently contains the subscription. Set to 1987 * {@link SubscriptionManager#INVALID_SIM_SLOT_INDEX} if the subscription is inactive. 1988 * 1989 * @param simSlotIndex The SIM slot index. 1990 * 1991 * @return The builder. 1992 */ 1993 @NonNull setSimSlotIndex(int simSlotIndex)1994 public Builder setSimSlotIndex(int simSlotIndex) { 1995 mSimSlotIndex = simSlotIndex; 1996 return this; 1997 } 1998 1999 /** 2000 * The name displayed to the user that identifies this subscription. This name is used 2001 * in Settings page and can be renamed by the user. 2002 * 2003 * @param displayName The display name. 2004 * 2005 * @return The builder. 2006 */ 2007 @NonNull setDisplayName(@onNull String displayName)2008 public Builder setDisplayName(@NonNull String displayName) { 2009 Objects.requireNonNull(displayName); 2010 mDisplayName = displayName; 2011 return this; 2012 } 2013 2014 /** 2015 * The name displayed to the user that identifies subscription provider name. This name 2016 * is the SPN displayed in status bar and many other places. Can't be renamed by the user. 2017 * 2018 * @param carrierName The carrier name. 2019 * 2020 * @return The builder. 2021 */ 2022 @NonNull setCarrierName(@onNull String carrierName)2023 public Builder setCarrierName(@NonNull String carrierName) { 2024 Objects.requireNonNull(carrierName); 2025 mCarrierName = carrierName; 2026 return this; 2027 } 2028 2029 /** 2030 * Set the source of the display name. 2031 * 2032 * @param displayNameSource The source of the display name. 2033 * @return The builder. 2034 * 2035 * @see SubscriptionInfoInternal#getDisplayName() 2036 */ 2037 @NonNull setDisplayNameSource(@imDisplayNameSource int displayNameSource)2038 public Builder setDisplayNameSource(@SimDisplayNameSource int displayNameSource) { 2039 mDisplayNameSource = displayNameSource; 2040 return this; 2041 } 2042 2043 /** 2044 * Set the color to be used for tinting the icon when displaying to the user. 2045 * 2046 * @param iconTint The color to be used for tinting the icon when displaying to the user. 2047 * 2048 * @return The builder. 2049 */ 2050 @NonNull setIconTint(int iconTint)2051 public Builder setIconTint(int iconTint) { 2052 mIconTint = iconTint; 2053 return this; 2054 } 2055 2056 /** 2057 * Set the number presented to the user identify this subscription. 2058 * 2059 * @param number the number presented to the user identify this subscription. 2060 * 2061 * @return The builder. 2062 */ 2063 @NonNull setNumber(@onNull String number)2064 public Builder setNumber(@NonNull String number) { 2065 Objects.requireNonNull(number); 2066 mNumber = number; 2067 return this; 2068 } 2069 2070 /** 2071 * Set whether user enables data roaming for this subscription or not. 2072 * 2073 * @param dataRoaming Data roaming mode. Either 2074 * {@link SubscriptionManager#DATA_ROAMING_ENABLE} or 2075 * {@link SubscriptionManager#DATA_ROAMING_DISABLE} 2076 * 2077 * @return The builder. 2078 */ 2079 @NonNull setDataRoaming(int dataRoaming)2080 public Builder setDataRoaming(int dataRoaming) { 2081 mDataRoaming = dataRoaming; 2082 return this; 2083 } 2084 2085 /** 2086 * Set the mobile country code. 2087 * 2088 * @param mcc The mobile country code. 2089 * 2090 * @return The builder. 2091 */ 2092 @NonNull setMcc(@onNull String mcc)2093 public Builder setMcc(@NonNull String mcc) { 2094 Objects.requireNonNull(mcc); 2095 mMcc = mcc; 2096 return this; 2097 } 2098 2099 /** 2100 * Set the mobile network code. 2101 * 2102 * @param mnc Mobile network code. 2103 * 2104 * @return The builder. 2105 */ 2106 @NonNull setMnc(@onNull String mnc)2107 public Builder setMnc(@NonNull String mnc) { 2108 Objects.requireNonNull(mnc); 2109 mMnc = mnc; 2110 return this; 2111 } 2112 2113 /** 2114 * Set EHPLMNs associated with the subscription. 2115 * 2116 * @param ehplmns EHPLMNs associated with the subscription. 2117 * 2118 * @return The builder. 2119 */ 2120 @NonNull setEhplmns(@onNull String ehplmns)2121 public Builder setEhplmns(@NonNull String ehplmns) { 2122 Objects.requireNonNull(ehplmns); 2123 mEhplmns = ehplmns; 2124 return this; 2125 } 2126 2127 /** 2128 * Set HPLMNs associated with the subscription. 2129 * 2130 * @param hplmns HPLMNs associated with the subscription. 2131 * 2132 * @return The builder. 2133 */ 2134 @NonNull setHplmns(@onNull String hplmns)2135 public Builder setHplmns(@NonNull String hplmns) { 2136 Objects.requireNonNull(hplmns); 2137 mHplmns = hplmns; 2138 return this; 2139 } 2140 2141 /** 2142 * Set whether the subscription is from eSIM or not. 2143 * 2144 * @param isEmbedded {@code 1} if the subscription is from eSIM. 2145 * 2146 * @return The builder. 2147 */ 2148 @NonNull setEmbedded(int isEmbedded)2149 public Builder setEmbedded(int isEmbedded) { 2150 mIsEmbedded = isEmbedded; 2151 return this; 2152 } 2153 2154 /** 2155 * Set the card string of the SIM card. 2156 * 2157 * @param cardString The card string of the SIM card. 2158 * 2159 * @return The builder. 2160 * 2161 * @see #getCardString() 2162 */ 2163 @NonNull setCardString(@onNull String cardString)2164 public Builder setCardString(@NonNull String cardString) { 2165 Objects.requireNonNull(cardString); 2166 mCardString = cardString; 2167 return this; 2168 } 2169 2170 /** 2171 * Set the native access rules for this subscription, if it is embedded and defines any. 2172 * This does not include access rules for non-embedded subscriptions. 2173 * 2174 * @param nativeAccessRules The native access rules for this subscription. 2175 * 2176 * @return The builder. 2177 */ 2178 @NonNull setNativeAccessRules(@onNull byte[] nativeAccessRules)2179 public Builder setNativeAccessRules(@NonNull byte[] nativeAccessRules) { 2180 Objects.requireNonNull(nativeAccessRules); 2181 mNativeAccessRules = nativeAccessRules; 2182 return this; 2183 } 2184 2185 /** 2186 * Set the native access rules for this subscription, if it is embedded and defines any. 2187 * This does not include access rules for non-embedded subscriptions. 2188 * 2189 * @param nativeAccessRules The native access rules for this subscription. 2190 * 2191 * @return The builder. 2192 */ 2193 @NonNull setNativeAccessRules(@onNull List<UiccAccessRule> nativeAccessRules)2194 public Builder setNativeAccessRules(@NonNull List<UiccAccessRule> nativeAccessRules) { 2195 Objects.requireNonNull(nativeAccessRules); 2196 if (!nativeAccessRules.isEmpty()) { 2197 mNativeAccessRules = UiccAccessRule.encodeRules( 2198 nativeAccessRules.toArray(new UiccAccessRule[0])); 2199 } 2200 return this; 2201 } 2202 2203 /** 2204 * Set the carrier certificates for this subscription that are saved in carrier configs. 2205 * This does not include access rules from the Uicc, whether embedded or non-embedded. 2206 * 2207 * @param carrierConfigAccessRules The carrier certificates for this subscription. 2208 * 2209 * @return The builder. 2210 */ 2211 @NonNull setCarrierConfigAccessRules(@onNull byte[] carrierConfigAccessRules)2212 public Builder setCarrierConfigAccessRules(@NonNull byte[] carrierConfigAccessRules) { 2213 Objects.requireNonNull(carrierConfigAccessRules); 2214 mCarrierConfigAccessRules = carrierConfigAccessRules; 2215 return this; 2216 } 2217 2218 /** 2219 * Set whether an embedded subscription is on a removable card. Such subscriptions are 2220 * marked inaccessible as soon as the current card is removed. Otherwise, they will remain 2221 * accessible unless explicitly deleted. Only meaningful when {@link #getEmbedded()} is 2222 * {@code 1}. 2223 * 2224 * @param isRemovableEmbedded {@code true} if the subscription is from the removable 2225 * embedded SIM. 2226 * 2227 * @return The builder. 2228 */ 2229 @NonNull setRemovableEmbedded(boolean isRemovableEmbedded)2230 public Builder setRemovableEmbedded(boolean isRemovableEmbedded) { 2231 mIsRemovableEmbedded = isRemovableEmbedded ? 1 : 0; 2232 return this; 2233 } 2234 2235 /** 2236 * Set whether an embedded subscription is on a removable card. Such subscriptions are 2237 * marked inaccessible as soon as the current card is removed. Otherwise, they will remain 2238 * accessible unless explicitly deleted. Only meaningful when {@link #getEmbedded()} is 2239 * {@code 1}. 2240 * 2241 * @param isRemovableEmbedded {@code 1} if the subscription is from the removable 2242 * embedded SIM. 2243 * 2244 * @return The builder. 2245 */ 2246 @NonNull setRemovableEmbedded(int isRemovableEmbedded)2247 public Builder setRemovableEmbedded(int isRemovableEmbedded) { 2248 mIsRemovableEmbedded = isRemovableEmbedded; 2249 return this; 2250 } 2251 2252 /** 2253 * Set whether cell broadcast extreme threat alert is enabled by the user or not. 2254 * 2255 * @param isExtremeThreatAlertEnabled whether cell broadcast extreme threat alert is enabled 2256 * by the user or not. 2257 * 2258 * @return The builder. 2259 */ 2260 @NonNull setCellBroadcastExtremeThreatAlertEnabled(int isExtremeThreatAlertEnabled)2261 public Builder setCellBroadcastExtremeThreatAlertEnabled(int isExtremeThreatAlertEnabled) { 2262 mIsExtremeThreatAlertEnabled = isExtremeThreatAlertEnabled; 2263 return this; 2264 } 2265 2266 /** 2267 * Set whether cell broadcast severe threat alert is enabled by the user or not. 2268 * 2269 * @param isSevereThreatAlertEnabled whether cell broadcast severe threat alert is enabled 2270 * by the user or not. 2271 * 2272 * @return The builder. 2273 */ 2274 @NonNull setCellBroadcastSevereThreatAlertEnabled(int isSevereThreatAlertEnabled)2275 public Builder setCellBroadcastSevereThreatAlertEnabled(int isSevereThreatAlertEnabled) { 2276 mIsSevereThreatAlertEnabled = isSevereThreatAlertEnabled; 2277 return this; 2278 } 2279 2280 /** 2281 * Set whether cell broadcast amber alert is enabled by the user or not. 2282 * 2283 * @param isAmberAlertEnabled whether cell broadcast amber alert is enabled by the user or 2284 * not. 2285 * 2286 * @return The builder. 2287 */ 2288 @NonNull setCellBroadcastAmberAlertEnabled(int isAmberAlertEnabled)2289 public Builder setCellBroadcastAmberAlertEnabled(int isAmberAlertEnabled) { 2290 mIsAmberAlertEnabled = isAmberAlertEnabled; 2291 return this; 2292 } 2293 2294 /** 2295 * Set whether cell broadcast emergency alert is enabled by the user or not. 2296 * 2297 * @param isEmergencyAlertEnabled whether cell broadcast emergency alert is enabled by the 2298 * user or not. 2299 * 2300 * @return The builder. 2301 */ 2302 @NonNull setCellBroadcastEmergencyAlertEnabled(int isEmergencyAlertEnabled)2303 public Builder setCellBroadcastEmergencyAlertEnabled(int isEmergencyAlertEnabled) { 2304 mIsEmergencyAlertEnabled = isEmergencyAlertEnabled; 2305 return this; 2306 } 2307 2308 /** 2309 * Set cell broadcast alert sound duration. 2310 * 2311 * @param alertSoundDuration Alert sound duration in seconds. 2312 * 2313 * @return The builder. 2314 */ 2315 @NonNull setCellBroadcastAlertSoundDuration(int alertSoundDuration)2316 public Builder setCellBroadcastAlertSoundDuration(int alertSoundDuration) { 2317 mAlertSoundDuration = alertSoundDuration; 2318 return this; 2319 } 2320 2321 /** 2322 * Set cell broadcast alert reminder interval in minutes. 2323 * 2324 * @param reminderInterval Alert reminder interval in minutes. 2325 * 2326 * @return The builder. 2327 */ setCellBroadcastAlertReminderInterval(int reminderInterval)2328 public Builder setCellBroadcastAlertReminderInterval(int reminderInterval) { 2329 mReminderInterval = reminderInterval; 2330 return this; 2331 } 2332 2333 /** 2334 * Set whether cell broadcast alert vibration is enabled by the user or not. 2335 * 2336 * @param isAlertVibrationEnabled whether cell broadcast alert vibration is enabled by the 2337 * user or not. 2338 * 2339 * @return The builder. 2340 */ 2341 @NonNull setCellBroadcastAlertVibrationEnabled(int isAlertVibrationEnabled)2342 public Builder setCellBroadcastAlertVibrationEnabled(int isAlertVibrationEnabled) { 2343 mIsAlertVibrationEnabled = isAlertVibrationEnabled; 2344 return this; 2345 } 2346 2347 /** 2348 * Set whether cell broadcast alert speech is enabled by the user or not. 2349 * 2350 * @param isAlertSpeechEnabled whether cell broadcast alert speech is enabled by the user or 2351 * not. 2352 * 2353 * @return The builder. 2354 */ 2355 @NonNull setCellBroadcastAlertSpeechEnabled(int isAlertSpeechEnabled)2356 public Builder setCellBroadcastAlertSpeechEnabled(int isAlertSpeechEnabled) { 2357 mIsAlertSpeechEnabled = isAlertSpeechEnabled; 2358 return this; 2359 } 2360 2361 /** 2362 * Set whether ETWS test alert is enabled by the user or not. 2363 * 2364 * @param isEtwsTestAlertEnabled whether cell broadcast ETWS test alert is enabled by the 2365 * user or not. 2366 * 2367 * @return The builder. 2368 */ 2369 @NonNull setCellBroadcastEtwsTestAlertEnabled(int isEtwsTestAlertEnabled)2370 public Builder setCellBroadcastEtwsTestAlertEnabled(int isEtwsTestAlertEnabled) { 2371 mIsEtwsTestAlertEnabled = isEtwsTestAlertEnabled; 2372 return this; 2373 } 2374 2375 /** 2376 * Set whether area info message is enabled by the user or not. 2377 * 2378 * @param isAreaInfoMessageEnabled whether cell broadcast area info message is enabled by 2379 * the user or not. 2380 * 2381 * @return The builder. 2382 */ 2383 @NonNull setCellBroadcastAreaInfoMessageEnabled(int isAreaInfoMessageEnabled)2384 public Builder setCellBroadcastAreaInfoMessageEnabled(int isAreaInfoMessageEnabled) { 2385 mIsAreaInfoMessageEnabled = isAreaInfoMessageEnabled; 2386 return this; 2387 } 2388 2389 /** 2390 * Set whether cell broadcast test alert is enabled by the user or not. 2391 * 2392 * @param isTestAlertEnabled whether cell broadcast test alert is enabled by the user or 2393 * not. 2394 * 2395 * @return The builder. 2396 */ 2397 @NonNull setCellBroadcastTestAlertEnabled(int isTestAlertEnabled)2398 public Builder setCellBroadcastTestAlertEnabled(int isTestAlertEnabled) { 2399 mIsTestAlertEnabled = isTestAlertEnabled; 2400 return this; 2401 } 2402 2403 /** 2404 * Set whether cell broadcast opt-out dialog should be shown or not. 2405 * 2406 * @param isOptOutDialogEnabled whether cell broadcast opt-out dialog should be shown or 2407 * not. 2408 * 2409 * @return The builder. 2410 */ 2411 @NonNull setCellBroadcastOptOutDialogEnabled(int isOptOutDialogEnabled)2412 public Builder setCellBroadcastOptOutDialogEnabled(int isOptOutDialogEnabled) { 2413 mIsOptOutDialogEnabled = isOptOutDialogEnabled; 2414 return this; 2415 } 2416 2417 /** 2418 * Set whether enhanced 4G mode is enabled by the user or not. 2419 * 2420 * @param isEnhanced4GModeEnabled whether enhanced 4G mode is enabled by the user or not. 2421 * 2422 * @return The builder. 2423 */ 2424 @NonNull setEnhanced4GModeEnabled(int isEnhanced4GModeEnabled)2425 public Builder setEnhanced4GModeEnabled(int isEnhanced4GModeEnabled) { 2426 mIsEnhanced4GModeEnabled = isEnhanced4GModeEnabled; 2427 return this; 2428 } 2429 2430 /** 2431 * Set whether video telephony is enabled by the user or not. 2432 * 2433 * @param isVideoTelephonyEnabled whether video telephony is enabled by the user or not. 2434 * 2435 * @return The builder. 2436 */ 2437 @NonNull setVideoTelephonyEnabled(int isVideoTelephonyEnabled)2438 public Builder setVideoTelephonyEnabled(int isVideoTelephonyEnabled) { 2439 mIsVideoTelephonyEnabled = isVideoTelephonyEnabled; 2440 return this; 2441 } 2442 2443 /** 2444 * Set whether Wi-Fi calling is enabled by the user or not when the device is not roaming. 2445 * 2446 * @param isWifiCallingEnabled whether Wi-Fi calling is enabled by the user or not when 2447 * the device is not roaming. 2448 * 2449 * @return The builder. 2450 */ 2451 @NonNull setWifiCallingEnabled(int isWifiCallingEnabled)2452 public Builder setWifiCallingEnabled(int isWifiCallingEnabled) { 2453 mIsWifiCallingEnabled = isWifiCallingEnabled; 2454 return this; 2455 } 2456 2457 /** 2458 * Set Wi-Fi calling mode when the device is not roaming. 2459 * 2460 * @param wifiCallingMode Wi-Fi calling mode when the device is not roaming. 2461 * 2462 * @return The builder. 2463 */ 2464 @NonNull setWifiCallingMode(@msMmTelManager.WiFiCallingMode int wifiCallingMode)2465 public Builder setWifiCallingMode(@ImsMmTelManager.WiFiCallingMode int wifiCallingMode) { 2466 mWifiCallingMode = wifiCallingMode; 2467 return this; 2468 } 2469 2470 /** 2471 * Set Wi-Fi calling mode when the device is roaming. 2472 * 2473 * @param wifiCallingModeForRoaming Wi-Fi calling mode when the device is roaming. 2474 * 2475 * @return The builder. 2476 */ 2477 @NonNull setWifiCallingModeForRoaming( @msMmTelManager.WiFiCallingMode int wifiCallingModeForRoaming)2478 public Builder setWifiCallingModeForRoaming( 2479 @ImsMmTelManager.WiFiCallingMode int wifiCallingModeForRoaming) { 2480 mWifiCallingModeForRoaming = wifiCallingModeForRoaming; 2481 return this; 2482 } 2483 2484 /** 2485 * Set whether Wi-Fi calling is enabled by the user or not when the device is roaming. 2486 * 2487 * @param wifiCallingEnabledForRoaming whether Wi-Fi calling is enabled by the user or not 2488 * when the device is roaming. 2489 * 2490 * @return The builder. 2491 */ 2492 @NonNull setWifiCallingEnabledForRoaming(int wifiCallingEnabledForRoaming)2493 public Builder setWifiCallingEnabledForRoaming(int wifiCallingEnabledForRoaming) { 2494 mIsWifiCallingEnabledForRoaming = wifiCallingEnabledForRoaming; 2495 return this; 2496 } 2497 2498 /** 2499 * Set whether the subscription is opportunistic or not. 2500 * 2501 * @param isOpportunistic {@code 1} if the subscription is opportunistic. 2502 * @return The builder. 2503 */ 2504 @NonNull setOpportunistic(int isOpportunistic)2505 public Builder setOpportunistic(int isOpportunistic) { 2506 mIsOpportunistic = isOpportunistic; 2507 return this; 2508 } 2509 2510 /** 2511 * Set the group UUID of the subscription group. 2512 * 2513 * @param groupUuid The group UUID. 2514 * @return The builder. 2515 * 2516 */ 2517 @NonNull setGroupUuid(@onNull String groupUuid)2518 public Builder setGroupUuid(@NonNull String groupUuid) { 2519 Objects.requireNonNull(groupUuid); 2520 mGroupUuid = groupUuid; 2521 return this; 2522 } 2523 2524 /** 2525 * Set the ISO country code for the subscription's provider. 2526 * 2527 * @param countryIso The ISO country code for the subscription's provider. 2528 * @return The builder. 2529 */ 2530 @NonNull setCountryIso(@onNull String countryIso)2531 public Builder setCountryIso(@NonNull String countryIso) { 2532 Objects.requireNonNull(countryIso); 2533 mCountryIso = countryIso; 2534 return this; 2535 } 2536 2537 /** 2538 * Set the subscription carrier id. 2539 * 2540 * @param carrierId The carrier id. 2541 * @return The builder 2542 * 2543 * @see TelephonyManager#getSimCarrierId() 2544 */ 2545 @NonNull setCarrierId(int carrierId)2546 public Builder setCarrierId(int carrierId) { 2547 mCarrierId = carrierId; 2548 return this; 2549 } 2550 2551 /** 2552 * Set the profile class populated from the profile metadata if present. 2553 * 2554 * @param profileClass the profile class populated from the profile metadata if present. 2555 * @return The builder 2556 * 2557 * @see #getProfileClass() 2558 */ 2559 @NonNull setProfileClass(@rofileClass int profileClass)2560 public Builder setProfileClass(@ProfileClass int profileClass) { 2561 mProfileClass = profileClass; 2562 return this; 2563 } 2564 2565 /** 2566 * Set the subscription type. 2567 * 2568 * @param type Subscription type. 2569 * @return The builder. 2570 */ 2571 @NonNull setType(@ubscriptionType int type)2572 public Builder setType(@SubscriptionType int type) { 2573 mType = type; 2574 return this; 2575 } 2576 2577 /** 2578 * Set the owner package of group the subscription belongs to. 2579 * 2580 * @param groupOwner Owner package of group the subscription belongs to. 2581 * @return The builder. 2582 */ 2583 @NonNull setGroupOwner(@onNull String groupOwner)2584 public Builder setGroupOwner(@NonNull String groupOwner) { 2585 Objects.requireNonNull(groupOwner); 2586 mGroupOwner = groupOwner; 2587 return this; 2588 } 2589 2590 /** 2591 * Set the enabled mobile data policies. 2592 * 2593 * @param enabledMobileDataPolicies The enabled mobile data policies. 2594 * @return The builder. 2595 */ 2596 @NonNull setEnabledMobileDataPolicies(@onNull String enabledMobileDataPolicies)2597 public Builder setEnabledMobileDataPolicies(@NonNull String enabledMobileDataPolicies) { 2598 Objects.requireNonNull(enabledMobileDataPolicies); 2599 mEnabledMobileDataPolicies = enabledMobileDataPolicies; 2600 return this; 2601 } 2602 2603 /** 2604 * Set the IMSI (International Mobile Subscriber Identity) of the subscription. 2605 * 2606 * @param imsi The IMSI. 2607 * @return The builder. 2608 */ 2609 @NonNull setImsi(@onNull String imsi)2610 public Builder setImsi(@NonNull String imsi) { 2611 Objects.requireNonNull(imsi); 2612 mImsi = imsi; 2613 return this; 2614 } 2615 2616 /** 2617 * Set whether Uicc applications are configured to enable or not. 2618 * 2619 * @param areUiccApplicationsEnabled {@code 1} if Uicc applications are configured to 2620 * enable. 2621 * @return The builder. 2622 */ 2623 @NonNull setUiccApplicationsEnabled(int areUiccApplicationsEnabled)2624 public Builder setUiccApplicationsEnabled(int areUiccApplicationsEnabled) { 2625 mAreUiccApplicationsEnabled = areUiccApplicationsEnabled; 2626 return this; 2627 } 2628 2629 /** 2630 * Set whether the user has enabled IMS RCS User Capability Exchange (UCE) for this 2631 * subscription. 2632 * 2633 * @param isRcsUceEnabled If the user enabled RCS UCE for this subscription. 2634 * @return The builder. 2635 */ 2636 @NonNull setRcsUceEnabled(int isRcsUceEnabled)2637 public Builder setRcsUceEnabled(int isRcsUceEnabled) { 2638 mIsRcsUceEnabled = isRcsUceEnabled; 2639 return this; 2640 } 2641 2642 /** 2643 * Set whether the user has enabled cross SIM calling for this subscription. 2644 * 2645 * @param isCrossSimCallingEnabled If the user enabled cross SIM calling for this 2646 * subscription. 2647 * @return The builder. 2648 */ 2649 @NonNull setCrossSimCallingEnabled(int isCrossSimCallingEnabled)2650 public Builder setCrossSimCallingEnabled(int isCrossSimCallingEnabled) { 2651 mIsCrossSimCallingEnabled = isCrossSimCallingEnabled; 2652 return this; 2653 } 2654 2655 /** 2656 * Set the RCS config for this subscription. 2657 * 2658 * @param rcsConfig The RCS config for this subscription. 2659 * @return The builder. 2660 */ 2661 @NonNull setRcsConfig(byte[] rcsConfig)2662 public Builder setRcsConfig(byte[] rcsConfig) { 2663 Objects.requireNonNull(rcsConfig); 2664 mRcsConfig = rcsConfig; 2665 return this; 2666 } 2667 2668 /** 2669 * Set the allowed network types for reasons. 2670 * 2671 * @param allowedNetworkTypesForReasons The allowed network types for reasons in string 2672 * format. The format is 2673 * "[reason]=[network types bitmask], [reason]=[network types bitmask], ..." 2674 * 2675 * For example, "user=1239287394, thermal=298791239, carrier=3456812312". 2676 * 2677 * @return The builder. 2678 */ setAllowedNetworkTypesForReasons( @onNull String allowedNetworkTypesForReasons)2679 public Builder setAllowedNetworkTypesForReasons( 2680 @NonNull String allowedNetworkTypesForReasons) { 2681 Objects.requireNonNull(allowedNetworkTypesForReasons); 2682 mAllowedNetworkTypesForReasons = allowedNetworkTypesForReasons; 2683 return this; 2684 } 2685 2686 /** 2687 * Set device to device sharing status. 2688 * 2689 * @param deviceToDeviceStatusSharingPreference Device to device sharing status. 2690 * @return The builder. 2691 */ setDeviceToDeviceStatusSharingPreference( @eviceToDeviceStatusSharingPreference int deviceToDeviceStatusSharingPreference)2692 public Builder setDeviceToDeviceStatusSharingPreference( 2693 @DeviceToDeviceStatusSharingPreference int deviceToDeviceStatusSharingPreference) { 2694 mDeviceToDeviceStatusSharingPreference = deviceToDeviceStatusSharingPreference; 2695 return this; 2696 } 2697 2698 /** 2699 * Set whether the user has opted-in voice over IMS. 2700 * 2701 * @param isVoImsOptInEnabled Whether the user has opted-in voice over IMS. 2702 * @return The builder. 2703 */ 2704 @NonNull setVoImsOptInEnabled(int isVoImsOptInEnabled)2705 public Builder setVoImsOptInEnabled(int isVoImsOptInEnabled) { 2706 mIsVoImsOptInEnabled = isVoImsOptInEnabled; 2707 return this; 2708 } 2709 2710 /** 2711 * Set contacts information that allow device to device sharing. 2712 * 2713 * @param deviceToDeviceStatusSharingContacts contacts information that allow device to 2714 * device sharing. 2715 * @return The builder. 2716 */ 2717 @NonNull setDeviceToDeviceStatusSharingContacts( @onNull String deviceToDeviceStatusSharingContacts)2718 public Builder setDeviceToDeviceStatusSharingContacts( 2719 @NonNull String deviceToDeviceStatusSharingContacts) { 2720 Objects.requireNonNull(deviceToDeviceStatusSharingContacts); 2721 mDeviceToDeviceStatusSharingContacts = deviceToDeviceStatusSharingContacts; 2722 return this; 2723 } 2724 2725 /** 2726 * Set whether the user has enabled NR advanced calling. 2727 * 2728 * @param isNrAdvancedCallingEnabled Whether the user has enabled NR advanced calling. 2729 * @return The builder. 2730 */ 2731 @NonNull setNrAdvancedCallingEnabled(int isNrAdvancedCallingEnabled)2732 public Builder setNrAdvancedCallingEnabled(int isNrAdvancedCallingEnabled) { 2733 mIsNrAdvancedCallingEnabled = isNrAdvancedCallingEnabled; 2734 return this; 2735 } 2736 2737 /** 2738 * Set the phone number retrieved from carrier. 2739 * 2740 * @param numberFromCarrier The phone number retrieved from carrier. 2741 * @return The builder. 2742 */ 2743 @NonNull setNumberFromCarrier(@onNull String numberFromCarrier)2744 public Builder setNumberFromCarrier(@NonNull String numberFromCarrier) { 2745 Objects.requireNonNull(numberFromCarrier); 2746 mNumberFromCarrier = numberFromCarrier; 2747 return this; 2748 } 2749 2750 /** 2751 * Set the phone number retrieved from IMS. 2752 * 2753 * @param numberFromIms The phone number retrieved from IMS. 2754 * @return The builder. 2755 */ 2756 @NonNull setNumberFromIms(@onNull String numberFromIms)2757 public Builder setNumberFromIms(@NonNull String numberFromIms) { 2758 Objects.requireNonNull(numberFromIms); 2759 mNumberFromIms = numberFromIms; 2760 return this; 2761 } 2762 2763 /** 2764 * Set the port index of the Uicc card. 2765 * 2766 * @param portIndex The port index of the Uicc card. 2767 * @return The builder. 2768 */ 2769 @NonNull setPortIndex(int portIndex)2770 public Builder setPortIndex(int portIndex) { 2771 mPortIndex = portIndex; 2772 return this; 2773 } 2774 2775 /** 2776 * Set subscription's preferred usage setting. 2777 * 2778 * @param usageSetting Subscription's preferred usage setting. 2779 * @return The builder. 2780 */ 2781 @NonNull setUsageSetting(@sageSetting int usageSetting)2782 public Builder setUsageSetting(@UsageSetting int usageSetting) { 2783 mUsageSetting = usageSetting; 2784 return this; 2785 } 2786 2787 /** 2788 * Set last used TP message reference. 2789 * 2790 * @param lastUsedTPMessageReference Last used TP message reference. 2791 * @return The builder. 2792 */ 2793 @NonNull setLastUsedTPMessageReference( int lastUsedTPMessageReference)2794 public Builder setLastUsedTPMessageReference( 2795 int lastUsedTPMessageReference) { 2796 mLastUsedTPMessageReference = lastUsedTPMessageReference; 2797 return this; 2798 } 2799 2800 /** 2801 * Set the user id associated with this subscription. 2802 * 2803 * @param userId The user id associated with this subscription. 2804 * @return The builder. 2805 */ 2806 @NonNull setUserId(@serIdInt int userId)2807 public Builder setUserId(@UserIdInt int userId) { 2808 mUserId = userId; 2809 return this; 2810 } 2811 2812 /** 2813 * Set whether satellite is enabled or not. 2814 * @param isSatelliteEnabled {@code 1} if satellite is enabled. 2815 * @return The builder. 2816 */ 2817 @NonNull setSatelliteEnabled(int isSatelliteEnabled)2818 public Builder setSatelliteEnabled(int isSatelliteEnabled) { 2819 mIsSatelliteEnabled = isSatelliteEnabled; 2820 return this; 2821 } 2822 2823 /** 2824 * Set whether satellite attach for carrier is enabled or disabled by user. 2825 * @param isSatelliteAttachEnabledForCarrier {@code 1} if satellite attach for carrier is 2826 * enabled. 2827 * @return The builder. 2828 */ 2829 @NonNull setSatelliteAttachEnabledForCarrier( @onNull int isSatelliteAttachEnabledForCarrier)2830 public Builder setSatelliteAttachEnabledForCarrier( 2831 @NonNull int isSatelliteAttachEnabledForCarrier) { 2832 mIsSatelliteAttachEnabledForCarrier = isSatelliteAttachEnabledForCarrier; 2833 return this; 2834 } 2835 2836 /** 2837 * Set whether the subscription is for NTN or not. 2838 * 2839 * @param isOnlyNonTerrestrialNetwork {@code 1} if the subscription is for NTN, {@code 0} 2840 * otherwise. 2841 * @return The builder. 2842 */ 2843 @NonNull setOnlyNonTerrestrialNetwork(int isOnlyNonTerrestrialNetwork)2844 public Builder setOnlyNonTerrestrialNetwork(int isOnlyNonTerrestrialNetwork) { 2845 mIsOnlyNonTerrestrialNetwork = isOnlyNonTerrestrialNetwork; 2846 return this; 2847 } 2848 2849 // Below are the fields that do not exist in the SimInfo table. 2850 /** 2851 * Set the card ID of the SIM card which contains the subscription. 2852 * 2853 * @param cardId The card ID of the SIM card which contains the subscription. 2854 * @return The builder. 2855 */ 2856 @NonNull setCardId(int cardId)2857 public Builder setCardId(int cardId) { 2858 mCardId = cardId; 2859 return this; 2860 } 2861 2862 /** 2863 * Whether group of the subscription is disabled. This is only useful if it's a grouped 2864 * opportunistic subscription. In this case, if all primary (non-opportunistic) 2865 * subscriptions in the group are deactivated (unplugged pSIM or deactivated eSIM profile), 2866 * we should disable this opportunistic subscription. 2867 * 2868 * @param isGroupDisabled {@code 1} if group of the subscription is disabled. 2869 * @return The builder. 2870 */ 2871 @NonNull setGroupDisabled(boolean isGroupDisabled)2872 public Builder setGroupDisabled(boolean isGroupDisabled) { 2873 mIsGroupDisabled = isGroupDisabled; 2874 return this; 2875 } 2876 2877 /** 2878 * Set the service capabilities the subscription supports. 2879 * @param capabilities Cellular service capabilities bitmasks 2880 * @return The builder 2881 */ setServiceCapabilities(int capabilities)2882 public Builder setServiceCapabilities(int capabilities) { 2883 mServiceCapabilities = capabilities; 2884 return this; 2885 } 2886 2887 /** 2888 * Set the transfer status of the subscription. 2889 * 2890 * @param status The transfer status 2891 * @return The builder. 2892 */ 2893 @NonNull setTransferStatus(int status)2894 public Builder setTransferStatus(int status) { 2895 mTransferStatus = status; 2896 return this; 2897 } 2898 2899 /** 2900 * Set whether satellite entitlement status is enabled by entitlement query result. 2901 * 2902 * @param isSatelliteEntitlementStatus {@code 1} if satellite entitlement status is 2903 * enabled by entitlement query result. 2904 * @return The builder 2905 */ 2906 @NonNull setSatelliteEntitlementStatus(int isSatelliteEntitlementStatus)2907 public Builder setSatelliteEntitlementStatus(int isSatelliteEntitlementStatus) { 2908 mIsSatelliteEntitlementStatus = isSatelliteEntitlementStatus; 2909 return this; 2910 } 2911 2912 /** 2913 * Set whether satellite entitlement plmns is empty or not by entitlement query result. 2914 * 2915 * @param satelliteEntitlementPlmns satellite entitlement plmns is empty or not by 2916 * entitlement query result. 2917 * @return The builder 2918 */ 2919 @NonNull setSatelliteEntitlementPlmns(@onNull String satelliteEntitlementPlmns)2920 public Builder setSatelliteEntitlementPlmns(@NonNull String satelliteEntitlementPlmns) { 2921 mSatelliteEntitlementPlmns = satelliteEntitlementPlmns; 2922 return this; 2923 } 2924 2925 /** 2926 * Build the {@link SubscriptionInfoInternal}. 2927 * 2928 * @return The {@link SubscriptionInfoInternal} instance. 2929 */ build()2930 public SubscriptionInfoInternal build() { 2931 return new SubscriptionInfoInternal(this); 2932 } 2933 } 2934 } 2935