Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d6c1bdfe authored by Matt Pape's avatar Matt Pape Committed by Android (Google) Code Review
Browse files

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

parents 72401d4f 7b1c6cda
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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);
+2 −2
Original line number Diff line number Diff line
@@ -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 =
+18 −2
Original line number Diff line number Diff line
@@ -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]*");