• 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 PERF_MONITOR_ADAPTER_H
17 #define PERF_MONITOR_ADAPTER_H
18 
19 #include "perf_constants.h"
20 #include "perf_model.h"
21 
22 namespace OHOS {
23 namespace HiviewDFX {
24 
25 class __attribute__((visibility("default"))) PerfMonitorAdapter {
26 public:
27     static PerfMonitorAdapter& GetInstance();
28     PerfMonitorAdapter() = default;
29     ~PerfMonitorAdapter() = default;
30     void RegisterFrameCallback(IFrameCallback* cb);
31     void UnregisterFrameCallback(IFrameCallback* cb);
32     void RegisterAnimatorCallback(IAnimatorCallback* cb);
33     void UnregisterAnimatorCallback(IAnimatorCallback* cb);
34     void RegisterSceneCallback(ISceneCallback* cb);
35     void UnregisterSceneCallback(ISceneCallback* cb);
36 
37     void RecordInputEvent(PerfActionType type, PerfSourceType sourceType, int64_t time);
38     int64_t GetInputTime(const std::string& sceneId, PerfActionType type, const std::string& note);
39 
40     void NotifyAppJankStatsBegin();
41     void NotifyAppJankStatsEnd();
42     void SetPageUrl(const std::string& pageUrl);
43     std::string GetPageUrl();
44     void SetPageName(const std::string& pageName);
45     std::string GetPageName();
46     void SetAppForeground(bool isShow);
47     void SetAppStartStatus();
48     void SetAppInfo(AceAppInfo& appInfo);
49     void SetSubHealthInfo(const std::string& info, const std::string& reason, const int32_t duration);
50     bool IsScrollJank(const std::string& sceneId);
51 
52     void Start(const std::string& sceneId, PerfActionType type, const std::string& note);
53     void End(const std::string& sceneId, bool isRsRender);
54     void StartCommercial(const std::string& sceneId, PerfActionType type, const std::string& note);
55     void EndCommercial(const std::string& sceneId, bool isRsRender);
56     void SetFrameTime(int64_t vsyncTime, int64_t duration, double jank, const std::string& windowName);
57     void OnFrameEnd(int64_t vsyncTime, int64_t duration, double jank, const std::string& windowName);
58 
59     void ReportJankFrameApp(double jank, int32_t jankThreshold);
60     void ReportPageShowMsg(const std::string& pageUrl, const std::string& bundleName,
61         const std::string& pageName);
62 
63     void StartRecordImageLoadStat(int64_t id);
64     void EndRecordImageLoadStat(int64_t id, std::pair<int, int> size, const std::string& type, int state);
65     void OnSceneChanged(const SceneType& type, bool status);
66 
67     void ReportSurface(const int64_t& uniqueId, const std::string& surfaceName, const std::string& componentName,
68         const std::string& bundleName, const int32_t& pid);
69 };
70 }
71 }
72 #endif  // PERF_MONITOR_ADAPTER_H