Employ module controllers

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"
    <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>" />

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.