• 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 
16 #ifndef DFX_HISYSEVENT_H
17 #define DFX_HISYSEVENT_H
18 
19 #include <string>
20 
21 #include "hisysevent.h"
22 
23 #include "input_device_manager.h"
24 #include "key_event.h"
25 #include "mmi_log.h"
26 #include "pointer_event.h"
27 #include "uds_session.h"
28 
29 namespace OHOS {
30 namespace MMI {
31 class DfxHisysevent {
32 public:
33     struct DispCastTime {
34         uint32_t sampleCount;
35         uint32_t totalTimes;
36         uint32_t below10msTimes;
37         uint32_t below25msTimes;
38         uint32_t below50msTimes;
39         uint32_t above50msTimes;
40     };
41     struct ComboStartCastTime {
42         uint32_t totalTimes;
43         uint32_t below10msTimes;
44         uint32_t below30msTimes;
45         uint32_t below50msTimes;
46         uint32_t above50msTimes;
47     };
48     struct ClientConnectData {
49         int32_t pid { -1 };
50         int32_t uid { -1 };
51         int32_t moduleType { -1 };
52         std::string programName;
53         int32_t serverFd { -1 };
54     };
55 
56     enum TOUCHPAD_SETTING_CODE {
57         TOUCHPAD_SCROLL_SETTING = 1,
58         TOUCHPAD_SCROLL_DIR_SETTING,
59         TOUCHPAD_TAP_SETTING,
60         TOUCHPAD_SWIPE_SETTING,
61         TOUCHPAD_PINCH_SETTING,
62         TOUCHPAD_POINTER_SPEED_SETTING,
63         TOUCHPAD_RIGHT_CLICK_SETTING
64     };
65 
66     static void OnDeviceConnect(int32_t id, OHOS::HiviewDFX::HiSysEvent::EventType type);
67     static void OnDeviceDisconnect(int32_t id, OHOS::HiviewDFX::HiSysEvent::EventType type);
68     static void OnClientConnect(const ClientConnectData &data, OHOS::HiviewDFX::HiSysEvent::EventType type);
69     static void OnClientDisconnect(const SessionPtr& secPtr, int32_t fd,
70         OHOS::HiviewDFX::HiSysEvent::EventType type);
71     static void OnUpdateTargetPointer(std::shared_ptr<PointerEvent> pointer, int32_t fd,
72         OHOS::HiviewDFX::HiSysEvent::EventType type);
73     static void OnUpdateTargetKey(std::shared_ptr<KeyEvent> key, int32_t fd,
74         OHOS::HiviewDFX::HiSysEvent::EventType type);
75     static void OnFocusWindowChanged(int32_t oldFocusWindowId, int32_t newFocusWindowId,
76         int32_t oldFocusWindowPid, int32_t newFocusWindowPid);
77     static void OnZorderWindowChanged(int32_t oldZorderFirstWindowId, int32_t newZorderFirstWindowId,
78         int32_t oldZorderFirstWindowPid, int32_t newZorderFirstWindowPid);
79     static void OnLidSwitchChanged(int32_t lidSwitch);
80     static void ApplicationBlockInput(const SessionPtr& sess);
81     static void CalcKeyDispTimes();
82     static void CalcPointerDispTimes();
83     static void CalcComboStartTimes(int32_t keyDownDuration);
84     static void ReportDispTimes();
85     static void ReportComboStartTimes();
86     static void ReportPowerInfo(std::shared_ptr<KeyEvent> key, OHOS::HiviewDFX::HiSysEvent::EventType type);
GetComboStartTime()87     static inline void GetComboStartTime()
88     {
89         comboStartTime_ = GetSysClockTime();
90     }
GetDispStartTime()91     static inline void GetDispStartTime()
92     {
93         dispatchStartTime_ = GetSysClockTime();
94     }
95     static void ReportTouchpadSettingState(TOUCHPAD_SETTING_CODE settingCode, bool flag);
96     static void ReportTouchpadSettingState(TOUCHPAD_SETTING_CODE settingCode, int32_t value);
97     static void StatisticTouchpadGesture(std::shared_ptr<PointerEvent> pointerEvent);
98     static void ReportKnuckleClickEvent();
99     static void ReportScreenCaptureGesture();
100     static void ReportSingleKnuckleDoubleClickEvent(int32_t intervalTime);
101     static void ReportFailIfInvalidTime(const std::shared_ptr<PointerEvent> touchEvent, int32_t intervalTime);
102     static void ReportFailIfInvalidDistance(const std::shared_ptr<PointerEvent> touchEvent, float distance);
103 
104 private:
105     static inline int64_t dispatchStartTime_ { 0 };
106     static inline int64_t comboStartTime_ { 0 };
107     static inline DispCastTime dispCastTime_ { 0 };
108     static inline ComboStartCastTime comboStartCastTime_ { 0 };
109 };
110 } // namespace MMI
111 } // namespace OHOS
112 #endif // BYTRACE_ADAPTER_H
113