summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fastboot/1.1-custom/Fastboot.cpp42
-rw-r--r--fastboot/1.1-custom/Fastboot.h2
2 files changed, 42 insertions, 2 deletions
diff --git a/fastboot/1.1-custom/Fastboot.cpp b/fastboot/1.1-custom/Fastboot.cpp
index 4515ef9..862fe31 100644
--- a/fastboot/1.1-custom/Fastboot.cpp
+++ b/fastboot/1.1-custom/Fastboot.cpp
@@ -16,12 +16,19 @@
#include "Fastboot.h"
+#include <unordered_map>
+
+#include <android-base/properties.h>
+#include <android-base/strings.h>
+
namespace android {
namespace hardware {
namespace fastboot {
namespace V1_1 {
namespace implementation {
+using OEMCommandHandler = std::function<Result(const std::vector<std::string>&)>;
+
// Methods from ::android::hardware::fastboot::V1_1::IFastboot follow.
Return<void> Fastboot::getPartitionType(const hidl_string& /* partitionName */,
getPartitionType_cb _hidl_cb) {
@@ -29,8 +36,39 @@ Return<void> Fastboot::getPartitionType(const hidl_string& /* partitionName */,
return Void();
}
-Return<void> Fastboot::doOemCommand(const hidl_string& /* oemCmdArgs */, doOemCommand_cb _hidl_cb) {
- _hidl_cb({Status::FAILURE_UNKNOWN, "Command not supported"});
+Result GetProp(const std::vector<std::string>& args) {
+ if (!args.size()) {
+ return { Status::INVALID_ARGUMENT, "Property unspecified" };
+ }
+
+ auto property = android::base::GetProperty(args[0], "");
+
+ if (!property.empty()) {
+ return { Status::SUCCESS, args[0] + ": " + property };
+ }
+
+ return { Status::FAILURE_UNKNOWN, "Unable to get property" };
+}
+
+Return<void> Fastboot::doOemCommand(const hidl_string& oemCmdArgs, doOemCommand_cb _hidl_cb) {
+ const std::unordered_map<std::string, OEMCommandHandler> kOEMCmdMap = {
+ {FB_OEM_GET_PROP, GetProp},
+ };
+
+ 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" });
+ }
+
return Void();
}
diff --git a/fastboot/1.1-custom/Fastboot.h b/fastboot/1.1-custom/Fastboot.h
index 09b39c2..b07d0b7 100644
--- a/fastboot/1.1-custom/Fastboot.h
+++ b/fastboot/1.1-custom/Fastboot.h
@@ -24,6 +24,8 @@ namespace fastboot {
namespace V1_1 {
namespace implementation {
+#define FB_OEM_GET_PROP "getprop"
+
using ::android::hardware::hidl_string;
using ::android::hardware::Return;
using ::android::hardware::Void;