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

Change-Id: Ie051016e9f38f4c453f4137dc50fd9e55ab53a83
This commit is contained in:
Automerger Merge Worker
2019-12-07 06:44:34 +00:00

View File

@@ -24,6 +24,7 @@ import android.os.Handler;
import android.os.Message; import android.os.Message;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.UserManager; import android.os.UserManager;
import android.util.Slog;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewTreeObserver; import android.view.ViewTreeObserver;
@@ -46,6 +47,8 @@ class UserSwitchingDialog extends AlertDialog
// Time to wait for the onWindowShown() callback before continuing the user switch // Time to wait for the onWindowShown() callback before continuing the user switch
private static final int WINDOW_SHOWN_TIMEOUT_MS = 3000; private static final int WINDOW_SHOWN_TIMEOUT_MS = 3000;
private static final boolean DEBUG = false;
private final ActivityManagerService mService; private final ActivityManagerService mService;
private final int mUserId; private final int mUserId;
private static final int MSG_START_USER = 1; private static final int MSG_START_USER = 1;
@@ -118,7 +121,7 @@ class UserSwitchingDialog extends AlertDialog
@Override @Override
public void show() { public void show() {
// Slog.v(TAG, "show called"); if (DEBUG) Slog.d(TAG, "show called");
super.show(); super.show();
final View decorView = getWindow().getDecorView(); final View decorView = getWindow().getDecorView();
if (decorView != null) { if (decorView != null) {
@@ -132,13 +135,14 @@ class UserSwitchingDialog extends AlertDialog
@Override @Override
public void onWindowShown() { public void onWindowShown() {
// Slog.v(TAG, "onWindowShown called"); if (DEBUG) Slog.d(TAG, "onWindowShown called");
startUser(); startUser();
} }
void startUser() { void startUser() {
synchronized (this) { synchronized (this) {
if (!mStartedUser) { if (!mStartedUser) {
Slog.i(TAG, "starting user " + mUserId);
mService.mUserController.startUserInForeground(mUserId); mService.mUserController.startUserInForeground(mUserId);
dismiss(); dismiss();
mStartedUser = true; mStartedUser = true;
@@ -147,6 +151,8 @@ class UserSwitchingDialog extends AlertDialog
decorView.getViewTreeObserver().removeOnWindowShownListener(this); decorView.getViewTreeObserver().removeOnWindowShownListener(this);
} }
mHandler.removeMessages(MSG_START_USER); 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) { public void handleMessage(Message msg) {
switch (msg.what) { switch (msg.what) {
case MSG_START_USER: case MSG_START_USER:
Slog.w(TAG, "user switch window not shown in "
+ WINDOW_SHOWN_TIMEOUT_MS + " ms");
startUser(); startUser();
break; break;
} }