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。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],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))`."]]