BundletoolUtil

public class BundletoolUtil
extends Object

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


Utility class that uses bundletool command line to install the .apks on deivce. Bundletool doc link: https://developer.android.com/studio/command-line/bundletool The bundletool.jar is downloaded from the unbundled module branch together with the module file.

Summary

Public constructors

BundletoolUtil(File bundletoolJar)

Public methods

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

Extracts the split apk/apex from .apks.

String generateDeviceSpecFile(ITestDevice device)

Generates a JSON file for a connected device configuration.

void installApks(File apks, ITestDevice device, extraArgs)

Installs the apk .apks that using bundletool.

void installApks(File apks, ITestDevice device)

Installs the apk .apks that using bundletool.

void installApksFromZip(File apksZip, ITestDevice device, extraArgs)

Installs the apks contained in provided zip file

Protected methods

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

Public constructors

BundletoolUtil

public BundletoolUtil (File bundletoolJar)

Parameters
bundletoolJar File

Public methods

extractSplitsFromApks

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

Extracts the split apk/apex from .apks. Renames the splits and stores the splits to the directory where .apks stored. Returns the new directory that the splits stored.

Parameters
apks File: the apks that need to be extracted

deviceSpecPath String: the device spec file that bundletool uses to extract the apks

device ITestDevice: the connected device

buildInfo IBuildInfo: build artifact information

Returns
File a ERROR(/File) that is the directory where the extracted apk(s)/apex live under

generateDeviceSpecFile

public String generateDeviceSpecFile (ITestDevice device)

Generates a JSON file for a connected device configuration.

Parameters
device ITestDevice: the connected device

Returns
String a String representing the path of the device specification file.

installApks

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

Installs the apk .apks that using bundletool.

Parameters
apks File: the apks that need to be installed

device ITestDevice: the connected device

extraArgs : for the bundletool command.

Throws
TargetSetupError

installApks

public void installApks (File apks, 
                ITestDevice device)

Installs the apk .apks that using bundletool.

Parameters
apks File: the apks that need to be installed

device ITestDevice: the connected device

Throws
TargetSetupError

installApksFromZip

public void installApksFromZip (File apksZip, 
                ITestDevice device, 
                 extraArgs)

Installs the apks contained in provided zip file

Parameters
apksZip File: the zip file to install

device ITestDevice: the connected device

extraArgs : additional args to pass to bundletool install command

Throws
TargetSetupError

Protected methods

getAdbPath

protected String getAdbPath ()

Returns
String

getBundletoolFile

protected File getBundletoolFile ()

Returns
File

getRunUtil

protected IRunUtil getRunUtil ()

Returns
IRunUtil

parseCmdTimeout

protected static long parseCmdTimeout ( args, 
                long defaultValue)

Parameters
args

defaultValue long

Returns
long

Throws
TargetSetupError