diff options
-rw-r--r-- | fastboot/Android.bp | 1 | ||||
-rw-r--r-- | fastboot/constants.h | 1 | ||||
-rw-r--r-- | fastboot/device/commands.cpp | 1 | ||||
-rw-r--r-- | fastboot/device/fastboot_device.cpp | 6 | ||||
-rw-r--r-- | fastboot/device/fastboot_device.h | 5 | ||||
-rw-r--r-- | fastboot/device/variables.cpp | 44 | ||||
-rw-r--r-- | fastboot/device/variables.h | 2 |
7 files changed, 58 insertions, 2 deletions
diff --git a/fastboot/Android.bp b/fastboot/Android.bp index 3b91dddc2..6b175af7d 100644 --- a/fastboot/Android.bp +++ b/fastboot/Android.bp @@ -121,6 +121,7 @@ cc_binary { shared_libs: [ "android.hardware.boot@1.0", + "android.hardware.fastboot@1.0", "libadbd", "libasyncio", "libbase", diff --git a/fastboot/constants.h b/fastboot/constants.h index 8a425ae0d..57e25fc59 100644 --- a/fastboot/constants.h +++ b/fastboot/constants.h @@ -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" diff --git a/fastboot/device/commands.cpp b/fastboot/device/commands.cpp index 771c28892..0ec09945b 100644 --- a/fastboot/device/commands.cpp +++ b/fastboot/device/commands.cpp @@ -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}}, {FB_VAR_HW_REVISION, {GetHardwareRevision, nullptr}}}; diff --git a/fastboot/device/fastboot_device.cpp b/fastboot/device/fastboot_device.cpp index 55aca9ccd..ae2e7a607 100644 --- a/fastboot/device/fastboot_device.cpp +++ b/fastboot/device/fastboot_device.cpp @@ -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(); diff --git a/fastboot/device/fastboot_device.h b/fastboot/device/fastboot_device.h index 171e7ae3b..189cf80c1 100644 --- a/fastboot/device/fastboot_device.h +++ b/fastboot/device/fastboot_device.h @@ -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_; }; diff --git a/fastboot/device/variables.cpp b/fastboot/device/variables.cpp index a9601896d..75352489e 100644 --- a/fastboot/device/variables.cpp +++ b/fastboot/device/variables.cpp @@ -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) { diff --git a/fastboot/device/variables.h b/fastboot/device/variables.h index a44e72928..63f267024 100644 --- a/fastboot/device/variables.h +++ b/fastboot/device/variables.h @@ -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, |