UserSwitchingDialogpublic final class UserSwitchingDialog extends android.app.AlertDialog implements ViewTreeObserver.OnWindowShownListenerDialog to show when a user switch it about to happen. The intent is to snapshot the screen
immediately after the dialog shows so that the user is informed that something is happening
in the background rather than just freeze the screen and not know if the user-switch affordance
was being handled. |
Fields Summary |
---|
private static final String | TAG | private final ActivityManagerService | mService | private final int | mUserId |
Constructors Summary |
---|
public UserSwitchingDialog(ActivityManagerService service, android.content.Context context, int userId, String userName, boolean aboveSystem)
super(context);
mService = service;
mUserId = userId;
// Set up the dialog contents
setCancelable(false);
Resources res = getContext().getResources();
// Custom view due to alignment and font size requirements
View view = LayoutInflater.from(getContext()).inflate(R.layout.user_switching_dialog, null);
((TextView) view.findViewById(R.id.message)).setText(
res.getString(com.android.internal.R.string.user_switching_message, userName));
setView(view);
if (aboveSystem) {
getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
}
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.privateFlags = WindowManager.LayoutParams.PRIVATE_FLAG_SYSTEM_ERROR |
WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
getWindow().setAttributes(attrs);
|
Methods Summary |
---|
public void | onWindowShown()
// Slog.v(TAG, "onWindowShown called");
mService.startUserInForeground(mUserId, this);
final View decorView = getWindow().getDecorView();
if (decorView != null) {
decorView.getViewTreeObserver().removeOnWindowShownListener(this);
}
| public void | show()
// Slog.v(TAG, "show called");
super.show();
final View decorView = getWindow().getDecorView();
if (decorView != null) {
decorView.getViewTreeObserver().addOnWindowShownListener(this);
}
|
|