测试应用程序安装设置

public class TestAppInstallSetup
extends BaseTargetPreparer implements IAbiReceiver , IDiscoverDependencies

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


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

如果测试 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 ()

如果 Apks 在拆卸过程中被清理,则返回 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)

强制可查询的默认值为 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)

从测试应用程序获取包名称。

resolveApkFiles ( TestInformation testInfo, apkFiles) resolveApkFiles ( TestInformation testInfo, apkFiles)

帮助将一些 apk 解析为其文件和包。

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

尝试从设备中取出包装。

领域

增量安装会话

protected IncrementalInstallSession incrementalInstallSession

mBlockFilterPercentage

protected double mBlockFilterPercentage

mIncrementalInstallTimeout

protected int mIncrementalInstallTimeout

m增量安装

protected boolean mIncrementalInstallation

公共构造函数

测试应用程序安装设置

public TestAppInstallSetup ()

公共方法

添加安装参数

public void addInstallArg (String arg)

添加一个要使用的 apk 安装参数。

参数
arg String

添加SplitApk文件名

public void addSplitApkFileNames (String fileNames)

在要作为拆分 apk 安装的字符串中添加一组用“,”分隔的文件名

参数
fileNames String : 文件名除以 ',' 的字符串

添加测试文件

public void addTestFile (File file)

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

参数
file File

添加测试文件名

public void addTestFileName (String fileName)

将文件名添加到要安装的 apk 列表中。

参数
fileName String

获取阿比

public IAbi getAbi ()

退货
IAbi

获取设备

public ITestDevice getDevice ()

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

退货
ITestDevice

投掷
com.android.tradefed.targetprep.TargetSetupError
TargetSetupError

获取测试信息

public TestInformation getTestInfo ()

退货
TestInformation

获取测试文件名

public  getTestsFileName ()

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

退货

是否启用清理

public boolean isCleanUpEnabled ()

如果 Apks 在拆卸过程中被清理,则返回 True。

退货
boolean

是即时模式

public final boolean isInstantMode ()

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

退货
boolean

报告依赖关系

public  reportDependencies ()

退货

设置Aapt版本

public void setAaptVersion (AaptParser.AaptVersion aaptVersion)

设置 APK 解析的 AAPT 版本。

参数
aaptVersion AaptParser.AaptVersion

设置阿比

public void setAbi (IAbi abi)

参数
abi IAbi

设置备用目录

public void setAltDir (File altDir)

设置备用目录。

参数
altDir File

setAltDir行为

public void setAltDirBehavior (AltDirBehavior altDirBehavior)

设置备用目录行为。

参数
altDirBehavior AltDirBehavior

设置清理应用程序

public void setCleanApk (boolean shouldClean)

设置是否应在拆卸时清理已安装的 apk

参数
shouldClean boolean

设置强制可查询

public void setForceQueryable (boolean forceQueryable)

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

参数
forceQueryable boolean

设置即时模式

public final void setInstantMode (boolean mode)

设置安装 apk 时是否使用 --instant。如果设置了force-install-mode,则不会有任何效果。

参数
mode boolean

设置ShouldGrantPermission

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

受保护的方法

获取增量安装会话构建器

protected IncrementalInstallSession.Builder getIncrementalInstallSessionBuilder ()

初始化会话构建器以增量安装测试应用程序。

退货
IncrementalInstallSession.Builder

获取文件名的本地路径

protected File getLocalPathForFilename (TestInformation testInfo, 
                String apkFileName)

根据构建信息中的测试工件信息解析实际的 apk 路径。

参数
testInfo TestInformation :调用的TestInformation

apkFileName String : 要安装的 apk 文件名

退货
File ERROR(/File)表示主机上的物理 apk 文件,如果文件不存在则为null

投掷
TargetSetupError

增量安装包

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

解析包名

protected String parsePackageName (File testAppFile)

从测试应用程序获取包名称。

参数
testAppFile File

退货
String

投掷
TargetSetupError

解析Apk文件

protected  resolveApkFiles (TestInformation testInfo, 
                 apkFiles)

帮助将一些 apk 解析为其文件和包。

参数
testInfo TestInformation

apkFiles

退货

投掷
DeviceNotAvailableException
TargetSetupError

设置测试信息

protected void setTestInformation (TestInformation testInfo)

参数
testInfo TestInformation

卸载包

protected void uninstallPackage (ITestDevice device, 
                String packageName)

尝试从设备中取出包装。

参数
device ITestDevice

packageName String

投掷
DeviceNotAvailableException