Flagged APIs are annotated using `@FlaggedApi(Flags.FLAG_NAME)`, where Flags.FLAG_NAME was auto-generated by aconfig. When metalava generates an API signature file, it can either a) insert the value of the constant ("com.foo.bar.flag_name"), or b) insert the name of the constant (FLAG.NAME) In the case of @FlaggedApi, we want a). This requires that x) metlava has access to the definition of the constant while generating the API signature file, and y) the constant is not part of the API surface of the API signature file x) is handled by the build system, y) is handled by the aconfig code generation. This CL @hide:s all generated Java code, to make sure it is accessible within the platform, but never part of any API surface. Bug: 297881670 Test: atest aconfig.test aconfig.test.java Change-Id: I328ed1a652a4e5e293f2f4b11f916d29fc2fbcbd
36 lines
926 B
Plaintext
36 lines
926 B
Plaintext
package {package_name};
|
|
{{ if not is_test_mode }}
|
|
{{ if is_read_write- }}
|
|
import android.provider.DeviceConfig;
|
|
{{ endif }}
|
|
/** @hide */
|
|
public final class FeatureFlagsImpl implements FeatureFlags \{
|
|
{{ for item in class_elements}}
|
|
@Override
|
|
public boolean {item.method_name}() \{
|
|
{{ -if item.is_read_write }}
|
|
return DeviceConfig.getBoolean(
|
|
"{item.device_config_namespace}",
|
|
"{item.device_config_flag}",
|
|
{item.default_value}
|
|
);
|
|
{{ else }}
|
|
return {item.default_value};
|
|
{{ endif- }}
|
|
}
|
|
{{ endfor }}
|
|
}
|
|
{{ else }}
|
|
{#- Generate only stub if in test mode #}
|
|
/** @hide */
|
|
public final class FeatureFlagsImpl implements FeatureFlags \{
|
|
{{ for item in class_elements}}
|
|
@Override
|
|
public boolean {item.method_name}() \{
|
|
throw new UnsupportedOperationException(
|
|
"Method is not implemented.");
|
|
}
|
|
{{ endfor }}
|
|
}
|
|
{{ endif }}
|