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
Constants | |
|---|---|
String |
APEX_OPTION
|
String |
APEX_SUFFIX
|
String |
APK_SUFFIX
|
String |
APK_ZIP_OPTION
|
String |
CHILD_SESSION_CREATION_CMD
|
String |
PARENT_SESSION_CREATION_CMD
|
String |
ROLLBACK_STATE_COMMITTED
|
String |
ROLLBACK_STATE_UNKNOWN
|
String |
SPLIT_APKS_SUFFIX
|
Fields | |
|---|---|
protected
File |
mTrainFolderPath
|
Public constructors | |
|---|---|
InstallApexModuleTargetPreparer()
|
|
Public methods | |
|---|---|
List<File>
|
getModulesToInstall(TestInformation testInfo)
Gets the modules that should be installed on the train, based on the modules preloaded on the device. |
void
|
setIgnoreIfNotPreloaded(boolean skip)
|
void
|
setSkipApexTearDown(boolean skip)
|
void
|
setUp(TestInformation testInfo)
|
void
|
tearDown(TestInformation testInfo, Throwable e)
|
Protected methods | |
|---|---|
void
|
addApksToTestFiles()
|
void
|
addStagedReadyTimeoutForAdb(List<String> cmd)
|
void
|
addTimeoutMillisForBundletool(List<String> extraArgs)
|
void
|
checkApexActivation(ITestDevice device)
Check if all apexes are activated. |
List<ITestDevice.ApexInfo>
|
collectApexInfoFromApexModules(Map<File, String> testAppFileNames, TestInformation testInfo)
Collects apex info from the apex modules for activation check. |
List<String>
|
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. |
List<ITestDevice.ApexInfo>
|
getModulesFailToActivate(Set<ITestDevice.ApexInfo> activatedApexes)
Get modules that failed to be activated. |
List<File>
|
getSplitsForApks(TestInformation testInfo, File moduleFile)
Extracts and returns splits for the specified apks. |
void
|
initBundletoolUtil(TestInformation testInfo)
Initializes the bundletool util for this class. |
void
|
installTrain(TestInformation testInfo, List<File> moduleFilenames)
Attempts to install a mainline train containing apex on the device. |
void
|
installUsingBundleTool(TestInformation testInfo, List<File> testAppFileNames)
Attempts to install mainline module(s) using bundletool. |
void
|
installer(TestInformation testInfo, Map<File, String> testAppFileNames)
Attempt to install an package or split package on the device. |
ITestDevice.ApexInfo
|
retrieveApexInfo(File testApexFile, DeviceDescriptor deviceDescriptor)
Retrieves ApexInfo which contains packageName and versionCode from the given apex file. |
Constants
APEX_OPTION
protected static final String APEX_OPTION
Constant Value: "--apex"
APEX_SUFFIX
protected static final String APEX_SUFFIX
Constant Value: ".apex"
APK_SUFFIX
protected static final String APK_SUFFIX
Constant Value: ".apk"
APK_ZIP_OPTION
protected static final String APK_ZIP_OPTION
Constant Value: "--apks-zip"
CHILD_SESSION_CREATION_CMD
protected static final String CHILD_SESSION_CREATION_CMD
Constant Value: "pm install-create"
PARENT_SESSION_CREATION_CMD
protected static final String PARENT_SESSION_CREATION_CMD
Constant Value: "pm install-create --multi-package"
ROLLBACK_STATE_COMMITTED
public static final String ROLLBACK_STATE_COMMITTED
Constant Value: "committed"
ROLLBACK_STATE_UNKNOWN
public static final String ROLLBACK_STATE_UNKNOWN
Constant Value: "unknown"
SPLIT_APKS_SUFFIX
protected static final String SPLIT_APKS_SUFFIX
Constant Value: ".apks"
Fields
mTrainFolderPath
protected File mTrainFolderPath
Public constructors
InstallApexModuleTargetPreparer
public InstallApexModuleTargetPreparer ()
Public methods
getModulesToInstall
public List<File> 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<File> |
List |
| Throws | |
|---|---|
DeviceNotAvailableException |
when device is not available. |
TargetSetupError |
when mandatory modules are not installed, or module cannot be installed. |
setIgnoreIfNotPreloaded
public void setIgnoreIfNotPreloaded (boolean skip)
| Parameters | |
|---|---|
skip |
boolean |
setSkipApexTearDown
public void setSkipApexTearDown (boolean skip)
| Parameters | |
|---|---|
skip |
boolean |
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 |
|
DeviceRuntimeException |
|
Protected methods
addApksToTestFiles
protected void addApksToTestFiles ()
addStagedReadyTimeoutForAdb
protected void addStagedReadyTimeoutForAdb (List<String> cmd)
| Parameters | |
|---|---|
cmd |
List |
addTimeoutMillisForBundletool
protected void addTimeoutMillisForBundletool (List<String> extraArgs)
| Parameters | |
|---|---|
extraArgs |
List |
checkApexActivation
protected void checkApexActivation (ITestDevice device)
Check if all apexes are activated.
| Parameters | |
|---|---|
device |
ITestDevice: under test. |
| Throws | |
|---|---|
TargetSetupError |
if activation failed. |
DeviceNotAvailableException |
|
collectApexInfoFromApexModules
protected List<ITestDevice.ApexInfo> collectApexInfoFromApexModules (Map<File, String> testAppFileNames, TestInformation testInfo)
Collects apex info from the apex modules for activation check.
| Parameters | |
|---|---|
testAppFileNames |
Map: The list of the file names of the modules to install |
testInfo |
TestInformation: The TestInformation |
| Returns | |
|---|---|
List<ITestDevice.ApexInfo> |
a list containing the apexinfo of the apex modules in the input file lists |
| Throws | |
|---|---|
TargetSetupError |
|
getApkInstalled
protected List<String> getApkInstalled ()
| Returns | |
|---|---|
List<String> |
|
getBundletoolFileName
protected String getBundletoolFileName ()
| Returns | |
|---|---|
String |
|
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 List<ITestDevice.ApexInfo> getModulesFailToActivate (Set<ITestDevice.ApexInfo> activatedApexes)
Get modules that failed to be activated.
| Parameters | |
|---|---|
activatedApexes |
Set: The set of the active apexes on device |
| Returns | |
|---|---|
List<ITestDevice.ApexInfo> |
a list containing the apexinfo of the input apex modules that failed to be activated. |
| Throws | |
|---|---|
DeviceNotAvailableException |
|
TargetSetupError |
|
getSplitsForApks
protected List<File> getSplitsForApks (TestInformation testInfo, File moduleFile)
Extracts and returns splits for the specified apks.
| Parameters | |
|---|---|
testInfo |
TestInformation: the TestInformation |
moduleFile |
File: The module file to extract the splits from. |
| Returns | |
|---|---|
List<File> |
a File[] containing the splits. |
| Throws | |
|---|---|
TargetSetupError |
if bundletool cannot be found or device spec file fails to generate. |
initBundletoolUtil
protected void initBundletoolUtil (TestInformation testInfo)
Initializes the bundletool util for this class.
| Parameters | |
|---|---|
testInfo |
TestInformation: the TestInformation for the invocation. |
| Throws | |
|---|---|
TargetSetupError |
if bundletool cannot be found. |
installTrain
protected void installTrain (TestInformation testInfo, List<File> moduleFilenames)
Attempts to install a mainline train containing apex on the device.
| Parameters | |
|---|---|
testInfo |
TestInformation: the TestInformation |
moduleFilenames |
List: List of String. The list of filenames of the mainline modules to be
installed. |
| Throws | |
|---|---|
DeviceNotAvailableException |
|
TargetSetupError |
|
installUsingBundleTool
protected void installUsingBundleTool (TestInformation testInfo, List<File> testAppFileNames)
Attempts to install mainline module(s) using bundletool.
| Parameters | |
|---|---|
testInfo |
TestInformation: the TestInformation |
testAppFileNames |
List: the filenames of the preloaded modules to install. |
| Throws | |
|---|---|
DeviceNotAvailableException |
|
TargetSetupError |
|
installer
protected void installer (TestInformation testInfo, Map<File, String> testAppFileNames)
Attempt to install an package or split package on the device.
| Parameters | |
|---|---|
testInfo |
TestInformation: the TestInformation for the invocation |
testAppFileNames |
Map: The apks and their package to be installed. |
| 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. |