測試應用程序安裝設置

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