Integrate with fastboot HAL to get partition type
Bug: 79480454 Bug: 78793464 Test: fastboot getvar partition-type:userdata Change-Id: Ib096ee8061568b8503f3a3f2dbb7e19a932162c4
This commit is contained in:
parent
33dcdb808b
commit
bf9f8d1a64
|
@ -121,6 +121,7 @@ cc_binary {
|
|||
|
||||
shared_libs: [
|
||||
"android.hardware.boot@1.0",
|
||||
"android.hardware.fastboot@1.0",
|
||||
"libadbd",
|
||||
"libasyncio",
|
||||
"libbase",
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#define FB_VAR_HAS_SLOT "has-slot"
|
||||
#define FB_VAR_SLOT_COUNT "slot-count"
|
||||
#define FB_VAR_PARTITION_SIZE "partition-size"
|
||||
#define FB_VAR_PARTITION_TYPE "partition-type"
|
||||
#define FB_VAR_SLOT_SUCCESSFUL "slot-successful"
|
||||
#define FB_VAR_SLOT_UNBOOTABLE "slot-unbootable"
|
||||
#define FB_VAR_IS_LOGICAL "is-logical"
|
||||
|
|
|
@ -88,6 +88,7 @@ bool GetVarHandler(FastbootDevice* device, const std::vector<std::string>& args)
|
|||
{FB_VAR_SLOT_SUCCESSFUL, {GetSlotSuccessful, nullptr}},
|
||||
{FB_VAR_SLOT_UNBOOTABLE, {GetSlotUnbootable, nullptr}},
|
||||
{FB_VAR_PARTITION_SIZE, {GetPartitionSize, GetAllPartitionArgsWithSlot}},
|
||||
{FB_VAR_PARTITION_TYPE, {GetPartitionType, GetAllPartitionArgsWithSlot}},
|
||||
{FB_VAR_IS_LOGICAL, {GetPartitionIsLogical, GetAllPartitionArgsWithSlot}},
|
||||
{FB_VAR_IS_USERSPACE, {GetIsUserspace, nullptr}}};
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <android-base/logging.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <android/hardware/boot/1.0/IBootControl.h>
|
||||
|
||||
#include <android/hardware/fastboot/1.0/IFastboot.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include "constants.h"
|
||||
|
@ -29,6 +29,7 @@
|
|||
using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::boot::V1_0::IBootControl;
|
||||
using ::android::hardware::boot::V1_0::Slot;
|
||||
using ::android::hardware::fastboot::V1_0::IFastboot;
|
||||
namespace sph = std::placeholders;
|
||||
|
||||
FastbootDevice::FastbootDevice()
|
||||
|
@ -49,7 +50,8 @@ FastbootDevice::FastbootDevice()
|
|||
{FB_CMD_UPDATE_SUPER, UpdateSuperHandler},
|
||||
}),
|
||||
transport_(std::make_unique<ClientUsbTransport>()),
|
||||
boot_control_hal_(IBootControl::getService()) {}
|
||||
boot_control_hal_(IBootControl::getService()),
|
||||
fastboot_hal_(IFastboot::getService()) {}
|
||||
|
||||
FastbootDevice::~FastbootDevice() {
|
||||
CloseDevice();
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include <android/hardware/boot/1.0/IBootControl.h>
|
||||
#include <android/hardware/fastboot/1.0/IFastboot.h>
|
||||
|
||||
#include "commands.h"
|
||||
#include "transport.h"
|
||||
|
@ -49,11 +50,15 @@ class FastbootDevice {
|
|||
android::sp<android::hardware::boot::V1_0::IBootControl> boot_control_hal() {
|
||||
return boot_control_hal_;
|
||||
}
|
||||
android::sp<android::hardware::fastboot::V1_0::IFastboot> fastboot_hal() {
|
||||
return fastboot_hal_;
|
||||
}
|
||||
|
||||
private:
|
||||
const std::unordered_map<std::string, CommandHandler> kCommandMap;
|
||||
|
||||
std::unique_ptr<Transport> transport_;
|
||||
android::sp<android::hardware::boot::V1_0::IBootControl> boot_control_hal_;
|
||||
android::sp<android::hardware::fastboot::V1_0::IFastboot> fastboot_hal_;
|
||||
std::vector<char> download_data_;
|
||||
};
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
|
||||
using ::android::hardware::boot::V1_0::BoolResult;
|
||||
using ::android::hardware::boot::V1_0::Slot;
|
||||
using ::android::hardware::fastboot::V1_0::FileSystemType;
|
||||
using ::android::hardware::fastboot::V1_0::Result;
|
||||
using ::android::hardware::fastboot::V1_0::Status;
|
||||
|
||||
constexpr int kMaxDownloadSizeDefault = 0x20000000;
|
||||
constexpr char kFastbootProtocolVersion[] = "0.4";
|
||||
|
@ -195,6 +198,47 @@ bool GetPartitionSize(FastbootDevice* device, const std::vector<std::string>& ar
|
|||
return true;
|
||||
}
|
||||
|
||||
bool GetPartitionType(FastbootDevice* device, const std::vector<std::string>& args,
|
||||
std::string* message) {
|
||||
if (args.size() < 1) {
|
||||
*message = "Missing argument";
|
||||
return false;
|
||||
}
|
||||
std::string partition_name = args[0];
|
||||
auto fastboot_hal = device->fastboot_hal();
|
||||
if (!fastboot_hal) {
|
||||
*message = "Fastboot HAL not found";
|
||||
return false;
|
||||
}
|
||||
|
||||
FileSystemType type;
|
||||
Result ret;
|
||||
auto ret_val =
|
||||
fastboot_hal->getPartitionType(args[0], [&](FileSystemType fs_type, Result result) {
|
||||
type = fs_type;
|
||||
ret = result;
|
||||
});
|
||||
if (!ret_val.isOk() || (ret.status != Status::SUCCESS)) {
|
||||
*message = "Unable to retrieve partition type";
|
||||
} else {
|
||||
switch (type) {
|
||||
case FileSystemType::RAW:
|
||||
*message = "raw";
|
||||
return true;
|
||||
case FileSystemType::EXT4:
|
||||
*message = "ext4";
|
||||
return true;
|
||||
case FileSystemType::F2FS:
|
||||
*message = "f2fs";
|
||||
return true;
|
||||
default:
|
||||
*message = "Unknown file system type";
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GetPartitionIsLogical(FastbootDevice* device, const std::vector<std::string>& args,
|
||||
std::string* message) {
|
||||
if (args.size() < 1) {
|
||||
|
|
|
@ -44,6 +44,8 @@ bool GetUnlocked(FastbootDevice* device, const std::vector<std::string>& args,
|
|||
bool GetHasSlot(FastbootDevice* device, const std::vector<std::string>& args, std::string* message);
|
||||
bool GetPartitionSize(FastbootDevice* device, const std::vector<std::string>& args,
|
||||
std::string* message);
|
||||
bool GetPartitionType(FastbootDevice* device, const std::vector<std::string>& args,
|
||||
std::string* message);
|
||||
bool GetPartitionIsLogical(FastbootDevice* device, const std::vector<std::string>& args,
|
||||
std::string* message);
|
||||
bool GetIsUserspace(FastbootDevice* device, const std::vector<std::string>& args,
|
||||
|
|
Loading…
Reference in New Issue