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

Commit e79f4561 authored by Jiuyu Sun's avatar Jiuyu Sun
Browse files

Revert "Public EuiccManager APIs."

This reverts commit 4d59805c.

Reason for revert: <INSERT REASONING HERE>

Change-Id: I18af805c5678c14af9926010b5cd7f3e100cad97
parent 4d59805c
Loading
Loading
Loading
Loading
+11 −21
Original line number Diff line number Diff line
@@ -710,25 +710,20 @@ public class SubscriptionInfoUpdater extends Handler {
        }

        final EuiccProfileInfo[] embeddedProfiles;
        if (result.getResult() == EuiccService.RESULT_OK) {
            List<EuiccProfileInfo> list = result.getProfiles();
            if (list == null || list.size() == 0) {
                embeddedProfiles = null;
        if (result.result == EuiccService.RESULT_OK) {
            embeddedProfiles = result.profiles;
        } else {
                embeddedProfiles = list.toArray(new EuiccProfileInfo[list.size()]);
            }
        } else {
            logd("updatedEmbeddedSubscriptions: error " + result.getResult() + " listing profiles");
            logd("updatedEmbeddedSubscriptions: error " + result.result + " listing profiles");
            // If there's an error listing profiles, treat it equivalently to a successful
            // listing which returned no profiles under the assumption that none are currently
            // accessible.
            embeddedProfiles = new EuiccProfileInfo[0];
        }
        final boolean isRemovable = result.getIsRemovable();
        final boolean isRemovable = result.isRemovable;

        final String[] embeddedIccids = new String[embeddedProfiles.length];
        for (int i = 0; i < embeddedProfiles.length; i++) {
            embeddedIccids[i] = embeddedProfiles[i].getIccid();
            embeddedIccids[i] = embeddedProfiles[i].iccid;
        }

        // Note that this only tracks whether we make any writes to the DB. It's possible this will
@@ -746,30 +741,25 @@ public class SubscriptionInfoUpdater extends Handler {
        ContentResolver contentResolver = mContext.getContentResolver();
        for (EuiccProfileInfo embeddedProfile : embeddedProfiles) {
            int index =
                    findSubscriptionInfoForIccid(existingSubscriptions, embeddedProfile.getIccid());
                    findSubscriptionInfoForIccid(existingSubscriptions, embeddedProfile.iccid);
            if (index < 0) {
                // No existing entry for this ICCID; create an empty one.
                SubscriptionController.getInstance().insertEmptySubInfoRecord(
                        embeddedProfile.getIccid(), SubscriptionManager.SIM_NOT_INSERTED);
                        embeddedProfile.iccid, SubscriptionManager.SIM_NOT_INSERTED);
            } else {
                existingSubscriptions.remove(index);
            }
            ContentValues values = new ContentValues();
            values.put(SubscriptionManager.IS_EMBEDDED, 1);
            List<UiccAccessRule> ruleList = embeddedProfile.getUiccAccessRules();
            boolean isRuleListEmpty = false;
            if (ruleList == null || ruleList.size() == 0) {
                isRuleListEmpty = true;
            }
            values.put(SubscriptionManager.ACCESS_RULES,
                    isRuleListEmpty ? null : UiccAccessRule.encodeRules(
                            ruleList.toArray(new UiccAccessRule[ruleList.size()])));
                    embeddedProfile.accessRules == null ? null :
                            UiccAccessRule.encodeRules(embeddedProfile.accessRules));
            values.put(SubscriptionManager.IS_REMOVABLE, isRemovable);
            values.put(SubscriptionManager.DISPLAY_NAME, embeddedProfile.getNickname());
            values.put(SubscriptionManager.DISPLAY_NAME, embeddedProfile.nickname);
            values.put(SubscriptionManager.NAME_SOURCE, SubscriptionManager.NAME_SOURCE_USER_INPUT);
            hasChanges = true;
            contentResolver.update(SubscriptionManager.CONTENT_URI, values,
                    SubscriptionManager.ICC_ID + "=\"" + embeddedProfile.getIccid() + "\"", null);
                    SubscriptionManager.ICC_ID + "=\"" + embeddedProfile.iccid + "\"", null);

            // refresh Cached Active Subscription Info List
            SubscriptionController.getInstance().refreshCachedActiveSubscriptionInfoList();
