Loading core/java/android/provider/Settings.java +9 −0 Original line number Original line Diff line number Diff line Loading @@ -8155,6 +8155,15 @@ public final class Settings { public static final String UNINSTALLED_EPHEMERAL_APP_CACHE_DURATION_MILLIS = public static final String UNINSTALLED_EPHEMERAL_APP_CACHE_DURATION_MILLIS = "uninstalled_ephemeral_app_cache_duration_millis"; "uninstalled_ephemeral_app_cache_duration_millis"; /** * Allows switching users when system user is locked. * <p> * Type: int * @hide */ public static final String ALLOW_USER_SWITCHING_WHEN_SYSTEM_USER_LOCKED = "allow_user_switching_when_system_user_locked"; /** /** * Settings to backup. This is here so that it's in the same place as the settings * Settings to backup. This is here so that it's in the same place as the settings * keys and easy to update. * keys and easy to update. Loading packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailItemView.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -103,6 +103,11 @@ public class UserDetailItemView extends LinearLayout { mAvatar.setDisabled(disabled); mAvatar.setDisabled(disabled); } } public void setEnabled(boolean enabled) { mName.setEnabled(enabled); mAvatar.setDisabled(!enabled); } @Override @Override protected void onFinishInflate() { protected void onFinishInflate() { mAvatar = (UserAvatarView) findViewById(R.id.user_picture); mAvatar = (UserAvatarView) findViewById(R.id.user_picture); Loading packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java +4 −1 Original line number Original line Diff line number Diff line Loading @@ -82,6 +82,9 @@ public class UserDetailView extends PseudoGridView { } } v.setActivated(item.isCurrent); v.setActivated(item.isCurrent); v.setDisabledByAdmin(item.isDisabledByAdmin); v.setDisabledByAdmin(item.isDisabledByAdmin); if (!item.isSwitchToEnabled) { v.setEnabled(false); } v.setTag(item); v.setTag(item); return v; return v; } } Loading @@ -94,7 +97,7 @@ public class UserDetailView extends PseudoGridView { final Intent intent = RestrictedLockUtils.getShowAdminSupportDetailsIntent( final Intent intent = RestrictedLockUtils.getShowAdminSupportDetailsIntent( mContext, tag.enforcedAdmin); mContext, tag.enforcedAdmin); mController.startActivity(intent); mController.startActivity(intent); } else { } else if (tag.isSwitchToEnabled) { MetricsLogger.action(mContext, MetricsEvent.QS_SWITCH_USER); MetricsLogger.action(mContext, MetricsEvent.QS_SWITCH_USER); switchTo(tag); switchTo(tag); } } Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java +11 −4 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,8 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.ObjectAnimator; import android.content.Context; import android.content.Context; import android.database.DataSetObserver; import android.database.DataSetObserver; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.MotionEvent; Loading Loading @@ -242,7 +244,6 @@ public class KeyguardUserSwitcher { @Override @Override public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) { UserSwitcherController.UserRecord item = getItem(position); UserSwitcherController.UserRecord item = getItem(position); if (!(convertView instanceof UserDetailItemView) if (!(convertView instanceof UserDetailItemView) || !(convertView.getTag() instanceof UserSwitcherController.UserRecord)) { || !(convertView.getTag() instanceof UserSwitcherController.UserRecord)) { convertView = LayoutInflater.from(mContext).inflate( convertView = LayoutInflater.from(mContext).inflate( Loading @@ -252,11 +253,17 @@ public class KeyguardUserSwitcher { UserDetailItemView v = (UserDetailItemView) convertView; UserDetailItemView v = (UserDetailItemView) convertView; String name = getName(mContext, item); String name = getName(mContext, item); Drawable drawable; if (item.picture == null) { if (item.picture == null) { v.bind(name, getDrawable(mContext, item)); drawable = getDrawable(mContext, item).mutate(); } else { } else { v.bind(name, item.picture); drawable = new BitmapDrawable(mContext.getResources(), item.picture); } // Disable the icon if switching is disabled if (!item.isSwitchToEnabled) { drawable.setTint(mContext.getColor(R.color.qs_tile_disabled_color)); } } v.bind(name, drawable); convertView.setActivated(item.isCurrent); convertView.setActivated(item.isCurrent); convertView.setTag(item); convertView.setTag(item); return convertView; return convertView; Loading @@ -269,7 +276,7 @@ public class KeyguardUserSwitcher { // Close the switcher if tapping the current user. Guest is excluded because // Close the switcher if tapping the current user. Guest is excluded because // tapping the guest user while it's current clears the session. // tapping the guest user while it's current clears the session. mKeyguardUserSwitcher.hideIfNotSimple(true /* animate */); mKeyguardUserSwitcher.hideIfNotSimple(true /* animate */); } else { } else if (user.isSwitchToEnabled) { switchTo(user); switchTo(user); } } } } Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java +33 −8 Original line number Original line Diff line number Diff line Loading @@ -99,6 +99,7 @@ public class UserSwitcherController { private boolean mSimpleUserSwitcher; private boolean mSimpleUserSwitcher; private boolean mAddUsersWhenLocked; private boolean mAddUsersWhenLocked; private boolean mPauseRefreshUsers; private boolean mPauseRefreshUsers; private boolean mAllowUserSwitchingWhenSystemUserLocked; private SparseBooleanArray mForcePictureLoadForUserId = new SparseBooleanArray(2); private SparseBooleanArray mForcePictureLoadForUserId = new SparseBooleanArray(2); public UserSwitcherController(Context context, KeyguardMonitor keyguardMonitor, public UserSwitcherController(Context context, KeyguardMonitor keyguardMonitor, Loading @@ -115,6 +116,7 @@ public class UserSwitcherController { filter.addAction(Intent.ACTION_USER_INFO_CHANGED); filter.addAction(Intent.ACTION_USER_INFO_CHANGED); filter.addAction(Intent.ACTION_USER_SWITCHED); filter.addAction(Intent.ACTION_USER_SWITCHED); filter.addAction(Intent.ACTION_USER_STOPPING); filter.addAction(Intent.ACTION_USER_STOPPING); filter.addAction(Intent.ACTION_USER_UNLOCKED); mContext.registerReceiverAsUser(mReceiver, UserHandle.SYSTEM, filter, mContext.registerReceiverAsUser(mReceiver, UserHandle.SYSTEM, filter, null /* permission */, null /* scheduler */); null /* permission */, null /* scheduler */); Loading @@ -130,6 +132,10 @@ public class UserSwitcherController { mContext.getContentResolver().registerContentObserver( mContext.getContentResolver().registerContentObserver( Settings.Global.getUriFor(Settings.Global.ADD_USERS_WHEN_LOCKED), true, Settings.Global.getUriFor(Settings.Global.ADD_USERS_WHEN_LOCKED), true, mSettingsObserver); mSettingsObserver); mContext.getContentResolver().registerContentObserver( Settings.Global.getUriFor( Settings.Global.ALLOW_USER_SWITCHING_WHEN_SYSTEM_USER_LOCKED), true, mSettingsObserver); // Fetch initial values. // Fetch initial values. mSettingsObserver.onChange(false); mSettingsObserver.onChange(false); Loading Loading @@ -180,6 +186,8 @@ public class UserSwitcherController { } } ArrayList<UserRecord> records = new ArrayList<>(infos.size()); ArrayList<UserRecord> records = new ArrayList<>(infos.size()); int currentId = ActivityManager.getCurrentUser(); int currentId = ActivityManager.getCurrentUser(); boolean allowUserSwitching = mAllowUserSwitchingWhenSystemUserLocked || mUserManager.isUserUnlocked(UserHandle.SYSTEM); UserInfo currentUserInfo = null; UserInfo currentUserInfo = null; UserRecord guestRecord = null; UserRecord guestRecord = null; int avatarSize = mContext.getResources() int avatarSize = mContext.getResources() Loading @@ -190,10 +198,11 @@ public class UserSwitcherController { if (isCurrent) { if (isCurrent) { currentUserInfo = info; currentUserInfo = info; } } boolean switchToEnabled = allowUserSwitching || isCurrent; if (info.isGuest()) { if (info.isGuest()) { guestRecord = new UserRecord(info, null /* picture */, guestRecord = new UserRecord(info, null /* picture */, true /* isGuest */, isCurrent, false /* isAddUser */, true /* isGuest */, isCurrent, false /* isAddUser */, false /* isRestricted */); false /* isRestricted */, switchToEnabled); } else if (info.isEnabled() && info.supportsSwitchToByUser()) { } else if (info.isEnabled() && info.supportsSwitchToByUser()) { Bitmap picture = bitmaps.get(info.id); Bitmap picture = bitmaps.get(info.id); if (picture == null) { if (picture == null) { Loading @@ -206,7 +215,8 @@ public class UserSwitcherController { } } int index = isCurrent ? 0 : records.size(); int index = isCurrent ? 0 : records.size(); records.add(index, new UserRecord(info, picture, false /* isGuest */, records.add(index, new UserRecord(info, picture, false /* isGuest */, isCurrent, false /* isAddUser */, false /* isRestricted */)); isCurrent, false /* isAddUser */, false /* isRestricted */, switchToEnabled)); } } } } Loading @@ -228,7 +238,7 @@ public class UserSwitcherController { if (canCreateGuest) { if (canCreateGuest) { guestRecord = new UserRecord(null /* info */, null /* picture */, guestRecord = new UserRecord(null /* info */, null /* picture */, true /* isGuest */, false /* isCurrent */, true /* isGuest */, false /* isCurrent */, false /* isAddUser */, createIsRestricted); false /* isAddUser */, createIsRestricted, allowUserSwitching); checkIfAddUserDisallowedByAdminOnly(guestRecord); checkIfAddUserDisallowedByAdminOnly(guestRecord); records.add(guestRecord); records.add(guestRecord); } } Loading @@ -241,7 +251,7 @@ public class UserSwitcherController { if (!mSimpleUserSwitcher && canCreateUser) { if (!mSimpleUserSwitcher && canCreateUser) { UserRecord addUserRecord = new UserRecord(null /* info */, null /* picture */, UserRecord addUserRecord = new UserRecord(null /* info */, null /* picture */, false /* isGuest */, false /* isCurrent */, true /* isAddUser */, false /* isGuest */, false /* isCurrent */, true /* isAddUser */, createIsRestricted); createIsRestricted, allowUserSwitching); checkIfAddUserDisallowedByAdminOnly(addUserRecord); checkIfAddUserDisallowedByAdminOnly(addUserRecord); records.add(addUserRecord); records.add(addUserRecord); } } Loading Loading @@ -463,6 +473,12 @@ public class UserSwitcherController { } else if (Intent.ACTION_USER_INFO_CHANGED.equals(intent.getAction())) { } else if (Intent.ACTION_USER_INFO_CHANGED.equals(intent.getAction())) { forcePictureLoadForId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, forcePictureLoadForId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL); UserHandle.USER_NULL); } else if (Intent.ACTION_USER_UNLOCKED.equals(intent.getAction())) { // Unlocking the system user may require a refresh int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL); if (userId != UserHandle.USER_SYSTEM) { return; } } } refreshUsers(forcePictureLoadForId); refreshUsers(forcePictureLoadForId); if (unpauseRefreshUsers) { if (unpauseRefreshUsers) { Loading Loading @@ -525,6 +541,9 @@ public class UserSwitcherController { SIMPLE_USER_SWITCHER_GLOBAL_SETTING, 0) != 0; SIMPLE_USER_SWITCHER_GLOBAL_SETTING, 0) != 0; mAddUsersWhenLocked = Settings.Global.getInt(mContext.getContentResolver(), mAddUsersWhenLocked = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.ADD_USERS_WHEN_LOCKED, 0) != 0; Settings.Global.ADD_USERS_WHEN_LOCKED, 0) != 0; mAllowUserSwitchingWhenSystemUserLocked = Settings.Global.getInt( mContext.getContentResolver(), Settings.Global.ALLOW_USER_SWITCHING_WHEN_SYSTEM_USER_LOCKED, 0) != 0; refreshUsers(UserHandle.USER_NULL); refreshUsers(UserHandle.USER_NULL); }; }; }; }; Loading Loading @@ -646,26 +665,29 @@ public class UserSwitcherController { public final boolean isRestricted; public final boolean isRestricted; public boolean isDisabledByAdmin; public boolean isDisabledByAdmin; public EnforcedAdmin enforcedAdmin; public EnforcedAdmin enforcedAdmin; public boolean isSwitchToEnabled; public UserRecord(UserInfo info, Bitmap picture, boolean isGuest, boolean isCurrent, public UserRecord(UserInfo info, Bitmap picture, boolean isGuest, boolean isCurrent, boolean isAddUser, boolean isRestricted) { boolean isAddUser, boolean isRestricted, boolean isSwitchToEnabled) { this.info = info; this.info = info; this.picture = picture; this.picture = picture; this.isGuest = isGuest; this.isGuest = isGuest; this.isCurrent = isCurrent; this.isCurrent = isCurrent; this.isAddUser = isAddUser; this.isAddUser = isAddUser; this.isRestricted = isRestricted; this.isRestricted = isRestricted; this.isSwitchToEnabled = isSwitchToEnabled; } } public UserRecord copyWithIsCurrent(boolean _isCurrent) { public UserRecord copyWithIsCurrent(boolean _isCurrent) { return new UserRecord(info, picture, isGuest, _isCurrent, isAddUser, isRestricted); return new UserRecord(info, picture, isGuest, _isCurrent, isAddUser, isRestricted, isSwitchToEnabled); } } public String toString() { public String toString() { StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder(); sb.append("UserRecord("); sb.append("UserRecord("); if (info != null) { if (info != null) { sb.append("name=\"" + info.name + "\" id=" + info.id); sb.append("name=\"").append(info.name).append("\" id=").append(info.id); } else { } else { if (isGuest) { if (isGuest) { sb.append("<add guest placeholder>"); sb.append("<add guest placeholder>"); Loading @@ -680,7 +702,10 @@ public class UserSwitcherController { if (isRestricted) sb.append(" <isRestricted>"); if (isRestricted) sb.append(" <isRestricted>"); if (isDisabledByAdmin) { if (isDisabledByAdmin) { sb.append(" <isDisabledByAdmin>"); sb.append(" <isDisabledByAdmin>"); sb.append(" enforcedAdmin=" + enforcedAdmin); sb.append(" enforcedAdmin=").append(enforcedAdmin); } if (isSwitchToEnabled) { sb.append(" <isSwitchToEnabled>"); } } sb.append(')'); sb.append(')'); return sb.toString(); return sb.toString(); Loading Loading
core/java/android/provider/Settings.java +9 −0 Original line number Original line Diff line number Diff line Loading @@ -8155,6 +8155,15 @@ public final class Settings { public static final String UNINSTALLED_EPHEMERAL_APP_CACHE_DURATION_MILLIS = public static final String UNINSTALLED_EPHEMERAL_APP_CACHE_DURATION_MILLIS = "uninstalled_ephemeral_app_cache_duration_millis"; "uninstalled_ephemeral_app_cache_duration_millis"; /** * Allows switching users when system user is locked. * <p> * Type: int * @hide */ public static final String ALLOW_USER_SWITCHING_WHEN_SYSTEM_USER_LOCKED = "allow_user_switching_when_system_user_locked"; /** /** * Settings to backup. This is here so that it's in the same place as the settings * Settings to backup. This is here so that it's in the same place as the settings * keys and easy to update. * keys and easy to update. Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailItemView.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -103,6 +103,11 @@ public class UserDetailItemView extends LinearLayout { mAvatar.setDisabled(disabled); mAvatar.setDisabled(disabled); } } public void setEnabled(boolean enabled) { mName.setEnabled(enabled); mAvatar.setDisabled(!enabled); } @Override @Override protected void onFinishInflate() { protected void onFinishInflate() { mAvatar = (UserAvatarView) findViewById(R.id.user_picture); mAvatar = (UserAvatarView) findViewById(R.id.user_picture); Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java +4 −1 Original line number Original line Diff line number Diff line Loading @@ -82,6 +82,9 @@ public class UserDetailView extends PseudoGridView { } } v.setActivated(item.isCurrent); v.setActivated(item.isCurrent); v.setDisabledByAdmin(item.isDisabledByAdmin); v.setDisabledByAdmin(item.isDisabledByAdmin); if (!item.isSwitchToEnabled) { v.setEnabled(false); } v.setTag(item); v.setTag(item); return v; return v; } } Loading @@ -94,7 +97,7 @@ public class UserDetailView extends PseudoGridView { final Intent intent = RestrictedLockUtils.getShowAdminSupportDetailsIntent( final Intent intent = RestrictedLockUtils.getShowAdminSupportDetailsIntent( mContext, tag.enforcedAdmin); mContext, tag.enforcedAdmin); mController.startActivity(intent); mController.startActivity(intent); } else { } else if (tag.isSwitchToEnabled) { MetricsLogger.action(mContext, MetricsEvent.QS_SWITCH_USER); MetricsLogger.action(mContext, MetricsEvent.QS_SWITCH_USER); switchTo(tag); switchTo(tag); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java +11 −4 Original line number Original line Diff line number Diff line Loading @@ -21,6 +21,8 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.ObjectAnimator; import android.content.Context; import android.content.Context; import android.database.DataSetObserver; import android.database.DataSetObserver; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.MotionEvent; Loading Loading @@ -242,7 +244,6 @@ public class KeyguardUserSwitcher { @Override @Override public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) { UserSwitcherController.UserRecord item = getItem(position); UserSwitcherController.UserRecord item = getItem(position); if (!(convertView instanceof UserDetailItemView) if (!(convertView instanceof UserDetailItemView) || !(convertView.getTag() instanceof UserSwitcherController.UserRecord)) { || !(convertView.getTag() instanceof UserSwitcherController.UserRecord)) { convertView = LayoutInflater.from(mContext).inflate( convertView = LayoutInflater.from(mContext).inflate( Loading @@ -252,11 +253,17 @@ public class KeyguardUserSwitcher { UserDetailItemView v = (UserDetailItemView) convertView; UserDetailItemView v = (UserDetailItemView) convertView; String name = getName(mContext, item); String name = getName(mContext, item); Drawable drawable; if (item.picture == null) { if (item.picture == null) { v.bind(name, getDrawable(mContext, item)); drawable = getDrawable(mContext, item).mutate(); } else { } else { v.bind(name, item.picture); drawable = new BitmapDrawable(mContext.getResources(), item.picture); } // Disable the icon if switching is disabled if (!item.isSwitchToEnabled) { drawable.setTint(mContext.getColor(R.color.qs_tile_disabled_color)); } } v.bind(name, drawable); convertView.setActivated(item.isCurrent); convertView.setActivated(item.isCurrent); convertView.setTag(item); convertView.setTag(item); return convertView; return convertView; Loading @@ -269,7 +276,7 @@ public class KeyguardUserSwitcher { // Close the switcher if tapping the current user. Guest is excluded because // Close the switcher if tapping the current user. Guest is excluded because // tapping the guest user while it's current clears the session. // tapping the guest user while it's current clears the session. mKeyguardUserSwitcher.hideIfNotSimple(true /* animate */); mKeyguardUserSwitcher.hideIfNotSimple(true /* animate */); } else { } else if (user.isSwitchToEnabled) { switchTo(user); switchTo(user); } } } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java +33 −8 Original line number Original line Diff line number Diff line Loading @@ -99,6 +99,7 @@ public class UserSwitcherController { private boolean mSimpleUserSwitcher; private boolean mSimpleUserSwitcher; private boolean mAddUsersWhenLocked; private boolean mAddUsersWhenLocked; private boolean mPauseRefreshUsers; private boolean mPauseRefreshUsers; private boolean mAllowUserSwitchingWhenSystemUserLocked; private SparseBooleanArray mForcePictureLoadForUserId = new SparseBooleanArray(2); private SparseBooleanArray mForcePictureLoadForUserId = new SparseBooleanArray(2); public UserSwitcherController(Context context, KeyguardMonitor keyguardMonitor, public UserSwitcherController(Context context, KeyguardMonitor keyguardMonitor, Loading @@ -115,6 +116,7 @@ public class UserSwitcherController { filter.addAction(Intent.ACTION_USER_INFO_CHANGED); filter.addAction(Intent.ACTION_USER_INFO_CHANGED); filter.addAction(Intent.ACTION_USER_SWITCHED); filter.addAction(Intent.ACTION_USER_SWITCHED); filter.addAction(Intent.ACTION_USER_STOPPING); filter.addAction(Intent.ACTION_USER_STOPPING); filter.addAction(Intent.ACTION_USER_UNLOCKED); mContext.registerReceiverAsUser(mReceiver, UserHandle.SYSTEM, filter, mContext.registerReceiverAsUser(mReceiver, UserHandle.SYSTEM, filter, null /* permission */, null /* scheduler */); null /* permission */, null /* scheduler */); Loading @@ -130,6 +132,10 @@ public class UserSwitcherController { mContext.getContentResolver().registerContentObserver( mContext.getContentResolver().registerContentObserver( Settings.Global.getUriFor(Settings.Global.ADD_USERS_WHEN_LOCKED), true, Settings.Global.getUriFor(Settings.Global.ADD_USERS_WHEN_LOCKED), true, mSettingsObserver); mSettingsObserver); mContext.getContentResolver().registerContentObserver( Settings.Global.getUriFor( Settings.Global.ALLOW_USER_SWITCHING_WHEN_SYSTEM_USER_LOCKED), true, mSettingsObserver); // Fetch initial values. // Fetch initial values. mSettingsObserver.onChange(false); mSettingsObserver.onChange(false); Loading Loading @@ -180,6 +186,8 @@ public class UserSwitcherController { } } ArrayList<UserRecord> records = new ArrayList<>(infos.size()); ArrayList<UserRecord> records = new ArrayList<>(infos.size()); int currentId = ActivityManager.getCurrentUser(); int currentId = ActivityManager.getCurrentUser(); boolean allowUserSwitching = mAllowUserSwitchingWhenSystemUserLocked || mUserManager.isUserUnlocked(UserHandle.SYSTEM); UserInfo currentUserInfo = null; UserInfo currentUserInfo = null; UserRecord guestRecord = null; UserRecord guestRecord = null; int avatarSize = mContext.getResources() int avatarSize = mContext.getResources() Loading @@ -190,10 +198,11 @@ public class UserSwitcherController { if (isCurrent) { if (isCurrent) { currentUserInfo = info; currentUserInfo = info; } } boolean switchToEnabled = allowUserSwitching || isCurrent; if (info.isGuest()) { if (info.isGuest()) { guestRecord = new UserRecord(info, null /* picture */, guestRecord = new UserRecord(info, null /* picture */, true /* isGuest */, isCurrent, false /* isAddUser */, true /* isGuest */, isCurrent, false /* isAddUser */, false /* isRestricted */); false /* isRestricted */, switchToEnabled); } else if (info.isEnabled() && info.supportsSwitchToByUser()) { } else if (info.isEnabled() && info.supportsSwitchToByUser()) { Bitmap picture = bitmaps.get(info.id); Bitmap picture = bitmaps.get(info.id); if (picture == null) { if (picture == null) { Loading @@ -206,7 +215,8 @@ public class UserSwitcherController { } } int index = isCurrent ? 0 : records.size(); int index = isCurrent ? 0 : records.size(); records.add(index, new UserRecord(info, picture, false /* isGuest */, records.add(index, new UserRecord(info, picture, false /* isGuest */, isCurrent, false /* isAddUser */, false /* isRestricted */)); isCurrent, false /* isAddUser */, false /* isRestricted */, switchToEnabled)); } } } } Loading @@ -228,7 +238,7 @@ public class UserSwitcherController { if (canCreateGuest) { if (canCreateGuest) { guestRecord = new UserRecord(null /* info */, null /* picture */, guestRecord = new UserRecord(null /* info */, null /* picture */, true /* isGuest */, false /* isCurrent */, true /* isGuest */, false /* isCurrent */, false /* isAddUser */, createIsRestricted); false /* isAddUser */, createIsRestricted, allowUserSwitching); checkIfAddUserDisallowedByAdminOnly(guestRecord); checkIfAddUserDisallowedByAdminOnly(guestRecord); records.add(guestRecord); records.add(guestRecord); } } Loading @@ -241,7 +251,7 @@ public class UserSwitcherController { if (!mSimpleUserSwitcher && canCreateUser) { if (!mSimpleUserSwitcher && canCreateUser) { UserRecord addUserRecord = new UserRecord(null /* info */, null /* picture */, UserRecord addUserRecord = new UserRecord(null /* info */, null /* picture */, false /* isGuest */, false /* isCurrent */, true /* isAddUser */, false /* isGuest */, false /* isCurrent */, true /* isAddUser */, createIsRestricted); createIsRestricted, allowUserSwitching); checkIfAddUserDisallowedByAdminOnly(addUserRecord); checkIfAddUserDisallowedByAdminOnly(addUserRecord); records.add(addUserRecord); records.add(addUserRecord); } } Loading Loading @@ -463,6 +473,12 @@ public class UserSwitcherController { } else if (Intent.ACTION_USER_INFO_CHANGED.equals(intent.getAction())) { } else if (Intent.ACTION_USER_INFO_CHANGED.equals(intent.getAction())) { forcePictureLoadForId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, forcePictureLoadForId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL); UserHandle.USER_NULL); } else if (Intent.ACTION_USER_UNLOCKED.equals(intent.getAction())) { // Unlocking the system user may require a refresh int userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, UserHandle.USER_NULL); if (userId != UserHandle.USER_SYSTEM) { return; } } } refreshUsers(forcePictureLoadForId); refreshUsers(forcePictureLoadForId); if (unpauseRefreshUsers) { if (unpauseRefreshUsers) { Loading Loading @@ -525,6 +541,9 @@ public class UserSwitcherController { SIMPLE_USER_SWITCHER_GLOBAL_SETTING, 0) != 0; SIMPLE_USER_SWITCHER_GLOBAL_SETTING, 0) != 0; mAddUsersWhenLocked = Settings.Global.getInt(mContext.getContentResolver(), mAddUsersWhenLocked = Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.ADD_USERS_WHEN_LOCKED, 0) != 0; Settings.Global.ADD_USERS_WHEN_LOCKED, 0) != 0; mAllowUserSwitchingWhenSystemUserLocked = Settings.Global.getInt( mContext.getContentResolver(), Settings.Global.ALLOW_USER_SWITCHING_WHEN_SYSTEM_USER_LOCKED, 0) != 0; refreshUsers(UserHandle.USER_NULL); refreshUsers(UserHandle.USER_NULL); }; }; }; }; Loading Loading @@ -646,26 +665,29 @@ public class UserSwitcherController { public final boolean isRestricted; public final boolean isRestricted; public boolean isDisabledByAdmin; public boolean isDisabledByAdmin; public EnforcedAdmin enforcedAdmin; public EnforcedAdmin enforcedAdmin; public boolean isSwitchToEnabled; public UserRecord(UserInfo info, Bitmap picture, boolean isGuest, boolean isCurrent, public UserRecord(UserInfo info, Bitmap picture, boolean isGuest, boolean isCurrent, boolean isAddUser, boolean isRestricted) { boolean isAddUser, boolean isRestricted, boolean isSwitchToEnabled) { this.info = info; this.info = info; this.picture = picture; this.picture = picture; this.isGuest = isGuest; this.isGuest = isGuest; this.isCurrent = isCurrent; this.isCurrent = isCurrent; this.isAddUser = isAddUser; this.isAddUser = isAddUser; this.isRestricted = isRestricted; this.isRestricted = isRestricted; this.isSwitchToEnabled = isSwitchToEnabled; } } public UserRecord copyWithIsCurrent(boolean _isCurrent) { public UserRecord copyWithIsCurrent(boolean _isCurrent) { return new UserRecord(info, picture, isGuest, _isCurrent, isAddUser, isRestricted); return new UserRecord(info, picture, isGuest, _isCurrent, isAddUser, isRestricted, isSwitchToEnabled); } } public String toString() { public String toString() { StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder(); sb.append("UserRecord("); sb.append("UserRecord("); if (info != null) { if (info != null) { sb.append("name=\"" + info.name + "\" id=" + info.id); sb.append("name=\"").append(info.name).append("\" id=").append(info.id); } else { } else { if (isGuest) { if (isGuest) { sb.append("<add guest placeholder>"); sb.append("<add guest placeholder>"); Loading @@ -680,7 +702,10 @@ public class UserSwitcherController { if (isRestricted) sb.append(" <isRestricted>"); if (isRestricted) sb.append(" <isRestricted>"); if (isDisabledByAdmin) { if (isDisabledByAdmin) { sb.append(" <isDisabledByAdmin>"); sb.append(" <isDisabledByAdmin>"); sb.append(" enforcedAdmin=" + enforcedAdmin); sb.append(" enforcedAdmin=").append(enforcedAdmin); } if (isSwitchToEnabled) { sb.append(" <isSwitchToEnabled>"); } } sb.append(')'); sb.append(')'); return sb.toString(); return sb.toString(); Loading