Zhi Dou | 4655c96 | 2023-06-12 15:56:03 +0000 | [diff] [blame] | 1 | package {package_name}; |
| 2 | |
Zhi Dou | 22a90f4 | 2023-10-06 07:28:44 +0000 | [diff] [blame] | 3 | // TODO(b/303773055): Remove the annotation after access issue is resolved. |
| 4 | import android.compat.annotation.UnsupportedAppUsage; |
| 5 | |
Mårten Kongstad | 65efa27 | 2023-09-11 12:17:25 +0000 | [diff] [blame] | 6 | /** @hide */ |
Zhi Dou | 4655c96 | 2023-06-12 15:56:03 +0000 | [diff] [blame] | 7 | public final class Flags \{ |
Zhi Dou | 72c2a93 | 2023-10-31 22:57:30 +0000 | [diff] [blame] | 8 | {{- for item in flag_elements}} |
Ted Bauer | 4a6af78 | 2023-11-29 15:44:24 +0000 | [diff] [blame] | 9 | {{ if library_exported }} |
| 10 | {{ if item.exported }} |
Mårten Kongstad | fb10840 | 2023-09-13 10:15:01 +0200 | [diff] [blame] | 11 | /** @hide */ |
Mårten Kongstad | a2e152a | 2023-06-19 16:11:33 +0200 | [diff] [blame] | 12 | public static final String FLAG_{item.flag_name_constant_suffix} = "{item.device_config_flag}"; |
Ted Bauer | 4a6af78 | 2023-11-29 15:44:24 +0000 | [diff] [blame] | 13 | {{ endif }} |
| 14 | {{ else }} |
| 15 | /** @hide */ |
| 16 | public static final String FLAG_{item.flag_name_constant_suffix} = "{item.device_config_flag}"; |
| 17 | {{ endif }} |
Zhi Dou | a41cc5e | 2023-06-29 15:01:56 +0000 | [diff] [blame] | 18 | {{- endfor }} |
Zhi Dou | 72c2a93 | 2023-10-31 22:57:30 +0000 | [diff] [blame] | 19 | {{ for item in flag_elements}} |
Ted Bauer | 4a6af78 | 2023-11-29 15:44:24 +0000 | [diff] [blame] | 20 | {{ if library_exported }} |
| 21 | |
| 22 | {{ if item.exported }} |
| 23 | @UnsupportedAppUsage |
| 24 | public static boolean {item.method_name}() \{ |
| 25 | return FEATURE_FLAGS.{item.method_name}(); |
| 26 | } |
| 27 | {{ endif }} |
| 28 | |
| 29 | {{ else }} |
| 30 | |
Zhi Dou | deafa79 | 2023-09-05 18:22:46 +0000 | [diff] [blame] | 31 | {{ -if not item.is_read_write }} |
| 32 | {{ -if item.default_value }} |
| 33 | @com.android.aconfig.annotations.AssumeTrueForR8 |
| 34 | {{ -else }} |
| 35 | @com.android.aconfig.annotations.AssumeFalseForR8 |
| 36 | {{ -endif- }} |
| 37 | {{ endif }} |
Zhi Dou | 22a90f4 | 2023-10-06 07:28:44 +0000 | [diff] [blame] | 38 | @UnsupportedAppUsage |
Zhi Dou | 4655c96 | 2023-06-12 15:56:03 +0000 | [diff] [blame] | 39 | public static boolean {item.method_name}() \{ |
| 40 | return FEATURE_FLAGS.{item.method_name}(); |
| 41 | } |
Ted Bauer | 4a6af78 | 2023-11-29 15:44:24 +0000 | [diff] [blame] | 42 | {{ endif }} |
Zhi Dou | a41cc5e | 2023-06-29 15:01:56 +0000 | [diff] [blame] | 43 | {{ endfor }} |
| 44 | {{ -if is_test_mode }} |
Zhi Dou | 5aaeee3 | 2023-08-07 22:54:13 +0000 | [diff] [blame] | 45 | public static void setFeatureFlags(FeatureFlags featureFlags) \{ |
Zhi Dou | 8ba6aa7 | 2023-06-26 21:03:40 +0000 | [diff] [blame] | 46 | Flags.FEATURE_FLAGS = featureFlags; |
| 47 | } |
| 48 | |
Zhi Dou | 5aaeee3 | 2023-08-07 22:54:13 +0000 | [diff] [blame] | 49 | public static void unsetFeatureFlags() \{ |
Zhi Dou | 8ba6aa7 | 2023-06-26 21:03:40 +0000 | [diff] [blame] | 50 | Flags.FEATURE_FLAGS = null; |
| 51 | } |
Zhi Dou | deafa79 | 2023-09-05 18:22:46 +0000 | [diff] [blame] | 52 | {{ endif }} |
Zhi Dou | 8ba6aa7 | 2023-06-26 21:03:40 +0000 | [diff] [blame] | 53 | private static FeatureFlags FEATURE_FLAGS{{ -if not is_test_mode }} = new FeatureFlagsImpl(){{ -endif- }}; |
Zhi Dou | 4655c96 | 2023-06-12 15:56:03 +0000 | [diff] [blame] | 54 | |
| 55 | } |