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

Commit 269797b0 authored by Pengquan Meng's avatar Pengquan Meng
Browse files

Add cardid to requestEmbeddedSubscriptionInfoListRrefresh

Bug: 112902036
Test: atest FrameworksTelephonysTests
Change-Id: I05b5248a80dd0375a0874cf027f5423116aef1ca
parent 8e06591f
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -386,11 +386,13 @@ public class PhoneFactory {
    /**
     * Request a refresh of the embedded subscription list.
     *
     * @param cardId the card ID of the eUICC.
     * @param callback Optional callback to execute after the refresh completes. Must terminate
     *     quickly as it will be called from SubscriptionInfoUpdater's handler thread.
     */
    public static void requestEmbeddedSubscriptionInfoListRefresh(@Nullable Runnable callback) {
        sSubInfoRecordUpdater.requestEmbeddedSubscriptionInfoListRefresh(callback);
    public static void requestEmbeddedSubscriptionInfoListRefresh(
            int cardId, @Nullable Runnable callback) {
        sSubInfoRecordUpdater.requestEmbeddedSubscriptionInfoListRefresh(cardId, callback);
    }

    /**
+19 −4
Original line number Diff line number Diff line
@@ -849,26 +849,41 @@ public class SubscriptionController extends ISub.Stub {
    }

    @Override
    public void requestEmbeddedSubscriptionInfoListRefresh() {
    public void requestEmbeddedSubscriptionInfoListRefresh(int cardId) {
        mContext.enforceCallingOrSelfPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS,
                "requestEmbeddedSubscriptionInfoListRefresh");
        long token = Binder.clearCallingIdentity();
        try {
            PhoneFactory.requestEmbeddedSubscriptionInfoListRefresh(null /* callback */);
            PhoneFactory.requestEmbeddedSubscriptionInfoListRefresh(cardId, null /* callback */);
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }

    /**
     * Asynchronously refresh the embedded subscription info list.
     * Asynchronously refresh the embedded subscription info list for the embedded card has the
     * given card id {@code cardId}.
     *
     * @param callback Optional callback to execute after the refresh completes. Must terminate
     *     quickly as it will be called from SubscriptionInfoUpdater's handler thread.
     */
    // No permission check needed as this is not exposed via AIDL.
    public void requestEmbeddedSubscriptionInfoListRefresh(
            int cardId, @Nullable Runnable callback) {
        PhoneFactory.requestEmbeddedSubscriptionInfoListRefresh(cardId, callback);
    }

    /**
     * Asynchronously refresh the embedded subscription info list for the embedded card has the
     * default card id return by {@link TelephonyManager#getCardIdForDefaultEuicc()}.
     *
     * @param callback Optional callback to execute after the refresh completes. Must terminate
     *     quickly as it will be called from SubscriptionInfoUpdater's handler thread.
     */
    // No permission check needed as this is not exposed via AIDL.
    public void requestEmbeddedSubscriptionInfoListRefresh(@Nullable Runnable callback) {
        PhoneFactory.requestEmbeddedSubscriptionInfoListRefresh(callback);
        PhoneFactory.requestEmbeddedSubscriptionInfoListRefresh(
                mTelephonyManager.getCardIdForDefaultEuicc(), callback);
    }

    /**
+19 −7
Original line number Diff line number Diff line
@@ -53,11 +53,13 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.euicc.EuiccController;
import com.android.internal.telephony.uicc.IccRecords;
import com.android.internal.telephony.uicc.IccUtils;
import com.android.internal.telephony.uicc.UiccController;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 *@hide
@@ -282,7 +284,7 @@ public class SubscriptionInfoUpdater extends Handler {
                // intentional fall through

            case EVENT_REFRESH_EMBEDDED_SUBSCRIPTIONS:
                if (updateEmbeddedSubscriptions()) {
                if (updateEmbeddedSubscriptions(msg.arg1)) {
                    SubscriptionController.getInstance().notifySubscriptionInfoChanged();
                }
                if (msg.obj != null) {
@@ -295,8 +297,9 @@ public class SubscriptionInfoUpdater extends Handler {
        }
    }

    void requestEmbeddedSubscriptionInfoListRefresh(@Nullable Runnable callback) {
        sendMessage(obtainMessage(EVENT_REFRESH_EMBEDDED_SUBSCRIPTIONS, callback));
    void requestEmbeddedSubscriptionInfoListRefresh(int cardId, @Nullable Runnable callback) {
        sendMessage(obtainMessage(
                EVENT_REFRESH_EMBEDDED_SUBSCRIPTIONS, cardId, 0 /* arg2 */, callback));
    }

    private void handleSimLocked(int slotId, String reason) {
@@ -690,21 +693,30 @@ public class SubscriptionInfoUpdater extends Handler {
                mSubscriptionManager.getDefaultDataSubscriptionId());

        // No need to check return value here as we notify for the above changes anyway.
        updateEmbeddedSubscriptions();
        if (subInfos != null) {
            UiccController uiccController = UiccController.getInstance();
            subInfos.stream()
                    .filter(subInfo -> subInfo.isEmbedded())
                    .mapToInt(subInfo -> uiccController.convertToPublicCardId(subInfo.getCardId()))
                    .mapToObj(cardId -> cardId)
                    .collect(Collectors.toSet())
                    .forEach(cardId -> updateEmbeddedSubscriptions(cardId));
        }

        SubscriptionController.getInstance().notifySubscriptionInfoChanged();
        logd("updateSubscriptionInfoByIccId:- SubscriptionInfo update complete");
    }

    /**
     * Update the cached list of embedded subscriptions.
     * Update the cached list of embedded subscription for the eUICC with the given card ID
     * {@code cardId}.
     *
     * @return true if changes may have been made. This is not a guarantee that changes were made,
     * but notifications about subscription changes may be skipped if this returns false as an
     * optimization to avoid spurious notifications.
     */
    @VisibleForTesting(visibility = VisibleForTesting.Visibility.PRIVATE)
    public boolean updateEmbeddedSubscriptions() {
    public boolean updateEmbeddedSubscriptions(int cardId) {
        if (DBG) logd("updateEmbeddedSubscriptions");
        // Do nothing if eUICCs are disabled. (Previous entries may remain in the cache, but they
        // are filtered out of list calls as long as EuiccManager.isEnabled returns false).
@@ -713,7 +725,7 @@ public class SubscriptionInfoUpdater extends Handler {
        }

        GetEuiccProfileInfoListResult result =
                EuiccController.get().blockingGetEuiccProfileInfoList();
                EuiccController.get().blockingGetEuiccProfileInfoList(cardId);
        if (result == null) {
            // IPC to the eUICC controller failed.
            return false;
+9 −3
Original line number Diff line number Diff line
@@ -478,7 +478,9 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            @Override
            public void onResult(Void result) {
                Log.i(TAG, "Request subscription info list refresh after delete.");
                SubscriptionController.getInstance().requestEmbeddedSubscriptionInfoListRefresh();
                SubscriptionController.getInstance()
                        .requestEmbeddedSubscriptionInfoListRefresh(
                                mUiccController.convertToPublicCardId(cardId));
                try {
                    callback.onComplete(EuiccCardManager.RESULT_OK);
                } catch (RemoteException exception) {
@@ -528,7 +530,9 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            @Override
            public void onResult(Void result) {
                Log.i(TAG, "Request subscription info list refresh after reset memory.");
                SubscriptionController.getInstance().requestEmbeddedSubscriptionInfoListRefresh();
                SubscriptionController.getInstance()
                        .requestEmbeddedSubscriptionInfoListRefresh(
                                mUiccController.convertToPublicCardId(cardId));
                try {
                    callback.onComplete(EuiccCardManager.RESULT_OK);
                } catch (RemoteException exception) {
@@ -1015,7 +1019,9 @@ public class EuiccCardController extends IEuiccCardController.Stub {
            @Override
            public void onResult(byte[] result) {
                Log.i(TAG, "Request subscription info list refresh after install.");
                SubscriptionController.getInstance().requestEmbeddedSubscriptionInfoListRefresh();
                SubscriptionController.getInstance()
                        .requestEmbeddedSubscriptionInfoListRefresh(
                                mUiccController.convertToPublicCardId(cardId));
                try {
                    callback.onComplete(EuiccCardManager.RESULT_OK, result);
                } catch (RemoteException exception) {
+2 −2
Original line number Diff line number Diff line
@@ -432,8 +432,8 @@ public class EuiccConnector extends StateMachine implements ServiceConnection {
        sendMessage(CMD_DOWNLOAD_SUBSCRIPTION, request);
    }

    void getEuiccProfileInfoList(GetEuiccProfileInfoListCommandCallback callback) {
        sendMessage(CMD_GET_EUICC_PROFILE_INFO_LIST, callback);
    void getEuiccProfileInfoList(int cardId, GetEuiccProfileInfoListCommandCallback callback) {
        sendMessage(CMD_GET_EUICC_PROFILE_INFO_LIST, cardId, 0 /* arg2 */, callback);
    }

    /** Asynchronously fetch the default downloadable subscription list. */
Loading