diff --git a/tools/aconfig/src/codegen_java.rs b/tools/aconfig/src/codegen_java.rs index 0d1b281696..47516b76c9 100644 --- a/tools/aconfig/src/codegen_java.rs +++ b/tools/aconfig/src/codegen_java.rs @@ -66,6 +66,7 @@ struct ClassElement { pub default_value: String, pub device_config_namespace: String, pub device_config_flag: String, + pub flag_name_constant_suffix: String, pub is_read_write: bool, pub method_name: String, } @@ -81,6 +82,7 @@ fn create_class_element(package: &str, pf: &ProtoParsedFlag) -> ClassElement { }, device_config_namespace: pf.namespace().to_string(), device_config_flag, + flag_name_constant_suffix: pf.name().to_ascii_uppercase(), is_read_write: pf.permission() == ProtoFlagPermission::READ_WRITE, method_name: format_java_method_name(pf.name()), } @@ -115,6 +117,11 @@ mod tests { let expect_flags_content = r#" package com.android.aconfig.test; public final class Flags { + public static final String FLAG_DISABLED_RO = "com.android.aconfig.test.disabled_ro"; + public static final String FLAG_DISABLED_RW = "com.android.aconfig.test.disabled_rw"; + public static final String FLAG_ENABLED_RO = "com.android.aconfig.test.enabled_ro"; + public static final String FLAG_ENABLED_RW = "com.android.aconfig.test.enabled_rw"; + public static boolean disabledRo() { return FEATURE_FLAGS.disabledRo(); } diff --git a/tools/aconfig/templates/Flags.java.template b/tools/aconfig/templates/Flags.java.template index 752a469afb..62116c59e2 100644 --- a/tools/aconfig/templates/Flags.java.template +++ b/tools/aconfig/templates/Flags.java.template @@ -1,6 +1,9 @@ package {package_name}; public final class Flags \{ + {{- for item in class_elements}} + public static final String FLAG_{item.flag_name_constant_suffix} = "{item.device_config_flag}"; + {{- endfor }} {{ for item in class_elements}} public static boolean {item.method_name}() \{ return FEATURE_FLAGS.{item.method_name}();