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

Commit 4944756c authored by Yasin Kilicdere's avatar Yasin Kilicdere Committed by Android (Google) Code Review
Browse files

Merge "Fix NPE in UserManagerService when calling isUserInitialized()." into main

parents 216c3446 bf9deb25
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -7237,7 +7237,8 @@ public class UserManagerService extends IUserManager.Stub {

        @Override
        public boolean isUserInitialized(@UserIdInt int userId) {
            return (getUserInfo(userId).flags & UserInfo.FLAG_INITIALIZED) != 0;
            final UserInfo userInfo = getUserInfo(userId);
            return userInfo != null && (userInfo.flags & UserInfo.FLAG_INITIALIZED) != 0;
        }

        @Override
+7 −0
Original line number Diff line number Diff line
@@ -182,6 +182,13 @@ public class UserManagerServiceTest {
                .isFalse();
    }

    @Test
    public void testIsUserInitialized_NonExistentUserReturnsFalse() {
        int nonExistentUserId = UserHandle.USER_NULL;
        assertThat(mUserManagerService.isUserInitialized(nonExistentUserId))
                .isFalse();
    }

    @Test
    public void testSetUserRestrictionWithIncorrectID() throws Exception {
        int incorrectId = 1;