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

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

Merge changes from topic "cp"

* changes:
  Fixed network tearing down due to data profile check failed
  Fixed two IMS data profiles sent to modem
  Seperate recovered reason
  Improve log for networkTypeBitmask
  QNS anomaly report only track frequent HO
  Persist user data roaming settings
parents fb8f6b2e 3038f6ac
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -364,14 +364,19 @@ public class AccessNetworksManager extends Handler {
            }

            List<QualifiedNetworks> qualifiedNetworksList = new ArrayList<>();
            // For anomaly report, only track frequent HO between cellular and IWLAN
            boolean isRequestedNetworkOnIwlan = Arrays.stream(qualifiedNetworkTypes)
                    .anyMatch(network -> network == AccessNetworkType.IWLAN);
            int satisfiedApnTypes = 0;
            for (int apnType : SUPPORTED_APN_TYPES) {
                if ((apnTypes & apnType) == apnType) {
                    // skip the APN anomaly detection if not using the T data stack
                    if (mDataConfigManager != null) {
                        satisfiedApnTypes |= apnType;
                        if (isRequestedNetworkOnIwlan) {
                            trackFrequentApnTypeChange(apnType);
                        }
                    }

                    if (mAvailableNetworks.get(apnType) != null) {
                        if (Arrays.equals(mAvailableNetworks.get(apnType),
+8 −9
Original line number Diff line number Diff line
@@ -1713,9 +1713,11 @@ public class DataNetworkController extends Handler {
                    && !dataProfile.getApnSetting().canSupportLingeringNetworkType(networkType)) {
                log("networkType=" + TelephonyManager.getNetworkTypeName(networkType)
                        + ", networkTypeBitmask="
                        + dataProfile.getApnSetting().getNetworkTypeBitmask()
                        + TelephonyManager.convertNetworkTypeBitmaskToString(
                                dataProfile.getApnSetting().getNetworkTypeBitmask())
                        + ", lingeringNetworkTypeBitmask="
                        + dataProfile.getApnSetting().getLingeringNetworkTypeBitmask());
                        + TelephonyManager.convertNetworkTypeBitmaskToString(
                                dataProfile.getApnSetting().getLingeringNetworkTypeBitmask()));
                evaluation.addDataDisallowedReason(
                        DataDisallowedReason.DATA_NETWORK_TYPE_NOT_ALLOWED);
            }
@@ -1725,13 +1727,10 @@ public class DataNetworkController extends Handler {
            evaluation.addDataDisallowedReason(DataDisallowedReason.DATA_DISABLED);
        }

        // Check if the data profile is still valid, sometimes the users can remove it from the APN
        // editor. We use very loose check here because APN id can change after APN reset to
        // default
        if (mDataProfileManager.getDataProfile(
                dataProfile.getApnSetting() != null
                        ? dataProfile.getApnSetting().getApnName() : null,
                dataProfile.getTrafficDescriptor()) == null) {
        // Check if the data profile is still compatible, sometimes the users can remove it from the
        // APN editor. If some of the important fields are changed in APN settings, we need to
        // tear down the network. Note traffic descriptor from the data profile will not be checked.
        if (!mDataProfileManager.isDataProfileCompatible(dataProfile)) {
            evaluation.addDataDisallowedReason(DataDisallowedReason.DATA_PROFILE_INVALID);
        }

+22 −28
Original line number Diff line number Diff line
@@ -86,7 +86,11 @@ public class DataProfileManager extends Handler {
    /** Cellular data service. */
    private final @NonNull DataServiceManager mWwanDataServiceManager;

    /** All data profiles for the current carrier. */
    /**
     * All data profiles for the current carrier. Note only data profiles loaded from the APN
     * database will be stored here. The on-demand data profiles (generated dynamically, for
     * example, enterprise data profiles with differentiator) are not stored here.
     */
    private final @NonNull List<DataProfile> mAllDataProfiles = new ArrayList<>();

    /** The data profile used for initial attach. */
@@ -911,39 +915,29 @@ public class DataProfileManager extends Handler {
    }

    /**
     * Get data profile by APN name and/or traffic descriptor.
     *
     * @param apnName APN name.
     * @param trafficDescriptor Traffic descriptor.
     * Check if the provided data profile is still compatible with the current environment. Note
     * this method ignores APN id check and traffic descriptor check. A data profile with traffic
     * descriptor only can always be used in any condition.
     *
     * @return Data profile by APN name and/or traffic descriptor. Either one of APN name or
     * traffic descriptor should be provided. {@code null} if data profile is not found.
     * @param dataProfile The data profile to check.
     * @return {@code true} if the provided data profile can be still used in current environment.
     */
    public @Nullable DataProfile getDataProfile(@Nullable String apnName,
            @Nullable TrafficDescriptor trafficDescriptor) {
        if (apnName == null && trafficDescriptor == null) return null;

        List<DataProfile> dataProfiles = mAllDataProfiles;

        // Check if any existing data profile has the same traffic descriptor.
        if (trafficDescriptor != null) {
            dataProfiles = mAllDataProfiles.stream()
                    .filter(dp -> trafficDescriptor.equals(dp.getTrafficDescriptor()))
                    .collect(Collectors.toList());
    public boolean isDataProfileCompatible(@NonNull DataProfile dataProfile) {
        if (dataProfile == null) {
            return false;
        }

        // Check if any existing data profile has the same APN name.
        if (apnName != null) {
            dataProfiles = dataProfiles.stream()
                    .filter(dp -> dp.getApnSetting() != null
                            && (dp.getApnSetting().getApnSetId()
                            == Telephony.Carriers.MATCH_ALL_APN_SET_ID
                            || dp.getApnSetting().getApnSetId() == mPreferredDataProfileSetId))
                    .filter(dp -> apnName.equals(dp.getApnSetting().getApnName()))
                    .collect(Collectors.toList());
        if (dataProfile.getApnSetting() == null && dataProfile.getTrafficDescriptor() != null) {
            // A traffic descriptor only data profile can be always used. Traffic descriptors are
            // always generated on the fly instead loaded from the database.
            return true;
        }

        return dataProfiles.isEmpty() ? null : dataProfiles.get(0);
        // Only check the APN from the profile is compatible or not.
        return mAllDataProfiles.stream()
                .filter(dp -> dp.getApnSetting() != null)
                .anyMatch(dp -> dp.getApnSetting().equals(dataProfile.getApnSetting(),
                        mPhone.getServiceState().getDataRoamingFromRegistration()));
    }

    /**
+13 −11
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ import java.util.UUID;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * DataRetryManager manages data network setup retry and its configurations.
@@ -1397,18 +1398,19 @@ public class DataRetryManager extends Handler {
            // equal to the data profiles kept in data profile manager (due to some fields missing
            // in DataProfileInfo.aidl), so we need to get the equivalent data profile from data
            // profile manager.
            final DataProfile dp = mDataProfileManager.getDataProfile(
                    dataProfile.getApnSetting() != null
                            ? dataProfile.getApnSetting().getApnName() : null,
                    dataProfile.getTrafficDescriptor());
            log("onDataProfileUnthrottled: getDataProfile=" + dp);
            if (dp != null) {
                dataUnthrottlingEntries = mDataThrottlingEntries.stream()
                        .filter(entry -> entry.expirationTimeMillis > now
                                && entry.dataProfile.equals(dp)
                                && entry.transport == transport)
                        .collect(Collectors.toList());
            log("onDataProfileUnthrottled: dataProfile=" + dataProfile);
            Stream<DataThrottlingEntry> stream = mDataThrottlingEntries.stream();
            stream = stream.filter(entry -> entry.expirationTimeMillis > now);
            if (dataProfile.getApnSetting() != null) {
                stream = stream
                        .filter(entry -> entry.dataProfile.getApnSetting() != null)
                        .filter(entry -> entry.dataProfile.getApnSetting().getApnName()
                                .equals(dataProfile.getApnSetting().getApnName()));
            }
            stream = stream.filter(entry -> Objects.equals(entry.dataProfile.getTrafficDescriptor(),
                    dataProfile.getTrafficDescriptor()));

            dataUnthrottlingEntries = stream.collect(Collectors.toList());
        } else if (apn != null) {
            // For HIDL 1.6 or below
            dataUnthrottlingEntries = mDataThrottlingEntries.stream()
+34 −11
Original line number Diff line number Diff line
@@ -221,14 +221,8 @@ public class DataSettingsManager extends Handler {
            }
            case EVENT_SET_DATA_ROAMING_ENABLED: {
                boolean enabled = (boolean) msg.obj;
                // Will trigger handleDataOnRoamingChange() through observer
                boolean changed = GlobalSettingsHelper.setBoolean(mPhone.getContext(),
                        Settings.Global.DATA_ROAMING, mSubId, enabled);
                if (changed) {
                    logl("DataRoamingEnabled changed to " + enabled);
                    mDataSettingsManagerCallbacks.forEach(callback -> callback.invokeFromExecutor(
                            () -> callback.onDataRoamingEnabledChanged(enabled)));
                }
                setDataRoamingEnabledInternal(enabled);
                setDataRoamingFromUserAction();
                break;
            }
            case EVENT_SET_ALWAYS_ALLOW_MMS_DATA: {
@@ -501,13 +495,28 @@ public class DataSettingsManager extends Handler {
    }

    /**
     * Enable or disable data roaming.
     * Enable or disable data roaming from user settings.
     * @param enabled {@code true} to enable data roaming and {@code false} to disable.
     */
    public void setDataRoamingEnabled(boolean enabled) {
        obtainMessage(EVENT_SET_DATA_ROAMING_ENABLED, enabled).sendToTarget();
    }

    /**
     * Enable or disable data roaming.
     * @param enabled {@code true} to enable data roaming and {@code false} to disable.
     */
    private void setDataRoamingEnabledInternal(boolean enabled) {
        // Will trigger handleDataOnRoamingChange() through observer
        boolean changed = GlobalSettingsHelper.setBoolean(mPhone.getContext(),
                Settings.Global.DATA_ROAMING, mSubId, enabled);
        if (changed) {
            logl("DataRoamingEnabled changed to " + enabled);
            mDataSettingsManagerCallbacks.forEach(callback -> callback.invokeFromExecutor(
                    () -> callback.onDataRoamingEnabledChanged(enabled)));
        }
    }

    /**
     * Check whether data roaming is enabled for the device based on the current
     * {@link Settings.Global#DATA_ROAMING} value.
@@ -537,7 +546,7 @@ public class DataSettingsManager extends Handler {
    public void setDefaultDataRoamingEnabled() {
        // For SSSS, this is a per-phone property from DATA_ROAMING_IS_USER_SETTING_KEY.
        // For DSDS, this is a per-sub property from Settings.Global.DATA_ROAMING + subId.
        // If the user has not manually set the value, use the default from carrier configurations.
        // If the user has not manually set the value, use the default value.
        boolean useCarrierSpecificDefault = false;
        if (mPhone.getContext().getSystemService(TelephonyManager.class).getSimCount() != 1) {
            String setting = Settings.Global.DATA_ROAMING + mPhone.getSubId();
@@ -554,7 +563,7 @@ public class DataSettingsManager extends Handler {
        log("setDefaultDataRoamingEnabled: useCarrierSpecificDefault=" + useCarrierSpecificDefault);
        if (useCarrierSpecificDefault) {
            boolean defaultVal = isDefaultDataRoamingEnabled();
            setDataRoamingEnabled(defaultVal);
            setDataRoamingEnabledInternal(defaultVal);
        }
    }

@@ -573,6 +582,17 @@ public class DataSettingsManager extends Handler {
        return sp.getBoolean(Phone.DATA_ROAMING_IS_USER_SETTING_KEY, true);
    }

    /**
     * Indicate that the user has manually enabled or disabled the data roaming value from settings.
     * If the user has not manually set the data roaming value, the default value from
     * {@link #isDefaultDataRoamingEnabled()} will continue to be used.
     */
    private void setDataRoamingFromUserAction() {
        final SharedPreferences.Editor sp = PreferenceManager
                .getDefaultSharedPreferences(mPhone.getContext()).edit();
        sp.putBoolean(Phone.DATA_ROAMING_IS_USER_SETTING_KEY, true).commit();
    }

    private @NonNull DataEnabledOverride getDataEnabledOverride() {
        return new DataEnabledOverride(SubscriptionController.getInstance()
                .getDataEnabledOverrideRules(mSubId));
@@ -724,6 +744,9 @@ public class DataSettingsManager extends Handler {
        pw.println("isDataEnabled(internet)=" + isDataEnabled(ApnSetting.TYPE_DEFAULT));
        pw.println("isDataEnabled(mms)=" + isDataEnabled(ApnSetting.TYPE_MMS));
        pw.println("isUserDataEnabled=" + isUserDataEnabled());
        pw.println("isDataRoamingEnabled=" + isDataRoamingEnabled());
        pw.println("isDefaultDataRoamingEnabled=" + isDefaultDataRoamingEnabled());
        pw.println("isDataRoamingFromUserAction=" + isDataRoamingFromUserAction());
        pw.println("device_provisioned=" + Settings.Global.getInt(
                mResolver, Settings.Global.DEVICE_PROVISIONED, 0));
        pw.println("isProvisioningDataEnabled=" + isProvisioningDataEnabled());
Loading