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

Commit f4085d01 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13299163 from 52aa07e3 to 25Q3-release

Change-Id: I88925712cac29c402f56535f7043ab266383d884
parents 7c05ea1a 52aa07e3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2159,7 +2159,7 @@ public class RIL extends BaseCommands implements CommandsInterface {
                riljLog(rr.serialString() + "> iccIO: " + RILUtils.requestToString(rr.mRequest)
                        + " command = 0x" + Integer.toHexString(command) + " fileId = 0x"
                        + Integer.toHexString(fileId) + " path = " + path + " p1 = " + p1
                        + " p2 = " + p2 + " p3 = " + " data = " + data + " aid = " + aid);
                        + " p2 = " + p2 + " p3 = " + p3 + " data = " + data + " aid = " + aid);
            } else {
                riljLog(rr.serialString() + "> iccIO: "
                        + RILUtils.requestToString(rr.mRequest));
+7 −3
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ import java.security.KeyStore;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.Executors;

import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
@@ -145,6 +146,7 @@ public class PinStorage extends Handler {
    private final int mBootCount;
    private final KeyStore mKeyStore;

    @Nullable
    private SecretKey mLongTermSecretKey;
    private SecretKey mShortTermSecretKey;

@@ -208,7 +210,9 @@ public class PinStorage extends Handler {
        // The short term key is retrieved later when needed.
        String alias = (!mIsDeviceSecure || mIsDeviceLocked)
                ? KEYSTORE_ALIAS_LONG_TERM_ALWAYS : KEYSTORE_ALIAS_LONG_TERM_USER_AUTH;
        mLongTermSecretKey = initializeSecretKey(alias, /*createIfAbsent=*/ true);
        // This is the main thread, so accessing keystore in a separate thread to prevent ANR.
        Executors.newSingleThreadExecutor().execute(() -> mLongTermSecretKey = initializeSecretKey(
                alias, /*createIfAbsent=*/ true));

        // If the device is not securee or is unlocked, we can start logic. Otherwise we need to
        // wait for the device to be unlocked and store any temporary PIN in RAM.
@@ -807,7 +811,7 @@ public class PinStorage extends Handler {
     * @return true if the operation was successful, false otherwise
     */
    private boolean savePinInformation(SharedPreferences.Editor editor, int slotId,
            StoredPin storedPin, String baseKey, SecretKey secretKey) {
            StoredPin storedPin, String baseKey, @Nullable SecretKey secretKey) {
        if (secretKey == null) {
            // Secret key for encryption is missing
            return false;
@@ -1150,7 +1154,7 @@ public class PinStorage extends Handler {
    }

    /** Returns the encrypted version of {@code input}, or an empty array in case of error. */
    private byte[] encrypt(SecretKey secretKey, byte[] input) {
    private byte[] encrypt(@Nullable SecretKey secretKey, byte[] input) {
        if (secretKey == null) {
            loge("Encrypt: Secret key is null");
            return new byte[0];
+0 −30
Original line number Diff line number Diff line
@@ -392,31 +392,6 @@ public class ApduSenderTest {
        verify(mMockCi, times(1)).iccOpenLogicalChannel(eq(ApduSender.ISD_R_AID), anyInt(), any());
    }

    @Test
    public void testConstructor_doNotCloseOpenChannelInSharedPreference()
                  throws InterruptedException {
        // Open a channel and not close it, by making CI.iccTransmitApduLogicalChannel throw.
        int channel = LogicalChannelMocker.mockOpenLogicalChannelResponse(mMockCi, "9000");
        doThrow(new RuntimeException()).when(mMockCi).iccTransmitApduLogicalChannel(
                eq(channel), anyInt(), anyInt(), anyInt(), anyInt(), anyInt(), any(),
                anyBoolean(), any());
        mSender.send((selectResponse, requestBuilder) -> requestBuilder.addApdu(
                10, 1, 2, 3, 0, "a"), mResponseCaptor, mHandler);
        mLooper.processAllMessages();
        // Stub close channel
        reset(mMockCi);
        LogicalChannelMocker.mockCloseLogicalChannel(mMockCi, channel, /* error= */ null);

        // Call constructor
        mSender = new ApduSender(InstrumentationRegistry.getContext(), PHONE_ID,
                            mMockCi, ApduSender.ISD_R_AID, false /* supportExtendedApdu */);
        mLooper.processAllMessages();

        // The constructor should have closed channel
        verify(mMockCi, times(0)).iccCloseLogicalChannel(eq(channel), eq(true /*isEs10*/), any());
        assertEquals(1, getChannelIdFromSharedPreferences());
    }

    @Test
    public void testSend_OpenChannelFailedNoSuchElement_useChannelInSharedPreference() {
        // Open a channel but not close, by making CI.iccTransmitApduLogicalChannel throw.
@@ -427,13 +402,8 @@ public class ApduSenderTest {
        mSender.send((selectResponse, requestBuilder) -> requestBuilder.addApdu(
                10, 1, 2, 3, 0, "a"), mResponseCaptor, mHandler);
        mLooper.processAllMessages();
        reset(mMockCi);
        // Constructor fails to close channel
        LogicalChannelMocker.mockCloseLogicalChannel(
                mMockCi, channel, new CommandException(RADIO_NOT_AVAILABLE));
        mSender = new ApduSender(InstrumentationRegistry.getContext(), PHONE_ID,
                            mMockCi, ApduSender.ISD_R_AID, false /* supportExtendedApdu */);
        mLooper.processAllMessages();
        reset(mMockCi);
        // Stub open channel failure NO_SUCH_ELEMENT
        LogicalChannelMocker.mockOpenLogicalChannelResponse(mMockCi,