Starting March 27, 2025, we recommend using android-latest-release
instead of aosp-main
to build and contribute to AOSP. For more information, see Changes to AOSP.
Employ module controllers
Stay organized with collections
Save and categorize content based on your preferences.
Each suite module (defined by AndroidTest.xml
) can contain a special
module_controller
object that can alter some behavior of the module:
Whether to run the module or not based on some conditions
By implementing BaseModuleController
and adding it to the AndroidTest.xml
like this:
<object type="module_controller" class="com.android.tradefed.testtype.suite.module.<NAME>" />
The module controller will be used to determine whether the module should run
or not, based on the
public abstract RunStrategy shouldRun(IInvocationContext context);
implementation.
Whether to collect some logs or not on failures
When running a full suite, it's possible to request at the suite level the
collection of some logs on failures (screenshot, bugreport, logcat). But for
some modules, a particular log requested might not have any value and will
simply waste time to be collected. In that situation, a module can explicitly
specify which logs they are interested in:
<object type="module_controller"
class="com.android.tradefed.testtype.suite.module.TestFailureModuleController">
<option name="screenshot-on-failure" value="<true OR false>" />
<option name="bugreportz-on-failure" value="<true OR false>" />
<option name="logcat-on-failure" value="<true OR false>" />
</object>
NOTE: Implementation of controllers should be generic if possible in order to
maximize re-usability. And skipping a module based on its condition should
be reviewed by the module owner to get the approval that skipping a module is
the proper behavior for them.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-06-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-18 UTC."],[],[],null,["# Employ module controllers\n\nEach suite module (defined by `AndroidTest.xml`) can contain a special\n`module_controller` object that can alter some behavior of the module:\n\nWhether to run the module or not based on some conditions\n---------------------------------------------------------\n\nBy implementing [BaseModuleController](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/src/com/android/tradefed/testtype/suite/module/BaseModuleController.java)\nand adding it to the `AndroidTest.xml` like this: \n\n \u003cobject type=\"module_controller\" class=\"com.android.tradefed.testtype.suite.module.\u003cNAME\u003e\" /\u003e\n\nThe module controller will be used to determine whether the module should run\nor not, based on the\n`public abstract RunStrategy shouldRun(IInvocationContext context);`\nimplementation.\n\nWhether to collect some logs or not on failures\n-----------------------------------------------\n\nWhen running a full suite, it's possible to request at the suite level the\ncollection of some logs on failures (screenshot, bugreport, logcat). But for\nsome modules, a particular log requested might not have any value and will\nsimply waste time to be collected. In that situation, a module can explicitly\nspecify which logs they are interested in: \n\n \u003cobject type=\"module_controller\"\n class=\"com.android.tradefed.testtype.suite.module.TestFailureModuleController\"\u003e\n \u003coption name=\"screenshot-on-failure\" value=\"\u003ctrue OR false\u003e\" /\u003e\n \u003coption name=\"bugreportz-on-failure\" value=\"\u003ctrue OR false\u003e\" /\u003e\n \u003coption name=\"logcat-on-failure\" value=\"\u003ctrue OR false\u003e\" /\u003e\n \u003c/object\u003e\n\nNOTE: Implementation of controllers should be generic if possible in order to\nmaximize re-usability. And skipping a module based on its condition should\nbe reviewed by the module owner to get the approval that skipping a module is\nthe proper behavior for them."]]