diff options
Diffstat (limited to 'packages/SystemUI/src/com/android')
3 files changed, 14 insertions, 23 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java b/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java index bfbc56c..a8199fa 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java @@ -119,11 +119,7 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene @Override public void onClick(DialogInterface dialog, int which) { if (which == DialogInterface.BUTTON_NEGATIVE) { - if (mSecurityController.isLegacyVpn()) { - mSecurityController.disconnectFromLegacyVpn(); - } else { - mSecurityController.openVpnApp(); - } + mSecurityController.disconnectFromVpn(); } } @@ -142,7 +138,7 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene if (mSecurityController.isLegacyVpn()) { return mContext.getString(R.string.disconnect_vpn); } else { - return mContext.getString(R.string.open_app); + return mContext.getString(R.string.disable_vpn); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java index ede8129..3a5a53b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java @@ -23,8 +23,7 @@ public interface SecurityController { String getVpnApp(); boolean isLegacyVpn(); String getLegacyVpnName(); - void openVpnApp(); - void disconnectFromLegacyVpn(); + void disconnectFromVpn(); void addCallback(VpnCallback callback); void removeCallback(VpnCallback callback); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java index 8e04e5e..ae0291b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java @@ -18,7 +18,6 @@ package com.android.systemui.statusbar.policy; import android.app.admin.DevicePolicyManager; import android.content.Context; import android.content.Intent; -import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.net.ConnectivityManager; import android.net.ConnectivityManager.NetworkCallback; @@ -109,18 +108,17 @@ public class SecurityControllerImpl implements SecurityController { } @Override - public void openVpnApp() { - Intent i = mContext.getPackageManager().getLaunchIntentForPackage(mVpnConfig.user); - if (i != null) { - i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - mContext.startActivity(i); - } - } - - @Override - public void disconnectFromLegacyVpn() { + public void disconnectFromVpn() { try { - mConnectivityService.prepareVpn(VpnConfig.LEGACY_VPN, VpnConfig.LEGACY_VPN); + if (isLegacyVpn()) { + mConnectivityService.prepareVpn(VpnConfig.LEGACY_VPN, VpnConfig.LEGACY_VPN); + } else { + // Prevent this app from initiating VPN connections in the future without user + // intervention. + mConnectivityService.setVpnPackageAuthorization(false); + + mConnectivityService.prepareVpn(mVpnConfig.user, VpnConfig.LEGACY_VPN); + } } catch (Exception e) { Log.e(TAG, "Unable to disconnect from VPN", e); } @@ -154,9 +152,7 @@ public class SecurityControllerImpl implements SecurityController { mIsVpnEnabled = mVpnConfig != null; if (mVpnConfig != null && !mVpnConfig.legacy) { - ApplicationInfo info = - mContext.getPackageManager().getApplicationInfo(mVpnConfig.user, 0); - mVpnName = mContext.getPackageManager().getApplicationLabel(info).toString(); + mVpnName = VpnConfig.getVpnLabel(mContext, mVpnConfig.user).toString(); } } catch (RemoteException | NameNotFoundException e) { Log.w(TAG, "Unable to get current VPN", e); |