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.
Device allocation in Tradefed
Stay organized with collections
Save and categorize content based on your preferences.
When starting a test (for example, an instrumentation test), it might need a
device to be able to run properly. Or the test (such as some Java unit tests)
might not need a device at all. Still others or might even need multi-devices
(like phone + watch tests). In all those cases, the Device Manager is
responsible for allocating the required devices to the test so it runs
properly. We call this phase the device allocation or device selection step.
The allocation is driven by
DeviceSelectionOptions
that allow a test to declare any properties it needs from a device, including:
- Battery level
- Device type
- Product type
- Serial number
Use real devices
This is the default setting that will be allocated to all tests that don't
specify any device properties. A physical random device marked
AVAILABLE
will be picked and assigned to the test.
Use no devices
When no devices are needed by the test, it can specify --null-device
or -n
on its command line, or <option name="null-device" value="true" />
in its
configuration XML. This allocates a stub placeholder NullDevice that
represents no device was allocated.
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-08-29 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-08-29 UTC."],[],[],null,["# Device allocation in Tradefed\n\nWhen starting a test (for example, an instrumentation test), it might need a\ndevice to be able to run properly. Or the test (such as some Java unit tests)\nmight not need a device at all. Still others or might even need multi-devices\n(like phone + watch tests). In all those cases, the Device Manager is\nresponsible for allocating the required devices to the test so it runs\nproperly. We call this phase the *device allocation* or *device selection* step.\n\nThe allocation is driven by\n[DeviceSelectionOptions](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/src/com/android/tradefed/device/DeviceSelectionOptions.java)\nthat allow a test to declare any properties it needs from a device, including:\n\n- Battery level\n- Device type\n- Product type\n- Serial number\n\nUse real devices\n----------------\n\nThis is the default setting that will be allocated to all tests that don't\nspecify any device properties. A physical random device marked\n[AVAILABLE](/docs/core/tests/tradefed/architecture/device-manager#allocation_states)\nwill be picked and assigned to the test.\n\nUse no devices\n--------------\n\nWhen no devices are needed by the test, it can specify `--null-device` or `-n`\non its command line, or `\u003coption name=\"null-device\" value=\"true\" /\u003e` in its\nconfiguration XML. This allocates a stub placeholder NullDevice that\nrepresents no device was allocated."]]