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

Commit 6cc8dc45 authored by Chalard Jean's avatar Chalard Jean Committed by Automerger Merge Worker
Browse files

Merge "Allow any transport with TEST if the network is restricted" am: 7e9223a7 am: a76cc4e9

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1702489

Change-Id: I8b42aa698f279774b8d5781811dc848c7d7ff713
parents d52c25c2 a76cc4e9
Loading
Loading
Loading
Loading
+14 −4
Original line number Original line Diff line number Diff line
@@ -830,8 +830,17 @@ public final class NetworkCapabilities implements Parcelable {
        final int[] originalAdministratorUids = getAdministratorUids();
        final int[] originalAdministratorUids = getAdministratorUids();
        final TransportInfo originalTransportInfo = getTransportInfo();
        final TransportInfo originalTransportInfo = getTransportInfo();
        clearAll();
        clearAll();
        mTransportTypes = (originalTransportTypes & TEST_NETWORKS_ALLOWED_TRANSPORTS)
        if (0 != (originalCapabilities & NET_CAPABILITY_NOT_RESTRICTED)) {
            // If the test network is not restricted, then it is only allowed to declare some
            // specific transports. This is to minimize impact on running apps in case an app
            // run from the shell creates a test a network.
            mTransportTypes =
                    (originalTransportTypes & UNRESTRICTED_TEST_NETWORKS_ALLOWED_TRANSPORTS)
                            | (1 << TRANSPORT_TEST);
                            | (1 << TRANSPORT_TEST);
        } else {
            // If the test transport is restricted, then it may declare any transport.
            mTransportTypes = (originalTransportTypes | (1 << TRANSPORT_TEST));
        }
        mNetworkCapabilities = originalCapabilities & TEST_NETWORKS_ALLOWED_CAPABILITIES;
        mNetworkCapabilities = originalCapabilities & TEST_NETWORKS_ALLOWED_CAPABILITIES;
        mNetworkSpecifier = originalSpecifier;
        mNetworkSpecifier = originalSpecifier;
        mSignalStrength = originalSignalStrength;
        mSignalStrength = originalSignalStrength;
@@ -935,9 +944,10 @@ public final class NetworkCapabilities implements Parcelable {
    };
    };


    /**
    /**
     * Allowed transports on a test network, in addition to TRANSPORT_TEST.
     * Allowed transports on an unrestricted test network (in addition to TRANSPORT_TEST).
     */
     */
    private static final int TEST_NETWORKS_ALLOWED_TRANSPORTS = 1 << TRANSPORT_TEST
    private static final int UNRESTRICTED_TEST_NETWORKS_ALLOWED_TRANSPORTS =
            1 << TRANSPORT_TEST
            // Test ethernet networks can be created with EthernetManager#setIncludeTestInterfaces
            // Test ethernet networks can be created with EthernetManager#setIncludeTestInterfaces
            | 1 << TRANSPORT_ETHERNET
            | 1 << TRANSPORT_ETHERNET
            // Test VPN networks can be created but their UID ranges must be empty.
            // Test VPN networks can be created but their UID ranges must be empty.