1 /*
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
17 #define LOG_TAG "dumpstate"
18
19 #include "DumpstateDevice.h"
20
21 #include <log/log.h>
22 #include <cutils/properties.h>
23
24 #include "DumpstateUtil.h"
25
26 using android::os::dumpstate::CommandOptions;
27 using android::os::dumpstate::DumpFileToFd;
28 using android::os::dumpstate::RunCommandToFd;
29
30 namespace android {
31 namespace hardware {
32 namespace dumpstate {
33 namespace V1_0 {
34 namespace implementation {
35
36 // Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow.
dumpstateBoard(const hidl_handle & handle)37 Return<void> DumpstateDevice::dumpstateBoard(const hidl_handle& handle) {
38 if (handle->numFds < 1) {
39 ALOGE("no FDs\n");
40 return Void();
41 }
42
43 int fd = handle->data[0];
44 if (fd < 0) {
45 ALOGE("invalid FD: %d\n", handle->data[0]);
46 return Void();
47 }
48
49 /* ask init.dragon.rc to dump the charging state and wait */
50 property_set("debug.bq25892", "dump");
51 sleep(1);
52
53 DumpFileToFd(fd, "EC Version", "/sys/class/chromeos/cros_ec/version");
54 RunCommandToFd(fd, "FW Version", {"fwtool", "vboot"}, CommandOptions::WithTimeout(5).Build());
55
56 DumpFileToFd(fd, "INTERRUPTS", "/proc/interrupts");
57 // This is the file created by setting debug.bq25892.
58 DumpFileToFd(fd, "Charger chip registers", "/data/misc/fw_logs/bq25892.txt");
59
60 DumpFileToFd(fd, "Battery gas gauge", "/sys/class/power_supply/bq27742-0/uevent");
61 DumpFileToFd(fd, "Touchscreen firmware updater", "/data/misc/touchfwup/rmi4update.txt");
62 DumpFileToFd(fd, "Ion heap", "/d/ion/heaps/system");
63
64 return Void();
65 }
66
67 } // namespace implementation
68 } // namespace V1_0
69 } // namespace dumpstate
70 } // namespace hardware
71 } // namespace android
72