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

Commit 527c14b4 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add a guard on UserController to avoid user switches when not ready."...

Merge "Add a guard on UserController to avoid user switches when not ready." into rvc-dev am: 340e55d0

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11817081

Change-Id: I16607c147596e9f44bb3f1d8df76183199401d33
parents fe98465d 340e55d0
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -348,6 +348,17 @@ class UserController implements Handler.Callback {
    @GuardedBy("mUserIdToUserJourneyMap")
    private final SparseArray<UserJourneySession> mUserIdToUserJourneyMap = new SparseArray<>();

    /**
     * Sets on {@link #setInitialConfig(boolean, int, boolean)}, which is called by
     * {@code ActivityManager} when the system is started.
     *
     * <p>It's useful to ignore external operations (i.e., originated outside {@code system_server},
     * like from {@code adb shell am switch-user})) that could happen before such call is made and
     * the system is ready.
     */
    @GuardedBy("mLock")
    private boolean mInitialized;

    UserController(ActivityManagerService service) {
        this(new Injector(service));
    }
@@ -372,6 +383,7 @@ class UserController implements Handler.Callback {
            mUserSwitchUiEnabled = userSwitchUiEnabled;
            mMaxRunningUsers = maxRunningUsers;
            mDelayUserDataLocking = delayUserDataLocking;
            mInitialized = true;
        }
    }

@@ -1587,6 +1599,11 @@ class UserController implements Handler.Callback {
        }
        boolean userSwitchUiEnabled;
        synchronized (mLock) {
            if (!mInitialized) {
                Slog.e(TAG, "Cannot switch to User #" + targetUserId
                        + ": UserController not ready yet");
                return false;
            }
            mTargetUserId = targetUserId;
            userSwitchUiEnabled = mUserSwitchUiEnabled;
        }
@@ -2422,6 +2439,7 @@ class UserController implements Handler.Callback {
            pw.println("  mDelayUserDataLocking:" + mDelayUserDataLocking);
            pw.println("  mMaxRunningUsers:" + mMaxRunningUsers);
            pw.println("  mUserSwitchUiEnabled:" + mUserSwitchUiEnabled);
            pw.println("  mInitialized:" + mInitialized);
        }
    }