aconfig: flag java lib enable optimization

This change adds annotation in the generated code. If the flag is read
only, annotations @com.android.aconfig.annotations.AssumeTrueForR8 or
@com.android.aconfig.annotations.AssumeFalseForR8 will be added in to
the corresponding methods in the interface FeatureFlags, and class
Flags.

Test: atest aconfig aconfig.test.java
Bug: 295328116
Change-Id: Ic1b62a86f0945a5e72ae2c4987cce77fe3f172e9
This commit is contained in:
Zhi Dou
2023-09-05 18:22:46 +00:00
parent 6c4627369e
commit deafa792eb
3 changed files with 21 additions and 1 deletions

View File

@@ -5,6 +5,13 @@ public final class Flags \{
public static final String FLAG_{item.flag_name_constant_suffix} = "{item.device_config_flag}";
{{- endfor }}
{{ for item in class_elements}}
{{ -if not item.is_read_write }}
{{ -if item.default_value }}
@com.android.aconfig.annotations.AssumeTrueForR8
{{ -else }}
@com.android.aconfig.annotations.AssumeFalseForR8
{{ -endif- }}
{{ endif }}
public static boolean {item.method_name}() \{
return FEATURE_FLAGS.{item.method_name}();
}
@@ -17,7 +24,7 @@ public final class Flags \{
public static void unsetFeatureFlags() \{
Flags.FEATURE_FLAGS = null;
}
{{ endif}}
{{ endif }}
private static FeatureFlags FEATURE_FLAGS{{ -if not is_test_mode }} = new FeatureFlagsImpl(){{ -endif- }};
}