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

Commit f6c8e58a authored by Muralidhar Reddy Mule's avatar Muralidhar Reddy Mule Committed by Android (Google) Code Review
Browse files

Merge "[MEP] Parse APDU response to handle enabledOnEsimPort value"

parents f46c39a1 f3e46591
Loading
Loading
Loading
Loading
+31 −20
Original line number Diff line number Diff line
@@ -212,6 +212,17 @@ public class EuiccCardController extends IEuiccCardController.Stub {
        return null;
    }

    private EuiccPort getFirstActiveEuiccPort(String cardId) {
        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
            return null;
        }
        if (card.getUiccPortList().length > 0 ) {
            return (EuiccPort) card.getUiccPortList()[0]; // return first active port.
        }
        return null;
    }

    private EuiccPort getEuiccPort(String cardId, int portIdx) {
        EuiccCard card = getEuiccCard(cardId);
        if (card == null) {
@@ -245,7 +256,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND, null);
@@ -294,7 +305,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND, null);
@@ -456,7 +467,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND);
@@ -504,7 +515,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND);
@@ -556,7 +567,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND);
@@ -608,7 +619,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND, null);
@@ -656,7 +667,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND, null);
@@ -704,7 +715,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND);
@@ -752,7 +763,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND, null);
@@ -801,7 +812,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND, null);
@@ -849,7 +860,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND, null);
@@ -897,7 +908,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND, null);
@@ -946,7 +957,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND, null);
@@ -996,7 +1007,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND, null);
@@ -1045,7 +1056,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND, null);
@@ -1097,7 +1108,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND, null);
@@ -1145,7 +1156,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND, null);
@@ -1194,7 +1205,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND, null);
@@ -1243,7 +1254,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND, null);
@@ -1292,7 +1303,7 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            return;
        }

        EuiccPort port = getEuiccPort(cardId, TelephonyManager.DEFAULT_PORT_INDEX);
        EuiccPort port = getFirstActiveEuiccPort(cardId);
        if (port == null) {
            try {
                callback.onComplete(EuiccCardManager.RESULT_EUICC_NOT_FOUND);
+11 −2
Original line number Diff line number Diff line
@@ -1224,8 +1224,17 @@ public class EuiccPort extends UiccPort {
        }

        if (profileNode.hasChild(Tags.TAG_PROFILE_STATE)) {
            // In case of MEP capable eUICC, the profileState value returned SHALL only be Enabled
            // if the Profile is in the Enabled state on the same eSIM Port as where this
            // getProfilesInfo command was sent. So should check for enabledOnEsimPort(TAG_PORT)
            // tag and verify its value is a valid port (means port value is >=0) or not.
            if (profileNode.hasChild(Tags.TAG_PORT)
                    && profileNode.getChild(Tags.TAG_PORT).asInteger() >= 0) {
                profileBuilder.setState(EuiccProfileInfo.PROFILE_STATE_ENABLED);
            } else {
                // noinspection WrongConstant
                profileBuilder.setState(profileNode.getChild(Tags.TAG_PROFILE_STATE).asInteger());
            }
        } else {
            profileBuilder.setState(EuiccProfileInfo.PROFILE_STATE_DISABLED);
        }
+3 −0
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@ class Tags {
    static final int TAG_PROFILE_NAME = 0x92;
    static final int TAG_OPERATOR_ID = 0xB7;
    static final int TAG_CARRIER_PRIVILEGE_RULES = 0xBF76;
    static final int TAG_PORT = 0x9F24;

    // Tags from the RefArDo data standard - https://source.android.com/devices/tech/config/uicc
    static final int TAG_REF_AR_DO = 0xE2;
@@ -106,6 +107,8 @@ class Tags {
            (byte) TAG_PROFILE_POLICY_RULE,
            (byte) (TAG_CARRIER_PRIVILEGE_RULES / 256),
            (byte) (TAG_CARRIER_PRIVILEGE_RULES % 256),
            (byte) (TAG_PORT / 256),
            (byte) (TAG_PORT % 256),
    };

    private Tags() {}
+41 −4
Original line number Diff line number Diff line
@@ -158,7 +158,7 @@ public class EuiccPortTest extends TelephonyTest {
        assertEquals(1, profiles.length);
        assertEquals("98760000000000543210", profiles[0].getIccid());
        assertEquals(EuiccProfileInfo.PROFILE_STATE_ENABLED, profiles[0].getState());
        verifyStoreData(channel, "BF2D0D5C0B5A909192B79F709599BF76");
        verifyStoreData(channel, "BF2D0F5C0D5A909192B79F709599BF769F24");
    }

    @Test
@@ -175,7 +175,43 @@ public class EuiccPortTest extends TelephonyTest {
        assertEquals(1, profiles.length);
        assertEquals("98760000000000543210", profiles[0].getIccid());
        assertEquals(EuiccProfileInfo.PROFILE_STATE_ENABLED, profiles[0].getState());
        verifyStoreData(channel, "BF2D0D5C0B5A909192B79F709599BF76");
        verifyStoreData(channel, "BF2D0F5C0D5A909192B79F709599BF769F24");
    }

    @Test
    public void testEnabledOnEsimPort_GetAllProfiles() {
        int channel = mockLogicalChannelResponses(
                "BF2D18A016E3145A0A896700000000004523019F7001009F2401019000");

        ResultCaptor<EuiccProfileInfo[]> resultCaptor = new ResultCaptor<>();
        mEuiccPort.getAllProfiles(resultCaptor, mHandler);
        processAllMessages();

        assertUnexpectedException(resultCaptor.exception);
        EuiccProfileInfo[] profiles = resultCaptor.result;
        assertEquals(1, profiles.length);
        assertEquals("98760000000000543210", profiles[0].getIccid());
        // Even though profilestate is disabled in the response, enabledOnEsimPort is 1
        // which is valid port. So the state should be enabled.
        // (As per MEP state and enabledOnEsimPort concept)
        assertEquals(EuiccProfileInfo.PROFILE_STATE_ENABLED, profiles[0].getState());
        verifyStoreData(channel, "BF2D0F5C0D5A909192B79F709599BF769F24");
    }

    @Test
    public void testGetAllProfiles_DisableState() {
        // iccID is 987600000000005432FF.
        int channel = mockLogicalChannelResponses(
                "BF2D14A012E3105A0A896700000000004523FF9F7001009000");

        ResultCaptor<EuiccProfileInfo[]> resultCaptor = new ResultCaptor<>();
        mEuiccPort.getAllProfiles(resultCaptor, mHandler);
        processAllMessages();

        EuiccProfileInfo[] profiles = resultCaptor.result;
        assertEquals(1, profiles.length);
        assertEquals(EuiccProfileInfo.PROFILE_STATE_DISABLED, profiles[0].getState());
        verifyStoreData(channel, "BF2D0F5C0D5A909192B79F709599BF769F24");
    }

    @Test
@@ -192,7 +228,7 @@ public class EuiccPortTest extends TelephonyTest {
        assertEquals(1, profiles.length);
        assertEquals("987600000000005432", profiles[0].getIccid());
        assertEquals(EuiccProfileInfo.PROFILE_STATE_ENABLED, profiles[0].getState());
        verifyStoreData(channel, "BF2D0D5C0B5A909192B79F709599BF76");
        verifyStoreData(channel, "BF2D0F5C0D5A909192B79F709599BF769F24");
    }

    @Test
@@ -238,7 +274,8 @@ public class EuiccPortTest extends TelephonyTest {
                                "com.google.android.apps.myapp", 1)
                },
                profile.getUiccAccessRules().toArray());
        verifyStoreData(channel, "BF2D1BA00C5A0A896700000000004523015C0B5A909192B79F709599BF76");
        verifyStoreData(channel,
                "BF2D1DA00C5A0A896700000000004523015C0D5A909192B79F709599BF769F24");
    }

    @Test