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

Commit 18de56de authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I026a4d71,I88e2284a,I596c8174,I175ee661,Ie6eca088, ...

* changes:
  Fixed delay data switching issue
  Fixed network request not detached from data network
  Fixed NPE
  Disable tethering profile when roaming
  Refine invalid DataCallResponse anomaly detection
  Seperate DataConfig update into Carrier and Device
  [DSRM] Do recovery actions only after validation passed once.
  Initialize default data roaming setting
parents 4bcd4ac0 69a5ede4
Loading
Loading
Loading
Loading
+70 −32
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.internal.telephony.data;

import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.StringDef;
import android.content.BroadcastReceiver;
@@ -29,7 +30,6 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.PersistableBundle;
import android.os.RegistrantList;
import android.provider.DeviceConfig;
import android.telephony.Annotation.ApnType;
import android.telephony.Annotation.NetCapability;
@@ -41,6 +41,7 @@ import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
import android.telephony.data.ApnSetting;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.IndentingPrintWriter;

import com.android.internal.annotations.VisibleForTesting;
@@ -62,6 +63,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executor;
import java.util.stream.Collectors;

/**
@@ -70,6 +72,9 @@ import java.util.stream.Collectors;
 * {@link CarrierConfigManager}. All the data config will be loaded once and stored here.
 */
public class DataConfigManager extends Handler {
    /** The max timeout in ms for data network stuck in a transit state. */
    public static final int MAX_NETWORK_TRANSIT_STATE_TIMEOUT_MS = 3600000;

