TestAppInstallSetup

public class TestAppInstallSetup
extends BaseTargetPreparer implements IAbiReceiver, IDiscoverDependencies, IIncrementalSetup

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


一种将 IDeviceBuildInfo.getTestsDir() 文件夹中的一个或多个应用安装到设备上的 ITargetPreparer

如果测试 zip 不存在或不包含所需的 APK,此准备器将在备用目录中查找。搜索将按从最后一个备选目录到第一个备选目录的顺序进行。

摘要

常量

String INSTALLED_PACKAGES_KEY

包含已安装 APK 的软件包名称(以逗号分隔列表形式)的 TestInformation 属性的键。

字段

protected double mBlockFilterPercentage

protected int mIncrementalInstallTimeout

protected boolean mIncrementalInstallation

公共构造函数

TestAppInstallSetup()

公共方法

void addInstallArg(String arg)

添加要使用的一个 APK 安装实参。

void addSplitApkFileNames(String fileNames)

添加一组以“,”分隔的文件名(以字符串形式),以便作为拆分 APK 进行安装

void addTestFile(File file)

将文件或目录添加到要安装的 APK 列表。

void addTestFileName(String fileName)

向要安装的 APK 列表添加文件名。

IAbi getAbi()
ITestDevice getDevice()

返回准备器应应用于的设备。

TestInformation getTestInfo()
List<File> getTestsFileName()

返回指定测试 APK 名称列表的副本。

boolean isCleanUpEnabled()

如果在拆解期间清理 APK,则返回 True。

final boolean isInstantMode()

返回是否已启用即时模式安装。

Set<String> reportDependencies()
void setAaptVersion(AaptParser.AaptVersion aaptVersion)

设置用于解析 APK 的 AAPT 版本。

void setAbi(IAbi abi)
void setAltDir(File altDir)

设置备用目录。

void setAltDirBehavior(AltDirBehavior altDirBehavior)

设置备用目录行为。

void setCleanApk(boolean shouldClean)

设置是否应在 tearDown 时清理已安装的 APK

void setForceQueryable(boolean forceQueryable)

强制可查询的默认值为 true。

void setIncrementalSetupEnabled(boolean shouldEnable)

设置是否在 TradeFed preparer 上启用增量设置。

final void setInstantMode(boolean mode)

设置在安装 APK 时是否应使用 --instant。

void setShouldGrantPermission(boolean shouldGrant)

如果提供了 userId,则可以为 APK 安装设置 grantPermission。

void setUp(ITestDevice device, IBuildInfo buildInfo)

此方法已废弃。 临时向后兼容回调。

void setUp(TestInformation testInfo)

void setUserId(int userId)

如果应为特定用户安装 APK,则设置要安装的用户 ID。

void tearDown(TestInformation testInfo, Throwable e)

受保护的方法

File getLocalPathForFilename(TestInformation testInfo, String apkFileName)

根据 build 信息中的测试制品信息解析实际的 APK 路径。

void installer(TestInformation testInfo, Map<File, String> appFilesAndPackages)

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

String parsePackageName(File testAppFile)

从测试应用获取软件包名称。

Map<File, String> resolveApkFiles(TestInformation testInfo, List<File> apkFiles)

用于将某些 APK 解析为相应的文件和软件包的辅助程序。

void setTestInformation(TestInformation testInfo)
void uninstallPackage(ITestDevice device, String packageName)

尝试从设备中移除软件包。

常量

INSTALLED_PACKAGES_KEY

public static final String INSTALLED_PACKAGES_KEY

包含已安装 APK 的软件包名称(以逗号分隔列表形式)的 TestInformation 属性的键。用于将已安装软件包的列表传达给其他准备器,例如 RunOnSecondaryUserTargetPreparer

常量值: "INSTALLED_PACKAGES_KEY"

字段

mBlockFilterPercentage

protected double mBlockFilterPercentage

mIncrementalInstallTimeout

protected int mIncrementalInstallTimeout

mIncrementalInstallation

protected boolean mIncrementalInstallation

公共构造函数

TestAppInstallSetup

public TestAppInstallSetup ()

公共方法

addInstallArg

public void addInstallArg (String arg)

添加要使用的一个 APK 安装实参。

参数
arg String

addSplitApkFileNames

public void addSplitApkFileNames (String fileNames)

添加一组以“,”分隔的文件名(以字符串形式),以便作为拆分 APK 进行安装

参数
fileNames String:以“,”分隔的文件名字符串

addTestFile

public void addTestFile (File file)

将文件或目录添加到要安装的 APK 列表。

参数
file File

addTestFileName

