blob: 42642355bc709df178baf638ad4b25b2d4c5e11e [file] [log] [blame]
Felipe Leme6a276ba2016-11-28 09:42:12 -08001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Felipe Lemee83f9fb2016-11-15 15:08:47 -080017#define LOG_TAG "dumpstate"
18
19#include "DumpstateDevice.h"
20
21#include <log/log.h>
22
23#include "DumpstateUtil.h"
24
25namespace android {
26namespace hardware {
27namespace dumpstate {
28namespace V1_0 {
29namespace implementation {
30
31// Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow.
Colin Cross94a069e2016-11-22 21:31:36 -080032Return<void> DumpstateDevice::dumpstateBoard(const hidl_handle& handle) {
Felipe Lemee83f9fb2016-11-15 15:08:47 -080033 if (handle->numFds < 1) {
34 ALOGE("no FDs\n");
35 return Void();
36 }
37
38 int fd = handle->data[0];
39 if (fd < 0) {
40 ALOGE("invalid FD: %d\n", handle->data[0]);
41 return Void();
42 }
43 ALOGD("DumpstateDevice::dumpstateBoard() FD: %d\n", fd);
44 ALOGI("Dumpstate HIDL not provided by device\n");
45 dprintf(fd, "Dumpstate HIDL not provided by device; providing bogus data.\n");
46
Felipe Leme6a276ba2016-11-28 09:42:12 -080047 // Shows some examples on how to use the libdumpstateutil API.
48 RunCommandToFd(fd, "DATE", {"/system/bin/date"});
49 DumpFileToFd(fd, "HOSTS", "/system/etc/hosts");
Felipe Lemee83f9fb2016-11-15 15:08:47 -080050
51 return Void();
52}
53
54
55IDumpstateDevice* HIDL_FETCH_IDumpstateDevice(const char* /* name */) {
56 // TODO: temporary returning nullptr until it's implemented on master devices
57 return nullptr;
58// return new DumpstateDevice();
59}
60
61} // namespace implementation
62} // namespace V1_0
63} // namespace dumpstate
64} // namespace hardware
65} // namespace android