测试应用程序安装设置

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)

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)

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

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

添加 SplitApkFileNames

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 名称列表的副本。

退货

isCleanUpEnabled

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

设置Abi

public void setAbi (IAbi abi)

参数
abi IAbi

设置替代目录

public void setAltDir (File altDir)

设置备用目录。

参数
altDir File

设置 AltDir 行为

public void setAltDirBehavior (AltDirBehavior altDirBehavior)

设置备用目录行为。

参数
altDirBehavior AltDirBehavior

设置CleanApk

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。如果设置了强制安装模式,则不会有任何效果。

参数
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表示主机上物理 apk 文件的ERROR(/File)如果文件不存在则为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

解析包名

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