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

Commit 23a3ad21 authored by Nikhil Kumar's avatar Nikhil Kumar Committed by Android (Google) Code Review
Browse files

Merge "Improvements in UMS.isUserRunning()"

parents d50b929a 060f8f38
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -35,18 +35,20 @@ import java.util.ArrayList;
public final class UserState {
    private static final String TAG = TAG_WITH_CLASS_NAME ? "UserState" : TAG_AM;

    // user doesn't exist.
    public static final int STATE_NONE = -1;
    // User is first coming up.
    public final static int STATE_BOOTING = 0;
    public static final int STATE_BOOTING = 0;
    // User is in the locked state.
    public final static int STATE_RUNNING_LOCKED = 1;
    public static final int STATE_RUNNING_LOCKED = 1;
    // User is in the unlocking state.
    public final static int STATE_RUNNING_UNLOCKING = 2;
    public static final int STATE_RUNNING_UNLOCKING = 2;
    // User is in the running state.
    public final static int STATE_RUNNING_UNLOCKED = 3;
    public static final int STATE_RUNNING_UNLOCKED = 3;
    // User is in the initial process of being stopped.
    public final static int STATE_STOPPING = 4;
    public static final int STATE_STOPPING = 4;
    // User is in the final phase of stopping, sending Intent.ACTION_SHUTDOWN.
    public final static int STATE_SHUTDOWN = 5;
    public static final int STATE_SHUTDOWN = 5;

    public final UserHandle mHandle;
    public final ArrayList<IStopUserCallback> mStopCallbacks = new ArrayList<>();
+6 −1
Original line number Diff line number Diff line
@@ -6578,9 +6578,14 @@ public class UserManagerService extends IUserManager.Stub {

        @Override
        public boolean isUserRunning(@UserIdInt int userId) {
            int state;
            synchronized (mUserStates) {
                return mUserStates.get(userId, -1) >= 0;
                state =  mUserStates.get(userId, UserState.STATE_NONE);
            }

            return state != UserState.STATE_NONE
                    && state != UserState.STATE_STOPPING
                    && state != UserState.STATE_SHUTDOWN;
        }

        @Override
+1 −2
Original line number Diff line number Diff line
@@ -535,8 +535,7 @@ abstract class UserManagerServiceOrInternalTestCase extends ExtendedMockitoTestC
    }

    protected final void stopDefaultProfile() {
        // TODO(b/244798930): should set it to STATE_STOPPING or STATE_SHUTDOWN instead
        removeUserState(PROFILE_USER_ID);
        setUserState(PROFILE_USER_ID, UserState.STATE_STOPPING);
    }

    // NOTE: should only called by tests that indirectly needs to check user assignments (like