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

Commit a512d304 authored by Jovana Knezevic's avatar Jovana Knezevic Committed by Android (Google) Code Review
Browse files

Merge "Separates current process user and foreground user" into pi-dev

parents 68e4c45e 82029aed
Loading
Loading
Loading
Loading
+135 −64
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ public final class UserManagerHelper {
    private static final String TAG = "UserManagerHelper";
    private final Context mContext;
    private final UserManager mUserManager;
    private final ActivityManager mActivityManager;
    private OnUsersUpdateListener mUpdateListener;
    private final BroadcastReceiver mUserChangeReceiver = new BroadcastReceiver() {
        @Override
@@ -52,6 +53,7 @@ public final class UserManagerHelper {
    public UserManagerHelper(Context context) {
        mContext = context;
        mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
        mActivityManager = (ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE);
    }

    /**
@@ -72,30 +74,64 @@ public final class UserManagerHelper {
    }

    /**
     * Gets {@link UserInfo} for the current user.
     * Gets UserInfo for the foreground user.
     *
     * @return {@link UserInfo} for the current user.
     * Concept of foreground user is relevant for the multi-user deployment. Foreground user
     * corresponds to the currently "logged in" user.
     *
     * @return {@link UserInfo} for the foreground user.
     */
    public UserInfo getCurrentUserInfo() {
        return mUserManager.getUserInfo(UserHandle.myUserId());
    public UserInfo getForegroundUserInfo() {
        return mUserManager.getUserInfo(getForegroundUserId());
    }

    /**
     * Gets all the other users on the system that are not the current user.
     * @return Id of the foreground user.
     */
    public int getForegroundUserId() {
        return mActivityManager.getCurrentUser();
    }

    /**
     * Gets UserInfo for the user running the caller process.
     *
     * Differentiation between foreground user and current process user is relevant for multi-user
     * deployments.
     *
     * Some multi-user aware components (like SystemUI) might run as a singleton - one component
     * for all users. Current process user is then always the same for that component, even when
     * the foreground user changes.
     *
     * @return List of {@code UserInfo} for each user that is not the current user.
     * @return {@link UserInfo} for the user running the current process.
     */
    public List<UserInfo> getAllUsersExcludesCurrentUser() {
        List<UserInfo> others = getAllUsers();
    public UserInfo getCurrentProcessUserInfo() {
        return mUserManager.getUserInfo(getCurrentProcessUserId());
    }

        for (Iterator<UserInfo> iterator = others.iterator(); iterator.hasNext(); ) {
            UserInfo userInfo = iterator.next();
            if (userInfo.id == UserHandle.myUserId()) {
                // Remove current user from the list.
                iterator.remove();
    /**
     * @return Id for the user running the current process.
     */
    public int getCurrentProcessUserId() {
        return UserHandle.myUserId();
    }

    /**
     * Gets all the other users on the system that are not the user running the current process.
     *
     * @return List of {@code UserInfo} for each user that is not the user running the process.
     */
    public List<UserInfo> getAllUsersExcludesCurrentProcessUser() {
        return getAllUsersExceptUser(getCurrentProcessUserId());
    }
        return others;

    /**
     * Gets all the existing users on the system that are not the currently running as the
     * foreground user.
     *
     * @return List of {@code UserInfo} for each user that is not the foreground user.
     */
    public List<UserInfo> getAllUsersExcludesForegroundUser() {
        return getAllUsersExceptUser(getForegroundUserId());
    }

    /**
@@ -104,12 +140,22 @@ public final class UserManagerHelper {
     * @return List of {@code UserInfo} for each user that is not the system user.
     */
    public List<UserInfo> getAllUsersExcludesSystemUser() {
        return getAllUsersExceptUser(UserHandle.USER_SYSTEM);
    }

    /**
     * Get all the users except the one with userId passed in.
     *
     * @param userId of the user not to be returned.
     * @return All users other than user with userId.
     */
    public List<UserInfo> getAllUsersExceptUser(int userId) {
        List<UserInfo> others = getAllUsers();

        for (Iterator<UserInfo> iterator = others.iterator(); iterator.hasNext(); ) {
            UserInfo userInfo = iterator.next();
            if (userIsSystemUser(userInfo)) {
                // Remove system user from the list.
            if (userInfo.id == userId) {
                // Remove user with userId from the list.
                iterator.remove();
            }
        }
@@ -146,78 +192,115 @@ public final class UserManagerHelper {
    }

    /**
     * Checks whether passed in user is the user that's currently logged in.
     * Checks whether passed in user is the foreground user.
     *
     * @param userInfo User to check.
     * @return {@code true} if foreground user, {@code false} otherwise.
     */
    public boolean userIsForegroundUser(UserInfo userInfo) {
        return getForegroundUserId() == userInfo.id;
    }

    /**
     * Checks whether passed in user is the user that's running the current process.
     *
     * @param userInfo User to check.
     * @return {@code true} if current user, {@code false} otherwise.
     * @return {@code true} if user running the process, {@code false} otherwise.
     */
    public boolean userIsCurrentUser(UserInfo userInfo) {
        return getCurrentUserInfo().id == userInfo.id;
    public boolean userIsRunningCurrentProcess(UserInfo userInfo) {
        return getCurrentProcessUserId() == userInfo.id;
    }

    // Current user information accessors
    // Foreground user information accessors.

    /**
     * Checks if the current user is a demo user.
     * Checks if the foreground user is a guest user.
     */
    public boolean isDemoUser() {
    public boolean foregroundUserIsGuestUser() {
      return getForegroundUserInfo().isGuest();
    }

    /**
     * Return whether the foreground user has a restriction.
     *
     * @param restriction Restriction to check. Should be a UserManager.* restriction.
     * @return Whether that restriction exists for the foreground user.
     */
    public boolean foregroundUserHasUserRestriction(String restriction) {
        return mUserManager.hasUserRestriction(restriction, getForegroundUserInfo().getUserHandle());
    }

    /**
     * Checks if the foreground user can add new users.
     */
    public boolean foregroundUserCanAddUsers() {
        return !foregroundUserHasUserRestriction(UserManager.DISALLOW_ADD_USER);
    }

    // Current process user information accessors

    /**
     * Checks if the calling app is running in a demo user.
     */
    public boolean currentProcessRunningAsDemoUser() {
        return mUserManager.isDemoUser();
    }

    /**
     * Checks if the current user is a guest user.
     * Checks if the calling app is running as a guest user.
     */
    public boolean isGuestUser() {
    public boolean currentProcessRunningAsGuestUser() {
        return mUserManager.isGuestUser();
    }

    /**
     * Checks if the current user is the system user (User 0).
     * Checks whether this process is running under the system user.
     */
    public boolean isSystemUser() {
    public boolean currentProcessRunningAsSystemUser() {
        return mUserManager.isSystemUser();
    }

    // Current user restriction accessors
    // Current process user restriction accessors

    /**
     * Return whether the current user has a restriction.
     * Return whether the user running the current process has a restriction.
     *
     * @param restriction Restriction to check. Should be a UserManager.* restriction.
     * @return Whether that restriction exists for the current user.
     * @return Whether that restriction exists for the user running the process.
     */
    public boolean hasUserRestriction(String restriction) {
    public boolean currentProcessHasUserRestriction(String restriction) {
        return mUserManager.hasUserRestriction(restriction);
    }

    /**
     * Checks if the current user can add new users.
     * Checks if the user running the current process can add new users.
     */
    public boolean canAddUsers() {
        return !hasUserRestriction(UserManager.DISALLOW_ADD_USER);
    public boolean currentProcessCanAddUsers() {
        return !currentProcessHasUserRestriction(UserManager.DISALLOW_ADD_USER);
    }

    /**
     * Checks if the current user can remove users.
     * Checks if the user running the current process can remove users.
     */
    public boolean canRemoveUsers() {
        return !hasUserRestriction(UserManager.DISALLOW_REMOVE_USER);
    public boolean currentProcessCanRemoveUsers() {
        return !currentProcessHasUserRestriction(UserManager.DISALLOW_REMOVE_USER);
    }

    /**
     * Checks if the current user is allowed to switch to another user.
     * Checks if the user running the current process is allowed to switch to another user.
     */
    public boolean canSwitchUsers() {
        return !hasUserRestriction(UserManager.DISALLOW_USER_SWITCH);
    public boolean currentProcessCanSwitchUsers() {
        return !currentProcessHasUserRestriction(UserManager.DISALLOW_USER_SWITCH);
    }

    /**
     * Checks if the current user can modify accounts. Demo and Guest users cannot modify accounts
     * even if the DISALLOW_MODIFY_ACCOUNTS restriction is not applied.
     * Checks if the current process user can modify accounts. Demo and Guest users cannot modify
     * accounts even if the DISALLOW_MODIFY_ACCOUNTS restriction is not applied.
     */
    public boolean canModifyAccounts() {
        return !hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS) && !isDemoUser()
                && !isGuestUser();
    public boolean currentProcessCanModifyAccounts() {
        return !currentProcessHasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS)
                && !currentProcessRunningAsDemoUser()
                && !currentProcessRunningAsGuestUser();
    }

    // User actions
@@ -242,8 +325,8 @@ public final class UserManagerHelper {

    /**
     * Tries to remove the user that's passed in. System user cannot be removed.
     * If the user to be removed is current user, it switches to the system user first, and then
     * removes the user.
     * If the user to be removed is user currently running the process,
     * it switches to the system user first, and then removes the user.
     *
     * @param userInfo User to be removed
     * @return {@code true} if user is successfully removed, {@code false} otherwise.
@@ -254,7 +337,7 @@ public final class UserManagerHelper {
            return false;
        }

        if (userInfo.id == getCurrentUserInfo().id) {
        if (userInfo.id == getCurrentProcessUserId()) {
            switchToUserId(UserHandle.USER_SYSTEM);
        }

@@ -267,7 +350,7 @@ public final class UserManagerHelper {
     * @param userInfo User to switch to.
     */
    public void switchToUser(UserInfo userInfo) {
        if (userInfo.id == getCurrentUserInfo().id) {
        if (userInfo.id == getForegroundUserId()) {
            return;
        }

@@ -276,15 +359,6 @@ public final class UserManagerHelper {
            return;
        }

        if (UserManager.isGuestUserEphemeral()) {
            // If switching from guest, we want to bring up the guest exit dialog instead of
            // switching
            UserInfo currUserInfo = getCurrentUserInfo();
            if (currUserInfo != null && currUserInfo.isGuest()) {
                return;
            }
        }

        switchToUserId(userInfo.id);
    }

@@ -366,9 +440,7 @@ public final class UserManagerHelper {

    private void switchToUserId(int id) {
        try {
            final ActivityManager am = (ActivityManager)
                    mContext.getSystemService(Context.ACTIVITY_SERVICE);
            am.switchUser(id);
            mActivityManager.switchUser(id);
        } catch (Exception e) {
            Log.e(TAG, "Couldn't switch user.", e);
        }
@@ -389,4 +461,3 @@ public final class UserManagerHelper {
        void onUsersUpdate();
    }
}
+73 −106
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ public class UserManagerHelperTest {
    private UserManagerHelper.OnUsersUpdateListener mTestListener;

    private UserManagerHelper mHelper;
    private UserInfo mCurrentUser;
    private UserInfo mCurrentProcessUser;
    private UserInfo mSystemUser;

    @Before
@@ -70,13 +70,13 @@ public class UserManagerHelperTest {
                .thenReturn(InstrumentationRegistry.getTargetContext().getResources());
        mHelper = new UserManagerHelper(mContext);

        mCurrentUser = createUserInfoForId(UserHandle.myUserId());
        mCurrentProcessUser = createUserInfoForId(UserHandle.myUserId());
        mSystemUser = createUserInfoForId(UserHandle.USER_SYSTEM);
        when(mUserManager.getUserInfo(UserHandle.myUserId())).thenReturn(mCurrentUser);
        when(mUserManager.getUserInfo(UserHandle.myUserId())).thenReturn(mCurrentProcessUser);
    }

    @Test
    public void testUserIsSystemUser() {
    public void userIsSystemUser() {
        UserInfo testInfo = new UserInfo();

        testInfo.id = UserHandle.USER_SYSTEM;
@@ -87,57 +87,55 @@ public class UserManagerHelperTest {
    }

    @Test
    public void testGetAllUsersExcludesCurrentUser() {
        int currentUser = UserHandle.myUserId();

        UserInfo otherUser1 = createUserInfoForId(currentUser + 1);
        UserInfo otherUser2 = createUserInfoForId(currentUser - 1);
        UserInfo otherUser3 = createUserInfoForId(currentUser + 2);
    public void getAllUsersExcludesSystemUser() {
        UserInfo otherUser1 = createUserInfoForId(10);
        UserInfo otherUser2 = createUserInfoForId(11);
        UserInfo otherUser3 = createUserInfoForId(12);

        List<UserInfo> testUsers = new ArrayList<>();
        testUsers.add(otherUser1);
        testUsers.add(otherUser2);
        testUsers.add(mCurrentUser);
        testUsers.add(mSystemUser);
        testUsers.add(otherUser3);

        when(mUserManager.getUsers(true)).thenReturn(testUsers);

        // Should return 3 users that don't have currentUser id.
        assertThat(mHelper.getAllUsersExcludesCurrentUser().size()).isEqualTo(3);
        // Should not contain current user.
        assertThat(mHelper.getAllUsersExcludesCurrentUser()).doesNotContain(mCurrentUser);
        // Should contain non-current users.
        assertThat(mHelper.getAllUsersExcludesCurrentUser()).contains(otherUser1);
        assertThat(mHelper.getAllUsersExcludesCurrentUser()).contains(otherUser2);
        assertThat(mHelper.getAllUsersExcludesCurrentUser()).contains(otherUser3);
        // Should return 3 users that don't have SYSTEM USER id.
        assertThat(mHelper.getAllUsersExcludesSystemUser()).hasSize(3);
        assertThat(mHelper.getAllUsersExcludesSystemUser())
                .containsExactly(otherUser1, otherUser2, otherUser3);
    }

    @Test
    public void testGetAllUsersExcludesSystemUser() {
        UserInfo otherUser1 = createUserInfoForId(10);
        UserInfo otherUser2 = createUserInfoForId(11);
        UserInfo otherUser3 = createUserInfoForId(12);
    public void getAllUsersExceptUser() {
        UserInfo user1 = createUserInfoForId(10);
        UserInfo user2 = createUserInfoForId(10);
        UserInfo user3 = createUserInfoForId(12);

        List<UserInfo> testUsers = new ArrayList<>();
        testUsers.add(otherUser1);
        testUsers.add(otherUser2);
        testUsers.add(mSystemUser);
        testUsers.add(otherUser3);
        testUsers.add(user1);
        testUsers.add(user2);
        testUsers.add(user3);

        when(mUserManager.getUsers(true)).thenReturn(testUsers);
        when(mUserManager.getUsers(true)).thenReturn(new ArrayList<>(testUsers));

        // Should return 3 users that don't have SYSTEM USER id.
        assertThat(mHelper.getAllUsersExcludesSystemUser().size()).isEqualTo(3);
        // Should not contain system user.
        assertThat(mHelper.getAllUsersExcludesSystemUser()).doesNotContain(mSystemUser);
        // Should contain non-system users.
        assertThat(mHelper.getAllUsersExcludesSystemUser()).contains(otherUser1);
        assertThat(mHelper.getAllUsersExcludesSystemUser()).contains(otherUser2);
        assertThat(mHelper.getAllUsersExcludesSystemUser()).contains(otherUser3);
        // Should return all 3 users.
        assertThat(mHelper.getAllUsersExceptUser(9).size()).isEqualTo(3);

        // Should return only user 12.
        assertThat(mHelper.getAllUsersExceptUser(10).size()).isEqualTo(1);
        assertThat(mHelper.getAllUsersExceptUser(10)).contains(user3);

        when(mUserManager.getUsers(true)).thenReturn(new ArrayList<>(testUsers));

        // Should drop user 12.
        assertThat(mHelper.getAllUsersExceptUser(12).size()).isEqualTo(2);
        assertThat(mHelper.getAllUsersExceptUser(12)).contains(user1);
        assertThat(mHelper.getAllUsersExceptUser(12)).contains(user2);
    }

    @Test
    public void testGetAllUsers() {
    public void getAllUsers() {
        int currentUser = UserHandle.myUserId();

        UserInfo otherUser1 = createUserInfoForId(currentUser + 1);
@@ -147,21 +145,18 @@ public class UserManagerHelperTest {
        List<UserInfo> testUsers = new ArrayList<>();
        testUsers.add(otherUser1);
        testUsers.add(otherUser2);
        testUsers.add(mCurrentUser);
        testUsers.add(mCurrentProcessUser);
        testUsers.add(otherUser3);

        when(mUserManager.getUsers(true)).thenReturn(testUsers);

        // Should return 3 users that don't have currentUser id.
        assertThat(mHelper.getAllUsers().size()).isEqualTo(4);
        assertThat(mHelper.getAllUsers()).contains(mCurrentUser);
        assertThat(mHelper.getAllUsers()).contains(otherUser1);
        assertThat(mHelper.getAllUsers()).contains(otherUser2);
        assertThat(mHelper.getAllUsers()).contains(otherUser3);
        assertThat(mHelper.getAllUsers())
                .containsExactly(mCurrentProcessUser, otherUser1, otherUser2, otherUser3);
    }

    @Test
    public void testUserCanBeRemoved() {
    public void userCanBeRemoved() {
        UserInfo testInfo = new UserInfo();

        // System user cannot be removed.
@@ -173,71 +168,59 @@ public class UserManagerHelperTest {
    }

    @Test
    public void testUserIsCurrentUser() {
        UserInfo testInfo = new UserInfo();

        // System user cannot be removed.
        testInfo.id = UserHandle.myUserId();
        assertThat(mHelper.userIsCurrentUser(testInfo)).isTrue();

        testInfo.id = UserHandle.myUserId() + 2;
        assertThat(mHelper.userIsCurrentUser(testInfo)).isFalse();
    }

    @Test
    public void testCanAddUsers() {
    public void currentProcessCanAddUsers() {
        when(mUserManager.hasUserRestriction(UserManager.DISALLOW_ADD_USER)).thenReturn(false);
        assertThat(mHelper.canAddUsers()).isTrue();
        assertThat(mHelper.currentProcessCanAddUsers()).isTrue();

        when(mUserManager.hasUserRestriction(UserManager.DISALLOW_ADD_USER)).thenReturn(true);
        assertThat(mHelper.canAddUsers()).isFalse();
        assertThat(mHelper.currentProcessCanAddUsers()).isFalse();
    }

    @Test
    public void testCanRemoveUsers() {
    public void currentProcessCanRemoveUsers() {
        when(mUserManager.hasUserRestriction(UserManager.DISALLOW_REMOVE_USER)).thenReturn(false);
        assertThat(mHelper.canRemoveUsers()).isTrue();
        assertThat(mHelper.currentProcessCanRemoveUsers()).isTrue();

        when(mUserManager.hasUserRestriction(UserManager.DISALLOW_REMOVE_USER)).thenReturn(true);
        assertThat(mHelper.canRemoveUsers()).isFalse();
        assertThat(mHelper.currentProcessCanRemoveUsers()).isFalse();
    }

    @Test
    public void testCanSwitchUsers() {
    public void currentProcessCanSwitchUsers() {
        when(mUserManager.hasUserRestriction(UserManager.DISALLOW_USER_SWITCH)).thenReturn(false);
        assertThat(mHelper.canSwitchUsers()).isTrue();
        assertThat(mHelper.currentProcessCanSwitchUsers()).isTrue();

        when(mUserManager.hasUserRestriction(UserManager.DISALLOW_USER_SWITCH)).thenReturn(true);
        assertThat(mHelper.canSwitchUsers()).isFalse();
        assertThat(mHelper.currentProcessCanSwitchUsers()).isFalse();
    }

    @Test
    public void testGuestCannotModifyAccounts() {
        assertThat(mHelper.canModifyAccounts()).isTrue();
    public void currentProcessRunningAsGuestCannotModifyAccounts() {
        assertThat(mHelper.currentProcessCanModifyAccounts()).isTrue();

        when(mUserManager.isGuestUser()).thenReturn(true);
        assertThat(mHelper.canModifyAccounts()).isFalse();
        assertThat(mHelper.currentProcessCanModifyAccounts()).isFalse();
    }

    @Test
    public void testDemoUserCannotModifyAccounts() {
        assertThat(mHelper.canModifyAccounts()).isTrue();
    public void currentProcessRunningAsDemoUserCannotModifyAccounts() {
        assertThat(mHelper.currentProcessCanModifyAccounts()).isTrue();

        when(mUserManager.isDemoUser()).thenReturn(true);
        assertThat(mHelper.canModifyAccounts()).isFalse();
        assertThat(mHelper.currentProcessCanModifyAccounts()).isFalse();
    }

    @Test
    public void testUserWithDisallowModifyAccountsRestrictionCannotModifyAccounts() {
        assertThat(mHelper.canModifyAccounts()).isTrue();
    public void currentProcessWithDisallowModifyAccountsRestrictionCannotModifyAccounts() {
        assertThat(mHelper.currentProcessCanModifyAccounts()).isTrue();

        when(mUserManager.hasUserRestriction(UserManager.DISALLOW_MODIFY_ACCOUNTS))
                .thenReturn(true);
        assertThat(mHelper.canModifyAccounts()).isFalse();
        assertThat(mHelper.currentProcessCanModifyAccounts()).isFalse();
    }

    @Test
    public void testCreateNewUser() {
    public void createNewUser() {
        // Verify createUser on UserManager gets called.
        mHelper.createNewUser("Test User");
        verify(mUserManager).createUser("Test User", 0);
@@ -252,52 +235,36 @@ public class UserManagerHelperTest {
    }

    @Test
    public void testRemoveUser() {
    public void removeUser() {
        // Cannot remove system user.
        assertThat(mHelper.removeUser(mSystemUser)).isFalse();

        // Removing non-current, non-system user, simply calls removeUser.
        UserInfo userToRemove = createUserInfoForId(mCurrentUser.id + 2);
        mHelper.removeUser(userToRemove);
        verify(mUserManager).removeUser(mCurrentUser.id + 2);
    }
        UserInfo userToRemove = createUserInfoForId(mCurrentProcessUser.id + 2);

    @Test
    public void testSwitchToUser() {
        // Switching to current user doesn't do anything.
        mHelper.switchToUser(mCurrentUser);
        verify(mActivityManager, never()).switchUser(mCurrentUser.id);

        // Switching to Guest calls createGuest.
        UserInfo guestInfo = new UserInfo(mCurrentUser.id + 1, "Test Guest", UserInfo.FLAG_GUEST);
        mHelper.switchToUser(guestInfo);
        verify(mUserManager).createGuest(mContext, "Test Guest");

        // Switching to non-current, non-guest user, simply calls switchUser.
        UserInfo userToSwitchTo = new UserInfo(mCurrentUser.id + 5, "Test User", 0);
        mHelper.switchToUser(userToSwitchTo);
        verify(mActivityManager).switchUser(mCurrentUser.id + 5);
        mHelper.removeUser(userToRemove);
        verify(mUserManager).removeUser(mCurrentProcessUser.id + 2);
    }

    @Test
    public void testSwitchToGuest() {
    public void switchToGuest() {
        mHelper.switchToGuest("Test Guest");
        verify(mUserManager).createGuest(mContext, "Test Guest");

        UserInfo guestInfo = new UserInfo(mCurrentUser.id + 2, "Test Guest", UserInfo.FLAG_GUEST);
        UserInfo guestInfo = new UserInfo(21, "Test Guest", UserInfo.FLAG_GUEST);
        when(mUserManager.createGuest(mContext, "Test Guest")).thenReturn(guestInfo);
        mHelper.switchToGuest("Test Guest");
        verify(mActivityManager).switchUser(mCurrentUser.id + 2);
        verify(mActivityManager).switchUser(21);
    }

    @Test
    public void testGetUserIcon() {
        mHelper.getUserIcon(mCurrentUser);
        verify(mUserManager).getUserIcon(mCurrentUser.id);
    public void getUserIcon() {
        mHelper.getUserIcon(mCurrentProcessUser);
        verify(mUserManager).getUserIcon(mCurrentProcessUser.id);
    }

    @Test
    public void testScaleUserIcon() {
    public void scaleUserIcon() {
        Bitmap fakeIcon = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
        Drawable scaledIcon = mHelper.scaleUserIcon(fakeIcon, 300);
        assertThat(scaledIcon.getIntrinsicWidth()).isEqualTo(300);
@@ -305,14 +272,14 @@ public class UserManagerHelperTest {
    }

    @Test
    public void testSetUserName() {
        UserInfo testInfo = createUserInfoForId(mCurrentUser.id + 3);
    public void setUserName() {
        UserInfo testInfo = createUserInfoForId(mCurrentProcessUser.id + 3);
        mHelper.setUserName(testInfo, "New Test Name");
        verify(mUserManager).setUserName(mCurrentUser.id + 3, "New Test Name");
        verify(mUserManager).setUserName(mCurrentProcessUser.id + 3, "New Test Name");
    }

    @Test
    public void testRegisterUserChangeReceiver() {
    public void registerUserChangeReceiver() {
        mHelper.registerOnUsersUpdateListener(mTestListener);

        ArgumentCaptor<BroadcastReceiver> receiverCaptor =
+65 −0

File added.

Preview size limit exceeded, changes collapsed.

+224 −0

File added.

Preview size limit exceeded, changes collapsed.

+2 −2

File changed.

Preview size limit exceeded, changes collapsed.