summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jared Duke <jdduke@google.com> 2023-11-15 21:12:36 +0000
committer Jared Duke <jdduke@google.com> 2024-07-02 22:51:05 +0000
commit1b6d14296e69179258fc4feb3b8a3011d24bd60b (patch)
tree7d44184e282911f897b4cd0dfe3780c4bb5f93a7
parentb95116177363452107e7f13f3ea39c5212a531ee (diff)
Reuse Java flag name constants in FeatureFlagsImpl
This may not matter in practice due to string inlining and interning, but might avoid any accidental name drift/bugs in the future. Bug: 280833463 Test: atest aconfig.test Change-Id: I53b5b3effb577493ba708800928553c04b2fdc54
-rw-r--r--tools/aconfig/aconfig/src/codegen/java.rs14
-rw-r--r--tools/aconfig/aconfig/templates/FeatureFlagsImpl.java.template2
2 files changed, 8 insertions, 8 deletions
diff --git a/tools/aconfig/aconfig/src/codegen/java.rs b/tools/aconfig/aconfig/src/codegen/java.rs
index 9abc892908..a53788147b 100644
--- a/tools/aconfig/aconfig/src/codegen/java.rs
+++ b/tools/aconfig/aconfig/src/codegen/java.rs
@@ -496,11 +496,11 @@ mod tests {
try {
Properties properties = DeviceConfig.getProperties("aconfig_test");
disabledRw =
- properties.getBoolean("com.android.aconfig.test.disabled_rw", false);
+ properties.getBoolean(Flags.FLAG_DISABLED_RW, false);
disabledRwExported =
- properties.getBoolean("com.android.aconfig.test.disabled_rw_exported", false);
+ properties.getBoolean(Flags.FLAG_DISABLED_RW_EXPORTED, false);
enabledRw =
- properties.getBoolean("com.android.aconfig.test.enabled_rw", true);
+ properties.getBoolean(Flags.FLAG_ENABLED_RW, true);
} catch (NullPointerException e) {
throw new RuntimeException(
"Cannot read value from namespace aconfig_test "
@@ -518,7 +518,7 @@ mod tests {
try {
Properties properties = DeviceConfig.getProperties("other_namespace");
disabledRwInOtherNamespace =
- properties.getBoolean("com.android.aconfig.test.disabled_rw_in_other_namespace", false);
+ properties.getBoolean(Flags.FLAG_DISABLED_RW_IN_OTHER_NAMESPACE, false);
} catch (NullPointerException e) {
throw new RuntimeException(
"Cannot read value from namespace other_namespace "
@@ -691,11 +691,11 @@ mod tests {
try {
Properties properties = DeviceConfig.getProperties("aconfig_test");
disabledRwExported =
- properties.getBoolean("com.android.aconfig.test.disabled_rw_exported", false);
+ properties.getBoolean(Flags.FLAG_DISABLED_RW_EXPORTED, false);
enabledFixedRoExported =
- properties.getBoolean("com.android.aconfig.test.enabled_fixed_ro_exported", false);
+ properties.getBoolean(Flags.FLAG_ENABLED_FIXED_RO_EXPORTED, false);
enabledRoExported =
- properties.getBoolean("com.android.aconfig.test.enabled_ro_exported", false);
+ properties.getBoolean(Flags.FLAG_ENABLED_RO_EXPORTED, false);
} catch (NullPointerException e) {
throw new RuntimeException(
"Cannot read value from namespace aconfig_test "
diff --git a/tools/aconfig/aconfig/templates/FeatureFlagsImpl.java.template b/tools/aconfig/aconfig/templates/FeatureFlagsImpl.java.template
index 6235e6946c..63c4f2de72 100644
--- a/tools/aconfig/aconfig/templates/FeatureFlagsImpl.java.template
+++ b/tools/aconfig/aconfig/templates/FeatureFlagsImpl.java.template
@@ -27,7 +27,7 @@ public final class FeatureFlagsImpl implements FeatureFlags \{
{{ -for flag in namespace_with_flags.flags }}
{{ -if flag.is_read_write }}
{flag.method_name} =
- properties.getBoolean("{flag.device_config_flag}", {flag.default_value});
+ properties.getBoolean(Flags.FLAG_{flag.flag_name_constant_suffix}, {flag.default_value});
{{ -endif }}
{{ -endfor }}
} catch (NullPointerException e) \{