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

Commit 60191a91 authored by Ling Ma's avatar Ling Ma
Browse files

Configure satellite network capabilities

For a satellite network, remove the unsupported characteristic
capabilities. If the network is unrestricted, it must be constrained.
If it's restricted, dont remove not_constrained bit so that caller
doesnt have to make changes.

Bug: 339688297
Test: basic voice call + reviewed bugreport

Change-Id: Iff9fffab307c94d3490033a6ef80b962df7befba
parent 71084453
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -714,8 +714,7 @@ public class DataConfigManager extends Handler {
    /**
     * Update the voice over PS related config from the carrier config.
     */
    private void updateVopsConfig() {
        synchronized (this) {
    private synchronized void updateVopsConfig() {
            mShouldKeepNetworkUpInNonVops = mCarrierConfig.getBoolean(CarrierConfigManager
                    .Ims.KEY_KEEP_PDN_UP_IN_NO_VOPS_BOOL);
            int[] allowedNetworkTypes = mCarrierConfig.getIntArray(
@@ -724,7 +723,6 @@ public class DataConfigManager extends Handler {
                Arrays.stream(allowedNetworkTypes).forEach(mEnabledVopsNetworkTypesInNonVops::add);
            }
    }
    }

    /**
     * @return The list of {@link NetworkType} that only supports single data networks
@@ -885,6 +883,14 @@ public class DataConfigManager extends Handler {
        return new DataNetwork.NetworkBandwidth(DEFAULT_BANDWIDTH, DEFAULT_BANDWIDTH);
    }

    /**
     * @return What kind of traffic is supported on an unrestricted satellite network.
     */
    @CarrierConfigManager.SATELLITE_DATA_SUPPORT_MODE
    public int getSatelliteDataSupportMode() {
        return mCarrierConfig.getInt(CarrierConfigManager.KEY_SATELLITE_DATA_SUPPORT_MODE_INT);
    }

    /**
     * @return Whether data throttling should be reset when the TAC changes from the carrier config.
     */
+18 −5
Original line number Diff line number Diff line
@@ -2445,6 +2445,7 @@ public class DataNetwork extends StateMachine {
        }

        // Always start with not-restricted, and then remove if needed.
        // By default, NET_CAPABILITY_NOT_RESTRICTED and NET_CAPABILITY_NOT_CONSTRAINED are included
        builder.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);

        // When data is disabled, or data roaming is disabled and the device is roaming, we need
@@ -2483,11 +2484,6 @@ public class DataNetwork extends StateMachine {
            builder.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);
        }

        // mark the network as restricted when service state is non-terrestrial(satellite network)
        if (mFlags.satelliteInternet() && mIsSatellite) {
            builder.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);
        }

        // Check if the feature force MMS on IWLAN is enabled. When the feature is enabled, MMS
        // will be attempted on IWLAN if possible, even if existing cellular networks already
        // supports IWLAN.
