Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b8030515 authored by jovanak's avatar jovanak
Browse files

Fixing when the full-screen switcher appears.

Now, full screen user switcher always shows up on reboot.

The switcher is dismissed after "switch" to another user
is detected.
Switching should lead to authentication directly

Bug: 74445625
Test: Repeated boot and switch on Mojave, with single and many users.
Change-Id: Ia1645246276d9eb65288c01c8c320c82a796d442
parent a153811a
Loading
Loading
Loading
Loading
+25 −4
Original line number Diff line number Diff line
@@ -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;

@@ -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) {
@@ -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);

@@ -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 */);
    }