Effective in 2026, to align with our trunk stable development model and ensure platform stability for the ecosystem, we will publish source code to AOSP in Q2 and Q4. For building and contributing to AOSP, use android-latest-release. The android-latest-release manifest branch will always reference the most recent release pushed to AOSP. For more information, see Changes to AOSP.
Google 會運用 AI 技術將內容翻譯成你偏好的語言,但可能會出錯。
指定準備者
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
目標準備器會在
測試層級中定義的測試之前叫用。這樣就能設定任何裝置,確保測試順利進行。
基本介面
基本介面為 ITargetPreparer,可執行 setUp 方法的實作。建議您實作基本抽象類別 BaseTargetPreparer,這個類別提供內建停用功能,可輕鬆停用準備工具。
更簡潔的介面
setUp 的自然擴充功能是 tearDown,由不同的介面 ITargetCleaner 提供。這會提供 tearDown 介面,方便您在測試執行後,清除 setUp 中執行的任何作業。
BaseTargetPreparer 類別也會擴充 ITargetCleaner。
建議
建議每個準備者只執行單一主要函式,例如安裝 APK 或執行指令。這樣一來,您就能更輕鬆地重複使用準備工具。
此外,請先查看可用的準備人員清單,再新增人員,以免重複作業。「準備」功能適用於 tools/tradefederation/core/src/com/android/tradefed/targetprep/。
XML 設定
物件標記為 target_preparer,例如:
<target_preparer class="com.android.tradefed.targetprep.InstallApkSetup">
<option name="install-arg" value="-d"/>
</target_preparer>
如需相關背景資訊,請參閱「設定套件」。
頂層設定
如果是在頂層設定中指定,準備程序只會為每個裝置執行一次。以 cts-common.xml 為例,這是 Android Compatibility Test Suite (CTS) 測試的頂層設定。
模組層級設定
如果是在模組層級指定,準備程序一律會在該模組之前執行。例如 backup/AndroidTest.xml,定義 Tradefed 執行 backup CTS 模組的方式。
請注意,準備工具會在模組之前執行,但會在任何系統狀態檢查工具「之後」執行。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2026-10-11 (世界標準時間)。
[[["容易理解","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"]],["上次更新時間:2026-10-11 (世界標準時間)。"],[],[]]