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)

从启动/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 启动映像是否符合预期。(已废弃。请使用提供的 tmpDir 进行调用)

参数
device ITestDeviceITestDevice

buildInfo IBuildInfoIBuildInfo 构建信息

抛出
TargetSetupError 如果没有有效的 GKI 启动映像

受保护的方法

addHashFooter

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

验证 GKI 启动映像是否符合预期。如果没有有效的 boot.img,则抛出异常。

参数
device ITestDeviceITestDevice

buildInfo IBuildInfoIBuildInfo 构建信息

tmpDir File:临时目录 File

抛出
TargetSetupError 如果没有有效的 GKI 启动映像
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) 的封装容器,用于为单元测试提供解压缩桩。

参数
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 下。这是为了匹配平台 build 的预期 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]。如果无法解析版本字符串,则返回 null。2

抛出
DeviceNotAvailableException

getHostOptions

protected IHostOptions getHostOptions ()

获取对 IHostOptions 的引用

返回
IHostOptions 要使用的 IHostOptions

getKernelVersionFromImage

protected String[] getKernelVersionFromImage (File image)

从 boot/vendor_boot/system_dlkm/vendor_dlkm 映像文件中提取内核版本。此方法会读取启动/vendor_boot/system_dlkm/vendor_dlkm 映像文件,并在 Android 内核版本字符串中搜索特定模式。然后,它会解析找到的字符串,以提取标准化格式的内核版本。

参数
image File:启动映像文件(例如 boot.img)的 File

返回
String[] 一个 ERROR(/String[]),包含已解析的内核版本信息:[kernelVersion, patchLevel, pageSize]。如果无法解析版本字符串,则返回 null。

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 启动映像

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 启动映像
DeviceNotAvailableException