@@ -2529,6 +2525,23 @@ public class DataNetwork extends StateMachine {
        builder.setLinkDownstreamBandwidthKbps(mNetworkBandwidth.downlinkBandwidthKbps);
        builder.setLinkUpstreamBandwidthKbps(mNetworkBandwidth.uplinkBandwidthKbps);

        // Configure the network as restricted/constrained for unrestricted satellite network.
        if (mFlags.satelliteInternet() && mIsSatellite && builder.build()
                .hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED)) {
            switch (mDataConfigManager.getSatelliteDataSupportMode()) {
                case CarrierConfigManager.SATELLITE_DATA_SUPPORT_ONLY_RESTRICTED
                        -> builder.removeCapability(
                                NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);
                case CarrierConfigManager.SATELLITE_DATA_SUPPORT_BANDWIDTH_CONSTRAINED -> {
                    try {
                        builder.removeCapability(DataUtils
                                .NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED);
                    } catch (Exception ignored) { }
                }
                // default case CarrierConfigManager.SATELLITE_DATA_SUPPORT_ALL
            }
        }

        NetworkCapabilities nc = builder.build();
        if (mNetworkCapabilities == null || mNetworkAgent == null) {
            // This is the first time when network capabilities is created. The agent is not created
+24 −21
Original line number Diff line number Diff line
@@ -1947,24 +1947,14 @@ public class DataNetworkController extends Handler {
        // If the network is satellite, then the network must be restricted.
        if (mFeatureFlags.satelliteInternet()) {
            // The IWLAN data network should remain intact even when satellite is connected.
            if (dataNetwork.getTransport() != AccessNetworkConstants.TRANSPORT_TYPE_WLAN) {
                // On satellite, every data network needs to be restricted.
                if (mServiceState.isUsingNonTerrestrialNetwork()
                        && dataNetwork.getNetworkCapabilities()
                        .hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED)) {
                    evaluation.addDataDisallowedReason(
                            DataDisallowedReason.DATA_NETWORK_TRANSPORT_NOT_ALLOWED);
                }

                // Check if the transport is compatible with the network
                if (mServiceState.isUsingNonTerrestrialNetwork() != dataNetwork.isSatellite()) {
            if (dataNetwork.getTransport() != AccessNetworkConstants.TRANSPORT_TYPE_WLAN
                    && mServiceState.isUsingNonTerrestrialNetwork() != dataNetwork.isSatellite()) {
                // Since we don't support satellite/cellular network handover, we should always
                // tear down the network when transport changes.
                evaluation.addDataDisallowedReason(
                        DataDisallowedReason.DATA_NETWORK_TRANSPORT_NOT_ALLOWED);
            }
        }
        }

        // Check whether data limit reached for bootstrap sim, else re-evaluate based on the timer
        // set.
@@ -2171,12 +2161,25 @@ public class DataNetworkController extends Handler {
            return true;
        }

        // When the device is on satellite, only restricted network request can request network.
        if (mServiceState.isUsingNonTerrestrialNetwork()
                && networkRequest.hasCapability(
        // When the device is on satellite, only restricted/constrained network request can request
        // network.
        if (mServiceState.isUsingNonTerrestrialNetwork() && networkRequest.hasCapability(
                NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED)) {
            switch (mDataConfigManager.getSatelliteDataSupportMode()) {
                case CarrierConfigManager.SATELLITE_DATA_SUPPORT_ONLY_RESTRICTED -> {
                    return false;
                }
                case CarrierConfigManager.SATELLITE_DATA_SUPPORT_BANDWIDTH_CONSTRAINED -> {
                    try {
                        if (networkRequest.hasCapability(DataUtils
                                .NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED)) {
                            return false;
                        }
                    } catch (Exception ignored) { }
                }
                // default case CarrierConfigManager.SATELLITE_DATA_SUPPORT_ALL
            }
        }

        // If the network request does not specify cellular or satellite, then it can be
        // satisfied when the device is either on cellular ot satellite.
+2 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import java.util.stream.Collectors;
 * This class contains all the utility methods used by telephony data stack.
 */
public class DataUtils {
    public static final int NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED = 37;
    /** The time format for converting time to readable string. */
    private static final SimpleDateFormat TIME_FORMAT =
            new SimpleDateFormat("HH:mm:ss.SSS", Locale.US);
@@ -165,6 +166,7 @@ public class DataUtils {
            case NetworkCapabilities.NET_CAPABILITY_MMTEL -> "MMTEL";
            case NetworkCapabilities.NET_CAPABILITY_PRIORITIZE_LATENCY -> "PRIORITIZE_LATENCY";
            case NetworkCapabilities.NET_CAPABILITY_PRIORITIZE_BANDWIDTH -> "PRIORITIZE_BANDWIDTH";
            case NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED -> "NOT_BANDWIDTH_CONSTRAINED";
            default -> {
                loge("Unknown network capability(" + netCap + ")");
                yield "Unknown(" + netCap + ")";
+70 −4
Original line number Diff line number Diff line
@@ -5052,18 +5052,84 @@ public class DataNetworkControllerTest extends TelephonyTest {

    @Test
    public void testNonTerrestrialNetwork() throws Exception {
        TelephonyNetworkRequest request;
        mIsNonTerrestrialNetwork = true;
        serviceStateChanged(TelephonyManager.NETWORK_TYPE_LTE,
                NetworkRegistrationInfo.REGISTRATION_STATE_HOME);
        mDataNetworkControllerUT.addNetworkRequest(
                createNetworkRequest(false, NetworkCapabilities.NET_CAPABILITY_RCS));
        // By default, Test only support restricted network, regardless whether constrained.
        // Verify not_restricted network not supported.
        request = createNetworkRequest(false, NetworkCapabilities.NET_CAPABILITY_RCS);
        mDataNetworkControllerUT.addNetworkRequest(request);
        processAllMessages();
        verifyAllDataDisconnected();
        mDataNetworkControllerUT.removeNetworkRequest(request);

        mDataNetworkControllerUT.addNetworkRequest(
                createNetworkRequest(true, NetworkCapabilities.NET_CAPABILITY_RCS));
        // Verify restricted network is supported.
        request = createNetworkRequest(true, NetworkCapabilities.NET_CAPABILITY_RCS);
        mDataNetworkControllerUT.addNetworkRequest(request);
        processAllMessages();
        verifyConnectedNetworkHasDataProfile(mNtnDataProfile);
        mDataNetworkControllerUT.removeNetworkRequest(request);
        getDataNetworks().get(0).tearDown(DataNetwork
                .TEAR_DOWN_REASON_CONNECTIVITY_SERVICE_UNWANTED);

        // Test constrained network is supported, regardless whether it's restricted
        processAllFutureMessages();
        verifyAllDataDisconnected();
        mCarrierConfig.putInt(CarrierConfigManager.KEY_SATELLITE_DATA_SUPPORT_MODE_INT,
                CarrierConfigManager.SATELLITE_DATA_SUPPORT_BANDWIDTH_CONSTRAINED);
        carrierConfigChanged();
        // Verify not_restricted, not_constrained network not supported.
        NetworkCapabilities netCaps = new NetworkCapabilities();
        netCaps.addCapability(NetworkCapabilities.NET_CAPABILITY_RCS);
        try {
            netCaps.addCapability(DataUtils.NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED);
        } catch (Exception ignored) { }
        request = new TelephonyNetworkRequest(new NetworkRequest(netCaps,
                ConnectivityManager.TYPE_MOBILE, ++mNetworkRequestId,
                NetworkRequest.Type.REQUEST), mPhone, mFeatureFlags);

        mDataNetworkControllerUT.addNetworkRequest(request);
        processAllMessages();
        verifyAllDataDisconnected();
        mDataNetworkControllerUT.removeNetworkRequest(request);

        // Verify restricted, not_constrained network is supported.
        netCaps = new NetworkCapabilities();
        netCaps.addCapability(NetworkCapabilities.NET_CAPABILITY_RCS);
        netCaps.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED);
        try {
            netCaps.addCapability(DataUtils.NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED);
        } catch (Exception ignored) { }
        request = new TelephonyNetworkRequest(new NetworkRequest(netCaps,
                ConnectivityManager.TYPE_MOBILE, ++mNetworkRequestId,
                NetworkRequest.Type.REQUEST), mPhone, mFeatureFlags);
        mDataNetworkControllerUT.addNetworkRequest(request);
        processAllMessages();
        verifyConnectedNetworkHasDataProfile(mNtnDataProfile);
        mDataNetworkControllerUT.removeNetworkRequest(request);
        getDataNetworks().get(0).tearDown(DataNetwork
                .TEAR_DOWN_REASON_CONNECTIVITY_SERVICE_UNWANTED);

        // TODO(enable after NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED become a default cap)
        // Test not constrained network supported
//        processAllFutureMessages();
//        verifyAllDataDisconnected();
//        mCarrierConfig.putInt(CarrierConfigManager.KEY_SATELLITE_DATA_SUPPORT_MODE_INT,
//                CarrierConfigManager.SATELLITE_DATA_SUPPORT_ALL);
//        carrierConfigChanged();
//
//        netCaps = new NetworkCapabilities();
//        netCaps.addCapability(NetworkCapabilities.NET_CAPABILITY_RCS);
//        try {
//            netCaps.addCapability(DataUtils.NET_CAPABILITY_NOT_BANDWIDTH_CONSTRAINED);
//        } catch (Exception ignored) {}
//        mDataNetworkControllerUT.addNetworkRequest(
//                new TelephonyNetworkRequest(new NetworkRequest(netCaps,
//                        ConnectivityManager.TYPE_MOBILE, ++mNetworkRequestId,
//                        NetworkRequest.Type.REQUEST), mPhone, mFeatureFlags));
//        processAllMessages();
//        verifyConnectedNetworkHasDataProfile(mNtnDataProfile);
    }

    @Test
Loading