Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 953a8fc4 authored by Steve Statia's avatar Steve Statia Committed by Android (Google) Code Review
Browse files

Merge "Fix SIM card id that is shown when inserting a pin locked pSIM or eSIM...

Merge "Fix SIM card id that is shown when inserting a pin locked pSIM or eSIM for the first time." into 24D1-dev
parents 2316a64b 03f0e112
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -1172,7 +1172,7 @@ public class SubscriptionManagerService extends ISub.Stub {
                                SubscriptionManager.INVALID_SIM_SLOT_INDEX,
                                null, SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM);
                        mSubscriptionDatabaseManager.setDisplayName(subId, mContext.getResources()
                                .getString(R.string.default_card_name, subId));
                                .getString(R.string.default_card_name, getCardNumber(subId)));
                        subInfo = mSubscriptionDatabaseManager.getSubscriptionInfoInternal(subId);
                    }

@@ -1486,7 +1486,8 @@ public class SubscriptionManagerService extends ISub.Stub {
                    subId = insertSubscriptionInfo(iccId, phoneId, null,
                            SubscriptionManager.SUBSCRIPTION_TYPE_LOCAL_SIM);
                    mSubscriptionDatabaseManager.setDisplayName(subId,
                            mContext.getResources().getString(R.string.default_card_name, subId));
                            mContext.getResources().getString(R.string.default_card_name,
                                    getCardNumber(subId)));
                } else {
                    subId = subInfo.getSubscriptionId();
                    log("updateSubscription: Found existing subscription. subId= " + subId
@@ -4613,6 +4614,24 @@ public class SubscriptionManagerService extends ISub.Stub {
                || SystemProperties.getBoolean(BOOT_ALLOW_MOCK_MODEM_PROPERTY, false));
    }

    /**
     * Iterates through previously subscribed SIMs to excludes subscriptions that are not visible
     * to the users to provide a more appropriate number to describe the current SIM.
     * @param subId current subscription id.
     * @return cardNumber subId excluding invisible subscriptions.
     */
    private int getCardNumber(int subId) {
        int cardNumber = subId; // Initialize with the potential card number
        for (int i = subId - 1; i > 0; i--) {
            SubscriptionInfoInternal subInfo = getSubscriptionInfoInternal(i);
            if (subInfo != null && !subInfo.isVisible()) {
                cardNumber--;
            }
        }

        return cardNumber;
    }

    /**
     * Log debug messages.
     *