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

Commit 228cce86 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes from topics "data_retry", "setup_data"

* changes:
  Added data retry support
  Added setup/tear down data support
parents 837f0ebd 85264cba
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -340,7 +340,7 @@ public class GsmCdmaPhone extends Phone {
            mTransportManager.registerDataThrottler(dcTracker.getDataThrottler());
        }

        if (false/*isUsingNewDataStack()*/) {
        if (isUsingNewDataStack()) {
            mDataNetworkController = mTelephonyComponentFactory.inject(
                    DataNetworkController.class.getName())
                    .makeDataNetworkController(this, getLooper());
+3 −3
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.WorkSource;
import android.preference.PreferenceManager;
import android.provider.DeviceConfig;
import android.sysprop.TelephonyProperties;
import android.telecom.VideoProfile;
import android.telephony.AccessNetworkConstants;
@@ -5134,8 +5133,9 @@ public abstract class Phone extends Handler implements PhoneInternalInterface {
    // TODO: Temp code. Use cl/399526916 for future canary process. After rolling out to 100%
    //  dogfooders, the code below should be completely removed.
    public boolean isUsingNewDataStack() {
        String configValue = DeviceConfig.getProperty(DeviceConfig.NAMESPACE_TELEPHONY,
        return false;
        /*String configValue = DeviceConfig.getProperty(DeviceConfig.NAMESPACE_TELEPHONY,
                "new_telephony_data_enabled");
        return configValue != null && Boolean.parseBoolean(configValue);
        return Boolean.parseBoolean(configValue);*/
    }
}
+23 −4
Original line number Diff line number Diff line
@@ -28,8 +28,11 @@ import android.os.Looper;
import android.os.Message;
import android.os.PersistableBundle;
import android.os.RegistrantList;
import android.telephony.Annotation.NetCapability;
import android.telephony.Annotation.NetworkType;
import android.telephony.CarrierConfigManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.IndentingPrintWriter;

import com.android.internal.telephony.Phone;
@@ -135,6 +138,9 @@ public class DataConfigManager extends Handler {
        if (mCarrierConfigManager != null) {
            mCarrierConfig = mCarrierConfigManager.getConfigForSubId(mPhone.getSubId());
        }
        if (mCarrierConfig == null) {
            mCarrierConfig = CarrierConfigManager.getDefaultConfig();
        }
        mResources = SubscriptionManager.getResourcesForSubId(mPhone.getContext(),
                mPhone.getSubId());

@@ -151,7 +157,6 @@ public class DataConfigManager extends Handler {
     * Update the network capability priority from carrier config.
     */
    private void updateNetworkCapabilityPriority() {
        if (mCarrierConfig == null) return;
        String[] capabilityPriorityStrings = mCarrierConfig.getStringArray(
                CarrierConfigManager.KEY_TELEPHONY_NETWORK_CAPABILITY_PRIORITIES_STRING_ARRAY);
        if (capabilityPriorityStrings != null) {
@@ -181,7 +186,7 @@ public class DataConfigManager extends Handler {
     * @param capability The network capability
     * @return The priority range from 0 ~ 100. 100 is the highest priority.
     */
    public int getNetworkCapabilityPriority(int capability) {
    public int getNetworkCapabilityPriority(@NetCapability int capability) {
        if (mNetworkCapabilityPriorityMap.containsKey(capability)) {
            return mNetworkCapabilityPriorityMap.get(capability);
        }
@@ -193,7 +198,6 @@ public class DataConfigManager extends Handler {
     */
    private void updateDataRetryRules() {
        mDataRetryRules.clear();
        if (mCarrierConfig == null) return;
        String[] dataRetryRulesStrings = mCarrierConfig.getStringArray(
                CarrierConfigManager.KEY_TELEPHONY_DATA_RETRY_RULES_STRING_ARRAY);
        if (dataRetryRulesStrings != null) {
@@ -210,6 +214,21 @@ public class DataConfigManager extends Handler {
        return Collections.unmodifiableList(mDataRetryRules);
    }

    /**
     * Get the TCP config string, which will be used for
     * {@link android.net.LinkProperties#setTcpBufferSizes(String)}
     *
     * @param networkType The network type. Note that {@link TelephonyManager#NETWORK_TYPE_NR} is
     * used for both 5G SA and NSA case. {@link TelephonyManager#NETWORK_TYPE_LTE_CA} can be used
     * for LTE CA even though it's not really a radio access technology.
     *
     * @return The TCP buffer configuration string.
     */
    public @NonNull String getTcpConfigString(@NetworkType int networkType) {
        // TODO: Move all TCP_BUFFER_SIZES_XXX from DataConnection to here.
        return null;
    }

    /**
     * Registration point for subscription info ready
     *
@@ -261,6 +280,7 @@ public class DataConfigManager extends Handler {
            pw.print(DataUtils.networkCapabilityToString(entry.getKey()) + ":"
                    + entry.getValue() + " ");
        }
        pw.decreaseIndent();
        pw.println();
        pw.println("Data retry rules:");
        pw.increaseIndent();
@@ -269,6 +289,5 @@ public class DataConfigManager extends Handler {
        }
        pw.decreaseIndent();
        pw.decreaseIndent();
        pw.decreaseIndent();
    }
}
+85 −26
Original line number Diff line number Diff line
@@ -18,32 +18,47 @@ package com.android.internal.telephony.data;

import android.annotation.CurrentTimeMillisLong;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.telephony.data.DataProfile;

import java.text.DateFormat;
import java.util.HashSet;
import java.util.Set;

/**
 * The class to describe the result of environment evaluation for whether allowing or disallowing
 * The class to describe a data evaluation for whether allowing or disallowing
 * establishing a data network.
 */
public class DataEvaluationResult {
public class DataEvaluation {
    /** The reason for this evaluation */
    private final DataEvaluationReason mDataEvaluationReason;

    /** Data disallowed reasons. There could be multiple reasons for not allowing data. */
    private @NonNull Set<DataDisallowedReason> mDataDisallowedReasons = new HashSet<>();
    private final @NonNull Set<DataDisallowedReason> mDataDisallowedReasons = new HashSet<>();

    /** Data allowed reason. It is intended to only have one allowed reason. */
    private DataAllowedReason mDataAllowedReason = DataAllowedReason.NONE;

    private @Nullable DataProfile mCandidateDataProfile = null;

    /** The timestamp of evaluation time */
    private @CurrentTimeMillisLong long mEvaluatedTime = 0;

    /**
     * Constructor
     *
     * @param reason The reason for this evaluation.
     */
    public DataEvaluation(DataEvaluationReason reason) {
        mDataEvaluationReason = reason;
    }

    /**
     * Add a data disallowed reason. Note that adding a disallowed reason will clean up the
     * allowed reason because they are mutual exclusive.
     *
     * @param reason Disallowed reason.
     */
    public void add(DataDisallowedReason reason) {
    public void addDataDisallowedReason(DataDisallowedReason reason) {
        mDataAllowedReason = DataAllowedReason.NONE;
        mDataDisallowedReasons.add(reason);
        mEvaluatedTime = System.currentTimeMillis();
@@ -55,7 +70,7 @@ public class DataEvaluationResult {
     *
     * @param reason Allowed reason.
     */
    public void add(DataAllowedReason reason) {
    public void addDataAllowedReason(DataAllowedReason reason) {
        mDataDisallowedReasons.clear();

        // Only higher priority allowed reason can overwrite the old one. See
@@ -66,21 +81,20 @@ public class DataEvaluationResult {
        mEvaluatedTime = System.currentTimeMillis();
    }

    @Override
    public String toString() {
        StringBuilder reasonStr = new StringBuilder();
        reasonStr.append("EvaluationResult: ");
        if (mDataDisallowedReasons.size() > 0) {
            reasonStr.append("Data disallowed reasons:");
            for (DataDisallowedReason reason : mDataDisallowedReasons) {
                reasonStr.append(" ").append(reason);
            }
        } else {
            reasonStr.append("Data allowed reason:");
            reasonStr.append(" ").append(mDataAllowedReason);
    /**
     * Set the candidate data profile for setup data network.
     *
     * @param dataProfile The candidate data profile.
     */
    public void setCandidateDataProfile(@NonNull DataProfile dataProfile) {
        mCandidateDataProfile = dataProfile;
    }
        reasonStr.append(", time=" + DateFormat.getDateTimeInstance().format(mEvaluatedTime));
        return reasonStr.toString();

    /**
     * @return The candidate data profile for setup data network.
     */
    public @Nullable DataProfile getCandidateDataProfile() {
        return mCandidateDataProfile;
    }

    /**
@@ -132,6 +146,34 @@ public class DataEvaluationResult {
        return false;
    }

    /** The reason for evaluating unsatisfied network requests. */
    enum DataEvaluationReason {
        /** New request from the apps. */
        NEW_REQUEST,
        /** Data config changed. */
        DATA_CONFIG_CHANGED,
        /** SIM is loaded. */
        SIM_LOADED,
        /** 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 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,
        /** Network capabilities changed. The unsatisfied requests might have chances to attach. */
        DATA_NETWORK_CAPABILITIES_CHANGED,
    }

    /** Disallowed reasons. There could be multiple reasons if data connection is not allowed. */
    public enum DataDisallowedReason {
        // Soft failure reasons. A soft reason means that in certain conditions, data is still
@@ -148,6 +190,8 @@ public class DataEvaluationResult {
        // not be allowed.
        /** Data registration state is not in service. */
        NOT_IN_SERVICE(true),
        /** Data config is not ready. */
        DATA_CONFIG_NOT_READY(true),
        /** SIM is not ready. */
        SIM_NOT_READY(true),
        /** Concurrent voice and data is not allowed. */
@@ -160,10 +204,6 @@ public class DataEvaluationResult {
        INTERNAL_DATA_DISABLED(true),
        /** Airplane mode is forcibly turned on by the carrier. */
        RADIO_DISABLED_BY_CARRIER(true),
        /** certain APNs are only allowed when the device is camped on NR. */
        NOT_ON_NR(true),
        /** Data is not allowed while device is in emergency callback mode. */
        IN_ECBM(true),
        /** Underlying data service is not bound. */
        DATA_SERVICE_NOT_READY(true);

@@ -191,7 +231,7 @@ public class DataEvaluationResult {
    /**
     * Data allowed reasons. There will be only one reason if data is allowed.
     */
    enum DataAllowedReason {
    public enum DataAllowedReason {
        // Note that unlike disallowed reasons, we only have one allowed reason every time
        // when we check data is allowed or not. The order of these allowed reasons is very
        // important. The lower ones take precedence over the upper ones.
@@ -218,4 +258,23 @@ public class DataEvaluationResult {
         */
        EMERGENCY_REQUEST,
    }

    @Override
    public String toString() {
        StringBuilder evaluationStr = new StringBuilder();
        evaluationStr.append("Data evaluation: evaluation reason:" + mDataEvaluationReason + ", ");
        if (mDataDisallowedReasons.size() > 0) {
            evaluationStr.append("Data disallowed reasons:");
            for (DataDisallowedReason reason : mDataDisallowedReasons) {
                evaluationStr.append(" ").append(reason);
            }
        } else {
            evaluationStr.append("Data allowed reason:");
            evaluationStr.append(" ").append(mDataAllowedReason);
        }
        evaluationStr.append(", candidate profile=" + mCandidateDataProfile);
        evaluationStr.append(", time=" + DataUtils.getReadableSystemTime(mEvaluatedTime));
        return evaluationStr.toString();
    }

}
+1214 −98

File changed.

Preview size limit exceeded, changes collapsed.

Loading