use of android.os.UserManagerInternal in project android_frameworks_base by ResurrectionRemix.
the class SettingsProvider method startWatchingUserRestrictionChanges.
private void startWatchingUserRestrictionChanges() {
// TODO: The current design of settings looking different based on user restrictions
// should be reworked to keep them separate and system code should check the setting
// first followed by checking the user restriction before performing an operation.
UserManagerInternal userManager = LocalServices.getService(UserManagerInternal.class);
userManager.addUserRestrictionsListener((int userId, Bundle newRestrictions, Bundle prevRestrictions) -> {
// value passes the security checks, so clear binder calling id.
if (newRestrictions.containsKey(UserManager.DISALLOW_SHARE_LOCATION) != prevRestrictions.containsKey(UserManager.DISALLOW_SHARE_LOCATION)) {
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
Setting setting = getSecureSetting(Settings.Secure.LOCATION_PROVIDERS_ALLOWED, userId);
updateSecureSetting(Settings.Secure.LOCATION_PROVIDERS_ALLOWED, setting != null ? setting.getValue() : null, userId, true);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
if (newRestrictions.containsKey(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES) != prevRestrictions.containsKey(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES)) {
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
Setting setting = getGlobalSetting(Settings.Global.INSTALL_NON_MARKET_APPS);
updateGlobalSetting(Settings.Global.INSTALL_NON_MARKET_APPS, setting != null ? setting.getValue() : null, userId, true);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
if (newRestrictions.containsKey(UserManager.DISALLOW_DEBUGGING_FEATURES) != prevRestrictions.containsKey(UserManager.DISALLOW_DEBUGGING_FEATURES)) {
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
Setting setting = getGlobalSetting(Settings.Global.ADB_ENABLED);
updateGlobalSetting(Settings.Global.ADB_ENABLED, setting != null ? setting.getValue() : null, userId, true);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
if (newRestrictions.containsKey(UserManager.ENSURE_VERIFY_APPS) != prevRestrictions.containsKey(UserManager.ENSURE_VERIFY_APPS)) {
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
Setting enable = getGlobalSetting(Settings.Global.PACKAGE_VERIFIER_ENABLE);
updateGlobalSetting(Settings.Global.PACKAGE_VERIFIER_ENABLE, enable != null ? enable.getValue() : null, userId, true);
Setting include = getGlobalSetting(Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB);
updateGlobalSetting(Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, include != null ? include.getValue() : null, userId, true);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
if (newRestrictions.containsKey(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS) != prevRestrictions.containsKey(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
Setting setting = getGlobalSetting(Settings.Global.PREFERRED_NETWORK_MODE);
updateGlobalSetting(Settings.Global.PREFERRED_NETWORK_MODE, setting != null ? setting.getValue() : null, userId, true);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
});
}
use of android.os.UserManagerInternal in project android_frameworks_base by AOSPA.
the class SettingsProvider method startWatchingUserRestrictionChanges.
private void startWatchingUserRestrictionChanges() {
// TODO: The current design of settings looking different based on user restrictions
// should be reworked to keep them separate and system code should check the setting
// first followed by checking the user restriction before performing an operation.
UserManagerInternal userManager = LocalServices.getService(UserManagerInternal.class);
userManager.addUserRestrictionsListener((int userId, Bundle newRestrictions, Bundle prevRestrictions) -> {
// value passes the security checks, so clear binder calling id.
if (newRestrictions.containsKey(UserManager.DISALLOW_SHARE_LOCATION) != prevRestrictions.containsKey(UserManager.DISALLOW_SHARE_LOCATION)) {
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
Setting setting = getSecureSetting(Settings.Secure.LOCATION_PROVIDERS_ALLOWED, userId);
updateSecureSetting(Settings.Secure.LOCATION_PROVIDERS_ALLOWED, setting != null ? setting.getValue() : null, userId, true);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
if (newRestrictions.containsKey(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES) != prevRestrictions.containsKey(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES)) {
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
Setting setting = getGlobalSetting(Settings.Global.INSTALL_NON_MARKET_APPS);
updateGlobalSetting(Settings.Global.INSTALL_NON_MARKET_APPS, setting != null ? setting.getValue() : null, userId, true);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
if (newRestrictions.containsKey(UserManager.DISALLOW_DEBUGGING_FEATURES) != prevRestrictions.containsKey(UserManager.DISALLOW_DEBUGGING_FEATURES)) {
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
Setting setting = getGlobalSetting(Settings.Global.ADB_ENABLED);
updateGlobalSetting(Settings.Global.ADB_ENABLED, setting != null ? setting.getValue() : null, userId, true);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
if (newRestrictions.containsKey(UserManager.ENSURE_VERIFY_APPS) != prevRestrictions.containsKey(UserManager.ENSURE_VERIFY_APPS)) {
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
Setting enable = getGlobalSetting(Settings.Global.PACKAGE_VERIFIER_ENABLE);
updateGlobalSetting(Settings.Global.PACKAGE_VERIFIER_ENABLE, enable != null ? enable.getValue() : null, userId, true);
Setting include = getGlobalSetting(Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB);
updateGlobalSetting(Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, include != null ? include.getValue() : null, userId, true);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
if (newRestrictions.containsKey(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS) != prevRestrictions.containsKey(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
Setting setting = getGlobalSetting(Settings.Global.PREFERRED_NETWORK_MODE);
updateGlobalSetting(Settings.Global.PREFERRED_NETWORK_MODE, setting != null ? setting.getValue() : null, userId, true);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
});
}
use of android.os.UserManagerInternal in project platform_frameworks_base by android.
the class PackageManagerService method loadPrivatePackagesInner.
private void loadPrivatePackagesInner(VolumeInfo vol) {
final String volumeUuid = vol.fsUuid;
if (TextUtils.isEmpty(volumeUuid)) {
Slog.e(TAG, "Loading internal storage is probably a mistake; ignoring");
return;
}
final ArrayList<PackageFreezer> freezers = new ArrayList<>();
final ArrayList<ApplicationInfo> loaded = new ArrayList<>();
final int parseFlags = mDefParseFlags | PackageParser.PARSE_EXTERNAL_STORAGE;
final VersionInfo ver;
final List<PackageSetting> packages;
synchronized (mPackages) {
ver = mSettings.findOrCreateVersion(volumeUuid);
packages = mSettings.getVolumePackagesLPr(volumeUuid);
}
for (PackageSetting ps : packages) {
freezers.add(freezePackage(ps.name, "loadPrivatePackagesInner"));
synchronized (mInstallLock) {
final PackageParser.Package pkg;
try {
pkg = scanPackageTracedLI(ps.codePath, parseFlags, SCAN_INITIAL, 0, null);
loaded.add(pkg.applicationInfo);
} catch (PackageManagerException e) {
Slog.w(TAG, "Failed to scan " + ps.codePath + ": " + e.getMessage());
}
if (!Build.FINGERPRINT.equals(ver.fingerprint)) {
clearAppDataLIF(ps.pkg, UserHandle.USER_ALL, StorageManager.FLAG_STORAGE_DE | StorageManager.FLAG_STORAGE_CE | Installer.FLAG_CLEAR_CODE_CACHE_ONLY);
}
}
}
// Reconcile app data for all started/unlocked users
final StorageManager sm = mContext.getSystemService(StorageManager.class);
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;
}
try {
sm.prepareUserStorage(volumeUuid, user.id, user.serialNumber, flags);
synchronized (mInstallLock) {
reconcileAppsDataLI(volumeUuid, user.id, flags);
}
} catch (IllegalStateException e) {
// Device was probably ejected, and we'll process that event momentarily
Slog.w(TAG, "Failed to prepare storage: " + e);
}
}
synchronized (mPackages) {
int updateFlags = UPDATE_PERMISSIONS_ALL;
if (ver.sdkVersion != mSdkVersion) {
logCriticalInfo(Log.INFO, "Platform changed from " + ver.sdkVersion + " to " + mSdkVersion + "; regranting permissions for " + volumeUuid);
updateFlags |= UPDATE_PERMISSIONS_REPLACE_PKG | UPDATE_PERMISSIONS_REPLACE_ALL;
}
updatePermissionsLPw(null, null, volumeUuid, updateFlags);
// Yay, everything is now upgraded
ver.forceCurrent();
mSettings.writeLPr();
}
for (PackageFreezer freezer : freezers) {
freezer.close();
}
if (DEBUG_INSTALL)
Slog.d(TAG, "Loaded packages " + loaded);
sendResourcesChangedBroadcast(true, false, loaded, null);
}
use of android.os.UserManagerInternal 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.UserManagerInternal in project platform_frameworks_base by android.
the class SettingsProvider method startWatchingUserRestrictionChanges.
private void startWatchingUserRestrictionChanges() {
// TODO: The current design of settings looking different based on user restrictions
// should be reworked to keep them separate and system code should check the setting
// first followed by checking the user restriction before performing an operation.
UserManagerInternal userManager = LocalServices.getService(UserManagerInternal.class);
userManager.addUserRestrictionsListener((int userId, Bundle newRestrictions, Bundle prevRestrictions) -> {
// value passes the security checks, so clear binder calling id.
if (newRestrictions.containsKey(UserManager.DISALLOW_SHARE_LOCATION) != prevRestrictions.containsKey(UserManager.DISALLOW_SHARE_LOCATION)) {
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
Setting setting = getSecureSetting(Settings.Secure.LOCATION_PROVIDERS_ALLOWED, userId);
updateSecureSetting(Settings.Secure.LOCATION_PROVIDERS_ALLOWED, setting != null ? setting.getValue() : null, userId, true);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
if (newRestrictions.containsKey(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES) != prevRestrictions.containsKey(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES)) {
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
Setting setting = getGlobalSetting(Settings.Global.INSTALL_NON_MARKET_APPS);
updateGlobalSetting(Settings.Global.INSTALL_NON_MARKET_APPS, setting != null ? setting.getValue() : null, userId, true);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
if (newRestrictions.containsKey(UserManager.DISALLOW_DEBUGGING_FEATURES) != prevRestrictions.containsKey(UserManager.DISALLOW_DEBUGGING_FEATURES)) {
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
Setting setting = getGlobalSetting(Settings.Global.ADB_ENABLED);
updateGlobalSetting(Settings.Global.ADB_ENABLED, setting != null ? setting.getValue() : null, userId, true);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
if (newRestrictions.containsKey(UserManager.ENSURE_VERIFY_APPS) != prevRestrictions.containsKey(UserManager.ENSURE_VERIFY_APPS)) {
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
Setting enable = getGlobalSetting(Settings.Global.PACKAGE_VERIFIER_ENABLE);
updateGlobalSetting(Settings.Global.PACKAGE_VERIFIER_ENABLE, enable != null ? enable.getValue() : null, userId, true);
Setting include = getGlobalSetting(Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB);
updateGlobalSetting(Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, include != null ? include.getValue() : null, userId, true);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
if (newRestrictions.containsKey(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS) != prevRestrictions.containsKey(UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS)) {
final long identity = Binder.clearCallingIdentity();
try {
synchronized (mLock) {
Setting setting = getGlobalSetting(Settings.Global.PREFERRED_NETWORK_MODE);
updateGlobalSetting(Settings.Global.PREFERRED_NETWORK_MODE, setting != null ? setting.getValue() : null, userId, true);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
});
}
Aggregations