Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release
thay vì aosp-main
để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
Sử dụng trình điều khiển mô-đun
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Mỗi mô-đun bộ (do AndroidTest.xml
xác định) có thể chứa một đối tượng module_controller
đặc biệt có thể thay đổi một số hành vi của mô-đun:
Có chạy mô-đun hay không dựa trên một số điều kiện
Bằng cách triển khai BaseModuleController và thêm vào AndroidTest.xml
như sau:
<object type="module_controller" class="com.android.tradefed.testtype.suite.module.<NAME>" />
Bộ điều khiển mô-đun sẽ được dùng để xác định xem mô-đun có chạy hay không, dựa trên cách triển khai public abstract RunStrategy shouldRun(IInvocationContext context);
.
Có thu thập một số nhật ký hay không khi xảy ra lỗi
Khi chạy một bộ công cụ đầy đủ, bạn có thể yêu cầu ở cấp bộ công cụ để thu thập một số nhật ký về lỗi (ảnh chụp màn hình, báo cáo lỗi, logcat). Tuy nhiên, đối với một số mô-đun, một nhật ký cụ thể được yêu cầu có thể không có giá trị nào và chỉ lãng phí thời gian để thu thập. Trong trường hợp đó, một mô-đun có thể chỉ định rõ ràng những nhật ký mà chúng quan tâm:
<object type="module_controller"
class="com.android.tradefed.testtype.suite.module.TestFailureModuleController">
<option name="screenshot-on-failure" value="<true OR false>" />
<option name="bugreportz-on-failure" value="<true OR false>" />
<option name="logcat-on-failure" value="<true OR false>" />
</object>
LƯU Ý: Việc triển khai bộ điều khiển phải chung chung nếu có thể để tối đa hoá khả năng sử dụng lại. Chủ sở hữu mô-đun phải xem xét việc bỏ qua mô-đun dựa trên điều kiện của mô-đun để được phê duyệt rằng việc bỏ qua mô-đun là hành vi phù hợp với họ.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],null,["# Employ module controllers\n\nEach suite module (defined by `AndroidTest.xml`) can contain a special\n`module_controller` object that can alter some behavior of the module:\n\nWhether to run the module or not based on some conditions\n---------------------------------------------------------\n\nBy implementing [BaseModuleController](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/src/com/android/tradefed/testtype/suite/module/BaseModuleController.java)\nand adding it to the `AndroidTest.xml` like this: \n\n \u003cobject type=\"module_controller\" class=\"com.android.tradefed.testtype.suite.module.\u003cNAME\u003e\" /\u003e\n\nThe module controller will be used to determine whether the module should run\nor not, based on the\n`public abstract RunStrategy shouldRun(IInvocationContext context);`\nimplementation.\n\nWhether to collect some logs or not on failures\n-----------------------------------------------\n\nWhen running a full suite, it's possible to request at the suite level the\ncollection of some logs on failures (screenshot, bugreport, logcat). But for\nsome modules, a particular log requested might not have any value and will\nsimply waste time to be collected. In that situation, a module can explicitly\nspecify which logs they are interested in: \n\n \u003cobject type=\"module_controller\"\n class=\"com.android.tradefed.testtype.suite.module.TestFailureModuleController\"\u003e\n \u003coption name=\"screenshot-on-failure\" value=\"\u003ctrue OR false\u003e\" /\u003e\n \u003coption name=\"bugreportz-on-failure\" value=\"\u003ctrue OR false\u003e\" /\u003e\n \u003coption name=\"logcat-on-failure\" value=\"\u003ctrue OR false\u003e\" /\u003e\n \u003c/object\u003e\n\nNOTE: Implementation of controllers should be generic if possible in order to\nmaximize re-usability. And skipping a module based on its condition should\nbe reviewed by the module owner to get the approval that skipping a module is\nthe proper behavior for them."]]