為配合主幹穩定開發模型,並確保生態系統的平台穩定性,我們將自 2026 年起,在第 2 季和第 4 季將原始碼發布至 AOSP。如要建構及貢獻 AOSP,請使用 android-latest-release。android-latest-release 資訊清單分支版本一律會參照推送至 Android 開放原始碼計畫的最新版本。詳情請參閱「Android 開放原始碼計畫變更」。
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
GkiDeviceFlashPreparer
public
class
GkiDeviceFlashPreparer
extends BaseTargetPreparer
implements
ILabPreparer
目標準備工具,可使用 Android 通用核心一般映像檔刷新裝置。詳情請參閱 https://source.android.com/devices/architecture/kernel/android-common。
摘要
受保護的方法 |
void
|
addHashFooter(ITestDevice device, IBuildInfo buildInfo, File tmpDir)
驗證 GKI 開機映像檔是否符合預期。
|
void
|
buildGkiSystemDlkmImg(ITestDevice device, IBuildInfo buildInfo, File tmpDir)
如果提供 system_dlkm 封存檔,請建構 GKI system_dlkm 映像檔。
|
File
|
extractSystemDlkmTarGzip(File systemDlkmArchive)
將 system_dlkm tar gzip 檔案解壓縮至 system_dlkm_staging 資料夾。
|
void
|
flattenSystemDlkm(ITestDevice device, File systemDlkmStagingDir)
將 system_dlkm 暫存目錄扁平化,讓所有核心模組都直接位於 /lib/modules 下方。
|
String[]
|
getDeviceKernelVersion(ITestDevice device)
在刷機前,請先從裝置取得裝置核心版本。
|
IHostOptions
|
getHostOptions()
取得 IHostOptions 的參照
|
String[]
|
getKernelVersionFromImage(File image)
從 boot/vendor_boot/system_dlkm/vendor_dlkm 映像檔擷取核心版本。
|
File
|
getRequestedFile(ITestDevice device, String requestedFileName, File sourceFile, File tmpDir)
依要求的檔案名稱,從來源檔案 (ZIP 或資料夾) 取得要求的檔案。
|
IRunUtil
|
getRunUtil()
取得要使用的 IRunUtil 執行個體。
|
String[]
|
parseKernelVersion(String source, String kernelVersionString)
|
void
|
validateGkiBootImg(ITestDevice device, IBuildInfo buildInfo, File tmpDir)
驗證 GKI 開機映像檔是否符合預期。
|
void
|
validateKernelCompatibility(String imageName, String[] imageVersion, String[] bootVersion, ITestDevice device)
|
void
|
validateKernelVersion(ITestDevice device, IBuildInfo buildInfo, File tmpDir)
確認映像檔中的核心版本是否符合預期。
|
公用建構函式
GkiDeviceFlashPreparer
public GkiDeviceFlashPreparer ()
公用方法
validateGkiBootImg
public void validateGkiBootImg (ITestDevice device,
IBuildInfo buildInfo)
確認 GKI 開機映像檔是否符合預期。(已淘汰。Please call with tmpDir provided)
受保護的方法
protected void addHashFooter (ITestDevice device,
IBuildInfo buildInfo,
File tmpDir)
確認 GKI 開機映像檔是否符合預期。如果沒有有效的 boot.img,則擲回例外狀況。
buildGkiSystemDlkmImg
protected void buildGkiSystemDlkmImg (ITestDevice device,
IBuildInfo buildInfo,
File tmpDir)
如果提供 system_dlkm 封存檔,請建構 GKI system_dlkm 映像檔。
protected File extractSystemDlkmTarGzip (File systemDlkmArchive)
將 system_dlkm tar gzip 檔案解壓縮至 system_dlkm_staging 資料夾。這個函式是 ERROR(/TarUtil.extractTarGzipToTemp) 的包裝函式,用於單元測試的虛設常式 untarring。
| 參數 |
systemDlkmArchive |
File:包含 GKI 模組的 system_dlkm tar gzip 檔案。 |
| 傳回 |
File |
內含 system_dlkm tar gzip 內容的檔案。 |
| 擲回 |
|
java.io.IOException |
IOException |
|
flattenSystemDlkm
protected void flattenSystemDlkm (ITestDevice device,
File systemDlkmStagingDir)
將 system_dlkm 暫存目錄扁平化,讓所有核心模組都直接位於 /lib/modules 下方。這是為了配合平台建構作業的預期 system_dlkm 檔案版面配置。
| 參數 |
device |
ITestDevice:ITestDevice |
systemDlkmStagingDir |
File:system_dlkm 暫存目錄 File |
getDeviceKernelVersion
protected String[] getDeviceKernelVersion (ITestDevice device)
在刷機前,請先從裝置取得裝置核心版本。
| 傳回 |
String[] |
ERROR(/String[]),其中包含已剖析的核心版本資訊:[kernelVersion、
patchLevel、pageSize]。如果無法剖析版本字串,則傳回空值。2 |
getKernelVersionFromImage
protected String[] getKernelVersionFromImage (File image)
從 boot/vendor_boot/system_dlkm/vendor_dlkm 映像檔擷取核心版本。這個方法會讀取 boot/vendor_boot/system_dlkm/vendor_dlkm 映像檔,並在 Android 核心版本字串中搜尋特定模式。然後剖析找到的字串,以標準化格式擷取核心版本。
| 參數 |
image |
File:開機映像檔 (例如 boot.img) 的 File。 |
| 傳回 |
String[] |
ERROR(/String[]),其中包含已剖析的核心版本資訊:[kernelVersion、
patchLevel、pageSize]。如果無法剖析版本字串,則傳回空值。 |
getRequestedFile
protected File getRequestedFile (ITestDevice device,
String requestedFileName,
File sourceFile,
File tmpDir)
根據要求的檔案名稱,從來源檔案 (ZIP 或資料夾) 取得要求的檔案。
提供的來源檔案可以是 ZIP 檔案。這個方法會將檔案解壓縮至暫時目錄,並依據提供的檔案名稱尋找所需檔案。
提供的來源檔案可以是檔案資料夾。這個方法會根據提供的檔案名稱尋找要求的檔案。
| 參數 |
device |
ITestDevice:ITestDevice |
requestedFileName |
String:要求的檔案名稱字串 |
sourceFile |
File:來源檔案 |
tmpDir |
File |
parseKernelVersion
protected String[] parseKernelVersion (String source,
String kernelVersionString)
| 參數 |
source |
String |
kernelVersionString |
String |
validateGkiBootImg
protected void validateGkiBootImg (ITestDevice device,
IBuildInfo buildInfo,
File tmpDir)
確認 GKI 開機映像檔是否符合預期。如果沒有有效的 boot.img,則擲回例外狀況。
validateKernelCompatibility
protected void validateKernelCompatibility (String imageName,
String[] imageVersion,
String[] bootVersion,
ITestDevice device)
| 參數 |
imageName |
String |
imageVersion |
String |
bootVersion |
String |
device |
ITestDevice |
validateKernelVersion
protected void validateKernelVersion (ITestDevice device,
IBuildInfo buildInfo,
File tmpDir)
確認映像檔中的核心版本是否符合預期。如果無效,則擲回例外狀況。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2026-06-22 (世界標準時間)。
[[["容易理解","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-06-22 (世界標準時間)。"],[],[]]