Issue a warning when the user switching dialog times out.
Example: 11-22 06:44:38.846 2825 2842 W ActivityManagerUserSwitchingDialog: user switch window not shown in 3000 ms Bug: 145001354 Test: manual verification Change-Id: I2dc748ea43df227d9f07e6743e39ae25a096352a (cherry picked from commit 72a052308f67b72c8abba231568f8c93e7e6ec07)
This commit is contained in:
@@ -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