BundletoolUtil

public class BundletoolUtil
extends Object

java.lang.Object
   ↳ com.android.tradefed.util.BundletoolUtil


使用 bundletool 命令行在设备上安装 .apks 的实用程序类。Bundletool 文档链接:https://developer.android.com/studio/command-line/bundletool bundletool.jar 是从非捆绑模块分支下载的,与模块文件一起下载。

摘要

公共构造函数

BundletoolUtil(File bundletoolJar)

公共方法

File extractSplitsFromApks(File apks, String deviceSpecPath, ITestDevice device, IBuildInfo buildInfo)

从 .apks 中提取拆分 APK/APEX。

String generateDeviceSpecFile(ITestDevice device)

为已连接的设备配置生成 JSON 文件。

void installApks(File apks, ITestDevice device, List<String> extraArgs)

安装使用 bundletool 的 APK .apks。

void installApks(File apks, ITestDevice device)

安装使用 bundletool 的 APK .apks。

void installApksFromZip(File apksZip, ITestDevice device, List<String> extraArgs)

安装所提供 zip 文件中包含的 APK

受保护的方法

String getAdbPath()
File getBundletoolFile()
IRunUtil getRunUtil()
static long parseCmdTimeout(List<String> args, long defaultValue)

公共构造函数

BundletoolUtil

public BundletoolUtil (File bundletoolJar)

参数
bundletoolJar File

公共方法

extractSplitsFromApks

public File extractSplitsFromApks (File apks, 
                String deviceSpecPath, 
                ITestDevice device, 
                IBuildInfo buildInfo)

从 .apks 中提取拆分 APK/APEX。重命名拆分,并将拆分存储到存储 .apks 的目录中。返回存储拆分的新的目录。

参数
apks File:需要提取的 APK

deviceSpecPath String:bundletool 用于提取 APK 的设备规范文件

device ITestDevice:已连接的设备

buildInfo IBuildInfo:构建工件信息

返回
File 一个 File,即提取的 APK/APEX 所在的目录

generateDeviceSpecFile

public String generateDeviceSpecFile (ITestDevice device)

为已连接的设备配置生成 JSON 文件。

参数
device ITestDevice:已连接的设备

返回
String 一个 String,表示设备规范文件的路径。

抛出
IOException

installApks

public void installApks (File apks, 
                ITestDevice device, 
                List<String> extraArgs)

安装使用 bundletool 的 APK .apks。

参数
apks File:需要安装的 APK

device ITestDevice:已连接的设备

extraArgs List:用于 bundletool 命令。

抛出
TargetSetupError

installApks

public void installApks (File apks, 
                ITestDevice device)

安装使用 bundletool 的 APK .apks。

参数
apks File:需要安装的 APK

device ITestDevice:已连接的设备

抛出
TargetSetupError

installApksFromZip

public void installApksFromZip (File apksZip, 
                ITestDevice device, 
                List<String> extraArgs)

安装所提供 zip 文件中包含的 APK

参数
apksZip File:要安装的 ZIP 文件

device ITestDevice:已连接的设备

extraArgs List:要传递给 bundletool install 命令的其他实参

抛出
TargetSetupError

受保护的方法

getAdbPath

protected String getAdbPath ()

返回
String

getBundletoolFile

protected File getBundletoolFile ()

返回
File

getRunUtil

protected IRunUtil getRunUtil ()

返回
IRunUtil

parseCmdTimeout

protected static long parseCmdTimeout (List<String> args, 
                long defaultValue)

参数
args List

defaultValue long

返回
long

抛出
TargetSetupError