TestAppInstallSetup

public class TestAppInstallSetup
extends BaseTargetPreparer implements IAbiReceiver, IDiscoverDependencies, IIncrementalSetup

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()

如果 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)

設定是否應在 tearDown 時清除已安裝的 APK

void setForceQueryable(boolean forceQueryable)

強制可查詢的預設值為 true。

void setIncrementalSetupEnabled(boolean shouldEnable)

設定是否要在 TradeFed 準備者中啟用遞增設定。

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)

嘗試在裝置上安裝套件或分割套件。

String parsePackageName(File testAppFile)

從測試應用程式取得套件名稱。

resolveApkFiles(TestInformation testInfo, apkFiles)

輔助程式可將部分 APK 解析為檔案和套件。

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

嘗試從裝置中移除套件。

欄位

incrementalInstallSession

protected IncrementalInstallSession incrementalInstallSession

mBlockFilterPercentage

protected double mBlockFilterPercentage

mIncrementalInstallTimeout

protected int mIncrementalInstallTimeout

mIncrementalInstallation

protected boolean mIncrementalInstallation

公用建構函式

TestAppInstallSetup

public TestAppInstallSetup ()

公用方法

addInstallArg

public void addInstallArg (String arg)

新增要使用的 APK 安裝引數。

參數
arg String

addSplitApkFileNames

public void addSplitApkFileNames (String fileNames)

在字串中新增一組以 ',' 分隔的檔案名稱,以便以分割 APK 形式安裝

參數
fileNames String:以「,」分隔的檔案名稱字串

addTestFile

public void addTestFile (File file)

將檔案或目錄新增至要安裝的 APK 清單。

參數
file File

addTestFileName

public void addTestFileName (String fileName)

將檔案名稱新增至要安裝的 APK 清單。

參數
fileName String

getAbi

public IAbi getAbi ()

傳回
IAbi

getDevice

public ITestDevice getDevice ()

傳回預備者應套用的裝置。

傳回
ITestDevice

擲回
com.android.tradefed.targetprep.TargetSetupError
TargetSetupError

getTestInfo

public TestInformation getTestInfo ()

傳回
TestInformation

getTestsFileName

public  getTestsFileName ()

傳回指定測試 APK 名稱清單的副本。

傳回

isCleanUpEnabled

public boolean isCleanUpEnabled ()

如果 APK 會在拆解期間清除,則傳回 True。

傳回
boolean

isInstantMode

public final boolean isInstantMode ()

傳回是否已啟用即時模式安裝功能。

傳回
boolean

reportDependencies

public  reportDependencies ()

傳回

setAaptVersion

public void setAaptVersion (AaptParser.AaptVersion aaptVersion)

設定用於 APK 剖析的 AAPT 版本。

參數
aaptVersion AaptParser.AaptVersion

setAbi

public void setAbi (IAbi abi)

參數
abi IAbi

setAltDir

public void setAltDir (File altDir)

設定替代目錄。

參數
altDir File

setAltDirBehavior

public void setAltDirBehavior (AltDirBehavior altDirBehavior)

設定替代目錄行為。

參數
altDirBehavior AltDirBehavior

setCleanApk

public void setCleanApk (boolean shouldClean)

設定是否要在 tearDown 時清除已安裝的 APK

參數
shouldClean boolean

setForceQueryable

public void setForceQueryable (boolean forceQueryable)

強制可查詢的預設值為 true。如果要安裝的 APK 不應可供查詢,請將其更新為 false。

參數
forceQueryable boolean

setIncrementalSetupEnabled

public void setIncrementalSetupEnabled (boolean shouldEnable)

設定是否要在 TradeFed 準備者中啟用遞增設定。

參數
shouldEnable boolean

setInstantMode

public final void setInstantMode (boolean mode)

設定是否應在安裝 APK 時使用 --instant。如果已設定強制安裝模式,這項設定就不會生效。

參數
mode boolean

setShouldGrantPermission

public void setShouldGrantPermission (boolean shouldGrant)

如果提供 userId,則可為 APK 安裝作業設定 grantPermission。

參數
shouldGrant boolean

setUp

public void setUp (ITestDevice device, 
                IBuildInfo buildInfo)

This method is deprecated.
暫時回溯相容回呼。

參數
device ITestDevice

buildInfo IBuildInfo

擲回
BuildError
DeviceNotAvailableException
TargetSetupError

setUp

public void setUp (TestInformation testInfo)

參數
testInfo TestInformation

擲回
BuildError
DeviceNotAvailableException
TargetSetupError

setUserId

public void setUserId (int userId)

如果 APK 應安裝給特定使用者,請設定要安裝給哪位使用者的 ID。

參數
userId int

tearDown

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:增量安裝工作階段的建構工具物件。

擲回
com.android.tradefed.targetprep.TargetSetupError
TargetSetupError

安裝程式

protected void installer (TestInformation testInfo, 
                 appFilesAndPackages)

嘗試在裝置上安裝套件或分割套件。

參數
testInfo TestInformation:叫用作業的 TestInformation

appFilesAndPackages :要安裝的 APK 和套件。

擲回
DeviceNotAvailableException
TargetSetupError

parsePackageName

protected String parsePackageName (File testAppFile)

從測試應用程式取得套件名稱。

參數
testAppFile File

傳回
String

擲回
TargetSetupError

resolveApkFiles

protected  resolveApkFiles (TestInformation testInfo, 
                 apkFiles)

輔助程式,可將部分 APK 解析為檔案和套件。

參數
testInfo TestInformation

apkFiles

傳回

擲回
DeviceNotAvailableException
TargetSetupError

setTestInformation

protected void setTestInformation (TestInformation testInfo)

參數
testInfo TestInformation

uninstallPackage

protected void uninstallPackage (ITestDevice device, 
                String packageName)

嘗試從裝置中移除套件。

參數
device ITestDevice

packageName String

擲回
DeviceNotAvailableException