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 double mBlockFilterPercentage

protected int mIncrementalInstallTimeout

protected boolean mIncrementalInstallation

公用建構函式

TestAppInstallSetup()

公用方法

void addInstallArg(String arg)

Adds one apk installation arg to be used.

void addSplitApkFileNames(String fileNames)

在字串中新增以「,」分隔的一組檔案名稱,做為要安裝的分割 APK

void addTestFile(File file)

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

void addTestFileName(String fileName)

Adds a file name to the list of apks to installed.

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)

Sets whether or not the installed apk should be cleaned on tearDown

void setForceQueryable(boolean forceQueryable)

force queryable 的預設值為 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)

受保護的方法

File getLocalPathForFilename(TestInformation testInfo, String apkFileName)

根據建構資訊內的測試構件資訊,解析實際的 APK 路徑。

void installer(TestInformation testInfo, appFilesAndPackages)

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

String parsePackageName(File testAppFile)

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

resolveApkFiles(TestInformation testInfo, apkFiles)

Helper to resolve some apk to their File and Package.

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

嘗試從裝置中移除套件。

欄位

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)

Adds a set of file names divided by ',' in a string to be installed as split apks

參數
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)

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

參數
forceQueryable boolean

setIncrementalSetupEnabled

public void setIncrementalSetupEnabled (boolean shouldEnable)

設定是否要在 TradeFed 準備工具上啟用增量設定。

參數
shouldEnable boolean

setInstantMode

public final void setInstantMode (boolean mode)

設定安裝 APK 時是否要使用 --instant。如果設定了 force-install-mode,這項政策不會有任何作用。

參數
mode boolean

setShouldGrantPermission

public void setShouldGrantPermission (boolean shouldGrant)

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

參數
shouldGrant boolean

setUp

public void setUp (ITestDevice device, 
                IBuildInfo buildInfo)

這個方法已淘汰。
暫時回溯相容的回呼。

參數
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

受保護的方法

getLocalPathForFilename

protected File getLocalPathForFilename (TestInformation testInfo, 
                String apkFileName)

根據建構資訊中的測試構件資訊,解析實際的 APK 路徑。

參數
testInfo TestInformation:叫用的 TestInformation

apkFileName String:要安裝的 APK 檔案名稱

傳回
File 代表主機上實際 APK 檔案的 ERROR(/File),或檔案不存在時的 null

擲回
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)

Helper to resolve some apk to their File and Package.

參數
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