ITargetPreparer

public interface ITargetPreparer
implements IDisableable

com.android.tradefed.targetprep.ITargetPreparer
AdbStopServerPreparer Target preparer to stop adb server on the host before and after running adb tests. 
AllTestAppsInstallSetup A ITargetPreparer that installs all apps from a IDeviceBuildInfo.getTestsDir() folder onto device. 
AoaTargetPreparer ITargetPreparer that executes a series of actions (e.g. clicks and swipes) using the Android Open Accessory (AOAv2) protocol. 
AppSetup A ITargetPreparer that installs an apk and its tests. 
ArtChrootPreparer Create chroot directory for ART tests. 
BaseEmulatorPreparer Common preparer for launching a local emulator. 
BaseTargetPreparer Base implementation class for ITargetPreparer that allows to control whether the object is disabled or not. 
BuildInfoRecorder An ITargetPreparer that writes build info meta data into a specified file. 
CheckPairingPreparer A CompanionAwarePreparer that verifies BT bonding between primary and companion devices 
CompanionAllocator Base class that takes care of allocating and freeing companion device

getCompanionDeviceSelectionOptions() should be implemented to describe the criteria needed to allocate the companion device 

CompanionAwarePreparer An ITargetPreparer that encapsulates the logic of getting an already allocated companion device. 
CompanionRunCommandTargetPreparer A ITargetPreparer that runs specified commands on the allocated companion device 
CompanionTestAppInstallSetup A ITargetPreparer that installs one or more apps from a IDeviceBuildInfo.getTestsDir() folder onto an allocated companion device. 
CompileBootImageWithSpeedTargetPreparer Recompiles the boot classpath and system server with the compiler filter 'speed'. 
CpuThrottlingWaiter An ITargetPreparer that waits until max frequency on all cores are restored to highest level available 
CreateAvdPreparer  
CreateUserPreparer Target preparer for creating user and cleaning it up at the end. 
DeviceActionTargetPreparer A ITargetPreparer to perform device actions. 
DeviceBuildInfoBootStrapper A ITargetPreparer that replaces build info fields with attributes read from device

