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,此准备程序将在其他目录中查找。搜索将按从最后一个指定的备选目录到第一个备选目录的顺序进行。
摘要
字段 | |
---|---|
protected
IncrementalInstallSession |
incrementalInstallSession
|
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()
|
|
getTestsFileName()
返回指定测试 apk 名称列表的副本。 |
boolean
|
isCleanUpEnabled()
如果在拆解期间要清理 APK,则返回 True。 |
final
boolean
|
isInstantMode()
返回是否已启用即时模式安装。 |
|
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 准备者中启用增量设置。 |
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)
|
受保护的方法 | |
---|---|
IncrementalInstallSession.Builder
|
getIncrementalInstallSessionBuilder()
初始化会话构建器以增量安装测试应用。 |
File
|
getLocalPathForFilename(TestInformation testInfo, String apkFileName)
根据 build 信息中的测试工件信息解析实际 APK 路径。 |
void
|
installPackageIncrementally(IncrementalInstallSession.Builder builder)
为测试应用启动增量安装会话。 |
void
|
installer(TestInformation testInfo,
尝试在设备上安装软件包或分屏软件包。 |
String
|
parsePackageName(File testAppFile)
从测试应用获取软件包名称。 |
|
resolveApkFiles(TestInformation testInfo,
用于将某些 apk 解析为其文件和软件包的帮助程序。 |
void
|
setTestInformation(TestInformation testInfo)
|
void
|
uninstallPackage(ITestDevice device, String packageName)
尝试从设备中移除该软件包。 |
字段
incrementalInstallSession
protected IncrementalInstallSession incrementalInstallSession
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 |
getDevice
public ITestDevice getDevice ()
返回应应用准备程序的设备。
返回 | |
---|---|
ITestDevice |
抛出 | |
---|---|
|
com.android.tradefed.targetprep.TargetSetupError |
TargetSetupError |
getTestsFileName
publicgetTestsFileName ()
返回指定测试 apk 名称列表的副本。
返回 | |
---|---|
|
isCleanUpEnabled
public boolean isCleanUpEnabled ()
如果在拆解期间要清理 APK,则返回 true。
返回 | |
---|---|
boolean |
isInstantMode
public final boolean isInstantMode ()
返回是否已启用即时模式安装。
返回 | |
---|---|
boolean |
reportDependencies
publicreportDependencies ()
返回 | |
---|---|
|
setAaptVersion
public void setAaptVersion (AaptParser.AaptVersion aaptVersion)
设置用于 APK 解析的 AAPT 版本。
参数 | |
---|---|
aaptVersion |
AaptParser.AaptVersion |
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 准备者中启用增量设置。
参数 | |
---|---|
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 |
受保护的方法
getIncrementalInstallSessionBuilder
protected IncrementalInstallSession.Builder getIncrementalInstallSessionBuilder ()
初始化会话构建器,以增量安装测试应用。
返回 | |
---|---|
IncrementalInstallSession.Builder |
getLocalPathForFilename
protected File getLocalPathForFilename (TestInformation testInfo, String apkFileName)
根据 build 信息中的测试工件信息解析实际 APK 路径。
参数 | |
---|---|
testInfo |
TestInformation :调用的 TestInformation 。 |
apkFileName |
String :要安装的 apk 的文件名 |
返回 | |
---|---|
File |
一个 ERROR(/File) ,表示主机上的实际 APK 文件;如果该文件不存在,则为 null 。 |
抛出 | |
---|---|
TargetSetupError |
installPackageIncrementally
protected void installPackageIncrementally (IncrementalInstallSession.Builder builder)
为测试应用启动增量安装会话。
参数 | |
---|---|
builder |
IncrementalInstallSession.Builder :增量安装会话的 Builder 对象。 |
抛出 | |
---|---|
|
com.android.tradefed.targetprep.TargetSetupError |
TargetSetupError |
安装者
protected void installer (TestInformation testInfo,appFilesAndPackages)
尝试在设备上安装软件包或分屏软件包。
参数 | |
---|---|
testInfo |
TestInformation :调用的 TestInformation |
appFilesAndPackages |
:要安装的 apk 及其软件包。 |
抛出 | |
---|---|
DeviceNotAvailableException |
|
TargetSetupError |
parsePackageName
protected String parsePackageName (File testAppFile)
从测试应用获取软件包名称。
参数 | |
---|---|
testAppFile |
File |
返回 | |
---|---|
String |
抛出 | |
---|---|
TargetSetupError |
resolveApkFiles
protectedresolveApkFiles (TestInformation testInfo, apkFiles)
用于将某些 apk 解析为其文件和软件包的帮助程序。
参数 | |
---|---|
testInfo |
TestInformation |
apkFiles |
|
返回 | |
---|---|
|
抛出 | |
---|---|
DeviceNotAvailableException |
|
TargetSetupError |
setTestInformation
protected void setTestInformation (TestInformation testInfo)
参数 | |
---|---|
testInfo |
TestInformation |
uninstallPackage
protected void uninstallPackage (ITestDevice device, String packageName)
尝试从设备中移除软件包。
参数 | |
---|---|
device |
ITestDevice |
packageName |
String |
抛出 | |
---|---|
DeviceNotAvailableException |