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

Commit b9605c1a authored by felipeal's avatar felipeal Committed by android-build-merger
Browse files

Merge "Issue a warning when the user switching dialog times out." into qt-qpr1-dev am: 839c5ec5

am: 80332ab6

Change-Id: I7ca0244e7255d49f9ab11a54cf89c42dc49ba1ec
parents c83bb571 80332ab6
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.Handler;
import android.os.Message;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Slog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewTreeObserver;
@@ -46,6 +47,8 @@ class UserSwitchingDialog extends AlertDialog
    // Time to wait for the onWindowShown() callback before continuing the user switch
    private static final int WINDOW_SHOWN_TIMEOUT_MS = 3000;

    private static final boolean DEBUG = false;

    private final ActivityManagerService mService;
    private final int mUserId;
    private static final int MSG_START_USER = 1;
@@ -118,7 +121,7 @@ class UserSwitchingDialog extends AlertDialog

    @Override
    public void show() {
        // Slog.v(TAG, "show called");
        if (DEBUG) Slog.d(TAG, "show called");
        super.show();
        final View decorView = getWindow().getDecorView();
        if (decorView != null) {
@@ -132,13 +135,14 @@ class UserSwitchingDialog extends AlertDialog

    @Override
    public void onWindowShown() {
        // Slog.v(TAG, "onWindowShown called");
        if (DEBUG) Slog.d(TAG, "onWindowShown called");
        startUser();
    }

    void startUser() {
        synchronized (this) {
            if (!mStartedUser) {
                Slog.i(TAG, "starting user " + mUserId);
                mService.mUserController.startUserInForeground(mUserId);
                dismiss();
                mStartedUser = true;
@@ -147,6 +151,8 @@ class UserSwitchingDialog extends AlertDialog
                    decorView.getViewTreeObserver().removeOnWindowShownListener(this);
                }
                mHandler.removeMessages(MSG_START_USER);
            } else {
                Slog.i(TAG, "user " + mUserId + " already started");
            }
        }
    }
@@ -156,6 +162,8 @@ class UserSwitchingDialog extends AlertDialog
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case MSG_START_USER:
                    Slog.w(TAG, "user switch window not shown in "
                            + WINDOW_SHOWN_TIMEOUT_MS + " ms");
                    startUser();
                    break;
            }