summaryrefslogtreecommitdiff
path: root/fastboot
diff options
context:
space:
mode:
authorJoseph Jang <josephjang@google.com>2020-10-28 17:33:49 +0800
committerJoseph Jang <josephjang@google.com>2020-10-28 17:34:45 +0800
commita1834d92ddbf913070c4890e40fdfd3b5cd1e02c (patch)
treeee2f1c720d0859735e4c97bb995a7ab83aa3156a /fastboot
parente346369e20b87cc16f302f99bb78dca15791e7cf (diff)
downloadpixel-a1834d92ddbf913070c4890e40fdfd3b5cd1e02c.tar.gz
fastboot: Use doOemSpecificErase() to erase Titan M userdata
Since fastbootd 1.1 add new API doOemSpecificErase() for oem to erase vendor specific data. Try to implement doOemSpecificErase() to notify Tian M to erase userdata when user input 'fastboot erase userdata' in fastbootd. Bug: 169173873 Change-Id: I46a30449aa47031cded182d3290dea4e25dfa013
Diffstat (limited to 'fastboot')
-rw-r--r--fastboot/Android.bp3
-rw-r--r--fastboot/Fastboot.cpp60
-rw-r--r--fastboot/include/fastboot/Fastboot.h13
3 files changed, 38 insertions, 38 deletions
diff --git a/fastboot/Android.bp b/fastboot/Android.bp
index 4ba5231c..bc2c726b 100644
--- a/fastboot/Android.bp
+++ b/fastboot/Android.bp
@@ -14,7 +14,7 @@
// limitations under the License.
cc_library {
- name: "android.hardware.fastboot@1.0-impl.pixel",
+ name: "android.hardware.fastboot@1.1-impl.pixel",
recovery: true,
srcs: [
"Fastboot.cpp",
@@ -28,6 +28,7 @@ cc_library {
"libutils",
"libcutils",
"android.hardware.fastboot@1.0",
+ "android.hardware.fastboot@1.1",
],
static_libs: [
"libnos_for_fastboot",
diff --git a/fastboot/Fastboot.cpp b/fastboot/Fastboot.cpp
index a29148db..93435d69 100644
--- a/fastboot/Fastboot.cpp
+++ b/fastboot/Fastboot.cpp
@@ -31,7 +31,7 @@
namespace android {
namespace hardware {
namespace fastboot {
-namespace V1_0 {
+namespace V1_1 {
namespace implementation {
constexpr const char* BRIGHTNESS_FILE = "/sys/class/backlight/panel0-backlight/brightness";
@@ -99,20 +99,36 @@ Result SetBrightnessLevel(const std::vector<std::string>& args) {
return { Status::FAILURE_UNKNOWN, "Unable to set display brightness" };
}
-Result PostWipeData(const std::vector<std::string>& args) {
- if (!args.size()||((args[0] != "userdata")&&(args[0] != "support"))) {
- return { Status::INVALID_ARGUMENT, "Invalid oem command" };
+Return<void> Fastboot::doOemCommand(const ::android::hardware::hidl_string& oemCmdArgs,
+ doOemCommand_cb _hidl_cb) {
+ const std::unordered_map<std::string, OEMCommandHandler> kOEMCmdMap = {
+ {FB_OEM_SET_BRIGHTNESS, SetBrightnessLevel},
+ };
+
+ auto args = android::base::Split(oemCmdArgs, " ");
+ if (args.size() < 2) {
+ _hidl_cb({ Status::INVALID_ARGUMENT, "Invalid OEM command" });
+ return Void();
}
- if (args[0] == "support") {
- return { Status::SUCCESS, "" };
+ // args[0] will be "oem", args[1] will be the command name
+ auto cmd_handler = kOEMCmdMap.find(args[1]);
+ if (cmd_handler != kOEMCmdMap.end()) {
+ _hidl_cb(cmd_handler->second(std::vector<std::string>(args.begin() + 2, args.end())));
+ } else {
+ _hidl_cb({ Status::FAILURE_UNKNOWN, "Unknown OEM command" });
}
+ return Void();
+}
+
+Return<void> Fastboot::doOemSpecificErase(V1_1::IFastboot::doOemSpecificErase_cb _hidl_cb) {
// Connect to Titan M
::nos::NuggetClient client;
client.Open();
if (!client.IsOpen()) {
- return { Status::FAILURE_UNKNOWN, "open Titan M fail" };
+ _hidl_cb({ Status::FAILURE_UNKNOWN, "open Titan M fail" });
+ return Void();
}
// Tell Titan M to wipe user data
@@ -124,34 +140,12 @@ Result PostWipeData(const std::vector<std::string>& args) {
const uint32_t status
= client.CallApp(APP_ID_NUGGET, NUGGET_PARAM_NUKE_FROM_ORBIT, magic, nullptr);
if (status == APP_SUCCESS) {
- return { Status::SUCCESS, "" };
+ _hidl_cb({ Status::SUCCESS, "" });
+ return Void();
}
}
- return { Status::FAILURE_UNKNOWN, "Titan M user data wipe failed" };
-}
-
-Return<void> Fastboot::doOemCommand(const ::android::hardware::hidl_string& oemCmdArgs,
- doOemCommand_cb _hidl_cb) {
- const std::unordered_map<std::string, OEMCommandHandler> kOEMCmdMap = {
- {FB_OEM_SET_BRIGHTNESS, SetBrightnessLevel},
- {FB_OEM_POST_WIPEDATA, PostWipeData},
- };
-
- auto args = android::base::Split(oemCmdArgs, " ");
- if (args.size() < 2) {
- _hidl_cb({ Status::INVALID_ARGUMENT, "Invalid OEM command" });
- return Void();
- }
-
- // args[0] will be "oem", args[1] will be the command name
- auto cmd_handler = kOEMCmdMap.find(args[1]);
- if (cmd_handler != kOEMCmdMap.end()) {
- _hidl_cb(cmd_handler->second(std::vector<std::string>(args.begin() + 2, args.end())));
- } else {
- _hidl_cb({ Status::FAILURE_UNKNOWN, "Unknown OEM command" });
- }
-
+ _hidl_cb({ Status::FAILURE_UNKNOWN, "Titan M user data wipe failed" });
return Void();
}
@@ -164,7 +158,7 @@ extern "C" IFastboot* HIDL_FETCH_IFastboot(const char* /* name */) {
}
} // namespace implementation
-} // namespace V1_0
+} // namespace V1_1
} // namespace fastboot
} // namespace hardware
} // namespace android
diff --git a/fastboot/include/fastboot/Fastboot.h b/fastboot/include/fastboot/Fastboot.h
index 5280f7cb..2e3afb19 100644
--- a/fastboot/include/fastboot/Fastboot.h
+++ b/fastboot/include/fastboot/Fastboot.h
@@ -16,22 +16,24 @@
#pragma once
-#include <android/hardware/fastboot/1.0/IFastboot.h>
+#include <android/hardware/fastboot/1.1/IFastboot.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
namespace android {
namespace hardware {
namespace fastboot {
-namespace V1_0 {
+namespace V1_1 {
namespace implementation {
#define FB_OEM_SET_BRIGHTNESS "setbrightness"
-#define FB_OEM_POST_WIPEDATA "postwipedata"
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
+using ::android::hardware::fastboot::V1_0::FileSystemType;
+using ::android::hardware::fastboot::V1_0::Status;
+using ::android::hardware::fastboot::V1_0::Result;
struct Fastboot : public IFastboot {
Fastboot();
@@ -44,12 +46,15 @@ struct Fastboot : public IFastboot {
Return<void> getVariant(getVariant_cb _hidl_cb) override;
Return<void> getOffModeChargeState(getOffModeChargeState_cb _hidl_cb) override;
Return<void> getBatteryVoltageFlashingThreshold(getBatteryVoltageFlashingThreshold_cb _hidl_cb) override;
+
+ // Methods from ::android::hardware::fastboot::V1_1::IFastboot follow.
+ Return<void> doOemSpecificErase(V1_1::IFastboot::doOemSpecificErase_cb _hidl_cb) override;
};
extern "C" IFastboot* HIDL_FETCH_IFastboot(const char* name);
} // namespace implementation
-} // namespace V1_0
+} // namespace V1_1
} // namespace fastboot
} // namespace hardware
} // namespace android