Merge "Issue a warning when the user switching dialog times out." into qt-qpr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
839c5ec5e4
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user