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

Commit 65042c69 authored by Jack Yu's avatar Jack Yu Committed by Gerrit Code Review
Browse files

Merge changes Ifb085003,I83d60b4b,Ide483451

* changes:
  Moved SIM state broadcast back to UiccController
  Skip retry delay for handover not allowed by policy
  Fix to set transportType when creating DataServiceManager.
parents 2910df87 0db34569
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;
+17 −4
Original line number Diff line number Diff line
@@ -264,8 +264,9 @@ public class DataNetwork extends StateMachine {
    private static final int DEFAULT_INTERNET_NETWORK_SCORE = 50;
    private static final int OTHER_NETWORK_SCORE = 45;

    @IntDef(prefix = {"DEACTIVATION_REASON_"},
    @IntDef(prefix = {"TEAR_DOWN_REASON_"},
            value = {
                    TEAR_DOWN_REASON_NONE,
                    TEAR_DOWN_REASON_CONNECTIVITY_SERVICE_UNWANTED,
                    TEAR_DOWN_REASON_SIM_REMOVAL,
                    TEAR_DOWN_REASON_AIRPLANE_MODE_ON,
@@ -298,6 +299,9 @@ public class DataNetwork extends StateMachine {
            })
    public @interface TearDownReason {}

    /** Data network was not torn down. */
    public static final int TEAR_DOWN_REASON_NONE = 0;

    /** Data network tear down requested by connectivity service. */
    public static final int TEAR_DOWN_REASON_CONNECTIVITY_SERVICE_UNWANTED = 1;

@@ -375,7 +379,7 @@ public class DataNetwork extends StateMachine {
    /** Data network tear down due to data profile not preferred. */
    public static final int TEAR_DOWN_REASON_DATA_PROFILE_NOT_PREFERRED = 26;

    /** Data network tear down due to not allowed by policy. */
    /** Data network tear down due to handover not allowed by policy. */
    public static final int TEAR_DOWN_REASON_NOT_ALLOWED_BY_POLICY = 27;

    /** Data network tear down due to illegal state. */
@@ -623,6 +627,11 @@ public class DataNetwork extends StateMachine {
     */
    private @DataFailureCause int mFailCause = DataFailCause.NONE;

    /**
     * The tear down reason if the data call is voluntarily deactivated, not due to failure.
     */
    private @TearDownReason int mTearDownReason = TEAR_DOWN_REASON_NONE;

    /**
     * The retry delay in milliseconds from setup data failure.
     */
@@ -783,9 +792,10 @@ public class DataNetwork extends StateMachine {
         *
         * @param dataNetwork The data network.
         * @param cause The disconnect cause.
         * @param tearDownReason The reason the network was torn down
         */
        public abstract void onDisconnected(@NonNull DataNetwork dataNetwork,
                @DataFailureCause int cause);
                @DataFailureCause int cause, @TearDownReason int tearDownReason);

        /**
         * Called when handover between IWLAN and cellular network succeeded.
@@ -1562,7 +1572,7 @@ public class DataNetwork extends StateMachine {

            if (mEverConnected) {
                mDataNetworkCallback.invokeFromExecutor(() -> mDataNetworkCallback
                        .onDisconnected(DataNetwork.this, mFailCause));
                        .onDisconnected(DataNetwork.this, mFailCause, mTearDownReason));
                if (mTransport == AccessNetworkConstants.TRANSPORT_TYPE_WWAN) {
                    unregisterForWwanEvents();
                }
@@ -2530,6 +2540,7 @@ public class DataNetwork extends StateMachine {
        if (getCurrentState() == null || isDisconnected()) {
            return;
        }
        mTearDownReason = reason;
        sendMessage(obtainMessage(EVENT_TEAR_DOWN_NETWORK, reason));
    }

@@ -3355,6 +3366,8 @@ public class DataNetwork extends StateMachine {
     */
    public static @NonNull String tearDownReasonToString(@TearDownReason int reason) {
        switch (reason) {
            case TEAR_DOWN_REASON_NONE:
                return "NONE";
            case TEAR_DOWN_REASON_CONNECTIVITY_SERVICE_UNWANTED:
                return "CONNECTIVITY_SERVICE_UNWANTED";
            case TEAR_DOWN_REASON_SIM_REMOVAL:
+13 −10
Original line number Diff line number Diff line
@@ -780,8 +780,7 @@ public class DataNetworkController extends Handler {

        mAccessNetworksManager = phone.getAccessNetworksManager();
        for (int transport : mAccessNetworksManager.getAvailableTransports()) {
            mDataServiceManagers.put(transport, new DataServiceManager(mPhone, looper,
                    AccessNetworkConstants.TRANSPORT_TYPE_WWAN));
            mDataServiceManagers.put(transport, new DataServiceManager(mPhone, looper, transport));
        }

        mDataConfigManager = new DataConfigManager(mPhone, looper);
@@ -1851,7 +1850,7 @@ public class DataNetworkController extends Handler {
            }
        }

        log("Evaluated " + dataNetwork + ", " + evaluation.toString());
        log("Evaluated " + dataNetwork + ", " + evaluation);
        return evaluation;
    }

@@ -2045,7 +2044,7 @@ public class DataNetworkController extends Handler {
                    return DataNetwork.TEAR_DOWN_REASON_ONLY_ALLOWED_SINGLE_NETWORK;
            }
        }
        return 0;
        return DataNetwork.TEAR_DOWN_REASON_NONE;
    }

    /**
@@ -2487,9 +2486,9 @@ public class DataNetworkController extends Handler {

                    @Override
                    public void onDisconnected(@NonNull DataNetwork dataNetwork,
                            @DataFailureCause int cause) {
                            @DataFailureCause int cause, @TearDownReason int tearDownReason) {
                        DataNetworkController.this.onDataNetworkDisconnected(
                                dataNetwork, cause);
                                dataNetwork, cause, tearDownReason);
                    }

                    @Override
@@ -2811,11 +2810,13 @@ public class DataNetworkController extends Handler {
     *
     * @param dataNetwork The data network.
     * @param cause The disconnect cause.
     * @param tearDownReason The reason the network was torn down
     */
    private void onDataNetworkDisconnected(@NonNull DataNetwork dataNetwork,
            @DataFailureCause int cause) {
            @DataFailureCause int cause, @TearDownReason int tearDownReason) {
        logl("onDataNetworkDisconnected: " + dataNetwork + ", cause="
                + DataFailCause.toString(cause) + "(" + cause + ")");
                + DataFailCause.toString(cause) + "(" + cause + "), tearDownReason="
                + DataNetwork.tearDownReasonToString(tearDownReason));
        mDataNetworkList.remove(dataNetwork);
        mPendingImsDeregDataNetworks.remove(dataNetwork);
        mDataRetryManager.cancelPendingHandoverRetry(dataNetwork);
@@ -2836,11 +2837,13 @@ public class DataNetworkController extends Handler {
                    () -> callback.onAnyDataNetworkExistingChanged(mAnyDataNetworkExisting)));
        }

        // Immediately reestablish on target transport if network was torn down due to policy
        long delayMillis = tearDownReason == DataNetwork.TEAR_DOWN_REASON_HANDOVER_NOT_ALLOWED
                ? 0 : mDataConfigManager.getRetrySetupAfterDisconnectMillis();
        // Sometimes network was unsolicitedly reported lost for reasons. We should re-evaluate
        // and see if data network can be re-established again.
        sendMessageDelayed(obtainMessage(EVENT_REEVALUATE_UNSATISFIED_NETWORK_REQUESTS,
                DataEvaluationReason.RETRY_AFTER_DISCONNECTED),
                mDataConfigManager.getRetrySetupAfterDisconnectMillis());
                        DataEvaluationReason.RETRY_AFTER_DISCONNECTED), delayMillis);
    }

    /**
+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.

Loading