Loading packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java +25 −4 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ import android.widget.ProgressBar; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; import com.android.settingslib.users.UserManagerHelper; import com.android.systemui.R; import com.android.systemui.statusbar.phone.StatusBar; Loading @@ -38,7 +40,8 @@ public class FullscreenUserSwitcher { private final ProgressBar mSwitchingUsers; private final int mShortAnimDuration; private final StatusBar mStatusBar; private final UserManagerHelper mUserManagerHelper; private int mCurrentForegroundUserId; private boolean mShowing; public FullscreenUserSwitcher(StatusBar statusBar, ViewStub containerStub, Context context) { Loading @@ -52,6 +55,9 @@ public class FullscreenUserSwitcher { mUserGridView.buildAdapter(); mUserGridView.setUserSelectionListener(this::onUserSelected); mUserManagerHelper = new UserManagerHelper(context); updateCurrentForegroundUser(); mShortAnimDuration = mContainer.getResources() .getInteger(android.R.integer.config_shortAnimTime); Loading @@ -73,18 +79,33 @@ public class FullscreenUserSwitcher { } public void onUserSwitched(int newUserId) { mParent.post(this::showOfflineAuthUi); // The logic for foreground user change is needed here to exclude the reboot case. On // reboot, system fires ACTION_USER_SWITCHED change from -1 to 0 user. This is not an actual // user switch. We only want to trigger keyguard dismissal when foreground user changes. if (foregroundUserChanged()) { updateCurrentForegroundUser(); mParent.post(this::dismissKeyguard); } } private boolean foregroundUserChanged() { return mCurrentForegroundUserId != mUserManagerHelper.getForegroundUserId(); } private void updateCurrentForegroundUser() { mCurrentForegroundUserId = mUserManagerHelper.getForegroundUserId(); } private void onUserSelected(UserGridRecyclerView.UserRecord record) { if (record.mIsForeground) { showOfflineAuthUi(); dismissKeyguard(); return; } toggleSwitchInProgress(true); } private void showOfflineAuthUi() { // Dismisses the keyguard and shows bouncer if authentication is necessary. private void dismissKeyguard() { mStatusBar.executeRunnableDismissingKeyguard(null/* runnable */, null /* cancelAction */, true /* dismissShade */, true /* afterKeyguardGone */, true /* deferred */); } Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java +25 −4 Original line number Diff line number Diff line Loading @@ -25,6 +25,8 @@ import android.widget.ProgressBar; import android.support.v7.widget.GridLayoutManager; import android.support.v7.widget.RecyclerView; import com.android.settingslib.users.UserManagerHelper; import com.android.systemui.R; import com.android.systemui.statusbar.phone.StatusBar; Loading @@ -38,7 +40,8 @@ public class FullscreenUserSwitcher { private final ProgressBar mSwitchingUsers; private final int mShortAnimDuration; private final StatusBar mStatusBar; private final UserManagerHelper mUserManagerHelper; private int mCurrentForegroundUserId; private boolean mShowing; public FullscreenUserSwitcher(StatusBar statusBar, ViewStub containerStub, Context context) { Loading @@ -52,6 +55,9 @@ public class FullscreenUserSwitcher { mUserGridView.buildAdapter(); mUserGridView.setUserSelectionListener(this::onUserSelected); mUserManagerHelper = new UserManagerHelper(context); updateCurrentForegroundUser(); mShortAnimDuration = mContainer.getResources() .getInteger(android.R.integer.config_shortAnimTime); Loading @@ -73,18 +79,33 @@ public class FullscreenUserSwitcher { } public void onUserSwitched(int newUserId) { mParent.post(this::showOfflineAuthUi); // The logic for foreground user change is needed here to exclude the reboot case. On // reboot, system fires ACTION_USER_SWITCHED change from -1 to 0 user. This is not an actual // user switch. We only want to trigger keyguard dismissal when foreground user changes. if (foregroundUserChanged()) { updateCurrentForegroundUser(); mParent.post(this::dismissKeyguard); } } private boolean foregroundUserChanged() { return mCurrentForegroundUserId != mUserManagerHelper.getForegroundUserId(); } private void updateCurrentForegroundUser() { mCurrentForegroundUserId = mUserManagerHelper.getForegroundUserId(); } private void onUserSelected(UserGridRecyclerView.UserRecord record) { if (record.mIsForeground) { showOfflineAuthUi(); dismissKeyguard(); return; } toggleSwitchInProgress(true); } private void showOfflineAuthUi() { // Dismisses the keyguard and shows bouncer if authentication is necessary. private void dismissKeyguard() { mStatusBar.executeRunnableDismissingKeyguard(null/* runnable */, null /* cancelAction */, true /* dismissShade */, true /* afterKeyguardGone */, true /* deferred */); } Loading