From 1a447535cef7e3739d5f763dfe13e568568b9789 Mon Sep 17 00:00:00 2001 From: Kenny Guy Date: Thu, 20 Feb 2014 21:55:32 +0000 Subject: Hide managed profiles from user switchers. Hide managed profiles from lockscreen user switcher on tablets. Hide managed profiles from power menu user switcher on phones. Add flag to enable multi user ui turned off by default. Change-Id: I4c69a6f7b0f39c249fc85fd940318df1ddab073f --- .../src/com/android/keyguard/KeyguardHostView.java | 77 ++++++++++------------ .../keyguard/KeyguardMultiUserSelectorView.java | 10 +-- .../com/android/keyguard/KeyguardViewMediator.java | 4 +- .../systemui/statusbar/phone/QuickSettings.java | 2 +- 4 files changed, 42 insertions(+), 51 deletions(-) (limited to 'packages') diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java index 7ac94bd..1e79ee4 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardHostView.java @@ -1051,9 +1051,6 @@ public class KeyguardHostView extends KeyguardViewBase { } private void enableUserSelectorIfNecessary() { - if (!UserManager.supportsMultipleUsers()) { - return; // device doesn't support multi-user mode - } final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE); if (um == null) { Throwable t = new Throwable(); @@ -1063,61 +1060,53 @@ public class KeyguardHostView extends KeyguardViewBase { } // if there are multiple users, we need to enable to multi-user switcher - final List users = um.getUsers(true); - if (users == null) { - Throwable t = new Throwable(); - t.fillInStackTrace(); - Log.e(TAG, "list of users is null.", t); + if (!um.isUserSwitcherEnabled()) { return; } final View multiUserView = findViewById(R.id.keyguard_user_selector); if (multiUserView == null) { - Throwable t = new Throwable(); - t.fillInStackTrace(); - Log.e(TAG, "can't find user_selector in layout.", t); + if (DEBUG) Log.d(TAG, "can't find user_selector in layout."); return; } - if (users.size() > 1) { - if (multiUserView instanceof KeyguardMultiUserSelectorView) { - mKeyguardMultiUserSelectorView = (KeyguardMultiUserSelectorView) multiUserView; - mKeyguardMultiUserSelectorView.setVisibility(View.VISIBLE); - mKeyguardMultiUserSelectorView.addUsers(users); - UserSwitcherCallback callback = new UserSwitcherCallback() { - @Override - public void hideSecurityView(int duration) { - getSecurityContainer().animate().alpha(0).setDuration(duration); - } + if (multiUserView instanceof KeyguardMultiUserSelectorView) { + mKeyguardMultiUserSelectorView = (KeyguardMultiUserSelectorView) multiUserView; + mKeyguardMultiUserSelectorView.setVisibility(View.VISIBLE); + mKeyguardMultiUserSelectorView.addUsers(um.getUsers(true)); + UserSwitcherCallback callback = new UserSwitcherCallback() { + @Override + public void hideSecurityView(int duration) { + getSecurityContainer().animate().alpha(0).setDuration(duration); + } - @Override - public void showSecurityView() { - getSecurityContainer().setAlpha(1.0f); - } + @Override + public void showSecurityView() { + getSecurityContainer().setAlpha(1.0f); + } - @Override - public void showUnlockHint() { - if (getSecurityContainer() != null) { - getSecurityContainer().showUsabilityHint(); - } + @Override + public void showUnlockHint() { + if (getSecurityContainer() != null) { + getSecurityContainer().showUsabilityHint(); } + } - @Override - public void userActivity() { - if (mViewMediatorCallback != null) { - mViewMediatorCallback.userActivity(); - } + @Override + public void userActivity() { + if (mViewMediatorCallback != null) { + mViewMediatorCallback.userActivity(); } - }; - mKeyguardMultiUserSelectorView.setCallback(callback); - } else { - Throwable t = new Throwable(); - t.fillInStackTrace(); - if (multiUserView == null) { - Log.e(TAG, "could not find the user_selector.", t); - } else { - Log.e(TAG, "user_selector is the wrong type.", t); } + }; + mKeyguardMultiUserSelectorView.setCallback(callback); + } else { + Throwable t = new Throwable(); + t.fillInStackTrace(); + if (multiUserView == null) { + Log.e(TAG, "could not find the user_selector.", t); + } else { + Log.e(TAG, "user_selector is the wrong type.", t); } } } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardMultiUserSelectorView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardMultiUserSelectorView.java index 7975d8e..06815e1 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardMultiUserSelectorView.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardMultiUserSelectorView.java @@ -76,11 +76,13 @@ public class KeyguardMultiUserSelectorView extends FrameLayout implements View.O Collections.sort(users, mOrderAddedComparator); for (UserInfo user: users) { - KeyguardMultiUserAvatar uv = createAndAddUser(user); - if (user.id == activeUser.id) { - mActiveUserAvatar = uv; + if (user.supportsSwitchTo()) { + KeyguardMultiUserAvatar uv = createAndAddUser(user); + if (user.id == activeUser.id) { + mActiveUserAvatar = uv; + } + uv.setActive(false, false, null); } - uv.setActive(false, false, null); } mActiveUserAvatar.lockPressed(true); } diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java index e0ee4e0..151177e 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java @@ -704,7 +704,7 @@ public class KeyguardViewMediator { private void maybeSendUserPresentBroadcast() { if (mSystemReady && mLockPatternUtils.isLockScreenDisabled() - && mUserManager.getUsers(true).size() == 1) { + && !mUserManager.isUserSwitcherEnabled()) { // Lock screen is disabled because the user has set the preference to "None". // In this case, send out ACTION_USER_PRESENT here instead of in // handleKeyguardDone() @@ -940,7 +940,7 @@ public class KeyguardViewMediator { return; } - if (mUserManager.getUsers(true).size() < 2 + if (!mUserManager.isUserSwitcherEnabled() && mLockPatternUtils.isLockScreenDisabled() && !lockedOrMissing) { if (DEBUG) Log.d(TAG, "doKeyguard: not showing because lockscreen is off"); return; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java index 4d7ff5e..bcb818a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java @@ -312,7 +312,7 @@ class QuickSettings { public void onClick(View v) { collapsePanels(); final UserManager um = UserManager.get(mContext); - if (um.getUsers(true).size() > 1) { + if (um.isUserSwitcherEnabled()) { // Since keyguard and systemui were merged into the same process to save // memory, they share the same Looper and graphics context. As a result, // there's no way to allow concurrent animation while keyguard inflates. -- cgit v1.1