diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 5d78008d6b28b..921e18f18dff8 100755 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -8155,6 +8155,15 @@ public final class Settings { public static final String UNINSTALLED_EPHEMERAL_APP_CACHE_DURATION_MILLIS = "uninstalled_ephemeral_app_cache_duration_millis"; + /** + * Allows switching users when system user is locked. + *
+ * 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
* keys and easy to update.
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailItemView.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailItemView.java
index 33befd0058b91..fcf758b458686 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailItemView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailItemView.java
@@ -103,6 +103,11 @@ public class UserDetailItemView extends LinearLayout {
mAvatar.setDisabled(disabled);
}
+ public void setEnabled(boolean enabled) {
+ mName.setEnabled(enabled);
+ mAvatar.setDisabled(!enabled);
+ }
+
@Override
protected void onFinishInflate() {
mAvatar = (UserAvatarView) findViewById(R.id.user_picture);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java
index 2c8a4784e5f2a..da98762352631 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java
@@ -82,6 +82,9 @@ public class UserDetailView extends PseudoGridView {
}
v.setActivated(item.isCurrent);
v.setDisabledByAdmin(item.isDisabledByAdmin);
+ if (!item.isSwitchToEnabled) {
+ v.setEnabled(false);
+ }
v.setTag(item);
return v;
}
@@ -94,7 +97,7 @@ public class UserDetailView extends PseudoGridView {
final Intent intent = RestrictedLockUtils.getShowAdminSupportDetailsIntent(
mContext, tag.enforcedAdmin);
mController.startActivity(intent);
- } else {
+ } else if (tag.isSwitchToEnabled) {
MetricsLogger.action(mContext, MetricsEvent.QS_SWITCH_USER);
switchTo(tag);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
index 867a8a3ca833a..fb310a64a3585 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
@@ -21,6 +21,8 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.database.DataSetObserver;
+import android.graphics.drawable.BitmapDrawable;
+import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -242,7 +244,6 @@ public class KeyguardUserSwitcher {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
UserSwitcherController.UserRecord item = getItem(position);
-
if (!(convertView instanceof UserDetailItemView)
|| !(convertView.getTag() instanceof UserSwitcherController.UserRecord)) {
convertView = LayoutInflater.from(mContext).inflate(
@@ -252,11 +253,17 @@ public class KeyguardUserSwitcher {
UserDetailItemView v = (UserDetailItemView) convertView;
String name = getName(mContext, item);
+ Drawable drawable;
if (item.picture == null) {
- v.bind(name, getDrawable(mContext, item));
+ drawable = getDrawable(mContext, item).mutate();
} 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.setTag(item);
return convertView;
@@ -269,7 +276,7 @@ public class KeyguardUserSwitcher {
// Close the switcher if tapping the current user. Guest is excluded because
// tapping the guest user while it's current clears the session.
mKeyguardUserSwitcher.hideIfNotSimple(true /* animate */);
- } else {
+ } else if (user.isSwitchToEnabled) {
switchTo(user);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
index 13369f2e36f5b..4c67010f54aa7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
@@ -99,6 +99,7 @@ public class UserSwitcherController {
private boolean mSimpleUserSwitcher;
private boolean mAddUsersWhenLocked;
private boolean mPauseRefreshUsers;
+ private boolean mAllowUserSwitchingWhenSystemUserLocked;
private SparseBooleanArray mForcePictureLoadForUserId = new SparseBooleanArray(2);
public UserSwitcherController(Context context, KeyguardMonitor keyguardMonitor,
@@ -115,6 +116,7 @@ public class UserSwitcherController {
filter.addAction(Intent.ACTION_USER_INFO_CHANGED);
filter.addAction(Intent.ACTION_USER_SWITCHED);
filter.addAction(Intent.ACTION_USER_STOPPING);
+ filter.addAction(Intent.ACTION_USER_UNLOCKED);
mContext.registerReceiverAsUser(mReceiver, UserHandle.SYSTEM, filter,
null /* permission */, null /* scheduler */);
@@ -130,6 +132,10 @@ public class UserSwitcherController {
mContext.getContentResolver().registerContentObserver(
Settings.Global.getUriFor(Settings.Global.ADD_USERS_WHEN_LOCKED), true,
mSettingsObserver);
+ mContext.getContentResolver().registerContentObserver(
+ Settings.Global.getUriFor(
+ Settings.Global.ALLOW_USER_SWITCHING_WHEN_SYSTEM_USER_LOCKED),
+ true, mSettingsObserver);
// Fetch initial values.
mSettingsObserver.onChange(false);
@@ -180,6 +186,8 @@ public class UserSwitcherController {
}
ArrayList