blob: a279b895255a5733843f0690e02a3fdf4d1bbc4e [file] [log] [blame]
Felipe Lemee83f9fb2016-11-15 15:08:47 -08001#define LOG_TAG "dumpstate"
2
3#include "DumpstateDevice.h"
4
5#include <log/log.h>
6
7#include "DumpstateUtil.h"
8
9namespace android {
10namespace hardware {
11namespace dumpstate {
12namespace V1_0 {
13namespace implementation {
14
15// Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow.
Colin Cross94a069e2016-11-22 21:31:36 -080016Return<void> DumpstateDevice::dumpstateBoard(const hidl_handle& handle) {
Felipe Lemee83f9fb2016-11-15 15:08:47 -080017 if (handle->numFds < 1) {
18 ALOGE("no FDs\n");
19 return Void();
20 }
21
22 int fd = handle->data[0];
23 if (fd < 0) {
24 ALOGE("invalid FD: %d\n", handle->data[0]);
25 return Void();
26 }
27 ALOGD("DumpstateDevice::dumpstateBoard() FD: %d\n", fd);
28 ALOGI("Dumpstate HIDL not provided by device\n");
29 dprintf(fd, "Dumpstate HIDL not provided by device; providing bogus data.\n");
30
31 // Shows some examples on how to use the libdumpstateutils API.
32 dprintf(fd, "Time now is: ");
33 RunCommandToFd(fd, {"/system/bin/date"});
34 dprintf(fd, "Contents of a small file (/system/etc/hosts):\n");
35 DumpFileToFd(fd, "/system/etc/hosts");
36
37 return Void();
38}
39
40
41IDumpstateDevice* HIDL_FETCH_IDumpstateDevice(const char* /* name */) {
42 // TODO: temporary returning nullptr until it's implemented on master devices
43 return nullptr;
44// return new DumpstateDevice();
45}
46
47} // namespace implementation
48} // namespace V1_0
49} // namespace dumpstate
50} // namespace hardware
51} // namespace android