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

Commit 68a5be13 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Reset card state to its initial value on radio unavailable."

parents b85117c4 99c5ad1c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -403,7 +403,7 @@ public class UiccSlot extends Handler {
                    mContext, IccCardConstants.State.UNKNOWN, null, mPhoneId);
        }

        mCardState = CardState.CARDSTATE_ABSENT;
        mCardState = null;
        mLastRadioState = TelephonyManager.RADIO_POWER_UNAVAILABLE;
    }

+35 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import androidx.test.filters.SmallTest;

import com.android.internal.telephony.IccCardConstants;
import com.android.internal.telephony.TelephonyTest;
import com.android.internal.telephony.uicc.IccCardStatus.CardState;

import org.junit.After;
import org.junit.Before;
@@ -271,6 +272,40 @@ public class UiccSlotTest extends TelephonyTest {
        assertNull(mUiccSlot.getUiccCard());
    }

    @Test
    @SmallTest
    public void testUiccSlotBroadcastAbsent() {
        int phoneId = 0;
        int slotIndex = 0;
        // Simulate when SIM is added, UiccCard and UiccProfile should be created.
        mIccCardStatus.mCardState = IccCardStatus.CardState.CARDSTATE_PRESENT;
        mUiccSlot.update(mSimulatedCommands, mIccCardStatus, phoneId, slotIndex);
        verify(mTelephonyComponentFactory).makeUiccProfile(
                anyObject(), eq(mSimulatedCommands), eq(mIccCardStatus), anyInt(), anyObject(),
                anyObject());
        assertEquals(IccCardStatus.CardState.CARDSTATE_PRESENT, mUiccSlot.getCardState());
        assertNotNull(mUiccSlot.getUiccCard());

        // radio state unavailable
        mUiccSlot.onRadioStateUnavailable();

        // Verify that UNKNOWN state is sent to SubscriptionInfoUpdater in this case.
        verify(mSubInfoRecordUpdater).updateInternalIccState(
                IccCardConstants.INTENT_VALUE_ICC_UNKNOWN, null, phoneId);
        assertEquals(IccCardStatus.CardState.CARDSTATE_ABSENT, mUiccSlot.getCardState());
        assertNull(mUiccSlot.getUiccCard());

        // SIM removed while radio is unavailable, and then radio state on triggers update()
        mIccCardStatus.mCardState = CardState.CARDSTATE_ABSENT;
        mUiccSlot.update(mSimulatedCommands, mIccCardStatus, phoneId, slotIndex);

        // Verify that ABSENT state is sent to SubscriptionInfoUpdater in this case.
        verify(mSubInfoRecordUpdater).updateInternalIccState(
                IccCardConstants.INTENT_VALUE_ICC_ABSENT, null, phoneId);
        assertEquals(IccCardStatus.CardState.CARDSTATE_ABSENT, mUiccSlot.getCardState());
        assertNull(mUiccSlot.getUiccCard());
    }

    @Test
    public void testNotRemovable() throws InterruptedException {
        int phoneId = 0;