GkiDeviceFlashPreparer

public class GkiDeviceFlashPreparer
extends BaseTargetPreparer implements ILabPreparer

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


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

Public constructors

GkiDeviceFlashPreparer()

Public methods

void setUp(TestInformation testInfo)

Perform the target setup for testing.

void validateGkiBootImg(ITestDevice device, IBuildInfo buildInfo)

Validate GKI boot image is expected.

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.

IHostOptions getHostOptions()

Get a reference to the IHostOptions

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.

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

Validate GKI boot image is expected.

Public constructors

GkiDeviceFlashPreparer

public GkiDeviceFlashPreparer ()

Public methods

setUp

public void setUp (TestInformation testInfo)

Perform the target setup for testing.

Parameters
testInfo TestInformation: The TestInformation of the invocation.

Throws
BuildError
DeviceNotAvailableException
TargetSetupError

validateGkiBootImg

public void validateGkiBootImg (ITestDevice device, 
                IBuildInfo buildInfo)

Validate GKI boot image is expected. (Obsoleted. Please call with tmpDir provided)

Parameters
device ITestDevice: the ITestDevice

buildInfo IBuildInfo: the IBuildInfo the build info

Throws
TargetSetupError if there is no valid gki boot.img

Protected methods

addHashFooter

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 ERROR(/File)

Throws
TargetSetupError if there is no valid gki boot.img
DeviceNotAvailableException

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 ERROR(/File)

Throws
TargetSetupError if there is an error building the image file.

extractSystemDlkmTarGzip

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
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 ERROR(/File)

Throws
or TargetSetupError if there is an error flattening the system_dlkm.
TargetSetupError

getHostOptions

protected IHostOptions getHostOptions ()

Get a reference to the IHostOptions

Returns
IHostOptions the IHostOptions to use

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

Throws
com.android.tradefed.targetprep.TargetSetupError
TargetSetupError

getRunUtil

protected IRunUtil getRunUtil ()

Get the IRunUtil instance to use.

Returns
IRunUtil the IRunUtil to use

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 ERROR(/File)

Throws
TargetSetupError if there is no valid gki boot.img