From 05542603dd4f1e0ea47a3dca01de3999a9a329a9 Mon Sep 17 00:00:00 2001 From: Jeff Davidson Date: Mon, 11 Aug 2014 14:07:27 -0700 Subject: Less intrusive VPN dialog and other UX tweaks. -The ability to launch VPNs is now sticky; once approved by the user, further approvals are not needed UNLESS the connection is revoked in Quick Settings. -The old persistent notification has been removed in favor of the new Quick Settings UI. -The name of the VPN app is now pulled from the label of the VPN service rather than the app itself, if one is set. Bug: 12878887 Bug: 16578022 Change-Id: I102a14c05db26ee3aef030cda971e5165f078a91 --- .../src/com/android/systemui/qs/QSFooter.java | 8 ++----- .../statusbar/policy/SecurityController.java | 3 +-- .../statusbar/policy/SecurityControllerImpl.java | 26 +++++++++------------- 3 files changed, 14 insertions(+), 23 deletions(-) (limited to 'packages/SystemUI/src') 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); -- cgit v1.1