• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef RENDER_SERVICE_BASE_COMMON_RS_HISYSEVENT_H
17 #define RENDER_SERVICE_BASE_COMMON_RS_HISYSEVENT_H
18 
19 #include "hisysevent.h"
20 #include "platform/common/rs_log.h"
21 #include <string>
22 #include <unordered_map>
23 #include <utility>
24 
25 namespace OHOS {
26 namespace Rosen {
27 namespace RSEventName {
28     const std::string NO_DRAW = "NO_DRAW";
29     const std::string JANK_FRAME_SKIP = "JANK_FRAME_SKIP";
30     const std::string RS_COMPOSITION_TIMEOUT = "RS_COMPOSITION_TIMEOUT";
31     const std::string EPS_LCD_FREQ = "EPS_LCD_FREQ";
32     const std::string JANK_STATS_RS = "JANK_STATS_RS";
33     const std::string JANK_FRAME_RS = "JANK_FRAME_RS";
34     const std::string INTERACTION_RESPONSE_LATENCY = "INTERACTION_RESPONSE_LATENCY";
35     const std::string INTERACTION_COMPLETED_LATENCY = "INTERACTION_COMPLETED_LATENCY";
36     const std::string INTERACTION_RENDER_JANK = "INTERACTION_RENDER_JANK";
37     const std::string INTERACTION_HITCH_TIME_RATIO = "INTERACTION_HITCH_TIME_RATIO";
38     const std::string FIRST_FRAME_DRAWN = "FIRST_FRAME_DRAWN";
39     const std::string RS_NODE_LIMIT_EXCEEDED = "RS_NODE_LIMIT_EXCEEDED";
40     const std::string ANIMATION_CALLBACK_MISSING = "ANIMATION_CALLBACK_MISSING";
41     const std::string HGM_VOTER_INFO = "HGM_VOTER_INFO";
42     const std::string GPU_SUBHEALTH_MONITORING = "GPU_SUBHEALTH_MONITORING";
43     const std::string IPC_DATA_OVER_ERROR = "IPC_DATA_OVER_ERROR";
44     const std::string RENDER_MEMORY_OVER_WARNING = "RENDER_MEMORY_OVER_WARNING";
45     const std::string RENDER_MEMORY_OVER_ERROR = "RENDER_MEMORY_OVER_ERROR";
46     const std::string RS_HARDWARE_THREAD_LOAD_WARNING = "RS_HARDWARE_THREAD_LOAD_WARNING";
47     const std::string RENDER_DRAWABLE_MULTI_ACCESS = "RENDER_DRAWABLE_MULTI_ACCESS";
48     const std::string RS_RENDER_EXCEPTION = "RS_RENDER_EXCEPTION";
49 } // namespace RSEventName
50 
51 enum RSEventType {
52     RS_FAULT     = 1,    // system fault event
53     RS_STATISTIC = 2,    // system statistic event
54     RS_SECURITY  = 3,    // system security event
55     RS_BEHAVIOR  = 4     // system behavior event
56 };
57 
58 class RSHiSysEvent {
59 public:
60     template<typename... Types>
EventWrite(const std::string & eventName,RSEventType type,Types &&...types)61     static int EventWrite(const std::string& eventName, RSEventType type, Types&&... types)
62     {
63         int hiSysEventWriteRet = HiSysEventWrite(HiDomain::GRAPHIC, eventName, rsEventTypeToEventTypeMap_[type],
64             std::forward<Types>(types)...);
65         if (hiSysEventWriteRet != 0) {
66             RS_LOGW("Write RSHiSysEvent failed, eventName: %{public}s, ret: %{public}d",
67                 eventName.c_str(), hiSysEventWriteRet);
68         }
69         return hiSysEventWriteRet;
70     }
71 private:
72     using HiDomain = OHOS::HiviewDFX::HiSysEvent::Domain;
73     using HiEventType = OHOS::HiviewDFX::HiSysEvent::EventType;
74     static std::unordered_map<RSEventType, HiEventType> rsEventTypeToEventTypeMap_;
75 };
76 
77 } // namespace Rosen
78 } // namespace OHOS
79 #endif