Google is committed to advancing racial equity for Black communities. See how.

Multi-Target Preparer

Similar to Target Preparer, multi-target preparer allows setup of multiple devices together. For example, this would be used when connecting two devices via Bluetooth for testing.

Base interface

The base interface is IMultiTargetPreparer, which allows implementing a setUp method that will be executed. We recommend implementing our basic abstract class BaseMultiTargetPreparer, which provides a built-in disablement feature to easily disable a preparer.

Multi-target preparers also directly provide a tearDown method for any cleanup operation.

Recommendation

We recommend each preparer be limited to a single main function. This allows for easier re-use of preparers.

You should also check the list of available preparers before adding a new one to avoid duplicating work. Preparers are available in:

tools/tradefederation/core/src/com/android/tradefed/targetprep/multi/

There is no limit to the number of devices that a multi-target preparer can set up. All the devices are available in the IInvocationContext of the interface to implement.

XML configuration

The object tag will be multi_target_preparer, for example:

<multi_target_preparer class="com.android.tradefed.targetprep.multi.HelloWorldMultiTargetPreparer">
</multi_target_preparer>

Operation order

  1. multi_target_preparer executes setUp after target_preparer
  2. multi_target_preparer executes tearDown before target cleaners

This does not always allow performance of all setup steps, so it is possible in theXML to define the multi-target preparer as multi_pre_target_preparer and execute it before target_preparers.

<multi_pre_target_preparer class="com.android.tradefed.targetprep.multi.HelloWorldMultiTargetPreparer">
</multi_pre_target_preparer>

The overall operation order is as followed:

  1. multi_pre_target_preparer(s) setUp
  2. target_preparer(s) setUp
  3. multi_target_preparer(s) setUp
  4. multi_target_preparer(s) tearDown
  5. target_preparer(s) tearDown
  6. multi_pre_target_preparer(s) tearDown

Any multi-target preparer can be declared as multi_target_preparer or multi_pre_target_preparer depending of what order of setup is required.