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

Commit 9717482e authored by Steve Statia's avatar Steve Statia Committed by Automerger Merge Worker
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 am: 953a8fc4

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/27215837



Change-Id: I8c3abb2a56593efe24f4c206eb0514b70f5950be
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 6503dbb1 953a8fc4
Loading
Loading
Loading
Loading
+21 −2
Original line number Diff line number Diff line
@@ -1181,7 +1181,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);
                    }

@@ -1495,7 +1495,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
@@ -4732,6 +4733,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.
     *