FastbootDeviceFlasher

public class FastbootDeviceFlasher
extends Object implements IDeviceFlasher

java.lang.Object
com.android.tradefed.targetprep.FastbootDeviceFlasher


依赖 fastboot 在物理 Android 硬件上刷新映像的类。

概括

领域

public static final String BASEBAND_IMAGE_NAME

公共构造函数

FastbootDeviceFlasher ()

公共方法

void flash ( ITestDevice device, IDeviceBuildInfo deviceBuild)

闪存是在设备上构建的。

CommandStatus getSystemFlashingStatus ()

检索刷新主系统分区的命令执行状态。

IDeviceFlasher.UserDataFlashOption getUserDataFlashOption ()

获取是否应刷新、擦除或保留用户数据映像

void overrideDeviceOptions ( ITestDevice device)

覆盖设备的选项。

void preFlashOperations ( ITestDevice device, IDeviceBuildInfo deviceBuild)

所有设置操作和检查必须在实际闪烁关键部分之前进行。

void setDataWipeSkipList ( dataWipeSkipList) setDataWipeSkipList ( dataWipeSkipList)

设置/data下的路径列表以避免使用ITestsZipInstaller时被清除

请注意,跳过列表的粒度是/data的直接子级。

void setFlashOptions ( flashOptions) setFlashOptions ( flashOptions)

设置要通过 flash/update 命令传递的选项列表。

void setFlashingResourcesRetriever ( IFlashingResourcesRetriever retriever)

设置刷新器检索资源文​​件以进行刷新的机制。

void setForceSystemFlash (boolean forceSystemFlash)

设置系统是否应该始终刷新,即使运行当前版本

void setIncrementalFlashing ( IncrementalImageUtil incrementalUtil)
void setRamdiskPartition (String ramdiskPartition)

设置虚拟磁盘分区

void setShouldFlashRamdisk (boolean shouldFlashRamdisk)

设置通过映像 zip 更新设备后是否应刷新附加 ramdisk

void setUserDataFlashOption ( IDeviceFlasher.UserDataFlashOption flashOption)

切换是否应刷新、擦除或保留用户数据映像

void setWipeTimeout (long timeout)

设置擦除数据的超时时间。

boolean shouldFlashRamdisk ()

检查刷新器是否设置为在通过映像 zip 更新设备后应刷新额外的 ramdisk

受保护的方法

void checkAndFlashBaseband ( ITestDevice device, IDeviceBuildInfo deviceBuild)

如果需要,请在设备上刷新基带映像。

boolean checkAndFlashBootloader ( ITestDevice device, IDeviceBuildInfo deviceBuild)

如果需要,请在设备上刷新引导加载程序映像。

boolean checkAndFlashSystem ( ITestDevice device, String systemBuildId, String systemBuildFlavor, IDeviceBuildInfo deviceBuild)

如果需要,请在设备上刷新系统映像。

boolean checkShouldFlashBaseband ( ITestDevice device, IDeviceBuildInfo deviceBuild)

检查所提供设备上的基带是否需要刷新。

IFlashingResourcesParser createFlashingResourcesParser ( IDeviceBuildInfo localBuild, DeviceDescriptor descriptor)

用于创建IFlashingResourcesParser工厂方法。

void downloadExtraImageFiles ( IFlashingResourcesParser resourceParser, IFlashingResourcesRetriever retriever, IDeviceBuildInfo localBuild)

如果需要,允许子类下载额外的自定义图像文件的挂钩。

void downloadFlashingResources ( ITestDevice device, IDeviceBuildInfo localBuild)

下载所需的额外闪烁图像文件

String executeFastbootCmd ( ITestDevice device, String... cmdArgs)

执行 fastboot 命令的帮助程序方法。

String executeLongFastbootCmd ( ITestDevice device, String... cmdArgs)

用于执行长时间运行的 fastboot 命令的帮助程序方法。

String executeLongFastbootCmd ( ITestDevice device, envVarMap, String... cmdArgs) executeLongFastbootCmd ( ITestDevice device, envVarMap, String... cmdArgs)

