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

Commit d687148b authored by Holly Jiuyu Sun's avatar Holly Jiuyu Sun
Browse files

Bugs fix for eUICC.

1) Bug fix on getProfile. Should have an A0 tag when creating the
request for getProfile and pad the trailing Fs back.
2) Check null on payload to avoid NPE.
3) Fix a typo on device capabilities. cdma1x should not have the
underscore.
4) Fix the bug on length cut when creating an APDU command segment.

Bug: 77661092
Test: test on phone, unit test
Change-Id: I69ac74179d96a51fdbff9eba34e17c379e5a1bdd
parent bd7db2a4
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ public class EuiccCard extends UiccCard {
    // Device capabilities.
    private static final String DEV_CAP_GSM = "gsm";
    private static final String DEV_CAP_UTRAN = "utran";
    private static final String DEV_CAP_CDMA_1X = "cdma_1x";
    private static final String DEV_CAP_CDMA_1X = "cdma1x";
    private static final String DEV_CAP_HRPD = "hrpd";
    private static final String DEV_CAP_EHRPD = "ehrpd";
    private static final String DEV_CAP_EUTRAN = "eutran";
@@ -234,7 +234,10 @@ public class EuiccCard extends UiccCard {
        sendApdu(
                newRequestProvider((RequestBuilder requestBuilder) ->
                        requestBuilder.addStoreData(Asn1Node.newBuilder(Tags.TAG_GET_PROFILES)
                                .addChildAsBytes(Tags.TAG_ICCID, IccUtils.bcdToBytes(iccid))
                                .addChild(Asn1Node.newBuilder(Tags.TAG_CTX_COMP_0)
                                    .addChildAsBytes(
                                        Tags.TAG_ICCID, IccUtils.bcdToBytes(padTrailingFs(iccid)))
                                    .build())
                                .addChildAsBytes(Tags.TAG_TAG_LIST, Tags.EUICC_PROFILE_TAGS)
                                .build().toHex())),
                (byte[] response) -> {
+6 −4
Original line number Diff line number Diff line
@@ -198,11 +198,13 @@ public class ApduSender {
            Handler handler) {
        ByteArrayOutputStream resultBuilder =
                responseBuilder == null ? new ByteArrayOutputStream() : responseBuilder;
        if (lastResponse.payload != null) {
            try {
                resultBuilder.write(lastResponse.payload);
            } catch (IOException e) {
                // Should never reach here.
            }
        }
        if (lastResponse.sw1 != SW1_MORE_RESPONSE) {
            lastResponse.payload = resultBuilder.toByteArray();
            resultCallback.onResult(lastResponse);
+2 −4
Original line number Diff line number Diff line
@@ -81,13 +81,11 @@ public class RequestBuilder {
        int totalSubCmds = totalLen == 0 ? 1 : (totalLen + mMaxApduDataLen - 1) / mMaxApduDataLen;
        for (int i = 1; i < totalSubCmds; ++i) {
            String data = cmdHex.substring(startPos, startPos + cmdLen);
            addApdu(CLA_STORE_DATA, INS_STORE_DATA, P1_STORE_DATA_INTERM, i - 1, mMaxApduDataLen,
                    data);
            addApdu(CLA_STORE_DATA, INS_STORE_DATA, P1_STORE_DATA_INTERM, i - 1, data);
            startPos += cmdLen;
        }
        String data = cmdHex.substring(startPos);
        addApdu(CLA_STORE_DATA, INS_STORE_DATA, P1_STORE_DATA_END, totalSubCmds - 1,
                totalLen % mMaxApduDataLen, data);
        addApdu(CLA_STORE_DATA, INS_STORE_DATA, P1_STORE_DATA_END, totalSubCmds - 1, data);
    }

    List<ApduCommand> getCommands() {
+7 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.internal.telephony.uicc.euicc.async;

import android.telephony.Rlog;

/**
 * Class to deliver the returned value from an asynchronous call. Either {@link #onResult(Result)}
 * or {@link #onException(Throwable)} will be called. You can create an anonymous subclass and
@@ -38,9 +40,13 @@ package com.android.internal.telephony.uicc.euicc.async;
 */
public abstract class AsyncResultCallback<Result> {

    private static final String LOG_TAG = "AsyncResultCallback";

    /** This will be called when the result is returned. */
    public abstract void onResult(Result result);

    /** This will be called when any exception is thrown. */
    public void onException(Throwable e) {}
    public void onException(Throwable e) {
        Rlog.e(LOG_TAG, "Error in onException", e);
    }
}
+5 −5
Original line number Diff line number Diff line
@@ -274,7 +274,7 @@ public class EuiccCardTest extends TelephonyTest {
                                "com.google.android.apps.myapp", 1)
                },
                profile.getUiccAccessRules().toArray());
        verifyStoreData(channel, "BF2D195A0A896700000000004523015C0B5A909192B79F709599BF76");
        verifyStoreData(channel, "BF2D1BA00C5A0A896700000000004523015C0B5A909192B79F709599BF76");
    }

    @Test
@@ -608,11 +608,11 @@ public class EuiccCardTest extends TelephonyTest {
        assertUnexpectedException(resultCaptor.exception);
        assertEquals("BF3802A000", IccUtils.bytesToHexString(resultCaptor.result));
        verifyStoreData(channel,
                "BF3846" + "A000" + "A100" + "A200" + "A300" + "A03C"
                "BF384B" + "A000" + "A100" + "A200" + "A300" + "A041"
                        + "800D4131423243332D583459355A36" // Matching id
                        + "A12B800489674523" // TAC
                        + "A130800489674523" // TAC
                        // Device capabilities
                        + "A11980030B000081030B0000830303000084030C000085030B0000"
                        + "A11E80030B000081030B00008203010000830303000084030C000085030B0000"
                        + "82088967452301214305"); // IMEI
    }

@@ -927,7 +927,7 @@ public class EuiccCardTest extends TelephonyTest {
        child = node.getChild(Tags.TAG_CTX_1);
        assertTrue(Arrays.equals(new byte[] {11, 0 , 0}, child.asBytes()));

        devCapItem = "cdma_1x,1";
        devCapItem = "cdma1x,1";
        mEuiccCard.addDeviceCapability(devCapsBuilder, devCapItem);
        node = devCapsBuilder.build();

Loading