aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-08-11 01:07:53 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-08-11 01:07:53 +0000
commit51302ef5e1a2f5c13b4db2650a1c52735ccca992 (patch)
treec3352ca71f8935ab45f412b4cf972897f19977f5
parent9d9d033db09cac5220eecb61592a8cad4aad826d (diff)
parent5f8529e26eac1bffe92092c6090d64e803ae09ed (diff)
downloadtelephony-android12-s3-release.tar.gz
Change-Id: I7948042fd7eb529b959acdda503aef79f15ce0d6
-rw-r--r--src/java/com/android/internal/telephony/uicc/PinStorage.java8
-rw-r--r--src/java/com/android/internal/telephony/uicc/UiccProfile.java2
-rw-r--r--tests/telephonytests/src/com/android/internal/telephony/uicc/PinStorageTest.java44
3 files changed, 27 insertions, 27 deletions
diff --git a/src/java/com/android/internal/telephony/uicc/PinStorage.java b/src/java/com/android/internal/telephony/uicc/PinStorage.java
index b348c61286..28851247c2 100644
--- a/src/java/com/android/internal/telephony/uicc/PinStorage.java
+++ b/src/java/com/android/internal/telephony/uicc/PinStorage.java
@@ -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 "";
}
@@ -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;
diff --git a/src/java/com/android/internal/telephony/uicc/UiccProfile.java b/src/java/com/android/internal/telephony/uicc/UiccProfile.java
index 542043752c..9b601853f3 100644
--- a/src/java/com/android/internal/telephony/uicc/UiccProfile.java
+++ b/src/java/com/android/internal/telephony/uicc/UiccProfile.java
@@ -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));
diff --git a/tests/telephonytests/src/com/android/internal/telephony/uicc/PinStorageTest.java b/tests/telephonytests/src/com/android/internal/telephony/uicc/PinStorageTest.java
index f165a9ef4d..a26c0f905a 100644
--- a/tests/telephonytests/src/com/android/internal/telephony/uicc/PinStorageTest.java
+++ b/tests/telephonytests/src/com/android/internal/telephony/uicc/PinStorageTest.java
@@ -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
@@ -118,7 +118,7 @@ public class PinStorageTest extends TelephonyTest {
simulateReboot();
- assertThat(mPinStorage.getPin(0)).isEqualTo("");
+ assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo("");
}
@Test
@@ -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
@@ -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
@@ -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
@@ -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();
@@ -189,7 +189,7 @@ public class PinStorageTest extends TelephonyTest {
simulateReboot();
- assertThat(mPinStorage.getPin(0)).isEqualTo("");
+ assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo("");
}
@Test
@@ -205,7 +205,7 @@ public class PinStorageTest extends TelephonyTest {
processAllMessages();
simulateReboot();
- assertThat(mPinStorage.getPin(0)).isEqualTo("");
+ assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo("");
}
@Test
@@ -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
@@ -240,7 +240,7 @@ public class PinStorageTest extends TelephonyTest {
simulateReboot();
- assertThat(mPinStorage.getPin(0)).isEqualTo("");
+ assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo("");
}
@Test
@@ -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
@@ -267,7 +267,7 @@ public class PinStorageTest extends TelephonyTest {
simulateReboot();
- assertThat(mPinStorage.getPin(0)).isEqualTo("");
+ assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo("");
}
@Test
@@ -280,7 +280,7 @@ public class PinStorageTest extends TelephonyTest {
simulateReboot();
- assertThat(mPinStorage.getPin(0)).isEqualTo("");
+ assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo("");
}
@Test
@@ -293,7 +293,7 @@ public class PinStorageTest extends TelephonyTest {
simulateReboot();
- assertThat(mPinStorage.getPin(0)).isEqualTo("");
+ assertThat(mPinStorage.getPin(0, ICCID_INVALID)).isEqualTo("");
}
@Test
@@ -309,7 +309,7 @@ public class PinStorageTest extends TelephonyTest {
simulateReboot();
- assertThat(mPinStorage.getPin(0)).isEqualTo("");
+ assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo("");
}
@Test
@@ -328,7 +328,7 @@ public class PinStorageTest extends TelephonyTest {
simulateReboot();
- assertThat(mPinStorage.getPin(0)).isEqualTo("");
+ assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo("");
}
@Test
@@ -346,7 +346,7 @@ public class PinStorageTest extends TelephonyTest {
simulateReboot();
- assertThat(mPinStorage.getPin(0)).isEqualTo("");
+ assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo("");
}
@Test
@@ -369,7 +369,7 @@ public class PinStorageTest extends TelephonyTest {
simulateReboot();
- assertThat(mPinStorage.getPin(0)).isEqualTo("");
+ assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo("");
}
@Test
@@ -389,7 +389,7 @@ public class PinStorageTest extends TelephonyTest {
simulateReboot();
- assertThat(mPinStorage.getPin(0)).isEqualTo("");
+ assertThat(mPinStorage.getPin(0, ICCID_1)).isEqualTo("");
}
@Test
@@ -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("");
}
}