使用环境变量执行长时间运行的 fastboot 命令的帮助程序方法。

void flashBaseband ( ITestDevice device, File basebandImageFile)

刷新给定的基带映像并重新引导回引导加载程序

void flashBootloader ( ITestDevice device, File bootloaderImageFile)

刷新给定的引导加载程序映像并重新启动回到引导加载程序

void flashExtraImages ( ITestDevice device, IDeviceBuildInfo deviceBuild)

在刷新系统并重新启动之前,刷新任何设备特定分区。

void flashPartition ( ITestDevice device, File imgFile, String partition)

闪存设备的单个分区

void flashRamdiskIfNeeded ( ITestDevice device, IDeviceBuildInfo deviceBuild)
void flashSystem ( ITestDevice device, IDeviceBuildInfo deviceBuild)

在设备上刷新系统映像。

void flashUserData ( ITestDevice device, IDeviceBuildInfo deviceBuild)

设备上的闪存用户数据分区。

void flashUserDataFromDeviceImageFile ( ITestDevice device, IDeviceBuildInfo deviceBuild)

从设备映像文件中提取 userdata.img 并将其刷新到设备上

String getBootPartitionName ()

获取该设备闪存器的启动分区名称。

String getBootloaderFilePrefix ( ITestDevice device)

获取引导加载程序文件前缀。

String getCurrentSlot ( ITestDevice device)

用于检索当前插槽的辅助方法(对于支持 A/B 的设备)。

IFlashingResourcesRetriever getFlashingResourcesRetriever ()
FuseUtil getFuseUtil ()
String getImageVersion ( ITestDevice device, String imageName)

获取设备上当前映像版本的帮助程序方法。

IRunUtil getRunUtil ()

暴露进行测试。

void handleUserDataFlashing ( ITestDevice device, IDeviceBuildInfo deviceBuild)

处理用户数据/缓存分区的刷新

boolean hasPartition ( ITestDevice device, String partition)

检查引导加载程序是否存在指定的分区

void preFlashSetup ( ITestDevice device, IDeviceBuildInfo deviceBuild)

执行所需的任何额外预闪烁设置。

void setSystemBuildInfo (String systemBuildId, String systemBuildFlavor)
void verifyRequiredBoards ( ITestDevice device, IFlashingResourcesParser resourceParser, String deviceProductType)

验证设备的产品类型是否支持要闪存的版本。

void wipeCache ( ITestDevice device)

擦除设备上的缓存分区。

void wipePartition ( ITestDevice device, String partition)

使用“fastboot擦除<名称>”擦除指定分区

领域

BASEBAND_IMAGE_NAME

public static final String BASEBAND_IMAGE_NAME

公共构造函数

FastbootDeviceFlasher

public FastbootDeviceFlasher ()

公共方法

闪光

public void flash (ITestDevice device, 
                IDeviceBuildInfo deviceBuild)

闪存是在设备上构建的。

闪烁完成后立即返回。呼叫者应等待设备上线并可用,然后再继续测试。

参数
device ITestDevice :要刷新的ITestDevice

deviceBuild IDeviceBuildInfo :要刷新的IDeviceBuildInfo

投掷
DeviceNotAvailableException
TargetSetupError

获取系统闪烁状态

public CommandStatus getSystemFlashingStatus ()

检索刷新主系统分区的命令执行状态。

请注意,如果系统分区未刷新(系统已经具有要刷新的版本),则命令状态可能为null

退货
CommandStatus

获取用户数据闪存选项

public IDeviceFlasher.UserDataFlashOption getUserDataFlashOption ()

获取是否应刷新、擦除或保留用户数据映像

退货
IDeviceFlasher.UserDataFlashOption是否应刷新、擦除或保留用户数据映像

覆盖设备选项

public void overrideDeviceOptions (ITestDevice device)

覆盖设备的选项。如果特定设备不支持默认值,则用于覆盖默认选项值。

预闪操作

public void preFlashOperations (ITestDevice device, 
                IDeviceBuildInfo deviceBuild)

