1 /* 2 * Copyright (C) 2022 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 #ifndef SRC_TRACE_PROCESSOR_IMPORTERS_ANDROID_BUGREPORT_ANDROID_DUMPSTATE_READER_H_ 18 #define SRC_TRACE_PROCESSOR_IMPORTERS_ANDROID_BUGREPORT_ANDROID_DUMPSTATE_READER_H_ 19 20 #include "src/trace_processor/importers/android_bugreport/android_battery_stats_reader.h" 21 #include "src/trace_processor/importers/android_bugreport/android_log_reader.h" 22 #include "src/trace_processor/importers/android_bugreport/chunked_line_reader.h" 23 #include "src/trace_processor/storage/trace_storage.h" 24 25 namespace perfetto::trace_processor { 26 27 class TraceProcessorContext; 28 29 // Trace importer for Android dumpstate files. 30 class AndroidDumpstateReader : public ChunkedLineReader { 31 public: 32 // Create a reader that will only forward events that are not present in the 33 // given list. 34 AndroidDumpstateReader(TraceProcessorContext* context, int32_t year = 0); 35 ~AndroidDumpstateReader() override; 36 37 base::Status ParseLine(base::StringView line) override; 38 void EndOfStream(base::StringView leftovers) override; 39 log_reader()40 BufferingAndroidLogReader& log_reader() { return log_reader_; } 41 42 private: 43 enum class Section { kOther = 0, kDumpsys, kLog, kBatteryStats }; 44 TraceProcessorContext* const context_; 45 AndroidBatteryStatsReader battery_stats_reader_; 46 BufferingAndroidLogReader log_reader_; 47 Section current_section_ = Section::kOther; 48 StringId current_section_id_ = StringId::Null(); 49 StringId current_service_id_ = StringId::Null(); 50 }; 51 52 } // namespace perfetto::trace_processor 53 54 #endif // SRC_TRACE_PROCESSOR_IMPORTERS_ANDROID_BUGREPORT_ANDROID_DUMPSTATE_READER_H_ 55