自 2026 年起,为了与我们的主干稳定开发模型保持一致,并确保生态系统的平台稳定性,我们将在第 2 季度和第 4 季度向 AOSP 发布源代码。如需构建 AOSP 并为其贡献代码,请使用 android-latest-release。android-latest-release 清单分支将始终引用推送到 AOSP 的最新版本。如需了解详情,请参阅 AOSP 变更。
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)
从启动/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 启动映像是否符合预期。(已废弃。请使用提供的 tmpDir 进行调用)
受保护的方法
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) 的封装容器,用于为单元测试提供解压缩桩。
| 参数 |
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 |
ITestDevice:ITestDevice |
systemDlkmStagingDir |
File:system_dlkm 临时目录 File |
getDeviceKernelVersion
protected String[] getDeviceKernelVersion (ITestDevice device)
在刷写之前,从设备获取设备内核版本。
| 返回 |
String[] |
一个 ERROR(/String[]),包含已解析的内核版本信息:[kernelVersion, patchLevel, pageSize]。如果无法解析版本字符串,则返回 null。2 |
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 |
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 和/或其关联公司的注册商标。
最后更新时间 (UTC):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"]],["最后更新时间 (UTC):2026-06-22。"],[],[]]