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

Commit 29b1b5be authored by lucaslin's avatar lucaslin Committed by Cherrypicker Worker
Browse files

Address leftover comments of ag/18112116

Bug: 225010642
Test: atest FrameworksNetTests:VpnTest
Change-Id: I0b129ec322159f608c447f608a4e11bed1971b55
(cherry picked from commit 5226b1f4)
Merged-In: I0b129ec322159f608c447f608a4e11bed1971b55
parent 09eab9ca
Loading
Loading
Loading
Loading
+28 −23
Original line number Diff line number Diff line
@@ -763,12 +763,20 @@ public class Vpn {
        // Also notify the new package if there was a provider change.
        final boolean shouldNotifyNewPkg = isVpnApp(packageName) && isPackageChanged;

        if (setAlwaysOnPackageInternal(packageName, lockdown, lockdownAllowlist)) {
        if (!setAlwaysOnPackageInternal(packageName, lockdown, lockdownAllowlist)) {
            return false;
        }

        saveAlwaysOnPackage();

        // TODO(b/230548427): Remove SDK check once VPN related stuff are decoupled from
        //  ConnectivityServiceTest.
            if (shouldNotifyOldPkg && SdkLevel.isAtLeastT()) {
                // If both of shouldNotifyOldPkg & isPackageChanged are true, which means the
        if (!SdkLevel.isAtLeastT()) {
            return true;
        }

        if (shouldNotifyOldPkg) {
            // If both of shouldNotifyOldPkg & isPackageChanged are true, that means the
            // always-on of old package is disabled or the old package is replaced with the new
            // package. In this case, VpnProfileState should be disconnected.
            sendEventToVpnManagerApp(VpnManager.CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED,
@@ -777,9 +785,8 @@ public class Vpn {
                            : makeVpnProfileStateLocked(),
                    null /* underlyingNetwork */, null /* nc */, null /* lp */);
        }
            // TODO(b/230548427): Remove SDK check once VPN related stuff are decoupled from
            //  ConnectivityServiceTest.
            if (shouldNotifyNewPkg && SdkLevel.isAtLeastT()) {

        if (shouldNotifyNewPkg) {
            sendEventToVpnManagerApp(VpnManager.CATEGORY_EVENT_ALWAYS_ON_STATE_CHANGED,
                    -1 /* errorClass */, -1 /* errorCode*/, packageName,
                    getSessionKeyLocked(), makeVpnProfileStateLocked(),
@@ -787,8 +794,6 @@ public class Vpn {
        }
        return true;
    }
        return false;
    }

    /**
     * Configures an always-on VPN connection through a specific application, the same as {@link