use of android.content.pm.UserInfo in project platform_frameworks_base by android.
the class UserManagerTest method testAdd2Users.
public void testAdd2Users() throws Exception {
UserInfo user1 = createUser("Guest 1", UserInfo.FLAG_GUEST);
UserInfo user2 = createUser("User 2", UserInfo.FLAG_ADMIN);
assertTrue(user1 != null);
assertTrue(user2 != null);
assertTrue(findUser(0));
assertTrue(findUser(user1.id));
assertTrue(findUser(user2.id));
}
use of android.content.pm.UserInfo in project platform_frameworks_base by android.
the class UserManagerTest method testAddManagedProfile.
// Make sure only one managed profile can be created
public void testAddManagedProfile() throws Exception {
final int primaryUserId = mUserManager.getPrimaryUser().id;
UserInfo userInfo1 = createProfileForUser("Managed 1", UserInfo.FLAG_MANAGED_PROFILE, primaryUserId);
UserInfo userInfo2 = createProfileForUser("Managed 2", UserInfo.FLAG_MANAGED_PROFILE, primaryUserId);
assertNotNull(userInfo1);
assertNull(userInfo2);
// Verify that current user is not a managed profile
assertFalse(mUserManager.isManagedProfile());
}
use of android.content.pm.UserInfo in project platform_frameworks_base by android.
the class UserManagerTest method testAddUser.
public void testAddUser() throws Exception {
UserInfo userInfo = createUser("Guest 1", UserInfo.FLAG_GUEST);
assertTrue(userInfo != null);
List<UserInfo> list = mUserManager.getUsers();
boolean found = false;
for (UserInfo user : list) {
if (user.id == userInfo.id && user.name.equals("Guest 1") && user.isGuest() && !user.isAdmin() && !user.isPrimary()) {
found = true;
Bundle restrictions = mUserManager.getUserRestrictions(user.getUserHandle());
assertTrue("Guest user should have DISALLOW_CONFIG_WIFI=true by default", restrictions.getBoolean(UserManager.DISALLOW_CONFIG_WIFI));
}
}
assertTrue(found);
}
use of android.content.pm.UserInfo in project platform_frameworks_base by android.
the class UserManagerTest method testSerialNumber.
public void testSerialNumber() {
UserInfo user1 = createUser("User 1", 0);
int serialNumber1 = user1.serialNumber;
assertEquals(serialNumber1, mUserManager.getUserSerialNumber(user1.id));
assertEquals(user1.id, mUserManager.getUserHandle(serialNumber1));
UserInfo user2 = createUser("User 2", 0);
int serialNumber2 = user2.serialNumber;
assertFalse(serialNumber1 == serialNumber2);
assertEquals(serialNumber2, mUserManager.getUserSerialNumber(user2.id));
assertEquals(user2.id, mUserManager.getUserHandle(serialNumber2));
}
use of android.content.pm.UserInfo in project platform_frameworks_base by android.
the class PermissionMonitor method startMonitoring.
// Intended to be called only once at startup, after the system is ready. Installs a broadcast
// receiver to monitor ongoing UID changes, so this shouldn't/needn't be called again.
public synchronized void startMonitoring() {
log("Monitoring");
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_USER_ADDED);
intentFilter.addAction(Intent.ACTION_USER_REMOVED);
mContext.registerReceiverAsUser(mIntentReceiver, UserHandle.ALL, intentFilter, null, null);
intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
intentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
intentFilter.addDataScheme("package");
mContext.registerReceiverAsUser(mIntentReceiver, UserHandle.ALL, intentFilter, null, null);
List<PackageInfo> apps = mPackageManager.getInstalledPackages(GET_PERMISSIONS);
if (apps == null) {
loge("No apps");
return;
}
for (PackageInfo app : apps) {
int uid = app.applicationInfo != null ? app.applicationInfo.uid : -1;
if (uid < 0) {
continue;
}
boolean isNetwork = hasNetworkPermission(app);
boolean hasRestrictedPermission = hasRestrictedNetworkPermission(app);
if (isNetwork || hasRestrictedPermission) {
Boolean permission = mApps.get(uid);
// permissions, don't downgrade (i.e., if it's already SYSTEM, leave it as is).
if (permission == null || permission == NETWORK) {
mApps.put(uid, hasRestrictedPermission);
}
}
}
// exclude dying users
List<UserInfo> users = mUserManager.getUsers(true);
if (users != null) {
for (UserInfo user : users) {
mUsers.add(user.id);
}
}
log("Users: " + mUsers.size() + ", Apps: " + mApps.size());
update(mUsers, mApps, true);
}
Aggregations