public void addTestFileName (String fileName)

向要安装的 APK 列表添加文件名。

参数
fileName String

getAbi

public IAbi getAbi ()

返回
IAbi

getDevice

public ITestDevice getDevice ()

返回准备器应应用到的设备。

返回
ITestDevice

抛出
com.android.tradefed.targetprep.TargetSetupError
TargetSetupError

getTestInfo

public TestInformation getTestInfo ()

返回
TestInformation

getTestsFileName

public List<File> getTestsFileName ()

返回指定测试 APK 名称列表的副本。

返回
List<File>

isCleanUpEnabled

public boolean isCleanUpEnabled ()

如果在拆解期间清理 APK,则返回 True。

返回
boolean

isInstantMode

public final boolean isInstantMode ()

返回是否已启用即时模式安装。

返回
boolean

reportDependencies

public Set<String> reportDependencies ()

返回
Set<String>

setAaptVersion

public void setAaptVersion (AaptParser.AaptVersion aaptVersion)

设置用于解析 APK 的 AAPT 版本。

参数
aaptVersion AaptParser.AaptVersion

setAbi

public void setAbi (IAbi abi)

参数
abi IAbi

setAltDir

public void setAltDir (File altDir)

设置备用目录。

参数
altDir File

setAltDirBehavior

public void setAltDirBehavior (AltDirBehavior altDirBehavior)

设置备用目录行为。

参数
altDirBehavior AltDirBehavior

setCleanApk

public void setCleanApk (boolean shouldClean)

设置是否应在 tearDown 时清理已安装的 APK

参数
shouldClean boolean

setForceQueryable

public void setForceQueryable (boolean forceQueryable)

强制可查询的默认值为 true。如果待安装的 APK 不应可查询,请将其更新为 false。

参数
forceQueryable boolean

setIncrementalSetupEnabled

public void setIncrementalSetupEnabled (boolean shouldEnable)

设置是否在 TradeFed preparer 上启用增量设置。

参数
shouldEnable boolean

setInstantMode

public final void setInstantMode (boolean mode)

设置在安装 APK 时是否应使用 --instant。如果设置了 force-install-mode,则不会产生任何影响。

参数
mode boolean

setShouldGrantPermission

public void setShouldGrantPermission (boolean shouldGrant)

如果提供了 userId,则可以为 APK 安装设置 grantPermission。

参数
shouldGrant boolean

setUp

public void setUp (ITestDevice device, 
                IBuildInfo buildInfo)

此方法已废弃。
临时向后兼容的回调。

参数
device ITestDevice

buildInfo IBuildInfo

抛出
BuildError
DeviceNotAvailableException
TargetSetupError

setUp

public void setUp (TestInformation testInfo)

参数
testInfo TestInformation

抛出
BuildError
DeviceNotAvailableException
TargetSetupError

setUserId

public void setUserId (int userId)

如果应为特定用户安装 APK,则设置要安装的用户 ID。

参数
userId int

tearDown

public void tearDown (TestInformation testInfo, 
                Throwable e)

参数
testInfo TestInformation

e Throwable

抛出
DeviceNotAvailableException

受保护的方法

getLocalPathForFilename

protected File getLocalPathForFilename (TestInformation testInfo, 
                String apkFileName)

根据 build 信息中的测试制品信息解析实际的 APK 路径。

参数
testInfo TestInformation:调用的 TestInformation

apkFileName String:要安装的 APK 的文件名

返回
File 一个 File,表示主机上的实际 APK 文件;如果该文件不存在,则为 null

抛出
TargetSetupError

安装者

protected void installer (TestInformation testInfo, 
                Map<File, String> appFilesAndPackages)

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

参数
testInfo TestInformation:调用的 TestInformation

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

抛出
DeviceNotAvailableException
TargetSetupError

parsePackageName

protected String parsePackageName (File testAppFile)

从测试应用获取软件包名称。

参数
testAppFile File

返回
String

抛出
TargetSetupError

resolveApkFiles

protected Map<File, String> resolveApkFiles (TestInformation testInfo, 
                List<File> apkFiles)

用于将某些 APK 解析为相应的文件和软件包的辅助程序。

参数
testInfo TestInformation

apkFiles List

返回
Map<File, String>

抛出
DeviceNotAvailableException
TargetSetupError

setTestInformation

protected void setTestInformation (TestInformation testInfo)

参数
testInfo TestInformation

uninstallPackage

protected void uninstallPackage (ITestDevice device, 
                String packageName)

尝试从设备中移除软件包。

参数
device ITestDevice

packageName String

抛出
DeviceNotAvailableException