summaryrefslogtreecommitdiffstats
path: root/dumpstate/1.0/default
diff options
context:
space:
mode:
authorFelipe Leme <felipeal@google.com>2016-11-15 15:08:47 -0800
committerFelipe Leme <felipeal@google.com>2016-11-18 17:05:34 -0800
commite83f9fbc0294e49892ba3c3b4d8450543ed9c418 (patch)
treea398f06fddab4735947aca25bb711d96d067d7ba /dumpstate/1.0/default
parent17452436fb4b1c8171b7c24ea3d1cec04302eb9c (diff)
downloadplatform_hardware_interfaces-e83f9fbc0294e49892ba3c3b4d8450543ed9c418.tar.gz
platform_hardware_interfaces-e83f9fbc0294e49892ba3c3b4d8450543ed9c418.tar.bz2
platform_hardware_interfaces-e83f9fbc0294e49892ba3c3b4d8450543ed9c418.zip
Initial definition of the Dumpstate HIDL interfaces.
BUG: 31982882 Test: manually built it Change-Id: I3dd1d681061d16059ec9cf67869f20759fb75cd0
Diffstat (limited to 'dumpstate/1.0/default')
-rw-r--r--dumpstate/1.0/default/Android.mk22
-rw-r--r--dumpstate/1.0/default/DumpstateDevice.cpp51
-rw-r--r--dumpstate/1.0/default/DumpstateDevice.h36
3 files changed, 109 insertions, 0 deletions
diff --git a/dumpstate/1.0/default/Android.mk b/dumpstate/1.0/default/Android.mk
new file mode 100644
index 0000000000..4d5c9087e7
--- /dev/null
+++ b/dumpstate/1.0/default/Android.mk
@@ -0,0 +1,22 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.dumpstate@1.0-impl
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_SRC_FILES := \
+ DumpstateDevice.cpp \
+
+LOCAL_SHARED_LIBRARIES := \
+ android.hardware.dumpstate@1.0 \
+ libbase \
+ libcutils \
+ libhidlbase \
+ libhidltransport \
+ libhwbinder \
+ liblog \
+ libutils
+
+LOCAL_STATIC_LIBRARIES := \
+ libdumpstateutil
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/dumpstate/1.0/default/DumpstateDevice.cpp b/dumpstate/1.0/default/DumpstateDevice.cpp
new file mode 100644
index 0000000000..fac4ff310f
--- /dev/null
+++ b/dumpstate/1.0/default/DumpstateDevice.cpp
@@ -0,0 +1,51 @@
+#define LOG_TAG "dumpstate"
+
+#include "DumpstateDevice.h"
+
+#include <log/log.h>
+
+#include "DumpstateUtil.h"
+
+namespace android {
+namespace hardware {
+namespace dumpstate {
+namespace V1_0 {
+namespace implementation {
+
+// Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow.
+Return<void> DumpstateDevice::dumpstateBoard(const native_handle_t* handle) {
+ if (handle->numFds < 1) {
+ ALOGE("no FDs\n");
+ return Void();
+ }
+
+ int fd = handle->data[0];
+ if (fd < 0) {
+ ALOGE("invalid FD: %d\n", handle->data[0]);
+ return Void();
+ }
+ ALOGD("DumpstateDevice::dumpstateBoard() FD: %d\n", fd);
+ ALOGI("Dumpstate HIDL not provided by device\n");
+ dprintf(fd, "Dumpstate HIDL not provided by device; providing bogus data.\n");
+
+ // Shows some examples on how to use the libdumpstateutils API.
+ dprintf(fd, "Time now is: ");
+ RunCommandToFd(fd, {"/system/bin/date"});
+ dprintf(fd, "Contents of a small file (/system/etc/hosts):\n");
+ DumpFileToFd(fd, "/system/etc/hosts");
+
+ return Void();
+}
+
+
+IDumpstateDevice* HIDL_FETCH_IDumpstateDevice(const char* /* name */) {
+ // TODO: temporary returning nullptr until it's implemented on master devices
+ return nullptr;
+// return new DumpstateDevice();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace dumpstate
+} // namespace hardware
+} // namespace android
diff --git a/dumpstate/1.0/default/DumpstateDevice.h b/dumpstate/1.0/default/DumpstateDevice.h
new file mode 100644
index 0000000000..366888d54c
--- /dev/null
+++ b/dumpstate/1.0/default/DumpstateDevice.h
@@ -0,0 +1,36 @@
+#ifndef ANDROID_HARDWARE_DUMPSTATE_V1_0_DUMPSTATEDEVICE_H
+#define ANDROID_HARDWARE_DUMPSTATE_V1_0_DUMPSTATEDEVICE_H
+
+#include <android/hardware/dumpstate/1.0/IDumpstateDevice.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace dumpstate {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::dumpstate::V1_0::IDumpstateDevice;
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::sp;
+
+struct DumpstateDevice : public IDumpstateDevice {
+ // Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow.
+ Return<void> dumpstateBoard(const native_handle_t* fd) override;
+
+};
+
+extern "C" IDumpstateDevice* HIDL_FETCH_IDumpstateDevice(const char* name);
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace dumpstate
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_DUMPSTATE_V1_0_DUMPSTATEDEVICE_H