Felipe Leme | e83f9fb | 2016-11-15 15:08:47 -0800 | [diff] [blame^] | 1 | #define LOG_TAG "dumpstate" |
| 2 | |
| 3 | #include "DumpstateDevice.h" |
| 4 | |
| 5 | #include <log/log.h> |
| 6 | |
| 7 | #include "DumpstateUtil.h" |
| 8 | |
| 9 | namespace android { |
| 10 | namespace hardware { |
| 11 | namespace dumpstate { |
| 12 | namespace V1_0 { |
| 13 | namespace implementation { |
| 14 | |
| 15 | // Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow. |
| 16 | Return<void> DumpstateDevice::dumpstateBoard(const native_handle_t* handle) { |
| 17 | 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 | |
| 41 | IDumpstateDevice* 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 |