測試應用程式安裝設定

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