Refresh user list a little more eagerly
Unfortunately, we don't get a signal when user restrictions such as
for adding new users change. That means the user switcher UI could get
out of sync and showed the add user option when in fact it couldn't add one.
Also cleans up an unused method.
Bug: 18292723
Change-Id: I56f6f848d967d9d1c11bd6262eacbdb11f90cfe2
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 c524edc..6bad652 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/UserDetailView.java
@@ -47,6 +47,10 @@
ViewGroupAdapterBridge.link(this, mAdapter);
}
+ public void refreshAdapter() {
+ mAdapter.refresh();
+ }
+
public static class Adapter extends UserSwitcherController.BaseUserAdapter
implements OnClickListener {
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 7ee1fc5..1460e5f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyguardUserSwitcher.java
@@ -107,6 +107,7 @@
public void show(boolean animate) {
if (mUserSwitcher != null && mUserSwitcherContainer.getVisibility() != View.VISIBLE) {
cancelAnimations();
+ mAdapter.refresh();
mUserSwitcherContainer.setVisibility(View.VISIBLE);
mStatusBarView.setKeyguardUserSwitcherShowing(true, animate);
if (animate) {
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 e5b357a..4ac41a1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/UserSwitcherController.java
@@ -417,18 +417,6 @@
}
}
- public int getSwitchableUsers() {
- int result = 0;
- ArrayList<UserRecord> users = mController.mUsers;
- int N = users.size();
- for (int i = 0; i < N; i++) {
- if (users.get(i).info != null) {
- result++;
- }
- }
- return result;
- }
-
public Drawable getDrawable(Context context, UserRecord item) {
if (item.isAddUser) {
return context.getDrawable(R.drawable.ic_add_circle_qs);
@@ -436,6 +424,10 @@
return UserIcons.getDefaultUserIcon(item.isGuest ? UserHandle.USER_NULL : item.info.id,
/* light= */ true);
}
+
+ public void refresh() {
+ mController.refreshUsers(UserHandle.USER_NULL);
+ }
}
public static final class UserRecord {
@@ -500,6 +492,7 @@
} else {
v = (UserDetailView) convertView;
}
+ v.refreshAdapter();
return v;
}