upgrade dumpstate from hidl to aidl

Bug: 240530709
Test: adb bugreport
Change-Id: I0cd75fa84e495037a55284b43bd0ee53e5379d4c
This commit is contained in:
Adam Shih 2022-10-12 15:26:51 +08:00 committed by TreeHugger Robot
parent a8295107d3
commit 0e57a35f5d
11 changed files with 155 additions and 221 deletions

View file

@ -452,7 +452,7 @@ PRODUCT_PACKAGES += \
# dumpstate HAL # dumpstate HAL
PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \
android.hardware.dumpstate@1.1-service.gs101 android.hardware.dumpstate-service.gs101
# AoC support # AoC support
PRODUCT_PACKAGES += \ PRODUCT_PACKAGES += \

28
dumpstate/Android.bp Normal file
View file

@ -0,0 +1,28 @@
package {
default_applicable_licenses: ["Android-Apache-2.0"],
}
cc_binary {
name: "android.hardware.dumpstate-service.gs101",
srcs: [
"Dumpstate.cpp",
"service.cpp",
],
init_rc: ["android.hardware.dumpstate-service.gs101.rc"],
vintf_fragments: ["android.hardware.dumpstate-service.gs101.xml"],
cflags: [
"-Wall",
"-Werror",
],
shared_libs: [
"libbase",
"libbinder_ndk",
"libcutils",
"libdumpstateutil",
"liblog",
"libutils",
"android.hardware.dumpstate-V1-ndk",
],
vendor: true,
relative_install_path: "hw",
}

View file

@ -1,47 +0,0 @@
#
# Copyright 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.
#
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := android.hardware.dumpstate@1.1-service.gs101
LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
LOCAL_LICENSE_CONDITIONS := notice
LOCAL_NOTICE_FILE := $(LOCAL_PATH)/../NOTICE
LOCAL_INIT_RC := android.hardware.dumpstate@1.1-service.gs101.rc
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_SRC_FILES := \
DumpstateDevice.cpp \
service.cpp
LOCAL_SHARED_LIBRARIES := \
android.hardware.dumpstate@1.0 \
android.hardware.dumpstate@1.1 \
libbase \
libcutils \
libdumpstateutil \
libhidlbase \
libhidltransport \
libhwbinder \
liblog \
libutils
LOCAL_CFLAGS := -Werror -Wall
LOCAL_MODULE_TAGS := optional
LOCAL_PROPRIETARY_MODULE := true
include $(BUILD_EXECUTABLE)

View file

