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

Commit 91fc38b3 authored by Lorenzo Colitti's avatar Lorenzo Colitti
Browse files

Stop using ConnectivityManager for VPNs in DPMS.

These methods have all moved to VpnManager.

Bug: 173331190
Test: atest com.android.server.devicepolicy.DevicePolicyManagerTest
Test: atest MixedDeviceOwnerTest#testAlwaysOnVpn \
            MixedDeviceOwnerTest#testAlwaysOnVpnLockDown \
            MixedDeviceOwnerTest#testAlwaysOnVpnAcrossReboot \
            MixedDeviceOwnerTest#testAlwaysOnVpnPackageUninstalled \
            MixedDeviceOwnerTest#testAlwaysOnVpnUnsupportedPackage \
            MixedDeviceOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced \
            MixedDeviceOwnerTest#testAlwaysOnVpnPackageLogged \
            MixedProfileOwnerTest#testAlwaysOnVpn \
            MixedProfileOwnerTest#testAlwaysOnVpnLockDown \
            MixedProfileOwnerTest#testAlwaysOnVpnAcrossReboot \
            MixedProfileOwnerTest#testAlwaysOnVpnPackageUninstalled \
            MixedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackage \
            MixedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced \
            MixedProfileOwnerTest#testAlwaysOnVpnPackageLogged \
            MixedManagedProfileOwnerTest#testAlwaysOnVpn \
            MixedManagedProfileOwnerTest#testAlwaysOnVpnLockDown \
            MixedManagedProfileOwnerTest#testAlwaysOnVpnAcrossReboot \
            MixedManagedProfileOwnerTest#testAlwaysOnVpnPackageUninstalled \
            MixedManagedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackage \
            MixedManagedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced \
            MixedManagedProfileOwnerTest#testAlwaysOnVpnPackageLogged
Change-Id: I46d9a7768546139690154b1ee1e1bf716b3a2c17
parent e8c108af
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -221,6 +221,7 @@ import android.net.ConnectivityManager;
import android.net.IIpConnectivityMetrics;
import android.net.ProxyInfo;
import android.net.Uri;
import android.net.VpnManager;
import android.net.metrics.IpConnectivityLog;
import android.net.wifi.WifiManager;
import android.os.Binder;
@@ -1262,6 +1263,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
            return mContext.getSystemService(ConnectivityManager.class);
        }
        VpnManager getVpnManager() {
            return mContext.getSystemService(VpnManager.class);
        }
        LocationManager getLocationManager() {
            return mContext.getSystemService(LocationManager.class);
        }
@@ -6292,7 +6297,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                }
            }
            // If some package is uninstalled after the check above, it will be ignored by CM.
            if (!mInjector.getConnectivityManager().setAlwaysOnVpnPackageForUser(
            if (!mInjector.getVpnManager().setAlwaysOnVpnPackageForUser(
                    userId, vpnPackage, lockdown, lockdownAllowlist)) {
                throw new UnsupportedOperationException();
            }
@@ -6324,8 +6329,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        Preconditions.checkCallAuthorization(isDeviceOwner(caller) || isProfileOwner(caller));
        return mInjector.binderWithCleanCallingIdentity(
                () -> mInjector.getConnectivityManager().getAlwaysOnVpnPackageForUser(
                        caller.getUserId()));
                () -> mInjector.getVpnManager().getAlwaysOnVpnPackageForUser(caller.getUserId()));
    }
    @Override
@@ -6351,7 +6355,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        }
        return mInjector.binderWithCleanCallingIdentity(
                () -> mInjector.getConnectivityManager().isVpnLockdownEnabled(caller.getUserId()));
                () -> mInjector.getVpnManager().isVpnLockdownEnabled(caller.getUserId()));
    }
    @Override
@@ -6372,8 +6376,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
        Preconditions.checkCallAuthorization(isDeviceOwner(caller) || isProfileOwner(caller));
        return mInjector.binderWithCleanCallingIdentity(
                () -> mInjector.getConnectivityManager().getVpnLockdownAllowlist(
                        caller.getUserId()));
                () -> mInjector.getVpnManager().getVpnLockdownAllowlist(caller.getUserId()));
    }
    private void forceWipeDeviceNoLock(boolean wipeExtRequested, String reason, boolean wipeEuicc,