• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
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 BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_FRAME_REPORT_SCHED_H
18 #define BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_FRAME_REPORT_SCHED_H
19 
20 #include <string>
21 #include <unordered_map>
22 
23 namespace OHOS {
24 namespace AppExecFwk {
25 enum class FrameSchedEvent {
26     SCHED_EVENT_BASE = 0,
27     INIT = 1,
28     UI_FLUSH_BEGIN = 20001,
29     UI_EVENT_HANDLE_BEGIN = 20005,
30     SCHED_EVENT_MAX,
31 };
32 
33 using ReportSchedEventFunc = void (*)(FrameSchedEvent, const std::unordered_map<std::string, std::string>&);
34 
35 class FrameReport final {
36 public:
37     static FrameReport& GetInstance();
38     void ReportSchedEvent(FrameSchedEvent event, const std::unordered_map<std::string, std::string>& payload);
39 
40 private:
41     FrameReport();
42     ~FrameReport();
43     void LoadLibrary();
44     void CloseLibrary();
45     void* LoadSymbol(const char* symName);
46 
47     void* frameSchedHandle_ = nullptr;
48     bool frameSchedSoLoaded_ = false;
49     unsigned int uid_ = 0;
50     ReportSchedEventFunc reportSchedEventFunc_ = nullptr;
51 };
52 }  // namespace AppExecFwk
53 }  // namespace OHOS
54 
55 #endif  // #ifndef BASE_EVENTHANDLER_FRAMEWORKS_EVENTHANDLER_INCLUDE_FRAME_REPORT_SCHED_H