所有设置操作和检查必须在实际闪烁关键部分之前进行。这些操作都不会包含在并发控制的关键部分中。

参数
device ITestDevice :要刷新的ITestDevice

deviceBuild IDeviceBuildInfo :要刷新的IDeviceBuildInfo

投掷
DeviceNotAvailableException
TargetSetupError

设置数据擦除跳过列表

public void setDataWipeSkipList ( dataWipeSkipList)

设置/data下的路径列表以避免使用ITestsZipInstaller时被清除

请注意,跳过列表的粒度是/data的直接子级。

参数
dataWipeSkipList

设置Flash选项

public void setFlashOptions ( flashOptions)

设置要通过 flash/update 命令传递的选项列表。

setFlashingResourcesRetriever

public void setFlashingResourcesRetriever (IFlashingResourcesRetriever retriever)

设置刷新器检索资源文​​件以进行刷新的机制。

参数
retriever IFlashingResourcesRetriever :要使用的IFlashingResourcesRetriever

设置强制系统闪存

public void setForceSystemFlash (boolean forceSystemFlash)

设置系统是否应该始终刷新,即使运行当前版本

设置增量闪烁

public void setIncrementalFlashing (IncrementalImageUtil incrementalUtil)

参数
incrementalUtil IncrementalImageUtil

设置虚拟磁盘分区

public void setRamdiskPartition (String ramdiskPartition)

设置虚拟磁盘分区

设置ShouldFlash Ramdisk

public void setShouldFlashRamdisk (boolean shouldFlashRamdisk)

设置通过映像 zip 更新设备后是否应刷新附加 ramdisk

设置用户数据闪存选项

public void setUserDataFlashOption (IDeviceFlasher.UserDataFlashOption flashOption)

切换是否应刷新、擦除或保留用户数据映像

设置擦除超时

public void setWipeTimeout (long timeout)

设置擦除数据的超时时间。

参数
timeout long

应该Flash Ramdisk

public boolean shouldFlashRamdisk ()

检查刷新器是否设置为在通过映像 zip 更新设备后应刷新额外的 ramdisk

退货
boolean

受保护的方法

检查AndFlash基带

protected void checkAndFlashBaseband (ITestDevice device, 
                IDeviceBuildInfo deviceBuild)

如果需要,请在设备上刷新基带映像。仅当设备上的当前版本!=所需版本时才会刷新基带

参数
device ITestDevice :要刷新的ITestDevice

deviceBuild IDeviceBuildInfo :包含要刷新的基带图像的IDeviceBuildInfo

投掷
DeviceNotAvailableException如果设备不可用
TargetSetupError如果刷基带失败

检查AndFlashBootloader

protected boolean checkAndFlashBootloader (ITestDevice device, 
                IDeviceBuildInfo deviceBuild)

如果需要,请在设备上刷新引导加载程序映像。

仅当设备上的当前版本!=所需版本时才会刷新引导加载程序。

参数
device ITestDevice :要刷新的ITestDevice

deviceBuild IDeviceBuildInfo :包含要闪存的引导加载程序映像的IDeviceBuildInfo

退货
boolean如果引导加载程序已刷新则为true ,如果跳过则为false

投掷
DeviceNotAvailableException如果设备不可用
TargetSetupError如果刷新引导加载程序失败

检查和Flash系统

protected boolean checkAndFlashSystem (ITestDevice device, 
                String systemBuildId, 
                String systemBuildFlavor, 
                IDeviceBuildInfo deviceBuild)

如果需要,请在设备上刷新系统映像。

