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

Commit 3503cc3c authored by Ankita Vyas's avatar Ankita Vyas Committed by Android (Google) Code Review
Browse files

Merge "Do not show Choose Profile dialog for clone user."

parents 62c6b9f6 93049776
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnDismissListener;
import android.content.DialogInterface.OnShowListener;
import android.content.Intent;
import android.content.pm.UserInfo;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
@@ -168,7 +169,8 @@ public class ProfileSelectDialog extends DialogFragment implements UserAdapter.O
        }
        final UserManager userManager = UserManager.get(context);
        for (int i = userHandles.size() - 1; i >= 0; i--) {
            if (userManager.getUserInfo(userHandles.get(i).getIdentifier()) == null) {
            UserInfo userInfo = userManager.getUserInfo(userHandles.get(i).getIdentifier());
            if (userInfo == null || userInfo.isCloneProfile()) {
                if (DEBUG) {
                    Log.d(TAG, "Delete the user: " + userHandles.get(i).getIdentifier());
                }
+17 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ public class ProfileSelectDialogTest {

    private static final UserHandle NORMAL_USER = new UserHandle(1111);
    private static final UserHandle REMOVED_USER = new UserHandle(2222);
    private static final UserHandle CLONE_USER = new UserHandle(3333);

    @Spy
    private Context mContext = ApplicationProvider.getApplicationContext();
@@ -101,6 +102,22 @@ public class ProfileSelectDialogTest {
        verify(mUserManager, times(2)).getUserInfo(REMOVED_USER.getIdentifier());
    }

    @Test
    public void updateUserHandlesIfNeeded_removesCloneProfile() {
        final UserInfo userInfo = new UserInfo(CLONE_USER.getIdentifier(), "clone_user", null,
                UserInfo.FLAG_PROFILE, UserManager.USER_TYPE_PROFILE_CLONE);
        when(mUserManager.getUserInfo(CLONE_USER.getIdentifier())).thenReturn(userInfo);
        final Tile tile = new ActivityTile(mActivityInfo, CategoryKey.CATEGORY_HOMEPAGE);
        tile.userHandle.add(CLONE_USER);
        tile.userHandle.add(NORMAL_USER);

        ProfileSelectDialog.updateUserHandlesIfNeeded(mContext, tile);

        assertThat(tile.userHandle).hasSize(1);
        assertThat(tile.userHandle.get(0).getIdentifier()).isEqualTo(NORMAL_USER.getIdentifier());
        verify(mUserManager, times(1)).getUserInfo(CLONE_USER.getIdentifier());
    }

    @Test
    public void createDialog_showsCorrectTitle() {
        mContext.setTheme(R.style.Theme_AppCompat);