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

Commit 2947145c authored by Linus Tufvesson's avatar Linus Tufvesson
Browse files

Add an exception to setProperties method signature

Bug: 136135417
Test: atest FrameworksCoreTests:DeviceConfigTest
Change-Id: I4c917033925040863aa2d3884ecb4f6e4fae6cbe
parent 2f81e6ea
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -6980,7 +6980,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";
@@ -7012,6 +7012,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
@@ -571,11 +571,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);
@@ -791,6 +793,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.
     *
@@ -927,4 +938,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);