BundletoolUtil

public class BundletoolUtil
extends Object

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


使用 bundletool 命令行在设备上安装 .apk 的实用程序类。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, extraArgs)

使用 bundletool 安装 APK .apks。

void installApks(File apks, ITestDevice device)

使用 bundletool 安装 APK .apks。

void installApksFromZip(File apksZip, ITestDevice device, extraArgs)

安装提供的 ZIP 文件中包含的 APK

受保护的方法

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

公共构造函数

BundletoolUtil

public BundletoolUtil (File bundletoolJar)

参数
bundletoolJar File

公共方法

extractSplitsFromApks

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

从 .apk 中提取拆分 apk/apex。重命名分块并将分块存储到 .apk 存储的目录中。返回分块存储的新目录。

参数
apks File:需要提取的 apk

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

device ITestDevice:已连接的设备

buildInfo IBuildInfo:build 工件信息

返回
File ERROR(/File),即提取的 apk/apex 所在的目录

generateDeviceSpecFile

public String generateDeviceSpecFile (ITestDevice device)

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

参数
device ITestDevice:已连接的设备

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

installApks

public void installApks (File apks, 
                ITestDevice device, 
                 extraArgs)

安装使用 bundletool 生成的 APK .apks。

参数
apks File:需要安装的 apk

device ITestDevice:已连接的设备

extraArgs :适用于 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, 
                 extraArgs)

安装提供的 ZIP 文件中包含的 APK

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

device ITestDevice:已连接的设备

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

抛出
TargetSetupError

受保护的方法

getAdbPath

protected String getAdbPath ()

返回
String

getBundletoolFile

protected File getBundletoolFile ()

返回
File

getRunUtil

protected IRunUtil getRunUtil ()

返回
IRunUtil

parseCmdTimeout

protected static long parseCmdTimeout ( args, 
                long defaultValue)

参数
args

defaultValue long

返回
long

抛出
TargetSetupError