aconfig: Add exported mode to aconfig Java library generation.
This commit adds a third codegen mode, _exported_, in addition to the existing modes, production and test. When codegen mode is _exported_, getters are generated _only_ for flags marked as exported as well. Also the getters always look up DeviceConfig values at runtime, and have a default value of false. This only implements exported mode for Java codegen, follow-up CLs will support Rust and C++. Test: atest aconfig.test Bug: 311152507 Change-Id: Ie39379b40de072180e05d84c76361b24cc0e0d83
This commit is contained in:
@@ -14,9 +14,17 @@ public final class FeatureFlagsImpl implements FeatureFlags \{
|
||||
{{- endfor- }}
|
||||
|
||||
{{ for flag in flag_elements }}
|
||||
{{ if library_exported }}
|
||||
{{ if flag.exported }}
|
||||
private static boolean {flag.method_name} = false;
|
||||
{{ endif }}
|
||||
|
||||
{{ else }}
|
||||
|
||||
{{- if flag.is_read_write }}
|
||||
private static boolean {flag.method_name} = {flag.default_value};
|
||||
{{- endif- }}
|
||||
{{ endif }}
|
||||
{{ endfor }}
|
||||
|
||||
{{ for namespace_with_flags in namespace_flags }}
|
||||
@@ -25,10 +33,21 @@ public final class FeatureFlagsImpl implements FeatureFlags \{
|
||||
Properties properties = DeviceConfig.getProperties("{namespace_with_flags.namespace}");
|
||||
|
||||
{{- for flag in namespace_with_flags.flags }}
|
||||
{{- if flag.is_read_write }}
|
||||
{{ if library_exported }}
|
||||
|
||||
{{ if flag.exported }}
|
||||
{flag.method_name} =
|
||||
properties.getBoolean("{flag.device_config_flag}", false);
|
||||
{{ endif }}
|
||||
|
||||
{{ else }}
|
||||
|
||||
{{ if flag.is_read_write }}
|
||||
{flag.method_name} =
|
||||
properties.getBoolean("{flag.device_config_flag}", {flag.default_value});
|
||||
{{- endif- }}
|
||||
{{ endif }}
|
||||
|
||||
{{ endif }}
|
||||
{{ endfor }}
|
||||
} catch (NullPointerException e) \{
|
||||
throw new RuntimeException(
|
||||
@@ -46,6 +65,9 @@ public final class FeatureFlagsImpl implements FeatureFlags \{
|
||||
{{ endif- }}
|
||||
|
||||
{{ for flag in flag_elements }}
|
||||
{{ if library_exported }}
|
||||
|
||||
{{ if flag.exported }}
|
||||
@Override
|
||||
@UnsupportedAppUsage
|
||||
public boolean {flag.method_name}() \{
|
||||
@@ -58,6 +80,23 @@ public final class FeatureFlagsImpl implements FeatureFlags \{
|
||||
return {flag.default_value};
|
||||
{{ endif- }}
|
||||
}
|
||||
{{ endif }}
|
||||
|
||||
{{ else }}
|
||||
@Override
|
||||
@UnsupportedAppUsage
|
||||
public boolean {flag.method_name}() \{
|
||||
{{ -if flag.is_read_write }}
|
||||
if (!{flag.device_config_namespace}_is_cached) \{
|
||||
load_overrides_{flag.device_config_namespace}();
|
||||
}
|
||||
return {flag.method_name};
|
||||
{{ else }}
|
||||
return {flag.default_value};
|
||||
{{ endif- }}
|
||||
}
|
||||
{{ endif }}
|
||||
|
||||
{{ endfor }}
|
||||
}
|
||||
{{ else }}
|
||||
|
Reference in New Issue
Block a user