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

Commit 03f0e112 authored by Steve Statia's avatar Steve Statia
Browse files

Fix SIM card id that is shown when inserting a pin locked pSIM or eSIM for the first time.

Currently the subId is being shown, and since there is a eSIM hidden to
the user, when a user inserts a pSIM it will show 'CARD 2'. If a
factory reset is done and previous eSIMs are not erased then 'CARD n+1'
will be shown.

This fix will show the user 'CARD n", where n is the number of SIMs that the user has downloaded/inserted themselves, starting at 1. Effectively hiding the counting of the hidden eSIMs that may be on the device.

Bug: 337931073
Test: Visually verified changes are working on the SuW as well as after the SuW when inserting a SIM with a pin lock enabled. Also tested with a pin locked eSIM after a factory reset as well as on older devices
Change-Id: I5b26f21fe49cdb58539b2a539715bd441daddaa4
parent 98dea6c7
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -1166,7 +1166,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);
                    }

@@ -1473,7 +1473,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
@@ -4527,6 +4528,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.
     *