diff options
| author | 2023-02-10 16:46:45 -0800 | |
|---|---|---|
| committer | 2023-02-10 16:46:45 -0800 | |
| commit | bf5ccd26b937a06eac73f7c70bbedbb1a7decbca (patch) | |
| tree | 63aaca82501fd8c99b87746f485d092515963646 /services/java | |
| parent | 51a18cab4ffb714993a65574abf1ef0431a4815e (diff) | |
Various createUsers don't sometimes return null
Previously, UserManagerService.createUserInternalUncheckedNoTracing
would usually throw on failure, but could instead return null in certain
circumstances (namely, bad input).
This lead to ambiguity over whether the various createUser methods were
able to return null.
Here, we throw instead in these previously-null situations. This way,
all of the createUser methods are @NonNull, unless they specifically
catch errors and return null instead. The methods are now all
self-consistent.
In particular, this fixes the previously not-always-correct annotation
of @NonNull that is on UserManager.preCreateUser.
Bug: 219942927
Test: atest com.android.server.pm.UserManagerTest
Test: atest com.android.server.pm.UserManagerServiceTest
Test: atest android.multiuser.cts.UserManagerTest
Change-Id: I7a63b4e684d03b4d2ef76046d0cf277ba2d5744d
Diffstat (limited to 'services/java')
| -rw-r--r-- | services/java/com/android/server/HsumBootUserInitializer.java | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/services/java/com/android/server/HsumBootUserInitializer.java b/services/java/com/android/server/HsumBootUserInitializer.java index c4ad80e4c2c6..4e649150e6f1 100644 --- a/services/java/com/android/server/HsumBootUserInitializer.java +++ b/services/java/com/android/server/HsumBootUserInitializer.java @@ -112,11 +112,7 @@ final class HsumBootUserInitializer { UserInfo.FLAG_ADMIN | UserInfo.FLAG_MAIN, /* disallowedPackages= */ null, /* token= */ null); - if (newInitialUser == null) { - Slogf.wtf(TAG, "Initial bootable MainUser creation failed: returned null"); - } else { - Slogf.i(TAG, "Successfully created MainUser, userId=%d", newInitialUser.id); - } + Slogf.i(TAG, "Successfully created MainUser, userId=%d", newInitialUser.id); } catch (UserManager.CheckedUserOperationException e) { Slogf.wtf(TAG, "Initial bootable MainUser creation failed", e); } |