Loading cmds/incidentd/src/Section.cpp +7 −7 Original line number Diff line number Diff line Loading @@ -151,11 +151,10 @@ DONE: } // ================================================================================ Section::Section(int i, int64_t timeoutMs, bool userdebugAndEngOnly, bool deviceSpecific) Section::Section(int i, int64_t timeoutMs, bool userdebugAndEngOnly) : id(i), timeoutMs(timeoutMs), userdebugAndEngOnly(userdebugAndEngOnly), deviceSpecific(deviceSpecific) {} userdebugAndEngOnly(userdebugAndEngOnly) {} Section::~Section() {} Loading Loading @@ -240,9 +239,8 @@ status_t MetadataSection::Execute(ReportRequestSet* requests) const { // ================================================================================ static inline bool isSysfs(const char* filename) { return strncmp(filename, "/sys/", 5) == 0; } FileSection::FileSection(int id, const char* filename, const bool deviceSpecific, const int64_t timeoutMs) : Section(id, timeoutMs, false, deviceSpecific), mFilename(filename) { FileSection::FileSection(int id, const char* filename, const int64_t timeoutMs) : Section(id, timeoutMs, false), mFilename(filename) { name = "file "; name += filename; mIsSysfs = isSysfs(filename); Loading @@ -256,7 +254,9 @@ status_t FileSection::Execute(ReportRequestSet* requests) const { unique_fd fd(open(mFilename, O_RDONLY | O_CLOEXEC)); if (fd.get() == -1) { ALOGW("[%s] failed to open file", this->name.string()); return this->deviceSpecific ? NO_ERROR : -errno; // There may be some devices/architectures that won't have the file. // Just return here without an error. return NO_ERROR; } FdBuffer buffer; Loading cmds/incidentd/src/Section.h +2 −4 Original line number Diff line number Diff line Loading @@ -41,11 +41,9 @@ public: const int id; const int64_t timeoutMs; // each section must have a timeout const bool userdebugAndEngOnly; const bool deviceSpecific; String8 name; Section(int id, int64_t timeoutMs = REMOTE_CALL_TIMEOUT_MS, bool userdebugAndEngOnly = false, bool deviceSpecific = false); Section(int id, int64_t timeoutMs = REMOTE_CALL_TIMEOUT_MS, bool userdebugAndEngOnly = false); virtual ~Section(); virtual status_t Execute(ReportRequestSet* requests) const = 0; Loading Loading @@ -78,7 +76,7 @@ public: */ class FileSection : public Section { public: FileSection(int id, const char* filename, bool deviceSpecific = false, FileSection(int id, const char* filename, int64_t timeoutMs = 5000 /* 5 seconds */); virtual ~FileSection(); Loading cmds/incidentd/tests/Section_test.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -144,15 +144,15 @@ TEST_F(SectionTest, FileSection) { } TEST_F(SectionTest, FileSectionNotExist) { FileSection fs1(NOOP_PARSER, "notexist", false, QUICK_TIMEOUT_MS); ASSERT_EQ(NAME_NOT_FOUND, fs1.Execute(&requests)); FileSection fs1(NOOP_PARSER, "notexist", QUICK_TIMEOUT_MS); ASSERT_EQ(NO_ERROR, fs1.Execute(&requests)); FileSection fs2(NOOP_PARSER, "notexist", true, QUICK_TIMEOUT_MS); FileSection fs2(NOOP_PARSER, "notexist", QUICK_TIMEOUT_MS); ASSERT_EQ(NO_ERROR, fs2.Execute(&requests)); } TEST_F(SectionTest, FileSectionTimeout) { FileSection fs(TIMEOUT_PARSER, tf.path, false, QUICK_TIMEOUT_MS); FileSection fs(TIMEOUT_PARSER, tf.path, QUICK_TIMEOUT_MS); ASSERT_EQ(NO_ERROR, fs.Execute(&requests)); ASSERT_TRUE(requests.sectionStats(TIMEOUT_PARSER)->timed_out()); } Loading core/proto/android/os/incident.proto +0 −2 Original line number Diff line number Diff line Loading @@ -162,7 +162,6 @@ message IncidentProto { optional CpuFreqProto cpu_freq = 2004 [ (section).type = SECTION_FILE, (section).device_specific = true, (section).args = "/sys/devices/system/cpu/cpufreq/all_time_in_state" ]; Loading @@ -173,7 +172,6 @@ message IncidentProto { optional BatteryTypeProto battery_type = 2006 [ (section).type = SECTION_FILE, (section).device_specific = true, (section).args = "/sys/class/power_supply/bms/battery_type" ]; Loading libs/incident/proto/android/section.proto +1 −2 Original line number Diff line number Diff line Loading @@ -51,10 +51,9 @@ enum SectionType { message SectionFlags { optional SectionType type = 1 [default = SECTION_NONE]; optional string args = 2; optional bool device_specific = 3 [default = false]; // If true, then the section will only be generated for userdebug and eng // builds. optional bool userdebug_and_eng_only = 4 [default = false]; optional bool userdebug_and_eng_only = 3 [default = false]; } extend google.protobuf.FieldOptions { Loading Loading
cmds/incidentd/src/Section.cpp +7 −7 Original line number Diff line number Diff line Loading @@ -151,11 +151,10 @@ DONE: } // ================================================================================ Section::Section(int i, int64_t timeoutMs, bool userdebugAndEngOnly, bool deviceSpecific) Section::Section(int i, int64_t timeoutMs, bool userdebugAndEngOnly) : id(i), timeoutMs(timeoutMs), userdebugAndEngOnly(userdebugAndEngOnly), deviceSpecific(deviceSpecific) {} userdebugAndEngOnly(userdebugAndEngOnly) {} Section::~Section() {} Loading Loading @@ -240,9 +239,8 @@ status_t MetadataSection::Execute(ReportRequestSet* requests) const { // ================================================================================ static inline bool isSysfs(const char* filename) { return strncmp(filename, "/sys/", 5) == 0; } FileSection::FileSection(int id, const char* filename, const bool deviceSpecific, const int64_t timeoutMs) : Section(id, timeoutMs, false, deviceSpecific), mFilename(filename) { FileSection::FileSection(int id, const char* filename, const int64_t timeoutMs) : Section(id, timeoutMs, false), mFilename(filename) { name = "file "; name += filename; mIsSysfs = isSysfs(filename); Loading @@ -256,7 +254,9 @@ status_t FileSection::Execute(ReportRequestSet* requests) const { unique_fd fd(open(mFilename, O_RDONLY | O_CLOEXEC)); if (fd.get() == -1) { ALOGW("[%s] failed to open file", this->name.string()); return this->deviceSpecific ? NO_ERROR : -errno; // There may be some devices/architectures that won't have the file. // Just return here without an error. return NO_ERROR; } FdBuffer buffer; Loading
cmds/incidentd/src/Section.h +2 −4 Original line number Diff line number Diff line Loading @@ -41,11 +41,9 @@ public: const int id; const int64_t timeoutMs; // each section must have a timeout const bool userdebugAndEngOnly; const bool deviceSpecific; String8 name; Section(int id, int64_t timeoutMs = REMOTE_CALL_TIMEOUT_MS, bool userdebugAndEngOnly = false, bool deviceSpecific = false); Section(int id, int64_t timeoutMs = REMOTE_CALL_TIMEOUT_MS, bool userdebugAndEngOnly = false); virtual ~Section(); virtual status_t Execute(ReportRequestSet* requests) const = 0; Loading Loading @@ -78,7 +76,7 @@ public: */ class FileSection : public Section { public: FileSection(int id, const char* filename, bool deviceSpecific = false, FileSection(int id, const char* filename, int64_t timeoutMs = 5000 /* 5 seconds */); virtual ~FileSection(); Loading
cmds/incidentd/tests/Section_test.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -144,15 +144,15 @@ TEST_F(SectionTest, FileSection) { } TEST_F(SectionTest, FileSectionNotExist) { FileSection fs1(NOOP_PARSER, "notexist", false, QUICK_TIMEOUT_MS); ASSERT_EQ(NAME_NOT_FOUND, fs1.Execute(&requests)); FileSection fs1(NOOP_PARSER, "notexist", QUICK_TIMEOUT_MS); ASSERT_EQ(NO_ERROR, fs1.Execute(&requests)); FileSection fs2(NOOP_PARSER, "notexist", true, QUICK_TIMEOUT_MS); FileSection fs2(NOOP_PARSER, "notexist", QUICK_TIMEOUT_MS); ASSERT_EQ(NO_ERROR, fs2.Execute(&requests)); } TEST_F(SectionTest, FileSectionTimeout) { FileSection fs(TIMEOUT_PARSER, tf.path, false, QUICK_TIMEOUT_MS); FileSection fs(TIMEOUT_PARSER, tf.path, QUICK_TIMEOUT_MS); ASSERT_EQ(NO_ERROR, fs.Execute(&requests)); ASSERT_TRUE(requests.sectionStats(TIMEOUT_PARSER)->timed_out()); } Loading
core/proto/android/os/incident.proto +0 −2 Original line number Diff line number Diff line Loading @@ -162,7 +162,6 @@ message IncidentProto { optional CpuFreqProto cpu_freq = 2004 [ (section).type = SECTION_FILE, (section).device_specific = true, (section).args = "/sys/devices/system/cpu/cpufreq/all_time_in_state" ]; Loading @@ -173,7 +172,6 @@ message IncidentProto { optional BatteryTypeProto battery_type = 2006 [ (section).type = SECTION_FILE, (section).device_specific = true, (section).args = "/sys/class/power_supply/bms/battery_type" ]; Loading
libs/incident/proto/android/section.proto +1 −2 Original line number Diff line number Diff line Loading @@ -51,10 +51,9 @@ enum SectionType { message SectionFlags { optional SectionType type = 1 [default = SECTION_NONE]; optional string args = 2; optional bool device_specific = 3 [default = false]; // If true, then the section will only be generated for userdebug and eng // builds. optional bool userdebug_and_eng_only = 4 [default = false]; optional bool userdebug_and_eng_only = 3 [default = false]; } extend google.protobuf.FieldOptions { Loading