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

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

Snap for 7579269 from 8137e881 to sc-v2-release

Change-Id: I55129051ecb671e7bca85c05c3e27170cc62fc8a
parents b730beb3 8137e881
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1163,6 +1163,7 @@ public class UiccController extends Handler {
        }

        if (changed && resp.refreshResult == IccRefreshResponse.REFRESH_RESULT_RESET) {
            uiccCard.getUiccProfile().updateIccAvailability(true);
            // If there is any change on RESET, reset carrier config as well. From carrier config
            // perspective, this is treated the same as sim state unknown
            CarrierConfigManager configManager = (CarrierConfigManager)
+1 −1
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ public class UiccPkcs15 extends Handler {
        private void readBinary() {
            if (mChannelId >=0 ) {
                mUiccProfile.iccTransmitApduLogicalChannel(mChannelId, 0x00, 0xB0, 0x00, 0x00, 0x00,
                        mFileId, obtainMessage(EVENT_READ_BINARY_DONE));
                        "", obtainMessage(EVENT_READ_BINARY_DONE));
            } else {
                log("EF based");
            }
+4 −1
Original line number Diff line number Diff line
@@ -523,7 +523,10 @@ public class UiccProfile extends IccCard {
        }
    }

    private void updateIccAvailability(boolean allAppsChanged) {
    /**
     * ICC availability/state changed. Update corresponding fields and external state if needed.
     */
    public void updateIccAvailability(boolean allAppsChanged) {
        synchronized (mLock) {
            UiccCardApplication newApp;
            IccRecords newRecords = null;
+56 −105
Original line number Diff line number Diff line
@@ -42,7 +42,10 @@ import org.mockito.Mock;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;

@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
@@ -561,9 +564,11 @@ public class UiccCarrierPrivilegeRulesTest extends TelephonyTest {
        }).when(mUiccProfile).iccOpenLogicalChannel(anyString(), anyInt(), any(Message.class));

        // Select files
        AtomicReference<String> currentFileId = new AtomicReference<>();
        doAnswer(new Answer<Void>() {
            @Override
            public Void answer(InvocationOnMock invocation) throws Throwable {
                currentFileId.set((String) invocation.getArguments()[6]);
                Message message = (Message) invocation.getArguments()[7];
                AsyncResult ar = new AsyncResult(null, new int[]{2}, null);
                message.obj = ar;
@@ -573,85 +578,44 @@ public class UiccCarrierPrivilegeRulesTest extends TelephonyTest {
        }).when(mUiccProfile).iccTransmitApduLogicalChannel(anyInt(), eq(0x00), eq(0xA4), eq(0x00),
                eq(0x04), eq(0x02), anyString(), any(Message.class));

        // Read binary - ODF
        String odf = "A706300404025207";
        // Read binary - since params are identical across files, we need to keep track of which
        // file was selected most recently and give back that content.
        Map<String, String> binaryContent =
                new HashMap<>() {
                    {
                        // ODF
                        put("5031", "A706300404025207");
                        // DODF
                        put(
                                "5207",
                                "A1293000300F0C0D4750205345204163632043746CA1143012060A2A864886FC6B"
                                        + "81480101300404024200");
                        // ACMF
                        put("4200", "301004080102030405060708300404024300");
                        // ACRF
                        put("4300", "3010A0080406FFFFFFFFFFFF300404024310");
                        // ACCF
                        put(
                                "4310",
                                "30220420B9CFCE1C47A6AC713442718F15EF55B00B3A6D1A6D48CB46249FA8EB51"
                                        + "465350302204204C36AF4A5BDAD97C1F3D8B283416D244496C2AC5EA"
                                        + "FE8226079EF6F676FD1859");
                    }
                };
        doAnswer(new Answer<Void>() {
            @Override
            public Void answer(InvocationOnMock invocation) throws Throwable {
                Message message = (Message) invocation.getArguments()[7];
                IccIoResult iir = new IccIoResult(0x90, 0x00, IccUtils.hexStringToBytes(odf));
                IccIoResult iir =
                        new IccIoResult(0x90, 0x00,
                                IccUtils.hexStringToBytes(binaryContent.get(currentFileId.get())));
                AsyncResult ar = new AsyncResult(null, iir, null);
                message.obj = ar;
                message.sendToTarget();
                return null;
            }
        }).when(mUiccProfile).iccTransmitApduLogicalChannel(anyInt(), eq(0x00), eq(0xB0), eq(0x00),
                eq(0x00), eq(0x00), eq("5031"), any(Message.class));

        // Read binary - DODF
        String dodf =
                "A1293000300F0C0D4750205345204163632043746CA11"
                        + "43012060A2A864886FC6B81480101300404024200";
        doAnswer(new Answer<Void>() {
            @Override
            public Void answer(InvocationOnMock invocation) throws Throwable {
                Message message = (Message) invocation.getArguments()[7];
                IccIoResult iir = new IccIoResult(0x90, 0x00, IccUtils.hexStringToBytes(dodf));
                AsyncResult ar = new AsyncResult(null, iir, null);
                message.obj = ar;
                message.sendToTarget();
                return null;
            }
        }).when(mUiccProfile).iccTransmitApduLogicalChannel(anyInt(), eq(0x00), eq(0xB0), eq(0x00),
                eq(0x00), eq(0x00), eq("5207"), any(Message.class));

        // Read binary - ACMF
        String acmf = "301004080102030405060708300404024300";
        doAnswer(new Answer<Void>() {
            @Override
            public Void answer(InvocationOnMock invocation) throws Throwable {
                Message message = (Message) invocation.getArguments()[7];
                IccIoResult iir = new IccIoResult(0x90, 0x00, IccUtils.hexStringToBytes(acmf));
                AsyncResult ar = new AsyncResult(null, iir, null);
                message.obj = ar;
                message.sendToTarget();
                return null;
            }
        }).when(mUiccProfile).iccTransmitApduLogicalChannel(anyInt(), eq(0x00), eq(0xB0), eq(0x00),
                eq(0x00), eq(0x00), eq("4200"), any(Message.class));

        // Read binary - ACRF
        String acrf = "3010A0080406FFFFFFFFFFFF300404024310";
        doAnswer(new Answer<Void>() {
            @Override
            public Void answer(InvocationOnMock invocation) throws Throwable {
                Message message = (Message) invocation.getArguments()[7];
                IccIoResult iir = new IccIoResult(0x90, 0x00, IccUtils.hexStringToBytes(acrf));
                AsyncResult ar = new AsyncResult(null, iir, null);
                message.obj = ar;
                message.sendToTarget();
                return null;
            }
        }).when(mUiccProfile).iccTransmitApduLogicalChannel(anyInt(), eq(0x00), eq(0xB0), eq(0x00),
                eq(0x00), eq(0x00), eq("4300"), any(Message.class));

        // Read binary - ACCF
        String accf =
                "30220420B9CFCE1C47A6AC713442718F15EF55B00B3A6D1A6D48CB46249FA8EB514653503022042"
                        + "04C36AF4A5BDAD97C1F3D8B283416D244496C2AC5EAFE8226079EF6F676FD1859";
        doAnswer(new Answer<Void>() {
            @Override
            public Void answer(InvocationOnMock invocation) throws Throwable {
                Message message = (Message) invocation.getArguments()[7];
                IccIoResult iir = new IccIoResult(0x90, 0x00, IccUtils.hexStringToBytes(accf));
                AsyncResult ar = new AsyncResult(null, iir, null);
                message.obj = ar;
                message.sendToTarget();
                return null;
            }
        }).when(mUiccProfile).iccTransmitApduLogicalChannel(anyInt(), eq(0x00), eq(0xB0), eq(0x00),
                eq(0x00), eq(0x00), eq("4310"), any(Message.class));

                eq(0x00), eq(0x00), eq(""), any(Message.class));

        doAnswer(new Answer<Void>() {
            @Override
@@ -706,9 +670,11 @@ public class UiccCarrierPrivilegeRulesTest extends TelephonyTest {
        }).when(mUiccProfile).iccOpenLogicalChannel(anyString(), anyInt(), any(Message.class));

        // Select files
        AtomicReference<String> currentFileId = new AtomicReference<>();
        doAnswer(new Answer<Void>() {
            @Override
            public Void answer(InvocationOnMock invocation) throws Throwable {
                currentFileId.set((String) invocation.getArguments()[6]);
                Message message = (Message) invocation.getArguments()[7];
                AsyncResult ar = new AsyncResult(null, new int[]{2}, null);
                message.obj = ar;
@@ -718,52 +684,37 @@ public class UiccCarrierPrivilegeRulesTest extends TelephonyTest {
        }).when(mUiccProfile).iccTransmitApduLogicalChannel(anyInt(), eq(0x00), eq(0xA4), eq(0x00),
                eq(0x04), eq(0x02), anyString(), any(Message.class));

        // Read binary ODF failed
        doAnswer(new Answer<Void>() {
            @Override
            public Void answer(InvocationOnMock invocation) throws Throwable {
                Message message = (Message) invocation.getArguments()[7];
                IccIoResult iir = new IccIoResult(0x90, 0x00, new byte[]{});
                AsyncResult ar = new AsyncResult(null, iir, null);
                message.obj = ar;
                message.sendToTarget();
                return null;
            }
        }).when(mUiccProfile).iccTransmitApduLogicalChannel(anyInt(), eq(0x00), eq(0xB0), eq(0x00),
                eq(0x00), eq(0x00), eq("5031"), any(Message.class));

        // Read binary - ACRF
        String acrf = "3010A0080406FFFFFFFFFFFF300404024310";
        doAnswer(new Answer<Void>() {
            @Override
            public Void answer(InvocationOnMock invocation) throws Throwable {
                Message message = (Message) invocation.getArguments()[7];
                IccIoResult iir = new IccIoResult(0x90, 0x00, IccUtils.hexStringToBytes(acrf));
                AsyncResult ar = new AsyncResult(null, iir, null);
                message.obj = ar;
                message.sendToTarget();
                return null;
        // Read binary - since params are identical across files, we need to keep track of which
        // file was selected most recently and give back that content.
        Map<String, String> binaryContent =
                new HashMap<>() {
                    {
                        // ODF fails
                        put("5031", "");
                        // ACRF
                        put("4300", "3010A0080406FFFFFFFFFFFF300404024310");
                        // ACCF
                        put(
                                "4310",
                                "30220420B9CFCE1C47A6AC713442718F15EF55B00B3A6D1A6D48CB46249FA8EB51"
                                        + "465350302204204C36AF4A5BDAD97C1F3D8B283416D244496C2AC5EA"
                                        + "FE8226079EF6F676FD1859");
                    }
        }).when(mUiccProfile).iccTransmitApduLogicalChannel(anyInt(), eq(0x00), eq(0xB0), eq(0x00),
                eq(0x00), eq(0x00), eq("4300"), any(Message.class));

        // Read binary - ACCF
        String accf =
                "30220420B9CFCE1C47A6AC713442718F15EF55B00B3A6D1A6D48CB46249FA8EB514653503022042"
                        + "04C36AF4A5BDAD97C1F3D8B283416D244496C2AC5EAFE8226079EF6F676FD1859";
                };
        doAnswer(new Answer<Void>() {
            @Override
            public Void answer(InvocationOnMock invocation) throws Throwable {
                Message message = (Message) invocation.getArguments()[7];
                IccIoResult iir = new IccIoResult(0x90, 0x00, IccUtils.hexStringToBytes(accf));
                IccIoResult iir =
                        new IccIoResult(0x90, 0x00,
                                IccUtils.hexStringToBytes(binaryContent.get(currentFileId.get())));
                AsyncResult ar = new AsyncResult(null, iir, null);
                message.obj = ar;
                message.sendToTarget();
                return null;
            }
        }).when(mUiccProfile).iccTransmitApduLogicalChannel(anyInt(), eq(0x00), eq(0xB0), eq(0x00),
                eq(0x00), eq(0x00), eq("4310"), any(Message.class));

                eq(0x00), eq(0x00), eq(""), any(Message.class));

        doAnswer(new Answer<Void>() {
            @Override
+23 −0
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.doReturn;
@@ -60,6 +62,7 @@ public class UiccControllerTest extends TelephonyTest {
    private static final int ICC_CHANGED_EVENT = 0;
    private static final int EVENT_GET_ICC_STATUS_DONE = 3;
    private static final int EVENT_GET_SLOT_STATUS_DONE = 4;
    private static final int EVENT_SIM_REFRESH = 8;
    private static final int EVENT_EID_READY = 9;
    @Mock
    private Handler mMockedHandler;
@@ -73,6 +76,8 @@ public class UiccControllerTest extends TelephonyTest {
    private UiccCard mMockCard;
    @Mock
    private EuiccCard mMockEuiccCard;
    @Mock
    private UiccProfile mMockProfile;

    private IccCardApplicationStatus composeUiccApplicationStatus(
            IccCardApplicationStatus.AppType appType,
@@ -631,4 +636,22 @@ public class UiccControllerTest extends TelephonyTest {
        assertEquals(mUiccControllerUT.convertToPublicCardId(knownEidFromApdu),
                mUiccControllerUT.getCardIdForDefaultEuicc());
    }

    @Test
    public void testSimRefresh() {
        mUiccControllerUT.mUiccSlots[0] = mMockSlot;
        doReturn(mMockCard).when(mMockSlot).getUiccCard();
        doReturn(mMockProfile).when(mMockCard).getUiccProfile();

        doReturn(true).when(mMockCard).resetAppWithAid(nullable(String.class), eq(true));
        IccRefreshResponse resp = new IccRefreshResponse();
        resp.refreshResult = IccRefreshResponse.REFRESH_RESULT_RESET;
        AsyncResult ar = new AsyncResult(null, resp, null);
        Message msg = Message.obtain(mUiccControllerUT, EVENT_SIM_REFRESH, ar);
        mUiccControllerUT.handleMessage(msg);
        processAllMessages();

        // verify that updateIccAvailability() is called on refresh with RESET
        verify(mMockProfile).updateIccAvailability(true);
    }
}