• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 MMI_SERVICE_H
17 #define MMI_SERVICE_H
18 
19 #include <system_ability_definition.h>
20 #include "system_ability.h"
21 
22 #include "app_debug_listener.h"
23 #include "input_event_handler.h"
24 #include "json_parser.h"
25 #ifndef OHOS_BUILD_ENABLE_WATCH
26 #include "knuckle_drawing_component.h"
27 #endif // OHOS_BUILD_ENABLE_WATCH
28 #include "libinput_adapter.h"
29 #include "multimodal_input_connect_stub.h"
30 #include "server_msg_handler.h"
31 #include "input_device_consumer_handler.h"
32 
33 namespace OHOS {
34 namespace MMI {
35 #if defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR)
36 class TouchGestureManager;
37 #endif // defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR)
38 
39 struct DeviceConsumer {
40     std::string name {};
41     std::vector<int32_t> uids {};
42 };
43 
44 struct ConsumersData {
45     std::vector<DeviceConsumer> consumers {};
46 };
47 
48 enum class ServiceRunningState {STATE_NOT_START, STATE_RUNNING, STATE_EXIT};
49 class MMIService final : public UDSServer, public SystemAbility, public MultimodalInputConnectStub {
50     DECLARE_SYSTEM_ABILITY(MMIService);
51 
52 public:
53     static constexpr int32_t INVALID_SOCKET_FD = -1;
54     static constexpr int32_t MULTIMODAL_INPUT_CONNECT_SERVICE_ID = MULTIMODAL_INPUT_SERVICE_ID;
55     void OnStart() override;
56     void OnStop() override;
57     static MMIService* GetInstance();
58     int32_t Dump(int32_t fd, const std::vector<std::u16string> &args) override;
59     ErrCode AllocSocketFd(const std::string &programName, const int32_t moduleType,
60         int32_t &toReturnClientFd, int32_t &tokenType) override;
61     ErrCode AddInputEventFilter(const sptr<IEventFilter>& filter, int32_t filterId, int32_t priority,
62         uint32_t deviceTags) override;
63     ErrCode RemoveInputEventFilter(int32_t filterId) override;
64     ErrCode SetPointerSize(int32_t size) override;
65     ErrCode GetPointerSize(int32_t &size) override;
66     ErrCode GetCursorSurfaceId(uint64_t &surfaceId) override;
67     ErrCode SetMouseScrollRows(int32_t rows) override;
68     ErrCode GetMouseScrollRows(int32_t &rows) override;
69     ErrCode SetCustomCursorPixelMap(int32_t windowId, int32_t focusX, int32_t focusY,
70         const CursorPixelMap& curPixelMap) override;
71     ErrCode SetCustomCursor(int32_t windowId,
72         const CustomCursorParcel& curParcel, const CursorOptionsParcel& cOptionParcel) override;
73     ErrCode SetMouseIcon(int32_t windowId, const CursorPixelMap& curPixelMap) override;
74     ErrCode ClearWindowPointerStyle(int32_t pid, int32_t windowId) override;
75     ErrCode SetMouseHotSpot(int32_t pid, int32_t windowId, int32_t hotSpotX, int32_t hotSpotY) override;
76     ErrCode SetNapStatus(int32_t pid, int32_t uid, const std::string& bundleName, int32_t napStatus) override;
77     ErrCode SetMousePrimaryButton(int32_t primaryButton) override;
78     ErrCode GetMousePrimaryButton(int32_t &primaryButton) override;
79     ErrCode SetHoverScrollState(bool state) override;
80     ErrCode GetHoverScrollState(bool &state) override;
81     ErrCode SetPointerVisible(bool visible, int32_t priority) override;
82     ErrCode IsPointerVisible(bool &visible) override;
83     ErrCode MarkProcessed(int32_t eventType, int32_t eventId) override;
84     ErrCode SetPointerColor(int32_t color) override;
85     ErrCode GetPointerColor(int32_t &color) override;
86     ErrCode EnableCombineKey(bool enable) override;
87     ErrCode SetPointerSpeed(int32_t speed) override;
88     ErrCode GetPointerSpeed(int32_t &speed) override;
89     ErrCode SetPointerStyle(int32_t windowId, const PointerStyle& pointerStyle, bool isUiExtension = false) override;
90     ErrCode NotifyNapOnline() override;
91     ErrCode RemoveInputEventObserver() override;
92     ErrCode GetPointerStyle(int32_t windowId, PointerStyle& pointerStyle, bool isUiExtension = false) override;
93     ErrCode SupportKeys(int32_t deviceId, const std::vector<int32_t>& keys, std::vector<bool>& keystroke) override;
94     ErrCode GetDeviceIds(std::vector<int32_t> &ids) override;
95     ErrCode GetDevice(int32_t deviceId, InputDevice& inputDevice) override;
96     ErrCode RegisterDevListener() override;
97     ErrCode UnregisterDevListener() override;
98     ErrCode GetKeyboardType(int32_t deviceId, int32_t &keyboardType) override;
99     ErrCode SetKeyboardRepeatDelay(int32_t delay) override;
100     ErrCode SetKeyboardRepeatRate(int32_t rate) override;
101     ErrCode GetKeyboardRepeatDelay(int32_t &delay) override;
102     ErrCode GetKeyboardRepeatRate(int32_t &rate) override;
103     ErrCode AddInputHandler(int32_t handlerType, uint32_t eventType, int32_t priority, uint32_t deviceTags,
104         const std::vector<int32_t>& actionsType = std::vector<int32_t>()) override;
105     ErrCode RemoveInputHandler(int32_t handlerType, uint32_t eventType, int32_t priority, uint32_t deviceTags,
106         const std::vector<int32_t>& actionsType = std::vector<int32_t>()) override;
107     ErrCode AddPreInputHandler(int32_t handlerId, uint32_t eventType, const std::vector<int32_t>& keys) override;
108     ErrCode RemovePreInputHandler(int32_t handlerId) override;
109     ErrCode AddGestureMonitor(int32_t handlerType, uint32_t eventType, uint32_t gestureType, int32_t fingers) override;
110     ErrCode RemoveGestureMonitor(int32_t handlerType, uint32_t eventType,
111         uint32_t gestureType, int32_t fingers) override;
112     ErrCode MarkEventConsumed(int32_t eventId) override;
113     ErrCode MoveMouseEvent(int32_t offsetX, int32_t offsetY) override;
114     ErrCode InjectKeyEvent(const KeyEvent& keyEvent, bool isNativeInject) override;
115     ErrCode SubscribeKeyEvent(int32_t subscribeId, const KeyOption& keyOption) override;
116     ErrCode UnsubscribeKeyEvent(int32_t subscribeId) override;
117     ErrCode SubscribeHotkey(int32_t subscribeId, const KeyOption& keyOption) override;
118     ErrCode UnsubscribeHotkey(int32_t subscribeId) override;
119 #ifdef OHOS_BUILD_ENABLE_KEY_PRESSED_HANDLER
120     ErrCode SubscribeKeyMonitor(const KeyMonitorOption &keyOption) override;
121     ErrCode UnsubscribeKeyMonitor(const KeyMonitorOption &keyOption) override;
122 #endif // OHOS_BUILD_ENABLE_KEY_PRESSED_HANDLER
123     ErrCode SubscribeSwitchEvent(int32_t subscribeId, int32_t switchType) override;
124     ErrCode UnsubscribeSwitchEvent(int32_t subscribeId) override;
125     ErrCode QuerySwitchStatus(int32_t switchType, int32_t& state) override;
126     ErrCode SubscribeTabletProximity(int32_t subscribeId) override;
127     ErrCode UnsubscribetabletProximity(int32_t subscribeId) override;
128     ErrCode SubscribeLongPressEvent(int32_t subscribeId, const LongPressRequest &longPressRequest) override;
129     ErrCode UnsubscribeLongPressEvent(int32_t subscribeId) override;
130     ErrCode InjectPointerEvent(const PointerEvent& pointerEvent, bool isNativeInject, int32_t useCoordinate) override;
131     ErrCode InjectTouchPadEvent(const PointerEvent& pointerEvent, const TouchpadCDG& touchpadCDG,
132         bool isNativeInject) override;
133     ErrCode SetAnrObserver() override;
134     ErrCode GetDisplayBindInfo(std::vector<DisplayBindInfo>& infos) override;
135     ErrCode GetAllMmiSubscribedEvents(MmiEventMap& mmiEventMap) override;
136     ErrCode SetDisplayBind(int32_t deviceId, int32_t displayId, std::string &msg) override;
137     ErrCode GetFunctionKeyState(int32_t funcKey, bool &state) override;
138     ErrCode SetFunctionKeyState(int32_t funcKey, bool enable) override;
139     ErrCode SetPointerLocation(int32_t x, int32_t y, int32_t displayId) override;
140     ErrCode GetPointerLocation(int32_t &displayId, double &displayX, double &displayY) override;
141     ErrCode SetMouseCaptureMode(int32_t windowId, bool isCaptureMode) override;
142     ErrCode GetWindowPid(int32_t windowId, int32_t &windowPid) override;
143     ErrCode AppendExtraData(const ExtraData &extraData) override;
144     ErrCode EnableInputDevice(bool enable) override;
145     ErrCode SetKeyDownDuration(const std::string &businessId, int32_t delay) override;
146     ErrCode SetTouchpadScrollSwitch(bool switchFlag) override;
147     ErrCode GetTouchpadScrollSwitch(bool &switchFlag) override;
148     ErrCode SetTouchpadScrollDirection(bool state) override;
149     ErrCode GetTouchpadScrollDirection(bool &state) override;
150     ErrCode SetTouchpadTapSwitch(bool switchFlag) override;
151     ErrCode GetTouchpadTapSwitch(bool &switchFlag) override;
152     ErrCode SetTouchpadPointerSpeed(int32_t speed) override;
153     ErrCode GetTouchpadPointerSpeed(int32_t &speed) override;
154     ErrCode GetTouchpadCDG(TouchpadCDG &touchpadCDG) override;
155     ErrCode SetTouchpadPinchSwitch(bool switchFlag) override;
156     ErrCode GetTouchpadPinchSwitch(bool &switchFlag) override;
157     ErrCode SetTouchpadSwipeSwitch(bool switchFlag) override;
158     ErrCode GetTouchpadSwipeSwitch(bool &switchFlag) override;
159     ErrCode SetTouchpadRightClickType(int32_t type) override;
160     ErrCode GetTouchpadRightClickType(int32_t &type) override;
161     ErrCode SetTouchpadRotateSwitch(bool rotateSwitch) override;
162     ErrCode GetTouchpadRotateSwitch(bool &rotateSwitch) override;
163     ErrCode SetTouchpadDoubleTapAndDragState(bool switchFlag) override;
164     ErrCode GetTouchpadDoubleTapAndDragState(bool &switchFlag) override;
165     ErrCode SetShieldStatus(int32_t shieldMode, bool isShield) override;
166     ErrCode GetShieldStatus(int32_t shieldMode, bool &isShield) override;
167     ErrCode GetKeyState(std::vector<int32_t>& pressedKeys,
168         std::unordered_map<int32_t, int32_t>& specialKeysState) override;
169     ErrCode Authorize(bool isAuthorize) override;
170     ErrCode CancelInjection() override;
171     ErrCode RequestInjection(int32_t &status, int32_t &reqId) override;
172     ErrCode QueryAuthorizedStatus(int32_t &status) override;
173     ErrCode SetMoveEventFilters(bool flag) override;
174 #ifdef OHOS_RSS_CLIENT
175     void OnAddResSchedSystemAbility(int32_t systemAbilityId, const std::string &deviceId);
176 #endif // OHOS_RSS_CLIENT
177     void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override;
178     ErrCode HasIrEmitter(bool &hasIrEmitter) override;
179     ErrCode GetInfraredFrequencies(std::vector<InfraredFrequency>& frequencies) override;
180     ErrCode TransmitInfrared(int64_t number, const std::vector<int64_t>& pattern) override;
181 #ifdef OHOS_BUILD_ENABLE_VKEYBOARD
182     ErrCode CreateVKeyboardDevice(sptr<IRemoteObject> &vkeyboardDevice) override;
183     int32_t OnCreateVKeyboardDevice(sptr<IRemoteObject> &vkeyboardDevice);
184 #endif // OHOS_BUILD_ENABLE_VKEYBOARD
185     int32_t OnHasIrEmitter(bool &hasIrEmitter);
186     ErrCode SetPixelMapData(int32_t infoId, const CursorPixelMap& curPixelMap) override;
187     ErrCode SetCurrentUser(int32_t userId) override;
188     ErrCode SetTouchpadThreeFingersTapSwitch(bool switchFlag) override;
189     ErrCode GetTouchpadThreeFingersTapSwitch(bool &switchFlag) override;
190     ErrCode AddVirtualInputDevice(const InputDevice& device, int32_t& deviceId) override;
191     ErrCode RemoveVirtualInputDevice(int32_t deviceId) override;
192     ErrCode EnableHardwareCursorStats(bool enable) override;
193     ErrCode GetHardwareCursorStats(uint32_t &frameCount, uint32_t &vsyncCount) override;
194 #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR
195     ErrCode GetPointerSnapshot(CursorPixelMap& pixelMap) override;
196 #endif // OHOS_BUILD_ENABLE_MAGICCURSOR
197     ErrCode TransferBinderClientSrv(const sptr<IRemoteObject> &binderClientObject) override;
198     ErrCode SetTouchpadScrollRows(int32_t rows) override;
199     ErrCode GetTouchpadScrollRows(int32_t &rows) override;
200     ErrCode SkipPointerLayer(bool isSkip) override;
201     void CalculateFuntionRunningTime(std::function<void()> func, const std::string &flag);
202     ErrCode SetClientInfo(int32_t pid, uint64_t readThreadId) override;
203     ErrCode GetIntervalSinceLastInput(int64_t &timeInterval) override;
204 #ifdef OHOS_BUILD_ENABLE_ANCO
205     void InitAncoUds();
206     void StopAncoUds();
207     int32_t InjectKeyEventExt(const std::shared_ptr<KeyEvent> keyEvent, int32_t pid, bool isNativeInject);
208     int32_t InjectPointerEventExt(const std::shared_ptr<PointerEvent> pointerEvent, int32_t pid,
209         bool isNativeInject, bool isShell);
210     ErrCode AncoAddChannel(const sptr<IAncoChannel>& channel) override;
211     ErrCode AncoRemoveChannel(const sptr<IAncoChannel>& channel) override;
212     ErrCode CheckKnuckleEvent(float pointX, float pointY, bool &isKnuckleType) override;
213     int32_t SyncKnuckleStatus();
214 #endif // OHOS_BUILD_ENABLE_ANCO
215 #if defined(OHOS_BUILD_ENABLE_MONITOR) && defined(PLAYER_FRAMEWORK_EXISTS)
216     static void ScreenCaptureCallback(int32_t pid, bool isStart);
217     void RegisterScreenCaptureCallback();
218 #endif // OHOS_BUILD_ENABLE_MONITOR && PLAYER_FRAMEWORK_EXISTS
219 
220     int32_t OnGetAllSystemHotkey(std::vector<std::unique_ptr<KeyOption>> &keyOptions);
221     ErrCode GetAllSystemHotkeys(std::vector<KeyOption>& keyOptions) override;
222     ErrCode SetInputDeviceEnabled(int32_t deviceId, bool enable, int32_t index) override;
223     ErrCode ShiftAppPointerEvent(const ShiftWindowParam &param, bool autoGenDown) override;
224     ErrCode SetMultiWindowScreenId(uint64_t screenId, uint64_t displayNodeScreenId) override;
225     int32_t SetMultiWindowScreenIdInner(uint64_t screenId, uint64_t displayNodeScreenId);
226     ErrCode SetKnuckleSwitch(bool knuckleSwitch) override;
227     ErrCode LaunchAiScreenAbility() override;
228     ErrCode GetMaxMultiTouchPointNum(int32_t &pointNum) override;
229     ErrCode SubscribeInputActive(int32_t subscribeId, int64_t interval) override;
230     ErrCode UnsubscribeInputActive(int32_t subscribeId) override;
231     ErrCode SetMouseAccelerateMotionSwitch(int32_t deviceId, bool enable) override;
232     ErrCode SwitchScreenCapturePermission(uint32_t permissionType, bool enable) override;
233     ErrCode ClearMouseHideFlag(int32_t eventId) override;
234     ErrCode QueryPointerRecord(int32_t count, std::vector<std::shared_ptr<PointerEvent>> &pointerList) override;
235 
236 protected:
237     void OnConnected(SessionPtr s) override;
238     void OnDisconnected(SessionPtr s) override;
239     int32_t AddEpoll(EpollEventType type, int32_t fd, bool readOnly = false) override;
240     int32_t DelEpoll(EpollEventType type, int32_t fd);
241     bool IsRunning() const;
242 #if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_POINTER_DRAWING)
243     int32_t CheckPointerVisible(bool &visible);
244 #endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_POINTER_DRAWING
245 #ifdef OHOS_BUILD_ENABLE_POINTER
246     int32_t ReadMouseScrollRows(int32_t &rows);
247     int32_t ReadPointerSize(int32_t &size);
248     int32_t ReadMousePrimaryButton(int32_t &primaryButton);
249     int32_t ReadPointerSpeed(int32_t &speed);
250     int32_t ReadHoverScrollState(bool &state);
251     int32_t ReadPointerColor(int32_t &color);
252     int32_t ReadTouchpadScrollSwich(bool &switchFlag);
253     int32_t ReadTouchpadScrollDirection(bool &state);
254     int32_t ReadTouchpadTapSwitch(bool &switchFlag);
255     int32_t ReadTouchpadPointerSpeed(int32_t &speed);
256     int32_t ReadTouchpadCDG(TouchpadCDG &touchpadCDG);
257     int32_t ReadTouchpadPinchSwitch(bool &switchFlag);
258     int32_t ReadTouchpadSwipeSwitch(bool &switchFlag);
259     int32_t ReadTouchpadRightMenuType(int32_t &type);
260     int32_t ReadTouchpadRotateSwitch(bool &rotateSwitch);
261     int32_t ReadTouchpadDoubleTapAndDragState(bool &switchFlag);
262     int32_t ReadTouchpadScrollRows(int32_t &rows);
263 #endif // OHOS_BUILD_ENABLE_POINTER
264     int32_t OnRegisterDevListener(int32_t pid);
265     int32_t OnUnregisterDevListener(int32_t pid);
266     int32_t OnGetDeviceIds(std::vector<int32_t> &ids);
267     int32_t OnGetDevice(int32_t deviceId, std::shared_ptr<InputDevice> inputDevice);
268     int32_t OnSupportKeys(int32_t deviceId, std::vector<int32_t> &keys, std::vector<bool> &keystroke);
269     int32_t OnGetKeyboardType(int32_t deviceId, int32_t &keyboardType);
270     int32_t OnGetWindowPid(int32_t windowId, int32_t &windowPid);
271 #if defined(OHOS_BUILD_ENABLE_INTERCEPTOR) || defined(OHOS_BUILD_ENABLE_MONITOR)
272     int32_t CheckAddInput(int32_t pid, InputHandlerType handlerType, HandleEventType eventType,
273         int32_t priority, uint32_t deviceTags);
274     int32_t CheckRemoveInput(int32_t pid, InputHandlerType handlerType, HandleEventType eventType,
275         int32_t priority, uint32_t deviceTags);
276     int32_t ObserverAddInputHandler(int32_t pid);
277 #endif // OHOS_BUILD_ENABLE_INTERCEPTOR || OHOS_BUILD_ENABLE_MONITOR
278     int32_t CheckMarkConsumed(int32_t pid, int32_t eventId);
279     int32_t CheckInjectKeyEvent(const std::shared_ptr<KeyEvent> keyEvent, int32_t pid, bool isNativeInject);
280 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
281     int32_t OnGetKeyState(std::vector<int32_t> &pressedKeys, std::unordered_map<int32_t, int32_t> &specialKeysState);
282 #endif // OHOS_BUILD_ENABLE_KEYBOARD
283     int32_t CheckInjectPointerEvent(const std::shared_ptr<PointerEvent> pointerEvent,
284         int32_t pid, bool isNativeInject, bool isShell, int32_t useCoordinate);
285     int32_t CheckTouchPadEvent(const std::shared_ptr<PointerEvent> pointerEvent,
286         int32_t pid, const TouchpadCDG &touchpadCDG, bool isNativeInject, bool isShell);
287     bool InitLibinputService();
288     bool InitService();
289     bool InitSignalHandler();
290     bool InitDelegateTasks();
291     int32_t Init();
292     void InitPreferences();
293 #ifdef OHOS_BUILD_PC_PRIORITY
294     void SetMmiServicePriority(int32_t tid);
295 #endif // OHOS_BUILD_PC_PRIORITY
296     void OnThread();
297     void PreEventLoop();
298     void OnSignalEvent(int32_t signalFd);
299     void OnDelegateTask(epoll_event& ev);
300 
301     void AddReloadDeviceTimer();
302 #if defined(OHOS_BUILD_ENABLE_KEYBOARD) && defined(OHOS_BUILD_ENABLE_COMBINATION_KEY)
303     int32_t UpdateSettingsXml(const std::string &businessId, int32_t delay);
304 #endif // OHOS_BUILD_ENABLE_KEYBOARD && OHOS_BUILD_ENABLE_COMBINATION_KEY
305     void AddAppDebugListener();
306     void RemoveAppDebugListener();
307 #if defined(OHOS_BUILD_ENABLE_KEYBOARD) && defined(OHOS_BUILD_ENABLE_COMBINATION_KEY)
308     int32_t UpdateCombineKeyState(bool enable);
309 #endif // OHOS_BUILD_ENABLE_KEYBOARD && OHOS_BUILD_ENABLE_COMBINATION_KEY
310     int32_t OnAuthorize(bool isAuthorize);
311     int32_t OnCancelInjection(int32_t callPid = 0);
312     void InitPrintClientInfo();
313 #ifdef OHOS_BUILD_ENABLE_VKEYBOARD
314     void InitVKeyboardFuncHandler();
315 #endif // OHOS_BUILD_ENABLE_VKEYBOARD
316     int32_t SetInputDeviceEnable(int32_t deviceId, bool enable, int32_t index, int32_t pid, SessionPtr sess);
317     ErrCode SetInputDeviceConsumer(const std::vector<std::string>& deviceNames) override;
318     ErrCode ClearInputDeviceConsumer(const std::vector<std::string>& deviceNames) override;
319     ErrCode InitCustomConfig();
320 private:
321     MMIService();
322     ~MMIService();
323 
324     int32_t CheckPidPermission(int32_t pid);
325     void PrintLog(const std::string &flag, int32_t duration, int32_t pid, int32_t tid);
326     void OnSessionDelete(SessionPtr session);
327     bool IsValidType(int32_t type);
328     int32_t CheckInputHandlerVaild(InputHandlerType handlerType);
329     int32_t CheckRemoveInputHandlerVaild(InputHandlerType handlerType);
330     void DealConsumers(std::vector<std::string>& filterNames, const DeviceConsumer &consumer);
331     std::vector<std::string> FilterConsumers(const std::vector<std::string> &deviceNames);
332     void UpdateConsumers(const cJSON* consumer);
333     bool ParseDeviceConsumerConfig();
334 #if defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR)
335     void SetupTouchGestureHandler();
336 #endif // defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR)
337 
338     std::atomic<ServiceRunningState> state_ = ServiceRunningState::STATE_NOT_START;
339     int32_t mmiFd_ { -1 };
340     std::atomic<bool> isCesStart_ { false };
341     std::mutex mu_;
342     std::thread t_;
343     std::thread eventMonitorThread_;
344     ConsumersData consumersData_;
345 #ifdef OHOS_BUILD_ENABLE_ANCO
346     int32_t shellAssitentPid_ { -1 };
347 #endif // OHOS_BUILD_ENABLE_ANCO
348 #ifdef OHOS_RSS_CLIENT
349     std::atomic<uint64_t> tid_ = 0;
350 #endif // OHOS_RSS_CLIENT
351     LibinputAdapter libinputAdapter_;
352     ServerMsgHandler sMsgHandler_;
353     DelegateTasks delegateTasks_;
354 #if defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR)
355     std::shared_ptr<TouchGestureManager> touchGestureMgr_ { nullptr };
356 #endif // defined(OHOS_BUILD_ENABLE_TOUCH) && defined(OHOS_BUILD_ENABLE_MONITOR)
357     std::shared_ptr<DelegateInterface> delegateInterface_ { nullptr };
358     sptr<AppDebugListener> appDebugListener_;
359     std::atomic_bool threadStatusFlag_ { false };
360     struct ClientInfo {
361         int32_t pid { -1 };
362         uint64_t readThreadId { -1 };
363     };
364     std::map<std::string, ClientInfo> clientInfos_;
365     std::mutex mutex_;
366 #if defined(OHOS_BUILD_ENABLE_MONITOR) && defined(PLAYER_FRAMEWORK_EXISTS)
367     bool hasRegisterListener_ { false };
368 #endif // OHOS_BUILD_ENABLE_MONITOR && PLAYER_FRAMEWORK_EXISTS
369 #ifdef OHOS_BUILD_ENABLE_VKEYBOARD
370     std::atomic_bool isFoldPC_ { false };
371 #endif // OHOS_BUILD_ENABLE_VKEYBOARD
372 };
373 } // namespace MMI
374 } // namespace OHOS
375 #endif // MMI_SERVICE_H
376