diff options
Diffstat (limited to 'packages/SystemUI')
12 files changed, 127 insertions, 205 deletions
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 67a0bc6..f12fd0c 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -909,37 +909,25 @@ <string name="disconnect_vpn">Disconnect VPN</string> <!-- Monitoring dialog device owner body text [CHAR LIMIT=400] --> - <string name="monitoring_description_device_owned">This device is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\n\nYour administrator can monitor your device and network activity, including emails, apps and secure websites.\n\nFor more information, contact your administrator.</string> - - <!-- Monitoring dialog non-legacy VPN text [CHAR LIMIT=400] --> - <string name="monitoring_description_vpn">You gave \"<xliff:g id="application">%1$s</xliff:g>\" permission to set up a VPN connection.\n\nThis app can monitor your device and network activity, including emails, apps and secure websites.</string> - - <!-- Monitoring dialog legacy VPN text [CHAR LIMIT=400] --> - <string name="monitoring_description_legacy_vpn">You\'re connected to a VPN (\"<xliff:g id="application">%1$s</xliff:g>\").\n\nYour VPN service provider can monitor your device and network activity including emails, apps, and secure websites.</string> - - <!-- Monitoring dialog non-legacy VPN with device owner text [CHAR LIMIT=400] --> - <string name="monitoring_description_vpn_device_owned">This device is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\n\nYour administrator is capable of monitoring your network activity including emails, apps, and secure websites. For more information, contact your administrator.\n\nAlso, you gave \"<xliff:g id="application">%2$s</xliff:g>\" permission to set up a VPN connection. This app can monitor network activity too.</string> - - <!-- Monitoring dialog legacy VPN with device owner text [CHAR LIMIT=400] --> - <string name="monitoring_description_legacy_vpn_device_owned">This device is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\n\nYour administrator is capable of monitoring your network activity including emails, apps, and secure websites. For more information, contact your administrator.\n\nAlso, you\'re connected to a VPN (\"<xliff:g id="application">%2$s</xliff:g>\"). Your VPN service provider can monitor network activity too.</string> + <string name="monitoring_description_device_owned">Your device is managed by <xliff:g id="organization">%1$s</xliff:g>.\n\nYour administrator can monitor and manage settings, corporate access, apps, data associated with your device, and your device\'s location information. For more information, contact your administrator.</string> <!-- Monitoring dialog profile owner body text [CHAR LIMIT=400] --> - <string name="monitoring_description_profile_owned">This profile is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\n\nYour administrator can monitor your device and network activity, including emails, apps and secure websites.\n\nFor more information, contact your administrator.</string> + <string name="monitoring_description_profile_owned">Your work profile is managed by <xliff:g id="organization">%1$s</xliff:g>.\n\nYour administrator is capable of monitoring your network activity including emails, apps and secure websites.\n\nFor more information, contact your administrator.</string> <!-- Monitoring dialog device and profile owner body text [CHAR LIMIT=400] --> - <string name="monitoring_description_device_and_profile_owned">This device is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\nYour profile is managed by:\n<xliff:g id="organization">%2$s</xliff:g>\n\nYour administrator can monitor your device and network activity, including emails, apps and secure websites.\n\nFor more information, contact your administrator.</string> + <string name="monitoring_description_device_and_profile_owned">Your device is managed by:\n<xliff:g id="organization">%1$s</xliff:g>.\nYour work profile is managed by:\n<xliff:g id="organization">%2$s</xliff:g>.\n\nYour administrator can monitor your device and network activity, including emails, apps and secure websites.\n\nFor more information, contact your administrator.</string> - <!-- Monitoring dialog non-legacy VPN with profile owner text [CHAR LIMIT=400] --> - <string name="monitoring_description_vpn_profile_owned">This profile is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\n\nYour administrator is capable of monitoring your network activity including emails, apps, and secure websites. For more information, contact your administrator.\n\nAlso, you gave \"<xliff:g id="application">%2$s</xliff:g>\" permission to set up a VPN connection. This app can monitor network activity too.</string> + <!-- Monitoring dialog VPN text [CHAR LIMIT=400] --> + <string name="monitoring_description_vpn">You gave an app permission to set up a VPN connection.\n\nThis app can monitor your device and network activity, including emails, apps and secure websites.</string> - <!-- Monitoring dialog legacy VPN with profile owner text [CHAR LIMIT=400] --> - <string name="monitoring_description_legacy_vpn_profile_owned">This profile is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\n\nYour administrator is capable of monitoring your network activity including emails, apps, and secure websites. For more information, contact your administrator.\n\nAlso, you\'re connected to a VPN (\"<xliff:g id="application">%2$s</xliff:g>\"). Your VPN service provider can monitor network activity too.</string> + <!-- Monitoring dialog VPN with device owner text [CHAR LIMIT=400] --> + <string name="monitoring_description_vpn_device_owned">Your device is managed by <xliff:g id="organization">%1$s</xliff:g>.\n\nYour administrator can monitor and manage settings, corporate access, apps, data associated with your device, and your device\'s location information.\n\nYou\'re connected to a VPN, which can monitor your network activity, including emails, apps, and websites.\n\nFor more information, contact your administrator.</string> - <!-- Monitoring dialog non-legacy VPN with device and profile owner text [CHAR LIMIT=400] --> - <string name="monitoring_description_vpn_device_and_profile_owned">This device is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\nYour profile is managed by:\n<xliff:g id="organization">%2$s</xliff:g>\n\nYour administrator is capable of monitoring your network activity including emails, apps, and secure websites. For more information, contact your administrator.\n\nAlso, you gave \"<xliff:g id="application">%3$s</xliff:g>\" permission to set up a VPN connection. This app can monitor network activity too.</string> + <!-- Monitoring dialog VPN with profile owner text [CHAR LIMIT=400] --> + <string name="monitoring_description_vpn_profile_owned">Your work profile is managed by <xliff:g id="organization">%1$s</xliff:g>.\n\nYour administrator is capable of monitoring your network activity including emails, apps, and secure websites.\n\nFor more information, contact your administrator.\n\nYou\'re also connected to a VPN, which can monitor your network activity.</string> - <!-- Monitoring dialog legacy VPN with device and profile owner text [CHAR LIMIT=400] --> - <string name="monitoring_description_legacy_vpn_device_and_profile_owned">This device is managed by:\n<xliff:g id="organization">%1$s</xliff:g>\nYour profile is managed by:\n<xliff:g id="organization">%2$s</xliff:g>\n\nYour administrator is capable of monitoring your network activity including emails, apps, and secure websites. For more information, contact your administrator.\n\nAlso, you\'re connected to a VPN (\"<xliff:g id="application">%3$s</xliff:g>\"). Your VPN service provider can monitor network activity too.</string> + <!-- Monitoring dialog VPN with device and profile owner text [CHAR LIMIT=400] --> + <string name="monitoring_description_vpn_device_and_profile_owned">Your device is managed by <xliff:g id="organization">%1$s</xliff:g>.\nYour work profile is managed by:\n<xliff:g id="organization">%2$s</xliff:g>.\n\nYour administrator is capable of monitoring your network activity including emails, apps, and secure websites.\n\nFor more information, contact your administrator.\n\nYou\'re also connected to a VPN, which can monitor your personal network activity</string> <!-- Indication on the keyguard that appears when the user disables trust agents until the next time they unlock manually. [CHAR LIMIT=NONE] --> <string name="keyguard_indication_trust_disabled">Device will stay locked until you manually unlock</string> 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; diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java index f4fd6a2..b5c1ca8 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSPanel.java @@ -338,6 +338,7 @@ public class QSPanel extends ViewGroup { r.detailAdapter = r.tile.getDetailAdapter(); if (r.detailAdapter == null) return; } + r.tile.setDetailListening(show); int x = r.tileView.getLeft() + r.tileView.getWidth() / 2; int y = r.tileView.getTop() + r.tileView.getHeight() / 2; handleShowDetailImpl(r, show, x, y); diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java index 5a84db5..b9574dc 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java @@ -149,6 +149,10 @@ public abstract class QSTile<TState extends State> implements Listenable { return mState; } + public void setDetailListening(boolean listening) { + // optional + } + // call only on tile worker looper private void handleSetCallback(Callback callback) { diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java index 70746c7..d589366 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java @@ -67,9 +67,16 @@ public class WifiTile extends QSTile<QSTile.SignalState> { public void setListening(boolean listening) { if (listening) { mController.addNetworkSignalChangedCallback(mCallback); - mWifiController.addAccessPointCallback(mDetailAdapter); } else { mController.removeNetworkSignalChangedCallback(mCallback); + } + } + + @Override + public void setDetailListening(boolean listening) { + if (listening) { + mWifiController.addAccessPointCallback(mDetailAdapter); + } else { mWifiController.removeAccessPointCallback(mDetailAdapter); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java index 094cd1f..e5ef6ff 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -83,8 +83,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL private static final int DOZE_ANIMATION_STAGGER_DELAY = 48; private static final int DOZE_ANIMATION_ELEMENT_DURATION = 250; private static final long TRANSIENT_FP_ERROR_TIMEOUT = 1300; - private static final long[] FP_ERROR_VIBRATE_PATTERN = new long[] {0, 30, 100, 30}; - private static final long[] FP_SUCCESS_VIBRATE_PATTERN = new long[] {0, 30}; private KeyguardAffordanceView mCameraImageView; private KeyguardAffordanceView mPhoneImageView; @@ -551,14 +549,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL .setDuration(DOZE_ANIMATION_ELEMENT_DURATION); } - private void vibrateFingerprintError() { - mContext.getSystemService(Vibrator.class).vibrate(FP_ERROR_VIBRATE_PATTERN, -1); - } - - private void vibrateFingerprintSuccess() { - mContext.getSystemService(Vibrator.class).vibrate(FP_SUCCESS_VIBRATE_PATTERN, -1); - } - private final BroadcastReceiver mDevicePolicyReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { post(new Runnable() { @@ -603,7 +593,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL @Override public void onFingerprintAuthenticated(int userId) { - vibrateFingerprintSuccess(); } @Override @@ -613,7 +602,6 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL @Override public void onFingerprintHelp(int msgId, String helpString) { - vibrateFingerprintError(); mTransientFpError = true; mIndicationController.showTransientIndication(helpString, getResources().getColor(R.color.system_warning_color, null)); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java index dccf2e2..b4e4773 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/HeadsUpManager.java @@ -314,7 +314,8 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL * @return whether the touch is valid and should not be discarded */ public boolean shouldSwallowClick(String key) { - if (mClock.currentTimeMillis() < mHeadsUpEntries.get(key).postTime) { + HeadsUpEntry entry = mHeadsUpEntries.get(key); + if (entry != null && mClock.currentTimeMillis() < entry.postTime) { return true; } return false; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java index 5cf6a6e..9adf028 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/NetworkControllerImpl.java @@ -173,7 +173,7 @@ public class NetworkControllerImpl extends BroadcastReceiver filter.addAction(TelephonyIntents.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED); filter.addAction(TelephonyIntents.ACTION_DEFAULT_VOICE_SUBSCRIPTION_CHANGED); filter.addAction(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION); - filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION_IMMEDIATE); + filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); filter.addAction(ConnectivityManager.INET_CONDITION_ACTION); filter.addAction(Intent.ACTION_CONFIGURATION_CHANGED); filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED); @@ -331,7 +331,7 @@ public class NetworkControllerImpl extends BroadcastReceiver Log.d(TAG, "onReceive: intent=" + intent); } final String action = intent.getAction(); - if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION_IMMEDIATE) || + if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION) || action.equals(ConnectivityManager.INET_CONDITION_ACTION)) { updateConnectivity(); } else if (action.equals(Intent.ACTION_CONFIGURATION_CHANGED)) { 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 6148feb..e1e022d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityController.java @@ -22,10 +22,6 @@ public interface SecurityController { String getDeviceOwnerName(); String getProfileOwnerName(); boolean isVpnEnabled(); - String getVpnApp(); - boolean isLegacyVpn(); - String getLegacyVpnName(); - void disconnectFromVpn(); void onUserSwitched(int newUserId); void addCallback(SecurityControllerCallback 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 f0dd943..4f47cc6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SecurityControllerImpl.java @@ -19,6 +19,7 @@ import android.app.ActivityManager; import android.app.admin.DevicePolicyManager; import android.content.Context; import android.content.pm.PackageManager.NameNotFoundException; +import android.content.pm.UserInfo; import android.net.ConnectivityManager; import android.net.ConnectivityManager.NetworkCallback; import android.net.IConnectivityManager; @@ -27,10 +28,14 @@ import android.net.NetworkCapabilities; import android.net.NetworkRequest; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.UserHandle; +import android.os.UserManager; import android.text.TextUtils; import android.util.Log; +import android.util.SparseArray; import com.android.internal.net.VpnConfig; +import com.android.internal.net.VpnInfo; import java.io.FileDescriptor; import java.io.PrintWriter; @@ -50,15 +55,13 @@ public class SecurityControllerImpl implements SecurityController { private final Context mContext; private final ConnectivityManager mConnectivityManager; - private final IConnectivityManager mConnectivityService = IConnectivityManager.Stub.asInterface( - ServiceManager.getService(Context.CONNECTIVITY_SERVICE)); + private final IConnectivityManager mConnectivityManagerService; private final DevicePolicyManager mDevicePolicyManager; + private final UserManager mUserManager; private final ArrayList<SecurityControllerCallback> mCallbacks = new ArrayList<SecurityControllerCallback>(); - private VpnConfig mVpnConfig; - private String mVpnName; - private int mCurrentVpnNetworkId = NO_NETWORK; + private SparseArray<Boolean> mCurrentVpnUsers = new SparseArray<>(); private int mCurrentUserId; public SecurityControllerImpl(Context context) { @@ -67,6 +70,10 @@ public class SecurityControllerImpl implements SecurityController { context.getSystemService(Context.DEVICE_POLICY_SERVICE); mConnectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + mConnectivityManagerService = IConnectivityManager.Stub.asInterface( + ServiceManager.getService(Context.CONNECTIVITY_SERVICE)); + mUserManager = (UserManager) + context.getSystemService(Context.USER_SERVICE); // TODO: re-register network callback on user change. mConnectivityManager.registerNetworkCallback(REQUEST, mNetworkCallback); @@ -75,9 +82,7 @@ public class SecurityControllerImpl implements SecurityController { public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { pw.println("SecurityController state:"); - pw.print(" mCurrentVpnNetworkId="); pw.println(mCurrentVpnNetworkId); - pw.print(" mVpnConfig="); pw.println(mVpnConfig); - pw.print(" mVpnName="); pw.println(mVpnName); + pw.print(" mCurrentVpnUsers=" + mCurrentVpnUsers); } @Override @@ -86,56 +91,33 @@ public class SecurityControllerImpl implements SecurityController { } @Override - public boolean hasProfileOwner() { - return !TextUtils.isEmpty(mDevicePolicyManager.getProfileOwnerNameAsUser(mCurrentUserId)); - } - - @Override public String getDeviceOwnerName() { return mDevicePolicyManager.getDeviceOwnerName(); } @Override - public String getProfileOwnerName() { - return mDevicePolicyManager.getProfileOwnerNameAsUser(mCurrentUserId); - } - - - @Override - public boolean isVpnEnabled() { - return mCurrentVpnNetworkId != NO_NETWORK; - } - - @Override - public boolean isLegacyVpn() { - return mVpnConfig.legacy; - } - - @Override - public String getVpnApp() { - return mVpnName; + public boolean hasProfileOwner() { + boolean result = false; + for (UserInfo profile : mUserManager.getProfiles(mCurrentUserId)) { + result |= (mDevicePolicyManager.getProfileOwnerAsUser(profile.id) != null); + } + return result; } @Override - public String getLegacyVpnName() { - return mVpnConfig.session; + public String getProfileOwnerName() { + for (UserInfo profile : mUserManager.getProfiles(mCurrentUserId)) { + String name = mDevicePolicyManager.getProfileOwnerNameAsUser(profile.id); + if (name != null) { + return name; + } + } + return null; } @Override - public void disconnectFromVpn() { - try { - 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); - } + public boolean isVpnEnabled() { + return mCurrentVpnUsers.get(mCurrentUserId) != null; } @Override @@ -158,14 +140,6 @@ public class SecurityControllerImpl implements SecurityController { fireCallbacks(); } - private void setCurrentNetid(int netId) { - if (netId != mCurrentVpnNetworkId) { - mCurrentVpnNetworkId = netId; - updateState(); - fireCallbacks(); - } - } - private void fireCallbacks() { for (SecurityControllerCallback callback : mCallbacks) { callback.onStateChanged(); @@ -173,27 +147,30 @@ public class SecurityControllerImpl implements SecurityController { } private void updateState() { + // Find all users with an active VPN + SparseArray<Boolean> vpnUsers = new SparseArray<>(); try { - mVpnConfig = mConnectivityService.getVpnConfig(); + for (VpnInfo vpn : mConnectivityManagerService.getAllVpnInfo()) { + UserInfo user = mUserManager.getUserInfo(UserHandle.getUserId(vpn.ownerUid)); + int groupId = (user.profileGroupId != UserInfo.NO_PROFILE_GROUP_ID ? + user.profileGroupId : user.id); - if (mVpnConfig != null && !mVpnConfig.legacy) { - mVpnName = VpnConfig.getVpnLabel(mContext, mVpnConfig.user).toString(); + vpnUsers.put(groupId, Boolean.TRUE); } - } catch (RemoteException | NameNotFoundException e) { - Log.w(TAG, "Unable to get current VPN", e); + } catch (RemoteException rme) { + // Roll back to previous state + Log.e(TAG, "Unable to list active VPNs", rme); + return; } + mCurrentVpnUsers = vpnUsers; } private final NetworkCallback mNetworkCallback = new NetworkCallback() { @Override public void onAvailable(Network network) { - NetworkCapabilities networkCapabilities = - mConnectivityManager.getNetworkCapabilities(network); - if (DEBUG) Log.d(TAG, "onAvailable " + network.netId + " : " + networkCapabilities); - if (networkCapabilities != null && - networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_VPN)) { - setCurrentNetid(network.netId); - } + if (DEBUG) Log.d(TAG, "onAvailable " + network.netId); + updateState(); + fireCallbacks(); }; // TODO Find another way to receive VPN lost. This may be delayed depending on @@ -201,9 +178,8 @@ public class SecurityControllerImpl implements SecurityController { @Override public void onLost(Network network) { if (DEBUG) Log.d(TAG, "onLost " + network.netId); - if (mCurrentVpnNetworkId == network.netId) { - setCurrentNetid(NO_NETWORK); - } + updateState(); + fireCallbacks(); }; }; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/AmbientState.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/AmbientState.java index f2b971f..4a7ea96 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/AmbientState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/AmbientState.java @@ -23,7 +23,6 @@ import com.android.systemui.statusbar.ExpandableNotificationRow; import com.android.systemui.statusbar.policy.HeadsUpManager; import java.util.ArrayList; -import java.util.TreeSet; /** * A global state to track all input states for the algorithm. @@ -130,10 +129,6 @@ public class AmbientState { mHeadsUpManager = headsUpManager; } - public TreeSet<HeadsUpManager.HeadsUpEntry> getSortedHeadsUpEntries() { - return mHeadsUpManager.getSortedEntries(); - } - public float getStackTranslation() { return mStackTranslation; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java index d98bcfe..2a49a4c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollAlgorithm.java @@ -29,7 +29,6 @@ import com.android.systemui.statusbar.policy.HeadsUpManager; import java.util.ArrayList; import java.util.List; -import java.util.TreeSet; /** * The Algorithm of the {@link com.android.systemui.statusbar.stack @@ -155,7 +154,7 @@ public class StackScrollAlgorithm { scrollY = Math.max(0, scrollY); algorithmState.scrollY = (int) (scrollY + mCollapsedSize + bottomOverScroll); - updateVisibleChildren(resultState, algorithmState, ambientState); + updateVisibleChildren(resultState, algorithmState); // Phase 1: findNumberOfItemsInTopStackAndUpdateState(resultState, algorithmState, ambientState); @@ -337,27 +336,18 @@ public class StackScrollAlgorithm { * Update the visible children on the state. */ private void updateVisibleChildren(StackScrollState resultState, - StackScrollAlgorithmState state, AmbientState ambientState) { + StackScrollAlgorithmState state) { ViewGroup hostView = resultState.getHostView(); int childCount = hostView.getChildCount(); state.visibleChildren.clear(); state.visibleChildren.ensureCapacity(childCount); int notGoneIndex = 0; - TreeSet<HeadsUpManager.HeadsUpEntry> headsUpEntries - = ambientState.getSortedHeadsUpEntries(); - for (HeadsUpManager.HeadsUpEntry entry: headsUpEntries) { - ExpandableView v = entry.entry.row; - notGoneIndex = updateNotGoneIndex(resultState, state, notGoneIndex, v); - } for (int i = 0; i < childCount; i++) { ExpandableView v = (ExpandableView) hostView.getChildAt(i); if (v.getVisibility() != View.GONE) { + notGoneIndex = updateNotGoneIndex(resultState, state, notGoneIndex, v); if (v instanceof ExpandableNotificationRow) { ExpandableNotificationRow row = (ExpandableNotificationRow) v; - if (row.isHeadsUp()) { - continue; - } - notGoneIndex = updateNotGoneIndex(resultState, state, notGoneIndex, v); // handle the notgoneIndex for the children as well List<ExpandableNotificationRow> children = @@ -372,8 +362,6 @@ public class StackScrollAlgorithm { } } } - } else { - notGoneIndex = updateNotGoneIndex(resultState, state, notGoneIndex, v); } } } @@ -507,15 +495,25 @@ public class StackScrollAlgorithm { childViewState.yTranslation += ambientState.getTopPadding() + ambientState.getStackTranslation(); } - updateHeadsUpStates(resultState, ambientState); + updateHeadsUpStates(resultState, algorithmState, ambientState); } - private void updateHeadsUpStates(StackScrollState resultState, AmbientState ambientState) { - TreeSet<HeadsUpManager.HeadsUpEntry> headsUpEntries = ambientState.getSortedHeadsUpEntries(); - for (HeadsUpManager.HeadsUpEntry entry: headsUpEntries) { - ExpandableNotificationRow row = entry.entry.row; + private void updateHeadsUpStates(StackScrollState resultState, + StackScrollAlgorithmState algorithmState, AmbientState ambientState) { + int childCount = algorithmState.visibleChildren.size(); + ExpandableNotificationRow topHeadsUpEntry = null; + for (int i = 0; i < childCount; i++) { + View child = algorithmState.visibleChildren.get(i); + if (!(child instanceof ExpandableNotificationRow)) { + break; + } + ExpandableNotificationRow row = (ExpandableNotificationRow) child; + if (!row.isHeadsUp()) { + break; + } else if (topHeadsUpEntry == null) { + topHeadsUpEntry = row; + } StackViewState childState = resultState.getViewStateForView(row); - ExpandableNotificationRow topHeadsUpEntry = ambientState.getTopHeadsUpEntry(); boolean isTopEntry = topHeadsUpEntry == row; if (!row.isInShade()) { childState.yTranslation = 0; @@ -537,7 +535,6 @@ public class StackScrollAlgorithm { childState.yTranslation = Math.min(childState.yTranslation, bottomPosition); } - } } @@ -897,9 +894,6 @@ public class StackScrollAlgorithm { } private View findFirstVisibleChild(ViewGroup container) { - if (mHeadsUpManager != null && mHeadsUpManager.getTopEntry() != null) { - return mHeadsUpManager.getTopEntry().entry.row; - } int childCount = container.getChildCount(); for (int i = 0; i < childCount; i++) { View child = container.getChildAt(i); |
