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 BYTRACE_ADAPTER_H 17 #define BYTRACE_ADAPTER_H 18 19 #include "key_event.h" 20 #include "pointer_event.h" 21 22 namespace OHOS { 23 namespace MMI { 24 class BytraceAdapter final { 25 public: 26 enum TraceBtn { 27 TRACE_STOP = 0, 28 TRACE_START = 1 29 }; 30 enum HandlerType { 31 KEY_INTERCEPT_EVENT = 1, 32 KEY_LAUNCH_EVENT = 2, 33 KEY_SUBSCRIBE_EVENT = 3, 34 KEY_DISPATCH_EVENT = 4, 35 POINT_INTERCEPT_EVENT = 5, 36 POINT_DISPATCH_EVENT = 6 37 }; 38 enum EventType { 39 START_EVENT = 1, 40 LAUNCH_EVENT = 2, 41 STOP_EVENT = 3 42 }; 43 44 static void StartBytrace(std::shared_ptr<KeyEvent> keyEvent); 45 static void StartBytrace(std::shared_ptr<KeyEvent> key, HandlerType handlerType); 46 static void StartBytrace(std::shared_ptr<PointerEvent> pointerEvent, TraceBtn traceBtn); 47 static void StartBytrace(std::shared_ptr<KeyEvent> keyEvent, TraceBtn traceBtn, HandlerType handlerType); 48 static void StartBytrace(std::shared_ptr<PointerEvent> pointerEvent, TraceBtn traceBtn, HandlerType handlerType); 49 static void StartBytrace(TraceBtn traceBtn, EventType eventType); 50 51 static void StartIpcServer(uint32_t code); 52 static void StopIpcServer(); 53 54 static void StartHandleInput(int32_t code); 55 static void StopHandleInput(); 56 static void StartPackageEvent(const std::string &msg); 57 static void StopPackageEvent(); 58 59 static void StartSocketHandle(int32_t msgId); 60 static void StopSocketHandle(); 61 62 static void StartDevListener(const std::string& type, int32_t deviceId); 63 static void StopDevListener(); 64 65 static void StartLaunchAbility(int32_t type, const std::string &bundleName); 66 static void StopLaunchAbility(); 67 68 static void StartHandleTracker(int32_t pointerId); 69 static void StopHandleTracker(); 70 71 static void StartConsumer(std::shared_ptr<PointerEvent> pointerEvent); 72 static void StartConsumer(std::shared_ptr<KeyEvent> key); 73 static void StopConsumer(); 74 75 static void StartPostTaskEvent(std::shared_ptr<PointerEvent> pointerEvent); 76 static void StartPostTaskEvent(std::shared_ptr<KeyEvent> keyEvent); 77 static void StopPostTaskEvent(); 78 79 static void StartMarkedTracker(int32_t eventId); 80 static void StopMarkedTracker(); 81 82 static void StartTouchEvent(int32_t pointerId); 83 static void StopTouchEvent(); 84 85 static void StartToolType(int32_t toolType); 86 static void StopToolType(); 87 88 static void StartTouchUp(int32_t pointerId); 89 static void StopTouchUp(); 90 91 static void StartUpdateDisplayMode(const std::string &modeMsg); 92 static void StopUpdateDisplayMode(); 93 94 static void StartDataShare(const std::string &key); 95 static void StopDataShare(); 96 97 static void StartRsSurfaceNode(int32_t displayId); 98 static void StopRsSurfaceNode(); 99 100 static void StartFoldState(bool state); 101 static void StopFoldState(); 102 103 static void StartWindowVisible(int32_t pid); 104 static void StopWindowVisible(); 105 106 private: 107 static std::string GetPointerTraceString(std::shared_ptr<PointerEvent> pointerEvent); 108 static std::string GetKeyTraceString(std::shared_ptr<KeyEvent> keyEvent); 109 }; 110 } // namespace MMI 111 } // namespace OHOS 112 #endif // BYTRACE_ADAPTER_H 113