diff options
author | Robin Lee <rgl@google.com> | 2015-04-16 17:01:49 +0100 |
---|---|---|
committer | Robin Lee <rgl@google.com> | 2015-04-21 15:28:20 +0100 |
commit | 9cb1d5f6418da8cecdee58114c6e97b80c1b153f (patch) | |
tree | 5a9d1cc1bc31a0a960d161098c1b3400d7d5f0b6 /packages/SystemUI/src/com/android/systemui/qs/QSFooter.java | |
parent | ca02bc7cebabcf347bde98a45cce41c7d1ab26ee (diff) | |
download | frameworks_base-9cb1d5f6418da8cecdee58114c6e97b80c1b153f.zip frameworks_base-9cb1d5f6418da8cecdee58114c6e97b80c1b153f.tar.gz frameworks_base-9cb1d5f6418da8cecdee58114c6e97b80c1b153f.tar.bz2 |
SecurityController: track VPN for all users
Fixes inconsistencies when switching users.
Bug: 17763561
Bug: 17506956
Bug: 18419023
Change-Id: I65988e6c45afd00a402d1e266922d5648fd12743
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/qs/QSFooter.java')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/QSFooter.java | 96 |
1 files changed, 34 insertions, 62 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java b/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java index 0ab644a..d8e3984 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSFooter.java @@ -18,9 +18,11 @@ package com.android.systemui.qs; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; +import android.content.Intent; import android.os.Handler; import android.os.Looper; import android.os.Message; +import android.os.UserHandle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -38,6 +40,8 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene protected static final String TAG = "QSFooter"; protected static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); + private static final String ACTION_VPN_SETTINGS = "android.net.vpn.SETTINGS"; + private final View mRootView; private final TextView mFooterText; private final ImageView mFooterIcon; @@ -128,50 +132,42 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene @Override public void onClick(DialogInterface dialog, int which) { if (which == DialogInterface.BUTTON_NEGATIVE) { - mSecurityController.disconnectFromVpn(); + final Intent settingsIntent = new Intent(ACTION_VPN_SETTINGS); + mContext.startActivityAsUser(settingsIntent, UserHandle.CURRENT); } } private void createDialog() { + boolean hasDeviceOwner = mSecurityController.hasDeviceOwner(); + boolean hasProfile = mSecurityController.hasProfileOwner(); + boolean hasVpn = mSecurityController.isVpnEnabled(); + mDialog = new SystemUIDialog(mContext); - mDialog.setTitle(getTitle()); - mDialog.setMessage(getMessage()); + mDialog.setTitle(getTitle(hasDeviceOwner, hasProfile)); + mDialog.setMessage(getMessage(hasDeviceOwner, hasProfile, hasVpn)); mDialog.setButton(DialogInterface.BUTTON_POSITIVE, getPositiveButton(), this); - if (mSecurityController.isVpnEnabled()) { + if (hasVpn) { mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getNegativeButton(), this); } mDialog.show(); } private String getNegativeButton() { - if (mSecurityController.isLegacyVpn()) { - return mContext.getString(R.string.disconnect_vpn); - } else { - return mContext.getString(R.string.disable_vpn); - } + return mContext.getString(R.string.status_bar_settings_settings_button); } private String getPositiveButton() { return mContext.getString(R.string.quick_settings_done); } - private String getMessage() { - if (mSecurityController.hasDeviceOwner()) { - if (mSecurityController.hasProfileOwner()) { - if (mSecurityController.isVpnEnabled()) { - if (mSecurityController.isLegacyVpn()) { - return mContext.getString( - R.string.monitoring_description_legacy_vpn_device_and_profile_owned, - mSecurityController.getDeviceOwnerName(), - mSecurityController.getProfileOwnerName(), - mSecurityController.getLegacyVpnName()); - } else { - return mContext.getString( - R.string.monitoring_description_vpn_device_and_profile_owned, - mSecurityController.getDeviceOwnerName(), - mSecurityController.getProfileOwnerName(), - mSecurityController.getVpnApp()); - } + private String getMessage(boolean hasDeviceOwner, boolean hasProfile, boolean hasVpn) { + if (hasDeviceOwner) { + if (hasProfile) { + if (hasVpn) { + return mContext.getString( + R.string.monitoring_description_vpn_device_and_profile_owned, + mSecurityController.getDeviceOwnerName(), + mSecurityController.getProfileOwnerName()); } else { return mContext.getString( R.string.monitoring_description_device_and_profile_owned, @@ -179,57 +175,33 @@ public class QSFooter implements OnClickListener, DialogInterface.OnClickListene mSecurityController.getProfileOwnerName()); } } else { - if (mSecurityController.isVpnEnabled()) { - if (mSecurityController.isLegacyVpn()) { - return mContext.getString( - R.string.monitoring_description_legacy_vpn_device_owned, - mSecurityController.getDeviceOwnerName(), - mSecurityController.getLegacyVpnName()); - } else { - return mContext.getString(R.string.monitoring_description_vpn_device_owned, - mSecurityController.getDeviceOwnerName(), - mSecurityController.getVpnApp()); - } + if (hasVpn) { + return mContext.getString(R.string.monitoring_description_vpn_device_owned, + mSecurityController.getDeviceOwnerName()); } else { return mContext.getString(R.string.monitoring_description_device_owned, mSecurityController.getDeviceOwnerName()); } } - } else if (mSecurityController.hasProfileOwner()) { - if (mSecurityController.isVpnEnabled()) { - if (mSecurityController.isLegacyVpn()) { - return mContext.getString( - R.string.monitoring_description_legacy_vpn_profile_owned, - mSecurityController.getProfileOwnerName(), - mSecurityController.getLegacyVpnName()); - } else { - return mContext.getString( - R.string.monitoring_description_vpn_profile_owned, - mSecurityController.getProfileOwnerName(), - mSecurityController.getVpnApp()); - } + } else if (hasProfile) { + if (hasVpn) { + return mContext.getString( + R.string.monitoring_description_vpn_profile_owned, + mSecurityController.getProfileOwnerName()); } else { return mContext.getString( R.string.monitoring_description_profile_owned, mSecurityController.getProfileOwnerName()); } } else { - if (mSecurityController.isLegacyVpn()) { - return mContext.getString(R.string.monitoring_description_legacy_vpn, - mSecurityController.getLegacyVpnName()); - - } else { - return mContext.getString(R.string.monitoring_description_vpn, - mSecurityController.getVpnApp()); - } + return mContext.getString(R.string.monitoring_description_vpn); } } - private int getTitle() { - if (mSecurityController.hasDeviceOwner()) { + private int getTitle(boolean hasDeviceOwner, boolean hasProfile) { + if (hasDeviceOwner) { return R.string.monitoring_title_device_owned; - } - if (mSecurityController.hasProfileOwner()) { + } else if (hasProfile) { return R.string.monitoring_title_profile_owned; } return R.string.monitoring_title; |