Loading cmds/dumpstate/Android.mk +2 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ COMMON_LOCAL_CFLAGS := \ COMMON_SRC_FILES := \ utils.cpp COMMON_SHARED_LIBRARIES := \ android.hardware.dumpstate@1.0 \ libbase \ libbinder \ libcutils \ Loading @@ -38,7 +39,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) LOCAL_SRC_FILES := \ utils.cpp # TODO: temporary, until functions are moved to DumpstateUtil.cpp # TODO: include just what it uses once split from utils.cpp # TODO: include just what it uses (libbase, libcutils, etc...) once split from utils.cpp LOCAL_SHARED_LIBRARIES := $(COMMON_SHARED_LIBRARIES) LOCAL_STATIC_LIBRARIES := $(COMMON_ZIP_LIBRARIES) Loading cmds/dumpstate/DumpstateUtil.h +3 −1 Original line number Diff line number Diff line /* * Copyright (C) 2008 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. Loading @@ -16,6 +16,8 @@ #ifndef FRAMEWORK_NATIVE_CMD_DUMPSTATE_UTIL_H_ #define FRAMEWORK_NATIVE_CMD_DUMPSTATE_UTIL_H_ // TODO: use android::os::dumpstate (must wait until device code is refactored) /* * Defines the Linux user that should be executing a command. */ Loading cmds/dumpstate/dumpstate.cpp +54 −9 Original line number Diff line number Diff line Loading @@ -41,6 +41,8 @@ #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/unique_fd.h> #include <android/hardware/dumpstate/1.0/IDumpstateDevice.h> #include <cutils/native_handle.h> #include <cutils/properties.h> #include <hardware_legacy/power.h> #include <openssl/sha.h> Loading Loading @@ -1092,15 +1094,7 @@ static void dumpstate() { DumpFile("BINDER STATS", "/sys/kernel/debug/binder/stats"); DumpFile("BINDER STATE", "/sys/kernel/debug/binder/state"); printf("========================================================\n"); printf("== Board\n"); printf("========================================================\n"); { DurationReporter tmpDr("dumpstate_board()"); dumpstate_board(); printf("\n"); } ds.DumpstateBoard(); /* Migrate the ril_dumpstate to a dumpstate_board()? */ int rilDumpstateTimeout = android::base::GetIntProperty("ril.dumpstate.timeout", 0); Loading Loading @@ -1165,6 +1159,57 @@ static void dumpstate() { printf("========================================================\n"); } void Dumpstate::DumpstateBoard() { DurationReporter duration_reporter("dumpstate_board()"); printf("========================================================\n"); printf("== Board\n"); printf("========================================================\n"); fflush(stdout); android::sp<android::hardware::dumpstate::V1_0::IDumpstateDevice> dumpstate_device( android::hardware::dumpstate::V1_0::IDumpstateDevice::getService("DumpstateDevice")); if (dumpstate_device == nullptr) { // TODO: temporary workaround until devices on master implement it MYLOGE("no IDumpstateDevice implementation; using legacy dumpstate_board()\n"); dumpstate_board(); return; } if (!IsZipping()) { MYLOGE("Not dumping board info because it's not a zipped bugreport\n"); return; } std::string path = ds.GetPath("-dumpstate-board.txt"); MYLOGI("Calling IDumpstateDevice implementation using path %s\n", path.c_str()); int fd = TEMP_FAILURE_RETRY(open(path.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)); if (fd < 0) { MYLOGE("Could not open file %s: %s\n", path.c_str(), strerror(errno)); return; } native_handle_t* handle = native_handle_create(1, 0); if (handle == nullptr) { MYLOGE("Could not create native_handle\n"); return; } handle->data[0] = fd; dumpstate_device->dumpstateBoard(handle); AddZipEntry("dumpstate-board.txt", path); native_handle_close(handle); native_handle_delete(handle); if (remove(path.c_str()) != 0) { MYLOGE("Could not remove(%s): %s\n", path.c_str(), strerror(errno)); } } static void ShowUsageAndExit(int exitCode = 1) { fprintf(stderr, "usage: dumpstate [-h] [-b soundfile] [-e soundfile] [-o file] [-d] [-p] " Loading cmds/dumpstate/dumpstate.h +2 −0 Original line number Diff line number Diff line Loading @@ -260,6 +260,8 @@ class Dumpstate { // TODO: temporary method until Dumpstate object is properly set void SetProgress(std::unique_ptr<Progress> progress); void DumpstateBoard(); /* * Updates the overall progress of the bugreport generation by the given weight increment. */ Loading Loading
cmds/dumpstate/Android.mk +2 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ COMMON_LOCAL_CFLAGS := \ COMMON_SRC_FILES := \ utils.cpp COMMON_SHARED_LIBRARIES := \ android.hardware.dumpstate@1.0 \ libbase \ libbinder \ libcutils \ Loading @@ -38,7 +39,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH) LOCAL_SRC_FILES := \ utils.cpp # TODO: temporary, until functions are moved to DumpstateUtil.cpp # TODO: include just what it uses once split from utils.cpp # TODO: include just what it uses (libbase, libcutils, etc...) once split from utils.cpp LOCAL_SHARED_LIBRARIES := $(COMMON_SHARED_LIBRARIES) LOCAL_STATIC_LIBRARIES := $(COMMON_ZIP_LIBRARIES) Loading
cmds/dumpstate/DumpstateUtil.h +3 −1 Original line number Diff line number Diff line /* * Copyright (C) 2008 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. Loading @@ -16,6 +16,8 @@ #ifndef FRAMEWORK_NATIVE_CMD_DUMPSTATE_UTIL_H_ #define FRAMEWORK_NATIVE_CMD_DUMPSTATE_UTIL_H_ // TODO: use android::os::dumpstate (must wait until device code is refactored) /* * Defines the Linux user that should be executing a command. */ Loading
cmds/dumpstate/dumpstate.cpp +54 −9 Original line number Diff line number Diff line Loading @@ -41,6 +41,8 @@ #include <android-base/stringprintf.h> #include <android-base/strings.h> #include <android-base/unique_fd.h> #include <android/hardware/dumpstate/1.0/IDumpstateDevice.h> #include <cutils/native_handle.h> #include <cutils/properties.h> #include <hardware_legacy/power.h> #include <openssl/sha.h> Loading Loading @@ -1092,15 +1094,7 @@ static void dumpstate() { DumpFile("BINDER STATS", "/sys/kernel/debug/binder/stats"); DumpFile("BINDER STATE", "/sys/kernel/debug/binder/state"); printf("========================================================\n"); printf("== Board\n"); printf("========================================================\n"); { DurationReporter tmpDr("dumpstate_board()"); dumpstate_board(); printf("\n"); } ds.DumpstateBoard(); /* Migrate the ril_dumpstate to a dumpstate_board()? */ int rilDumpstateTimeout = android::base::GetIntProperty("ril.dumpstate.timeout", 0); Loading Loading @@ -1165,6 +1159,57 @@ static void dumpstate() { printf("========================================================\n"); } void Dumpstate::DumpstateBoard() { DurationReporter duration_reporter("dumpstate_board()"); printf("========================================================\n"); printf("== Board\n"); printf("========================================================\n"); fflush(stdout); android::sp<android::hardware::dumpstate::V1_0::IDumpstateDevice> dumpstate_device( android::hardware::dumpstate::V1_0::IDumpstateDevice::getService("DumpstateDevice")); if (dumpstate_device == nullptr) { // TODO: temporary workaround until devices on master implement it MYLOGE("no IDumpstateDevice implementation; using legacy dumpstate_board()\n"); dumpstate_board(); return; } if (!IsZipping()) { MYLOGE("Not dumping board info because it's not a zipped bugreport\n"); return; } std::string path = ds.GetPath("-dumpstate-board.txt"); MYLOGI("Calling IDumpstateDevice implementation using path %s\n", path.c_str()); int fd = TEMP_FAILURE_RETRY(open(path.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)); if (fd < 0) { MYLOGE("Could not open file %s: %s\n", path.c_str(), strerror(errno)); return; } native_handle_t* handle = native_handle_create(1, 0); if (handle == nullptr) { MYLOGE("Could not create native_handle\n"); return; } handle->data[0] = fd; dumpstate_device->dumpstateBoard(handle); AddZipEntry("dumpstate-board.txt", path); native_handle_close(handle); native_handle_delete(handle); if (remove(path.c_str()) != 0) { MYLOGE("Could not remove(%s): %s\n", path.c_str(), strerror(errno)); } } static void ShowUsageAndExit(int exitCode = 1) { fprintf(stderr, "usage: dumpstate [-h] [-b soundfile] [-e soundfile] [-o file] [-d] [-p] " Loading
cmds/dumpstate/dumpstate.h +2 −0 Original line number Diff line number Diff line Loading @@ -260,6 +260,8 @@ class Dumpstate { // TODO: temporary method until Dumpstate object is properly set void SetProgress(std::unique_ptr<Progress> progress); void DumpstateBoard(); /* * Updates the overall progress of the bugreport generation by the given weight increment. */ Loading