请查看ERROR(/#shouldFlashSystem(String,String,com.android.tradefed.build.IDeviceBuildInfo))

无论选择何种路径,在方法执行之后设备都应该启动到用户空间。

参数
device ITestDevice :要刷新的ITestDevice

systemBuildId String : 设备上运行的当前构建 ID

systemBuildFlavor String :设备上运行的当前构建风格

deviceBuild IDeviceBuildInfo :包含要刷新的系统映像的IDeviceBuildInfo

退货
boolean true如果系统已刷新, false如果跳过

投掷
DeviceNotAvailableException如果设备不可用
TargetSetupError如果刷新引导加载程序失败

检查ShouldFlashBaseband

protected boolean checkShouldFlashBaseband (ITestDevice device, 
                IDeviceBuildInfo deviceBuild)

检查所提供设备上的基带是否需要刷新。

参数
device ITestDevice :要检查的ITestDevice

deviceBuild IDeviceBuildInfo :包含要检查的基带图像的IDeviceBuildInfo

退货
boolean

投掷
DeviceNotAvailableException如果设备不可用
TargetSetupError如果刷基带失败

创建FlashingResourcesParser

protected IFlashingResourcesParser createFlashingResourcesParser (IDeviceBuildInfo localBuild, 
                DeviceDescriptor descriptor)

用于创建IFlashingResourcesParser工厂方法。

暴露用于单元测试。

参数
localBuild IDeviceBuildInfo :要解析的IDeviceBuildInfo

descriptor DeviceDescriptor :正在刷新的设备的描述符。

退货
IFlashingResourcesParser由工厂方法创建的IFlashingResourcesParser

投掷
com.android.tradefed.targetprep.TargetSetupError
TargetSetupError

下载额外图像文件

protected void downloadExtraImageFiles (IFlashingResourcesParser resourceParser, 
                IFlashingResourcesRetriever retriever, 
                IDeviceBuildInfo localBuild)

如果需要,允许子类下载额外的自定义图像文件的挂钩。

参数
resourceParser IFlashingResourcesParser : IFlashingResourcesParser

retriever IFlashingResourcesRetriever : IFlashingResourcesRetriever

localBuild IDeviceBuildInfoIDeviceBuildInfo

投掷
com.android.tradefed.targetprep.TargetSetupError
TargetSetupError

下载Flashing资源

protected void downloadFlashingResources (ITestDevice device, 
                IDeviceBuildInfo localBuild)

下载所需的额外闪烁图像文件

参数
device ITestDevice :要下载资源的ITestDevice

localBuild IDeviceBuildInfo :要填充的IDeviceBuildInfo 。假设设备映像文件已设置

投掷
DeviceNotAvailableException如果设备不可用
TargetSetupError如果检索资源失败

执行FastbootCmd

protected String executeFastbootCmd (ITestDevice device, 
                String... cmdArgs)

执行 fastboot 命令的帮助程序方法。

参数
device ITestDevice :要执行命令的ITestDevice

cmdArgs String : 提供给 fastboot 的参数

退货
String如果非空,则将命令的 stderr 输出字符串化。否则返回 stdout 一些 fastboot 命令很奇怪,因为它们在成功的情况下将输出转储到 stderr

投掷
DeviceNotAvailableException如果设备不可用
TargetSetupError如果 fastboot 命令失败

执行LongFastbootCmd

protected String executeLongFastbootCmd (ITestDevice device, 
                String... cmdArgs)

用于执行长时间运行的 fastboot 命令的帮助程序方法。

注意:大多数 fastboot 命令通常在INativeDevice.executeFastbootCommand(String)允许的超时内执行。但是,当多个设备同时刷新设备时,fastboot 命令可能需要比正常情况更长的时间。

参数
device ITestDevice :要执行命令的ITestDevice

cmdArgs String : 提供给 fastboot 的参数

退货
String如果非空,则将命令的 stderr 输出字符串化。否则返回 stdout 一些 fastboot 命令很奇怪,因为它们在成功的情况下将输出转储到 stderr

投掷
DeviceNotAvailableException如果设备不可用
TargetSetupError如果 fastboot 命令失败

执行LongFastbootCmd

protected String executeLongFastbootCmd (ITestDevice device, 
                 envVarMap, 
                String... cmdArgs)

使用环境变量执行长时间运行的 fastboot 命令的帮助程序方法。

注意:大多数 fastboot 命令通常在INativeDevice.executeFastbootCommand(String)允许的超时内执行。但是,当多个设备同时刷新设备时,fastboot 命令可能需要比正常情况更长的时间。

参数
device ITestDevice :要执行命令的ITestDevice

envVarMap :携带环境变量的映射,需要在运行fastboot命令之前设置

cmdArgs String : 提供给 fastboot 的参数

退货
String如果非空,则将命令的 stderr 输出字符串化。否则返回 stdout 一些 fastboot 命令很奇怪,因为它们在成功的情况下将输出转储到 stderr

投掷
DeviceNotAvailableException如果设备不可用
TargetSetupError如果 fastboot 命令失败

闪存基带

protected void flashBaseband (ITestDevice device, 
                File basebandImageFile)

刷新给定的基带映像并重新引导回引导加载程序

参数
device ITestDevice :要刷新的ITestDevice

basebandImageFile File :基带图像ERROR(/File)

投掷
DeviceNotAvailableException如果设备不可用
TargetSetupError如果刷基带失败

闪存引导加载程序

protected void flashBootloader (ITestDevice device, 
                File bootloaderImageFile)

刷新给定的引导加载程序映像并重新启动回到引导加载程序

参数
device ITestDevice :要刷新的ITestDevice

bootloaderImageFile File :引导加载程序映像ERROR(/File)

投掷
DeviceNotAvailableException如果设备不可用
TargetSetupError如果刷机失败

闪光额外图像

protected void flashExtraImages (ITestDevice device, 
                IDeviceBuildInfo deviceBuild)

在刷新系统并重新启动之前,刷新任何设备特定分区。除非被覆盖,否则无操作。

参数
device ITestDevice :要刷新的ITestDevice

deviceBuild IDeviceBuildInfo :包含构建文件的IDeviceBuildInfo

投掷
com.android.tradefed.device.DeviceNotAvailableException
com.android.tradefed.targetprep.TargetSetupError
DeviceNotAvailableException
TargetSetupError

闪存分区

protected void flashPartition (ITestDevice device, 
                File imgFile, 
                String partition)

闪存设备的单个分区

参数
device ITestDevice :要刷新的ITestDevice

imgFile File :指向要刷新的图像的ERROR(/File)

partition String : 要刷新的分区的名称

投掷
DeviceNotAvailableException
TargetSetupError

闪存虚拟盘(如果需要)

protected void flashRamdiskIfNeeded (ITestDevice device, 
                IDeviceBuildInfo deviceBuild)

参数
device ITestDevice

deviceBuild IDeviceBuildInfo

投掷
DeviceNotAvailableException
TargetSetupError

闪存系统

protected void flashSystem (ITestDevice device, 
                IDeviceBuildInfo deviceBuild)

在设备上刷新系统映像。

参数
device ITestDevice :要刷新的ITestDevice

deviceBuild IDeviceBuildInfo :要刷新的IDeviceBuildInfo

投掷
DeviceNotAvailableException如果设备不可用
TargetSetupError如果 fastboot 命令失败

闪存用户数据

protected void flashUserData (ITestDevice device, 
                IDeviceBuildInfo deviceBuild)

设备上的闪存用户数据分区。

参数
device ITestDevice :要刷新的ITestDevice

deviceBuild IDeviceBuildInfo :包含要刷新的文件的IDeviceBuildInfo

投掷
DeviceNotAvailableException如果设备不可用
TargetSetupError如果刷新用户数据失败

flashUserDataFromDeviceImageFile

protected void flashUserDataFromDeviceImageFile (ITestDevice device, 
                IDeviceBuildInfo deviceBuild)

从设备映像文件中提取 userdata.img 并将其刷新到设备上

参数
device ITestDevice :要刷新的ITestDevice

deviceBuild IDeviceBuildInfo :包含要刷新的文件的IDeviceBuildInfo

投掷
DeviceNotAvailableException如果设备不可用
TargetSetupError如果无法提取或刷新用户数据

获取引导分区名称

protected String getBootPartitionName ()

获取该设备闪存器的启动分区名称。

默认为“引导加载程序”。如有必要,子类应重写。

退货
String

获取Bootloader文件前缀

protected String getBootloaderFilePrefix (ITestDevice device)

获取引导加载程序文件前缀。

默认为getBootPartitionName() 。如有必要,子类应重写。

参数
device ITestDevice :要刷新的ITestDevice

退货
String

投掷
DeviceNotAvailableException如果设备不可用
TargetSetupError如果未能获取前缀

获取当前槽位

protected String getCurrentSlot (ITestDevice device)

用于检索当前插槽的辅助方法(对于支持 A/B 的设备)。

参数
device ITestDevice :要在其上执行命令的ITestDevice

退货
String “a”、“b”或 null(如果设备不支持 A/B)

投掷
com.android.tradefed.device.DeviceNotAvailableException
com.android.tradefed.targetprep.TargetSetupError
DeviceNotAvailableException
TargetSetupError

getFlashingResourcesRetriever

protected IFlashingResourcesRetriever getFlashingResourcesRetriever ()

退货
IFlashingResourcesRetriever

获取FuseUtil

protected FuseUtil getFuseUtil ()

退货
FuseUtil

获取图像版本

protected String getImageVersion (ITestDevice device, 
                String imageName)

获取设备上当前映像版本的帮助程序方法。

参数
device ITestDevice :要执行命令的ITestDevice

imageName String : 要获取的图像的名称。

退货
String将命令的 stdout 输出字符串化

投掷
DeviceNotAvailableException如果设备不可用
TargetSetupError如果 fastboot 命令失败或无法确定版本

获取运行工具

protected IRunUtil getRunUtil ()

暴露进行测试。

退货
IRunUtil

处理用户数据闪烁

protected void handleUserDataFlashing (ITestDevice device, 
                IDeviceBuildInfo deviceBuild)

处理用户数据/缓存分区的刷新

参数
device ITestDevice :要刷新的ITestDevice

deviceBuild IDeviceBuildInfo :包含要刷新的文件的IDeviceBuildInfo

投掷
com.android.tradefed.device.DeviceNotAvailableException
com.android.tradefed.targetprep.TargetSetupError
DeviceNotAvailableException
TargetSetupError

有分区

protected boolean hasPartition (ITestDevice device, 
                String partition)

检查引导加载程序是否存在指定的分区

参数
device ITestDevice :要操作的ITestDevice

partition String : 要检查的分区名称

退货
boolean

投掷
DeviceNotAvailableException

预闪光设置

protected void preFlashSetup (ITestDevice device, 
                IDeviceBuildInfo deviceBuild)

执行所需的任何额外预闪烁设置。除非被覆盖,否则无操作。

参数
device ITestDevice :要准备的ITestDevice

deviceBuild IDeviceBuildInfo :包含构建文件的IDeviceBuildInfo

投掷
com.android.tradefed.device.DeviceNotAvailableException
com.android.tradefed.targetprep.TargetSetupError
DeviceNotAvailableException
TargetSetupError

设置系统构建信息

protected void setSystemBuildInfo (String systemBuildId, 
                String systemBuildFlavor)

参数
systemBuildId String

systemBuildFlavor String

验证所需板

protected void verifyRequiredBoards (ITestDevice device, 
                IFlashingResourcesParser resourceParser, 
                String deviceProductType)

验证设备的产品类型是否支持要闪存的版本。

基本实现将验证 deviceProductType 是否包含在IFlashingResourcesParser.getRequiredBoards()集合中。子类可以根据需要重写。

参数
device ITestDevice :要刷新的ITestDevice

resourceParser IFlashingResourcesParser : IFlashingResourcesParser

deviceProductType Stringdevice的产品类型

投掷
TargetSetupError如果构建所需的主板信息与设备不匹配

擦除缓存

protected void wipeCache (ITestDevice device)

擦除设备上的缓存分区。

参数
device ITestDevice :要刷新的ITestDevice

投掷
DeviceNotAvailableException如果设备不可用
TargetSetupError如果刷新缓存失败

擦分区

protected void wipePartition (ITestDevice device, 
                String partition)

使用“fastboot擦除<名称>”擦除指定分区

参数
device ITestDevice :要操作的ITestDevice

partition String : 要擦除的分区的名称

投掷
DeviceNotAvailableException
TargetSetupError