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

Commit 56600e97 authored by Jack Yu's avatar Jack Yu Committed by Automerger Merge Worker
Browse files

Merge "Added more conditions for setup and tear down." am: e13a752c am: 957b998c

Original change: https://android-review.googlesource.com/c/platform/frameworks/opt/telephony/+/2007474

Change-Id: I4007fb4450d755c3f17979afd5ddcaa3e10d8ead
parents 676163ff 957b998c
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -238,6 +238,15 @@ public class DataConfigManager extends Handler {
        return mResources.getInteger(R.integer.config_delay_for_ims_dereg_millis);
    }

    /**
     * @return {@code true} if PDN should persist when IWLAN data service restarted/crashed.
     * {@code false} will cause all data networks on IWLAN torn down if IWLAN data service crashes.
     */
    public boolean shouldPersistIwlanDataNetworksWhenDataServiceRestarted() {
        return mResources.getBoolean(com.android.internal.R.bool
                .config_wlan_data_service_conn_persistence_on_restart);
    }

    /**
     * Registration point for subscription info ready
     *
@@ -283,6 +292,7 @@ public class DataConfigManager extends Handler {
        IndentingPrintWriter pw = new IndentingPrintWriter(printWriter, "  ");
        pw.println(DataConfigManager.class.getSimpleName() + "-" + mPhone.getPhoneId() + ":");
        pw.increaseIndent();
        pw.println("isConfigCarrierSpecific=" + isConfigCarrierSpecific());
        pw.println("Network capability priority:");
        pw.increaseIndent();
        for (Map.Entry<Integer, Integer> entry : mNetworkCapabilityPriorityMap.entrySet()) {
@@ -297,6 +307,9 @@ public class DataConfigManager extends Handler {
            pw.println(rule);
        }
        pw.decreaseIndent();
        pw.println("getImsDeregistrationDelay=" + getImsDeregistrationDelay());
        pw.println("shouldPersistIwlanDataNetworksWhenDataServiceRestarted="
                + shouldPersistIwlanDataNetworksWhenDataServiceRestarted());
        pw.decreaseIndent();
    }
}
+20 −11
Original line number Diff line number Diff line
@@ -21,7 +21,9 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.telephony.data.DataProfile;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
@@ -81,6 +83,13 @@ public class DataEvaluation {
        mEvaluatedTime = System.currentTimeMillis();
    }

    /**
     * @return List of data disallowed reasons.
     */
    public @NonNull List<DataDisallowedReason> getDataDisallowedReasons() {
        return new ArrayList<>(mDataDisallowedReasons);
    }

    /**
     * Set the candidate data profile for setup data network.
     *
@@ -154,22 +163,20 @@ public class DataEvaluation {
        DATA_CONFIG_CHANGED,
        /** SIM is loaded. */
        SIM_LOADED,
        /** SIM is removed. */
        SIM_REMOVAL,
        /** Data profiles changed. */
        DATA_PROFILES_CHANGED,
        /** Airplane mode off. */
        AIRPLANE_MODE_OFF,
        /** When data RAT changes, some unsatisfied network requests might fit with the new RAT. */
        DATA_RAT_CHANGED,
        /** When service state changes from out of service to in service. */
        DATA_IN_SERVICE,
        /** When service state changes.(For now only considering data RAT and data registration). */
        DATA_SERVICE_STATE_CHANGED,
        /** When data is enabled (by user, carrier, thermal, etc...) */
        DATA_ENABLED,
        /** When data roaming is enabled. */
        ROAMING_ENABLED,
        /** When voice call ended (for concurrent voice/data not supported RAT). */
        VOICE_CALL_ENDED,
        /** When network no longer restricts mobile data. */
        DATA_RESTRICTED_LIFTED,
        /** When network restricts or no longer restricts mobile data. */
        DATA_RESTRICTED_CHANGED,
        /** Network capabilities changed. The unsatisfied requests might have chances to attach. */
        DATA_NETWORK_CAPABILITIES_CHANGED,
    }
