Search in sources :

Example 41 with UserInfo

use of android.content.pm.UserInfo in project platform_frameworks_base by android.

the class DpmMockContext method getProfiles.

private List<UserInfo> getProfiles(int userId) {
    final ArrayList<UserInfo> ret = new ArrayList<UserInfo>();
    UserInfo parent = null;
    for (UserInfo ui : mUserInfos) {
        if (ui.id == userId) {
            parent = ui;
            break;
        }
    }
    if (parent == null) {
        return ret;
    }
    ret.add(parent);
    for (UserInfo ui : mUserInfos) {
        if (ui.id == userId) {
            continue;
        }
        if (ui.profileGroupId != UserInfo.NO_PROFILE_GROUP_ID && ui.profileGroupId == parent.profileGroupId) {
            ret.add(ui);
        }
    }
    return ret;
}
Also used : ArrayList(java.util.ArrayList) UserInfo(android.content.pm.UserInfo)

Example 42 with UserInfo

use of android.content.pm.UserInfo in project platform_frameworks_base by android.

the class AccountManagerService method dump.

@Override
protected void dump(FileDescriptor fd, PrintWriter fout, String[] args) {
    if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) != PackageManager.PERMISSION_GRANTED) {
        fout.println("Permission Denial: can't dump AccountsManager from from pid=" + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid() + " without permission " + android.Manifest.permission.DUMP);
        return;
    }
    final boolean isCheckinRequest = scanArgs(args, "--checkin") || scanArgs(args, "-c");
    final IndentingPrintWriter ipw = new IndentingPrintWriter(fout, "  ");
    final List<UserInfo> users = getUserManager().getUsers();
    for (UserInfo user : users) {
        ipw.println("User " + user + ":");
        ipw.increaseIndent();
        dumpUser(getUserAccounts(user.id), fd, ipw, args, isCheckinRequest);
        ipw.println();
        ipw.decreaseIndent();
    }
}
Also used : UserInfo(android.content.pm.UserInfo) IndentingPrintWriter(com.android.internal.util.IndentingPrintWriter)

Example 43 with UserInfo

use of android.content.pm.UserInfo in project platform_frameworks_base by android.

the class MountService method initIfReadyAndConnected.

private void initIfReadyAndConnected() {
    Slog.d(TAG, "Thinking about init, mSystemReady=" + mSystemReady + ", mDaemonConnected=" + mDaemonConnected);
    if (mSystemReady && mDaemonConnected && !StorageManager.isFileEncryptedNativeOnly()) {
        // When booting a device without native support, make sure that our
        // user directories are locked or unlocked based on the current
        // emulation status.
        final boolean initLocked = StorageManager.isFileEncryptedEmulatedOnly();
        Slog.d(TAG, "Setting up emulation state, initlocked=" + initLocked);
        final List<UserInfo> users = mContext.getSystemService(UserManager.class).getUsers();
        for (UserInfo user : users) {
            try {
                if (initLocked) {
                    mCryptConnector.execute("cryptfs", "lock_user_key", user.id);
                } else {
                    mCryptConnector.execute("cryptfs", "unlock_user_key", user.id, user.serialNumber, "!", "!");
                }
            } catch (NativeDaemonConnectorException e) {
                Slog.w(TAG, "Failed to init vold", e);
            }
        }
    }
}
Also used : UserManager(android.os.UserManager) UserInfo(android.content.pm.UserInfo)

Example 44 with UserInfo

use of android.content.pm.UserInfo in project platform_frameworks_base by android.

the class Am method runGetCurrentUser.

private void runGetCurrentUser() throws Exception {
    UserInfo currentUser = Preconditions.checkNotNull(mAm.getCurrentUser(), "Current user not set");
    System.out.println(currentUser.id);
}
Also used : UserInfo(android.content.pm.UserInfo)

Example 45 with UserInfo

use of android.content.pm.UserInfo in project platform_frameworks_base by android.

the class Pm method runCreateUser.

public int runCreateUser() {
    String name;
    int userId = -1;
    int flags = 0;
    String opt;
    while ((opt = nextOption()) != null) {
        if ("--profileOf".equals(opt)) {
            String optionData = nextOptionData();
            if (optionData == null || !isNumber(optionData)) {
                System.err.println("Error: no USER_ID specified");
                return showUsage();
            } else {
                userId = Integer.parseInt(optionData);
            }
        } else if ("--managed".equals(opt)) {
            flags |= UserInfo.FLAG_MANAGED_PROFILE;
        } else if ("--restricted".equals(opt)) {
            flags |= UserInfo.FLAG_RESTRICTED;
        } else if ("--ephemeral".equals(opt)) {
            flags |= UserInfo.FLAG_EPHEMERAL;
        } else if ("--guest".equals(opt)) {
            flags |= UserInfo.FLAG_GUEST;
        } else if ("--demo".equals(opt)) {
            flags |= UserInfo.FLAG_DEMO;
        } else {
            System.err.println("Error: unknown option " + opt);
            return showUsage();
        }
    }
    String arg = nextArg();
    if (arg == null) {
        System.err.println("Error: no user name specified.");
        return 1;
    }
    name = arg;
    try {
        UserInfo info;
        if ((flags & UserInfo.FLAG_RESTRICTED) != 0) {
            // In non-split user mode, userId can only be SYSTEM
            int parentUserId = userId >= 0 ? userId : UserHandle.USER_SYSTEM;
            info = mUm.createRestrictedProfile(name, parentUserId);
            mAm.addSharedAccountsFromParentUser(parentUserId, userId);
        } else if (userId < 0) {
            info = mUm.createUser(name, flags);
        } else {
            info = mUm.createProfileForUser(name, flags, userId);
        }
        if (info != null) {
            System.out.println("Success: created user id " + info.id);
            return 1;
        } else {
            System.err.println("Error: couldn't create User.");
            return 1;
        }
    } catch (RemoteException e) {
        System.err.println(e.toString());
        System.err.println(PM_NOT_RUNNING_ERR);
        return 1;
    }
}
Also used : UserInfo(android.content.pm.UserInfo) RemoteException(android.os.RemoteException)

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