Effective in 2026, to align with our trunk stable development model and ensure platform stability for the ecosystem, we will publish source code to AOSP in Q2 and Q4. For building and contributing to AOSP, use android-latest-release. The android-latest-release manifest branch will always reference the most recent release pushed to AOSP. For more information, see Changes to AOSP.
Stay organized with collections
Save and categorize content based on your preferences.
GkiDeviceFlashPreparer
public
class
GkiDeviceFlashPreparer
extends BaseTargetPreparer
implements
ILabPreparer
A target preparer that flash the device with android common kernel generic image. Please see
https://source.android.com/devices/architecture/kernel/android-common for details.
Summary
Protected methods |
void
|
addHashFooter(ITestDevice device, IBuildInfo buildInfo, File tmpDir)
Validate GKI boot image is expected.
|
void
|
buildGkiSystemDlkmImg(ITestDevice device, IBuildInfo buildInfo, File tmpDir)
Build GKI system_dlkm image if the system_dlkm archive is provided.
|
File
|
extractSystemDlkmTarGzip(File systemDlkmArchive)
Extracts the system_dlkm tar gzip file into the system_dlkm_staging folder.
|
void
|
flattenSystemDlkm(ITestDevice device, File systemDlkmStagingDir)
Flatten the system_dlkm staging directory so that all the kernel modules are directly under
/lib/modules.
|
String[]
|
getDeviceKernelVersion(ITestDevice device)
Get device kernel version from the device before flashing.
|
IHostOptions
|
getHostOptions()
Get a reference to the IHostOptions
|
String[]
|
getKernelVersionFromImage(File image)
Extracts the kernel version from a boot/vendor_boot/system_dlkm/vendor_dlkm image files.
|
File
|
getRequestedFile(ITestDevice device, String requestedFileName, File sourceFile, File tmpDir)
Get the requested file from the source file (zip or folder) by requested file name.
|
IRunUtil
|
getRunUtil()
Get the IRunUtil instance to use.
|
String[]
|
parseKernelVersion(String source, String kernelVersionString)
|
void
|
validateGkiBootImg(ITestDevice device, IBuildInfo buildInfo, File tmpDir)
Validate GKI boot image is expected.
|
void
|
validateKernelCompatibility(String imageName, String[] imageVersion, String[] bootVersion, ITestDevice device)
|
void
|
validateKernelVersion(ITestDevice device, IBuildInfo buildInfo, File tmpDir)
Validate kernel versions in the images are expected.
|
Public constructors
GkiDeviceFlashPreparer
public GkiDeviceFlashPreparer ()
Public methods
public void setUp (TestInformation testInfo)
Perform the target setup for testing.
| Parameters |
testInfo |
TestInformation: The TestInformation of the invocation. |
validateGkiBootImg
public void validateGkiBootImg (ITestDevice device,
IBuildInfo buildInfo)
Validate GKI boot image is expected. (Obsoleted. Please call with tmpDir provided)
Protected methods
protected void addHashFooter (ITestDevice device,
IBuildInfo buildInfo,
File tmpDir)
Validate GKI boot image is expected. Throw exception if there is no valid boot.img.
| Parameters |
device |
ITestDevice: the ITestDevice |
buildInfo |
IBuildInfo: the IBuildInfo the build info |
tmpDir |
File: the temporary directory File |
buildGkiSystemDlkmImg
protected void buildGkiSystemDlkmImg (ITestDevice device,
IBuildInfo buildInfo,
File tmpDir)
Build GKI system_dlkm image if the system_dlkm archive is provided.
| Parameters |
device |
ITestDevice: the ITestDevice |
buildInfo |
IBuildInfo: the IBuildInfo the build info |
tmpDir |
File: the temporary directory File |
protected File extractSystemDlkmTarGzip (File systemDlkmArchive)
Extracts the system_dlkm tar gzip file into the system_dlkm_staging folder. This function is
a wrapper around ERROR(/TarUtil.extractTarGzipToTemp) in order to stub out the untarring for
unit testing.
| Parameters |
systemDlkmArchive |
File: the system_dlkm tar gzip file containing GKI modules. |
| Returns |
File |
File containing the system_dlkm tar gzip contents. |
| Throws |
|
java.io.IOException |
IOException |
|
flattenSystemDlkm
protected void flattenSystemDlkm (ITestDevice device,
File systemDlkmStagingDir)
Flatten the system_dlkm staging directory so that all the kernel modules are directly under
/lib/modules. This is necessary to match the expected system_dlkm file layout for platform
builds.
| Parameters |
device |
ITestDevice: the ITestDevice |
systemDlkmStagingDir |
File: the system_dlkm staging directory File |
| Throws |
IOException |
or TargetSetupError if there is an error flattening the system_dlkm. |
TargetSetupError |
|
getDeviceKernelVersion
protected String[] getDeviceKernelVersion (ITestDevice device)
Get device kernel version from the device before flashing.
| Parameters |
device |
ITestDevice: The ITestDevice to get kernel version from. |
| Returns |
String[] |
A ERROR(/String[]) containing the parsed kernel version info: [kernelVersion,
patchLevel, pageSize]. Returns null if the version string cannot be parsed.2 |
getKernelVersionFromImage
protected String[] getKernelVersionFromImage (File image)
Extracts the kernel version from a boot/vendor_boot/system_dlkm/vendor_dlkm image files. This
method reads the boot/vendor_boot/system_dlkm/vendor_dlkm image file and searches for a
specific pattern in Android kernel version strings. It then parses the found string to
extract the kernel version in a standardized format.
| Parameters |
image |
File: The File to the boot image file (e.g., boot.img). |
| Returns |
String[] |
A ERROR(/String[]) containing the parsed kernel version info: [kernelVersion,
patchLevel, pageSize]. Returns null if the version string cannot be parsed. |
getRequestedFile
protected File getRequestedFile (ITestDevice device,
String requestedFileName,
File sourceFile,
File tmpDir)
Get the requested file from the source file (zip or folder) by requested file name.
The provided source file can be a zip file. The method will unzip it to tempary directory
and find the requested file by the provided file name.
The provided source file can be a file folder. The method will find the requestd file by
the provided file name.
| Parameters |
device |
ITestDevice: the ITestDevice |
requestedFileName |
String: the requeste file name String |
sourceFile |
File: the source file |
tmpDir |
File |
| Returns |
File |
the file that is specified by the requested file name |
parseKernelVersion
protected String[] parseKernelVersion (String source,
String kernelVersionString)
| Parameters |
source |
String |
kernelVersionString |
String |
validateGkiBootImg
protected void validateGkiBootImg (ITestDevice device,
IBuildInfo buildInfo,
File tmpDir)
Validate GKI boot image is expected. Throw exception if there is no valid boot.img.
| Parameters |
device |
ITestDevice: the ITestDevice |
buildInfo |
IBuildInfo: the IBuildInfo the build info |
tmpDir |
File: the temporary directory File |
validateKernelCompatibility
protected void validateKernelCompatibility (String imageName,
String[] imageVersion,
String[] bootVersion,
ITestDevice device)
| Parameters |
imageName |
String |
imageVersion |
String |
bootVersion |
String |
device |
ITestDevice |
validateKernelVersion
protected void validateKernelVersion (ITestDevice device,
IBuildInfo buildInfo,
File tmpDir)
Validate kernel versions in the images are expected. Throw exception if not valid.
| Parameters |
device |
ITestDevice: the ITestDevice |
buildInfo |
IBuildInfo: the IBuildInfo the build info |
tmpDir |
File: the temporary directory File |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026-06-22 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-06-22 UTC."],[],[]]