1c29fa5a6Sopenharmony_ci/* 2c29fa5a6Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 3c29fa5a6Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4c29fa5a6Sopenharmony_ci * you may not use this file except in compliance with the License. 5c29fa5a6Sopenharmony_ci * You may obtain a copy of the License at 6c29fa5a6Sopenharmony_ci * 7c29fa5a6Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8c29fa5a6Sopenharmony_ci * 9c29fa5a6Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10c29fa5a6Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11c29fa5a6Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12c29fa5a6Sopenharmony_ci * See the License for the specific language governing permissions and 13c29fa5a6Sopenharmony_ci * limitations under the License. 14c29fa5a6Sopenharmony_ci */ 15c29fa5a6Sopenharmony_ci 16c29fa5a6Sopenharmony_ci#ifndef DFX_HISYSEVENT_H 17c29fa5a6Sopenharmony_ci#define DFX_HISYSEVENT_H 18c29fa5a6Sopenharmony_ci 19c29fa5a6Sopenharmony_ci#include <string> 20c29fa5a6Sopenharmony_ci 21c29fa5a6Sopenharmony_ci#include "hisysevent.h" 22c29fa5a6Sopenharmony_ci 23c29fa5a6Sopenharmony_ci#include "input_device_manager.h" 24c29fa5a6Sopenharmony_ci#include "key_event.h" 25c29fa5a6Sopenharmony_ci#include "mmi_log.h" 26c29fa5a6Sopenharmony_ci#include "pointer_event.h" 27c29fa5a6Sopenharmony_ci#include "uds_session.h" 28c29fa5a6Sopenharmony_ci 29c29fa5a6Sopenharmony_cinamespace OHOS { 30c29fa5a6Sopenharmony_cinamespace MMI { 31c29fa5a6Sopenharmony_ciclass DfxHisysevent { 32c29fa5a6Sopenharmony_cipublic: 33c29fa5a6Sopenharmony_ci struct DispCastTime { 34c29fa5a6Sopenharmony_ci uint32_t sampleCount; 35c29fa5a6Sopenharmony_ci uint32_t totalTimes; 36c29fa5a6Sopenharmony_ci uint32_t below10msTimes; 37c29fa5a6Sopenharmony_ci uint32_t below25msTimes; 38c29fa5a6Sopenharmony_ci uint32_t below50msTimes; 39c29fa5a6Sopenharmony_ci uint32_t above50msTimes; 40c29fa5a6Sopenharmony_ci }; 41c29fa5a6Sopenharmony_ci struct ComboStartCastTime { 42c29fa5a6Sopenharmony_ci uint32_t totalTimes; 43c29fa5a6Sopenharmony_ci uint32_t below10msTimes; 44c29fa5a6Sopenharmony_ci uint32_t below30msTimes; 45c29fa5a6Sopenharmony_ci uint32_t below50msTimes; 46c29fa5a6Sopenharmony_ci uint32_t above50msTimes; 47c29fa5a6Sopenharmony_ci }; 48c29fa5a6Sopenharmony_ci struct ClientConnectData { 49c29fa5a6Sopenharmony_ci int32_t pid { -1 }; 50c29fa5a6Sopenharmony_ci int32_t uid { -1 }; 51c29fa5a6Sopenharmony_ci int32_t moduleType { -1 }; 52c29fa5a6Sopenharmony_ci std::string programName; 53c29fa5a6Sopenharmony_ci int32_t serverFd { -1 }; 54c29fa5a6Sopenharmony_ci }; 55c29fa5a6Sopenharmony_ci 56c29fa5a6Sopenharmony_ci enum TOUCHPAD_SETTING_CODE { 57c29fa5a6Sopenharmony_ci TOUCHPAD_SCROLL_SETTING = 1, 58c29fa5a6Sopenharmony_ci TOUCHPAD_SCROLL_DIR_SETTING, 59c29fa5a6Sopenharmony_ci TOUCHPAD_TAP_SETTING, 60c29fa5a6Sopenharmony_ci TOUCHPAD_SWIPE_SETTING, 61c29fa5a6Sopenharmony_ci TOUCHPAD_PINCH_SETTING, 62c29fa5a6Sopenharmony_ci TOUCHPAD_POINTER_SPEED_SETTING, 63c29fa5a6Sopenharmony_ci TOUCHPAD_RIGHT_CLICK_SETTING, 64c29fa5a6Sopenharmony_ci TOUCHPAD_ROTATE_SETTING 65c29fa5a6Sopenharmony_ci }; 66c29fa5a6Sopenharmony_ci 67c29fa5a6Sopenharmony_ci static void OnDeviceConnect(int32_t id, OHOS::HiviewDFX::HiSysEvent::EventType type); 68c29fa5a6Sopenharmony_ci static void OnDeviceDisconnect(int32_t id, OHOS::HiviewDFX::HiSysEvent::EventType type); 69c29fa5a6Sopenharmony_ci static void OnClientConnect(const ClientConnectData &data, OHOS::HiviewDFX::HiSysEvent::EventType type); 70c29fa5a6Sopenharmony_ci static void OnClientDisconnect(const SessionPtr& secPtr, int32_t fd, 71c29fa5a6Sopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType type); 72c29fa5a6Sopenharmony_ci static void OnUpdateTargetPointer(std::shared_ptr<PointerEvent> pointer, int32_t fd, 73c29fa5a6Sopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType type); 74c29fa5a6Sopenharmony_ci static void OnUpdateTargetKey(std::shared_ptr<KeyEvent> key, int32_t fd, 75c29fa5a6Sopenharmony_ci OHOS::HiviewDFX::HiSysEvent::EventType type); 76c29fa5a6Sopenharmony_ci static void OnFocusWindowChanged(int32_t oldFocusWindowId, int32_t newFocusWindowId, 77c29fa5a6Sopenharmony_ci int32_t oldFocusWindowPid, int32_t newFocusWindowPid); 78c29fa5a6Sopenharmony_ci static void OnZorderWindowChanged(int32_t oldZorderFirstWindowId, int32_t newZorderFirstWindowId, 79c29fa5a6Sopenharmony_ci int32_t oldZorderFirstWindowPid, int32_t newZorderFirstWindowPid); 80c29fa5a6Sopenharmony_ci static void OnLidSwitchChanged(int32_t lidSwitch); 81c29fa5a6Sopenharmony_ci static void ApplicationBlockInput(const SessionPtr& sess); 82c29fa5a6Sopenharmony_ci static void CalcKeyDispTimes(); 83c29fa5a6Sopenharmony_ci static void CalcPointerDispTimes(); 84c29fa5a6Sopenharmony_ci static void CalcComboStartTimes(int32_t keyDownDuration); 85c29fa5a6Sopenharmony_ci static void ReportDispTimes(); 86c29fa5a6Sopenharmony_ci static void ReportComboStartTimes(); 87c29fa5a6Sopenharmony_ci static void ReportPowerInfo(std::shared_ptr<KeyEvent> key, OHOS::HiviewDFX::HiSysEvent::EventType type); 88c29fa5a6Sopenharmony_ci static inline void GetComboStartTime() 89c29fa5a6Sopenharmony_ci { 90c29fa5a6Sopenharmony_ci comboStartTime_ = GetSysClockTime(); 91c29fa5a6Sopenharmony_ci } 92c29fa5a6Sopenharmony_ci static inline void GetDispStartTime() 93c29fa5a6Sopenharmony_ci { 94c29fa5a6Sopenharmony_ci dispatchStartTime_ = GetSysClockTime(); 95c29fa5a6Sopenharmony_ci } 96c29fa5a6Sopenharmony_ci static void ReportTouchpadSettingState(TOUCHPAD_SETTING_CODE settingCode, bool flag); 97c29fa5a6Sopenharmony_ci static void ReportTouchpadSettingState(TOUCHPAD_SETTING_CODE settingCode, int32_t value); 98c29fa5a6Sopenharmony_ci static void StatisticTouchpadGesture(std::shared_ptr<PointerEvent> pointerEvent); 99c29fa5a6Sopenharmony_ci static void ReportKnuckleClickEvent(); 100c29fa5a6Sopenharmony_ci static void ReportScreenCaptureGesture(); 101c29fa5a6Sopenharmony_ci static void ReportSingleKnuckleDoubleClickEvent(int32_t intervalTime, int32_t distanceInterval); 102c29fa5a6Sopenharmony_ci static void ReportFailIfInvalidTime(const std::shared_ptr<PointerEvent> touchEvent, int32_t intervalTime); 103c29fa5a6Sopenharmony_ci static void ReportFailIfInvalidDistance(const std::shared_ptr<PointerEvent> touchEvent, float distance); 104c29fa5a6Sopenharmony_ci#ifdef OHOS_BUILD_ENABLE_MAGICCURSOR 105c29fa5a6Sopenharmony_ci static void ReportMagicCursorColorChange(std::string fill_Color, std::string stroke_Color); 106c29fa5a6Sopenharmony_ci static void ReportMagicCursorShapeChange(std::string fill_Code, OHOS::MMI::MOUSE_ICON mouse_Style); 107c29fa5a6Sopenharmony_ci static void ReportMagicCursorSizeChange(std::string fill_Code, std::string mouse_Size); 108c29fa5a6Sopenharmony_ci static void ReportMagicCursorFault(std::string error_Code, std::string error_Name); 109c29fa5a6Sopenharmony_ci#endif // OHOS_BUILD_ENABLE_MAGICCURSOR 110c29fa5a6Sopenharmony_ci static void ReportSmartShotSuccTimes(); 111c29fa5a6Sopenharmony_ci static void ReportKnuckleGestureTrackLength(int32_t knuckleGestureTrackLength); 112c29fa5a6Sopenharmony_ci static void ReportKnuckleGestureTrackTime(const std::vector<int64_t> &gestureTimeStamps); 113c29fa5a6Sopenharmony_ci static void ReportKnuckleGestureFaildTimes(); 114c29fa5a6Sopenharmony_ci static void ReportKnuckleDrawSSuccessTimes(); 115c29fa5a6Sopenharmony_ci static void ReportKnuckleGestureFromFailToSuccessTime(int32_t intervalTime); 116c29fa5a6Sopenharmony_ci static void ReportKnuckleGestureFromSuccessToFailTime(int32_t intervalTime); 117c29fa5a6Sopenharmony_ci static void ReportScreenRecorderGesture(int32_t intervalTime); 118c29fa5a6Sopenharmony_ci static void ReportFailIfKnockTooFast(); 119c29fa5a6Sopenharmony_ci static void ReportFailIfOneSuccTwoFail(const std::shared_ptr<PointerEvent> touchEvent); 120c29fa5a6Sopenharmony_ci static std::string GetTpVendorName(); 121c29fa5a6Sopenharmony_ci static std::string GetAccVendorName(); 122c29fa5a6Sopenharmony_ci static std::string GetLcdInfo(); 123c29fa5a6Sopenharmony_ci 124c29fa5a6Sopenharmony_ciprivate: 125c29fa5a6Sopenharmony_ci static inline int64_t dispatchStartTime_ { 0 }; 126c29fa5a6Sopenharmony_ci static inline int64_t comboStartTime_ { 0 }; 127c29fa5a6Sopenharmony_ci static inline DispCastTime dispCastTime_ { 0 }; 128c29fa5a6Sopenharmony_ci static inline ComboStartCastTime comboStartCastTime_ { 0 }; 129c29fa5a6Sopenharmony_ci}; 130c29fa5a6Sopenharmony_ci} // namespace MMI 131c29fa5a6Sopenharmony_ci} // namespace OHOS 132c29fa5a6Sopenharmony_ci#endif // BYTRACE_ADAPTER_H 133