@ -22,12 +22,11 @@
#include <android-base/stringprintf.h> #include <android-base/stringprintf.h>
#include <android-base/properties.h> #include <android-base/properties.h>
#include <android-base/unique_fd.h> #include <android-base/unique_fd.h>
#include <hidl/HidlBinderSupport.h>
#include <log/log.h> #include <log/log.h>
#include <pthread.h> #include <pthread.h>
#include <sys/stat.h> #include <sys/stat.h>
#include "DumpstateDevice.h" #include "Dumpstate.h"
#include "DumpstateUtil.h" #include "DumpstateUtil.h"
@ -56,11 +55,10 @@ using android::os::dumpstate::DumpFileToFd;
using android::os::dumpstate::PropertiesHelper; using android::os::dumpstate::PropertiesHelper;
using android::os::dumpstate::RunCommandToFd; using android::os::dumpstate::RunCommandToFd;
namespace aidl {
namespace android { namespace android {
namespace hardware { namespace hardware {
namespace dumpstate { namespace dumpstate {
namespace V1_1 {
namespace implementation {
#define GPS_LOG_PREFIX "gl-" #define GPS_LOG_PREFIX "gl-"
#define GPS_MCU_LOG_PREFIX "esw-" #define GPS_MCU_LOG_PREFIX "esw-"
@ -146,9 +144,9 @@ void dumpLogs(int fd, std::string srcDir, std::string destDir, int maxFileNum,
void dumpRilLogs(int fd, std::string destDir) { void dumpRilLogs(int fd, std::string destDir) {
std::string rilLogDir = std::string rilLogDir =
android::base::GetProperty(RIL_LOG_DIRECTORY_PROPERTY, RIL_LOG_DIRECTORY); ::android::base::GetProperty(RIL_LOG_DIRECTORY_PROPERTY, RIL_LOG_DIRECTORY);
int maxFileNum = android::base::GetIntProperty(RIL_LOG_NUMBER_PROPERTY, 50); int maxFileNum = ::android::base::GetIntProperty(RIL_LOG_NUMBER_PROPERTY, 50);
const std::string currentLogDir = rilLogDir + "/cur"; const std::string currentLogDir = rilLogDir + "/cur";
const std::string previousLogDir = rilLogDir + "/prev"; const std::string previousLogDir = rilLogDir + "/prev";
@ -193,7 +191,7 @@ void dumpGpsLogs(int fd, std::string destDir) {
const std::string gpsLogDir = GPS_LOG_DIRECTORY; const std::string gpsLogDir = GPS_LOG_DIRECTORY;
const std::string gpsTmpLogDir = gpsLogDir + "/.tmp"; const std::string gpsTmpLogDir = gpsLogDir + "/.tmp";
const std::string gpsDestDir = destDir + "/gps"; const std::string gpsDestDir = destDir + "/gps";
int maxFileNum = android::base::GetIntProperty(GPS_LOG_NUMBER_PROPERTY, 20); int maxFileNum = ::android::base::GetIntProperty(GPS_LOG_NUMBER_PROPERTY, 20);
RunCommandToFd(fd, "MKDIR GPS LOG", {"/vendor/bin/mkdir", "-p", gpsDestDir.c_str()}, RunCommandToFd(fd, "MKDIR GPS LOG", {"/vendor/bin/mkdir", "-p", gpsDestDir.c_str()},
CommandOptions::WithTimeout(2).Build()); CommandOptions::WithTimeout(2).Build());
@ -217,7 +215,7 @@ void dumpCameraLogs(int fd, const std::string &destDir) {
} }
timepoint_t startSection(int fd, const std::string &sectionName) { timepoint_t startSection(int fd, const std::string &sectionName) {
android::base::WriteStringToFd( ::android::base::WriteStringToFd(
"\n" "\n"
"------ Section start: " + sectionName + " ------\n" "------ Section start: " + sectionName + " ------\n"
"\n", fd); "\n", fd);
@ -229,7 +227,7 @@ void endSection(int fd, const std::string &sectionName, timepoint_t startTime) {
auto elapsedMsec = std::chrono::duration_cast<std::chrono::milliseconds> auto elapsedMsec = std::chrono::duration_cast<std::chrono::milliseconds>
(endTime - startTime).count(); (endTime - startTime).count();
android::base::WriteStringToFd( ::android::base::WriteStringToFd(
"\n" "\n"
"------ Section end: " + sectionName + " ------\n" "------ Section end: " + sectionName + " ------\n"
"Elapsed msec: " + std::to_string(elapsedMsec) + "\n" "Elapsed msec: " + std::to_string(elapsedMsec) + "\n"
@ -241,13 +239,13 @@ void endSection(int fd, const std::string &sectionName, timepoint_t startTime) {
// related to each other - for instance, for a Foo peripheral - please add them // related to each other - for instance, for a Foo peripheral - please add them
// to a new dump function and include it in this table so it can be accessed from the // to a new dump function and include it in this table so it can be accessed from the
// command line, e.g.: // command line, e.g.:
// lshal debug android.hardware.dumpstate@1.0::IDumpstateDevice/default foo // dumpsys android.hardware.dumpstate.IDumpstateDevice/default foo
// //
// However, if your addition generates attachments and/or binary data for the // However, if your addition generates attachments and/or binary data for the
// bugreport (i.e. if it requires two file descriptors to execute), it must not be // bugreport (i.e. if it requires two file descriptors to execute), it must not be
// added to this table and should instead be added to dumpstateBoard() below. // added to this table and should instead be added to dumpstateBoard() below.
DumpstateDevice::DumpstateDevice() Dumpstate::Dumpstate()
: mTextSections{ : mTextSections{
{ "pre-touch", [this](int fd) { dumpPreTouchSection(fd); } }, { "pre-touch", [this](int fd) { dumpPreTouchSection(fd); } },
{ "wlan", [this](int fd) { dumpWlanSection(fd); } }, { "wlan", [this](int fd) { dumpWlanSection(fd); } },
@ -264,9 +262,9 @@ DumpstateDevice::DumpstateDevice()
} { } {
} }
// Dump data requested by an argument to the "debug" HAL interface, or help info // Dump data requested by an argument to the "dump" interface, or help info
// if the specified section is not supported. // if the specified section is not supported.
void DumpstateDevice::dumpTextSection(int fd, const std::string &sectionName) { void Dumpstate::dumpTextSection(int fd, const std::string &sectionName) {
bool dumpAll = (sectionName == kAllSections); bool dumpAll = (sectionName == kAllSections);
for (const auto &section : mTextSections) { for (const auto &section : mTextSections) {
@ -304,23 +302,23 @@ void DumpstateDevice::dumpTextSection(int fd, const std::string &sectionName) {
} }
// An unsupported section was requested on the command line // An unsupported section was requested on the command line
android::base::WriteStringToFd("Unrecognized text section: " + sectionName + "\n", fd); ::android::base::WriteStringToFd("Unrecognized text section: " + sectionName + "\n", fd);
android::base::WriteStringToFd("Try \"" + kAllSections + "\" or one of the following:", fd); ::android::base::WriteStringToFd("Try \"" + kAllSections + "\" or one of the following:", fd);
for (const auto &section : mTextSections) { for (const auto &section : mTextSections) {
android::base::WriteStringToFd(" " + section.first, fd); ::android::base::WriteStringToFd(" " + section.first, fd);
} }
android::base::WriteStringToFd("\nNote: sections with attachments (e.g. modem) are" ::android::base::WriteStringToFd("\nNote: sections with attachments (e.g. modem) are"
"not avalable from the command line.\n", fd); "not avalable from the command line.\n", fd);
} }
// Dump items related to wlan // Dump items related to wlan
void DumpstateDevice::dumpWlanSection(int fd) { void Dumpstate::dumpWlanSection(int fd) {
RunCommandToFd(fd, "WLAN Debug Dump", {"/vendor/bin/sh", "-c", RunCommandToFd(fd, "WLAN Debug Dump", {"/vendor/bin/sh", "-c",
"cat /sys/wifi/dump_start"}); "cat /sys/wifi/dump_start"});
} }
// Dump items related to power and battery // Dump items related to power and battery
void DumpstateDevice::dumpPowerSection(int fd) { void Dumpstate::dumpPowerSection(int fd) {
struct stat buffer; struct stat buffer;
RunCommandToFd(fd, "Power Stats Times", {"/vendor/bin/sh", "-c", RunCommandToFd(fd, "Power Stats Times", {"/vendor/bin/sh", "-c",
@ -505,7 +503,7 @@ void DumpstateDevice::dumpPowerSection(int fd) {
} }
// Dump items related to thermal // Dump items related to thermal
void DumpstateDevice::dumpThermalSection(int fd) { void Dumpstate::dumpThermalSection(int fd) {
RunCommandToFd(fd, "Temperatures", {"/vendor/bin/sh", "-c", RunCommandToFd(fd, "Temperatures", {"/vendor/bin/sh", "-c",
"for f in /sys/class/thermal/thermal* ; do " "for f in /sys/class/thermal/thermal* ; do "
"type=`cat $f/type` ; temp=`cat $f/temp` ; echo \"$type: $temp\" ; " "type=`cat $f/type` ; temp=`cat $f/temp` ; echo \"$type: $temp\" ; "
@ -537,7 +535,7 @@ void DumpstateDevice::dumpThermalSection(int fd) {
} }
// Dump items related to touch // Dump items related to touch
void DumpstateDevice::dumpPreTouchSection(int fd) { void Dumpstate::dumpPreTouchSection(int fd) {
const char nvt_spi_path[] = "/sys/class/spi_master/spi11/spi11.0/input/nvt_touch"; const char nvt_spi_path[] = "/sys/class/spi_master/spi11/spi11.0/input/nvt_touch";
char cmd[256]; char cmd[256];
@ -573,7 +571,7 @@ void DumpstateDevice::dumpPreTouchSection(int fd) {
} }
} }
void DumpstateDevice::dumpTouchSection(int fd) { void Dumpstate::dumpTouchSection(int fd) {
const char stm_cmd_path[4][50] = {"/sys/class/spi_master/spi11/spi11.0", const char stm_cmd_path[4][50] = {"/sys/class/spi_master/spi11/spi11.0",
"/proc/fts/driver_test", "/proc/fts/driver_test",
"/sys/class/spi_master/spi6/spi6.0", "/sys/class/spi_master/spi6/spi6.0",
@ -816,7 +814,7 @@ void DumpstateDevice::dumpTouchSection(int fd) {
} }
// Dump items related to CPUs // Dump items related to CPUs
void DumpstateDevice::dumpCpuSection(int fd) { void Dumpstate::dumpCpuSection(int fd) {
DumpFileToFd(fd, "CPU present", "/sys/devices/system/cpu/present"); DumpFileToFd(fd, "CPU present", "/sys/devices/system/cpu/present");
DumpFileToFd(fd, "CPU online", "/sys/devices/system/cpu/online"); DumpFileToFd(fd, "CPU online", "/sys/devices/system/cpu/online");
RunCommandToFd(fd, "CPU time-in-state", {"/vendor/bin/sh", "-c", RunCommandToFd(fd, "CPU time-in-state", {"/vendor/bin/sh", "-c",
@ -836,7 +834,7 @@ void DumpstateDevice::dumpCpuSection(int fd) {
} }
// Dump items related to Devfreq & BTS // Dump items related to Devfreq & BTS
void DumpstateDevice::dumpDevfreqSection(int fd) { void Dumpstate::dumpDevfreqSection(int fd) {
DumpFileToFd(fd, "MIF DVFS", DumpFileToFd(fd, "MIF DVFS",
"/sys/devices/platform/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/time_in_state"); "/sys/devices/platform/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/time_in_state");
DumpFileToFd(fd, "INT DVFS", DumpFileToFd(fd, "INT DVFS",
@ -857,7 +855,7 @@ void DumpstateDevice::dumpDevfreqSection(int fd) {
} }
// Dump items related to memory // Dump items related to memory
void DumpstateDevice::dumpMemorySection(int fd) { void Dumpstate::dumpMemorySection(int fd) {
RunCommandToFd(fd, "ION HEAPS", {"/vendor/bin/sh", "-c", RunCommandToFd(fd, "ION HEAPS", {"/vendor/bin/sh", "-c",
"for d in $(ls -d /d/ion/*); do " "for d in $(ls -d /d/ion/*); do "
"if [ -f $d ]; then " "if [ -f $d ]; then "
@ -883,7 +881,7 @@ void DumpstateDevice::dumpMemorySection(int fd) {
} }
// Dump items related to display // Dump items related to display
void DumpstateDevice::dumpDisplaySection(int fd) { void Dumpstate::dumpDisplaySection(int fd) {
DumpFileToFd(fd, "CRTC-0 underrun count", "/sys/kernel/debug/dri/0/crtc-0/underrun_cnt"); DumpFileToFd(fd, "CRTC-0 underrun count", "/sys/kernel/debug/dri/0/crtc-0/underrun_cnt");
DumpFileToFd(fd, "CRTC-0 crc count", "/sys/kernel/debug/dri/0/crtc-0/crc_cnt"); DumpFileToFd(fd, "CRTC-0 crc count", "/sys/kernel/debug/dri/0/crtc-0/crc_cnt");
DumpFileToFd(fd, "CRTC-0 ecc count", "/sys/kernel/debug/dri/0/crtc-0/ecc_cnt"); DumpFileToFd(fd, "CRTC-0 ecc count", "/sys/kernel/debug/dri/0/crtc-0/ecc_cnt");
@ -909,14 +907,14 @@ void DumpstateDevice::dumpDisplaySection(int fd) {
} }
// Dump items related to sensors usf. // Dump items related to sensors usf.
void DumpstateDevice::dumpSensorsUSFSection(int fd) { void Dumpstate::dumpSensorsUSFSection(int fd) {
CommandOptions options = CommandOptions::WithTimeout(2).Build(); CommandOptions options = CommandOptions::WithTimeout(2).Build();
RunCommandToFd(fd, "USF statistics", RunCommandToFd(fd, "USF statistics",
{"/vendor/bin/sh", "-c", "usf_stats get --all"}, {"/vendor/bin/sh", "-c", "usf_stats get --all"},
options); options);
if (!PropertiesHelper::IsUserBuild()) { if (!PropertiesHelper::IsUserBuild()) {
// Not a user build, if this is also not a production device dump the USF registry. // Not a user build, if this is also not a production device dump the USF registry.
std::string hwRev = android::base::GetProperty(HW_REVISION, ""); std::string hwRev = ::android::base::GetProperty(HW_REVISION, "");
if (hwRev.find("PROTO") != std::string::npos || if (hwRev.find("PROTO") != std::string::npos ||
hwRev.find("EVT") != std::string::npos || hwRev.find("EVT") != std::string::npos ||
hwRev.find("DVT") != std::string::npos) { hwRev.find("DVT") != std::string::npos) {
@ -931,13 +929,13 @@ void DumpstateDevice::dumpSensorsUSFSection(int fd) {
} }
// Dump items that don't fit well into any other section // Dump items that don't fit well into any other section
void DumpstateDevice::dumpMiscSection(int fd) { void Dumpstate::dumpMiscSection(int fd) {
RunCommandToFd(fd, "VENDOR PROPERTIES", {"/vendor/bin/getprop"}); RunCommandToFd(fd, "VENDOR PROPERTIES", {"/vendor/bin/getprop"});
DumpFileToFd(fd, "VENDOR PROC DUMP", "/proc/vendor_sched/dump_task"); DumpFileToFd(fd, "VENDOR PROC DUMP", "/proc/vendor_sched/dump_task");
} }
// Dump essential camera debugging logs // Dump essential camera debugging logs
void DumpstateDevice::dumpCameraSection(int fd) { void Dumpstate::dumpCameraSection(int fd) {
RunCommandToFd(fd, "Camera HAL Graph State Dump", {"/vendor/bin/sh", "-c", RunCommandToFd(fd, "Camera HAL Graph State Dump", {"/vendor/bin/sh", "-c",
"for f in $(ls -t /data/vendor/camera/hal_graph_state*.txt |head -1); do " "for f in $(ls -t /data/vendor/camera/hal_graph_state*.txt |head -1); do "
"echo $f ; cat $f ; done"}, "echo $f ; cat $f ; done"},
@ -959,20 +957,20 @@ static void *dumpModemThread(void *data) {
RunCommandToFd(STDOUT_FILENO, "MKDIR MODEM LOG", {"/vendor/bin/mkdir", "-p", modemLogAllDir.c_str()}, CommandOptions::WithTimeout(2).Build()); RunCommandToFd(STDOUT_FILENO, "MKDIR MODEM LOG", {"/vendor/bin/mkdir", "-p", modemLogAllDir.c_str()}, CommandOptions::WithTimeout(2).Build());
bool modemLogEnabled = android::base::GetBoolProperty(MODEM_LOGGING_PERSIST_PROPERTY, false); bool modemLogEnabled = ::android::base::GetBoolProperty(MODEM_LOGGING_PERSIST_PROPERTY, false);
if (modemLogEnabled && android::base::GetProperty(MODEM_LOGGING_PATH_PROPERTY, "") == MODEM_LOG_DIRECTORY) { if (modemLogEnabled && ::android::base::GetProperty(MODEM_LOGGING_PATH_PROPERTY, "") == MODEM_LOG_DIRECTORY) {
bool modemLogStarted = android::base::GetBoolProperty(MODEM_LOGGING_STATUS_PROPERTY, false); bool modemLogStarted = ::android::base::GetBoolProperty(MODEM_LOGGING_STATUS_PROPERTY, false);
int maxFileNum = android::base::GetIntProperty(MODEM_LOGGING_NUMBER_BUGREPORT_PROPERTY, 100); int maxFileNum = ::android::base::GetIntProperty(MODEM_LOGGING_NUMBER_BUGREPORT_PROPERTY, 100);
if (modemLogStarted) { if (modemLogStarted) {
android::base::SetProperty(MODEM_LOGGING_PROPERTY, "false"); ::android::base::SetProperty(MODEM_LOGGING_PROPERTY, "false");
ALOGD("Stopping modem logging...\n"); ALOGD("Stopping modem logging...\n");
} else { } else {
ALOGD("modem logging is not running\n"); ALOGD("modem logging is not running\n");
} }
for (int i = 0; i < 15; i++) { for (int i = 0; i < 15; i++) {
if (!android::base::GetBoolProperty(MODEM_LOGGING_STATUS_PROPERTY, false)) { if (!::android::base::GetBoolProperty(MODEM_LOGGING_STATUS_PROPERTY, false)) {
ALOGD("modem logging stopped\n"); ALOGD("modem logging stopped\n");
sleep(1); sleep(1);
break; break;
@ -984,18 +982,18 @@ static void *dumpModemThread(void *data) {
if (modemLogStarted) { if (modemLogStarted) {
ALOGD("Restarting modem logging...\n"); ALOGD("Restarting modem logging...\n");
android::base::SetProperty(MODEM_LOGGING_PROPERTY, "true"); ::android::base::SetProperty(MODEM_LOGGING_PROPERTY, "true");
} }
} }
if (!PropertiesHelper::IsUserBuild()) { if (!PropertiesHelper::IsUserBuild()) {
bool gpsLogEnabled = android::base::GetBoolProperty(GPS_LOGGING_STATUS_PROPERTY, false); bool gpsLogEnabled = ::android::base::GetBoolProperty(GPS_LOGGING_STATUS_PROPERTY, false);
bool tcpdumpEnabled = android::base::GetBoolProperty(TCPDUMP_PERSIST_PROPERTY, false); bool tcpdumpEnabled = ::android::base::GetBoolProperty(TCPDUMP_PERSIST_PROPERTY, false);
bool cameraLogsEnabled = android::base::GetBoolProperty( bool cameraLogsEnabled = ::android::base::GetBoolProperty(
"vendor.camera.debug.camera_performance_analyzer.attach_to_bugreport", true); "vendor.camera.debug.camera_performance_analyzer.attach_to_bugreport", true);
if (tcpdumpEnabled) { if (tcpdumpEnabled) {
dumpLogs(STDOUT_FILENO, tcpdumpLogDir, modemLogAllDir, android::base::GetIntProperty(TCPDUMP_NUMBER_BUGREPORT, 5), TCPDUMP_LOG_PREFIX); dumpLogs(STDOUT_FILENO, tcpdumpLogDir, modemLogAllDir, ::android::base::GetIntProperty(TCPDUMP_NUMBER_BUGREPORT, 5), TCPDUMP_LOG_PREFIX);
} }
if (gpsLogEnabled) { if (gpsLogEnabled) {
@ -1020,7 +1018,7 @@ static void *dumpModemThread(void *data) {
RunCommandToFd(STDOUT_FILENO, "CHG PERM", {"/vendor/bin/chmod", "a+w", modemLogCombined.c_str()}, CommandOptions::WithTimeout(2).Build()); RunCommandToFd(STDOUT_FILENO, "CHG PERM", {"/vendor/bin/chmod", "a+w", modemLogCombined.c_str()}, CommandOptions::WithTimeout(2).Build());
std::vector<uint8_t> buffer(65536); std::vector<uint8_t> buffer(65536);
android::base::unique_fd fdLog(TEMP_FAILURE_RETRY(open(modemLogCombined.c_str(), O_RDONLY | O_CLOEXEC | O_NONBLOCK))); ::android::base::unique_fd fdLog(TEMP_FAILURE_RETRY(open(modemLogCombined.c_str(), O_RDONLY | O_CLOEXEC | O_NONBLOCK)));
ALOGD("Going to write to dumpstate board binary\n"); ALOGD("Going to write to dumpstate board binary\n");
if (fdLog >= 0) { if (fdLog >= 0) {
@ -1053,53 +1051,47 @@ static void *dumpModemThread(void *data) {
return NULL; return NULL;
} }
// Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow. ndk::ScopedAStatus Dumpstate::dumpstateBoard(const std::vector<::ndk::ScopedFileDescriptor>& in_fds,
Return<void> DumpstateDevice::dumpstateBoard(const hidl_handle &handle) { IDumpstateDevice::DumpstateMode in_mode,
// Ignore return value, just return an empty status. int64_t in_timeoutMillis) {
dumpstateBoard_1_1(handle, DumpstateMode::DEFAULT, 30 * 1000 /* timeoutMillis */);
return Void();
}
// Methods from ::android::hardware::dumpstate::V1_1::IDumpstateDevice follow.
Return<DumpstateStatus> DumpstateDevice::dumpstateBoard_1_1(const hidl_handle& handle,
const DumpstateMode mode,
const uint64_t timeoutMillis) {
// Unused arguments. // Unused arguments.
(void) timeoutMillis; (void) in_timeoutMillis;
if (handle == nullptr || handle->numFds < 1) { if (in_fds.size() < 1) {
ALOGE("no FDs\n"); ALOGE("no FDs\n");
return DumpstateStatus::ILLEGAL_ARGUMENT; return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
"No file descriptor");
} }
int fd = handle->data[0]; int fd = in_fds[0].get();
if (fd < 0) { if (fd < 0) {
ALOGE("invalid FD: %d\n", handle->data[0]); ALOGE("invalid FD: %d\n", fd);
return DumpstateStatus::ILLEGAL_ARGUMENT; return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
"Invalid file descriptor");
} }
if (mode == DumpstateMode::WEAR) { if (in_mode == IDumpstateDevice::DumpstateMode::WEAR) {
// We aren't a Wear device. // We aren't a Wear device.
ALOGE("Unsupported mode: %d\n", mode); ALOGE("Unsupported mode: %d\n", in_mode);
return DumpstateStatus::UNSUPPORTED_MODE; return ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(ERROR_UNSUPPORTED_MODE,
} else if (mode < DumpstateMode::FULL || mode > DumpstateMode::PROTO) { "Unsupported mode");
ALOGE("Invalid mode: %d\n", mode); } else if (in_mode < IDumpstateDevice::DumpstateMode::FULL || in_mode > IDumpstateDevice::DumpstateMode::PROTO) {
return DumpstateStatus::ILLEGAL_ARGUMENT; ALOGE("Invalid mode: %d\n", in_mode);
return ndk::ScopedAStatus::fromExceptionCodeWithMessage(EX_ILLEGAL_ARGUMENT,
"Invalid mode");
} }
// Create thread to collect modem related logs // Create thread to collect modem related logs
bool VerboseLogging;
getVerboseLoggingEnabled(&VerboseLogging);
pthread_t modemThreadHandle = 0; pthread_t modemThreadHandle = 0;
if (getVerboseLoggingEnabled()) { if (VerboseLogging && in_fds.size() > 1) {
if (handle->numFds < 2) { int fdModem = in_fds[1].get();
ALOGE("no FD for modem\n"); if (pthread_create(&modemThreadHandle, NULL, dumpModemThread, (void *)((long)fdModem)) != 0) {
} else { ALOGE("could not create thread for dumpModem\n");
int fdModem = handle->data[1];
if (pthread_create(&modemThreadHandle, NULL, dumpModemThread, (void *)((long)fdModem)) != 0) {
ALOGE("could not create thread for dumpModem\n");
}
} }
} else { } else {
ALOGD("Verbose logging is not enabled\n"); ALOGD("Verbose logging is not enabled or no fd for modem.\n");
} }
dumpTextSection(fd, kAllSections); dumpTextSection(fd, kAllSections);
@ -1108,46 +1100,40 @@ Return<DumpstateStatus> DumpstateDevice::dumpstateBoard_1_1(const hidl_handle& h
pthread_join(modemThreadHandle, NULL); pthread_join(modemThreadHandle, NULL);
} }
return DumpstateStatus::OK; return ndk::ScopedAStatus::ok();
} }
Return<void> DumpstateDevice::setVerboseLoggingEnabled(const bool enable) { ndk::ScopedAStatus Dumpstate::setVerboseLoggingEnabled(bool in_enable) {
::android::base::SetProperty(kVerboseLoggingProperty, enable ? "true" : "false"); ::android::base::SetProperty(kVerboseLoggingProperty, in_enable ? "true" : "false");
return Void(); return ndk::ScopedAStatus::ok();
} }
Return<bool> DumpstateDevice::getVerboseLoggingEnabled() { ndk::ScopedAStatus Dumpstate::getVerboseLoggingEnabled(bool* _aidl_return) {
return ::android::base::GetBoolProperty(kVerboseLoggingProperty, false); *_aidl_return = ::android::base::GetBoolProperty(kVerboseLoggingProperty, false);
return ndk::ScopedAStatus::ok();
} }
// Since HALs that support the debug() interface are automatically invoked during // Since AIDLs that support the dump() interface are automatically invoked during
// bugreport generation and we don't want to generate a second copy of the same // bugreport generation and we don't want to generate a second copy of the same
// data that will go into dumpstate_board.txt, this function will only do // data that will go into dumpstate_board.txt, this function will only do
// something if it is called with an option, e.g. // something if it is called with an option, e.g.
// lshal debug android.hardware.dumpstate@1.0::IDumpstateDevice/default all // dumpsys android.hardware.dumpstate.IDumpstateDevice/default all
// //
// Also, note that sections which generate attachments and/or binary data when // Also, note that sections which generate attachments and/or binary data when
// included in a bugreport are not available through the debug() interface. // included in a bugreport are not available through the dump() interface.
Return<void> DumpstateDevice::debug(const hidl_handle &handle, const hidl_vec<hidl_string> &args) { binder_status_t Dumpstate::dump(int fd, const char** args, uint32_t numArgs) {
// Exit when dump is completed since this is a lazy HAL.
addPostCommandTask([]() {
exit(0);
});
if (handle == nullptr || handle->numFds < 1 || args.size() != 1) { if (numArgs != 1) {
return Void(); return STATUS_OK;
} }
int fd = handle->data[0];
dumpTextSection(fd, static_cast<std::string>(args[0])); dumpTextSection(fd, static_cast<std::string>(args[0]));
fsync(fd); fsync(fd);
return Void(); return STATUS_OK;
} }
} // namespace implementation
} // namespace V1_1
} // namespace dumpstate } // namespace dumpstate
} // namespace hardware } // namespace hardware
} // namespace android } // namespace android
} // namespace aidl

View file

@ -13,44 +13,30 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef ANDROID_HARDWARE_DUMPSTATE_V1_1_DUMPSTATEDEVICE_H #pragma once
#define ANDROID_HARDWARE_DUMPSTATE_V1_1_DUMPSTATEDEVICE_H
#include <aidl/android/hardware/dumpstate/BnDumpstateDevice.h>
#include <aidl/android/hardware/dumpstate/IDumpstateDevice.h>
#include <android/binder_status.h>
#include <android/hardware/dumpstate/1.1/IDumpstateDevice.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <string> #include <string>
namespace aidl {
namespace android { namespace android {
namespace hardware { namespace hardware {
namespace dumpstate { namespace dumpstate {
namespace V1_1 {
namespace implementation {
using ::android::hardware::dumpstate::V1_1::DumpstateMode; class Dumpstate : public BnDumpstateDevice {
using ::android::hardware::dumpstate::V1_1::DumpstateStatus;
using ::android::hardware::dumpstate::V1_1::IDumpstateDevice;
using ::android::hardware::hidl_handle;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
struct DumpstateDevice : public IDumpstateDevice {
public: public:
DumpstateDevice(); Dumpstate();
// Methods from ::android::hardware::dumpstate::V1_0::IDumpstateDevice follow. ::ndk::ScopedAStatus dumpstateBoard(const std::vector<::ndk::ScopedFileDescriptor>& in_fds,
Return<void> dumpstateBoard(const hidl_handle& h) override; IDumpstateDevice::DumpstateMode in_mode,
int64_t in_timeoutMillis) override;
// Methods from ::android::hardware::dumpstate::V1_1::IDumpstateDevice follow. ::ndk::ScopedAStatus getVerboseLoggingEnabled(bool* _aidl_return) override;
Return<DumpstateStatus> dumpstateBoard_1_1(const hidl_handle& h, ::ndk::ScopedAStatus setVerboseLoggingEnabled(bool in_enable) override;
const DumpstateMode mode, binder_status_t dump(int fd, const char** args, uint32_t numArgs) override;
const uint64_t timeoutMillis) override;
Return<void> setVerboseLoggingEnabled(const bool enable) override;
Return<bool> getVerboseLoggingEnabled() override;
// Methods from ::android::hidl::base::V1_0::IBase follow.
Return<void> debug(const hidl_handle &fd, const hidl_vec<hidl_string> &args) override;
private: private:
const std::string kAllSections = "all"; const std::string kAllSections = "all";
@ -75,10 +61,7 @@ struct DumpstateDevice : public IDumpstateDevice {
void dumpCameraSection(int fd); void dumpCameraSection(int fd);
}; };
} // namespace implementation
} // namespace V1_0
} // namespace dumpstate } // namespace dumpstate
} // namespace hardware } // namespace hardware
} // namespace android } // namespace android
} // namespace aidl
#endif // ANDROID_HARDWARE_DUMPSTATE_V1_1_DUMPSTATEDEVICE_H

View file

@ -0,0 +1,5 @@
service vendor.dumpstate-default /vendor/bin/hw/android.hardware.dumpstate-service.gs101
class hal
user system
group system shell
interface aidl android.hardware.dumpstate.IDumpstateDevice/default

View file

@ -0,0 +1,9 @@
<manifest version="1.0" type="device">
<hal format="aidl">
<name>android.hardware.dumpstate</name>
<interface>
<name>IDumpstateDevice</name>
<instance>default</instance>
</interface>
</hal>
</manifest>

View file

@ -1,6 +0,0 @@
service vendor.dumpstate-1-1 /vendor/bin/hw/android.hardware.dumpstate@1.1-service.gs101
class hal
user system
group system shell
interface android.hardware.dumpstate@1.0::IDumpstateDevice default
interface android.hardware.dumpstate@1.1::IDumpstateDevice default

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2016 The Android Open Source Project * Copyright (C) 2022 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -13,31 +13,25 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#define LOG_TAG "android.hardware.dumpstate@1.0-service.gs101" #define LOG_TAG "android.hardware.dumpstate-service.gs101"
#include <hidl/HidlSupport.h> #include "Dumpstate.h"
#include <hidl/HidlTransportSupport.h>
#include "DumpstateDevice.h" #include <android-base/logging.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
using ::android::hardware::configureRpcThreadpool; using aidl::android::hardware::dumpstate::Dumpstate;
using ::android::hardware::dumpstate::V1_1::IDumpstateDevice;
using ::android::hardware::dumpstate::V1_1::implementation::DumpstateDevice;
using ::android::hardware::joinRpcThreadpool;
using ::android::sp;
int main() {
ABinderProcess_setThreadPoolMaxThreadCount(0);
std::shared_ptr<Dumpstate> dumpstate = ndk::SharedRefBase::make<Dumpstate>();
int main(int /* argc */, char* /* argv */ []) { const std::string instance = std::string() + Dumpstate::descriptor + "/default";
sp<IDumpstateDevice> dumpstate = new DumpstateDevice; binder_status_t status =
configureRpcThreadpool(1, true); AServiceManager_addService(dumpstate->asBinder().get(), instance.c_str());
CHECK_EQ(status, STATUS_OK);
android::status_t status = dumpstate->registerAsService(); ABinderProcess_joinThreadPool();
return EXIT_FAILURE; // Unreachable
if (status != android::OK)
{
ALOGE("Could not register DumpstateDevice service (%d).", status);
return -1;
}
joinRpcThreadpool();
} }

View file

@ -57,15 +57,6 @@
<instance>default</instance> <instance>default</instance>
</interface> </interface>
</hal> </hal>
<hal format = "hidl">
<name>android.hardware.dumpstate</name>
<transport>hwbinder</transport>
<version>1.1</version>
<interface>
<name>IDumpstateDevice</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl"> <hal format="hidl">
<name>android.hardware.boot</name> <name>android.hardware.boot</name>
<transport>hwbinder</transport> <transport>hwbinder</transport>

View file

@ -44,15 +44,6 @@
<instance>default</instance> <instance>default</instance>
</interface> </interface>
</hal> </hal>
<hal format = "hidl">
<name>android.hardware.dumpstate</name>
<transport>hwbinder</transport>
<version>1.1</version>
<interface>
<name>IDumpstateDevice</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl"> <hal format="hidl">
<name>android.hardware.boot</name> <name>android.hardware.boot</name>
<transport>hwbinder</transport> <transport>hwbinder</transport>