Search in sources :

Example 16 with UserInfo

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);
}
Also used : UserInfo(android.content.pm.UserInfo)

Example 17 with UserInfo

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);
    }
}
Also used : Bundle(android.os.Bundle) UserHandle(android.os.UserHandle) UserInfo(android.content.pm.UserInfo)

Example 18 with UserInfo

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);
    }
}
Also used : ArrayList(java.util.ArrayList) UserInfo(android.content.pm.UserInfo)

Example 19 with UserInfo

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;
        }
    }
}
Also used : UserManager(android.os.UserManager) UserInfo(android.content.pm.UserInfo)

Example 20 with UserInfo

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);
        }
    }
}
Also used : UserInfo(android.content.pm.UserInfo)

Aggregations

UserInfo (android.content.pm.UserInfo)814 UserManager (android.os.UserManager)156 RemoteException (android.os.RemoteException)144 ArrayList (java.util.ArrayList)73 UserHandle (android.os.UserHandle)66 Intent (android.content.Intent)58 IOException (java.io.IOException)52 File (java.io.File)47 Bundle (android.os.Bundle)43 ApplicationInfo (android.content.pm.ApplicationInfo)40 PackageManager (android.content.pm.PackageManager)39 ComponentName (android.content.ComponentName)32 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)31 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)30 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)29 AtomicFile (android.util.AtomicFile)28 PackageInfo (android.content.pm.PackageInfo)26 DevicePolicyManager (android.app.admin.DevicePolicyManager)25 LockPatternUtils (com.android.internal.widget.LockPatternUtils)24 PendingIntent (android.app.PendingIntent)23