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

Commit 4a0dbe94 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add an exception to setProperties method signature"

parents 6137064d 2947145c
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -7060,7 +7060,7 @@ package android.provider {
    method @RequiresPermission(android.Manifest.permission.READ_DEVICE_CONFIG) public static String getString(@NonNull String, @NonNull String, @Nullable String);
    method public static void removeOnPropertiesChangedListener(@NonNull android.provider.DeviceConfig.OnPropertiesChangedListener);
    method @RequiresPermission(android.Manifest.permission.WRITE_DEVICE_CONFIG) public static void resetToDefaults(int, @Nullable String);
    method @RequiresPermission(android.Manifest.permission.WRITE_DEVICE_CONFIG) public static boolean setProperties(@NonNull android.provider.DeviceConfig.Properties);
    method @RequiresPermission(android.Manifest.permission.WRITE_DEVICE_CONFIG) public static boolean setProperties(@NonNull android.provider.DeviceConfig.Properties) throws android.provider.DeviceConfig.BadConfigException;
    method @RequiresPermission(android.Manifest.permission.WRITE_DEVICE_CONFIG) public static boolean setProperty(@NonNull String, @NonNull String, @Nullable String, boolean);
    field public static final String NAMESPACE_ACTIVITY_MANAGER = "activity_manager";
    field public static final String NAMESPACE_ACTIVITY_MANAGER_NATIVE_BOOT = "activity_manager_native_boot";
@@ -7092,6 +7092,10 @@ package android.provider {
    field public static final String NAMESPACE_TEXTCLASSIFIER = "textclassifier";
  }
  public static class DeviceConfig.BadConfigException extends java.lang.Exception {
    ctor public DeviceConfig.BadConfigException();
  }
  public static interface DeviceConfig.OnPropertiesChangedListener {
    method public void onPropertiesChanged(@NonNull android.provider.DeviceConfig.Properties);
  }
+13 −1
Original line number Diff line number Diff line
@@ -578,11 +578,13 @@ public final class DeviceConfig {
     * none or all of this update is picked up, but never only part of it.
     *
     * @param properties the complete set of properties to set for a specific namespace.
     * @throws BadConfigException if the provided properties are banned by RescueParty.
     * @return True if the values were set, false otherwise.
     * @hide
     */
    @SystemApi
    @RequiresPermission(WRITE_DEVICE_CONFIG)
    public static boolean setProperties(@NonNull Properties properties) {
    public static boolean setProperties(@NonNull Properties properties) throws BadConfigException {
        ContentResolver contentResolver = ActivityThread.currentApplication().getContentResolver();
        return Settings.Config.setStrings(contentResolver, properties.getNamespace(),
                properties.mMap);
@@ -798,6 +800,15 @@ public final class DeviceConfig {
        void onPropertiesChanged(@NonNull Properties properties);
    }

    /**
     * Thrown by {@link #setProperties(Properties)} when a configuration is rejected. This
     * happens if RescueParty has identified a bad configuration and reset the namespace.
     *
     * @hide
     */
    @SystemApi
    public static class BadConfigException extends Exception {}

    /**
     * A mapping of properties to values, as well as a single namespace which they all belong to.
     *
@@ -934,4 +945,5 @@ public final class DeviceConfig {
            }
        }
    }

}
+2 −2
Original line number Diff line number Diff line
@@ -488,7 +488,7 @@ public class DeviceConfigTest {
    }

    @Test
    public void setProperties() {
    public void setProperties() throws DeviceConfig.BadConfigException {
        Map<String, String> keyValues = new HashMap<>();
        keyValues.put(KEY, VALUE);
        keyValues.put(KEY2, VALUE2);
@@ -514,7 +514,7 @@ public class DeviceConfigTest {
    }

    @Test
    public void setProperties_multipleNamespaces() {
    public void setProperties_multipleNamespaces() throws DeviceConfig.BadConfigException {
        Map<String, String> keyValues = new HashMap<>();
        keyValues.put(KEY, VALUE);
        keyValues.put(KEY2, VALUE2);