Google is committed to advancing racial equity for Black communities. See how.

InstallApexModuleTargetPreparer

public class InstallApexModuleTargetPreparer
extends SuiteApkInstaller

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


Summary

Public constructors

InstallApexModuleTargetPreparer()

Public methods

getModulesToInstall(TestInformation testInfo)

Gets the modules that should be installed on the train, based on the modules preloaded on the device.

void setUp(TestInformation testInfo)

void tearDown(TestInformation testInfo, Throwable e)

Protected methods

collectApexInfoFromApexModules( testAppFileNames, TestInformation testInfo)

Collects apex info from the apex modules for activation check.

boolean containsPersistentApk( testAppFileNames, TestInformation testInfo)

Checks if the input files contain any persistent apk.

getApkInstalled()
String getBundletoolFileName()
BundletoolUtil getBundletoolUtil()
String getModuleKeywordFromApexPackageName(String packageName)

Gets the keyword (e.g., 'tzdata' for com.android.tzdata.apex) from the apex package name.

getModulesFailToActivate( activatedApexes)

Get modules that failed to be activated.

void installTrain(TestInformation testInfo, moduleFilenames, String[] extraArgs)

Attempts to install a mainline train containing apex on the device.

void installUsingBundleTool(TestInformation testInfo, testAppFileNames)

Attempts to install mainline module(s) using bundletool.

void installer(TestInformation testInfo, testAppFileNames)

Attempt to install an package or split package on the device.

boolean isPersistentApk(File filename, TestInformation testInfo)

Checks if an apk is a persistent apk.

ITestDevice.ApexInfo retrieveApexInfo(File testApexFile, DeviceDescriptor deviceDescriptor)

Retrieves ApexInfo which contains packageName and versionCode from the given apex file.

Public constructors

InstallApexModuleTargetPreparer

public InstallApexModuleTargetPreparer ()

Public methods

getModulesToInstall

public  getModulesToInstall (TestInformation testInfo)

Gets the modules that should be installed on the train, based on the modules preloaded on the device. Modules that are not preloaded will not be installed.

Parameters
testInfo TestInformation: the TestInformation

Returns
List of the modules that should be installed on the device.

Throws
DeviceNotAvailableException when device is not available.
TargetSetupError when mandatory modules are not installed, or module cannot be installed.

setUp

public void setUp (TestInformation testInfo)

Parameters
testInfo TestInformation

Throws
BuildError
DeviceNotAvailableException
TargetSetupError

tearDown

public void tearDown (TestInformation testInfo, 
                Throwable e)

Parameters
testInfo TestInformation

e Throwable

Throws
DeviceNotAvailableException

Protected methods

collectApexInfoFromApexModules

protected  collectApexInfoFromApexModules ( testAppFileNames, 
                TestInformation testInfo)

Collects apex info from the apex modules for activation check.

Parameters
testAppFileNames : The list of the file names of the modules to install

testInfo TestInformation: The TestInformation

Returns
a list containing the apexinfo of the apex modules in the input file lists

Throws
TargetSetupError

containsPersistentApk

protected boolean containsPersistentApk ( testAppFileNames, 
                TestInformation testInfo)

Checks if the input files contain any persistent apk.

Parameters
testAppFileNames : The list of the file names of the modules to install

testInfo TestInformation: The TestInformation

Returns
boolean true if the input files contains a persistent apk module.

Throws
DeviceNotAvailableException
TargetSetupError

getApkInstalled

protected  getApkInstalled ()

Returns

getBundletoolFileName

protected String getBundletoolFileName ()

Returns
String

getBundletoolUtil

protected BundletoolUtil getBundletoolUtil ()

Returns
BundletoolUtil

getModuleKeywordFromApexPackageName

protected String getModuleKeywordFromApexPackageName (String packageName)

Gets the keyword (e.g., 'tzdata' for com.android.tzdata.apex) from the apex package name.

Parameters
packageName String: The package name of the apex file.

Returns
String a string The keyword of the apex package name.

getModulesFailToActivate

protected  getModulesFailToActivate ( activatedApexes)

Get modules that failed to be activated.

Parameters
activatedApexes : The set of the active apexes on device

Returns
a list containing the apexinfo of the input apex modules that failed to be activated.

Throws
DeviceNotAvailableException
TargetSetupError

installTrain

protected void installTrain (TestInformation testInfo, 
                 moduleFilenames, 
                String[] extraArgs)

Attempts to install a mainline train containing apex on the device.

Parameters
testInfo TestInformation: the TestInformation

moduleFilenames : List of String. The list of filenames of the mainline modules to be installed.

extraArgs String

Throws
DeviceNotAvailableException
TargetSetupError

installUsingBundleTool

protected void installUsingBundleTool (TestInformation testInfo, 
                 testAppFileNames)

Attempts to install mainline module(s) using bundletool.

Parameters
testInfo TestInformation: the TestInformation

testAppFileNames : the filenames of the preloaded modules to install.

Throws
DeviceNotAvailableException
TargetSetupError

installer

protected void installer (TestInformation testInfo, 
                 testAppFileNames)

Attempt to install an package or split package on the device.

Parameters
testInfo TestInformation: the TestInformation for the invocation

testAppFileNames : The apks and their package to be installed.

Throws
DeviceNotAvailableException
TargetSetupError

isPersistentApk

protected boolean isPersistentApk (File filename, 
                TestInformation testInfo)

Checks if an apk is a persistent apk.

Parameters
filename File: The apk module file to check

testInfo TestInformation: The TestInformation

Returns
boolean true if this is a persistent apk module.

Throws
DeviceNotAvailableException
TargetSetupError

retrieveApexInfo

protected ITestDevice.ApexInfo retrieveApexInfo (File testApexFile, 
                DeviceDescriptor deviceDescriptor)

Retrieves ApexInfo which contains packageName and versionCode from the given apex file.

Parameters
testApexFile File: The apex file we retrieve information from.

deviceDescriptor DeviceDescriptor

Returns
ITestDevice.ApexInfo an ApexInfo containing the packageName and versionCode of the given file

Throws
TargetSetupError if aapt parser failed to parse the file.