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

Commit e2dce3ff authored by Jeremy Goldman's avatar Jeremy Goldman Committed by Automerger Merge Worker
Browse files

Merge "Deprecation of legacy VPN types no longer depends on the Provider Model...

Merge "Deprecation of legacy VPN types no longer depends on the Provider Model Flag" into sc-v2-dev am: 2d529a4f

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/16221118

Change-Id: Ib2a07498176d2f156d1f82f956b8af754c376ea8
parents da06c920 2d529a4f
Loading
Loading
Loading
Loading
+19 −25
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ import androidx.appcompat.app.AlertDialog;
import com.android.internal.net.VpnProfile;
import com.android.net.module.util.ProxyUtils;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.utils.AndroidKeystoreAliasLoader;

import java.net.InetAddress;
@@ -518,18 +517,14 @@ class ConfigDialog extends AlertDialog implements TextWatcher,
        String[] types = getContext().getResources().getStringArray(R.array.vpn_types);
        mTotalTypes = new ArrayList<>(Arrays.asList(types));
        mAllowedTypes = new ArrayList<>(Arrays.asList(types));

        // Although FEATURE_IPSEC_TUNNELS should always be present in android S and beyond,
        // keep this check here just to be safe.
        if (!getContext().getPackageManager().hasSystemFeature(
                PackageManager.FEATURE_IPSEC_TUNNELS)) {
            final List<String> typesList = new ArrayList<>(Arrays.asList(types));

            // This must be removed from back to front in order to ensure index consistency
            typesList.remove(VpnProfile.TYPE_IKEV2_IPSEC_RSA);
            typesList.remove(VpnProfile.TYPE_IKEV2_IPSEC_PSK);
            typesList.remove(VpnProfile.TYPE_IKEV2_IPSEC_USER_PASS);

            types = typesList.toArray(new String[0]);
        } else if (Utils.isProviderModelEnabled(getContext())) {
            // If the provider mode is enabled and the vpn is new or is not already a legacy type,
            Log.wtf(TAG, "FEATURE_IPSEC_TUNNELS missing from system");
        }
        // If the vpn is new or is not already a legacy type,
        // don't allow the user to set the type to a legacy option.

        // Set the mProfile.type to TYPE_IKEV2_IPSEC_USER_PASS if the VPN not exist
@@ -548,7 +543,6 @@ class ConfigDialog extends AlertDialog implements TextWatcher,

            types = mAllowedTypes.toArray(new String[0]);
        }
        }
        final ArrayAdapter<String> adapter = new ArrayAdapter<String>(
                getContext(), android.R.layout.simple_spinner_item, types);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
+4 −6
Original line number Diff line number Diff line
@@ -59,7 +59,6 @@ import com.android.internal.net.VpnConfig;
import com.android.internal.net.VpnProfile;
import com.android.settings.R;
import com.android.settings.RestrictedSettingsFragment;
import com.android.settings.Utils;
import com.android.settings.widget.GearPreference;
import com.android.settings.widget.GearPreference.OnGearClickListener;
import com.android.settingslib.RestrictedLockUtilsInternal;
@@ -130,12 +129,11 @@ public class VpnSettings extends RestrictedSettingsFragment implements
    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);
        // Although FEATURE_IPSEC_TUNNELS should always be present in android S,
        // Although FEATURE_IPSEC_TUNNELS should always be present in android S and beyond,
        // keep this check here just to be safe.
        if (Utils.isProviderModelEnabled(getContext())
                && !getContext().getPackageManager().hasSystemFeature(
        if (!getContext().getPackageManager().hasSystemFeature(
                PackageManager.FEATURE_IPSEC_TUNNELS)) {
            Log.w(LOG_TAG, "FEATURE_IPSEC_TUNNELS missing from system, cannot create new VPNs");
            Log.wtf(LOG_TAG, "FEATURE_IPSEC_TUNNELS missing from system, cannot create new VPNs");
            return;
        } else {
            // By default, we should inflate this menu.