自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
InstallApkSetup
public
class
InstallApkSetup
extends BaseTargetPreparer
用于安装文件系统中一个或多个 apk 的 ITargetPreparer
。
仅当测试的所有版本都依赖于文件系统中的 APK 时,才应使用此类从文件系统安装 APK。对于使用 TestAppInstallSetup
从测试 ZIP 文件安装 APK 的测试,请使用 --alt-dir
在文件系统上指定包含 APK 的其他测试配置(例如,不存在测试 ZIP 文件的本地运行)的替代目录。
摘要
公共构造函数
InstallApkSetup
public InstallApkSetup ()
公共方法
setApkPaths
public void setApkPaths ( paths)
设置 APK 路径。公开以供测试。
setThrowIfInstallFail
public void setThrowIfInstallFail (boolean throwIfInstallFail)
如果安装失败,则设置抛出。公开以供测试。
参数 |
throwIfInstallFail |
boolean |
setUp
public void setUp (ITestDevice device,
IBuildInfo buildInfo)
参数 |
device |
ITestDevice |
buildInfo |
IBuildInfo |
受保护的方法
getApkPaths
protected getApkPaths ()
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# InstallApkSetup\n===============\n\n\n`\npublic\n\n\nclass\nInstallApkSetup\n`\n\n\n`\n\n\n`\n\n`\n\nextends `[BaseTargetPreparer](../../../../../../reference/tradefed/com/android/tradefed/targetprep/BaseTargetPreparer.html)`\n\n\n`\n\n`\n\n\n`\n\n|---|---|-------------------------------------------------|\n| java.lang.Object |||\n| ↳ | [com.android.tradefed.targetprep.BaseTargetPreparer](../../../../../../reference/tradefed/com/android/tradefed/targetprep/BaseTargetPreparer.html) ||\n| | ↳ | com.android.tradefed.targetprep.InstallApkSetup |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nA [ITargetPreparer](../../../../../../reference/tradefed/com/android/tradefed/targetprep/ITargetPreparer.html) that installs one or more apks located on the filesystem.\n\nThis class should only be used for installing apks from the filesystem when all versions of\nthe test rely on the apk being on the filesystem. For tests which use [TestAppInstallSetup](../../../../../../reference/tradefed/com/android/tradefed/targetprep/TestAppInstallSetup.html)\nto install apks from the tests zip file, use `--alt-dir` to specify an alternate directory\non the filesystem containing the apk for other test configurations (for example, local runs where\nthe tests zip file is not present).\n\nSummary\n-------\n\n| ### Public constructors ||\n|----------------------------------------------------------------------------------------------------------------------------------------|---|\n| ` `[InstallApkSetup](../../../../../../reference/tradefed/com/android/tradefed/targetprep/InstallApkSetup.html#InstallApkSetup())`() ` |\n\n| ### Public methods ||\n|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` void` | ` `[setApkPaths](../../../../../../reference/tradefed/com/android/tradefed/targetprep/InstallApkSetup.html#setApkPaths(\u003cany\u003e))`(` paths) Sets APK paths. |\n| ` void` | ` `[setThrowIfInstallFail](../../../../../../reference/tradefed/com/android/tradefed/targetprep/InstallApkSetup.html#setThrowIfInstallFail(boolean))`(boolean throwIfInstallFail) ` Set throw if install fail. |\n| ` void` | ` `[setUp](../../../../../../reference/tradefed/com/android/tradefed/targetprep/InstallApkSetup.html#setUp(com.android.tradefed.device.ITestDevice,%20com.android.tradefed.build.IBuildInfo))`(`[ITestDevice](../../../../../../reference/tradefed/com/android/tradefed/device/ITestDevice.html)` device, `[IBuildInfo](../../../../../../reference/tradefed/com/android/tradefed/build/IBuildInfo.html)` buildInfo) ` |\n\n| ### Protected methods ||\n|-----|--------------------------------------------------------------------------------------------------------------------------------|\n| ` ` | ` `[getApkPaths](../../../../../../reference/tradefed/com/android/tradefed/targetprep/InstallApkSetup.html#getApkPaths())`() ` |\n\nPublic constructors\n-------------------\n\n### InstallApkSetup\n\n```\npublic InstallApkSetup ()\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nPublic methods\n--------------\n\n### setApkPaths\n\n```\npublic void setApkPaths ( paths)\n```\n\nSets APK paths. Exposed for testing.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------|--------|\n| `paths` | \u003cbr /\u003e |\n\n### setThrowIfInstallFail\n\n```\npublic void setThrowIfInstallFail (boolean throwIfInstallFail)\n```\n\nSet throw if install fail. Exposed for testing.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|----------------------|------------------|\n| `throwIfInstallFail` | `boolean` \u003cbr /\u003e |\n\n### setUp\n\n```\npublic void setUp (ITestDevice device, \n IBuildInfo buildInfo)\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-------------|----------------------|\n| `device` | `ITestDevice` \u003cbr /\u003e |\n| `buildInfo` | `IBuildInfo` \u003cbr /\u003e |\n\n| Throws ||\n|----------------------------------------------------------------------------------------------------------------------------------|---|\n| [BuildError](../../../../../../reference/tradefed/com/android/tradefed/targetprep/BuildError.html) | |\n| [DeviceNotAvailableException](../../../../../../reference/tradefed/com/android/tradefed/device/DeviceNotAvailableException.html) | |\n| [TargetSetupError](../../../../../../reference/tradefed/com/android/tradefed/targetprep/TargetSetupError.html) | |\n\nProtected methods\n-----------------\n\n### getApkPaths\n\n```\nprotected getApkPaths ()\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|--------|\n| | \u003cbr /\u003e |"]]