aconfig: cache flag value in generated java code
This change add cache in generated jave code to improve the performance.
The cache is a DeviceConfig.Properties. One Properties contains all
flag values from the given namesapce.
The Properties for a given namespace is initialized as null, and the
first call for any flags in that Properties will trigger the call to
fetch all the values. After the first call, the flag values are stored
in the Properties, so the following calls will directly get the value
from the Properties instead from the backup storage.
Test: atest aconfig.test.java
Bug: 307511846
Change-Id: Ic43626101c28099199b6faa419cf1945bd53b15d
diff --git a/tools/aconfig/templates/Flags.java.template b/tools/aconfig/templates/Flags.java.template
index 66c4c5a..cf6604c 100644
--- a/tools/aconfig/templates/Flags.java.template
+++ b/tools/aconfig/templates/Flags.java.template
@@ -5,11 +5,11 @@
/** @hide */
public final class Flags \{
-{{- for item in class_elements}}
+{{- for item in flag_elements}}
/** @hide */
public static final String FLAG_{item.flag_name_constant_suffix} = "{item.device_config_flag}";
{{- endfor }}
-{{ for item in class_elements}}
+{{ for item in flag_elements}}
{{ -if not item.is_read_write }}
{{ -if item.default_value }}
@com.android.aconfig.annotations.AssumeTrueForR8