ModuleOemTargetPreparer

public class ModuleOemTargetPreparer
extends InstallApexModuleTargetPreparer

java.lang.Object
   ↳ com.android.tradefed.targetprep.BaseTargetPreparer
     ↳ com.android.tradefed.targetprep.TestAppInstallSetup
       ↳ com.android.tradefed.targetprep.suite.SuiteApkInstaller
         ↳ com.android.tradefed.targetprep.InstallApexModuleTargetPreparer
           ↳ com.android.tradefed.targetprep.ModuleOemTargetPreparer


Summary

Nested classes

class ModuleOemTargetPreparer.ModuleInfo

A simple struct class to store information about a module  

Public constructors

ModuleOemTargetPreparer()

Public methods

void checkModuleAfterPush(ITestDevice device, pushedModules)

Check module name and version code after pushed

void setUp(TestInformation testInfo)

Perform the target setup for testing, push modules to replace the preload ones

Protected methods

void checkPreloadModules(TestInformation testInfo, DeviceDescriptor deviceDescriptor)

Check preload modules info

String[] getApkDirectory(ITestDevice device, String packageName)

Get apk file path under system directory

String getPackageVersioncode(ITestDevice device, String packageName, boolean isAPK)

Check package version after pushed module given package name.

ModuleOemTargetPreparer.ModuleInfo pushFile(File moduleFile, TestInformation testInfo)

Push files to /system/apex/ for apex or /system/** for apk

String renameFile(ITestDevice device, File moduleFile, String packageName)

Rename to-be-updated file name to same one under /system.

void setupDevice(TestInformation testInfo)

adb root and remount device before push files under /system

Public constructors

ModuleOemTargetPreparer

public ModuleOemTargetPreparer ()

Public methods

checkModuleAfterPush

public void checkModuleAfterPush (ITestDevice device, 
                 pushedModules)

Check module name and version code after pushed

Parameters
device ITestDevice

pushedModules : List of modules pushed

Throws
TargetSetupError throw exception if no module pushed
DeviceNotAvailableException throw exception if no device available

setUp

public void setUp (TestInformation testInfo)

Perform the target setup for testing, push modules to replace the preload ones

Parameters
testInfo TestInformation: The TestInformation of the invocation.

Throws
TargetSetupError if fatal error occurred setting up environment
BuildError If an error occurs due to the build being prepared
DeviceNotAvailableException if device became unresponsive

Protected methods

checkPreloadModules

protected void checkPreloadModules (TestInformation testInfo, 
                DeviceDescriptor deviceDescriptor)

Check preload modules info

Parameters
testInfo TestInformation: test info

deviceDescriptor DeviceDescriptor

Throws
DeviceNotAvailableException throws exception if devices no available
TargetSetupError throws exception if no modules preloaded

getApkDirectory

protected String[] getApkDirectory (ITestDevice device, 
                String packageName)

Get apk file path under system directory

Parameters
device ITestDevice

packageName String: module package name

Returns
String[] string array with apk name and path

Throws
DeviceNotAvailableException if device is not available
TargetSetupError if cannot find the path of the package

getPackageVersioncode

protected String getPackageVersioncode (ITestDevice device, 
                String packageName, 
                boolean isAPK)

Check package version after pushed module given package name.

Parameters
packageName String: pushed package name

isAPK boolean

Returns
String

Throws
DeviceNotAvailableException throws exception if device not found.

pushFile

protected ModuleOemTargetPreparer.ModuleInfo pushFile (File moduleFile, 
                TestInformation testInfo)

Push files to /system/apex/ for apex or /system/** for apk

Parameters
moduleFile File: module file

testInfo TestInformation: the TestInformation for the invocation.

Returns
ModuleOemTargetPreparer.ModuleInfo

Throws
TargetSetupError if cannot push file via adb
DeviceNotAvailableException if device not available

renameFile

protected String renameFile (ITestDevice device, 
                File moduleFile, 
                String packageName)

Rename to-be-updated file name to same one under /system.

Parameters
device ITestDevice: test device

moduleFile File: module file to be installed

packageName String: name under /system/*

Returns
String new file name after rename

Throws
TargetSetupError if file cannot be renamed
DeviceNotAvailableException

setupDevice

protected void setupDevice (TestInformation testInfo)

adb root and remount device before push files under /system

Parameters
testInfo TestInformation: the TestInformation for the invocation.

Throws
TargetSetupError if device cannot be remount.
DeviceNotAvailableException