GkiDeviceFlashPreparer

public class GkiDeviceFlashPreparer
extends BaseTargetPreparer implements ILabPreparer

java.lang.Object
   ↳ com.android.tradefed.targetprep.BaseTargetPreparer
     ↳ com.android.tradefed.targetprep.GkiDeviceFlashPreparer


目標準備工具,可使用 Android 通用核心一般映像檔刷新裝置。詳情請參閱 https://source.android.com/devices/architecture/kernel/android-common。

摘要

公用建構函式

GkiDeviceFlashPreparer()

公用方法

void setUp(TestInformation testInfo)

執行測試的目標設定。

void validateGkiBootImg(ITestDevice device, IBuildInfo buildInfo)

驗證 GKI 開機映像檔是否符合預期。

受保護的方法

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 ()

公用方法

setUp

public void setUp (TestInformation testInfo)

執行測試的目標設定。

參數
testInfo TestInformation:叫用的 TestInformation

擲回
BuildError
DeviceNotAvailableException
TargetSetupError

validateGkiBootImg

public void validateGkiBootImg (ITestDevice device, 
                IBuildInfo buildInfo)

確認 GKI 開機映像檔是否符合預期。(已淘汰。Please call with tmpDir provided)

參數
device ITestDeviceITestDevice

buildInfo IBuildInfoIBuildInfo建構資訊

擲回
TargetSetupError 如果沒有有效的 GKI boot.img

受保護的方法

addHashFooter

protected void addHashFooter (ITestDevice device, 
                IBuildInfo buildInfo, 
                File tmpDir)

確認 GKI 開機映像檔是否符合預期。如果沒有有效的 boot.img,則擲回例外狀況。

參數
device ITestDeviceITestDevice

buildInfo IBuildInfoIBuildInfo建構資訊

tmpDir File:臨時目錄 File

擲回
TargetSetupError 如果沒有有效的 GKI boot.img
DeviceNotAvailableException

buildGkiSystemDlkmImg

protected void buildGkiSystemDlkmImg (ITestDevice device, 
                IBuildInfo buildInfo, 
                File tmpDir)

如果提供 system_dlkm 封存檔,請建構 GKI system_dlkm 映像檔。

參數
device ITestDeviceITestDevice

buildInfo IBuildInfoIBuildInfo建構資訊

tmpDir File:臨時目錄 File

擲回
TargetSetupError 建構圖片檔案時發生錯誤。

extractSystemDlkmTarGzip

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 ITestDeviceITestDevice

systemDlkmStagingDir File:system_dlkm 暫存目錄 File

擲回
IOException 如果系統無法順利將 system_dlkm 攤平,則會傳回 TargetSetupError。
TargetSetupError

getDeviceKernelVersion

protected String[] getDeviceKernelVersion (ITestDevice device)

在刷機前,請先從裝置取得裝置核心版本。

參數
device ITestDevice:要從中取得核心版本的 ITestDevice

傳回
String[] ERROR(/String[]),其中包含已剖析的核心版本資訊:[kernelVersion、 patchLevel、pageSize]。如果無法剖析版本字串,則傳回空值。2

擲回
DeviceNotAvailableException

getHostOptions

protected IHostOptions getHostOptions ()

取得 IHostOptions 的參照

傳回
IHostOptions 要使用的 IHostOptions

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 ITestDeviceITestDevice

requestedFileName String:要求的檔案名稱字串

sourceFile File:來源檔案

tmpDir File

傳回
File 要求的檔案名稱所指定的檔案

擲回
com.android.tradefed.targetprep.TargetSetupError
TargetSetupError

getRunUtil

protected IRunUtil getRunUtil ()

取得要使用的 IRunUtil 執行個體。

傳回
IRunUtil 要使用的 IRunUtil

parseKernelVersion

protected String[] parseKernelVersion (String source, 
                String kernelVersionString)

參數
source String

kernelVersionString String

傳回
String[]

validateGkiBootImg

protected void validateGkiBootImg (ITestDevice device, 
                IBuildInfo buildInfo, 
                File tmpDir)

確認 GKI 開機映像檔是否符合預期。如果沒有有效的 boot.img,則擲回例外狀況。

參數
device ITestDeviceITestDevice

buildInfo IBuildInfoIBuildInfo建構資訊

tmpDir File:臨時目錄 File

擲回
TargetSetupError 如果沒有有效的 GKI boot.img

validateKernelCompatibility

protected void validateKernelCompatibility (String imageName, 
                String[] imageVersion, 
                String[] bootVersion, 
                ITestDevice device)

參數
imageName String

imageVersion String

bootVersion String

device ITestDevice

擲回
TargetSetupError

validateKernelVersion

protected void validateKernelVersion (ITestDevice device, 
                IBuildInfo buildInfo, 
                File tmpDir)

確認映像檔中的核心版本是否符合預期。如果無效,則擲回例外狀況。

參數
device ITestDeviceITestDevice

buildInfo IBuildInfoIBuildInfo建構資訊

tmpDir File:臨時目錄 File

擲回
TargetSetupError 如果沒有有效的 GKI boot.img
DeviceNotAvailableException