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

Commit 5f8529e2 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix potential deadlock accesing the value of ICCID" into sc-dev

parents 14362781 d1c9ec86
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -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));
+22 −22
Original line number Diff line number Diff line
@@ -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("");
    }
}