Loading src/java/com/android/internal/telephony/uicc/UiccProfile.java +5 −1 Original line number Diff line number Diff line Loading @@ -332,7 +332,11 @@ public class UiccProfile extends Handler implements IccCard { } } private void updateExternalState() { /** * Update the external SIM state */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) public void updateExternalState() { // First check if card state is IO_ERROR or RESTRICTED if (mUiccCard.getCardState() == IccCardStatus.CardState.CARDSTATE_ERROR) { setExternalState(IccCardConstants.State.CARD_IO_ERROR); Loading tests/telephonytests/src/com/android/internal/telephony/uicc/UiccProfileTest.java +26 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.isA; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; Loading @@ -31,7 +32,7 @@ import static org.mockito.Mockito.verify; import android.os.Handler; import android.os.HandlerThread; import android.os.Message; import android.test.suitebuilder.annotation.SmallTest; import android.support.test.filters.SmallTest; import com.android.internal.telephony.IccCardConstants.State; import com.android.internal.telephony.TelephonyTest; Loading Loading @@ -429,4 +430,28 @@ public class UiccProfileTest extends TelephonyTest { // state is loaded since there is no applications. assertEquals(State.NOT_READY, mUiccProfile.getState()); } @Test @SmallTest public void testUpdateExternalState() { // IO_ERROR doReturn(IccCardStatus.CardState.CARDSTATE_ERROR).when(mUiccCard).getCardState(); mUiccProfile.updateExternalState(); assertEquals(State.CARD_IO_ERROR, mUiccProfile.getState()); // RESTRICTED doReturn(IccCardStatus.CardState.CARDSTATE_RESTRICTED).when(mUiccCard).getCardState(); mUiccProfile.updateExternalState(); assertEquals(State.CARD_RESTRICTED, mUiccProfile.getState()); // CARD PRESENT; no mUiccApplication - state should be NOT_READY doReturn(IccCardStatus.CardState.CARDSTATE_PRESENT).when(mUiccCard).getCardState(); mUiccProfile.updateExternalState(); assertEquals(State.NOT_READY, mUiccProfile.getState()); // set mUiccApplication testUpdateUiccProfileApplicationAllReady(); mUiccProfile.updateExternalState(); assertEquals(State.LOADED, mUiccProfile.getState()); } } Loading
src/java/com/android/internal/telephony/uicc/UiccProfile.java +5 −1 Original line number Diff line number Diff line Loading @@ -332,7 +332,11 @@ public class UiccProfile extends Handler implements IccCard { } } private void updateExternalState() { /** * Update the external SIM state */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE) public void updateExternalState() { // First check if card state is IO_ERROR or RESTRICTED if (mUiccCard.getCardState() == IccCardStatus.CardState.CARDSTATE_ERROR) { setExternalState(IccCardConstants.State.CARD_IO_ERROR); Loading
tests/telephonytests/src/com/android/internal/telephony/uicc/UiccProfileTest.java +26 −1 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.isA; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; Loading @@ -31,7 +32,7 @@ import static org.mockito.Mockito.verify; import android.os.Handler; import android.os.HandlerThread; import android.os.Message; import android.test.suitebuilder.annotation.SmallTest; import android.support.test.filters.SmallTest; import com.android.internal.telephony.IccCardConstants.State; import com.android.internal.telephony.TelephonyTest; Loading Loading @@ -429,4 +430,28 @@ public class UiccProfileTest extends TelephonyTest { // state is loaded since there is no applications. assertEquals(State.NOT_READY, mUiccProfile.getState()); } @Test @SmallTest public void testUpdateExternalState() { // IO_ERROR doReturn(IccCardStatus.CardState.CARDSTATE_ERROR).when(mUiccCard).getCardState(); mUiccProfile.updateExternalState(); assertEquals(State.CARD_IO_ERROR, mUiccProfile.getState()); // RESTRICTED doReturn(IccCardStatus.CardState.CARDSTATE_RESTRICTED).when(mUiccCard).getCardState(); mUiccProfile.updateExternalState(); assertEquals(State.CARD_RESTRICTED, mUiccProfile.getState()); // CARD PRESENT; no mUiccApplication - state should be NOT_READY doReturn(IccCardStatus.CardState.CARDSTATE_PRESENT).when(mUiccCard).getCardState(); mUiccProfile.updateExternalState(); assertEquals(State.NOT_READY, mUiccProfile.getState()); // set mUiccApplication testUpdateUiccProfileApplicationAllReady(); mUiccProfile.updateExternalState(); assertEquals(State.LOADED, mUiccProfile.getState()); } }