Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 379e09d1 authored by Mårten Kongstad's avatar Mårten Kongstad
Browse files

aconfig: @hide generated Java code

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
parent 7d63a846
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ mod tests {

    const EXPECTED_FEATUREFLAGS_COMMON_CONTENT: &str = r#"
    package com.android.aconfig.test;
    /** @hide */
    public interface FeatureFlags {
        @com.android.aconfig.annotations.AssumeFalseForR8
        boolean disabledRo();
@@ -132,6 +133,7 @@ mod tests {

    const EXPECTED_FLAG_COMMON_CONTENT: &str = r#"
    package com.android.aconfig.test;
    /** @hide */
    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";
@@ -163,6 +165,7 @@ mod tests {
    package com.android.aconfig.test;
    import java.util.HashMap;
    import java.util.Map;
    /** @hide */
    public class FakeFeatureFlagsImpl implements FeatureFlags {
        public FakeFeatureFlagsImpl() {
            resetAll();
@@ -234,6 +237,7 @@ mod tests {
        let expect_featureflagsimpl_content = r#"
        package com.android.aconfig.test;
        import android.provider.DeviceConfig;
        /** @hide */
        public final class FeatureFlagsImpl implements FeatureFlags {
            @Override
            public boolean disabledRo() {
@@ -316,6 +320,7 @@ mod tests {
        "#;
        let expect_featureflagsimpl_content = r#"
        package com.android.aconfig.test;
        /** @hide */
        public final class FeatureFlagsImpl implements FeatureFlags {
            @Override
            public boolean disabledRo() {
+1 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ package {package_name};
import java.util.HashMap;
import java.util.Map;

/** @hide */
public class FakeFeatureFlagsImpl implements FeatureFlags \{
    public FakeFeatureFlagsImpl() \{
        resetAll();
+1 −0
Original line number Diff line number Diff line
package {package_name};

/** @hide */
public interface FeatureFlags \{
{{ for item in class_elements}}
{{ -if not item.is_read_write }}
+2 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@ package {package_name};
{{ if is_read_write- }}
import android.provider.DeviceConfig;
{{ endif }}
/** @hide */
public final class FeatureFlagsImpl implements FeatureFlags \{
{{ for item in class_elements}}
    @Override
@@ -21,6 +22,7 @@ public final class FeatureFlagsImpl implements FeatureFlags \{
}
{{ else }}
{#- Generate only stub if in test mode #}
/** @hide */
public final class FeatureFlagsImpl implements FeatureFlags \{
{{ for item in class_elements}}
    @Override
+1 −0
Original line number Diff line number Diff line
package {package_name};

/** @hide */
public final class Flags \{
{{- for item in class_elements}}
    public static final String FLAG_{item.flag_name_constant_suffix} = "{item.device_config_flag}";