summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yasin Kilicdere <tyk@google.com> 2025-04-08 17:01:21 +0100
committer Android Build Coastguard Worker <android-build-coastguard-worker@google.com> 2025-04-24 19:51:06 -0700
commitf67f8f0edb198c1078a0b0fceaadde85a37a6768 (patch)
tree510e8e8a36eed655b27aa091b10c7addab3bdccf
parent3c500d9c252a3e27cfeb1cece84050d13352b2c4 (diff)
UserSwitchingDialog timeout shouldn't remove all callbacks and messages.
The UserSwitchingDialog's timeout mechanism incorrectly removes all callbacks and messages. This causes unexpected behavior, notably the loss of a crucial post message (linked in the bugs). Bug: 409311749 Bug: 406689907 Test: atest UserControllerTest Flag: EXEMPT bugfix (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:82fc90457b122310ebcc4315958985db8db714bf) Merged-In: I4e353d751ea211cac2c1014c7b201da4d1cd1f7f Change-Id: I4e353d751ea211cac2c1014c7b201da4d1cd1f7f
-rw-r--r--services/core/java/com/android/server/am/UserController.java1
-rw-r--r--services/core/java/com/android/server/am/UserSwitchingDialog.java6
2 files changed, 5 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java
index 40a9bbec3598..10c81531f02c 100644
--- a/services/core/java/com/android/server/am/UserController.java
+++ b/services/core/java/com/android/server/am/UserController.java
@@ -203,6 +203,7 @@ class UserController implements Handler.Callback {
static final int COMPLETE_USER_SWITCH_MSG = 130;
static final int USER_COMPLETED_EVENT_MSG = 140;
static final int SCHEDULED_STOP_BACKGROUND_USER_MSG = 150;
+ static final int USER_SWITCHING_DIALOG_ANIMATION_TIMEOUT_MSG = 160;
private static final int NO_ARG2 = 0;
diff --git a/services/core/java/com/android/server/am/UserSwitchingDialog.java b/services/core/java/com/android/server/am/UserSwitchingDialog.java
index f4e733a0c99f..a1cc9dca092d 100644
--- a/services/core/java/com/android/server/am/UserSwitchingDialog.java
+++ b/services/core/java/com/android/server/am/UserSwitchingDialog.java
@@ -16,6 +16,8 @@
package com.android.server.am;
+import static com.android.server.am.UserController.USER_SWITCHING_DIALOG_ANIMATION_TIMEOUT_MSG;
+
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
@@ -302,14 +304,14 @@ class UserSwitchingDialog extends Dialog {
final AtomicBoolean isFirst = new AtomicBoolean(true);
final Runnable onAnimationEndOrTimeout = () -> {
if (isFirst.getAndSet(false)) {
- mHandler.removeCallbacksAndMessages(null);
+ mHandler.removeMessages(USER_SWITCHING_DIALOG_ANIMATION_TIMEOUT_MSG);
onAnimationEnd.run();
}
};
mHandler.postDelayed(() -> {
Slog.w(TAG, name + " animation not completed in " + ANIMATION_TIMEOUT_MS + " ms");
onAnimationEndOrTimeout.run();
- }, ANIMATION_TIMEOUT_MS);
+ }, USER_SWITCHING_DIALOG_ANIMATION_TIMEOUT_MSG, ANIMATION_TIMEOUT_MS);
return onAnimationEndOrTimeout;
}