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

Commit 0c899588 authored by Jack Yu's avatar Jack Yu Committed by Automerger Merge Worker
Browse files

Merge changes Ifb085003,I83d60b4b,Ide483451 am: 65042c69 am: 470cc742

parents 2a067463 470cc742
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.telephony;

import android.annotation.NonNull;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@@ -200,7 +201,13 @@ public class CarrierServiceBindHelper {
        }
    }

    void updateForPhoneId(int phoneId, String simState) {
    /**
     * Update SIM state.
     *
     * @param phoneId The phone id.
     * @param simState The legacy SIM state.
     */
    public void updateForPhoneId(int phoneId, @NonNull String simState) {
        logdWithLocalLog("update binding for phoneId: " + phoneId + " simState: " + simState);
        if (!SubscriptionManager.isValidPhoneId(phoneId)) {
            return;
+143 −1
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import android.telephony.SubscriptionManager.SubscriptionType;
import android.telephony.SubscriptionManager.UsageSetting;
import android.telephony.TelephonyFrameworkInitializer;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager.SimState;
import android.telephony.TelephonyRegistryManager;
import android.telephony.UiccAccessRule;
import android.telephony.euicc.EuiccManager;
@@ -427,6 +428,10 @@ public class SubscriptionManagerService extends ISub.Stub {
                    @Override
                    public void onDatabaseLoaded() {
                        log("Subscription database has been loaded.");
                        for (int phoneId = 0; phoneId < mTelephonyManager.getActiveModemCount()
                                ; phoneId++) {
                            markSubscriptionsInactive(phoneId);
                        }
                    }

                    /**
@@ -826,7 +831,7 @@ public class SubscriptionManagerService extends ISub.Stub {
    /**
     * Mark all subscriptions on this SIM slot index inactive.
     *
     * @param simSlotIndex The SIM slot index.
     * @param simSlotIndex The logical SIM slot index (i.e. phone id).
     */
    public void markSubscriptionsInactive(int simSlotIndex) {
        mSubscriptionDatabaseManager.getAllSubscriptions().stream()
@@ -985,6 +990,15 @@ public class SubscriptionManagerService extends ISub.Stub {
        }
    }

    /**
     * Update the subscriptions on the logical SIM slot index (i.e. phone id).
     *
     * @param slotIndex The logical SIM slot index.
     */
    private void updateSubscriptions(int slotIndex) {

    }

    /**
     * Get all subscription info records from SIMs that are inserted now or previously inserted.
     *
@@ -3174,6 +3188,134 @@ public class SubscriptionManagerService extends ISub.Stub {
                ? subscriptionInfoInternal.toSubscriptionInfo() : null;
    }

    /**
     * Called when SIM state changed to absent.
     *
     * @param slotIndex The logical SIM slot index.
     */
    private void onSimAbsent(int slotIndex) {
        if (mSlotIndexToSubId.containsKey(slotIndex)) {
            // Re-enable the SIM when it's removed, so it will be in enabled state when it gets
            // re-inserted again. (pre-U behavior)
            mSubscriptionDatabaseManager.setUiccApplicationsEnabled(
                    mSlotIndexToSubId.get(slotIndex), true);
            // When sim is absent, set the port index to invalid port index. (pre-U behavior)
            mSubscriptionDatabaseManager.setPortIndex(mSlotIndexToSubId.get(slotIndex),
                    TelephonyManager.INVALID_PORT_INDEX);
        }
        updateSubscriptions(slotIndex);
    }

    /**
     * Called when SIM state changed to locked.
     *
     * @param slotIndex The logical SIM slot index.
     */
    private void onSimLocked(int slotIndex) {

    }

    /**
     * Called when SIM state changed to ready.
     *
     * @param slotIndex The logical SIM slot index.
     */
    private void onSimReady(int slotIndex) {

    }

    /**
     * Called when SIM state changed to not ready.
     *
     * @param slotIndex The logical SIM slot index.
     */
    private void onSimNotReady(int slotIndex) {

    }

    /**
     * Called when SIM encounters error.
     *
     * @param slotIndex The logical SIM slot index.
     */
    private void onSimError(int slotIndex) {

    }

    /**
     * Called when SIM state changed to loaded.
     *
     * @param slotIndex The logical SIM slot index.
     */
    private void onSimLoaded(int slotIndex) {
    }

    /**
     * Called when eSIM becomes inactive.
     *
     * @param slotIndex The logical SIM slot index.
     */
    public void updateSimStateForInactivePort(int slotIndex) {
        mHandler.post(() -> {
            if (mSlotIndexToSubId.containsKey(slotIndex)) {
                // Re-enable the UICC application , so it will be in enabled state when it becomes
                // active again. (pre-U behavior)
                mSubscriptionDatabaseManager.setUiccApplicationsEnabled(
                        mSlotIndexToSubId.get(slotIndex), true);
                updateSubscriptions(slotIndex);
            }
        });
    }

    /**
     * Update SIM state. This method is supposed to be called by {@link UiccController} only.
     *
     * @param slotIndex The logical SIM slot index.
     * @param simState SIM state.
     * @param executor The executor to execute the callback.
     * @param updateCompleteCallback The callback to call when subscription manager service
     * completes subscription update. SIM state changed event will be broadcasted by
     * {@link UiccController} upon receiving callback.
     */
    public void updateSimState(int slotIndex, @SimState int simState,
            @Nullable @CallbackExecutor Executor executor,
            @Nullable Runnable updateCompleteCallback) {
        mHandler.post(() -> {
            switch (simState) {
                case TelephonyManager.SIM_STATE_ABSENT:
                    onSimAbsent(slotIndex);
                    break;
                case TelephonyManager.SIM_STATE_PIN_REQUIRED:
                case TelephonyManager.SIM_STATE_PUK_REQUIRED:
                case TelephonyManager.SIM_STATE_NETWORK_LOCKED:
                case TelephonyManager.SIM_STATE_PERM_DISABLED:
                    onSimLocked(slotIndex);
                    break;
                case TelephonyManager.SIM_STATE_READY:
                    onSimReady(slotIndex);
                    break;
                case TelephonyManager.SIM_STATE_NOT_READY:
                    onSimNotReady(slotIndex);
                    break;
                case TelephonyManager.SIM_STATE_CARD_IO_ERROR:
                    onSimError(slotIndex);
                    break;
                case TelephonyManager.SIM_STATE_CARD_RESTRICTED:
                    // No specific things needed to be done. Just return and broadcast the SIM
                    // states.
                    break;
                case TelephonyManager.SIM_STATE_LOADED:
                    onSimLoaded(slotIndex);
                    break;
                default:
                    break;
            }
            if (executor != null && updateCompleteCallback != null) {
                executor.execute(updateCompleteCallback);
            }
        });
    }

    /**
     * Log debug messages.
     *
+329 −7

File changed.

Preview size limit exceeded, changes collapsed.

+7 −2
Original line number Diff line number Diff line
@@ -801,10 +801,15 @@ public class UiccProfile extends IccCard {
            }
            log("setExternalState: set mPhoneId=" + mPhoneId + " mExternalState=" + mExternalState);

            if (PhoneFactory.isSubscriptionManagerServiceEnabled()) {
                UiccController.getInstance().updateSimState(mPhoneId, mExternalState,
                        getIccStateReason(mExternalState));
            } else {
                UiccController.updateInternalIccState(mContext, mExternalState,
                        getIccStateReason(mExternalState), mPhoneId);
            }
        }
    }

    private void setExternalState(IccCardConstants.State newState) {
        setExternalState(newState, false);
+24 −7
Original line number Diff line number Diff line
@@ -187,9 +187,15 @@ public class UiccSlot extends Handler {
                if (!iss.mSimPortInfos[i].mPortActive) {
                    // TODO: (b/79432584) evaluate whether should broadcast card state change
                    // even if it's inactive.
                    if (PhoneFactory.isSubscriptionManagerServiceEnabled()) {
                        UiccController.getInstance().updateSimStateForInactivePort(
                                mPortIdxToPhoneId.getOrDefault(i, INVALID_PHONE_ID),
                                iss.mSimPortInfos[i].mIccId);
                    } else {
                        UiccController.updateInternalIccStateForInactivePort(mContext,
                                mPortIdxToPhoneId.getOrDefault(i, INVALID_PHONE_ID),
                                iss.mSimPortInfos[i].mIccId);
                    }
                    mLastRadioState.put(i, TelephonyManager.RADIO_POWER_UNAVAILABLE);
                    if (mUiccCard != null) {
                        // Dispose the port
@@ -321,8 +327,14 @@ public class UiccSlot extends Handler {
            if (DBG) log("update: notify card removed");
            sendMessage(obtainMessage(EVENT_CARD_REMOVED, null));
        }

        if (PhoneFactory.isSubscriptionManagerServiceEnabled()) {
            UiccController.getInstance().updateSimState(phoneId, IccCardConstants.State.ABSENT,
                    null);
        } else {
            UiccController.updateInternalIccState(mContext, IccCardConstants.State.ABSENT,
                    null, phoneId);
        }
        // no card present in the slot now; dispose card and make mUiccCard null
        nullifyUiccCard(false /* sim state is not unknown */);
        mLastRadioState.put(portIndex, TelephonyManager.RADIO_POWER_UNAVAILABLE);
@@ -575,8 +587,13 @@ public class UiccSlot extends Handler {
        nullifyUiccCard(true /* sim state is unknown */);

        if (phoneId != INVALID_PHONE_ID) {
            if (PhoneFactory.isSubscriptionManagerServiceEnabled()) {
                UiccController.getInstance().updateSimState(phoneId,
                        IccCardConstants.State.UNKNOWN, null);
            } else {
                UiccController.updateInternalIccState(
                        mContext, IccCardConstants.State.UNKNOWN, null, phoneId);
            }
            mLastRadioState.put(getPortIndexFromPhoneId(phoneId),
                    TelephonyManager.RADIO_POWER_UNAVAILABLE);
        }