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

Commit 35016bb4 authored by Yeabkal Wubshit's avatar Yeabkal Wubshit Committed by Android (Google) Code Review
Browse files

Merge "Do null-checks before accessing VpnManager in DevicePolicyManagerService" into main

parents 0d8dc2ee e9fec511
Loading
Loading
Loading
Loading
+24 −6
Original line number Diff line number Diff line
@@ -1378,7 +1378,10 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        // Clear always-on configuration if it wasn't set by the admin.
        if (adminConfiguredVpnPkg == null) {
            mInjector.getVpnManager().setAlwaysOnVpnPackageForUser(userId, null, false, null);
            VpnManager vpnManager = mInjector.getVpnManager();
            if (vpnManager != null) {
                vpnManager.setAlwaysOnVpnPackageForUser(userId, null, false, null);
            }
        }
        // Clear app authorizations to establish VPNs. When DISALLOW_CONFIG_VPN is enforced apps
@@ -1789,6 +1792,7 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
            return mContext.getSystemService(ConnectivityManager.class);
        }
        @Nullable
        VpnManager getVpnManager() {
            return mContext.getSystemService(VpnManager.class);
        }
@@ -7704,7 +7708,9 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                }
            }
            // If some package is uninstalled after the check above, it will be ignored by CM.
            if (!mInjector.getVpnManager().setAlwaysOnVpnPackageForUser(
            VpnManager vpnManager = mInjector.getVpnManager();
            if (vpnManager == null
                    || !mInjector.getVpnManager().setAlwaysOnVpnPackageForUser(
                            userId, vpnPackage, lockdown, lockdownAllowlist)) {
                throw new UnsupportedOperationException();
            }
@@ -7753,8 +7759,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        Preconditions.checkCallAuthorization(
                isDefaultDeviceOwner(caller) || isProfileOwner(caller));
        VpnManager vpnManager = mInjector.getVpnManager();
        if (vpnManager == null) {
            return null;
        }
        return mInjector.binderWithCleanCallingIdentity(
                () -> mInjector.getVpnManager().getAlwaysOnVpnPackageForUser(caller.getUserId()));
                () -> vpnManager.getAlwaysOnVpnPackageForUser(caller.getUserId()));
    }
    @Override
@@ -7781,8 +7791,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
                    isDefaultDeviceOwner(caller) || isProfileOwner(caller));
        }
        VpnManager vpnManager = mInjector.getVpnManager();
        if (vpnManager == null) {
            return false;
        }
        return mInjector.binderWithCleanCallingIdentity(
                () -> mInjector.getVpnManager().isVpnLockdownEnabled(caller.getUserId()));
                () -> vpnManager.isVpnLockdownEnabled(caller.getUserId()));
    }
    @Override
@@ -7804,8 +7818,12 @@ public class DevicePolicyManagerService extends IDevicePolicyManager.Stub {
        Preconditions.checkCallAuthorization(
                isDefaultDeviceOwner(caller) || isProfileOwner(caller));
        VpnManager vpnManager = mInjector.getVpnManager();
        if (vpnManager == null) {
            return null;
        }
        return mInjector.binderWithCleanCallingIdentity(
                () -> mInjector.getVpnManager().getVpnLockdownAllowlist(caller.getUserId()));
                () -> vpnManager.getVpnLockdownAllowlist(caller.getUserId()));
    }
    private void forceWipeDeviceNoLock(boolean wipeExtRequested, String reason, boolean wipeEuicc,