自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
DeviceImageZipFlashingTargetPreparer
public
class
DeviceImageZipFlashingTargetPreparer
extends DeviceUpdateTargetPreparer
目標準備工具,可使用透過特定格式提供的裝置映像檔刷新裝置。
裝置圖片格式的高層級規定:
- 裝置映像檔必須是 ZIP 檔案
- ZIP 檔案的根目錄中必須包含 flash-all.sh 指令碼
- 指令碼必須假設裝置位於
adb devices
可見的使用者空間中 - 其餘的 ZIP 檔案會解壓縮至與指令碼相同的目錄位置,並以相同的目錄版面配置方式,且指令碼可透過相對路徑參照 ZIP 檔案中的任何檔案。
- 閃燈後,指令碼必須將裝置還原至相同狀態
- 環境變數
ANDROID_SERIAL
會設為裝置序號,做為執行環境的一部分 - 指令碼可能會假設 PATH 上有
adb
和 fastboot
這個目標準備工具會在上述條件假設下,解開裝置映像檔 ZIP 檔案,並執行內附的
flash-
all.sh
。
摘要
公用建構函式
DeviceImageZipFlashingTargetPreparer
public DeviceImageZipFlashingTargetPreparer ()
受保護的方法
getDeviceUpdateImage
protected File getDeviceUpdateImage ()
提供 ERROR(/File)
例項,代表用於更新的裝置映像檔案
protected void performDeviceUpdate (File deviceUpdateImage,
ITestDevice device)
展開裝置映像檔更新 ZIP 檔案,並呼叫內含的閃燈指令碼
擲回 |
DeviceNotAvailableException |
|
TargetSetupError |
|
postUpdateActions
protected void postUpdateActions (File deviceUpdateImage,
ITestDevice device)
無作業
擲回 |
DeviceNotAvailableException |
|
TargetSetupError |
|
preUpdateActions
protected void preUpdateActions (File deviceUpdateImage,
ITestDevice device)
無作業
擲回 |
DeviceNotAvailableException |
|
TargetSetupError |
|
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。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,["# DeviceImageZipFlashingTargetPreparer\n====================================\n\n\n`\npublic\n\n\nclass\nDeviceImageZipFlashingTargetPreparer\n`\n\n\n`\n\n\n`\n\n`\n\n\n`\n\n`\n\n\n`\n\n`\n\nextends `[DeviceUpdateTargetPreparer](../../../../../../reference/tradefed/com/android/tradefed/targetprep/DeviceUpdateTargetPreparer.html)`\n\n\n`\n\n`\n\n\n`\n\n|---|---|---|---|----------------------------------------------------------------------|\n| java.lang.Object |||||\n| ↳ | [com.android.tradefed.targetprep.BaseTargetPreparer](../../../../../../reference/tradefed/com/android/tradefed/targetprep/BaseTargetPreparer.html) ||||\n| | ↳ | [com.android.tradefed.targetprep.DeviceBuildInfoBootStrapper](../../../../../../reference/tradefed/com/android/tradefed/targetprep/DeviceBuildInfoBootStrapper.html) |||\n| | | ↳ | [com.android.tradefed.targetprep.DeviceUpdateTargetPreparer](../../../../../../reference/tradefed/com/android/tradefed/targetprep/DeviceUpdateTargetPreparer.html) ||\n| | | | ↳ | com.android.tradefed.targetprep.DeviceImageZipFlashingTargetPreparer |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nA target preparer that flashes the device with device images provided via a specific format.\n\nHigh level requirements for the device image format:\n\n- Device image file must be a zip file\n- The zip file must include a flash-all.sh script at the root\n- The script must assume that the device is in userspace visible to `adb devices`\n- The rest of the zip file will be extracted into the same location as script with the same directory layout, and the script may make reference to any files packaged in the zip via relative path\n- After flashing, the script must return the device to the same state\n- An environment variable `ANDROID_SERIAL` will be set to device serial number as part of the execution environment\n- The script may assume that it has `adb` and `fastboot` on PATH\n\nThis target preparer will unpack the device image zip file and execute the enclosed `flash-\nall.sh` under the assumptions outline in requirements above.\n\n\u003cbr /\u003e\n\nSummary\n-------\n\n| ### Public constructors ||\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| ` `[DeviceImageZipFlashingTargetPreparer](../../../../../../reference/tradefed/com/android/tradefed/targetprep/DeviceImageZipFlashingTargetPreparer.html#DeviceImageZipFlashingTargetPreparer())`() ` |\n\n| ### Protected methods ||\n|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` File` | ` `[getDeviceUpdateImage](../../../../../../reference/tradefed/com/android/tradefed/targetprep/DeviceImageZipFlashingTargetPreparer.html#getDeviceUpdateImage())`() ` Provides a [ERROR(/File)](../../../../../../) instance representing the device image file to be used for updating |\n| ` void` | ` `[performDeviceUpdate](../../../../../../reference/tradefed/com/android/tradefed/targetprep/DeviceImageZipFlashingTargetPreparer.html#performDeviceUpdate(File,%20com.android.tradefed.device.ITestDevice))`(File deviceUpdateImage, ITestDevice device) ` Expands the device image update zip and calls the enclosed flashing script |\n| ` void` | ` `[postUpdateActions](../../../../../../reference/tradefed/com/android/tradefed/targetprep/DeviceImageZipFlashingTargetPreparer.html#postUpdateActions(File,%20com.android.tradefed.device.ITestDevice))`(File deviceUpdateImage, ITestDevice device) ` No-op |\n| ` void` | ` `[preUpdateActions](../../../../../../reference/tradefed/com/android/tradefed/targetprep/DeviceImageZipFlashingTargetPreparer.html#preUpdateActions(File,%20com.android.tradefed.device.ITestDevice))`(File deviceUpdateImage, ITestDevice device) ` No-op |\n\nPublic constructors\n-------------------\n\n### DeviceImageZipFlashingTargetPreparer\n\n```\npublic DeviceImageZipFlashingTargetPreparer ()\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nProtected methods\n-----------------\n\n### getDeviceUpdateImage\n\n```\nprotected File getDeviceUpdateImage ()\n```\n\nProvides a [ERROR(/File)](../../../../../../) instance representing the device image file to be used for updating\n\n\u003cbr /\u003e\n\n| Returns ||\n|--------|--------|\n| `File` | \u003cbr /\u003e |\n\n### performDeviceUpdate\n\n```\nprotected void performDeviceUpdate (File deviceUpdateImage, \n ITestDevice device)\n```\n\nExpands the device image update zip and calls the enclosed flashing script\n\n\u003cbr /\u003e\n\n| Throws ||\n|-------------------------------|---|\n| `DeviceNotAvailableException` | |\n| `TargetSetupError` | |\n\n### postUpdateActions\n\n```\nprotected void postUpdateActions (File deviceUpdateImage, \n ITestDevice device)\n```\n\nNo-op\n\n\u003cbr /\u003e\n\n| Throws ||\n|-------------------------------|---|\n| `DeviceNotAvailableException` | |\n| `TargetSetupError` | |\n\n### preUpdateActions\n\n```\nprotected void preUpdateActions (File deviceUpdateImage, \n ITestDevice device)\n```\n\nNo-op\n\n\u003cbr /\u003e\n\n| Throws ||\n|-------------------------------|---|\n| `DeviceNotAvailableException` | |\n| `TargetSetupError` | |"]]