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;
}
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();
}
}
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);
}
}
}
}
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);
}
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;
}
}
Aggregations