+14 −23
Original line number Diff line number Diff line
@@ -259,12 +259,12 @@ public class EuiccController extends IEuiccController.Stub {
                GetDownloadableSubscriptionMetadataResult result) {
            Intent extrasIntent = new Intent();
            final int resultCode;
            switch (result.getResult()) {
            switch (result.result) {
                case EuiccService.RESULT_OK:
                    resultCode = OK;
                    extrasIntent.putExtra(
                            EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_DOWNLOADABLE_SUBSCRIPTION,
                            result.getDownloadableSubscription());
                            result.subscription);
                    break;
                case EuiccService.RESULT_MUST_DEACTIVATE_SIM:
                    resultCode = RESOLVABLE_ERROR;
@@ -278,7 +278,7 @@ public class EuiccController extends IEuiccController.Stub {
                    resultCode = ERROR;
                    extrasIntent.putExtra(
                            EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE,
                            result.getResult());
                            result.result);
                    break;
            }

@@ -346,7 +346,7 @@ public class EuiccController extends IEuiccController.Stub {
        @Override
        public void onGetMetadataComplete(
                GetDownloadableSubscriptionMetadataResult result) {
            if (result.getResult() == EuiccService.RESULT_MUST_DEACTIVATE_SIM) {
            if (result.result == EuiccService.RESULT_MUST_DEACTIVATE_SIM) {
                // If we need to deactivate the current SIM to even check permissions, go ahead and
                // require that the user resolve the stronger permission dialog.
                Intent extrasIntent = new Intent();
@@ -360,18 +360,14 @@ public class EuiccController extends IEuiccController.Stub {
                return;
            }

            if (result.getResult() != EuiccService.RESULT_OK) {
            if (result.result != EuiccService.RESULT_OK) {
                // Just propagate the error as normal.
                super.onGetMetadataComplete(result);
                return;
            }

            DownloadableSubscription subscription = result.getDownloadableSubscription();
            UiccAccessRule[] rules = null;
            List<UiccAccessRule> rulesList = subscription.getAccessRules();
            if (rulesList != null) {
                rules = rulesList.toArray(new UiccAccessRule[rulesList.size()]);
            }
            DownloadableSubscription subscription = result.subscription;
            UiccAccessRule[] rules = subscription.getAccessRules();
            if (rules == null) {
                Log.e(TAG, "No access rules but caller is unprivileged");
                sendResult(mCallbackIntent, ERROR, null /* extrasIntent */);
@@ -566,15 +562,12 @@ public class EuiccController extends IEuiccController.Stub {
        public void onGetDefaultListComplete(GetDefaultDownloadableSubscriptionListResult result) {
            Intent extrasIntent = new Intent();
            final int resultCode;
            switch (result.getResult()) {
            switch (result.result) {
                case EuiccService.RESULT_OK:
                    resultCode = OK;
                    List<DownloadableSubscription> list = result.getDownloadableSubscriptions();
                    if (list != null && list.size() > 0) {
                    extrasIntent.putExtra(
                            EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_DOWNLOADABLE_SUBSCRIPTIONS,
                                list.toArray(new DownloadableSubscription[list.size()]));
                    }
                            result.subscriptions);
                    break;
                case EuiccService.RESULT_MUST_DEACTIVATE_SIM:
                    resultCode = RESOLVABLE_ERROR;
@@ -589,7 +582,7 @@ public class EuiccController extends IEuiccController.Stub {
                    resultCode = ERROR;
                    extrasIntent.putExtra(
                            EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE,
                            result.getResult());
                            result.result);
                    break;
            }

@@ -718,7 +711,7 @@ public class EuiccController extends IEuiccController.Stub {
                    return;
                }
                if (!callerCanWriteEmbeddedSubscriptions
                        && !mSubscriptionManager.canManageSubscription(sub, callingPackage)) {
                        && !sub.canManageSubscription(mContext, callingPackage)) {
                    Log.e(TAG, "Not permitted to switch to subscription: " + subscriptionId);
                    sendResult(callbackIntent, ERROR, null /* extrasIntent */);
                    return;
@@ -1070,9 +1063,7 @@ public class EuiccController extends IEuiccController.Stub {
        int size = subInfoList.size();
        for (int subIndex = 0; subIndex < size; subIndex++) {
            SubscriptionInfo subInfo = subInfoList.get(subIndex);

            if (subInfo.isEmbedded()
                    && mSubscriptionManager.canManageSubscription(subInfo, callingPackage)) {
            if (subInfo.isEmbedded() && subInfo.canManageSubscription(mContext, callingPackage)) {
                return true;
            }
        }
+7 −7
Original line number Diff line number Diff line
@@ -207,37 +207,37 @@ public class EuiccOperation implements Parcelable {
        switch (mAction) {
            case ACTION_GET_METADATA_DEACTIVATE_SIM:
                resolvedGetMetadataDeactivateSim(
                        resolutionExtras.getBoolean(EuiccService.EXTRA_RESOLUTION_CONSENT),
                        resolutionExtras.getBoolean(EuiccService.RESOLUTION_EXTRA_CONSENT),
                        callbackIntent);
                break;
            case ACTION_DOWNLOAD_DEACTIVATE_SIM:
                resolvedDownloadDeactivateSim(
                        resolutionExtras.getBoolean(EuiccService.EXTRA_RESOLUTION_CONSENT),
                        resolutionExtras.getBoolean(EuiccService.RESOLUTION_EXTRA_CONSENT),
                        callbackIntent);
                break;
            case ACTION_DOWNLOAD_NO_PRIVILEGES:
                resolvedDownloadNoPrivileges(
                        resolutionExtras.getBoolean(EuiccService.EXTRA_RESOLUTION_CONSENT),
                        resolutionExtras.getBoolean(EuiccService.RESOLUTION_EXTRA_CONSENT),
                        callbackIntent);
                break;
            case ACTION_DOWNLOAD_CONFIRMATION_CODE:
                resolvedDownloadConfirmationCode(
                        resolutionExtras.getString(EuiccService.EXTRA_RESOLUTION_CONFIRMATION_CODE),
                        resolutionExtras.getString(EuiccService.RESOLUTION_EXTRA_CONFIRMATION_CODE),
                        callbackIntent);
                break;
            case ACTION_GET_DEFAULT_LIST_DEACTIVATE_SIM:
                resolvedGetDefaultListDeactivateSim(
                        resolutionExtras.getBoolean(EuiccService.EXTRA_RESOLUTION_CONSENT),
                        resolutionExtras.getBoolean(EuiccService.RESOLUTION_EXTRA_CONSENT),
                        callbackIntent);
                break;
            case ACTION_SWITCH_DEACTIVATE_SIM:
                resolvedSwitchDeactivateSim(
                        resolutionExtras.getBoolean(EuiccService.EXTRA_RESOLUTION_CONSENT),
                        resolutionExtras.getBoolean(EuiccService.RESOLUTION_EXTRA_CONSENT),
                        callbackIntent);
                break;
            case ACTION_SWITCH_NO_PRIVILEGES:
                resolvedSwitchNoPrivileges(
                        resolutionExtras.getBoolean(EuiccService.EXTRA_RESOLUTION_CONSENT),
                        resolutionExtras.getBoolean(EuiccService.RESOLUTION_EXTRA_CONSENT),
                        callbackIntent);
                break;
            default:
+8 −16
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ import com.android.internal.telephony.uicc.euicc.apdu.RequestProvider;
import com.android.internal.telephony.uicc.euicc.async.AsyncResultCallback;
import com.android.internal.telephony.uicc.euicc.async.AsyncResultHelper;

import java.util.Arrays;
import java.util.List;

/**
@@ -146,10 +145,7 @@ public class EuiccCard extends UiccCard {
                            loge("Profile must have an ICCID.");
                            continue;
                        }
                        String strippedIccIdString =
                                stripTrailingFs(profileNode.getChild(Tags.TAG_ICCID).asBytes());
                        EuiccProfileInfo.Builder profileBuilder =
                                new EuiccProfileInfo.Builder(strippedIccIdString);
                        EuiccProfileInfo.Builder profileBuilder = new EuiccProfileInfo.Builder();
                        buildProfile(profileNode, profileBuilder);

                        EuiccProfileInfo profile = profileBuilder.build();
@@ -182,10 +178,7 @@ public class EuiccCard extends UiccCard {
                        return null;
                    }
                    Asn1Node profileNode = profileNodes.get(0);
                    String strippedIccIdString =
                            stripTrailingFs(profileNode.getChild(Tags.TAG_ICCID).asBytes());
                    EuiccProfileInfo.Builder profileBuilder =
                            new EuiccProfileInfo.Builder(strippedIccIdString);
                    EuiccProfileInfo.Builder profileBuilder = new EuiccProfileInfo.Builder();
                    buildProfile(profileNode, profileBuilder);
                    return profileBuilder.build();
                },
@@ -466,7 +459,7 @@ public class EuiccCard extends UiccCard {
                        for (int j = 0; j < opIdSize; j++) {
                            opIds[j] = buildCarrierIdentifier(opIdNodes.get(j));
                        }
                        builder.add(node.getChild(Tags.TAG_CTX_0).asBits(), Arrays.asList(opIds),
                        builder.add(node.getChild(Tags.TAG_CTX_0).asBits(), opIds,
                                node.getChild(Tags.TAG_CTX_2).asBits());
                    }
                    return builder.build();
@@ -931,6 +924,10 @@ public class EuiccCard extends UiccCard {

    private static void buildProfile(Asn1Node profileNode, EuiccProfileInfo.Builder profileBuilder)
            throws TagNotFoundException, InvalidAsn1DataException {
        String strippedIccIdString =
                stripTrailingFs(profileNode.getChild(Tags.TAG_ICCID).asBytes());
        profileBuilder.setIccid(strippedIccIdString);

        if (profileNode.hasChild(Tags.TAG_NICKNAME)) {
            profileBuilder.setNickname(profileNode.getChild(Tags.TAG_NICKNAME).asString());
        }
@@ -974,12 +971,7 @@ public class EuiccCard extends UiccCard {
        if (profileNode.hasChild(Tags.TAG_CARRIER_PRIVILEGE_RULES)) {
            List<Asn1Node> refArDoNodes = profileNode.getChild(Tags.TAG_CARRIER_PRIVILEGE_RULES)
                    .getChildren(Tags.TAG_REF_AR_DO);
            UiccAccessRule[] rules = buildUiccAccessRule(refArDoNodes);
            List<UiccAccessRule> rulesList = null;
            if (rules != null) {
                rulesList = Arrays.asList(rules);
            }
            profileBuilder.setUiccAccessRule(rulesList);
            profileBuilder.setUiccAccessRule(buildUiccAccessRule(refArDoNodes));
        }
    }

+2 −8
Original line number Diff line number Diff line
@@ -73,7 +73,6 @@ import org.mockito.stubbing.Stubber;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.Collections;

@RunWith(AndroidJUnit4.class)
@@ -101,8 +100,7 @@ public class EuiccControllerTest extends TelephonyTest {
            DownloadableSubscription.forActivationCode("abcde");
    static {
        SUBSCRIPTION_WITH_METADATA.setCarrierName("test name");
        SUBSCRIPTION_WITH_METADATA.setAccessRules(
                Arrays.asList(new UiccAccessRule[] { ACCESS_RULE }));
        SUBSCRIPTION_WITH_METADATA.setAccessRules(new UiccAccessRule[] { ACCESS_RULE });
    }

    private static final String OS_VERSION = "1.0";
@@ -266,7 +264,7 @@ public class EuiccControllerTest extends TelephonyTest {

    @Test
    public void testGetEuiccInfo_success() {
        assertEquals(OS_VERSION, callGetEuiccInfo(true /* success */, EUICC_INFO).getOsVersion());
        assertEquals(OS_VERSION, callGetEuiccInfo(true /* success */, EUICC_INFO).osVersion);
    }

    @Test
@@ -839,8 +837,6 @@ public class EuiccControllerTest extends TelephonyTest {
        SubscriptionInfo subInfo = new SubscriptionInfo(
                0, "", 0, "", "", 0, 0, "", 0, null, 0, 0, "", true /* isEmbedded */,
                hasPrivileges ? new UiccAccessRule[] { ACCESS_RULE } : null);
        when(mSubscriptionManager.canManageSubscription(subInfo, PACKAGE_NAME)).thenReturn(
                hasPrivileges);
        when(mSubscriptionManager.getActiveSubscriptionInfoList()).thenReturn(
                Collections.singletonList(subInfo));
    }
@@ -849,8 +845,6 @@ public class EuiccControllerTest extends TelephonyTest {
        SubscriptionInfo subInfo = new SubscriptionInfo(
                SUBSCRIPTION_ID, ICC_ID, 0, "", "", 0, 0, "", 0, null, 0, 0, "",
                true /* isEmbedded */, hasPrivileges ? new UiccAccessRule[] { ACCESS_RULE } : null);
        when(mSubscriptionManager.canManageSubscription(subInfo, PACKAGE_NAME)).thenReturn(
                hasPrivileges);
        when(mSubscriptionManager.getAvailableSubscriptionInfoList()).thenReturn(
                Collections.singletonList(subInfo));
    }
Loading