• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1package {package_name};
2{{ if not library_exported- }}
3// TODO(b/303773055): Remove the annotation after access issue is resolved.
4import android.compat.annotation.UnsupportedAppUsage;
5{{ else }}
6import android.os.Build;
7{{ -endif }} {#- end not library_exported#}
8{{ -if single_exported_file }}
9{{ -if library_exported }}
10/**
11 * @deprecated Use \{@link ExportedFlags} instead.
12 */
13@Deprecated {#- PREFER ExportedFlags #}
14{{ -endif }}
15{{ -else }}
16/** @hide */
17{{ -endif }}
18public final class Flags \{
19{{ -for item in flag_elements}}
20    /** @hide */
21    public static final String FLAG_{item.flag_name_constant_suffix} = "{item.device_config_flag}";
22{{- endfor }}
23{{ -for item in flag_elements}}
24{{ -if not item.is_read_write }}
25{{ -if item.default_value }}
26    @com.android.aconfig.annotations.AssumeTrueForR8
27{{ -else }}
28    @com.android.aconfig.annotations.AssumeFalseForR8
29{{ -endif }}
30{{ -endif }}
31{{ -if not library_exported }}
32    @com.android.aconfig.annotations.AconfigFlagAccessor
33    @UnsupportedAppUsage
34{{ -endif }}
35    public static boolean {item.method_name}() \{
36        {{ if library_exported- }}
37        {{ -if item.finalized_sdk_present }}
38        if (Build.VERSION.SDK_INT >= {item.finalized_sdk_value}) \{
39          return true;
40        }
41        {{ -endif}}  {#- end finalized_sdk_present#}
42        {{ -endif}}  {#- end library_exported#}
43        return FEATURE_FLAGS.{item.method_name}();
44    }
45{{ -endfor }}
46{{ -if is_test_mode }}
47    public static void setFeatureFlags(FeatureFlags featureFlags) \{
48        Flags.FEATURE_FLAGS = featureFlags;
49    }
50
51    public static void unsetFeatureFlags() \{
52        Flags.FEATURE_FLAGS = null;
53    }
54{{ -endif }}
55
56    private static FeatureFlags FEATURE_FLAGS{{ -if not is_test_mode }} = new FeatureFlagsImpl(){{ -endif- }};
57
58}
59