Loading core/java/android/content/ContentProvider.java +4 −0 Original line number Diff line number Diff line Loading @@ -2774,6 +2774,10 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall + " provider from user:" + mContext.getUserId()); } if (userId != UserHandle.USER_CURRENT // getUserIdFromAuthority can return USER_NULL when can't cast the userId to // an int, which can cause high volume of binder calls. && (!android.multiuser.Flags.fixGetUserPropertyCache() || userId != UserHandle.USER_NULL) && userId != mContext.getUserId() // Since userId specified in content uri, the provider userId would be // determined from it. Loading core/java/android/os/UserManager.java +6 −1 Original line number Diff line number Diff line Loading @@ -3927,7 +3927,12 @@ public class UserManager { android.Manifest.permission.QUERY_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}, conditional = true) public @NonNull UserProperties getUserProperties(@NonNull UserHandle userHandle) { return mUserPropertiesCache.query(userHandle.getIdentifier()); final int userId = userHandle.getIdentifier(); // Avoid calling into system server for invalid user ids. if (android.multiuser.Flags.fixGetUserPropertyCache() && userId < 0) { throw new IllegalArgumentException("Cannot access properties for user " + userId); } return mUserPropertiesCache.query(userId); } /** Loading services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -1060,6 +1060,23 @@ public final class UserManagerTest { assertThrows(SecurityException.class, userProps::getAlwaysVisible); } /** * Test that UserManager.getUserProperties throws the IllegalArgumentException for unsupported * arguments such as UserHandle.NULL, UserHandle.CURRENT or UserHandle.ALL. **/ @MediumTest @Test public void testThrowUserPropertiesForUnsupportedUserHandles() throws Exception { assertThrows(IllegalArgumentException.class, () -> mUserManager.getUserProperties(UserHandle.of(UserHandle.USER_NULL))); assertThrows(IllegalArgumentException.class, () -> mUserManager.getUserProperties(UserHandle.CURRENT)); assertThrows(IllegalArgumentException.class, () -> mUserManager.getUserProperties(UserHandle.CURRENT_OR_SELF)); assertThrows(IllegalArgumentException.class, () -> mUserManager.getUserProperties(UserHandle.ALL)); } // Make sure only max managed profiles can be created @MediumTest @Test Loading Loading
core/java/android/content/ContentProvider.java +4 −0 Original line number Diff line number Diff line Loading @@ -2774,6 +2774,10 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall + " provider from user:" + mContext.getUserId()); } if (userId != UserHandle.USER_CURRENT // getUserIdFromAuthority can return USER_NULL when can't cast the userId to // an int, which can cause high volume of binder calls. && (!android.multiuser.Flags.fixGetUserPropertyCache() || userId != UserHandle.USER_NULL) && userId != mContext.getUserId() // Since userId specified in content uri, the provider userId would be // determined from it. Loading
core/java/android/os/UserManager.java +6 −1 Original line number Diff line number Diff line Loading @@ -3927,7 +3927,12 @@ public class UserManager { android.Manifest.permission.QUERY_USERS, android.Manifest.permission.INTERACT_ACROSS_USERS}, conditional = true) public @NonNull UserProperties getUserProperties(@NonNull UserHandle userHandle) { return mUserPropertiesCache.query(userHandle.getIdentifier()); final int userId = userHandle.getIdentifier(); // Avoid calling into system server for invalid user ids. if (android.multiuser.Flags.fixGetUserPropertyCache() && userId < 0) { throw new IllegalArgumentException("Cannot access properties for user " + userId); } return mUserPropertiesCache.query(userId); } /** Loading
services/tests/servicestests/src/com/android/server/pm/UserManagerTest.java +17 −0 Original line number Diff line number Diff line Loading @@ -1060,6 +1060,23 @@ public final class UserManagerTest { assertThrows(SecurityException.class, userProps::getAlwaysVisible); } /** * Test that UserManager.getUserProperties throws the IllegalArgumentException for unsupported * arguments such as UserHandle.NULL, UserHandle.CURRENT or UserHandle.ALL. **/ @MediumTest @Test public void testThrowUserPropertiesForUnsupportedUserHandles() throws Exception { assertThrows(IllegalArgumentException.class, () -> mUserManager.getUserProperties(UserHandle.of(UserHandle.USER_NULL))); assertThrows(IllegalArgumentException.class, () -> mUserManager.getUserProperties(UserHandle.CURRENT)); assertThrows(IllegalArgumentException.class, () -> mUserManager.getUserProperties(UserHandle.CURRENT_OR_SELF)); assertThrows(IllegalArgumentException.class, () -> mUserManager.getUserProperties(UserHandle.ALL)); } // Make sure only max managed profiles can be created @MediumTest @Test Loading