name: "RELEASE_MY_FLAG_NAME"
namespace: "android_UNKNOWN"
description: "Control if we should read from new storage."
workflow: LAUNCH
containers: "product"
containers: "system"
containers: "system_ext"
containers: "vendor"
其中:
name 包含标志的名称,前面是 RELEASE_。仅允许使用大写字母和下划线。
namespace 包含贡献的命名空间。您必须与指定的 Google 审核人员合作确定您的命名空间。如果您使用功能发布标志来保持您自己的 AOSP 镜像的稳定性,则可以随意使用命名空间。
value 是标志的初始类型和值。类型可以是 bool_value 或 string_value。如果类型为 string_value,则值必须用引号引起来。如果未指定,则该值为空字符串。布尔值以 true 表示,空字符串表示 false。
[null,null,["最后更新时间 (UTC):2025-04-04。"],[],[],null,["# Declare and use a build flag\n\nBuild flags are build-time constants and can't be changed during runtime. These\nflags are used in circumstances where aconfig flags can't be used, such as\n\n- You have a precompiled or prebuilt piece of code that you want include optionally in a build.\n- You want to make changes to build system itself.\n- You want to put flags around dependencies to manage code size.\n- You want to manage the launch of a feature, but you need to check the value of the flag before aconfig flags are made available by the system.\n\nDeclare a build flag\n--------------------\n\nBuild flags are declared in textproto files. To declare a build flag:\n\n1. Navigate to \u003cvar translate=\"no\"\u003eWORKING_DIRECTORY\u003c/var\u003e`/build/release/flag_declarations/`\n2. Create a file called `RELEASE_`\u003cvar translate=\"no\"\u003eMY_FLAG_NAME\u003c/var\u003e`.textproto`.\n3. Edit the file and add an entry similar to the following:\n\n name: \"RELEASE_MY_FLAG_NAME\"\n namespace: \"android_UNKNOWN\"\n description: \"Control if we should read from new storage.\"\n workflow: LAUNCH\n containers: \"product\"\n containers: \"system\"\n containers: \"system_ext\"\n containers: \"vendor\"\n\n Where:\n - `name` contains the name of the flag preceded by `RELEASE_`. Only uppercase letters and underscore are allowed.\n - `namespace` contains the namespace for contributions. You must work with the assigned Google reviewer to determine your namespace. If you are using feature launch flags to maintain stability of your own AOSP mirror, you can use namespace however you like.\n - `value` is the initial type and value for the flag. The type can be `bool_value` or `string_value`. If type is `string_value` then the value must be in quotes. If not specified, the value is an empty string. Boolean values are represented as either `true` or the empty string for false.\n - `workflow` is either `LAUNCH` or `PREBUILT`. Use `LAUNCH` for boolean flags that advance from `false` to `true`, similar to feature launch flags. Use `PREBUILT` for flags that set a version, typically of a prebuilt.\n - `containers` the type of code you are writing, such as \"vendor\" for vendor code or \"product\" for product code. If you are in doubt of the value to use, use all four containers types as shown in the previous sample.\n\nUse a build flag in a Soong file\n--------------------------------\n\nIn the build file and module where you want to query the flag value, use a\nconditional to branch on the flag value. For example, in the following snippet,\nthe `RELEASE__READ_FROM_NEW_STORAGE` flag's value is queried: \n\n cc_defaults {\n name: \"aconfig_lib_cc_shared_link.defaults\",\n shared_libs: select(release_flag(\"RELEASE_READ_FROM_NEW_STORAGE\"), {\n true: [\"libaconfig_storage_read_api_cc],\n default: [],\n }),\n }\n\nIf this flag's value is `true`, the `libaconfig_storage_read_api_cc` module is\ndynamically linked into the `cc_defaults` module.\n\nIf this flag's value is `false`, nothing (`default: [],`) happens.\n\nUse a build flag in a makefile\n------------------------------\n\nIn the make file, a build flag is a read-only make variable. The following\nmakefile sample accesses a build flag called `RELEASED_PACKAGE_NFC_STCK`: \n\n # NFC and Secure Element packages\n PRODUCT_PACKAGES += \\\n $(RELEASE_PACKAGE_NFC_STACK) \\\n Tag \\\n SecureElement \\\n android.hardware.nfc-service.st \\\n android.hardware.secure_element@1.0-service.st \\\n NfcOverlayCoral\n\nThis flag's declaration has a `workflow` field set to `PREBUILT` in\n[`RELEASE_PACKAGE_NFC_STACK.textproto`](https://cs.android.com/android/platform/superproject/+/android-latest-release:build/release/flag_declarations/RELEASE_PACKAGE_NFC_STACK.textproto?q=%22RELEASE_PACKAGE_NFC_STACK%22&ss=android%2Fplatform%2Fsuperproject%2Fmain)\nand a string value of\n`com.android.nfcservices` [`RELEASE_PACKAGE_NFC_STACK.textproto`](https://cs.android.com/android/platform/superproject/+/android-latest-release:build/release/flag_values/ap3a/RELEASE_PACKAGE_NFC_STACK.textproto)\nthe flag values file for the `trunk_staging` development configuration.\n| **Note:** Flags whose `workflow` field is set to `LAUNCH` should always be compared to an empty string, for example if `flag == true` is written `ifneq (,$(RELEASE_MY_FLAG))` and if `flag == false` is written `ifeq (,$(RELEASE_MY_FLAG))`."]]