diff options
author | Benedict Wong <benedictwong@google.com> | 2019-11-06 00:20:15 -0800 |
---|---|---|
committer | Benedict Wong <benedictwong@google.com> | 2020-02-04 21:05:36 +0000 |
commit | 526e7dd0b67a5e0ac22ec6966686a6116dcecb0a (patch) | |
tree | 697e5a2c7d27ae38885f1657a157084e5f1316d3 /packages/VpnDialogs/src | |
parent | dc63bcc1357ddf784a6531ed0eb6b4910182d2a0 (diff) |
Add separate user consent for Platform VPNs
This change adds a new VPN user consent flow (using the same text) for
granting the lesser OP_ACTIVATE_PLATFORM_VPN. A new
PlatformVpnConfirmDialog is created as a subclass to preserve all logic,
but ensure the right appop is granted for the relevant dialog.
Intent extras were considered, but are inherently unsafe, since the
caller may add any extras that they would want.
Bug: 144246835
Test: FrameworksNetTests passing
Change-Id: Ia6f36207d43c3748f938430c2780dcf29e5623f3
Merged-In: Ia6f36207d43c3748f938430c2780dcf29e5623f3
Diffstat (limited to 'packages/VpnDialogs/src')
-rw-r--r-- | packages/VpnDialogs/src/com/android/vpndialogs/ConfirmDialog.java | 13 | ||||
-rw-r--r-- | packages/VpnDialogs/src/com/android/vpndialogs/PlatformVpnConfirmDialog.java | 29 |
2 files changed, 41 insertions, 1 deletions
diff --git a/packages/VpnDialogs/src/com/android/vpndialogs/ConfirmDialog.java b/packages/VpnDialogs/src/com/android/vpndialogs/ConfirmDialog.java index 48adb9ba3f63..e66f2cc17a7f 100644 --- a/packages/VpnDialogs/src/com/android/vpndialogs/ConfirmDialog.java +++ b/packages/VpnDialogs/src/com/android/vpndialogs/ConfirmDialog.java @@ -23,6 +23,7 @@ import android.content.DialogInterface; import android.content.pm.PackageManager; import android.graphics.drawable.Drawable; import android.net.IConnectivityManager; +import android.net.VpnManager; import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; @@ -43,10 +44,20 @@ public class ConfirmDialog extends AlertActivity implements DialogInterface.OnClickListener, ImageGetter { private static final String TAG = "VpnConfirm"; + @VpnManager.VpnType private final int mVpnType; + private String mPackage; private IConnectivityManager mService; + public ConfirmDialog() { + this(VpnManager.TYPE_VPN_SERVICE); + } + + public ConfirmDialog(@VpnManager.VpnType int vpnType) { + mVpnType = vpnType; + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -138,7 +149,7 @@ public class ConfirmDialog extends AlertActivity if (mService.prepareVpn(null, mPackage, UserHandle.myUserId())) { // Authorize this app to initiate VPN connections in the future without user // intervention. - mService.setVpnPackageAuthorization(mPackage, UserHandle.myUserId(), true); + mService.setVpnPackageAuthorization(mPackage, UserHandle.myUserId(), mVpnType); setResult(RESULT_OK); } } catch (Exception e) { diff --git a/packages/VpnDialogs/src/com/android/vpndialogs/PlatformVpnConfirmDialog.java b/packages/VpnDialogs/src/com/android/vpndialogs/PlatformVpnConfirmDialog.java new file mode 100644 index 000000000000..e2e297caad14 --- /dev/null +++ b/packages/VpnDialogs/src/com/android/vpndialogs/PlatformVpnConfirmDialog.java @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.vpndialogs; + +import android.net.VpnManager; + +/** + * PlatformVpnConfirmDialog is a minimal subclass for requesting user consent for platform VPN + * profiles. + */ +public class PlatformVpnConfirmDialog extends ConfirmDialog { + public PlatformVpnConfirmDialog() { + super(VpnManager.TYPE_VPN_PLATFORM); + } +} |