Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 82fc9045 authored by Yasin Kilicdere's avatar Yasin Kilicdere
Browse files

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

Change-Id: I4e353d751ea211cac2c1014c7b201da4d1cd1f7f
parent 966e184a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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;

+4 −2
Original line number Diff line number Diff line
@@ -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;
    }