Loading src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +2 −0 Original line number Diff line number Diff line Loading @@ -169,6 +169,8 @@ public class SubscriptionInfoUpdater extends Handler { } public void updateInternalIccState(String simStatus, String reason, int slotId) { logd("updateInternalIccState to simStatus " + simStatus + " reason " + reason + " slotId " + slotId); int message = internalIccStateToMessage(simStatus); if (message != EVENT_INVALID) { sendMessage(obtainMessage(message, slotId, -1, reason)); Loading src/java/com/android/internal/telephony/uicc/UiccSlot.java +11 −5 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ public class UiccSlot extends Handler { if (DBG) log("Creating"); mContext = c; mActive = isActive; mCardState = CardState.CARDSTATE_ABSENT; mCardState = null; } /** Loading Loading @@ -100,9 +100,11 @@ public class UiccSlot extends Handler { IccCardConstants.INTENT_VALUE_ICC_ABSENT, null, mPhoneId); // no card present in the slot now; dispose card and make mUiccCard null if (mUiccCard != null) { mUiccCard.dispose(); mUiccCard = null; } else if (oldState == CardState.CARDSTATE_ABSENT } } else if ((oldState == null || oldState == CardState.CARDSTATE_ABSENT) && mCardState != CardState.CARDSTATE_ABSENT) { // No notifications while radio is off or we just powering up if (radioState == RadioState.RADIO_ON && mLastRadioState == RadioState.RADIO_ON) { Loading Loading @@ -301,9 +303,13 @@ public class UiccSlot extends Handler { */ public CardState getCardState() { synchronized (mLock) { if (mCardState == null) { return CardState.CARDSTATE_ABSENT; } else { return mCardState; } } } /** * Returns the UiccCard in the slot. Loading tests/telephonytests/src/com/android/internal/telephony/uicc/UiccSlotTest.java +43 −0 Original line number Diff line number Diff line Loading @@ -17,14 +17,20 @@ package com.android.internal.telephony.uicc; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.verify; import android.os.Handler; import android.os.HandlerThread; import android.os.Message; import android.support.test.filters.SmallTest; import com.android.internal.telephony.IccCardConstants; import com.android.internal.telephony.TelephonyTest; import org.junit.After; Loading Loading @@ -74,6 +80,7 @@ public class UiccSlotTest extends TelephonyTest { @Before public void setUp() throws Exception { super.setUp(getClass().getSimpleName()); mContextFixture.putBooleanResource(com.android.internal.R.bool.config_hotswapCapable, true); /* initially there are no application available */ mIccCardStatus.mApplications = new IccCardApplicationStatus[]{}; mIccCardStatus.mCdmaSubscriptionAppIndex = Loading Loading @@ -192,4 +199,40 @@ public class UiccSlotTest extends TelephonyTest { assertTrue(mUiccSlot.isActive()); assertFalse(mUiccSlot.isEuicc()); } @Test @SmallTest public void testUpdateAbsentState() { int phoneId = 0; // Make sure when received CARDSTATE_ABSENT state in the first time, mIccCardStatus.mCardState = IccCardStatus.CardState.CARDSTATE_ABSENT; mUiccSlot.update(mSimulatedCommands, mIccCardStatus, phoneId); verify(mSubInfoRecordUpdater).updateInternalIccState( IccCardConstants.INTENT_VALUE_ICC_ABSENT, null, phoneId); assertEquals(IccCardStatus.CardState.CARDSTATE_ABSENT, mUiccSlot.getCardState()); assertNull(mUiccSlot.getUiccCard()); } @Test @SmallTest public void testUiccSlotCreateAndDispose() { int phoneId = 0; // Simulate when SIM is added, UiccCard and UiccProfile should be created. mIccCardStatus.mCardState = IccCardStatus.CardState.CARDSTATE_PRESENT; mUiccSlot.update(mSimulatedCommands, mIccCardStatus, phoneId); verify(mTelephonyComponentFactory).makeUiccProfile( anyObject(), eq(mSimulatedCommands), eq(mIccCardStatus), anyInt(), anyObject()); assertEquals(IccCardStatus.CardState.CARDSTATE_PRESENT, mUiccSlot.getCardState()); assertNotNull(mUiccSlot.getUiccCard()); // Simulate when SIM is removed, UiccCard and UiccProfile should be disposed and ABSENT // state is sent to SubscriptionInfoUpdater. mIccCardStatus.mCardState = IccCardStatus.CardState.CARDSTATE_ABSENT; mUiccSlot.update(mSimulatedCommands, mIccCardStatus, phoneId); verify(mSubInfoRecordUpdater).updateInternalIccState( IccCardConstants.INTENT_VALUE_ICC_ABSENT, null, phoneId); verify(mUiccProfile).dispose(); assertEquals(IccCardStatus.CardState.CARDSTATE_ABSENT, mUiccSlot.getCardState()); assertNull(mUiccSlot.getUiccCard()); } } Loading
src/java/com/android/internal/telephony/SubscriptionInfoUpdater.java +2 −0 Original line number Diff line number Diff line Loading @@ -169,6 +169,8 @@ public class SubscriptionInfoUpdater extends Handler { } public void updateInternalIccState(String simStatus, String reason, int slotId) { logd("updateInternalIccState to simStatus " + simStatus + " reason " + reason + " slotId " + slotId); int message = internalIccStateToMessage(simStatus); if (message != EVENT_INVALID) { sendMessage(obtainMessage(message, slotId, -1, reason)); Loading
src/java/com/android/internal/telephony/uicc/UiccSlot.java +11 −5 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ public class UiccSlot extends Handler { if (DBG) log("Creating"); mContext = c; mActive = isActive; mCardState = CardState.CARDSTATE_ABSENT; mCardState = null; } /** Loading Loading @@ -100,9 +100,11 @@ public class UiccSlot extends Handler { IccCardConstants.INTENT_VALUE_ICC_ABSENT, null, mPhoneId); // no card present in the slot now; dispose card and make mUiccCard null if (mUiccCard != null) { mUiccCard.dispose(); mUiccCard = null; } else if (oldState == CardState.CARDSTATE_ABSENT } } else if ((oldState == null || oldState == CardState.CARDSTATE_ABSENT) && mCardState != CardState.CARDSTATE_ABSENT) { // No notifications while radio is off or we just powering up if (radioState == RadioState.RADIO_ON && mLastRadioState == RadioState.RADIO_ON) { Loading Loading @@ -301,9 +303,13 @@ public class UiccSlot extends Handler { */ public CardState getCardState() { synchronized (mLock) { if (mCardState == null) { return CardState.CARDSTATE_ABSENT; } else { return mCardState; } } } /** * Returns the UiccCard in the slot. Loading
tests/telephonytests/src/com/android/internal/telephony/uicc/UiccSlotTest.java +43 −0 Original line number Diff line number Diff line Loading @@ -17,14 +17,20 @@ package com.android.internal.telephony.uicc; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.Mockito.eq; import static org.mockito.Mockito.verify; import android.os.Handler; import android.os.HandlerThread; import android.os.Message; import android.support.test.filters.SmallTest; import com.android.internal.telephony.IccCardConstants; import com.android.internal.telephony.TelephonyTest; import org.junit.After; Loading Loading @@ -74,6 +80,7 @@ public class UiccSlotTest extends TelephonyTest { @Before public void setUp() throws Exception { super.setUp(getClass().getSimpleName()); mContextFixture.putBooleanResource(com.android.internal.R.bool.config_hotswapCapable, true); /* initially there are no application available */ mIccCardStatus.mApplications = new IccCardApplicationStatus[]{}; mIccCardStatus.mCdmaSubscriptionAppIndex = Loading Loading @@ -192,4 +199,40 @@ public class UiccSlotTest extends TelephonyTest { assertTrue(mUiccSlot.isActive()); assertFalse(mUiccSlot.isEuicc()); } @Test @SmallTest public void testUpdateAbsentState() { int phoneId = 0; // Make sure when received CARDSTATE_ABSENT state in the first time, mIccCardStatus.mCardState = IccCardStatus.CardState.CARDSTATE_ABSENT; mUiccSlot.update(mSimulatedCommands, mIccCardStatus, phoneId); verify(mSubInfoRecordUpdater).updateInternalIccState( IccCardConstants.INTENT_VALUE_ICC_ABSENT, null, phoneId); assertEquals(IccCardStatus.CardState.CARDSTATE_ABSENT, mUiccSlot.getCardState()); assertNull(mUiccSlot.getUiccCard()); } @Test @SmallTest public void testUiccSlotCreateAndDispose() { int phoneId = 0; // Simulate when SIM is added, UiccCard and UiccProfile should be created. mIccCardStatus.mCardState = IccCardStatus.CardState.CARDSTATE_PRESENT; mUiccSlot.update(mSimulatedCommands, mIccCardStatus, phoneId); verify(mTelephonyComponentFactory).makeUiccProfile( anyObject(), eq(mSimulatedCommands), eq(mIccCardStatus), anyInt(), anyObject()); assertEquals(IccCardStatus.CardState.CARDSTATE_PRESENT, mUiccSlot.getCardState()); assertNotNull(mUiccSlot.getUiccCard()); // Simulate when SIM is removed, UiccCard and UiccProfile should be disposed and ABSENT // state is sent to SubscriptionInfoUpdater. mIccCardStatus.mCardState = IccCardStatus.CardState.CARDSTATE_ABSENT; mUiccSlot.update(mSimulatedCommands, mIccCardStatus, phoneId); verify(mSubInfoRecordUpdater).updateInternalIccState( IccCardConstants.INTENT_VALUE_ICC_ABSENT, null, phoneId); verify(mUiccProfile).dispose(); assertEquals(IccCardStatus.CardState.CARDSTATE_ABSENT, mUiccSlot.getCardState()); assertNull(mUiccSlot.getUiccCard()); } }