Fastbootd: Use Fastboot AIDL with the help of fastbootshim for legacy fastboot HAL
Bug: 205760652
Test: build & flash & reboot fastboot
Change-Id: I79617a396f536258655bdc28006ac2d0a7ab1912
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
diff --git a/fastboot/device/commands.cpp b/fastboot/device/commands.cpp
index 3799d1f..f8befd3 100644
--- a/fastboot/device/commands.cpp
+++ b/fastboot/device/commands.cpp
@@ -57,8 +57,6 @@
using android::fs_mgr::MetadataBuilder;
using android::hal::CommandResult;
using ::android::hardware::hidl_string;
-using ::android::hardware::fastboot::V1_0::Result;
-using ::android::hardware::fastboot::V1_0::Status;
using android::snapshot::SnapshotManager;
using MergeStatus = android::hal::BootControlClient::MergeStatus;
@@ -203,20 +201,21 @@
return false;
}
- Result ret;
- auto ret_val = fastboot_hal->doOemSpecificErase([&](Result result) { ret = result; });
- if (!ret_val.isOk()) {
- return false;
- }
- if (ret.status == Status::NOT_SUPPORTED) {
- return false;
- } else if (ret.status != Status::SUCCESS) {
- device->WriteStatus(FastbootResult::FAIL, ret.message);
- } else {
+ auto status = fastboot_hal->doOemSpecificErase();
+ if (status.isOk()) {
device->WriteStatus(FastbootResult::OKAY, "Erasing succeeded");
+ return true;
}
-
- return true;
+ switch (status.getExceptionCode()) {
+ case EX_UNSUPPORTED_OPERATION:
+ return false;
+ case EX_SERVICE_SPECIFIC:
+ device->WriteStatus(FastbootResult::FAIL, status.getDescription());
+ return false;
+ default:
+ LOG(ERROR) << "Erase operation failed" << status.getDescription();
+ return false;
+ }
}
bool EraseHandler(FastbootDevice* device, const std::vector<std::string>& args) {
@@ -266,18 +265,16 @@
if (args[0] == "oem postwipedata userdata") {
return device->WriteStatus(FastbootResult::FAIL, "Unable to do oem postwipedata userdata");
}
-
- Result ret;
- auto ret_val = fastboot_hal->doOemCommand(args[0], [&](Result result) { ret = result; });
- if (!ret_val.isOk()) {
- return device->WriteStatus(FastbootResult::FAIL, "Unable to do OEM command");
- }
- if (ret.status != Status::SUCCESS) {
- return device->WriteStatus(FastbootResult::FAIL, ret.message);
+ std::string message;
+ auto status = fastboot_hal->doOemCommand(args[0], &message);
+ if (!status.isOk()) {
+ LOG(ERROR) << "Unable to do OEM command " << args[0].c_str() << status.getDescription();
+ return device->WriteStatus(FastbootResult::FAIL,
+ "Unable to do OEM command " + status.getDescription());
}
- device->WriteInfo(ret.message);
- return device->WriteStatus(FastbootResult::OKAY, ret.message);
+ device->WriteInfo(message);
+ return device->WriteStatus(FastbootResult::OKAY, message);
}
bool DownloadHandler(FastbootDevice* device, const std::vector<std::string>& args) {