• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 #ifndef DFX_HISYSEVENT_H
16 #define DFX_HISYSEVENT_H
17 
18 #include <string>
19 
20 #include "hisysevent.h"
21 
22 #include "input_device_manager.h"
23 #include "key_event.h"
24 #include "mmi_log.h"
25 #include "pointer_event.h"
26 #include "uds_session.h"
27 
28 namespace OHOS {
29 namespace MMI {
30 class DfxHisysevent {
31 public:
32     struct DispCastTime {
33         uint32_t sampleCount;
34         uint32_t totalTimes;
35         uint32_t below10msTimes;
36         uint32_t below25msTimes;
37         uint32_t below50msTimes;
38         uint32_t above50msTimes;
39     };
40     struct ComboStartCastTime {
41         uint32_t totalTimes;
42         uint32_t below10msTimes;
43         uint32_t below30msTimes;
44         uint32_t below50msTimes;
45         uint32_t above50msTimes;
46     };
47     struct ClientConnectData {
48         int32_t pid { -1 };
49         int32_t uid { -1 };
50         int32_t moduleType { -1 };
51         std::string programName;
52         int32_t serverFd { -1 };
53     };
54     static void OnDeviceConnect(int32_t id, OHOS::HiviewDFX::HiSysEvent::EventType type);
55     static void OnDeviceDisconnect(int32_t id, OHOS::HiviewDFX::HiSysEvent::EventType type);
56     static void OnClientConnect(const ClientConnectData &data, OHOS::HiviewDFX::HiSysEvent::EventType type);
57     static void OnClientDisconnect(const SessionPtr& secPtr, int32_t fd,
58         OHOS::HiviewDFX::HiSysEvent::EventType type);
59     static void OnUpdateTargetPointer(std::shared_ptr<PointerEvent> pointer, int32_t fd,
60         OHOS::HiviewDFX::HiSysEvent::EventType type);
61     static void OnUpdateTargetKey(std::shared_ptr<KeyEvent> key, int32_t fd,
62         OHOS::HiviewDFX::HiSysEvent::EventType type);
63     static void OnFocusWindowChanged(int32_t oldFocusWindowId, int32_t newFocusWindowId,
64         int32_t oldFocusWindowPid, int32_t newFocusWindowPid);
65     static void OnZorderWindowChanged(int32_t oldZorderFirstWindowId, int32_t newZorderFirstWindowId,
66         int32_t oldZorderFirstWindowPid, int32_t newZorderFirstWindowPid);
67     static void ApplicationBlockInput(const SessionPtr& sess);
68     static void CalcKeyDispTimes();
69     static void CalcPointerDispTimes();
70     static void CalcComboStartTimes(int32_t keyDownDuration);
71     static void ReportDispTimes();
72     static void ReportComboStartTimes();
GetComboStartTime()73     static inline void GetComboStartTime()
74     {
75         comboStartTime_ = GetSysClockTime();
76     }
GetDispStartTime()77     static inline void GetDispStartTime()
78     {
79         dispatchStartTime_ = GetSysClockTime();
80     }
81 private:
82     static inline int64_t dispatchStartTime_ { 0 };
83     static inline int64_t comboStartTime_ { 0 };
84     static inline DispCastTime dispCastTime_ { 0 };
85     static inline ComboStartCastTime comboStartCastTime_ { 0 };
86 };
87 } // namespace MMI
88 } // namespace OHOS
89 #endif // BYTRACE_ADAPTER_H
90