    /** Event for carrier config changed. */
    private static final int EVENT_CARRIER_CONFIG_CHANGED = 1;

@@ -189,6 +194,10 @@ public class DataConfigManager extends Handler {
    @Retention(RetentionPolicy.SOURCE)
    private @interface DataConfigNetworkType {}

    /** Data config update callbacks. */
    private final @NonNull Set<DataConfigManagerCallback> mDataConfigManagerCallbacks =
            new ArraySet<>();

    /** DeviceConfig key of anomaly report threshold for back to back ims release-request. */
    private static final String KEY_ANOMALY_IMS_RELEASE_REQUEST = "anomaly_ims_release_request";
    /** DeviceConfig key of anomaly report threshold for frequent setup data failure. */
@@ -239,9 +248,6 @@ public class DataConfigManager extends Handler {
    private @NonNull final Phone mPhone;
    private @NonNull final String mLogTag;

    /** The registrants list for config update event. */
    private @NonNull final RegistrantList mConfigUpdateRegistrants = new RegistrantList();

    private @NonNull final CarrierConfigManager mCarrierConfigManager;
    private @NonNull PersistableBundle mCarrierConfig = null;
    private @NonNull Resources mResources = null;
@@ -318,8 +324,46 @@ public class DataConfigManager extends Handler {

        // Must be called to set mCarrierConfig and mResources to non-null values
        updateCarrierConfig();
        // Must be called to set anomaly report threshold to non-null values
        updateDeviceConfig();
        mConfigUpdateRegistrants.notifyRegistrants();
    }

    /**
     * The data config callback.
     */
    public static class DataConfigManagerCallback extends DataCallback {
        /**
         * Constructor
         *
         * @param executor The executor of the callback.
         */
        public DataConfigManagerCallback(@NonNull @CallbackExecutor Executor executor) {
            super(executor);
        }

        /** Callback on carrier config update.*/
        public void onCarrierConfigChanged() {}

        /** Callback on device config update.*/
        public void onDeviceConfigChanged() {}
    }

    /**
     * Register the callback for receiving information from {@link DataConfigManager}.
     *
     * @param callback The callback.
     */
    public void registerCallback(@NonNull DataConfigManagerCallback callback) {
        mDataConfigManagerCallbacks.add(callback);
    }

    /**
     * Unregister the callback.
     *
     * @param callback The previously registered callback.
     */
    public void unregisterCallback(@NonNull DataConfigManagerCallback callback) {
        mDataConfigManagerCallbacks.remove(callback);
    }

    @Override
@@ -328,12 +372,14 @@ public class DataConfigManager extends Handler {
            case EVENT_CARRIER_CONFIG_CHANGED:
                log("EVENT_CARRIER_CONFIG_CHANGED");
                updateCarrierConfig();
                mConfigUpdateRegistrants.notifyRegistrants();
                mDataConfigManagerCallbacks.forEach(callback -> callback.invokeFromExecutor(
                        callback::onCarrierConfigChanged));
                break;
            case EVENT_DEVICE_CONFIG_CHANGED:
                log("EVENT_DEVICE_CONFIG_CHANGED");
                updateDeviceConfig();
                mConfigUpdateRegistrants.notifyRegistrants();
                mDataConfigManagerCallbacks.forEach(callback -> callback.invokeFromExecutor(
                        callback::onDeviceConfigChanged));
                break;
            default:
                loge("Unexpected message " + msg.what);
@@ -347,22 +393,22 @@ public class DataConfigManager extends Handler {

        mImsReleaseRequestAnomalyReportThreshold = parseSlidingWindowCounterThreshold(
                properties.getString(KEY_ANOMALY_IMS_RELEASE_REQUEST, null),
                300000,
                12);
                0,
                2);
        mNetworkUnwantedAnomalyReportThreshold = parseSlidingWindowCounterThreshold(
                properties.getString(KEY_ANOMALY_NETWORK_UNWANTED, null),
                300000,
                0,
                12);
        mSetupDataCallAnomalyReportThreshold = parseSlidingWindowCounterThreshold(
                properties.getString(KEY_ANOMALY_SETUP_DATA_CALL_FAILURE, null),
                0,
                2);
                12);
        mNetworkConnectingTimeout = properties.getInt(
                KEY_ANOMALY_NETWORK_CONNECTING_TIMEOUT, 86400000);
                KEY_ANOMALY_NETWORK_CONNECTING_TIMEOUT, MAX_NETWORK_TRANSIT_STATE_TIMEOUT_MS);
        mNetworkDisconnectingTimeout = properties.getInt(
                KEY_ANOMALY_NETWORK_DISCONNECTING_TIMEOUT, 86400000);
                KEY_ANOMALY_NETWORK_DISCONNECTING_TIMEOUT, MAX_NETWORK_TRANSIT_STATE_TIMEOUT_MS);
        mNetworkHandoverTimeout = properties.getInt(
                KEY_ANOMALY_NETWORK_HANDOVER_TIMEOUT, 86400000);
                KEY_ANOMALY_NETWORK_HANDOVER_TIMEOUT, MAX_NETWORK_TRANSIT_STATE_TIMEOUT_MS);
    }

    /**
@@ -536,6 +582,14 @@ public class DataConfigManager extends Handler {
                .collect(Collectors.toUnmodifiableSet());
    }

    /**
     * @return {@code true} if tethering profile should not be used when the device is roaming.
     */
    public boolean isTetheringProfileDisabledForRoaming() {
        return mCarrierConfig.getBoolean(
                CarrierConfigManager.KEY_DISABLE_DUN_APN_WHILE_ROAMING_WITH_PRESET_APN_BOOL);
    }

    /**
     * Check if the network capability metered.
     *
@@ -1127,24 +1181,6 @@ public class DataConfigManager extends Handler {
                com.android.internal.R.bool.config_enhanced_iwlan_handover_check);
    }

    /**
     * Registration point for subscription info ready.
     *
     * @param h handler to notify.
     * @param what what code of message when delivered.
     */
    public void registerForConfigUpdate(Handler h, int what) {
        mConfigUpdateRegistrants.addUnique(h, what, null);
    }

    /**
     *
     * @param h The original handler passed in {@link #registerForConfigUpdate(Handler, int)}.
     */
    public void unregisterForConfigUpdate(Handler h) {
        mConfigUpdateRegistrants.remove(h);
    }

    /**
     * Log debug messages.
     * @param s debug messages
@@ -1226,6 +1262,8 @@ public class DataConfigManager extends Handler {
                com.android.internal.R.string.config_bandwidthEstimateSource));
        pw.println("isDelayTearDownImsEnabled=" + isImsDelayTearDownEnabled());
        pw.println("isEnhancedIwlanHandoverCheckEnabled=" + isEnhancedIwlanHandoverCheckEnabled());
        pw.println("isTetheringProfileDisabledForRoaming="
                + isTetheringProfileDisabledForRoaming());
        pw.decreaseIndent();
    }
}
+103 −29
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import android.telephony.NetworkRegistrationInfo;
import android.telephony.PcoData;
import android.telephony.PreciseDataConnectionState;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionPlan;
import android.telephony.TelephonyDisplayInfo;
import android.telephony.TelephonyManager;
@@ -86,6 +87,7 @@ import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.PhoneFactory;
import com.android.internal.telephony.RIL;
import com.android.internal.telephony.data.DataConfigManager.DataConfigManagerCallback;
import com.android.internal.telephony.data.DataEvaluation.DataAllowedReason;
import com.android.internal.telephony.data.DataNetworkController.NetworkRequestList;
import com.android.internal.telephony.data.DataRetryManager.DataHandoverRetryEntry;
@@ -280,6 +282,7 @@ public class DataNetwork extends StateMachine {
                    TEAR_DOWN_REASON_NOT_ALLOWED_BY_POLICY,
                    TEAR_DOWN_REASON_ILLEGAL_STATE,
                    TEAR_DOWN_REASON_ONLY_ALLOWED_SINGLE_NETWORK,
                    TEAR_DOWN_REASON_PREFERRED_DATA_SWITCHED,
            })
    public @interface TearDownReason {}

@@ -369,6 +372,9 @@ public class DataNetwork extends StateMachine {
    /** Data network tear down due to only allowed single network. */
    public static final int TEAR_DOWN_REASON_ONLY_ALLOWED_SINGLE_NETWORK = 29;

    /** Data network tear down due to preferred data switched to another phone. */
    public static final int TEAR_DOWN_REASON_PREFERRED_DATA_SWITCHED = 30;

    @IntDef(prefix = {"BANDWIDTH_SOURCE_"},
            value = {
                    BANDWIDTH_SOURCE_UNKNOWN,
@@ -467,6 +473,9 @@ public class DataNetwork extends StateMachine {
     */
    private final int mSubId;

    /** The network score of this network. */
    private int mNetworkScore;

    /**
     * Indicates that
     * {@link DataService.DataServiceProvider#deactivateDataCall(int, int, DataServiceCallback)}
@@ -649,6 +658,11 @@ public class DataNetwork extends StateMachine {
     */
    private @Nullable LinkBandwidthEstimatorCallback mLinkBandwidthEstimatorCallback;

    /**
     * Data config callback for carrier config update.
     */
    private @Nullable DataConfigManagerCallback mDataConfigManagerCallback;

    /**
     * The network bandwidth.
     */
@@ -955,8 +969,10 @@ public class DataNetwork extends StateMachine {
                mPhone.getPhoneId());
        final NetworkProvider provider = (null == factory) ? null : factory.getProvider();

        mNetworkScore = getNetworkScore();
        return new TelephonyNetworkAgent(mPhone, getHandler().getLooper(), this,
                getNetworkScore(), configBuilder.build(), provider,
                new NetworkScore.Builder().setLegacyInt(mNetworkScore).build(),
                configBuilder.build(), provider,
                new TelephonyNetworkAgentCallback(getHandler()::post) {
                    @Override
                    public void onValidationStatus(@ValidationStatus int status,
@@ -978,7 +994,13 @@ public class DataNetwork extends StateMachine {
        @Override
        public void enter() {
            logv("Registering all events.");
            mDataConfigManager.registerForConfigUpdate(getHandler(), EVENT_DATA_CONFIG_UPDATED);
            mDataConfigManagerCallback = new DataConfigManagerCallback(getHandler()::post) {
                @Override
                public void onCarrierConfigChanged() {
                    sendMessage(EVENT_DATA_CONFIG_UPDATED);
                }
            };
            mDataConfigManager.registerCallback(mDataConfigManagerCallback);
            mPhone.getDisplayInfoController().registerForTelephonyDisplayInfoChanged(
                    getHandler(), EVENT_DISPLAY_INFO_CHANGED, null);
            mPhone.getServiceStateTracker().registerForServiceStateChanged(getHandler(),
@@ -1030,14 +1052,14 @@ public class DataNetwork extends StateMachine {
            mPhone.getServiceStateTracker().unregisterForServiceStateChanged(getHandler());
            mPhone.getDisplayInfoController().unregisterForTelephonyDisplayInfoChanged(
                    getHandler());
            mDataConfigManager.unregisterForConfigUpdate(getHandler());
            mDataConfigManager.unregisterCallback(mDataConfigManagerCallback);
        }

        @Override
        public boolean processMessage(Message msg) {
            switch (msg.what) {
                case EVENT_DATA_CONFIG_UPDATED:
                    onDataConfigUpdated();
                    onCarrierConfigUpdated();
                    break;
                case EVENT_SERVICE_STATE_CHANGED: {
                    mDataCallSessionStats.onDrsOrRatChanged(getDataNetworkType());
@@ -1047,13 +1069,12 @@ public class DataNetwork extends StateMachine {
                }
                case EVENT_ATTACH_NETWORK_REQUEST: {
                    onAttachNetworkRequests((NetworkRequestList) msg.obj);
                    updateNetworkScore();
                    break;
                }
                case EVENT_DETACH_NETWORK_REQUEST: {
                    TelephonyNetworkRequest networkRequest = (TelephonyNetworkRequest) msg.obj;
                    mAttachedNetworkRequestList.remove(networkRequest);
                    networkRequest.setState(TelephonyNetworkRequest.REQUEST_STATE_UNSATISFIED);
                    networkRequest.setAttachedNetwork(null);
                    onDetachNetworkRequest((TelephonyNetworkRequest) msg.obj);
                    updateNetworkScore();
                    break;
                }
                case EVENT_DETACH_ALL_NETWORK_REQUESTS: {
@@ -1166,10 +1187,14 @@ public class DataNetwork extends StateMachine {
                    deferMessage(msg);
                    break;
                case EVENT_STUCK_IN_TRANSIENT_STATE:
                    // enable detection only for valid timeout range
                    if (mDataConfigManager.getAnomalyNetworkConnectingTimeoutMs()
                            < DataConfigManager.MAX_NETWORK_TRANSIT_STATE_TIMEOUT_MS) {
                        reportAnomaly("Data network stuck in connecting state for "
                                + TimeUnit.MILLISECONDS.toSeconds(
                                mDataConfigManager.getAnomalyNetworkConnectingTimeoutMs())
                                + " seconds.", "58c56403-7ea7-4e56-a0c7-e467114d09b8");
                    }
                    // Setup data failed. Use the retry logic defined in
                    // CarrierConfigManager.KEY_TELEPHONY_DATA_SETUP_RETRY_RULES_STRING_ARRAY.
                    mRetryDelayMillis = DataCallResponse.RETRY_DURATION_UNDEFINED;
@@ -1357,10 +1382,14 @@ public class DataNetwork extends StateMachine {
                    onPcoDataReceived((PcoData) ar.result);
                    break;
                case EVENT_STUCK_IN_TRANSIENT_STATE:
                    // enable detection only for valid timeout range
                    if (mDataConfigManager.getNetworkHandoverTimeoutMs()
                            < DataConfigManager.MAX_NETWORK_TRANSIT_STATE_TIMEOUT_MS) {
                        reportAnomaly("Data service did not respond the handover request within "
                                        + TimeUnit.MILLISECONDS.toSeconds(
                                mDataConfigManager.getNetworkHandoverTimeoutMs()) + " seconds.",
                                "1afe68cb-8b41-4964-a737-4f34372429ea");
                    }

                    // Handover failed. Use the retry logic defined in
                    // CarrierConfigManager.KEY_TELEPHONY_DATA_HANDOVER_RETRY_RULES_STRING_ARRAY.
@@ -1455,11 +1484,16 @@ public class DataNetwork extends StateMachine {
                case EVENT_STUCK_IN_TRANSIENT_STATE:
                    // After frameworks issues deactivate data call request, RIL should report
                    // data disconnected through data call list changed event subsequently.

                    // enable detection only for valid timeout range
                    if (mDataConfigManager.getAnomalyNetworkDisconnectingTimeoutMs()
                            < DataConfigManager.MAX_NETWORK_TRANSIT_STATE_TIMEOUT_MS) {
                        reportAnomaly("RIL did not send data call list changed event after "
                                + "deactivate data call request within "
                                + TimeUnit.MILLISECONDS.toSeconds(
                                mDataConfigManager.getAnomalyNetworkDisconnectingTimeoutMs())
                                + " seconds.", "d0e4fa1c-c57b-4ba5-b4b6-8955487012cc");
                    }
                    mFailCause = DataFailCause.LOST_CONNECTION;
                    transitionTo(mDisconnectedState);
                    break;
@@ -1618,6 +1652,31 @@ public class DataNetwork extends StateMachine {
        }
    }

    /**
     * Called when detaching the network request from this data network.
     *
     * @param networkRequest Network request to detach.
     */
    private void onDetachNetworkRequest(@NonNull TelephonyNetworkRequest networkRequest) {
        mAttachedNetworkRequestList.remove(networkRequest);
        networkRequest.setState(TelephonyNetworkRequest.REQUEST_STATE_UNSATISFIED);
        networkRequest.setAttachedNetwork(null);

        if (mAttachedNetworkRequestList.isEmpty()) {
            log("All network requests are detached.");

            // If there is no network request attached, and we are not preferred data phone, then
            // this detach is likely due to temp DDS switch. We should tear down the network when
            // all requests are detached so the other network on preferred data sub can be
            // established properly.
            int preferredDataPhoneId = PhoneSwitcher.getInstance().getPreferredDataPhoneId();
            if (preferredDataPhoneId != SubscriptionManager.INVALID_PHONE_INDEX
                    && preferredDataPhoneId != mPhone.getPhoneId()) {
                tearDown(TEAR_DOWN_REASON_PREFERRED_DATA_SWITCHED);
            }
        }
    }

    /**
     * Detach the network request from this data network. Note that this will not tear down the
     * network.
@@ -2354,7 +2413,8 @@ public class DataNetwork extends StateMachine {
     * @param response The response to be validated
     */
    private void validateDataCallResponse(@Nullable DataCallResponse response) {
        if (response == null) return;
        if (response == null
                || response.getLinkStatus() == DataCallResponse.LINK_STATUS_INACTIVE) return;
        int failCause = response.getCause();
        if (failCause == DataFailCause.NONE) {
            if (TextUtils.isEmpty(response.getInterfaceName())
@@ -2370,7 +2430,7 @@ public class DataNetwork extends StateMachine {
                    > DataCallResponse.HANDOVER_FAILURE_MODE_NO_FALLBACK_RETRY_SETUP_NORMAL) {
                loge("Invalid DataCallResponse:" + response);
                reportAnomaly("Invalid DataCallResponse detected",
                        "9f775beb-c638-44d2-833a-8c3875fee2d1");
                        "1f273e9d-b09c-46eb-ad1c-421d01f61164");
            }
        } else if (!DataFailCause.isFailCauseExisting(failCause)) { // Setup data failed.
            loge("Invalid DataFailCause in " + response);
@@ -2531,10 +2591,10 @@ public class DataNetwork extends StateMachine {
    }

    /**
     * Called when data config updated.
     * Called when carrier config updated.
     */
    private void onDataConfigUpdated() {
        log("onDataConfigUpdated");
    private void onCarrierConfigUpdated() {
        log("onCarrierConfigUpdated");

        updateBandwidthFromDataConfig();
        updateTcpBufferSizes();
@@ -2757,17 +2817,28 @@ public class DataNetwork extends StateMachine {
        return mLinkStatus;
    }

    /**
     * Update the network score and report to connectivity service if necessary.
     */
    private void updateNetworkScore() {
        int networkScore = getNetworkScore();
        if (networkScore != mNetworkScore) {
            logl("Updating score from " + mNetworkScore + " to " + networkScore);
            mNetworkScore = networkScore;
            mNetworkAgent.sendNetworkScore(mNetworkScore);
        }
    }

    /**
     * @return The network score. The higher score of the network has higher chance to be
     * selected by the connectivity service as active network.
     */
    private @NonNull NetworkScore getNetworkScore() {
    private int getNetworkScore() {
        // If it's serving a network request that asks NET_CAPABILITY_INTERNET and doesn't have
        // specify a sub id, this data network is considered to be default internet data
        // connection. In this case we assign a slightly higher score of 50. The intention is
        // it will not be replaced by other data networks accidentally in DSDS use case.
        int score = OTHER_NETWORK_SCORE;
        // TODO: Should update the score when attached list changed.
        for (TelephonyNetworkRequest networkRequest : mAttachedNetworkRequestList) {
            if (networkRequest.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
                    && networkRequest.getNetworkSpecifier() == null) {
@@ -2775,7 +2846,7 @@ public class DataNetwork extends StateMachine {
            }
        }

        return new NetworkScore.Builder().setLegacyInt(score).build();
        return score;
    }

    /**
@@ -3205,6 +3276,8 @@ public class DataNetwork extends StateMachine {
                return "TEAR_DOWN_REASON_ILLEGAL_STATE";
            case TEAR_DOWN_REASON_ONLY_ALLOWED_SINGLE_NETWORK:
                return "TEAR_DOWN_REASON_ONLY_ALLOWED_SINGLE_NETWORK";
            case TEAR_DOWN_REASON_PREFERRED_DATA_SWITCHED:
                return "TEAR_DOWN_REASON_PREFERRED_DATA_SWITCHED";
            default:
                return "UNKNOWN(" + reason + ")";
        }
@@ -3349,6 +3422,7 @@ public class DataNetwork extends StateMachine {
        pw.println("mTransport=" + AccessNetworkConstants.transportTypeToString(mTransport));
        pw.println("WWAN cid=" + mCid.get(AccessNetworkConstants.TRANSPORT_TYPE_WWAN));
        pw.println("WLAN cid=" + mCid.get(AccessNetworkConstants.TRANSPORT_TYPE_WLAN));
        pw.println("mNetworkScore=" + mNetworkScore);
        pw.println("mDataAllowedReason=" + mDataAllowedReason);
        pw.println("mPduSessionId=" + mPduSessionId);
        pw.println("mDataProfile=" + mDataProfile);
+42 −21

File changed.

Preview size limit exceeded, changes collapsed.

+22 −13
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import android.util.IndentingPrintWriter;
import android.util.LocalLog;

import com.android.internal.telephony.Phone;
import com.android.internal.telephony.data.DataConfigManager.DataConfigManagerCallback;
import com.android.internal.telephony.data.DataNetworkController.DataNetworkControllerCallback;
import com.android.telephony.Rlog;

@@ -64,9 +65,6 @@ import java.util.stream.Collectors;
public class DataProfileManager extends Handler {
    private static final boolean VDBG = true;

    /** Event for data config updated. */
    private static final int EVENT_DATA_CONFIG_UPDATED = 1;

    /** Event for APN database changed. */
    private static final int EVENT_APN_DATABASE_CHANGED = 2;

@@ -156,7 +154,12 @@ public class DataProfileManager extends Handler {
                            @NonNull List<DataProfile> dataProfiles) {
                        DataProfileManager.this.onInternetDataNetworkConnected(dataProfiles);
                    }});
        mDataConfigManager.registerForConfigUpdate(this, EVENT_DATA_CONFIG_UPDATED);
        mDataConfigManager.registerCallback(new DataConfigManagerCallback(this::post) {
            @Override
            public void onCarrierConfigChanged() {
                DataProfileManager.this.onCarrierConfigUpdated();
            }
        });
        mPhone.getContext().getContentResolver().registerContentObserver(
                Telephony.Carriers.CONTENT_URI, true, new ContentObserver(this) {
                    @Override
@@ -171,9 +174,6 @@ public class DataProfileManager extends Handler {
    @Override
    public void handleMessage(Message msg) {
        switch (msg.what) {
            case EVENT_DATA_CONFIG_UPDATED:
                onDataConfigUpdated();
                break;
            case EVENT_SIM_REFRESH:
                log("Update data profiles due to SIM refresh.");
                updateDataProfiles();
@@ -189,10 +189,10 @@ public class DataProfileManager extends Handler {
    }

    /**
     * Called when data config was updated.
     * Called when carrier config was updated.
     */
    private void onDataConfigUpdated() {
        log("Update data profiles due to config updated.");
    private void onCarrierConfigUpdated() {
        log("Update data profiles due to carrier config updated.");
        updateDataProfiles();

        //TODO: more works needed to be done here.
@@ -273,7 +273,7 @@ public class DataProfileManager extends Handler {
        }

        // Check if any of the profile already supports IMS, if not, add the default one.
        DataProfile dataProfile = profiles.stream()
        dataProfile = profiles.stream()
                .filter(dp -> dp.canSatisfy(NetworkCapabilities.NET_CAPABILITY_IMS))
                .findFirst()
                .orElse(null);
@@ -688,14 +688,21 @@ public class DataProfileManager extends Handler {
     * Check if there is tethering data profile for certain network type.
     *
     * @param networkType The network type
     * @return {@code true} if tethering data profile is found.
     * @return {@code true} if tethering data profile is found. {@code false} if no specific profile
     * should used for tethering. In this case, tethering service will use internet network for
     * tethering.
     */
    public boolean isTetheringDataProfileExisting(@NetworkType int networkType) {
        if (mDataConfigManager.isTetheringProfileDisabledForRoaming()
                && mPhone.getServiceState().getDataRoaming()) {
            // Use internet network for tethering.
            return false;
        }
        TelephonyNetworkRequest networkRequest = new TelephonyNetworkRequest(
                new NetworkRequest.Builder()
                        .addCapability(NetworkCapabilities.NET_CAPABILITY_DUN)
                        .build(), mPhone);
        return null != getDataProfileForNetworkRequest(networkRequest, networkType);
        return getDataProfileForNetworkRequest(networkRequest, networkType) != null;
    }

     /**
@@ -934,6 +941,8 @@ public class DataProfileManager extends Handler {
        pw.println("Preferred data profile from config=" + getPreferredDataProfileFromConfig());
        pw.println("Preferred data profile set id=" + mPreferredDataProfileSetId);
        pw.println("Initial attach data profile=" + mInitialAttachDataProfile);
        pw.println("isTetheringDataProfileExisting=" + isTetheringDataProfileExisting(
                TelephonyManager.NETWORK_TYPE_LTE));

        pw.println("Local logs:");
        pw.increaseIndent();
+9 −10

File changed.

Preview size limit exceeded, changes collapsed.

Loading