Remove the "+" button on the help menu if no secure vpns can be created

If the provider model is turned on, all new VPNs must have the secure
type. However, there is a system property which is necessary in order to
create secure VPNs. So if the FEATURE_IPSEC_TUNNELS is missing from the
device then we should not enable new 1st party VPNs.

Note, it has been confirmed with the VPN team that we don't expect any
devices released on S to actually be missing this property, but it's
still good to check just in case.

Bug: 176821216
Test: atest -c SettingsUnitTest
Change-Id: I712d342e1970243520612196ba57227b1ff05bbf
This commit is contained in:
Jeremy Goldman
2021-04-19 16:39:56 +08:00
parent abc82d2606
commit 5be88d11de

View File

@@ -59,6 +59,7 @@ import com.android.internal.net.VpnConfig;
import com.android.internal.net.VpnProfile; import com.android.internal.net.VpnProfile;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.RestrictedSettingsFragment; import com.android.settings.RestrictedSettingsFragment;
import com.android.settings.Utils;
import com.android.settings.widget.GearPreference; import com.android.settings.widget.GearPreference;
import com.android.settings.widget.GearPreference.OnGearClickListener; import com.android.settings.widget.GearPreference.OnGearClickListener;
import com.android.settingslib.RestrictedLockUtilsInternal; import com.android.settingslib.RestrictedLockUtilsInternal;
@@ -129,7 +130,17 @@ public class VpnSettings extends RestrictedSettingsFragment implements
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.vpn, menu); // Although FEATURE_IPSEC_TUNNELS should always be present in android S,
// keep this check here just to be safe.
if (Utils.isProviderModelEnabled(getContext())
&& !getContext().getPackageManager().hasSystemFeature(
PackageManager.FEATURE_IPSEC_TUNNELS)) {
Log.w(LOG_TAG, "FEATURE_IPSEC_TUNNELS missing from system, cannot create new VPNs");
return;
} else {
// By default, we should inflate this menu.
inflater.inflate(R.menu.vpn, menu);
}
} }
@Override @Override