TestAppInstallSetup
public class TestAppInstallSetup
extends BaseTargetPreparer
implements IAbiReceiver , IDiscoverDependencies
java.lang.Object | ||
↳ | com.android.tradefed.targetprep.BaseTargetPreparer | |
↳ | com.android.tradefed.targetprep.TestAppInstallSetup |
将ITargetPreparer
IDeviceBuildInfo.getTestsDir()
文件夹中的一个或多个应用程序安装到设备上的 ITargetPreparer。
如果测试 zip 不存在或不包含所需的 apk,此准备程序将在备用目录中查找。搜索将按从指定的最后一个替代目录到第一个的顺序进行。
概括
字段 | |
---|---|
public static final String | RUN_TESTS_AS_USER_KEY |
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) 设置是否应在拆卸时清理已安装的 apk |
void | setForceQueryable (boolean forceQueryable) force queryable 的默认值为 true。 |
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) 根据构建信息中的测试工件信息解析实际的 apk 路径。 |
void | installPackageIncrementally (IncrementalInstallSession.Builder builder) 启动测试应用程序的增量安装会话。 |
void | installer ( TestInformation testInfo, appFilesAndPackages) installer ( TestInformation testInfo, appFilesAndPackages) 尝试在设备上安装包或拆分包。 |
String | parsePackageName (File testAppFile, DeviceDescriptor deviceDescriptor) 从测试应用程序获取包名称。 |
resolveApkFiles ( TestInformation testInfo, apkFiles) resolveApkFiles ( TestInformation testInfo, apkFiles) 帮助将一些 apk 解析为他们的文件和包。 | |
void | setTestInformation ( TestInformation testInfo) |
void | uninstallPackage ( ITestDevice device, String packageName) 尝试从设备中取出包装。 |
字段
RUN_TESTS_AS_USER_KEY
public static final String RUN_TESTS_AS_USER_KEY
增量安装会话
protected IncrementalInstallSession incrementalInstallSession
mBlockFilterPercentage
protected double mBlockFilterPercentage
mIncrementalInstallTimeout
protected int mIncrementalInstallTimeout
增量安装
protected boolean mIncrementalInstallation
公共构造函数
TestAppInstallSetup
public TestAppInstallSetup ()
公共方法
添加安装参数
public void addInstallArg (String arg)
添加一个要使用的 apk 安装参数。
参数 | |
---|---|
arg | String |
addSplitApkFileNames
public void addSplitApkFileNames (String fileNames)
在要作为拆分 apk 安装的字符串中添加一组文件名,除以“,”
参数 | |
---|---|
fileNames | String : 一串文件名除以',' |
添加测试文件
public void addTestFile (File file)
将文件或目录添加到要安装的 apk 列表中。
参数 | |
---|---|
file | File |
添加测试文件名
public void addTestFileName (String fileName)
将文件名添加到要安装的 apk 列表中。
参数 | |
---|---|
fileName | String |
获取测试文件名
publicgetTestsFileName ()
返回指定测试 apk 名称列表的副本。
退货 | |
---|---|
isCleanUpEnabled
public boolean isCleanUpEnabled ()
如果 Apk 在拆卸期间将被清理,则返回 True。
退货 | |
---|---|
boolean |
isInstantMode
public final boolean isInstantMode ()
返回是否已启用即时模式安装。
退货 | |
---|---|
boolean |
报告依赖项
publicreportDependencies ()
退货 | |
---|---|
设置Aapt版本
public void setAaptVersion (AaptParser.AaptVersion aaptVersion)
为 APK 解析设置 AAPT 的版本。
参数 | |
---|---|
aaptVersion | AaptParser.AaptVersion |
设置AltDir
public void setAltDir (File altDir)
设置备用目录。
参数 | |
---|---|
altDir | File |
setAltDirBehavior
public void setAltDirBehavior (AltDirBehavior altDirBehavior)
设置备用目录行为。
参数 | |
---|---|
altDirBehavior | AltDirBehavior |
setCleanApk
public void setCleanApk (boolean shouldClean)
设置是否应在拆卸时清理已安装的 apk
参数 | |
---|---|
shouldClean | boolean |
setForceQueryable
public void setForceQueryable (boolean forceQueryable)
force queryable 的默认值为 true。如果要安装的 apk 不可查询,请将其更新为 false。
参数 | |
---|---|
forceQueryable | boolean |
设置即时模式
public final void setInstantMode (boolean mode)
设置安装 apk 时是否应使用 --instant。如果设置了 force-install-mode 将无效。
参数 | |
---|---|
mode | boolean |
setShouldGrantPermission
public void setShouldGrantPermission (boolean shouldGrant)
如果提供了 userId,则可以为 apk 安装设置 grantPermission。
参数 | |
---|---|
shouldGrant | boolean |
设置
public void setUp (ITestDevice device, IBuildInfo buildInfo)
此方法已弃用。
临时向后兼容回调。
参数 | |
---|---|
device | ITestDevice |
buildInfo | IBuildInfo |
投掷 | |
---|---|
BuildError | |
DeviceNotAvailableException | |
TargetSetupError |
设置
public void setUp (TestInformation testInfo)
参数 | |
---|---|
testInfo | TestInformation |
投掷 | |
---|---|
BuildError | |
DeviceNotAvailableException | |
TargetSetupError |
设置用户 ID
public void setUserId (int userId)
如果应为特定用户安装 apk,请设置要为其安装的用户的 id。
参数 | |
---|---|
userId | int |
拆除
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)
根据构建信息中的测试工件信息解析实际的 apk 路径。
参数 | |
---|---|
testInfo | TestInformation :调用的TestInformation 。 |
apkFileName | String : 要安装的 apk 的文件名 |
退货 | |
---|---|
File | 一个ERROR(/File) 表示主机上的物理 apk 文件,如果文件不存在,则返回null 。 |
投掷 | |
---|---|
TargetSetupError |
installPackageIncrementally
protected void installPackageIncrementally (IncrementalInstallSession.Builder builder)
启动测试应用程序的增量安装会话。
参数 | |
---|---|
builder | IncrementalInstallSession.Builder :增量安装会话的 Builder 对象。 |
投掷 | |
---|---|
TargetSetupError |
安装程序
protected void installer (TestInformation testInfo,appFilesAndPackages)
尝试在设备上安装包或拆分包。
参数 | |
---|---|
testInfo | TestInformation : 调用的TestInformation |
appFilesAndPackages |
投掷 | |
---|---|
DeviceNotAvailableException | |
TargetSetupError |
解析包名
protected String parsePackageName (File testAppFile, DeviceDescriptor deviceDescriptor)
从测试应用程序获取包名称。
参数 | |
---|---|
testAppFile | File |
deviceDescriptor | DeviceDescriptor |
退货 | |
---|---|
String |
投掷 | |
---|---|
TargetSetupError |
解决 Apk 文件
protectedresolveApkFiles (TestInformation testInfo, apkFiles)
帮助将一些 apk 解析为他们的文件和包。
参数 | |
---|---|
testInfo | TestInformation |
apkFiles |
退货 | |
---|---|
投掷 | |
---|---|
DeviceNotAvailableException | |
TargetSetupError |
卸载包
protected void uninstallPackage (ITestDevice device, String packageName)
尝试从设备中取出包装。
参数 | |
---|---|
device | ITestDevice |
packageName | String |
投掷 | |
---|---|
DeviceNotAvailableException |