Skip to content

Commit f67f8f0

Browse files
Yasin KilicdereAndroid Build Coastguard Worker
authored andcommitted
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
1 parent 3c500d9 commit f67f8f0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

services/core/java/com/android/server/am/UserController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ class UserController implements Handler.Callback {
203203
static final int COMPLETE_USER_SWITCH_MSG = 130;
204204
static final int USER_COMPLETED_EVENT_MSG = 140;
205205
static final int SCHEDULED_STOP_BACKGROUND_USER_MSG = 150;
206+
static final int USER_SWITCHING_DIALOG_ANIMATION_TIMEOUT_MSG = 160;
206207

207208
private static final int NO_ARG2 = 0;
208209

services/core/java/com/android/server/am/UserSwitchingDialog.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.android.server.am;
1818

19+
import static com.android.server.am.UserController.USER_SWITCHING_DIALOG_ANIMATION_TIMEOUT_MSG;
20+
1921
import android.annotation.NonNull;
2022
import android.annotation.Nullable;
2123
import android.annotation.UserIdInt;
@@ -302,14 +304,14 @@ private Runnable animationWithTimeout(String name, Runnable onAnimationEnd) {
302304
final AtomicBoolean isFirst = new AtomicBoolean(true);
303305
final Runnable onAnimationEndOrTimeout = () -> {
304306
if (isFirst.getAndSet(false)) {
305-
mHandler.removeCallbacksAndMessages(null);
307+
mHandler.removeMessages(USER_SWITCHING_DIALOG_ANIMATION_TIMEOUT_MSG);
306308
onAnimationEnd.run();
307309
}
308310
};
309311
mHandler.postDelayed(() -> {
310312
Slog.w(TAG, name + " animation not completed in " + ANIMATION_TIMEOUT_MS + " ms");
311313
onAnimationEndOrTimeout.run();
312-
}, ANIMATION_TIMEOUT_MS);
314+
}, USER_SWITCHING_DIALOG_ANIMATION_TIMEOUT_MSG, ANIMATION_TIMEOUT_MS);
313315

314316
return onAnimationEndOrTimeout;
315317
}

0 commit comments

Comments
 (0)