• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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_PROTO_ANDROID_KERNEL_WAKELOCKS_MODULE_H_
18 #define SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_ANDROID_KERNEL_WAKELOCKS_MODULE_H_
19 
20 #include <cstdint>
21 #include <string>
22 
23 #include "protos/perfetto/trace/android/kernel_wakelock_data.pbzero.h"
24 #include "protos/perfetto/trace/trace_packet.pbzero.h"
25 #include "src/trace_processor/importers/common/parser_types.h"
26 #include "src/trace_processor/importers/proto/proto_importer_module.h"
27 #include "src/trace_processor/storage/trace_storage.h"
28 #include "src/trace_processor/types/trace_processor_context.h"
29 
30 namespace perfetto::trace_processor {
31 
32 struct KernelWakelockMetadata;
33 struct KernelWakelockLastValue;
34 
35 class AndroidKernelWakelocksModule : public ProtoImporterModule {
36  public:
37   explicit AndroidKernelWakelocksModule(TraceProcessorContext* context);
38 
39   ~AndroidKernelWakelocksModule() override;
40 
41   void ParseTracePacketData(const protos::pbzero::TracePacket::Decoder& decoder,
42                             int64_t ts,
43                             const TracePacketData&,
44                             uint32_t field_id) override;
45 
46  private:
47   void UpdateCounter(int64_t ts,
48                      const std::string& name,
49                      protos::pbzero::KernelWakelockData_Wakelock_Type type,
50                      uint64_t value);
51 
52   TraceProcessorContext* context_;
53 
54   const StringId kernel_name_id_;
55   const StringId native_name_id_;
56   const StringId unknown_name_id_;
57 };
58 
59 }  // namespace perfetto::trace_processor
60 
61 #endif  // SRC_TRACE_PROCESSOR_IMPORTERS_PROTO_ANDROID_KERNEL_WAKELOCKS_MODULE_H_
62