@@ -200,12 +207,14 @@ public class DataEvaluation {
        DATA_RESTRICTED_BY_NETWORK(true),
        /** Radio power is off (i.e. airplane mode on) */
        RADIO_POWER_OFF(true),
        /** Data disabled by telephony in some scenarios, for example, emergency call. */
        INTERNAL_DATA_DISABLED(true),
        /** Airplane mode is forcibly turned on by the carrier. */
        RADIO_DISABLED_BY_CARRIER(true),
        /** Underlying data service is not bound. */
        DATA_SERVICE_NOT_READY(true);
        DATA_SERVICE_NOT_READY(true),
        /** Unable to find a suitable data profile. */
        NO_SUITABLE_DATA_PROFILE(true),
        /** Current data network type not allowed. */
        DATA_NETWORK_TYPE_NOT_ALLOWED(true);

        private final boolean mIsHardReason;

+56 −2
Original line number Diff line number Diff line
@@ -173,6 +173,13 @@ public class DataNetwork extends StateMachine {
                    TEAR_DOWN_REASON_SIM_REMOVAL,
                    TEAR_DOWN_REASON_AIRPLANE_MODE_ON,
                    TEAR_DOWN_REASON_DATA_DISABLED,
                    TEAR_DOWN_REASON_NO_LIVE_REQUEST,
                    TEAR_DOWN_REASON_RAT_NOT_ALLOWED,
                    TEAR_DOWN_REASON_ROAMING_DISABLED,
                    TEAR_DOWN_REASON_CONCURRENT_VOICE_DATA_NOT_ALLOWED,
                    TEAR_DOWN_REASON_DATA_RESTRICTED_BY_NETWORK,
                    TEAR_DOWN_REASON_DATA_SERVICE_NOT_READY,
                    TEAR_DOWN_REASON_POWER_OFF_BY_CARRIER,
            })
    public @interface TearDownReason {}

