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


摘要

常量

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

字段

protected File mTrainFolderPath

公共构造函数

InstallApexModuleTargetPreparer()

公共方法

getModulesToInstall(TestInformation testInfo)

根据设备上预加载的模块,获取应安装在模块序列上的模块。

void setIgnoreIfNotPreloaded(boolean skip)
void setSkipApexTearDown(boolean skip)
void setUp(TestInformation testInfo)

void tearDown(TestInformation testInfo, Throwable e)

受保护的方法

void addApksToTestFiles()
void addStagedReadyTimeoutForAdb( cmd)
void addTimeoutMillisForBundletool( extraArgs)
void checkApexActivation(ITestDevice device)

检查所有 APEX 是否都已激活。

collectApexInfoFromApexModules( testAppFileNames, TestInformation testInfo)

从 apex 模块收集 apex 信息以进行激活检查。

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

获取关键字(例如,从 APEX 软件包名称中提取模块名称(例如,com.android.tzdata.apex 的“tzdata”)。

getModulesFailToActivate( activatedApexes)

获取未能成功激活的模块。

getSplitsForApks(TestInformation testInfo, File moduleFile)

提取并返回指定 APK 的拆分。

void initBundletoolUtil(TestInformation testInfo)

为此类初始化 bundletool 实用程序。

void installTrain(TestInformation testInfo, moduleFilenames)

尝试在设备上安装包含 APEX 的 Mainline 模块序列。

void installUsingBundleTool(TestInformation testInfo, testAppFileNames)

尝试使用 bundletool 安装 Mainline 模块。

void installer(TestInformation testInfo, testAppFileNames)

尝试在设备上安装软件包或拆分软件包。

ITestDevice.ApexInfo retrieveApexInfo(File testApexFile, DeviceDescriptor deviceDescriptor)

从给定的 APEX 文件中检索包含 packageName 和 versionCode 的 ApexInfo。

常量

APEX_OPTION

protected static final String APEX_OPTION

常量值: "--apex"

APEX_SUFFIX

protected static final String APEX_SUFFIX

常量值: ".apex"

APK_SUFFIX

protected static final String APK_SUFFIX

常量值: ".apk"

APK_ZIP_OPTION

protected static final String APK_ZIP_OPTION

常量值: "--apks-zip"

CHILD_SESSION_CREATION_CMD

protected static final String CHILD_SESSION_CREATION_CMD

常量值: “pm install-create”

PARENT_SESSION_CREATION_CMD

protected static final String PARENT_SESSION_CREATION_CMD

常量值: “pm install-create --multi-package”

ROLLBACK_STATE_COMMITTED

public static final String ROLLBACK_STATE_COMMITTED

常量值: "committed"

ROLLBACK_STATE_UNKNOWN

public static final String ROLLBACK_STATE_UNKNOWN

常量值: "unknown"

SPLIT_APKS_SUFFIX

protected static final String SPLIT_APKS_SUFFIX

常量值: ".apks"

字段

mTrainFolderPath

protected File mTrainFolderPath

公共构造函数

InstallApexModuleTargetPreparer

public InstallApexModuleTargetPreparer ()

公共方法

getModulesToInstall

public  getModulesToInstall (TestInformation testInfo)

根据设备上预加载的模块,获取应安装在模块序列上的模块。未预加载的模块将不会安装。

参数
testInfo TestInformationTestInformation

返回
应安装在设备上的模块的列表

抛出
DeviceNotAvailableException 当设备不可用时。
TargetSetupError 当未安装必需模块或无法安装模块时。

setIgnoreIfNotPreloaded

public void setIgnoreIfNotPreloaded (boolean skip)

参数
skip boolean

setSkipApexTearDown

public void setSkipApexTearDown (boolean skip)

参数
skip boolean

setUp

public void setUp (TestInformation testInfo)

参数
testInfo TestInformation

抛出
BuildError
DeviceNotAvailableException
TargetSetupError

tearDown

public void tearDown (TestInformation testInfo, 
                Throwable e)

参数
testInfo TestInformation

e Throwable

抛出
DeviceNotAvailableException
DeviceRuntimeException

受保护的方法

addApksToTestFiles

protected void addApksToTestFiles ()

addStagedReadyTimeoutForAdb

protected void addStagedReadyTimeoutForAdb ( cmd)

参数
cmd

addTimeoutMillisForBundletool

protected void addTimeoutMillisForBundletool ( extraArgs)

参数
extraArgs

checkApexActivation

protected void checkApexActivation (ITestDevice device)

检查所有 apex 是否已激活。

参数
device ITestDevice:正在测试。

抛出
TargetSetupError 如果激活失败。
DeviceNotAvailableException

collectApexInfoFromApexModules

protected  collectApexInfoFromApexModules ( testAppFileNames, 
                TestInformation testInfo)

从 apex 模块收集 apex 信息以进行激活检查。

参数
testAppFileNames :要安装的模块的文件名列表

testInfo TestInformationTestInformation

返回
一个列表,其中包含输入文件列表中的 APEX 模块的 apexinfo

抛出
TargetSetupError

getApkInstalled

protected  getApkInstalled ()

返回

getBundletoolFileName

protected String getBundletoolFileName ()

返回
String

getBundletoolUtil

protected BundletoolUtil getBundletoolUtil ()

返回
BundletoolUtil

getModuleKeywordFromApexPackageName

protected String getModuleKeywordFromApexPackageName (String packageName)

获取关键字(例如,从 APEX 软件包名称中提取模块名称(例如,com.android.tzdata.apex 的“tzdata”)。

参数
packageName String:apex 文件的软件包名称。

返回
String 字符串。apex 软件包名称的关键字。

getModulesFailToActivate

protected  getModulesFailToActivate ( activatedApexes)

获取未能成功激活的模块。

参数
activatedApexes :设备上的一组有效 apex

返回
一个列表,其中包含未能成功激活的输入 apex 模块的 apexinfo。

抛出
DeviceNotAvailableException
TargetSetupError

getSplitsForApks

protected  getSplitsForApks (TestInformation testInfo, 
                File moduleFile)

提取并返回指定 APK 的拆分。

参数
testInfo TestInformationTestInformation

moduleFile File:要从中提取拆分的模块文件。

返回
包含拆分的 File[]。

抛出
TargetSetupError 如果找不到 bundletool 或设备规范文件生成失败。

initBundletoolUtil

protected void initBundletoolUtil (TestInformation testInfo)

为此类初始化 bundletool 实用程序。

参数
testInfo TestInformation:调用的 TestInformation

抛出
TargetSetupError 如果找不到 bundletool。

installTrain

protected void installTrain (TestInformation testInfo, 
                 moduleFilenames)

尝试在设备上安装包含 APEX 的 Mainline 模块序列。

参数
testInfo TestInformationTestInformation

moduleFilenames :字符串列表。要安装的 Mainline 模块的文件名列表。

抛出
DeviceNotAvailableException
TargetSetupError

使用 BundleTool 进行安装

protected void installUsingBundleTool (TestInformation testInfo, 
                 testAppFileNames)

尝试使用 bundletool 安装 Mainline 模块。

参数
testInfo TestInformationTestInformation

testAppFileNames :要安装的预加载模块的文件名。

抛出
DeviceNotAvailableException
TargetSetupError

安装者

protected void installer (TestInformation testInfo, 
                 testAppFileNames)

尝试在设备上安装软件包或拆分软件包。

参数
testInfo TestInformation:调用的 TestInformation

testAppFileNames :要安装的 APK 及其软件包。

抛出
DeviceNotAvailableException
TargetSetupError

retrieveApexInfo

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

从给定的 APEX 文件中检索包含 packageName 和 versionCode 的 ApexInfo。

参数
testApexFile File:我们从中检索信息的 apex 文件。

deviceDescriptor DeviceDescriptor

返回
ITestDevice.ApexInfo 一个 ApexInfo,包含指定文件的 packageName 和 versionCode

抛出
TargetSetupError 如果 aapt 解析器未能解析文件。