use of android.content.pm.UserInfo in project platform_frameworks_base by android.
the class UserManagerService method setQuietModeEnabled.
@Override
public void setQuietModeEnabled(int userHandle, boolean enableQuietMode) {
checkManageUsersPermission("silence profile");
boolean changed = false;
UserInfo profile, parent;
synchronized (mPackagesLock) {
synchronized (mUsersLock) {
profile = getUserInfoLU(userHandle);
parent = getProfileParentLU(userHandle);
}
if (profile == null || !profile.isManagedProfile()) {
throw new IllegalArgumentException("User " + userHandle + " is not a profile");
}
if (profile.isQuietModeEnabled() != enableQuietMode) {
profile.flags ^= UserInfo.FLAG_QUIET_MODE;
writeUserLP(getUserDataLU(profile.id));
changed = true;
}
}
if (changed) {
long identity = Binder.clearCallingIdentity();
try {
if (enableQuietMode) {
ActivityManagerNative.getDefault().stopUser(userHandle, /* force */
true, null);
LocalServices.getService(ActivityManagerInternal.class).killForegroundAppsForUser(userHandle);
} else {
ActivityManagerNative.getDefault().startUserInBackground(userHandle);
}
} catch (RemoteException e) {
Slog.e(LOG_TAG, "fail to start/stop user for quiet mode", e);
} finally {
Binder.restoreCallingIdentity(identity);
}
broadcastProfileAvailabilityChanges(profile.getUserHandle(), parent.getUserHandle(), enableQuietMode);
}
}
use of android.content.pm.UserInfo in project platform_frameworks_base by android.
the class Settings method dumpPackageLPr.
void dumpPackageLPr(PrintWriter pw, String prefix, String checkinTag, ArraySet<String> permissionNames, PackageSetting ps, SimpleDateFormat sdf, Date date, List<UserInfo> users, boolean dumpAll) {
if (checkinTag != null) {
pw.print(checkinTag);
pw.print(",");
pw.print(ps.realName != null ? ps.realName : ps.name);
pw.print(",");
pw.print(ps.appId);
pw.print(",");
pw.print(ps.versionCode);
pw.print(",");
pw.print(ps.firstInstallTime);
pw.print(",");
pw.print(ps.lastUpdateTime);
pw.print(",");
pw.print(ps.installerPackageName != null ? ps.installerPackageName : "?");
pw.println();
if (ps.pkg != null) {
pw.print(checkinTag);
pw.print("-");
pw.print("splt,");
pw.print("base,");
pw.println(ps.pkg.baseRevisionCode);
if (ps.pkg.splitNames != null) {
for (int i = 0; i < ps.pkg.splitNames.length; i++) {
pw.print(checkinTag);
pw.print("-");
pw.print("splt,");
pw.print(ps.pkg.splitNames[i]);
pw.print(",");
pw.println(ps.pkg.splitRevisionCodes[i]);
}
}
}
for (UserInfo user : users) {
pw.print(checkinTag);
pw.print("-");
pw.print("usr");
pw.print(",");
pw.print(user.id);
pw.print(",");
pw.print(ps.getInstalled(user.id) ? "I" : "i");
pw.print(ps.getHidden(user.id) ? "B" : "b");
pw.print(ps.getSuspended(user.id) ? "SU" : "su");
pw.print(ps.getStopped(user.id) ? "S" : "s");
pw.print(ps.getNotLaunched(user.id) ? "l" : "L");
pw.print(",");
pw.print(ps.getEnabled(user.id));
String lastDisabledAppCaller = ps.getLastDisabledAppCaller(user.id);
pw.print(",");
pw.print(lastDisabledAppCaller != null ? lastDisabledAppCaller : "?");
pw.println();
}
return;
}
pw.print(prefix);
pw.print("Package [");
pw.print(ps.realName != null ? ps.realName : ps.name);
pw.print("] (");
pw.print(Integer.toHexString(System.identityHashCode(ps)));
pw.println("):");
if (ps.realName != null) {
pw.print(prefix);
pw.print(" compat name=");
pw.println(ps.name);
}
pw.print(prefix);
pw.print(" userId=");
pw.println(ps.appId);
if (ps.sharedUser != null) {
pw.print(prefix);
pw.print(" sharedUser=");
pw.println(ps.sharedUser);
}
pw.print(prefix);
pw.print(" pkg=");
pw.println(ps.pkg);
pw.print(prefix);
pw.print(" codePath=");
pw.println(ps.codePathString);
if (permissionNames == null) {
pw.print(prefix);
pw.print(" resourcePath=");
pw.println(ps.resourcePathString);
pw.print(prefix);
pw.print(" legacyNativeLibraryDir=");
pw.println(ps.legacyNativeLibraryPathString);
pw.print(prefix);
pw.print(" primaryCpuAbi=");
pw.println(ps.primaryCpuAbiString);
pw.print(prefix);
pw.print(" secondaryCpuAbi=");
pw.println(ps.secondaryCpuAbiString);
}
pw.print(prefix);
pw.print(" versionCode=");
pw.print(ps.versionCode);
if (ps.pkg != null) {
pw.print(" minSdk=");
pw.print(ps.pkg.applicationInfo.minSdkVersion);
pw.print(" targetSdk=");
pw.print(ps.pkg.applicationInfo.targetSdkVersion);
}
pw.println();
if (ps.pkg != null) {
if (ps.pkg.parentPackage != null) {
PackageParser.Package parentPkg = ps.pkg.parentPackage;
PackageSetting pps = mPackages.get(parentPkg.packageName);
if (pps == null || !pps.codePathString.equals(parentPkg.codePath)) {
pps = mDisabledSysPackages.get(parentPkg.packageName);
}
if (pps != null) {
pw.print(prefix);
pw.print(" parentPackage=");
pw.println(pps.realName != null ? pps.realName : pps.name);
}
} else if (ps.pkg.childPackages != null) {
pw.print(prefix);
pw.print(" childPackages=[");
final int childCount = ps.pkg.childPackages.size();
for (int i = 0; i < childCount; i++) {
PackageParser.Package childPkg = ps.pkg.childPackages.get(i);
PackageSetting cps = mPackages.get(childPkg.packageName);
if (cps == null || !cps.codePathString.equals(childPkg.codePath)) {
cps = mDisabledSysPackages.get(childPkg.packageName);
}
if (cps != null) {
if (i > 0) {
pw.print(", ");
}
pw.print(cps.realName != null ? cps.realName : cps.name);
}
}
pw.println("]");
}
pw.print(prefix);
pw.print(" versionName=");
pw.println(ps.pkg.mVersionName);
pw.print(prefix);
pw.print(" splits=");
dumpSplitNames(pw, ps.pkg);
pw.println();
final int apkSigningVersion = PackageParser.getApkSigningVersion(ps.pkg);
if (apkSigningVersion != PackageParser.APK_SIGNING_UNKNOWN) {
pw.print(prefix);
pw.print(" apkSigningVersion=");
pw.println(apkSigningVersion);
}
pw.print(prefix);
pw.print(" applicationInfo=");
pw.println(ps.pkg.applicationInfo.toString());
pw.print(prefix);
pw.print(" flags=");
printFlags(pw, ps.pkg.applicationInfo.flags, FLAG_DUMP_SPEC);
pw.println();
if (ps.pkg.applicationInfo.privateFlags != 0) {
pw.print(prefix);
pw.print(" privateFlags=");
printFlags(pw, ps.pkg.applicationInfo.privateFlags, PRIVATE_FLAG_DUMP_SPEC);
pw.println();
}
pw.print(prefix);
pw.print(" dataDir=");
pw.println(ps.pkg.applicationInfo.dataDir);
pw.print(prefix);
pw.print(" supportsScreens=[");
boolean first = true;
if ((ps.pkg.applicationInfo.flags & ApplicationInfo.FLAG_SUPPORTS_SMALL_SCREENS) != 0) {
if (!first)
pw.print(", ");
first = false;
pw.print("small");
}
if ((ps.pkg.applicationInfo.flags & ApplicationInfo.FLAG_SUPPORTS_NORMAL_SCREENS) != 0) {
if (!first)
pw.print(", ");
first = false;
pw.print("medium");
}
if ((ps.pkg.applicationInfo.flags & ApplicationInfo.FLAG_SUPPORTS_LARGE_SCREENS) != 0) {
if (!first)
pw.print(", ");
first = false;
pw.print("large");
}
if ((ps.pkg.applicationInfo.flags & ApplicationInfo.FLAG_SUPPORTS_XLARGE_SCREENS) != 0) {
if (!first)
pw.print(", ");
first = false;
pw.print("xlarge");
}
if ((ps.pkg.applicationInfo.flags & ApplicationInfo.FLAG_RESIZEABLE_FOR_SCREENS) != 0) {
if (!first)
pw.print(", ");
first = false;
pw.print("resizeable");
}
if ((ps.pkg.applicationInfo.flags & ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES) != 0) {
if (!first)
pw.print(", ");
first = false;
pw.print("anyDensity");
}
pw.println("]");
if (ps.pkg.libraryNames != null && ps.pkg.libraryNames.size() > 0) {
pw.print(prefix);
pw.println(" libraries:");
for (int i = 0; i < ps.pkg.libraryNames.size(); i++) {
pw.print(prefix);
pw.print(" ");
pw.println(ps.pkg.libraryNames.get(i));
}
}
if (ps.pkg.usesLibraries != null && ps.pkg.usesLibraries.size() > 0) {
pw.print(prefix);
pw.println(" usesLibraries:");
for (int i = 0; i < ps.pkg.usesLibraries.size(); i++) {
pw.print(prefix);
pw.print(" ");
pw.println(ps.pkg.usesLibraries.get(i));
}
}
if (ps.pkg.usesOptionalLibraries != null && ps.pkg.usesOptionalLibraries.size() > 0) {
pw.print(prefix);
pw.println(" usesOptionalLibraries:");
for (int i = 0; i < ps.pkg.usesOptionalLibraries.size(); i++) {
pw.print(prefix);
pw.print(" ");
pw.println(ps.pkg.usesOptionalLibraries.get(i));
}
}
if (ps.pkg.usesLibraryFiles != null && ps.pkg.usesLibraryFiles.length > 0) {
pw.print(prefix);
pw.println(" usesLibraryFiles:");
for (int i = 0; i < ps.pkg.usesLibraryFiles.length; i++) {
pw.print(prefix);
pw.print(" ");
pw.println(ps.pkg.usesLibraryFiles[i]);
}
}
}
pw.print(prefix);
pw.print(" timeStamp=");
date.setTime(ps.timeStamp);
pw.println(sdf.format(date));
pw.print(prefix);
pw.print(" firstInstallTime=");
date.setTime(ps.firstInstallTime);
pw.println(sdf.format(date));
pw.print(prefix);
pw.print(" lastUpdateTime=");
date.setTime(ps.lastUpdateTime);
pw.println(sdf.format(date));
if (ps.installerPackageName != null) {
pw.print(prefix);
pw.print(" installerPackageName=");
pw.println(ps.installerPackageName);
}
if (ps.volumeUuid != null) {
pw.print(prefix);
pw.print(" volumeUuid=");
pw.println(ps.volumeUuid);
}
pw.print(prefix);
pw.print(" signatures=");
pw.println(ps.signatures);
pw.print(prefix);
pw.print(" installPermissionsFixed=");
pw.print(ps.installPermissionsFixed);
pw.print(" installStatus=");
pw.println(ps.installStatus);
pw.print(prefix);
pw.print(" pkgFlags=");
printFlags(pw, ps.pkgFlags, FLAG_DUMP_SPEC);
pw.println();
if (ps.pkg != null && ps.pkg.permissions != null && ps.pkg.permissions.size() > 0) {
final ArrayList<PackageParser.Permission> perms = ps.pkg.permissions;
pw.print(prefix);
pw.println(" declared permissions:");
for (int i = 0; i < perms.size(); i++) {
PackageParser.Permission perm = perms.get(i);
if (permissionNames != null && !permissionNames.contains(perm.info.name)) {
continue;
}
pw.print(prefix);
pw.print(" ");
pw.print(perm.info.name);
pw.print(": prot=");
pw.print(PermissionInfo.protectionToString(perm.info.protectionLevel));
if ((perm.info.flags & PermissionInfo.FLAG_COSTS_MONEY) != 0) {
pw.print(", COSTS_MONEY");
}
if ((perm.info.flags & PermissionInfo.FLAG_REMOVED) != 0) {
pw.print(", HIDDEN");
}
if ((perm.info.flags & PermissionInfo.FLAG_INSTALLED) != 0) {
pw.print(", INSTALLED");
}
pw.println();
}
}
if ((permissionNames != null || dumpAll) && ps.pkg != null && ps.pkg.requestedPermissions != null && ps.pkg.requestedPermissions.size() > 0) {
final ArrayList<String> perms = ps.pkg.requestedPermissions;
pw.print(prefix);
pw.println(" requested permissions:");
for (int i = 0; i < perms.size(); i++) {
String perm = perms.get(i);
if (permissionNames != null && !permissionNames.contains(perm)) {
continue;
}
pw.print(prefix);
pw.print(" ");
pw.println(perm);
}
}
if (ps.sharedUser == null || permissionNames != null || dumpAll) {
PermissionsState permissionsState = ps.getPermissionsState();
dumpInstallPermissionsLPr(pw, prefix + " ", permissionNames, permissionsState);
}
for (UserInfo user : users) {
pw.print(prefix);
pw.print(" User ");
pw.print(user.id);
pw.print(": ");
pw.print("ceDataInode=");
pw.print(ps.getCeDataInode(user.id));
pw.print(" installed=");
pw.print(ps.getInstalled(user.id));
pw.print(" hidden=");
pw.print(ps.getHidden(user.id));
pw.print(" suspended=");
pw.print(ps.getSuspended(user.id));
pw.print(" stopped=");
pw.print(ps.getStopped(user.id));
pw.print(" notLaunched=");
pw.print(ps.getNotLaunched(user.id));
pw.print(" enabled=");
pw.println(ps.getEnabled(user.id));
String lastDisabledAppCaller = ps.getLastDisabledAppCaller(user.id);
if (lastDisabledAppCaller != null) {
pw.print(prefix);
pw.print(" lastDisabledCaller: ");
pw.println(lastDisabledAppCaller);
}
if (ps.sharedUser == null) {
PermissionsState permissionsState = ps.getPermissionsState();
dumpGidsLPr(pw, prefix + " ", permissionsState.computeGids(user.id));
dumpRuntimePermissionsLPr(pw, prefix + " ", permissionNames, permissionsState.getRuntimePermissionStates(user.id), dumpAll);
}
if (permissionNames == null) {
ArraySet<String> cmp = ps.getDisabledComponents(user.id);
if (cmp != null && cmp.size() > 0) {
pw.print(prefix);
pw.println(" disabledComponents:");
for (String s : cmp) {
pw.print(prefix);
pw.print(" ");
pw.println(s);
}
}
cmp = ps.getEnabledComponents(user.id);
if (cmp != null && cmp.size() > 0) {
pw.print(prefix);
pw.println(" enabledComponents:");
for (String s : cmp) {
pw.print(prefix);
pw.print(" ");
pw.println(s);
}
}
}
}
}
use of android.content.pm.UserInfo in project platform_frameworks_base by android.
the class UserManagerService method userWithName.
/**
* Returns a UserInfo object with the name filled in, for Owner, or the original
* if the name is already set.
*/
private UserInfo userWithName(UserInfo orig) {
if (orig != null && orig.name == null && orig.id == UserHandle.USER_SYSTEM) {
UserInfo withName = new UserInfo(orig);
withName.name = getOwnerName();
return withName;
} else {
return orig;
}
}
use of android.content.pm.UserInfo in project platform_frameworks_base by android.
the class UserManagerService method systemReady.
void systemReady() {
mAppOpsService = IAppOpsService.Stub.asInterface(ServiceManager.getService(Context.APP_OPS_SERVICE));
synchronized (mRestrictionsLock) {
applyUserRestrictionsLR(UserHandle.USER_SYSTEM);
}
UserInfo currentGuestUser = findCurrentGuestUser();
if (currentGuestUser != null && !hasUserRestriction(UserManager.DISALLOW_CONFIG_WIFI, currentGuestUser.id)) {
// If a guest user currently exists, apply the DISALLOW_CONFIG_WIFI option
// to it, in case this guest was created in a previous version where this
// user restriction was not a default guest restriction.
setUserRestriction(UserManager.DISALLOW_CONFIG_WIFI, true, currentGuestUser.id);
}
mContext.registerReceiver(mDisableQuietModeCallback, new IntentFilter(ACTION_DISABLE_QUIET_MODE_AFTER_UNLOCK), null, mHandler);
}
use of android.content.pm.UserInfo in project platform_frameworks_base by android.
the class UserManagerService method getProfilesLU.
/** Assume permissions already checked and caller's identity cleared */
private List<UserInfo> getProfilesLU(int userId, boolean enabledOnly, boolean fullInfo) {
IntArray profileIds = getProfileIdsLU(userId, enabledOnly);
ArrayList<UserInfo> users = new ArrayList<>(profileIds.size());
for (int i = 0; i < profileIds.size(); i++) {
int profileId = profileIds.get(i);
UserInfo userInfo = mUsers.get(profileId).info;
// If full info is not required - clear PII data to prevent 3P apps from reading it
if (!fullInfo) {
userInfo = new UserInfo(userInfo);
userInfo.name = null;
userInfo.iconPath = null;
} else {
userInfo = userWithName(userInfo);
}
users.add(userInfo);
}
return users;
}
Aggregations