@@ -191,6 +198,24 @@ public class DataNetwork extends StateMachine {
    /** Data network tear down due to no live network request. */
    public static final int TEAR_DOWN_REASON_NO_LIVE_REQUEST = 5;

    /** Data network tear down due to current RAT is not allowed by the data profile. */
    public static final int TEAR_DOWN_REASON_RAT_NOT_ALLOWED = 6;

    /** Data network tear down due to data roaming not enabled. */
    public static final int TEAR_DOWN_REASON_ROAMING_DISABLED = 7;

    /** Data network tear down due to concurrent voice/data not allowed. */
    public static final int TEAR_DOWN_REASON_CONCURRENT_VOICE_DATA_NOT_ALLOWED = 8;

    /** Data network tear down due to network restricted. */
    public static final int TEAR_DOWN_REASON_DATA_RESTRICTED_BY_NETWORK = 9;

    /** Data network tear down due to data service unbound. */
    public static final int TEAR_DOWN_REASON_DATA_SERVICE_NOT_READY = 10;

    /** Data network tear down due to radio turned off by the carrier. */
    public static final int TEAR_DOWN_REASON_POWER_OFF_BY_CARRIER = 11;

    /** The phone instance. */
    private final @NonNull Phone mPhone;
    /**
@@ -467,7 +492,12 @@ public class DataNetwork extends StateMachine {
        addState(mDisconnectedState, mDefaultState);
        setInitialState(mConnectingState);

        /**
         * This will trigger {@link DefaultState#enter()}, and then {@link ConnectingState#enter()}.
         * Check {@link StateMachine} class to see how Android state machine works.
         */
        start();
        // Do not add more stuffs here.
    }

    /**
@@ -519,6 +549,11 @@ public class DataNetwork extends StateMachine {
                    AccessNetworkConstants.TRANSPORT_TYPE_WWAN, getHandler(),
                    EVENT_SERVICE_STATE_CHANGED,
                    AccessNetworkConstants.TRANSPORT_TYPE_WWAN);

            // Only add symmetric code here, for example, registering and unregistering.
            // DefaultState.enter() is the starting point in the life cycle of the DataNetwork,
            // and DefaultState.exit() is the end. For non-symmetric initializing works, put them
            // in ConnectingState.enter().
        }

        @Override
@@ -1450,7 +1485,7 @@ public class DataNetwork extends StateMachine {
    /**
     * @return {@code true} if in connecting state.
     */
    private boolean isConnecting() {
    public boolean isConnecting() {
        return getCurrentState() == mConnectingState;
    }

@@ -1471,7 +1506,7 @@ public class DataNetwork extends StateMachine {
    /**
     * @return {@code true} if in disconnected state.
     */
    private boolean isDisconnected() {
    public boolean isDisconnected() {
        return getCurrentState() == mDisconnectedState;
    }

@@ -1489,6 +1524,13 @@ public class DataNetwork extends StateMachine {
        return getState() == TelephonyManager.DATA_SUSPENDED;
    }

    /**
     * @return The current transport of the data network.
     */
    public @TransportType int getTransport() {
        return mTransport;
    }

    private @DataState int getState() {
        IState state = getCurrentState();
        if (state == null || isDisconnected()) {
@@ -1572,6 +1614,18 @@ public class DataNetwork extends StateMachine {
                return "DATA_DISABLED";
            case TEAR_DOWN_REASON_NO_LIVE_REQUEST:
                return "TEAR_DOWN_REASON_NO_LIVE_REQUEST";
            case TEAR_DOWN_REASON_RAT_NOT_ALLOWED:
                return "TEAR_DOWN_REASON_RAT_NOT_ALLOWED";
            case TEAR_DOWN_REASON_ROAMING_DISABLED:
                return "TEAR_DOWN_REASON_ROAMING_DISABLED";
            case TEAR_DOWN_REASON_CONCURRENT_VOICE_DATA_NOT_ALLOWED:
                return "TEAR_DOWN_REASON_CONCURRENT_VOICE_DATA_NOT_ALLOWED";
            case TEAR_DOWN_REASON_DATA_RESTRICTED_BY_NETWORK:
                return "TEAR_DOWN_REASON_DATA_RESTRICTED_BY_NETWORK";
            case TEAR_DOWN_REASON_DATA_SERVICE_NOT_READY:
                return "TEAR_DOWN_REASON_DATA_SERVICE_NOT_READY";
            case TEAR_DOWN_REASON_POWER_OFF_BY_CARRIER:
                return "TEAR_DOWN_REASON_POWER_OFF_BY_CARRIER";
            default:
                return "UNKNOWN(" + reason + ")";
        }
+410 −31

File changed.

Preview size limit exceeded, changes collapsed.

+18 −14
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ import android.os.RegistrantList;
import android.provider.Telephony;
import android.telephony.Annotation;
import android.telephony.Annotation.NetCapability;
import android.telephony.NetworkRegistrationInfo;
import android.telephony.Annotation.NetworkType;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.telephony.data.ApnSetting;
@@ -60,6 +60,9 @@ public class DataProfileManager extends Handler {
    /** Event for APN database changed. */
    private static final int EVENT_APN_DATABASE_CHANGED = 2;

    /** Event for SIM refresh. */
    private static final int EVENT_SIM_REFRESH = 3;

    private final Phone mPhone;
    private final String mLogTag;
    private final LocalLog mLocalLog = new LocalLog(128);
@@ -126,6 +129,7 @@ public class DataProfileManager extends Handler {
                        sendEmptyMessage(EVENT_APN_DATABASE_CHANGED);
                    }
                });
        mPhone.mCi.registerForIccRefresh(this, EVENT_SIM_REFRESH, null);
    }

    @Override
@@ -134,8 +138,13 @@ public class DataProfileManager extends Handler {
            case EVENT_DATA_CONFIG_UPDATED:
                onDataConfigUpdated();
                break;
            case EVENT_SIM_REFRESH:
                log("SIM refreshed.");
                updateDataProfiles();
                break;
            case EVENT_APN_DATABASE_CHANGED:
                onApnDatabaseChanged();
                log("APN database changed.");
                updateDataProfiles();
                break;
        }
    }
@@ -305,7 +314,7 @@ public class DataProfileManager extends Handler {
        }

        if (initialAttachDataProfile == null) {
            loge("Cannot find initial attach data profile. ANN database needs to be configured"
            loge("Cannot find initial attach data profile. APN database needs to be configured"
                    + " correctly.");
            // return here as we can't push a null data profile to the modem as initial attach APN.
            return;
@@ -353,10 +362,11 @@ public class DataProfileManager extends Handler {
     * Get the data profile that can satisfy the network request.
     *
     * @param networkRequest The network request.
     * @param networkType The current data network type.
     * @return The data profile. {@code null} if can't find any satisfiable data profile.
     */
    public @Nullable DataProfile getDataProfileForNetworkRequest(
            @NonNull TelephonyNetworkRequest networkRequest) {
            @NonNull TelephonyNetworkRequest networkRequest, @NetworkType int networkType) {
        // Step 1: Check if preferred data profile can satisfy the request.
        if (mPreferredDataProfile != null
                && mPreferredDataProfile.canSatisfy(networkRequest.getCapabilities())) {
@@ -372,20 +382,14 @@ public class DataProfileManager extends Handler {
            return null;
        }

        // Step 3: Check if the remaining data profiles can used in current data RAT.
        int transport = mAccessNetworksManager.getPreferredTransportByNetworkCapability(
                networkRequest.getHighestPriorityNetworkCapability());
        NetworkRegistrationInfo nri = mPhone.getServiceState().getNetworkRegistrationInfo(
                NetworkRegistrationInfo.DOMAIN_PS, transport);
        int dataRat = nri.getAccessNetworkTechnology();

        // Step 3: Check if the remaining data profiles can used in current data network type.
        dataProfiles = dataProfiles.stream()
                .filter(dp -> dp.getApnSetting() != null
                        && dp.getApnSetting().canSupportNetworkType(dataRat))
                        && dp.getApnSetting().canSupportNetworkType(networkType))
                .collect(Collectors.toList());
        if (dataProfiles.size() == 0) {
            log("Can't find any data profile for RAT "
                    + TelephonyManager.getNetworkTypeName(dataRat));
            log("Can't find any data profile for network type "
                    + TelephonyManager.getNetworkTypeName(networkType));
            return null;
        }

Loading