Loading src/java/com/android/internal/telephony/uicc/PinStorage.java +4 −4 Original line number Diff line number Diff line Loading @@ -250,14 +250,14 @@ public class PinStorage extends Handler { } /** * Return the cached pin for the {@code slotId}, or an empty string if it is not available. * Return the cached pin for the SIM card identified by {@code slotId} and {@code iccid}, or * an empty string if it is not available. * * The method returns the PIN only if the state is VERIFICATION_READY. If the PIN is found, * its state changes to AVAILABLE, so that it cannot be retrieved a second time during the * same boot cycle. If the PIN verification fails, it will be removed after the failed attempt. */ public synchronized String getPin(int slotId) { String iccid = getIccid(slotId); public synchronized String getPin(int slotId, String iccid) { if (!validateSlotId(slotId) || !validateIccid(iccid)) { return ""; } Loading Loading @@ -874,7 +874,7 @@ public class PinStorage extends Handler { private void verifyPendingPin(int slotId) { // We intentionally invoke getPin() here, as it updates the status and makes sure that // same PIN is not used more than once String pin = getPin(slotId); String pin = getPin(slotId, getIccid(slotId)); if (pin.isEmpty()) { // PIN is not available for verification: return. return; Loading src/java/com/android/internal/telephony/uicc/UiccProfile.java +1 −1 Original line number Diff line number Diff line Loading @@ -630,7 +630,7 @@ public class UiccProfile extends IccCard { // If the PIN code is required and an available cached PIN is available, intercept // the update of external state and perform an internal PIN verification. if (lockedState == IccCardConstants.State.PIN_REQUIRED) { String pin = mPinStorage.getPin(mPhoneId); String pin = mPinStorage.getPin(mPhoneId, mIccRecords.getFullIccId()); if (!pin.isEmpty()) { log("PIN_REQUIRED[" + mPhoneId + "] - Cache present"); mCi.supplyIccPin(pin, mHandler.obtainMessage(EVENT_SUPPLY_ICC_PIN_DONE)); Loading tests/telephonytests/src/com/android/internal/telephony/uicc/PinStorageTest.java +22 −22 Original line number Diff line number Diff line Loading @@ -108,7 +108,7 @@ public class PinStorageTest extends TelephonyTest { public void storePin_withoutReboot_pinCannotBeRetrieved() { mPinStorage.storePin("1234", 0); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -118,7 +118,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -130,7 +130,7 @@ public class PinStorageTest extends TelephonyTest { mPinStorage = new PinStorage(mContext); mPinStorage.mShortTermSecretKeyDurationMinutes = 0; assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -144,8 +144,8 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); // PIN can be retrieved only once after unattended reboot assertThat(mPinStorage.getPin(0)).isEqualTo("1234"); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo("1234"); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -164,7 +164,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); // PIN cannot be retrieved assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -181,7 +181,7 @@ public class PinStorageTest extends TelephonyTest { moveTimeForward(60000); processAllMessages(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); // Simulate a second unattended reboot to make sure that PIN was deleted. result = mPinStorage.prepareUnattendedReboot(); Loading @@ -189,7 +189,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -205,7 +205,7 @@ public class PinStorageTest extends TelephonyTest { processAllMessages(); simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -221,12 +221,12 @@ public class PinStorageTest extends TelephonyTest { // Switch to a different ICCID in the device after the reboot doReturn(ICCID_2).when(mPhone).getFullIccSerialNumber(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_2)).isEqualTo(""); // Switch back to the initial ICCID to make sure that PIN was deleted. doReturn(ICCID_1).when(mPhone).getFullIccSerialNumber(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -240,7 +240,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -254,7 +254,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo("5678"); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo("5678"); } @Test Loading @@ -267,7 +267,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -280,7 +280,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -293,7 +293,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_INVALID)).isEqualTo(""); } @Test Loading @@ -309,7 +309,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -328,7 +328,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -346,7 +346,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -369,7 +369,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -389,7 +389,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -409,6 +409,6 @@ public class PinStorageTest extends TelephonyTest { mContext.sendBroadcast(intent); processAllMessages(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } } Loading
src/java/com/android/internal/telephony/uicc/PinStorage.java +4 −4 Original line number Diff line number Diff line Loading @@ -250,14 +250,14 @@ public class PinStorage extends Handler { } /** * Return the cached pin for the {@code slotId}, or an empty string if it is not available. * Return the cached pin for the SIM card identified by {@code slotId} and {@code iccid}, or * an empty string if it is not available. * * The method returns the PIN only if the state is VERIFICATION_READY. If the PIN is found, * its state changes to AVAILABLE, so that it cannot be retrieved a second time during the * same boot cycle. If the PIN verification fails, it will be removed after the failed attempt. */ public synchronized String getPin(int slotId) { String iccid = getIccid(slotId); public synchronized String getPin(int slotId, String iccid) { if (!validateSlotId(slotId) || !validateIccid(iccid)) { return ""; } Loading Loading @@ -874,7 +874,7 @@ public class PinStorage extends Handler { private void verifyPendingPin(int slotId) { // We intentionally invoke getPin() here, as it updates the status and makes sure that // same PIN is not used more than once String pin = getPin(slotId); String pin = getPin(slotId, getIccid(slotId)); if (pin.isEmpty()) { // PIN is not available for verification: return. return; Loading
src/java/com/android/internal/telephony/uicc/UiccProfile.java +1 −1 Original line number Diff line number Diff line Loading @@ -630,7 +630,7 @@ public class UiccProfile extends IccCard { // If the PIN code is required and an available cached PIN is available, intercept // the update of external state and perform an internal PIN verification. if (lockedState == IccCardConstants.State.PIN_REQUIRED) { String pin = mPinStorage.getPin(mPhoneId); String pin = mPinStorage.getPin(mPhoneId, mIccRecords.getFullIccId()); if (!pin.isEmpty()) { log("PIN_REQUIRED[" + mPhoneId + "] - Cache present"); mCi.supplyIccPin(pin, mHandler.obtainMessage(EVENT_SUPPLY_ICC_PIN_DONE)); Loading
tests/telephonytests/src/com/android/internal/telephony/uicc/PinStorageTest.java +22 −22 Original line number Diff line number Diff line Loading @@ -108,7 +108,7 @@ public class PinStorageTest extends TelephonyTest { public void storePin_withoutReboot_pinCannotBeRetrieved() { mPinStorage.storePin("1234", 0); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -118,7 +118,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -130,7 +130,7 @@ public class PinStorageTest extends TelephonyTest { mPinStorage = new PinStorage(mContext); mPinStorage.mShortTermSecretKeyDurationMinutes = 0; assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -144,8 +144,8 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); // PIN can be retrieved only once after unattended reboot assertThat(mPinStorage.getPin(0)).isEqualTo("1234"); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo("1234"); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -164,7 +164,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); // PIN cannot be retrieved assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -181,7 +181,7 @@ public class PinStorageTest extends TelephonyTest { moveTimeForward(60000); processAllMessages(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); // Simulate a second unattended reboot to make sure that PIN was deleted. result = mPinStorage.prepareUnattendedReboot(); Loading @@ -189,7 +189,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -205,7 +205,7 @@ public class PinStorageTest extends TelephonyTest { processAllMessages(); simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -221,12 +221,12 @@ public class PinStorageTest extends TelephonyTest { // Switch to a different ICCID in the device after the reboot doReturn(ICCID_2).when(mPhone).getFullIccSerialNumber(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_2)).isEqualTo(""); // Switch back to the initial ICCID to make sure that PIN was deleted. doReturn(ICCID_1).when(mPhone).getFullIccSerialNumber(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -240,7 +240,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -254,7 +254,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo("5678"); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo("5678"); } @Test Loading @@ -267,7 +267,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -280,7 +280,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -293,7 +293,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_INVALID)).isEqualTo(""); } @Test Loading @@ -309,7 +309,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -328,7 +328,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -346,7 +346,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -369,7 +369,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -389,7 +389,7 @@ public class PinStorageTest extends TelephonyTest { simulateReboot(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } @Test Loading @@ -409,6 +409,6 @@ public class PinStorageTest extends TelephonyTest { mContext.sendBroadcast(intent); processAllMessages(); assertThat(mPinStorage.getPin(0)).isEqualTo(""); assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo(""); } }