Merge "Don't show owner as a secondary user."
This commit is contained in:
@@ -32,6 +32,7 @@ import com.android.settings.core.PreferenceController;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SecondaryUserController controls the preferences on the Storage screen which had to do with
|
* SecondaryUserController controls the preferences on the Storage screen which had to do with
|
||||||
* secondary users.
|
* secondary users.
|
||||||
@@ -62,7 +63,7 @@ public class SecondaryUserController extends PreferenceController implements
|
|||||||
List<UserInfo> infos = userManager.getUsers();
|
List<UserInfo> infos = userManager.getUsers();
|
||||||
for (int i = 0, size = infos.size(); i < size; i++) {
|
for (int i = 0, size = infos.size(); i < size; i++) {
|
||||||
UserInfo info = infos.get(i);
|
UserInfo info = infos.get(i);
|
||||||
if (info.equals(primaryUser)) {
|
if (info.isPrimary()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -69,6 +69,7 @@ public class SecondaryUserControllerTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = RuntimeEnvironment.application;
|
mContext = RuntimeEnvironment.application;
|
||||||
mPrimaryUser = new UserInfo();
|
mPrimaryUser = new UserInfo();
|
||||||
|
mPrimaryUser.flags = UserInfo.FLAG_PRIMARY;
|
||||||
mController = new SecondaryUserController(mContext, mPrimaryUser);
|
mController = new SecondaryUserController(mContext, mPrimaryUser);
|
||||||
|
|
||||||
when(mScreen.getContext()).thenReturn(mContext);
|
when(mScreen.getContext()).thenReturn(mContext);
|
||||||
@@ -167,4 +168,23 @@ public class SecondaryUserControllerTest {
|
|||||||
|
|
||||||
assertThat(preference.getSummary()).isEqualTo("99.00B");
|
assertThat(preference.getSummary()).isEqualTo("99.00B");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void dontAddPrimaryProfileAsASecondaryProfile() throws Exception {
|
||||||
|
ArrayList<UserInfo> userInfos = new ArrayList<>();
|
||||||
|
// The primary UserInfo may be a different object with a different name... but represent the
|
||||||
|
// same user!
|
||||||
|
UserInfo primaryUserRenamed = new UserInfo();
|
||||||
|
primaryUserRenamed.name = "Owner";
|
||||||
|
primaryUserRenamed.flags = UserInfo.FLAG_PRIMARY;
|
||||||
|
userInfos.add(primaryUserRenamed);
|
||||||
|
when(mUserManager.getPrimaryUser()).thenReturn(mPrimaryUser);
|
||||||
|
when(mUserManager.getUsers()).thenReturn(userInfos);
|
||||||
|
List<PreferenceController> controllers =
|
||||||
|
SecondaryUserController.getSecondaryUserControllers(mContext, mUserManager);
|
||||||
|
|
||||||
|
assertThat(controllers).hasSize(1);
|
||||||
|
// We should have the NoSecondaryUserController.
|
||||||
|
assertThat(controllers.get(0) instanceof SecondaryUserController).isFalse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user