Merge "fastboot: add new oem command for post wipe userdata"
This commit is contained in:
commit
012ee0ae0a
4 changed files with 40 additions and 7 deletions
|
@ -126,7 +126,7 @@ cc_binary {
|
|||
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",
|
||||
|
|
|
@ -164,6 +164,28 @@ bool GetVarHandler(FastbootDevice* device, const std::vector<std::string>& args)
|
|||
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 @@ bool EraseHandler(FastbootDevice* device, const std::vector<std::string>& args)
|
|||
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");
|
||||
}
|
||||
|
|
|
@ -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::fs_mgr::Fstab;
|
|||
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;
|
||||
|
|
|
@ -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 @@ class FastbootDevice {
|
|||
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 @@ class FastbootDevice {
|
|||
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_;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue