From 4cfb5bbbf3c5aee4891496512d9dc19eef799923 Mon Sep 17 00:00:00 2001 From: Keita Date: Tue, 24 Oct 2017 01:58:14 -0300 Subject: shinano-common: Implement dumpstate as a service Change-Id: I77f72b9541b8adcc152fe64e45fd4528cff60f4f --- dumpstate/Android.mk | 32 +++++++---- dumpstate/DumpstateDevice.cpp | 63 ++++++++++++++++++++++ dumpstate/DumpstateDevice.h | 50 +++++++++++++++++ dumpstate/NOTICE | 2 +- .../android.hardware.dumpstate@1.0-service.sony.rc | 4 ++ dumpstate/dumpstate.c | 28 ---------- dumpstate/service.cpp | 41 ++++++++++++++ 7 files changed, 180 insertions(+), 40 deletions(-) create mode 100644 dumpstate/DumpstateDevice.cpp create mode 100644 dumpstate/DumpstateDevice.h create mode 100644 dumpstate/android.hardware.dumpstate@1.0-service.sony.rc delete mode 100644 dumpstate/dumpstate.c create mode 100644 dumpstate/service.cpp (limited to 'dumpstate') diff --git a/dumpstate/Android.mk b/dumpstate/Android.mk index 9c53292..f5fa995 100644 --- a/dumpstate/Android.mk +++ b/dumpstate/Android.mk @@ -1,4 +1,4 @@ -# Copyright (C) 2011 The Android Open Source Project +# Copyright (C) 2016 The Android Open Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,15 +12,25 @@ # See the License for the specific language governing permissions and # limitations under the License. -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_C_INCLUDES := frameworks/native/cmds/dumpstate - -LOCAL_SRC_FILES := dumpstate.c - -LOCAL_MODULE := libdumpstate.sony +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) +LOCAL_MODULE := android.hardware.dumpstate@1.0-service.sony +LOCAL_INIT_RC := android.hardware.dumpstate@1.0-service.sony.rc +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_SRC_FILES := \ + DumpstateDevice.cpp \ + service.cpp +LOCAL_SHARED_LIBRARIES := \ + android.hardware.dumpstate@1.0 \ + libbase \ + libcutils \ + libdumpstateutil \ + libhidlbase \ + libhidltransport \ + libhwbinder \ + liblog \ + libutils LOCAL_MODULE_TAGS := optional - -include $(BUILD_STATIC_LIBRARY) +LOCAL_PROPRIETARY_MODULE := true +include $(BUILD_EXECUTABLE) diff --git a/dumpstate/DumpstateDevice.cpp b/dumpstate/DumpstateDevice.cpp new file mode 100644 index 0000000..6719c75 --- /dev/null +++ b/dumpstate/DumpstateDevice.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "SonyDumpstate" + +#include "DumpstateDevice.h" + +#include + +#include "DumpstateUtil.h" + +using android::os::dumpstate::CommandOptions; +using android::os::dumpstate::DumpFileToFd; +using android::os::dumpstate::RunCommandToFd; + +namespace android { +namespace hardware { +namespace dumpstate { +namespace V1_0 { +namespace implementation { + +// Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow. +Return DumpstateDevice::dumpstateBoard(const hidl_handle& 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(); + } + + DumpFileToFd(fd, "INTERRUPTS", "/proc/interrupts"); + DumpFileToFd(fd, "Power Management Stats", "/proc/msm_pm_stats"); + RunCommandToFd(fd, "SUBSYSTEM TOMBSTONES", {"ls", "-l", "/data/tombstones/ramdump"}, CommandOptions::AS_ROOT); + DumpFileToFd(fd, "BAM DMUX Log", "/d/ipc_logging/bam_dmux/log"); + DumpFileToFd(fd, "SMD Log", "/d/ipc_logging/smd/log"); + DumpFileToFd(fd, "SMD PKT Log", "/d/ipc_logging/smd_pkt/log"); + DumpFileToFd(fd, "IPC Router Log", "/d/ipc_logging/ipc_router/log"); + + return Void(); +} + +} // namespace implementation +} // namespace V1_0 +} // namespace dumpstate +} // namespace hardware +} // namespace android diff --git a/dumpstate/DumpstateDevice.h b/dumpstate/DumpstateDevice.h new file mode 100644 index 0000000..f8585f5 --- /dev/null +++ b/dumpstate/DumpstateDevice.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ANDROID_HARDWARE_DUMPSTATE_V1_0_DUMPSTATEDEVICE_H +#define ANDROID_HARDWARE_DUMPSTATE_V1_0_DUMPSTATEDEVICE_H + +#include +#include +#include + +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_handle; +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 dumpstateBoard(const hidl_handle& h) override; + +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace dumpstate +} // namespace hardware +} // namespace android + +#endif // ANDROID_HARDWARE_DUMPSTATE_V1_0_DUMPSTATEDEVICE_H diff --git a/dumpstate/NOTICE b/dumpstate/NOTICE index a303bd0..e48dd6b 100644 --- a/dumpstate/NOTICE +++ b/dumpstate/NOTICE @@ -1,5 +1,5 @@ - Copyright (C) 2011 The Android Open Source Project + Copyright (C) 2016 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/dumpstate/android.hardware.dumpstate@1.0-service.sony.rc b/dumpstate/android.hardware.dumpstate@1.0-service.sony.rc new file mode 100644 index 0000000..85aa8d1 --- /dev/null +++ b/dumpstate/android.hardware.dumpstate@1.0-service.sony.rc @@ -0,0 +1,4 @@ +service dumpstate-1-0 /vendor/bin/hw/android.hardware.dumpstate@1.0-service.sony + class hal + user system + group system diff --git a/dumpstate/dumpstate.c b/dumpstate/dumpstate.c deleted file mode 100644 index a33cf47..0000000 --- a/dumpstate/dumpstate.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -void dumpstate_board() -{ - dump_file("INTERRUPTS", "/proc/interrupts"); - dump_file("Power Management Stats", "/proc/msm_pm_stats"); - run_command("SUBSYSTEM TOMBSTONES", 5, SU_PATH, "root", "ls", "-l", "/data/tombstones/ramdump", NULL); - dump_file("BAM DMUX Log", "/d/ipc_logging/bam_dmux/log"); - dump_file("SMD Log", "/d/ipc_logging/smd/log"); - dump_file("SMD PKT Log", "/d/ipc_logging/smd_pkt/log"); - dump_file("IPC Router Log", "/d/ipc_logging/ipc_router/log"); -}; diff --git a/dumpstate/service.cpp b/dumpstate/service.cpp new file mode 100644 index 0000000..7885433 --- /dev/null +++ b/dumpstate/service.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#define LOG_TAG "android.hardware.dumpstate@1.0-service.sony" + +#include +#include + +#include "DumpstateDevice.h" + +using ::android::hardware::configureRpcThreadpool; +using ::android::hardware::dumpstate::V1_0::IDumpstateDevice; +using ::android::hardware::dumpstate::V1_0::implementation::DumpstateDevice; +using ::android::hardware::joinRpcThreadpool; +using ::android::OK; +using ::android::sp; + +int main(int /* argc */, char* /* argv */ []) { + sp dumpstate = new DumpstateDevice; + configureRpcThreadpool(1, true /* will join */); + if (dumpstate->registerAsService() != OK) { + ALOGE("Could not register service."); + return 1; + } + joinRpcThreadpool(); + + ALOGE("Service exited!"); + return 1; +} -- cgit v1.2.3