diff options
author | 2024-09-25 00:43:28 +0000 | |
---|---|---|
committer | 2024-09-26 22:59:51 +0000 | |
commit | 5e13e25d51685f4cf1ae4c9188ae19577538c6f7 (patch) | |
tree | bc8bf33dad91ab85b2dbe311a1dedea7542ac4f6 /ravenwood/junit-src | |
parent | 983461633b96db0bc58205a657edeffad3ce4080 (diff) |
[Ravenwood] Use native system property implementation
System properties are not only used by Java code, but also native code.
To make the property values consistent across Java and native code, make
the "source of truth" of property values on the native side.
In order to achieve this, we have to introduce a new native library
"libravenwood_sysprops" that does NOT link against libbase, and load
that library first. By doing so, we can override the low-level sysprop
function symbols with our own implementation.
Once that is done, all existing native code accessing system properties,
regardless whether they use the libbase/libcutils wrappers or the raw
sysprop functions will go through Ravenwood's implementation.
Other than improving system properties, this provides the infrastructure
to override/implement C functions that is used in native code.
Bug: 292141694
Flag: EXEMPT host test change only
Test: $ANDROID_BUILD_TOP/frameworks/base/ravenwood/scripts/run-ravenwood-tests.sh
Merged-in: I14678e2ac52ace0b23bd53df7b6092a1cbb881b3
Change-Id: I14678e2ac52ace0b23bd53df7b6092a1cbb881b3
Diffstat (limited to 'ravenwood/junit-src')
-rw-r--r-- | ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodSystemProperties.java | 82 |
1 files changed, 38 insertions, 44 deletions
diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodSystemProperties.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodSystemProperties.java index ef8f5840f949..f1e1ef672871 100644 --- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodSystemProperties.java +++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodSystemProperties.java @@ -22,7 +22,6 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; -import java.util.function.Predicate; public class RavenwoodSystemProperties { private volatile boolean mIsImmutable; @@ -31,47 +30,9 @@ public class RavenwoodSystemProperties { /** Set of additional keys that should be considered readable */ private final Set<String> mKeyReadable = new HashSet<>(); - private final Predicate<String> mKeyReadablePredicate = (key) -> { - final String root = getKeyRoot(key); - - if (root.startsWith("debug.")) return true; - - // This set is carefully curated to help identify situations where a test may - // accidentally depend on a default value of an obscure property whose owner hasn't - // decided how Ravenwood should behave. - if (root.startsWith("boot.")) return true; - if (root.startsWith("build.")) return true; - if (root.startsWith("product.")) return true; - if (root.startsWith("soc.")) return true; - if (root.startsWith("system.")) return true; - - switch (key) { - case "gsm.version.baseband": - case "no.such.thing": - case "qemu.sf.lcd_density": - case "ro.bootloader": - case "ro.debuggable": - case "ro.hardware": - case "ro.hw_timeout_multiplier": - case "ro.odm.build.media_performance_class": - case "ro.sf.lcd_density": - case "ro.treble.enabled": - case "ro.vndk.version": - return true; - } - - return mKeyReadable.contains(key); - }; /** Set of additional keys that should be considered writable */ private final Set<String> mKeyWritable = new HashSet<>(); - private final Predicate<String> mKeyWritablePredicate = (key) -> { - final String root = getKeyRoot(key); - - if (root.startsWith("debug.")) return true; - - return mKeyWritable.contains(key); - }; public RavenwoodSystemProperties() { // TODO: load these values from build.prop generated files @@ -121,12 +82,45 @@ public class RavenwoodSystemProperties { return new HashMap<>(mValues); } - public Predicate<String> getKeyReadablePredicate() { - return mKeyReadablePredicate; + public boolean isKeyReadable(String key) { + final String root = getKeyRoot(key); + + if (root.startsWith("debug.")) return true; + + // This set is carefully curated to help identify situations where a test may + // accidentally depend on a default value of an obscure property whose owner hasn't + // decided how Ravenwood should behave. + if (root.startsWith("boot.")) return true; + if (root.startsWith("build.")) return true; + if (root.startsWith("product.")) return true; + if (root.startsWith("soc.")) return true; + if (root.startsWith("system.")) return true; + + switch (key) { + case "gsm.version.baseband": + case "no.such.thing": + case "qemu.sf.lcd_density": + case "ro.bootloader": + case "ro.debuggable": + case "ro.hardware": + case "ro.hw_timeout_multiplier": + case "ro.odm.build.media_performance_class": + case "ro.sf.lcd_density": + case "ro.treble.enabled": + case "ro.vndk.version": + case "ro.icu.data.path": + return true; + } + + return mKeyReadable.contains(key); } - public Predicate<String> getKeyWritablePredicate() { - return mKeyWritablePredicate; + public boolean isKeyWritable(String key) { + final String root = getKeyRoot(key); + + if (root.startsWith("debug.")) return true; + + return mKeyWritable.contains(key); } private static final String[] PARTITIONS = { @@ -208,4 +202,4 @@ public class RavenwoodSystemProperties { // Create a default instance, and make an immutable copy of it. public static final RavenwoodSystemProperties DEFAULT_VALUES = new RavenwoodSystemProperties(new RavenwoodSystemProperties(), true); -}
\ No newline at end of file +} |