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

Commit 9c8ca1f5 authored by yinxu's avatar yinxu
Browse files

Create UiccCard when mUiccCard is null and mCardState is not ABSENT

Previously mUiccCard is only created when the mCardState is changing
from ABSENT to non ABSENT. This logic is now broken because the
mCardState may be updated in both IccCardStatus and IccSlotStatus, and
may cause the issue that mUiccCard is never created. This Cl added an
extra logic that when the mCardState is not ABSENT, while the mUiccCard
is still null, we also need to create a new mUiccCard.

This is a clean cherry-pick from:
https://googleplex-android-review.git.corp.google.com/c/platform/frameworks/opt/telephony/+/3867960

Bug:77279870
Test: Unit Test
Change-Id: I0750cb118044dca6dfc12e8cf1a9cb6f143b2fdb
Merged-in: I0750cb118044dca6dfc12e8cf1a9cb6f143b2fdb
(cherry picked from commit de72f773)
parent 02f7123e
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -76,9 +76,11 @@ public class UiccSlot extends Handler {
     * Update slot. The main trigger for this is a change in the ICC Card status.
     */
    public void update(CommandsInterface ci, IccCardStatus ics, int phoneId) {
        if (DBG) log("cardStatus update: " + ics.toString());
        synchronized (mLock) {
            CardState oldState = mCardState;
            mCardState = ics.mCardState;
            mIccId = ics.iccid;
            mPhoneId = phoneId;
            parseAtr(ics.atr);
            mCi = ci;
@@ -104,8 +106,12 @@ public class UiccSlot extends Handler {
                    mUiccCard.dispose();
                    mUiccCard = null;
                }
            } else if ((oldState == null || oldState == CardState.CARDSTATE_ABSENT)
                    && mCardState != CardState.CARDSTATE_ABSENT) {
            // Because mUiccCard may be updated in both IccCardStatus and IccSlotStatus, we need to
            // create a new UiccCard instance in two scenarios:
            //   1. mCardState is changing from ABSENT to non ABSENT.
            //   2. The latest mCardState is not ABSENT, but there is no UiccCard instance.
            } else if ((oldState == null || oldState == CardState.CARDSTATE_ABSENT
                    || mUiccCard == null) && mCardState != CardState.CARDSTATE_ABSENT) {
                // No notifications while radio is off or we just powering up
                if (radioState == RadioState.RADIO_ON && mLastRadioState == RadioState.RADIO_ON) {
                    if (DBG) log("update: notify card added");
@@ -136,7 +142,7 @@ public class UiccSlot extends Handler {
     * Update slot based on IccSlotStatus.
     */
    public void update(CommandsInterface ci, IccSlotStatus iss) {
        log("slotStatus update");
        if (DBG) log("slotStatus update: " + iss.toString());
        synchronized (mLock) {
            mCi = ci;
            if (iss.slotState == IccSlotStatus.SlotState.SLOTSTATE_INACTIVE) {