* commit '16b7492240b92a81332e61680f51073da8af186c': Fix janky add guest transition
This commit is contained in:
@@ -602,7 +602,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
addNavigationBar();
|
addNavigationBar();
|
||||||
|
|
||||||
// Lastly, call to the icon policy to install/update all the icons.
|
// Lastly, call to the icon policy to install/update all the icons.
|
||||||
mIconPolicy = new PhoneStatusBarPolicy(mContext, mCastController, mHotspotController);
|
mIconPolicy = new PhoneStatusBarPolicy(mContext, mCastController, mHotspotController,
|
||||||
|
mUserInfoController);
|
||||||
mIconPolicy.setCurrentUserSetup(mUserSetup);
|
mIconPolicy.setCurrentUserSetup(mUserSetup);
|
||||||
mSettingsObserver.onChange(false); // set up
|
mSettingsObserver.onChange(false); // set up
|
||||||
|
|
||||||
@@ -851,7 +852,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
mNextAlarmController = new NextAlarmController(mContext);
|
mNextAlarmController = new NextAlarmController(mContext);
|
||||||
mKeyguardMonitor = new KeyguardMonitor(mContext);
|
mKeyguardMonitor = new KeyguardMonitor(mContext);
|
||||||
if (UserSwitcherController.isUserSwitcherAvailable(UserManager.get(mContext))) {
|
if (UserSwitcherController.isUserSwitcherAvailable(UserManager.get(mContext))) {
|
||||||
mUserSwitcherController = new UserSwitcherController(mContext, mKeyguardMonitor);
|
mUserSwitcherController = new UserSwitcherController(mContext, mKeyguardMonitor,
|
||||||
|
mHandler);
|
||||||
}
|
}
|
||||||
mKeyguardUserSwitcher = new KeyguardUserSwitcher(mContext,
|
mKeyguardUserSwitcher = new KeyguardUserSwitcher(mContext,
|
||||||
(ViewStub) mStatusBarWindow.findViewById(R.id.keyguard_user_switcher),
|
(ViewStub) mStatusBarWindow.findViewById(R.id.keyguard_user_switcher),
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import com.android.systemui.qs.tiles.DndTile;
|
|||||||
import com.android.systemui.statusbar.policy.CastController;
|
import com.android.systemui.statusbar.policy.CastController;
|
||||||
import com.android.systemui.statusbar.policy.CastController.CastDevice;
|
import com.android.systemui.statusbar.policy.CastController.CastDevice;
|
||||||
import com.android.systemui.statusbar.policy.HotspotController;
|
import com.android.systemui.statusbar.policy.HotspotController;
|
||||||
|
import com.android.systemui.statusbar.policy.UserInfoController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains all of the policy about which icons are installed in the status
|
* This class contains all of the policy about which icons are installed in the status
|
||||||
@@ -69,6 +70,7 @@ public class PhoneStatusBarPolicy {
|
|||||||
private final CastController mCast;
|
private final CastController mCast;
|
||||||
private final HotspotController mHotspot;
|
private final HotspotController mHotspot;
|
||||||
private final AlarmManager mAlarmManager;
|
private final AlarmManager mAlarmManager;
|
||||||
|
private final UserInfoController mUserInfoController;
|
||||||
|
|
||||||
// Assume it's all good unless we hear otherwise. We don't always seem
|
// Assume it's all good unless we hear otherwise. We don't always seem
|
||||||
// to get broadcasts that it *is* there.
|
// to get broadcasts that it *is* there.
|
||||||
@@ -111,12 +113,14 @@ public class PhoneStatusBarPolicy {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public PhoneStatusBarPolicy(Context context, CastController cast, HotspotController hotspot) {
|
public PhoneStatusBarPolicy(Context context, CastController cast, HotspotController hotspot,
|
||||||
|
UserInfoController userInfoController) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mCast = cast;
|
mCast = cast;
|
||||||
mHotspot = hotspot;
|
mHotspot = hotspot;
|
||||||
mService = (StatusBarManager) context.getSystemService(Context.STATUS_BAR_SERVICE);
|
mService = (StatusBarManager) context.getSystemService(Context.STATUS_BAR_SERVICE);
|
||||||
mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||||
|
mUserInfoController = userInfoController;
|
||||||
|
|
||||||
// listen for broadcasts
|
// listen for broadcasts
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
@@ -360,6 +364,7 @@ public class PhoneStatusBarPolicy {
|
|||||||
new IUserSwitchObserver.Stub() {
|
new IUserSwitchObserver.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void onUserSwitching(int newUserId, IRemoteCallback reply) {
|
public void onUserSwitching(int newUserId, IRemoteCallback reply) {
|
||||||
|
mUserInfoController.reloadUserInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ import android.os.UserManager;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
|
import android.util.SparseBooleanArray;
|
||||||
|
import android.util.SparseIntArray;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
@@ -68,6 +70,7 @@ public class UserSwitcherController {
|
|||||||
private static final String SIMPLE_USER_SWITCHER_GLOBAL_SETTING =
|
private static final String SIMPLE_USER_SWITCHER_GLOBAL_SETTING =
|
||||||
"lockscreenSimpleUserSwitcher";
|
"lockscreenSimpleUserSwitcher";
|
||||||
private static final String ACTION_REMOVE_GUEST = "com.android.systemui.REMOVE_GUEST";
|
private static final String ACTION_REMOVE_GUEST = "com.android.systemui.REMOVE_GUEST";
|
||||||
|
private static final int PAUSE_REFRESH_USERS_TIMEOUT_MS = 3000;
|
||||||
|
|
||||||
private static final int ID_REMOVE_GUEST = 1010;
|
private static final int ID_REMOVE_GUEST = 1010;
|
||||||
private static final String TAG_REMOVE_GUEST = "remove_guest";
|
private static final String TAG_REMOVE_GUEST = "remove_guest";
|
||||||
@@ -79,6 +82,7 @@ public class UserSwitcherController {
|
|||||||
private final GuestResumeSessionReceiver mGuestResumeSessionReceiver
|
private final GuestResumeSessionReceiver mGuestResumeSessionReceiver
|
||||||
= new GuestResumeSessionReceiver();
|
= new GuestResumeSessionReceiver();
|
||||||
private final KeyguardMonitor mKeyguardMonitor;
|
private final KeyguardMonitor mKeyguardMonitor;
|
||||||
|
private final Handler mHandler;
|
||||||
|
|
||||||
private ArrayList<UserRecord> mUsers = new ArrayList<>();
|
private ArrayList<UserRecord> mUsers = new ArrayList<>();
|
||||||
private Dialog mExitGuestDialog;
|
private Dialog mExitGuestDialog;
|
||||||
@@ -86,11 +90,15 @@ public class UserSwitcherController {
|
|||||||
private int mLastNonGuestUser = UserHandle.USER_OWNER;
|
private int mLastNonGuestUser = UserHandle.USER_OWNER;
|
||||||
private boolean mSimpleUserSwitcher;
|
private boolean mSimpleUserSwitcher;
|
||||||
private boolean mAddUsersWhenLocked;
|
private boolean mAddUsersWhenLocked;
|
||||||
|
private boolean mPauseRefreshUsers;
|
||||||
|
private SparseBooleanArray mForcePictureLoadForUserId = new SparseBooleanArray(2);
|
||||||
|
|
||||||
public UserSwitcherController(Context context, KeyguardMonitor keyguardMonitor) {
|
public UserSwitcherController(Context context, KeyguardMonitor keyguardMonitor,
|
||||||
|
Handler handler) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mGuestResumeSessionReceiver.register(context);
|
mGuestResumeSessionReceiver.register(context);
|
||||||
mKeyguardMonitor = keyguardMonitor;
|
mKeyguardMonitor = keyguardMonitor;
|
||||||
|
mHandler = handler;
|
||||||
mUserManager = UserManager.get(context);
|
mUserManager = UserManager.get(context);
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addAction(Intent.ACTION_USER_ADDED);
|
filter.addAction(Intent.ACTION_USER_ADDED);
|
||||||
@@ -129,17 +137,26 @@ public class UserSwitcherController {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void refreshUsers(int forcePictureLoadForId) {
|
private void refreshUsers(int forcePictureLoadForId) {
|
||||||
|
if (DEBUG) Log.d(TAG, "refreshUsers(forcePictureLoadForId=" + forcePictureLoadForId+")");
|
||||||
|
if (forcePictureLoadForId != UserHandle.USER_NULL) {
|
||||||
|
mForcePictureLoadForUserId.put(forcePictureLoadForId, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mPauseRefreshUsers) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SparseArray<Bitmap> bitmaps = new SparseArray<>(mUsers.size());
|
SparseArray<Bitmap> bitmaps = new SparseArray<>(mUsers.size());
|
||||||
final int N = mUsers.size();
|
final int N = mUsers.size();
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
UserRecord r = mUsers.get(i);
|
UserRecord r = mUsers.get(i);
|
||||||
if (r == null || r.info == null
|
if (r == null || r.picture == null ||
|
||||||
|| r.info.id == forcePictureLoadForId || r.picture == null) {
|
r.info == null || mForcePictureLoadForUserId.get(r.info.id)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
bitmaps.put(r.info.id, r.picture);
|
bitmaps.put(r.info.id, r.picture);
|
||||||
}
|
}
|
||||||
|
mForcePictureLoadForUserId.clear();
|
||||||
|
|
||||||
final boolean addUsersWhenLocked = mAddUsersWhenLocked;
|
final boolean addUsersWhenLocked = mAddUsersWhenLocked;
|
||||||
new AsyncTask<SparseArray<Bitmap>, Void, ArrayList<UserRecord>>() {
|
new AsyncTask<SparseArray<Bitmap>, Void, ArrayList<UserRecord>>() {
|
||||||
@@ -222,6 +239,13 @@ public class UserSwitcherController {
|
|||||||
}.execute((SparseArray) bitmaps);
|
}.execute((SparseArray) bitmaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void pauseRefreshUsers() {
|
||||||
|
if (!mPauseRefreshUsers) {
|
||||||
|
mHandler.postDelayed(mUnpauseRefreshUsers, PAUSE_REFRESH_USERS_TIMEOUT_MS);
|
||||||
|
mPauseRefreshUsers = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void notifyAdapters() {
|
private void notifyAdapters() {
|
||||||
for (int i = mAdapters.size() - 1; i >= 0; i--) {
|
for (int i = mAdapters.size() - 1; i >= 0; i--) {
|
||||||
BaseUserAdapter adapter = mAdapters.get(i).get();
|
BaseUserAdapter adapter = mAdapters.get(i).get();
|
||||||
@@ -268,6 +292,7 @@ public class UserSwitcherController {
|
|||||||
|
|
||||||
private void switchToUserId(int id) {
|
private void switchToUserId(int id) {
|
||||||
try {
|
try {
|
||||||
|
pauseRefreshUsers();
|
||||||
ActivityManagerNative.getDefault().switchUser(id);
|
ActivityManagerNative.getDefault().switchUser(id);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(TAG, "Couldn't switch user.", e);
|
Log.e(TAG, "Couldn't switch user.", e);
|
||||||
@@ -309,6 +334,10 @@ public class UserSwitcherController {
|
|||||||
Log.v(TAG, "Broadcast: a=" + intent.getAction()
|
Log.v(TAG, "Broadcast: a=" + intent.getAction()
|
||||||
+ " user=" + intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1));
|
+ " user=" + intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean unpauseRefreshUsers = false;
|
||||||
|
int forcePictureLoadForId = UserHandle.USER_NULL;
|
||||||
|
|
||||||
if (ACTION_REMOVE_GUEST.equals(intent.getAction())) {
|
if (ACTION_REMOVE_GUEST.equals(intent.getAction())) {
|
||||||
int currentUser = ActivityManager.getCurrentUser();
|
int currentUser = ActivityManager.getCurrentUser();
|
||||||
UserInfo userInfo = mUserManager.getUserInfo(currentUser);
|
UserInfo userInfo = mUserManager.getUserInfo(currentUser);
|
||||||
@@ -316,16 +345,13 @@ public class UserSwitcherController {
|
|||||||
showExitGuestDialog(currentUser);
|
showExitGuestDialog(currentUser);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
} else if (Intent.ACTION_USER_ADDED.equals(intent.getAction())) {
|
||||||
if (Intent.ACTION_USER_ADDED.equals(intent.getAction())) {
|
|
||||||
final int currentId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
|
final int currentId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1);
|
||||||
UserInfo userInfo = mUserManager.getUserInfo(currentId);
|
UserInfo userInfo = mUserManager.getUserInfo(currentId);
|
||||||
if (userInfo != null && userInfo.isGuest()) {
|
if (userInfo != null && userInfo.isGuest()) {
|
||||||
showGuestNotification(currentId);
|
showGuestNotification(currentId);
|
||||||
}
|
}
|
||||||
}
|
} else if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) {
|
||||||
|
|
||||||
if (Intent.ACTION_USER_SWITCHED.equals(intent.getAction())) {
|
|
||||||
if (mExitGuestDialog != null && mExitGuestDialog.isShowing()) {
|
if (mExitGuestDialog != null && mExitGuestDialog.isShowing()) {
|
||||||
mExitGuestDialog.cancel();
|
mExitGuestDialog.cancel();
|
||||||
mExitGuestDialog = null;
|
mExitGuestDialog = null;
|
||||||
@@ -350,13 +376,15 @@ public class UserSwitcherController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifyAdapters();
|
notifyAdapters();
|
||||||
}
|
unpauseRefreshUsers = true;
|
||||||
int forcePictureLoadForId = UserHandle.USER_NULL;
|
} else if (Intent.ACTION_USER_INFO_CHANGED.equals(intent.getAction())) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
refreshUsers(forcePictureLoadForId);
|
refreshUsers(forcePictureLoadForId);
|
||||||
|
if (unpauseRefreshUsers) {
|
||||||
|
mUnpauseRefreshUsers.run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showGuestNotification(int guestUserId) {
|
private void showGuestNotification(int guestUserId) {
|
||||||
@@ -378,6 +406,15 @@ public class UserSwitcherController {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private final Runnable mUnpauseRefreshUsers = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
mHandler.removeCallbacks(this);
|
||||||
|
mPauseRefreshUsers = false;
|
||||||
|
refreshUsers(UserHandle.USER_NULL);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private final ContentObserver mSettingsObserver = new ContentObserver(new Handler()) {
|
private final ContentObserver mSettingsObserver = new ContentObserver(new Handler()) {
|
||||||
public void onChange(boolean selfChange) {
|
public void onChange(boolean selfChange) {
|
||||||
mSimpleUserSwitcher = Settings.Global.getInt(mContext.getContentResolver(),
|
mSimpleUserSwitcher = Settings.Global.getInt(mContext.getContentResolver(),
|
||||||
|
|||||||
Reference in New Issue
Block a user