Merge "fastboot: add new oem command for post wipe userdata"
diff --git a/fastboot/Android.bp b/fastboot/Android.bp
index 81ebf43..fe05553 100644
--- a/fastboot/Android.bp
+++ b/fastboot/Android.bp
@@ -126,7 +126,7 @@
shared_libs: [
"android.hardware.boot@1.0",
"android.hardware.boot@1.1",
- "android.hardware.fastboot@1.0",
+ "android.hardware.fastboot@1.1",
"android.hardware.health@2.0",
"libasyncio",
"libbase",
diff --git a/fastboot/device/commands.cpp b/fastboot/device/commands.cpp
index 2553353..4601960 100644
--- a/fastboot/device/commands.cpp
+++ b/fastboot/device/commands.cpp
@@ -164,6 +164,28 @@
return device->WriteOkay(message);
}
+bool OemPostWipeData(FastbootDevice* device) {
+ auto fastboot_hal = device->fastboot_hal();
+ if (!fastboot_hal) {
+ 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 {
+ device->WriteStatus(FastbootResult::OKAY, "Erasing succeeded");
+ }
+
+ return true;
+}
+
bool EraseHandler(FastbootDevice* device, const std::vector<std::string>& args) {
if (args.size() < 2) {
return device->WriteStatus(FastbootResult::FAIL, "Invalid arguments");
@@ -184,7 +206,18 @@
return device->WriteStatus(FastbootResult::FAIL, "Partition doesn't exist");
}
if (wipe_block_device(handle.fd(), get_block_device_size(handle.fd())) == 0) {
- return device->WriteStatus(FastbootResult::OKAY, "Erasing succeeded");
+ //Perform oem PostWipeData if Android userdata partition has been erased
+ bool support_oem_postwipedata = false;
+ if (partition_name == "userdata") {
+ support_oem_postwipedata = OemPostWipeData(device);
+ }
+
+ if (!support_oem_postwipedata) {
+ return device->WriteStatus(FastbootResult::OKAY, "Erasing succeeded");
+ } else {
+ //Write device status in OemPostWipeData(), so just return true
+ return true;
+ }
}
return device->WriteStatus(FastbootResult::FAIL, "Erasing failed");
}
diff --git a/fastboot/device/fastboot_device.cpp b/fastboot/device/fastboot_device.cpp
index 1b0859f..52ea9f0 100644
--- a/fastboot/device/fastboot_device.cpp
+++ b/fastboot/device/fastboot_device.cpp
@@ -22,7 +22,7 @@
#include <android-base/properties.h>
#include <android-base/strings.h>
#include <android/hardware/boot/1.0/IBootControl.h>
-#include <android/hardware/fastboot/1.0/IFastboot.h>
+#include <android/hardware/fastboot/1.1/IFastboot.h>
#include <fs_mgr.h>
#include <fs_mgr/roots.h>
#include <healthhalutils/HealthHalUtils.h>
@@ -37,7 +37,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;
+using ::android::hardware::fastboot::V1_1::IFastboot;
using ::android::hardware::health::V2_0::get_health_service;
namespace sph = std::placeholders;
diff --git a/fastboot/device/fastboot_device.h b/fastboot/device/fastboot_device.h
index bbe8172..23be721 100644
--- a/fastboot/device/fastboot_device.h
+++ b/fastboot/device/fastboot_device.h
@@ -24,7 +24,7 @@
#include <android/hardware/boot/1.0/IBootControl.h>
#include <android/hardware/boot/1.1/IBootControl.h>
-#include <android/hardware/fastboot/1.0/IFastboot.h>
+#include <android/hardware/fastboot/1.1/IFastboot.h>
#include <android/hardware/health/2.0/IHealth.h>
#include "commands.h"
@@ -53,7 +53,7 @@
return boot_control_hal_;
}
android::sp<android::hardware::boot::V1_1::IBootControl> boot1_1() { return boot1_1_; }
- android::sp<android::hardware::fastboot::V1_0::IFastboot> fastboot_hal() {
+ android::sp<android::hardware::fastboot::V1_1::IFastboot> fastboot_hal() {
return fastboot_hal_;
}
android::sp<android::hardware::health::V2_0::IHealth> health_hal() { return health_hal_; }
@@ -67,7 +67,7 @@
android::sp<android::hardware::boot::V1_0::IBootControl> boot_control_hal_;
android::sp<android::hardware::boot::V1_1::IBootControl> boot1_1_;
android::sp<android::hardware::health::V2_0::IHealth> health_hal_;
- android::sp<android::hardware::fastboot::V1_0::IFastboot> fastboot_hal_;
+ android::sp<android::hardware::fastboot::V1_1::IFastboot> fastboot_hal_;
std::vector<char> download_data_;
std::string active_slot_;
};