קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
מצב ערכת בדיקה הוא תכונה שנוספה ל-Android 10 למפתחי אפליקציות של צד שלישי שרוצים להפוך מכשיר או צי של מכשירים לאוטומטיים. התכונה מספקת שיטה למחיקת כל נתוני המשתמש במכשיר Android, לשמירת מפתחות ADB ולדילוג על כל מסכי ההגדרה הראשונית. כך המשתמש יכול להריץ בדיקת ממשק משתמש מיד אחרי ההפעלה, בלי אינטראקציה ידנית.
התאמה אישית
כדי לבדוק אם מכשיר נמצא במצב 'מסגרת בדיקה', אפשר לבדוק את הערך של ActivityManager.isRunningInUserTestHarness(). כדאי לצמצם את ההתאמות אישיות למינימום, ולהסתפק בדברים כמו דילוג על מסכי הגדרה (במקלדת או באשף ההגדרה) שעלול לשבש את בדיקות ממשק המשתמש או לדרוש אינטראקציה ידנית.
בהטמעת ברירת המחדל של מצב 'מסגרת בדיקה' נעשה שימוש באותו מנגנון אחסון כמו בהגנה מפני איפוס להגדרות היצרן, כדי לאחסן את מפתחות ה-adb באופן זמני במחיצה קבועה. אם כבר הטמעתם במכשיר הבדיקה מחיצה קבועה עם הגנה מפני איפוס להגדרות המקוריות, לא תצטרכו לבצע הרבה עבודה כדי לתמוך בתכונה.
יצרני ציוד מקורי שלא הגדרו מחיצה קבועה צריכים להטמיע את PersistentDataBlockManagerInternal לפני שהם מריצים את TestHarnessModeService.
בדיקת הסטטוס של מצב 'מסגרת בדיקה'
כשמצב 'מסגרת בדיקה' מופעל, הפונקציה ActivityManager.isRunningInUserTestHarness() מחזירה את הערך true.
הפעלת מצב מסגרת בדיקה
הפעלת מצב מסגרת הבדיקה מוחקת את כל הנתונים מהמכשיר ומגדירה אותו לבדיקה. המשמעות היא שכל החלקים במכשיר שעשויים להפריע לבדיקה (כמו סנכרון אוטומטי של חשבונות, אימות חבילות ועדכונים אוטומטיים) מושבתים כברירת מחדל, אבל המשתמש יכול להפעיל אותם מחדש.
מריצים את הפקודה adb כדי להפעיל את מצב 'מסגרת בדיקה':
adb shell cmd testharness enable
דוגמאות התוכן והקוד שבדף הזה כפופות לרישיונות המפורטים בקטע רישיון לתוכן. Java ו-OpenJDK הם סימנים מסחריים או סימנים מסחריים רשומים של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-27 (שעון UTC).
[[["התוכן קל להבנה","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 (שעון UTC)."],[],[],null,["# Implement Test Harness Mode\n\nTest Harness Mode is a feature added in Android 10 for\nthird-party app developers that wish\nto automate a device or a fleet of devices. The feature provides a method to wipe *all*\nuser data on an Android device, retain ADB keys, and skip all first-time setup screens. This enables\nthe user to run a UI test immediately after startup without any manual interaction.\n| **Note:** Test Harness Mode is different from TradeFed Test Harness. Don't use it when running CTS test.\n\nCustomization\n-------------\n\nYou can determine if a device is in Test Harness Mode by checking\n`ActivityManager.isRunningInUserTestHarness()`. Keep customizations to a minimum;\nlimit to things like skipping setup screens (on the keyboard or setup wizard) that would break\nUI tests or require manual interaction.\n\nImplementation\n--------------\n\nThe default implementation of [`PersistentDataBlockManagerInternal`](https://android.googlesource.com/platform/frameworks/base/+/android16-release/services/core/java/com/android/server/pdb/PersistentDataBlockManagerInternal.java)\nis in [`PersistentDataBlockService`](https://android.googlesource.com/platform/frameworks/base/+/android16-release/services/core/java/com/android/server/pdb/PersistentDataBlockService.java).\nTest Harness Mode is implemented in [`TestHarnessModeService`](https://android.googlesource.com/platform/frameworks/base/+/android16-release/services/core/java/com/android/server/testharness/TestHarnessModeService.java).\n\nThe default implementation of Test Harness Mode uses the same storage mechanism as\nfactory reset protection to store the adb keys temporarily in a persistent partition. If a\npersistent partition with factory reset protection is already implemented on the test device,\nlittle to no work is necessary to support the feature.\n\nOEMs that don't have a persistent partition set up need to implement\n`PersistentDataBlockManagerInternal` before running\n`TestHarnessModeService`.\n\nCheck the status of Test Harness Mode\n-------------------------------------\n\nWhen Test Harness Mode is enabled,\n`ActivityManager.isRunningInUserTestHarness()` returns `true`.\n\nRun Test Harness Mode\n---------------------\n\nEnabling Test Harness Mode wipes all data from the device and sets up the device for\ntesting. This means that all parts of the device that could interfere with testing (such as\nauto-syncing accounts, package verification, and automatic updates) are all disabled by default\nbut the user can reenable them.\n\nRun the `adb` command to enable Test Harness Mode: \n\n```\nadb shell cmd testharness enable\n```"]]