use of com.android.providers.settings.SettingsState.Setting in project android_frameworks_base by ResurrectionRemix.
the class SettingsProvider method getAllGlobalSettings.
private Cursor getAllGlobalSettings(String[] projection) {
if (DEBUG) {
Slog.v(LOG_TAG, "getAllGlobalSettings()");
}
synchronized (mLock) {
// Get the settings.
SettingsState settingsState = mSettingsRegistry.getSettingsLocked(SETTINGS_TYPE_GLOBAL, UserHandle.USER_SYSTEM);
List<String> names = settingsState.getSettingNamesLocked();
final int nameCount = names.size();
String[] normalizedProjection = normalizeProjection(projection);
MatrixCursor result = new MatrixCursor(normalizedProjection, nameCount);
// Anyone can get the global settings, so no security checks.
for (int i = 0; i < nameCount; i++) {
String name = names.get(i);
Setting setting = settingsState.getSettingLocked(name);
appendSettingToCursor(result, setting);
}
return result;
}
}
use of com.android.providers.settings.SettingsState.Setting in project android_frameworks_base by ResurrectionRemix.
the class SettingsProvider method getAllSecureSettings.
private Cursor getAllSecureSettings(int userId, String[] projection) {
if (DEBUG) {
Slog.v(LOG_TAG, "getAllSecureSettings(" + userId + ")");
}
// Resolve the userId on whose behalf the call is made.
final int callingUserId = resolveCallingUserIdEnforcingPermissionsLocked(userId);
synchronized (mLock) {
List<String> names = mSettingsRegistry.getSettingsNamesLocked(SETTINGS_TYPE_SECURE, callingUserId);
final int nameCount = names.size();
String[] normalizedProjection = normalizeProjection(projection);
MatrixCursor result = new MatrixCursor(normalizedProjection, nameCount);
for (int i = 0; i < nameCount; i++) {
String name = names.get(i);
// Determine the owning user as some profile settings are cloned from the parent.
final int owningUserId = resolveOwningUserIdForSecureSettingLocked(callingUserId, name);
// Special case for location (sigh).
if (isLocationProvidersAllowedRestricted(name, callingUserId, owningUserId)) {
continue;
}
Setting setting = mSettingsRegistry.getSettingLocked(SETTINGS_TYPE_SECURE, owningUserId, name);
appendSettingToCursor(result, setting);
}
return result;
}
}
use of com.android.providers.settings.SettingsState.Setting 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 com.android.providers.settings.SettingsState.Setting in project android_frameworks_base by DirtyUnicorns.
the class SettingsProvider method getAllSecureSettings.
private Cursor getAllSecureSettings(int userId, String[] projection) {
if (DEBUG) {
Slog.v(LOG_TAG, "getAllSecureSettings(" + userId + ")");
}
// Resolve the userId on whose behalf the call is made.
final int callingUserId = resolveCallingUserIdEnforcingPermissionsLocked(userId);
synchronized (mLock) {
List<String> names = mSettingsRegistry.getSettingsNamesLocked(SETTINGS_TYPE_SECURE, callingUserId);
final int nameCount = names.size();
String[] normalizedProjection = normalizeProjection(projection);
MatrixCursor result = new MatrixCursor(normalizedProjection, nameCount);
for (int i = 0; i < nameCount; i++) {
String name = names.get(i);
// Determine the owning user as some profile settings are cloned from the parent.
final int owningUserId = resolveOwningUserIdForSecureSettingLocked(callingUserId, name);
// Special case for location (sigh).
if (isLocationProvidersAllowedRestricted(name, callingUserId, owningUserId)) {
continue;
}
Setting setting = mSettingsRegistry.getSettingLocked(SETTINGS_TYPE_SECURE, owningUserId, name);
appendSettingToCursor(result, setting);
}
return result;
}
}
use of com.android.providers.settings.SettingsState.Setting in project android_frameworks_base by DirtyUnicorns.
the class SettingsProvider method getAllSystemSettings.
private Cursor getAllSystemSettings(int userId, String[] projection) {
if (DEBUG) {
Slog.v(LOG_TAG, "getAllSecureSystem(" + userId + ")");
}
// Resolve the userId on whose behalf the call is made.
final int callingUserId = resolveCallingUserIdEnforcingPermissionsLocked(userId);
synchronized (mLock) {
List<String> names = mSettingsRegistry.getSettingsNamesLocked(SETTINGS_TYPE_SYSTEM, callingUserId);
final int nameCount = names.size();
String[] normalizedProjection = normalizeProjection(projection);
MatrixCursor result = new MatrixCursor(normalizedProjection, nameCount);
for (int i = 0; i < nameCount; i++) {
String name = names.get(i);
// Determine the owning user as some profile settings are cloned from the parent.
final int owningUserId = resolveOwningUserIdForSystemSettingLocked(callingUserId, name);
Setting setting = mSettingsRegistry.getSettingLocked(SETTINGS_TYPE_SYSTEM, owningUserId, name);
appendSettingToCursor(result, setting);
}
return result;
}
}
Aggregations