自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
Tradefed 中的裝置狀態
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
部 Android 裝置
Tradefed 中的 Android 裝置可透過裝置管理工具,經歷多個狀態。Android 裝置的狀態主要分為兩類:配置狀態和線上狀態。
您可以使用 l d
或 list devices
,在 Tradefed 控制台中檢查所有這些狀態。
tf >l d
Serial State Allocation Product Variant Build Battery
84TX0081B ONLINE Available blueline blueline MASTER 100
HT6550300002 ONLINE Available sailfish sailfish MASTER 94
876X00GNG UNAUTHORIZED Unavailable unknown unknown unknown unknown
HT6570300047 UNAUTHORIZED Unavailable unknown unknown unknown unknown
分配狀態
分配狀態是 Tradefed 專屬狀態,用於監控裝置使用情形。這些狀態由 DeviceAllocationState 描述,可為下列任一狀態:
- UNKNOWN:在轉換期間使用的中繼狀態,用於決定是否應將裝置從追蹤清單中移除。當裝置與
adb
中斷連線時,就會發生這種情況。
- 忽略:裝置已篩除,因此無法選取 TF 工作階段。TF 很可能在匯出
ANDROID_SERIAL
後啟動,因此會限制可選取的裝置範圍。
- 可用:裝置已準備好供測試。
- 無法使用:裝置已連線,但尚未準備好執行測試。通常會在
adb
中顯示為 offline
。
- 已分配:裝置目前正在執行測試,無法選取。
- CHECKING_AVAILABILITY:裝置剛連上網路,TF 會檢查裝置是否已正確連上網路,且可供使用。否則,系統會將其設為不可用。
線上狀態
線上狀態代表 adb devices
所見的裝置實際狀態。這些狀態由 TestDeviceState 說明,可分為以下類型:
- FASTBOOT
- 線上
- RECOVERY
- NOT_AVAILABLE
Tradefed 線上狀態會連結至我們使用的基礎 adb
程式庫 ddmlib
。並使用 DeviceState 說明狀態。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Device states in Tradefed\n\nAndroid devices\n---------------\n\nAndroid devices in Tradefed can go through several states made available through\nthe Device Manager. There are two main categories of states for Android devices:\nAllocation state and Online State.\n\nAll of these states can be checked in the\n[Tradefed Console](/docs/core/tests/tradefed/fundamentals/console) using\n`l d` or `list devices`. \n\n tf \u003el d\n Serial State Allocation Product Variant Build Battery\n 84TX0081B ONLINE Available blueline blueline MASTER 100\n HT6550300002 ONLINE Available sailfish sailfish MASTER 94\n 876X00GNG UNAUTHORIZED Unavailable unknown unknown unknown unknown\n HT6570300047 UNAUTHORIZED Unavailable unknown unknown unknown unknown\n\n### Allocation states\n\nAllocation states are Tradefed-specific states to monitor device use. They\nare described by\n[DeviceAllocationState](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/remote/src/com/android/tradefed/device/DeviceAllocationState.java)\nand can be any of:\n\n- UNKNOWN: An intermediate state used during transitions to decide if the device should be removed from the tracking list. This would happen when a device is disconnected from `adb`.\n- IGNORED: Device cannot be selected for the TF session because it was filtered out. Most likely TF was started with `ANDROID_SERIAL` exported, so it limits the scope of devices that can be picked.\n- AVAILABLE: Device is ready to be selected for a test.\n- UNAVAILABLE: Device is connected but not ready to run tests. It usually shows as `offline` in `adb`.\n- ALLOCATED: Device is currently running a test and cannot be selected.\n- CHECKING_AVAILABILITY: Device was just connected, and TF checks whether it is properly online and can be made available. If not, it will be made unavailable.\n\n### Online states\n\nOnline states represent the actual state of the device as seen by `adb devices`.\nThey are described by\n[TestDeviceState](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/device_build_interfaces/com/android/tradefed/device/TestDeviceState.java)\nand can be:\n\n- FASTBOOT\n- ONLINE\n- RECOVERY\n- NOT_AVAILABLE\n\nTradefed online states are linked to the underlying `adb` library we use,\n`ddmlib`. It describes the states with\n[DeviceState](https://android.googlesource.com/platform/tools/base/+/refs/heads/android16-release/ddmlib/src/main/java/com/android/ddmlib/IDevice.java)."]]