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

Commit 78e081d7 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix exempt IMS from single PDN arbitration" am: 2b02b5c6

parents 09a04d22 2b02b5c6
Loading
Loading
Loading
Loading
+25 −5
Original line number Diff line number Diff line
@@ -288,6 +288,8 @@ public class DataConfigManager extends Handler {
    /** The network types that only support single data networks */
    private @NonNull final @NetworkType List<Integer> mSingleDataNetworkTypeList =
            new ArrayList<>();
    private @NonNull final @NetCapability Set<Integer> mCapabilitiesExemptFromSingleDataList =
            new HashSet<>();
    /** The network types that support temporarily not metered */
    private @NonNull final @DataConfigNetworkType Set<String> mUnmeteredNetworkTypes =
            new HashSet<>();
@@ -458,13 +460,13 @@ public class DataConfigManager extends Handler {
        updateNetworkCapabilityPriority();
        updateDataRetryRules();
        updateMeteredApnTypes();
        updateSingleDataNetworkTypeList();
        updateSingleDataNetworkTypeAndCapabilityExemption();
        updateUnmeteredNetworkTypes();
        updateBandwidths();
        updateTcpBuffers();
        updateHandoverRules();

        log("Data config updated. Config is " + (isConfigCarrierSpecific() ? "" : "not ")
        log("Carrier config updated. Config is " + (isConfigCarrierSpecific() ? "" : "not ")
                + "carrier specific.");
    }

@@ -649,14 +651,21 @@ public class DataConfigManager extends Handler {
    /**
     * Update the network types for only single data networks from the carrier config.
     */
    private void updateSingleDataNetworkTypeList() {
    private void updateSingleDataNetworkTypeAndCapabilityExemption() {
        synchronized (this) {
            mSingleDataNetworkTypeList.clear();
            mCapabilitiesExemptFromSingleDataList.clear();
            int[] singleDataNetworkTypeList = mCarrierConfig.getIntArray(
                    CarrierConfigManager.KEY_ONLY_SINGLE_DC_ALLOWED_INT_ARRAY);
            if (singleDataNetworkTypeList != null) {
                Arrays.stream(singleDataNetworkTypeList)
                        .forEach(mSingleDataNetworkTypeList::add);
                Arrays.stream(singleDataNetworkTypeList).forEach(mSingleDataNetworkTypeList::add);
            }

            int[] singleDataCapabilitiesExemptList = mCarrierConfig.getIntArray(
                    CarrierConfigManager.KEY_CAPABILITIES_EXEMPT_FROM_SINGLE_DC_CHECK_INT_ARRAY);
            if (singleDataCapabilitiesExemptList != null) {
                Arrays.stream(singleDataCapabilitiesExemptList)
                        .forEach(mCapabilitiesExemptFromSingleDataList::add);
            }
        }
    }
@@ -668,6 +677,14 @@ public class DataConfigManager extends Handler {
        return Collections.unmodifiableList(mSingleDataNetworkTypeList);
    }

    /**
     * @return The list of {@link android.net.NetworkCapabilities.NetCapability} that every of which
     * is exempt from the single PDN check.
     */
    public @NonNull @NetCapability Set<Integer> getCapabilitiesExemptFromSingleDataNetwork() {
        return Collections.unmodifiableSet(mCapabilitiesExemptFromSingleDataList);
    }

    /**
     * @return Whether {@link NetworkCapabilities#NET_CAPABILITY_TEMPORARILY_NOT_METERED}
     * is supported by the carrier.
@@ -1289,6 +1306,9 @@ public class DataConfigManager extends Handler {
                .map(ApnSetting::getApnTypeString).collect(Collectors.joining(",")));
        pw.println("Single data network types=" + mSingleDataNetworkTypeList.stream()
                .map(TelephonyManager::getNetworkTypeName).collect(Collectors.joining(",")));
        pw.println("Capabilities exempt from single PDN=" + mCapabilitiesExemptFromSingleDataList
                .stream().map(DataUtils::networkCapabilityToString)
                .collect(Collectors.joining(",")));
        pw.println("Unmetered network types=" + String.join(",", mUnmeteredNetworkTypes));
        pw.println("Roaming unmetered network types="
                + String.join(",", mRoamingUnmeteredNetworkTypes));
+20 −8
Original line number Diff line number Diff line
@@ -1338,6 +1338,17 @@ public class DataNetworkController extends Handler {
                .contains(getDataNetworkType(transport));
    }

    /**
     * @param capabilities The Network Capabilities to be checked.
     * @return {@code true} if the capabilities contain any capability that's exempt from the single
     * PDN rule.
     */
    private boolean hasCapabilityExemptsFromSinglePdnRule(@NetCapability int[] capabilities) {
        Set<Integer> exemptCapabilities =
                mDataConfigManager.getCapabilitiesExemptFromSingleDataNetwork();
        return Arrays.stream(capabilities).anyMatch(exemptCapabilities::contains);
    }

    /**
     * Evaluate if telephony frameworks would allow data setup for internet in current environment.
     *
@@ -1502,13 +1513,12 @@ public class DataNetworkController extends Handler {
        }

        // Check if only one data network is allowed.
        // Note any IMS network is ignored for the single-connection rule.
        if (isOnlySingleDataNetworkAllowed(transport)
                && !networkRequest.hasCapability(NetworkCapabilities.NET_CAPABILITY_IMS)) {
            // if exists non-IMS network
                && !hasCapabilityExemptsFromSinglePdnRule(networkRequest.getCapabilities())) {
            // if exists not-exempt network.
            if (mDataNetworkList.stream()
                    .anyMatch(dataNetwork -> !dataNetwork.getNetworkCapabilities()
                                    .hasCapability(NetworkCapabilities.NET_CAPABILITY_IMS))) {
                    .anyMatch(dataNetwork -> !hasCapabilityExemptsFromSinglePdnRule(
                            dataNetwork.getNetworkCapabilities().getCapabilities()))) {
                evaluation.addDataDisallowedReason(
                        DataDisallowedReason.ONLY_ALLOWED_SINGLE_NETWORK);
            }
@@ -1671,16 +1681,18 @@ public class DataNetworkController extends Handler {
        }

        // Check if there are other network that has higher priority, and only single data network
        // is allowed. Note IMS network is exempt from the single-connection rule.
        // is allowed.
        if (isOnlySingleDataNetworkAllowed(dataNetwork.getTransport())
                && !dataNetwork.getNetworkCapabilities()
                .hasCapability(NetworkCapabilities.NET_CAPABILITY_IMS)) {
                && !hasCapabilityExemptsFromSinglePdnRule(
                        dataNetwork.getNetworkCapabilities().getCapabilities())) {
            // If there is network request that has higher priority than this data network, then
            // tear down the network, regardless that network request is satisfied or not.
            if (mAllNetworkRequestList.stream()
                    .filter(request -> dataNetwork.getTransport()
                            == mAccessNetworksManager.getPreferredTransportByNetworkCapability(
                                    request.getApnTypeNetworkCapability()))
                    .filter(request
                            -> !hasCapabilityExemptsFromSinglePdnRule(request.getCapabilities()))
                    .anyMatch(request -> request.getPriority() > dataNetwork.getPriority())) {
                evaluation.addDataDisallowedReason(
                        DataDisallowedReason.ONLY_ALLOWED_SINGLE_NETWORK);
+24 −1
Original line number Diff line number Diff line
@@ -209,6 +209,7 @@ public class DataNetworkControllerTest extends TelephonyTest {
                    .setNetworkTypeBitmask((int) (TelephonyManager.NETWORK_TYPE_BITMASK_LTE
                            | TelephonyManager.NETWORK_TYPE_BITMASK_1xRTT))
                    .setLingeringNetworkTypeBitmask((int) (TelephonyManager.NETWORK_TYPE_BITMASK_LTE
                            | TelephonyManager.NETWORK_TYPE_BITMASK_1xRTT
                            | TelephonyManager.NETWORK_TYPE_BITMASK_IWLAN
                            | TelephonyManager.NETWORK_TYPE_BITMASK_UMTS
                            | TelephonyManager.NETWORK_TYPE_BITMASK_NR))
@@ -619,6 +620,10 @@ public class DataNetworkControllerTest extends TelephonyTest {
                        TelephonyManager.NETWORK_TYPE_EVDO_0, TelephonyManager.NETWORK_TYPE_EVDO_A,
                        TelephonyManager.NETWORK_TYPE_EVDO_B});

        mCarrierConfig.putIntArray(CarrierConfigManager
                        .KEY_CAPABILITIES_EXEMPT_FROM_SINGLE_DC_CHECK_INT_ARRAY,
                new int[]{NetworkCapabilities.NET_CAPABILITY_IMS});

        mContextFixture.putResource(com.android.internal.R.string.config_bandwidthEstimateSource,
                "bandwidth_estimator");

@@ -1821,13 +1826,22 @@ public class DataNetworkControllerTest extends TelephonyTest {
        verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_IMS,
                NetworkCapabilities.NET_CAPABILITY_MMTEL);

        // Add internet, should be compatible with
        // Add internet, should be compatible
        mDataNetworkControllerUT.addNetworkRequest(
                createNetworkRequest(NetworkCapabilities.NET_CAPABILITY_INTERNET));
        setSuccessfulSetupDataResponse(mMockedDataServiceManagers
                .get(AccessNetworkConstants.TRANSPORT_TYPE_WWAN), 2);
        processAllMessages();

        verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_INTERNET);
        verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_IMS,
                NetworkCapabilities.NET_CAPABILITY_MMTEL);

        // Both internet and IMS should be retained after network re-evaluation
        mDataNetworkControllerUT.obtainMessage(16/*EVENT_REEVALUATE_EXISTING_DATA_NETWORKS*/)
                .sendToTarget();
        processAllMessages();

        verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_INTERNET);
        verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_IMS,
                NetworkCapabilities.NET_CAPABILITY_MMTEL);
@@ -1839,6 +1853,15 @@ public class DataNetworkControllerTest extends TelephonyTest {
                .get(AccessNetworkConstants.TRANSPORT_TYPE_WWAN), 3);
        processAllMessages();

        verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_MMS);
        verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_IMS,
                NetworkCapabilities.NET_CAPABILITY_MMTEL);

        // Both internet and IMS should be retained after network re-evaluation
        mDataNetworkControllerUT.obtainMessage(16/*EVENT_REEVALUATE_EXISTING_DATA_NETWORKS*/)
                .sendToTarget();
        processAllMessages();

        verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_MMS);
        verifyConnectedNetworkHasCapabilities(NetworkCapabilities.NET_CAPABILITY_IMS,
                NetworkCapabilities.NET_CAPABILITY_MMTEL);
+1 −1

File changed.

Contains only whitespace changes.