When adding code into AOSP, use feature launch flags to isolate untested code from tested code. Enable feature launch flags to execute and test your code. Conversely, disable feature launch flags to ensure untested code doesn't execute.
Feature launch flags are used primarily in these two ways:
- If you're contributing to AOSP, ensure your code uses feature launch flags so that it can be enabled or disabled as needed by Google to test your code and keep the external development branch stable. For further information on branches, see Release lifecycle.
- Google uses feature launch flags to ensure the external development branch (main) and release branch are stable for everyone. If your company keeps a mirror of AOSP and works from that mirror, use feature launch flagging to keep your mirror of AOSP code stable for your development team.
The high-level steps for implementing feature launch flagging are:
- For a given code change, determine if you need a flag and, if so, determine the flag type.
- Declare the flag.
- Wrap your code change in the flag.
- Set the flag's value.
- Build and test your code.
- Change flag values at runtime.
- Test code that uses feature release flags
The pages in this section teach you how to perform each of these steps.