Merge "Update DeviceConfigService to pass Settings.AUTHORITY to IContentProvider.call invocations."

This commit is contained in:
Matt Pape
2019-01-04 17:46:09 +00:00
committed by Android (Google) Code Review
3 changed files with 21 additions and 6 deletions

View File

@@ -14075,11 +14075,10 @@ public final class Settings {
try {
Bundle arg = new Bundle();
arg.putInt(CALL_METHOD_USER_KEY, resolver.getUserId());
arg.putInt(Settings.CALL_METHOD_RESET_MODE_KEY, resetMode);
arg.putInt(CALL_METHOD_RESET_MODE_KEY, resetMode);
if (prefix != null) {
arg.putString(Settings.CALL_METHOD_PREFIX_KEY, prefix);
}
arg.putInt(CALL_METHOD_RESET_MODE_KEY, resetMode);
IContentProvider cp = sProviderHolder.getProvider(resolver);
cp.call(resolver.getPackageName(), sProviderHolder.mUri.getAuthority(),
CALL_METHOD_RESET_CONFIG, null, arg);

View File

@@ -242,7 +242,7 @@ public final class DeviceConfigService extends Binder {
Bundle args = new Bundle();
args.putInt(Settings.CALL_METHOD_USER_KEY,
ActivityManager.getService().getCurrentUser().id);
Bundle b = provider.call(resolveCallingPackage(),
Bundle b = provider.call(resolveCallingPackage(), Settings.AUTHORITY,
Settings.CALL_METHOD_DELETE_CONFIG, compositeKey, args);
success = (b != null && b.getInt(SettingsProvider.RESULT_ROWS_DELETED) == 1);
} catch (RemoteException e) {
@@ -261,7 +261,7 @@ public final class DeviceConfigService extends Binder {
if (namespace != null) {
args.putString(Settings.CALL_METHOD_PREFIX_KEY, namespace);
}
Bundle b = provider.call(resolveCallingPackage(),
Bundle b = provider.call(resolveCallingPackage(), Settings.AUTHORITY,
Settings.CALL_METHOD_LIST_CONFIG, null, args);
if (b != null) {
Map<String, String> flagsToValues =

View File

@@ -1097,7 +1097,7 @@ public class SettingsProvider extends ContentProvider {
case MUTATION_OPERATION_INSERT: {
return mSettingsRegistry.insertSettingLocked(SETTINGS_TYPE_CONFIG,
UserHandle.USER_SYSTEM, name, value, null, makeDefault, true,
getCallingPackage(), false, null);
resolveCallingPackage(), false, null);
}
case MUTATION_OPERATION_DELETE: {
@@ -1107,7 +1107,7 @@ public class SettingsProvider extends ContentProvider {
case MUTATION_OPERATION_RESET: {
mSettingsRegistry.resetSettingsLocked(SETTINGS_TYPE_CONFIG,
UserHandle.USER_SYSTEM, getCallingPackage(), mode, null, prefix);
UserHandle.USER_SYSTEM, resolveCallingPackage(), mode, null, prefix);
} return true;
}
}
@@ -2247,6 +2247,22 @@ public class SettingsProvider extends ContentProvider {
return !(TextUtils.isEmpty(key) || SettingsState.isBinary(key));
}
private String resolveCallingPackage() {
switch (Binder.getCallingUid()) {
case Process.ROOT_UID: {
return "root";
}
case Process.SHELL_UID: {
return "com.android.shell";
}
default: {
return getCallingPackage();
}
}
}
private static final class Arguments {
private static final Pattern WHERE_PATTERN_WITH_PARAM_NO_BRACKETS =
Pattern.compile("[\\s]*name[\\s]*=[\\s]*\\?[\\s]*");