use of android.content.pm.UserInfo in project android_frameworks_base by ParanoidAndroid.
the class UserManagerTest method testAdd2Users.
public void testAdd2Users() throws Exception {
UserInfo user1 = mUserManager.createUser("Guest 1", UserInfo.FLAG_GUEST);
UserInfo user2 = mUserManager.createUser("User 2", UserInfo.FLAG_ADMIN);
assertTrue(user1 != null);
assertTrue(user2 != null);
assertTrue(findUser(0));
assertTrue(findUser(user1.id));
assertTrue(findUser(user2.id));
removeUser(user1.id);
removeUser(user2.id);
}
use of android.content.pm.UserInfo in project android_frameworks_base by ParanoidAndroid.
the class UserManagerTest method testRestrictions.
public void testRestrictions() {
List<UserInfo> users = mUserManager.getUsers();
if (users.size() > 1) {
Bundle restrictions = new Bundle();
restrictions.putBoolean(UserManager.DISALLOW_INSTALL_APPS, true);
restrictions.putBoolean(UserManager.DISALLOW_CONFIG_WIFI, false);
mUserManager.setUserRestrictions(restrictions, new UserHandle(users.get(1).id));
Bundle stored = mUserManager.getUserRestrictions(new UserHandle(users.get(1).id));
assertEquals(stored.getBoolean(UserManager.DISALLOW_CONFIG_WIFI), false);
assertEquals(stored.getBoolean(UserManager.DISALLOW_UNINSTALL_APPS), false);
assertEquals(stored.getBoolean(UserManager.DISALLOW_INSTALL_APPS), true);
}
}
use of android.content.pm.UserInfo in project android_frameworks_base by ParanoidAndroid.
the class UserManagerTest method testMaxUsers.
public void testMaxUsers() {
int N = UserManager.getMaxSupportedUsers();
int count = mUserManager.getUsers().size();
List<UserInfo> created = new ArrayList<UserInfo>();
// Create as many users as permitted and make sure creation passes
while (count < N) {
UserInfo ui = mUserManager.createUser("User " + count, 0);
assertNotNull(ui);
created.add(ui);
count++;
}
// Try to create one more user and make sure it fails
UserInfo extra = null;
assertNull(extra = mUserManager.createUser("One more", 0));
if (extra != null) {
removeUser(extra.id);
}
while (!created.isEmpty()) {
UserInfo user = created.remove(0);
removeUser(user.id);
}
}
use of android.content.pm.UserInfo in project platform_frameworks_base by android.
the class BaseSettingsProviderTest method setContext.
@Override
public void setContext(Context context) {
super.setContext(context);
UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
List<UserInfo> users = userManager.getUsers();
final int userCount = users.size();
for (int i = 0; i < userCount; i++) {
UserInfo user = users.get(i);
if (!user.isPrimary() && !user.isManagedProfile()) {
mSecondaryUserId = user.id;
break;
}
}
}
use of android.content.pm.UserInfo in project platform_frameworks_base by android.
the class SettingsProvider method dump.
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
synchronized (mLock) {
final long identity = Binder.clearCallingIdentity();
try {
List<UserInfo> users = mUserManager.getUsers(true);
final int userCount = users.size();
for (int i = 0; i < userCount; i++) {
UserInfo user = users.get(i);
dumpForUserLocked(user.id, pw);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
}
Aggregations