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 | setDataWipeSkipList ( dataWipeSkipList) setDataWipeSkipList ( dataWipeSkipList) 设置 /data 直接子级。 |
void | setFlashOptions ( flashOptions) setFlashOptions ( flashOptions) 设置要与Flash / Update命令一起传递的选项列表。 |
void | setFlashingResourcesRetriever ( IFlashingResourcesRetriever retriever) 设置刷新器可以检索刷新资源文件的机制。 |
void | setForceSystemFlash (boolean forceSystemFlash) 设置是否即使在运行当前版本时也应始终刷新系统 |
void | setShouldFlashRamdisk (boolean shouldFlashRamdisk) 设置在通过映像zip更新设备后是否应刷新其他虚拟磁盘 |
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) 用于创建 |
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命令的Helper方法。 |
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) 设备上的Flash用户数据分区。 |
void | flashUserDataFromDeviceImageFile (ITestDevice device, IDeviceBuildInfo deviceBuild) 从设备映像文件中提取userdata.img并将其闪存到设备上 |
String | getBootPartitionName () 获取此设备更新程序的引导分区名称。 |
String | getBootloaderFilePrefix (ITestDevice device) 获取引导加载程序文件前缀。 |
String | getCurrentSlot (ITestDevice device) 检索当前插槽的辅助方法(适用于具有A / B功能的设备)。 |
IFlashingResourcesRetriever | getFlashingResourcesRetriever () |
String | getImageVersion (ITestDevice device, String imageName) 获取设备上当前图像版本的Helper方法。 |
IRunUtil | getRunUtil () 暴露于测试。 |
void | handleUserDataFlashing (ITestDevice device, IDeviceBuildInfo deviceBuild) 处理用户数据/缓存分区的刷新 |
boolean | hasPartition (ITestDevice device, String partition) 检查引导加载程序是否存在指定的分区 |
void | preFlashSetup (ITestDevice device, IDeviceBuildInfo deviceBuild) 执行所需的任何其他预闪设置。 |
void | verifyRequiredBoards (ITestDevice device, IFlashingResourcesParser resourceParser, String deviceProductType) 验证设备的产品类型是否支持要刷新的版本。 |
void | wipeCache (ITestDevice device) 擦除设备上的缓存分区。 |
void | wipePartition (ITestDevice device, String partition) 用`fastboot delete <name>擦除指定的分区。 |
领域
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 |
getSystemFlashingStatus
public CommandStatus getSystemFlashingStatus ()
检索用于刷新主系统分区的命令执行状态。
请注意,如果未刷新系统分区(系统已经有要刷新的版本),则命令状态可能为null
退货 | |
---|---|
CommandStatus |
getUserDataFlashOption
public IDeviceFlasher.UserDataFlashOption getUserDataFlashOption ()
获取是否应刷新,擦除或保留用户数据图像
退货 | |
---|---|
IDeviceFlasher.UserDataFlashOption | 用户数据图像应被刷新,擦除还是保留 |
overrideDeviceOptions
public void overrideDeviceOptions (ITestDevice device)
设备的替代选项。如果特定设备不支持默认值,则用于覆盖默认选项值。
setDataWipeSkipList
public void setDataWipeSkipList (dataWipeSkipList)
设置/data
下的路径列表,以避免在使用ITestsZipInstaller
时ITestsZipInstaller
/data
直接子级。参量 | |
---|---|
dataWipeSkipList |
setFlashOptions
public void setFlashOptions (flashOptions)
设置要与Flash / Update命令一起传递的选项列表。
setFlashingResourcesRetriever
public void setFlashingResourcesRetriever (IFlashingResourcesRetriever retriever)
设置刷新器可以检索刷新资源文件的机制。
参量 | |
---|---|
retriever | IFlashingResourcesRetriever :要使用的IFlashingResourcesRetriever |
setForceSystemFlash
public void setForceSystemFlash (boolean forceSystemFlash)
设置是否即使在运行当前版本时也应始终刷新系统
setShouldFlashRamdisk
public void setShouldFlashRamdisk (boolean shouldFlashRamdisk)
设置在通过映像zip更新设备后是否应刷新其他虚拟磁盘
setUserDataFlashOption
public void setUserDataFlashOption (IDeviceFlasher.UserDataFlashOption flashOption)
切换是否应刷新,擦除或保留用户数据图像
setWipeTimeout
public void setWipeTimeout (long timeout)
设置清除数据的超时时间。
参量 | |
---|---|
timeout | long |
shouldFlashRamdisk
public boolean shouldFlashRamdisk ()
通过映像zip更新设备后,检查是否将闪存设置为具有附加的ramdisk。
退货 | |
---|---|
boolean |
受保护的方法
checkAndFlashBaseband
protected void checkAndFlashBaseband (ITestDevice device, IDeviceBuildInfo deviceBuild)
如果需要,请在设备上刷新基带图像。仅当设备上的当前版本!=必需版本时,才会闪烁基带
参量 | |
---|---|
device | ITestDevice :要闪烁的ITestDevice |
deviceBuild | IDeviceBuildInfo :包含要刷新的基带图像的IDeviceBuildInfo |
投掷 | |
---|---|
DeviceNotAvailableException | 如果设备不可用 |
TargetSetupError | 如果无法刷新基带 |
checkAndFlashBootloader
protected boolean checkAndFlashBootloader (ITestDevice device, IDeviceBuildInfo deviceBuild)
如果需要,请刷新设备上的引导加载程序映像。
仅当设备上的当前版本=需要的版本时,才会刷新引导程序。参量 | |
---|---|
device | ITestDevice :要闪烁的ITestDevice |
deviceBuild | IDeviceBuildInfo :包含要加载的引导加载程序映像的IDeviceBuildInfo |
退货 | |
---|---|
boolean | true 如果引导程序是一闪而过, false ,如果它被跳过 |
投掷 | |
---|---|
DeviceNotAvailableException | 如果设备不可用 |
TargetSetupError | 如果无法刷新引导程序 |
checkAndFlashSystem
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 | 如果无法刷新引导程序 |
checkShouldFlashBaseband
protected boolean checkShouldFlashBaseband (ITestDevice device, IDeviceBuildInfo deviceBuild)
检查所提供设备上的基带是否需要刷新。
参量 | |
---|---|
device | ITestDevice :要检查的ITestDevice |
deviceBuild | IDeviceBuildInfo :包含要检查的基带图像的IDeviceBuildInfo |
退货 | |
---|---|
boolean |
投掷 | |
---|---|
DeviceNotAvailableException | 如果设备不可用 |
TargetSetupError | 如果无法刷新基带 |
createFlashingResourcesParser
protected IFlashingResourcesParser createFlashingResourcesParser (IDeviceBuildInfo localBuild, DeviceDescriptor descriptor)
用于创建IFlashingResourcesParser
工厂方法。
参量 | |
---|---|
localBuild | IDeviceBuildInfo :要解析的IDeviceBuildInfo |
descriptor | DeviceDescriptor :要DeviceDescriptor 的设备的描述符。 |
退货 | |
---|---|
IFlashingResourcesParser | 由工厂方法创建的IFlashingResourcesParser 。 |
投掷 | |
---|---|
TargetSetupError |
downloadExtraImageFiles
protected void downloadExtraImageFiles (IFlashingResourcesParser resourceParser, IFlashingResourcesRetriever retriever, IDeviceBuildInfo localBuild)
如有必要,请允许子类下载其他自定义图像文件。
参量 | |
---|---|
resourceParser | IFlashingResourcesParser : IFlashingResourcesParser |
retriever | IFlashingResourcesRetriever : IFlashingResourcesRetriever |
localBuild | IDeviceBuildInfo : IDeviceBuildInfo |
投掷 | |
---|---|
TargetSetupError |
下载Flashing资源
protected void downloadFlashingResources (ITestDevice device, IDeviceBuildInfo localBuild)
下载所需的额外的闪烁图像文件
参量 | |
---|---|
device | ITestDevice :用于下载资源的ITestDevice |
localBuild | IDeviceBuildInfo :要填充的IDeviceBuildInfo 。假设设备映像文件已设置 |
投掷 | |
---|---|
DeviceNotAvailableException | 如果设备不可用 |
TargetSetupError | 如果检索资源失败 |
executeFastbootCmd
protected String executeFastbootCmd (ITestDevice device, String... cmdArgs)
执行fastboot命令的辅助方法。
参量 | |
---|---|
device | ITestDevice :要在ITestDevice 上执行命令的ITestDevice |
cmdArgs | String :提供给fastboot的参数 |
退货 | |
---|---|
String | 如果命令为非空,则将命令的stderr输出字符串化。否则返回stdout某些fastboot命令很奇怪,它们在成功的情况下将输出转储到stderr |
投掷 | |
---|---|
DeviceNotAvailableException | 如果设备不可用 |
TargetSetupError | 如果fastboot命令失败 |
executeLongFastbootCmd
protected String executeLongFastbootCmd (ITestDevice device, String... cmdArgs)
执行长时间运行的fastboot命令的Helper方法。
注意:大多数fastboot命令通常在ITestDevice#executeFastbootCommand(String...)
允许的超时内执行。但是,当多个设备同时刷新设备时,fastboot命令所花费的时间可能比正常情况长得多。
参量 | |
---|---|
device | ITestDevice :要在ITestDevice 上执行命令的ITestDevice |
cmdArgs | String :提供给fastboot的参数 |
退货 | |
---|---|
String | 如果命令为非空,则将命令的stderr输出字符串化。否则返回stdout某些fastboot命令很奇怪,它们在成功的情况下将输出转储到stderr |
投掷 | |
---|---|
DeviceNotAvailableException | 如果设备不可用 |
TargetSetupError | 如果fastboot命令失败 |
flashBaseband
protected void flashBaseband (ITestDevice device, File basebandImageFile)
刷新给定的基带映像,然后重新引导回引导程序
参量 | |
---|---|
device | ITestDevice :要闪烁的ITestDevice |
basebandImageFile | File :基带图像ERROR(/File) |
投掷 | |
---|---|
DeviceNotAvailableException | 如果设备不可用 |
TargetSetupError | 如果无法刷新基带 |
flashBootloader
protected void flashBootloader (ITestDevice device, File bootloaderImageFile)
刷新给定的引导加载程序映像,然后重新引导回引导加载程序
参量 | |
---|---|
device | ITestDevice :要闪烁的ITestDevice |
bootloaderImageFile | File :引导加载程序映像ERROR(/File) |
投掷 | |
---|---|
DeviceNotAvailableException | 如果设备不可用 |
TargetSetupError | 如果闪烁失败 |
flashExtraImages
protected void flashExtraImages (ITestDevice device, IDeviceBuildInfo deviceBuild)
在刷新系统并重新引导之前,请刷新所有设备特定的分区。除非被覆盖,否则不要操作。
参量 | |
---|---|
device | ITestDevice :要闪烁的ITestDevice |
deviceBuild | IDeviceBuildInfo :包含构建文件的IDeviceBuildInfo |
投掷 | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
TargetSetupError | |
DeviceNotAvailableException |
flashPartition
protected void flashPartition (ITestDevice device, File imgFile, String partition)
刷新设备的单个分区
参量 | |
---|---|
device | ITestDevice :要闪烁的ITestDevice |
imgFile | File :指向要刷新的图像的ERROR(/File) |
partition | String :要刷新的分区的名称 |
投掷 | |
---|---|
DeviceNotAvailableException | |
TargetSetupError |
flashRamdiskIfNeeded
protected void flashRamdiskIfNeeded (ITestDevice device, IDeviceBuildInfo deviceBuild)
参量 | |
---|---|
device | ITestDevice |
deviceBuild | IDeviceBuildInfo |
投掷 | |
---|---|
DeviceNotAvailableException | |
TargetSetupError |
flashSystem
protected void flashSystem (ITestDevice device, IDeviceBuildInfo deviceBuild)
刷新设备上的系统映像。
参量 | |
---|---|
device | ITestDevice :要闪烁的ITestDevice |
deviceBuild | IDeviceBuildInfo :要刷新的IDeviceBuildInfo |
投掷 | |
---|---|
DeviceNotAvailableException | 如果设备不可用 |
TargetSetupError | 如果fastboot命令失败 |
flashUserData
protected void flashUserData (ITestDevice device, IDeviceBuildInfo deviceBuild)
设备上的Flash用户数据分区。
参量 | |
---|---|
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 | 如果无法提取或刷新用户数据 |
getBootPartitionName
protected String getBootPartitionName ()
获取此设备更新程序的引导分区名称。
默认为'bootloader'。如有必要,子类应重写。
退货 | |
---|---|
String |
getBootloaderFilePrefix
protected String getBootloaderFilePrefix (ITestDevice device)
获取引导加载程序文件前缀。
默认为getBootPartitionName()
。如有必要,子类应重写。参量 | |
---|---|
device | ITestDevice :要闪烁的ITestDevice |
退货 | |
---|---|
String |
投掷 | |
---|---|
DeviceNotAvailableException | 如果设备不可用 |
TargetSetupError | 如果无法获得前缀 |
getCurrentSlot
protected String getCurrentSlot (ITestDevice device)
检索当前插槽的辅助方法(适用于具有A / B功能的设备)。
参量 | |
---|---|
device | ITestDevice :要在ITestDevice 上执行命令的ITestDevice 。 |
退货 | |
---|---|
String | “ a”,“ b”或null(如果设备不支持A / B) |
投掷 | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
TargetSetupError | |
DeviceNotAvailableException |
getFlashingResourcesRetriever
protected IFlashingResourcesRetriever getFlashingResourcesRetriever ()
退货 | |
---|---|
IFlashingResourcesRetriever |
getImageVersion
protected String getImageVersion (ITestDevice device, String imageName)
获取设备上当前图像版本的Helper方法。
参量 | |
---|---|
device | ITestDevice :要在ITestDevice 上执行命令的ITestDevice |
imageName | String :要获取的图像的名称。 |
退货 | |
---|---|
String | 字符串命令的标准输出 |
投掷 | |
---|---|
DeviceNotAvailableException | 如果设备不可用 |
TargetSetupError | 如果fastboot命令失败或无法确定版本 |
getRunUtil
protected IRunUtil getRunUtil ()
暴露于测试。
退货 | |
---|---|
IRunUtil |
handleUserDataFlashing
protected void handleUserDataFlashing (ITestDevice device, IDeviceBuildInfo deviceBuild)
处理用户数据/缓存分区的刷新
参量 | |
---|---|
device | ITestDevice :要闪烁的ITestDevice |
deviceBuild | IDeviceBuildInfo :包含要刷新的文件的IDeviceBuildInfo |
投掷 | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
TargetSetupError | |
DeviceNotAvailableException |
hasPartition
protected boolean hasPartition (ITestDevice device, String partition)
检查引导加载程序是否存在指定的分区
参量 | |
---|---|
device | ITestDevice :要运行的ITestDevice |
partition | String :要检查的分区的名称 |
退货 | |
---|---|
boolean |
投掷 | |
---|---|
DeviceNotAvailableException |
preFlashSetup
protected void preFlashSetup (ITestDevice device, IDeviceBuildInfo deviceBuild)
执行所需的任何其他预闪设置。除非被覆盖,否则不要操作。
参量 | |
---|---|
device | ITestDevice :准备的ITestDevice |
deviceBuild | IDeviceBuildInfo :包含构建文件的IDeviceBuildInfo |
投掷 | |
---|---|
| com.android.tradefed.device.DeviceNotAvailableException |
TargetSetupError | |
DeviceNotAvailableException |
verifyRequiredBoards
protected void verifyRequiredBoards (ITestDevice device, IFlashingResourcesParser resourceParser, String deviceProductType)
验证设备的产品类型是否支持要刷新的版本。
基本实现将验证IFlashingResourcesParser#getRequiredBoards()
集合中是否包含IFlashingResourcesParser#getRequiredBoards()
。子类可以根据需要重写。
参量 | |
---|---|
device | ITestDevice :要ITestDevice |
resourceParser | IFlashingResourcesParser : IFlashingResourcesParser |
deviceProductType | String : device的产品类型 |
投掷 | |
---|---|
TargetSetupError | 如果构建所需的主板信息与设备不匹配 |
擦除缓存
protected void wipeCache (ITestDevice device)
擦除设备上的缓存分区。
参量 | |
---|---|
device | ITestDevice :要闪烁的ITestDevice |
投掷 | |
---|---|
DeviceNotAvailableException | 如果设备不可用 |
TargetSetupError | 如果无法刷新缓存 |
擦分区
protected void wipePartition (ITestDevice device, String partition)
用`fastboot delete <name>擦除指定的分区。
参量 | |
---|---|
device | ITestDevice :要运行的ITestDevice |
partition | String :要擦除的分区的名称 |
投掷 | |
---|---|
DeviceNotAvailableException | |
TargetSetupError |