This is useful for testing devices with builds generated from an external source (e.g. 

DeviceBuildInfoInjector A ITargetPreparer that inserts DeviceBuildDescriptor metadata into the IBuildInfo
DeviceCleaner Performs reboot or format as cleanup action after test, and optionally turns screen off 
DeviceFlashPreparer A ITargetPreparer that flashes an image on physical Android hardware. 
DeviceImageZipFlashingTargetPreparer A target preparer that flashes the device with device images provided via a specific format. 
DeviceOwnerTargetPreparer An ITargetPreparer that sets up a device owner component. 
DeviceSetup A ITargetPreparer that configures a device for testing based on provided Options. 
DeviceStorageFiller Target preparer to fill up storage so some amount of free space is available. 
DeviceStringPusher Target preparer to write a string to a file. 
DeviceUpdateTargetPreparer An abstract ITargetPreparer that takes care of common steps around updating devices with a device image file from an external source (as opposed to a build service). 
DeviceWiper A ITargetPreparer that wipes userdata 
DisableSELinuxTargetPreparer Target preparer that disables SELinux if enabled. 
DynamicSystemPreparer An ITargetPreparer that sets up a system image on top of a device build with the Dynamic System Update. 
EraseUserDataPreparer A ITargetPreparer that wipes user data on the device. 
FastbootCommandPreparer Target preparer that triggers fastboot and sends fastboot commands. 
FastbootUpdateBootstrapPreparer An ITargetPreparer that stages specified files (bootloader, radio, device image zip) into IDeviceBuildInfo to get devices flashed with FastbootDeviceFlasher, then injects post-boot device attributes into the build info for result reporting purposes. 
FeatureFlagTargetPreparer Updates the DeviceConfig (feature flags tuned by a remote service). 
FoldableModePreparer A target preparer that can switch the foldable state of a device. 
FolderSaver A ITargetPreparer that pulls directories off device, compresses and saves it into logging backend. 
GkiDeviceFlashPreparer A target preparer that flash the device with android common kernel generic image. 
GsiDeviceFlashPreparer A target preparer that flashes the device with android generic system image. 
ILabPreparer Marker interface for lab preparers

See ITargetPreparer for a description of what these interfaces are intended. 

ITargetCleaner This interface is deprecated. tearDown has been moved to the base ITargetPreparer interface. 
InstallAllTestZipAppsSetup A ITargetPreparer that installs all apps in a test zip. 
InstallApexModuleTargetPreparer  
InstallApkSetup A ITargetPreparer that installs one or more apks located on the filesystem. 
InstallBuildEnvApkSetup A ITargetPreparer that installs one or more test apks from an Android platform build env. 
InstallKernelModulePreparer A target preparer that install kernel modules. 
InstrumentationPreparer A ITargetPreparer that runs instrumentation 
KillExistingEmulatorPreparer A ITargetPreparer that shuts down a running emulator. 
KnownFailurePreparer Target preparer to skip retrying known failure. 
LocalEmulatorLaunch A TargetPreparer that launches an emulator locally from an android build environment. 
LocalEmulatorSnapshot A TargetPreparer intended for generating a clean emulator snapshot from a android build/development environment 
MixKernelTargetPreparer A ITargetPreparer that allows to mix a kernel image with the device image. 
ModuleOemTargetPreparer  
NativeLeakCollector A ITargetPreparer that runs 'dumpsys meminfo --unreachable -a' to identify the unreachable native memory currently held by each process. 
NoApkTestSkipper Special preparer that allows to skip an invocation completely (preparation and tests) if there are no apks to tests. 
PerfettoPreparer Perfetto preparer pushes the config file in to the device at a standard location to which perfetto have access to. 
ProfileTargetPreparer Base class for setting up target preparer for any profile user android.os.usertype.profile.XXX
PushFileInvoker This class is deprecated. Use PushFilePreparer instead 
PushFilePreparer A ITargetPreparer that attempts to push any number of files from any host path to any device path. 
PythonVirtualenvPreparer Sets up a Python virtualenv on the host and installs packages. 
RebootTargetPreparer Target preparer that reboots the device. 
RecoveryLogPreparer A target preparer used to collect logs before recovery. 
RemoveSystemAppPreparer A ITargetPreparer for removing an apk from the system partition before a test run. 
RestartSystemServerTargetPreparer Target preparer that restarts the system server without rebooting the device. 
RootTargetPreparer Target preparer that performs "adb root" or "adb unroot" based on option "force-root". 
RootcanalForwarderPreparer  
RunCommandTargetPreparer  
RunHostCommandTargetPreparer Target preparer to run arbitrary host commands before and after running the test. 
RunHostScriptTargetPreparer Target preparer which executes a script before running a test. 
RunOnCloneProfileTargetPreparer  
RunOnPrivateProfileTargetPreparer  
RunOnSdkSandboxTargetPreparer An ITargetPreparer to marks that tests should run in the sdk sandbox. 
RunOnSecondaryUserTargetPreparer An ITargetPreparer to ensure that the test runs as a secondary user. 
RunOnSystemUserTargetPreparer An ITargetPreparer that marks that tests should be run on the user (rather than the current user). 
RunOnWorkProfileTargetPreparer An ITargetPreparer that creates a work profile in setup, and marks that tests should be run in that user. 
SemaphoreTokenTargetPreparer This is a preparer used to use token to serialize test excution in tradefed host. 
SideloadOtaTargetPreparer A target preparer that performs sideload of a specified OTA package, applies the package, waits for device to boot up, and injects the device build properties to use as build info

This target preparer assumes that the device will be in regular adb mode when started, and will ensure that the device exits in the same mode but with the newer build applied. 

StopServicesSetup A ITargetPreparer that stops services on the device. 
StubTargetPreparer Placeholder empty implementation of a ITargetPreparer
SuiteApkInstaller Installs specified APKs for Suite configuration: either from $ANDROID_TARGET_OUT_TESTCASES variable or the ROOT_DIR in build info. 
SwitchUserTargetPreparer A ITargetPreparer that switches to the specified user kind in setUp. 
TearDownPassThroughPreparer Allows for running tearDown on preparers that are included in a config as an object. 
TemperatureThrottlingWaiter An ITargetPreparer that waits until device's temperature gets down to target 
TestAppInstallSetup A ITargetPreparer that installs one or more apps from a IDeviceBuildInfo.getTestsDir() folder onto device. 
TestFilePushSetup A ITargetPreparer that pushes one or more files/dirs from a IDeviceBuildInfo.getTestsDir() folder onto device. 
TestSystemAppInstallSetup A ITargetPreparer that installs one or more apps from a IDeviceBuildInfo.getTestsDir() folder onto the /system partition on device. 
TimeWaster A simple target preparer to waste time and potentially restart the device. 
UserCleaner A ITargetPreparer that removes secondary users on teardown. 
VisibleBackgroundUserPreparer Target preparer for running tests in a user that is started in the visible in the background. 
WaitForDeviceDatetimePreparer A ITargetPreparer that waits for datetime to be set on device

Optionally this preparer can force a TargetSetupError if datetime is not set within timeout. 

WifiPreparer A ITargetPreparer that configures wifi on the device if necessary. 


Prepares the test environment for the test run.

For example, installs software, tweaks env settings for testing, launches targets etc.

Note that multiple ITargetPreparers can be specified in a configuration. It is recommended that each ITargetPreparer clearly document its expected environment pre-setup and post-setUp. e.g. a ITargetPreparer that configures a device for testing must be run after the ITargetPreparer that installs software.

Summary

Public methods

default void setUp(ITestDevice device, IBuildInfo buildInfo)

This method is deprecated. Use setUp(com.android.tradefed.invoker.TestInformation) instead

default void setUp(TestInformation testInformation)

Perform the target setup for testing.

default void tearDown(TestInformation testInformation, Throwable e)

Perform the target cleanup/teardown after testing.

default void tearDown(ITestDevice device, IBuildInfo buildInfo, Throwable e)

This method is deprecated. Use tearDown(com.android.tradefed.invoker.TestInformation, Throwable) instead

Public methods

setUp

public void setUp (ITestDevice device, 
                IBuildInfo buildInfo)

This method is deprecated.
Use setUp(com.android.tradefed.invoker.TestInformation) instead

Perform the target setup for testing.

Parameters
device ITestDevice: the ITestDevice to prepare.

buildInfo IBuildInfo: data about the build under test.

Throws
TargetSetupError if fatal error occurred setting up environment
BuildError If an error related to the BuildInfo occurs
DeviceNotAvailableException if device became unresponsive

setUp

public void setUp (TestInformation testInformation)

Perform the target setup for testing.

Parameters
testInformation TestInformation: The TestInformation of the invocation.

Throws
TargetSetupError if fatal error occurred setting up environment
BuildError If an error occurs due to the build being prepared
DeviceNotAvailableException if device became unresponsive

tearDown

public void tearDown (TestInformation testInformation, 
                Throwable e)

Perform the target cleanup/teardown after testing.

Parameters
testInformation TestInformation: The TestInformation of the invocation.

e Throwable: if the invocation ended with an exception, this will be the exception that was caught at the Invocation level. Otherwise, will be null.

Throws
DeviceNotAvailableException if device became unresponsive

tearDown

public void tearDown (ITestDevice device, 
                IBuildInfo buildInfo, 
                Throwable e)

This method is deprecated.
Use tearDown(com.android.tradefed.invoker.TestInformation, Throwable) instead

Perform the target cleanup/teardown after testing.

Parameters
device ITestDevice: the ITestDevice to prepare.

buildInfo IBuildInfo: data about the build under test.

e Throwable: if the invocation ended with an exception, this will be the exception that was caught at the Invocation level. Otherwise, will be null.

Throws
DeviceNotAvailableException if device became unresponsive