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

Commit 24177542 authored by chiachangwang's avatar chiachangwang
Browse files

Set vpn bypassability into VpnTransportInfo

Bypassability is available in VpnTransportInfo now. The value
should be read from VPN config and set to network capabilities
to apps to indicate the bypassability.

Bug: 256775913
Test: atest FrameworksNetTests
Change-Id: I8d59ecf69298e9c4f0f402cbeb7852f7067c0af8
parent a967fb80
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -620,7 +620,8 @@ public class Vpn {
                .addTransportType(NetworkCapabilities.TRANSPORT_VPN)
                .removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN)
                .addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VCN_MANAGED)
                .setTransportInfo(new VpnTransportInfo(VpnManager.TYPE_VPN_NONE, null))
                .setTransportInfo(new VpnTransportInfo(
                        VpnManager.TYPE_VPN_NONE, null /* sessionId */, false /* bypassable */))
                .build();

        loadAlwaysOnPackage();
@@ -684,7 +685,8 @@ public class Vpn {
    private void resetNetworkCapabilities() {
        mNetworkCapabilities = new NetworkCapabilities.Builder(mNetworkCapabilities)
                .setUids(null)
                .setTransportInfo(new VpnTransportInfo(VpnManager.TYPE_VPN_NONE, null))
                .setTransportInfo(new VpnTransportInfo(
                        VpnManager.TYPE_VPN_NONE, null /* sessionId */, false /* bypassable */))
                .build();
    }

@@ -1534,7 +1536,8 @@ public class Vpn {
        capsBuilder.setUids(createUserAndRestrictedProfilesRanges(mUserId,
                mConfig.allowedApplications, mConfig.disallowedApplications));

        capsBuilder.setTransportInfo(new VpnTransportInfo(getActiveVpnType(), mConfig.session));
        capsBuilder.setTransportInfo(
                new VpnTransportInfo(getActiveVpnType(), mConfig.session, mConfig.allowBypass));

        // Only apps targeting Q and above can explicitly declare themselves as metered.
        // These VPNs are assumed metered unless they state otherwise.