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

Commit 0c488346 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move UserController.dispatchOnBeforeUserSwitching to mHandler thread." into main

parents 498b8ff0 a1d0c42c
Loading
Loading
Loading
Loading
+164 −154
Original line number Diff line number Diff line
@@ -1920,6 +1920,21 @@ class UserController implements Handler.Callback {
                return false;
            }

            mHandler.post(() -> startUserInternalOnHandler(userId, oldUserId, userStartMode,
                    unlockListener, callingUid, callingPid));
        } finally {
            Binder.restoreCallingIdentity(ident);
        }

        return true;
    }

    private void startUserInternalOnHandler(int userId, int oldUserId, int userStartMode,
            IProgressListener unlockListener, int callingUid, int callingPid) {
        final TimingsTraceAndSlog t = new TimingsTraceAndSlog();
        final boolean foreground = userStartMode == USER_START_MODE_FOREGROUND;
        final UserInfo userInfo = getUserInfo(userId);

        boolean needStart = false;
        boolean updateUmState = false;
        UserState uss;
@@ -1943,7 +1958,7 @@ class UserController implements Handler.Callback {
                mPendingUserStarts.add(new PendingUserStart(userId, userStartMode,
                        unlockListener));
                t.traceEnd(); // updateStartedUserArrayStarting
                    return true;
                return;
            }
        }

@@ -2089,11 +2104,6 @@ class UserController implements Handler.Callback {
            sendUserStartingBroadcast(userId, callingUid, callingPid);
            t.traceEnd();
        }
        } finally {
            Binder.restoreCallingIdentity(ident);
        }

        return true;
    }

    /**
+3 −1
Original line number Diff line number Diff line
@@ -181,12 +181,14 @@ public class UserControllerTest {
            Intent.ACTION_USER_STARTING);

    private static final Set<Integer> START_FOREGROUND_USER_MESSAGE_CODES = newHashSet(
            0, // for startUserInternalOnHandler
            REPORT_USER_SWITCH_MSG,
            USER_SWITCH_TIMEOUT_MSG,
            USER_START_MSG,
            USER_CURRENT_MSG);

    private static final Set<Integer> START_BACKGROUND_USER_MESSAGE_CODES = newHashSet(
            0, // for startUserInternalOnHandler
            USER_START_MSG,
            REPORT_LOCKED_BOOT_COMPLETE_MSG);

@@ -374,7 +376,7 @@ public class UserControllerTest {
        // and the cascade effect goes on...). In fact, a better approach would to not assert the
        // binder calls, but their side effects (in this case, that the user is stopped right away)
        assertWithMessage("wrong binder message calls").that(mInjector.mHandler.getMessageCodes())
                .containsExactly(USER_START_MSG);
                .containsExactly(/* for startUserInternalOnHandler */ 0, USER_START_MSG);
    }

    private void startUserAssertions(