use of android.os.UserManager in project platform_frameworks_base by android.
the class PackageManagerService method prepareAppDataAfterInstallLIF.
/**
* Prepare app data for the given app just after it was installed or
* upgraded. This method carefully only touches users that it's installed
* for, and it forces a restorecon to handle any seinfo changes.
* <p>
* Verifies that directories exist and that ownership and labeling is
* correct for all installed apps. If there is an ownership mismatch, it
* will try recovering system apps by wiping data; third-party app data is
* left intact.
* <p>
* <em>Note: To avoid a deadlock, do not call this method with {@code mPackages} lock held</em>
*/
private void prepareAppDataAfterInstallLIF(PackageParser.Package pkg) {
final PackageSetting ps;
synchronized (mPackages) {
ps = mSettings.mPackages.get(pkg.packageName);
mSettings.writeKernelMappingLPr(ps);
}
final UserManager um = mContext.getSystemService(UserManager.class);
UserManagerInternal umInternal = getUserManagerInternal();
for (UserInfo user : um.getUsers()) {
final int flags;
if (umInternal.isUserUnlockingOrUnlocked(user.id)) {
flags = StorageManager.FLAG_STORAGE_DE | StorageManager.FLAG_STORAGE_CE;
} else if (umInternal.isUserRunning(user.id)) {
flags = StorageManager.FLAG_STORAGE_DE;
} else {
continue;
}
if (ps.getInstalled(user.id)) {
// TODO: when user data is locked, mark that we're still dirty
prepareAppDataLIF(pkg, user.id, flags);
}
}
}
use of android.os.UserManager in project platform_frameworks_base by android.
the class WallpaperManagerService method isSetWallpaperAllowed.
@Override
public boolean isSetWallpaperAllowed(String callingPackage) {
final PackageManager pm = mContext.getPackageManager();
String[] uidPackages = pm.getPackagesForUid(Binder.getCallingUid());
boolean uidMatchPackage = Arrays.asList(uidPackages).contains(callingPackage);
if (!uidMatchPackage) {
// callingPackage was faked.
return false;
}
final DevicePolicyManager dpm = mContext.getSystemService(DevicePolicyManager.class);
if (dpm.isDeviceOwnerApp(callingPackage) || dpm.isProfileOwnerApp(callingPackage)) {
return true;
}
final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
return !um.hasUserRestriction(UserManager.DISALLOW_SET_WALLPAPER);
}
use of android.os.UserManager 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;
}
}
}
use of android.os.UserManager in project platform_frameworks_base by android.
the class SettingsHelper method setGpsLocation.
private void setGpsLocation(String value) {
UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
if (um.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION)) {
return;
}
final String GPS = LocationManager.GPS_PROVIDER;
boolean enabled = GPS.equals(value) || value.startsWith(GPS + ",") || value.endsWith("," + GPS) || value.contains("," + GPS + ",");
Settings.Secure.setLocationProviderEnabled(mContext.getContentResolver(), GPS, enabled);
}
use of android.os.UserManager in project platform_frameworks_base by android.
the class SettingsProviderTest method testSettingsChangeForOtherUser.
@MediumTest
public void testSettingsChangeForOtherUser() {
UserManager um = (UserManager) getContext().getSystemService(Context.USER_SERVICE);
ContentResolver r = getContext().getContentResolver();
// Make sure there's an owner
assertTrue(findUser(um, UserHandle.USER_SYSTEM));
// create a new user to use for testing
UserInfo otherUser = um.createUser("TestUser1", UserInfo.FLAG_GUEST);
assertTrue(otherUser != null);
try {
assertNotSame("Current calling user id should not be the new guest user", otherUser.id, UserHandle.getCallingUserId());
final String testKey = "testSettingsChangeForOtherUser";
final String testValue1 = "value1";
final String testValue2 = "value2";
Settings.Secure.putString(r, testKey, testValue1);
Settings.Secure.putStringForUser(r, testKey, testValue2, otherUser.id);
assertEquals(testValue1, Settings.Secure.getString(r, testKey));
assertEquals(testValue2, Settings.Secure.getStringForUser(r, testKey, otherUser.id));
assertNotSame("Current calling user id should not be the new guest user", otherUser.id, UserHandle.getCallingUserId());
} finally {
// Tidy up
um.removeUser(otherUser.id);
}
}
Aggregations