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

Commit b1b50337 authored by yinxu's avatar yinxu
Browse files

Check whether eUICC is supported using bit mask

The spec ETSI TS 102 221 defines that if b8 and b2 of the tB are set to
1, eUICC is supported. The value of other bits are not necessarily 0.
So we should check tB using bit mask instead of value.

Bug: 119780944
Test: test on phone
Change-Id: I8e3b9ab979d278d2d29f2f69695b31c1d55db65d
parent 5b7f0fe4
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -38,10 +38,10 @@ public class AnswerToReset {
    private static final boolean VDBG = false; // STOPSHIP if true
    private static final int TAG_CARD_CAPABILITIES = 0x07;
    private static final int EXTENDED_APDU_INDEX = 2;
    private static final int B8_MASK = 0x80;
    private static final int B7_MASK = 0x40;
    private static final int B2_MASK = 0x02;

    public static final byte EUICC_SUPPORTED = (byte) 0x82;
    public static final byte DIRECT_CONVENTION = (byte) 0x3B;
    public static final byte INVERSE_CONVENTION = (byte) 0x3F;
    public static final int INTERFACE_BYTES_MASK = 0xF0;
@@ -148,12 +148,13 @@ public class AnswerToReset {
    }

    private void checkIsEuiccSupported() {
        // eUICC is supported only if the value of the first tB after T=15 is 82.
        // eUICC is supported only if the b8 and b2 of the first tB after T=15 are set to 1.
        for (int i = 0; i < mInterfaceBytes.size() - 1; i++) {
            if (mInterfaceBytes.get(i).getTD() != null
                    && (mInterfaceBytes.get(i).getTD() & T_MASK) == T_VALUE_FOR_GLOBAL_INTERFACE
                    && mInterfaceBytes.get(i + 1).getTB() != null
                    && mInterfaceBytes.get(i + 1).getTB() == EUICC_SUPPORTED) {
                    && (mInterfaceBytes.get(i + 1).getTB() & B8_MASK) != 0
                    && (mInterfaceBytes.get(i + 1).getTB() & B2_MASK) != 0) {
                mIsEuiccSupported = true;
                return;
            }