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

Commit 558a160f authored by Lucas Lin's avatar Lucas Lin Committed by Automerger Merge Worker
Browse files

Merge "Fix Ikev2 vpn cannot establish through startLegacyVpn()" into sc-dev am: 30d17bd9

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

Change-Id: Ia2405b8f996b91b357e6eab9d793f572013fdc45
parents 772eb813 30d17bd9
Loading
Loading
Loading
Loading
+8 −5
Original line number Original line Diff line number Diff line
@@ -377,12 +377,15 @@ public final class VpnProfile implements Cloneable, Parcelable {
    /** Checks if this profile specifies a LegacyVpn type. */
    /** Checks if this profile specifies a LegacyVpn type. */
    public static boolean isLegacyType(int type) {
    public static boolean isLegacyType(int type) {
        switch (type) {
        switch (type) {
            case VpnProfile.TYPE_IKEV2_IPSEC_USER_PASS: // fall through
            case VpnProfile.TYPE_PPTP:
            case VpnProfile.TYPE_IKEV2_IPSEC_RSA: // fall through
            case VpnProfile.TYPE_L2TP_IPSEC_PSK:
            case VpnProfile.TYPE_IKEV2_IPSEC_PSK:
            case VpnProfile.TYPE_L2TP_IPSEC_RSA:
                return false;
            case VpnProfile.TYPE_IPSEC_XAUTH_PSK:
            default:
            case VpnProfile.TYPE_IPSEC_XAUTH_RSA:
            case VpnProfile.TYPE_IPSEC_HYBRID_RSA:
                return true;
                return true;
            default:
                return false;
        }
        }
    }
    }


+2 −1
Original line number Original line Diff line number Diff line
@@ -357,7 +357,8 @@ public class VpnManagerService extends IVpnManager.Stub {
    @SuppressWarnings("AndroidFrameworkCompatChange")  // This is not an app-visible API.
    @SuppressWarnings("AndroidFrameworkCompatChange")  // This is not an app-visible API.
    @Override
    @Override
    public void startLegacyVpn(VpnProfile profile) {
    public void startLegacyVpn(VpnProfile profile) {
        if (Build.VERSION.DEVICE_INITIAL_SDK_INT >= Build.VERSION_CODES.S) {
        if (Build.VERSION.DEVICE_INITIAL_SDK_INT >= Build.VERSION_CODES.S
                && VpnProfile.isLegacyType(profile.type)) {
            throw new UnsupportedOperationException("Legacy VPN is deprecated");
            throw new UnsupportedOperationException("Legacy VPN is deprecated");
        }
        }
        int user = UserHandle.getUserId(mDeps.getCallingUid());
        int user = UserHandle.getUserId(mDeps.getCallingUid());