1c29fa5a6Sopenharmony_ci/* 2c29fa5a6Sopenharmony_ci * Copyright (c) 2021-2023 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 MMI_SERVICE_H 17c29fa5a6Sopenharmony_ci#define MMI_SERVICE_H 18c29fa5a6Sopenharmony_ci 19c29fa5a6Sopenharmony_ci#include <atomic> 20c29fa5a6Sopenharmony_ci#include <mutex> 21c29fa5a6Sopenharmony_ci#include <thread> 22c29fa5a6Sopenharmony_ci 23c29fa5a6Sopenharmony_ci#include "iremote_object.h" 24c29fa5a6Sopenharmony_ci#include "system_ability.h" 25c29fa5a6Sopenharmony_ci 26c29fa5a6Sopenharmony_ci#include "app_debug_listener.h" 27c29fa5a6Sopenharmony_ci#include "delegate_interface.h" 28c29fa5a6Sopenharmony_ci#include "delegate_tasks.h" 29c29fa5a6Sopenharmony_ci#include "infrared_frequency_info.h" 30c29fa5a6Sopenharmony_ci#include "input_event_handler.h" 31c29fa5a6Sopenharmony_ci#include "libinput_adapter.h" 32c29fa5a6Sopenharmony_ci#include "multimodal_input_connect_stub.h" 33c29fa5a6Sopenharmony_ci#include "nap_process.h" 34c29fa5a6Sopenharmony_ci#include "server_msg_handler.h" 35c29fa5a6Sopenharmony_ci#include "uds_server.h" 36c29fa5a6Sopenharmony_ci 37c29fa5a6Sopenharmony_cinamespace OHOS { 38c29fa5a6Sopenharmony_cinamespace MMI { 39c29fa5a6Sopenharmony_ciclass TouchGestureAdapter; 40c29fa5a6Sopenharmony_cienum class ServiceRunningState {STATE_NOT_START, STATE_RUNNING, STATE_EXIT}; 41c29fa5a6Sopenharmony_ciclass MMIService final : public UDSServer, public SystemAbility, public MultimodalInputConnectStub { 42c29fa5a6Sopenharmony_ci DECLARE_SYSTEM_ABILITY(MMIService); 43c29fa5a6Sopenharmony_ci 44c29fa5a6Sopenharmony_cipublic: 45c29fa5a6Sopenharmony_ci void OnStart() override; 46c29fa5a6Sopenharmony_ci void OnStop() override; 47c29fa5a6Sopenharmony_ci static MMIService* GetInstance(); 48c29fa5a6Sopenharmony_ci int32_t Dump(int32_t fd, const std::vector<std::u16string> &args) override; 49c29fa5a6Sopenharmony_ci int32_t AllocSocketFd(const std::string &programName, const int32_t moduleType, 50c29fa5a6Sopenharmony_ci int32_t &toReturnClientFd, int32_t &tokenType) override; 51c29fa5a6Sopenharmony_ci int32_t AddInputEventFilter(sptr<IEventFilter> filter, int32_t filterId, int32_t priority, 52c29fa5a6Sopenharmony_ci uint32_t deviceTags) override; 53c29fa5a6Sopenharmony_ci int32_t RemoveInputEventFilter(int32_t filterId) override; 54c29fa5a6Sopenharmony_ci int32_t SetPointerSize(int32_t size) override; 55c29fa5a6Sopenharmony_ci int32_t GetPointerSize(int32_t &size) override; 56c29fa5a6Sopenharmony_ci int32_t SetMouseScrollRows(int32_t rows) override; 57c29fa5a6Sopenharmony_ci int32_t GetMouseScrollRows(int32_t &rows) override; 58c29fa5a6Sopenharmony_ci int32_t SetCustomCursor(int32_t pid, int32_t windowId, int32_t focusX, int32_t focusY, void* pixelMap) override; 59c29fa5a6Sopenharmony_ci int32_t SetMouseIcon(int32_t windowId, void* pixelMap) override; 60c29fa5a6Sopenharmony_ci int32_t ClearWindowPointerStyle(int32_t pid, int32_t windowId) override; 61c29fa5a6Sopenharmony_ci int32_t SetMouseHotSpot(int32_t pid, int32_t windowId, int32_t hotSpotX, int32_t hotSpotY) override; 62c29fa5a6Sopenharmony_ci int32_t SetNapStatus(int32_t pid, int32_t uid, std::string bundleName, int32_t napState) override; 63c29fa5a6Sopenharmony_ci int32_t SetMousePrimaryButton(int32_t primaryButton) override; 64c29fa5a6Sopenharmony_ci int32_t GetMousePrimaryButton(int32_t &primaryButton) override; 65c29fa5a6Sopenharmony_ci int32_t SetHoverScrollState(bool state) override; 66c29fa5a6Sopenharmony_ci int32_t GetHoverScrollState(bool &state) override; 67c29fa5a6Sopenharmony_ci int32_t SetPointerVisible(bool visible, int32_t priority) override; 68c29fa5a6Sopenharmony_ci int32_t IsPointerVisible(bool &visible) override; 69c29fa5a6Sopenharmony_ci int32_t MarkProcessed(int32_t eventType, int32_t eventId) override; 70c29fa5a6Sopenharmony_ci int32_t SetPointerColor(int32_t color) override; 71c29fa5a6Sopenharmony_ci int32_t GetPointerColor(int32_t &color) override; 72c29fa5a6Sopenharmony_ci int32_t EnableCombineKey(bool enable) override; 73c29fa5a6Sopenharmony_ci int32_t SetPointerSpeed(int32_t speed) override; 74c29fa5a6Sopenharmony_ci int32_t GetPointerSpeed(int32_t &speed) override; 75c29fa5a6Sopenharmony_ci int32_t SetPointerStyle(int32_t windowId, PointerStyle pointerStyle, bool isUiExtension = false) override; 76c29fa5a6Sopenharmony_ci int32_t NotifyNapOnline() override; 77c29fa5a6Sopenharmony_ci int32_t RemoveInputEventObserver() override; 78c29fa5a6Sopenharmony_ci int32_t GetPointerStyle(int32_t windowId, PointerStyle &pointerStyle, bool isUiExtension = false) override; 79c29fa5a6Sopenharmony_ci int32_t SupportKeys(int32_t deviceId, std::vector<int32_t> &keys, std::vector<bool> &keystroke) override; 80c29fa5a6Sopenharmony_ci int32_t GetDeviceIds(std::vector<int32_t> &ids) override; 81c29fa5a6Sopenharmony_ci int32_t GetDevice(int32_t deviceId, std::shared_ptr<InputDevice> &inputDevice) override; 82c29fa5a6Sopenharmony_ci int32_t RegisterDevListener() override; 83c29fa5a6Sopenharmony_ci int32_t UnregisterDevListener() override; 84c29fa5a6Sopenharmony_ci int32_t GetKeyboardType(int32_t deviceId, int32_t &keyboardType) override; 85c29fa5a6Sopenharmony_ci int32_t SetKeyboardRepeatDelay(int32_t delay) override; 86c29fa5a6Sopenharmony_ci int32_t SetKeyboardRepeatRate(int32_t rate) override; 87c29fa5a6Sopenharmony_ci int32_t GetKeyboardRepeatDelay(int32_t &delay) override; 88c29fa5a6Sopenharmony_ci int32_t GetKeyboardRepeatRate(int32_t &rate) override; 89c29fa5a6Sopenharmony_ci int32_t AddInputHandler(InputHandlerType handlerType, HandleEventType eventType, 90c29fa5a6Sopenharmony_ci int32_t priority, uint32_t deviceTags, std::vector<int32_t> actionsType = std::vector<int32_t>()) override; 91c29fa5a6Sopenharmony_ci int32_t RemoveInputHandler(InputHandlerType handlerType, HandleEventType eventType, 92c29fa5a6Sopenharmony_ci int32_t priority, uint32_t deviceTags, std::vector<int32_t> actionsType = std::vector<int32_t>()) override; 93c29fa5a6Sopenharmony_ci int32_t AddGestureMonitor(InputHandlerType handlerType, 94c29fa5a6Sopenharmony_ci HandleEventType eventType, TouchGestureType gestureType, int32_t fingers) override; 95c29fa5a6Sopenharmony_ci int32_t RemoveGestureMonitor(InputHandlerType handlerType, 96c29fa5a6Sopenharmony_ci HandleEventType eventType, TouchGestureType gestureType, int32_t fingers) override; 97c29fa5a6Sopenharmony_ci int32_t MarkEventConsumed(int32_t eventId) override; 98c29fa5a6Sopenharmony_ci int32_t MoveMouseEvent(int32_t offsetX, int32_t offsetY) override; 99c29fa5a6Sopenharmony_ci int32_t InjectKeyEvent(const std::shared_ptr<KeyEvent> keyEvent, bool isNativeInject) override; 100c29fa5a6Sopenharmony_ci int32_t SubscribeKeyEvent(int32_t subscribeId, const std::shared_ptr<KeyOption> option) override; 101c29fa5a6Sopenharmony_ci int32_t UnsubscribeKeyEvent(int32_t subscribeId) override; 102c29fa5a6Sopenharmony_ci int32_t SubscribeHotkey(int32_t subscribeId, const std::shared_ptr<KeyOption> option) override; 103c29fa5a6Sopenharmony_ci int32_t UnsubscribeHotkey(int32_t subscribeId) override; 104c29fa5a6Sopenharmony_ci int32_t SubscribeSwitchEvent(int32_t subscribeId, int32_t switchType) override; 105c29fa5a6Sopenharmony_ci int32_t UnsubscribeSwitchEvent(int32_t subscribeId) override; 106c29fa5a6Sopenharmony_ci int32_t InjectPointerEvent(const std::shared_ptr<PointerEvent> pointerEvent, bool isNativeInject) override; 107c29fa5a6Sopenharmony_ci int32_t SetAnrObserver() override; 108c29fa5a6Sopenharmony_ci int32_t GetDisplayBindInfo(DisplayBindInfos &infos) override; 109c29fa5a6Sopenharmony_ci int32_t GetAllMmiSubscribedEvents(std::map<std::tuple<int32_t, int32_t, std::string>, 110c29fa5a6Sopenharmony_ci int32_t> &datas) override; 111c29fa5a6Sopenharmony_ci int32_t SetDisplayBind(int32_t deviceId, int32_t displayId, std::string &msg) override; 112c29fa5a6Sopenharmony_ci int32_t GetFunctionKeyState(int32_t funcKey, bool &state) override; 113c29fa5a6Sopenharmony_ci int32_t SetFunctionKeyState(int32_t funcKey, bool enable) override; 114c29fa5a6Sopenharmony_ci int32_t SetPointerLocation(int32_t x, int32_t y) override; 115c29fa5a6Sopenharmony_ci virtual int32_t SetMouseCaptureMode(int32_t windowId, bool isCaptureMode) override; 116c29fa5a6Sopenharmony_ci int32_t GetWindowPid(int32_t windowId) override; 117c29fa5a6Sopenharmony_ci int32_t AppendExtraData(const ExtraData& extraData) override; 118c29fa5a6Sopenharmony_ci int32_t EnableInputDevice(bool enable) override; 119c29fa5a6Sopenharmony_ci int32_t SetKeyDownDuration(const std::string &businessId, int32_t delay) override; 120c29fa5a6Sopenharmony_ci int32_t SetTouchpadScrollSwitch(bool switchFlag) override; 121c29fa5a6Sopenharmony_ci int32_t GetTouchpadScrollSwitch(bool &switchFlag) override; 122c29fa5a6Sopenharmony_ci int32_t SetTouchpadScrollDirection(bool state) override; 123c29fa5a6Sopenharmony_ci int32_t GetTouchpadScrollDirection(bool &state) override; 124c29fa5a6Sopenharmony_ci int32_t SetTouchpadTapSwitch(bool switchFlag) override; 125c29fa5a6Sopenharmony_ci int32_t GetTouchpadTapSwitch(bool &switchFlag) override; 126c29fa5a6Sopenharmony_ci int32_t SetTouchpadPointerSpeed(int32_t speed) override; 127c29fa5a6Sopenharmony_ci int32_t GetTouchpadPointerSpeed(int32_t &speed) override; 128c29fa5a6Sopenharmony_ci int32_t SetTouchpadPinchSwitch(bool switchFlag) override; 129c29fa5a6Sopenharmony_ci int32_t GetTouchpadPinchSwitch(bool &switchFlag) override; 130c29fa5a6Sopenharmony_ci int32_t SetTouchpadSwipeSwitch(bool switchFlag) override; 131c29fa5a6Sopenharmony_ci int32_t GetTouchpadSwipeSwitch(bool &switchFlag) override; 132c29fa5a6Sopenharmony_ci int32_t SetTouchpadRightClickType(int32_t type) override; 133c29fa5a6Sopenharmony_ci int32_t GetTouchpadRightClickType(int32_t &type) override; 134c29fa5a6Sopenharmony_ci int32_t SetTouchpadRotateSwitch(bool rotateSwitch) override; 135c29fa5a6Sopenharmony_ci int32_t GetTouchpadRotateSwitch(bool &rotateSwitch) override; 136c29fa5a6Sopenharmony_ci int32_t SetShieldStatus(int32_t shieldMode, bool isShield) override; 137c29fa5a6Sopenharmony_ci int32_t GetShieldStatus(int32_t shieldMode, bool &isShield) override; 138c29fa5a6Sopenharmony_ci int32_t GetKeyState(std::vector<int32_t> &pressedKeys, std::map<int32_t, int32_t> &specialKeysState) override; 139c29fa5a6Sopenharmony_ci int32_t Authorize(bool isAuthorize) override; 140c29fa5a6Sopenharmony_ci int32_t CancelInjection() override; 141c29fa5a6Sopenharmony_ci int32_t SetMoveEventFilters(bool flag) override; 142c29fa5a6Sopenharmony_ci#ifdef OHOS_RSS_CLIENT 143c29fa5a6Sopenharmony_ci void OnAddResSchedSystemAbility(int32_t systemAbilityId, const std::string &deviceId); 144c29fa5a6Sopenharmony_ci#endif // OHOS_RSS_CLIENT 145c29fa5a6Sopenharmony_ci void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; 146c29fa5a6Sopenharmony_ci int32_t HasIrEmitter(bool &hasIrEmitter) override; 147c29fa5a6Sopenharmony_ci int32_t GetInfraredFrequencies(std::vector<InfraredFrequency>& frequencies) override; 148c29fa5a6Sopenharmony_ci int32_t TransmitInfrared(int64_t number, std::vector<int64_t>& pattern) override; 149c29fa5a6Sopenharmony_ci#ifdef OHOS_BUILD_ENABLE_VKEYBOARD 150c29fa5a6Sopenharmony_ci int32_t SetVKeyboardArea(double topLeftX, double topLeftY, double bottomRightX, double bottomRightY) override; 151c29fa5a6Sopenharmony_ci int32_t OnSetVKeyboardArea(double topLeftX, double topLeftY, double bottomRightX, double bottomRightY); 152c29fa5a6Sopenharmony_ci int32_t SetMotionSpace(std::string& keyName, bool useShift, std::vector<int32_t>& pattern) override; 153c29fa5a6Sopenharmony_ci int32_t OnSetMotionSpace(std::string& keyName, bool useShift, std::vector<int32_t>& pattern); 154c29fa5a6Sopenharmony_ci#endif // OHOS_BUILD_ENABLE_VKEYBOARD 155c29fa5a6Sopenharmony_ci int32_t OnHasIrEmitter(bool &hasIrEmitter); 156c29fa5a6Sopenharmony_ci int32_t SetPixelMapData(int32_t infoId, void* pixelMap) override; 157c29fa5a6Sopenharmony_ci int32_t SetCurrentUser(int32_t userId) override; 158c29fa5a6Sopenharmony_ci int32_t SetTouchpadThreeFingersTapSwitch(bool switchFlag) override; 159c29fa5a6Sopenharmony_ci int32_t GetTouchpadThreeFingersTapSwitch(bool &switchFlag) override; 160c29fa5a6Sopenharmony_ci int32_t AddVirtualInputDevice(std::shared_ptr<InputDevice> device, int32_t &deviceId) override; 161c29fa5a6Sopenharmony_ci int32_t RemoveVirtualInputDevice(int32_t deviceId) override; 162c29fa5a6Sopenharmony_ci int32_t EnableHardwareCursorStats(bool enable) override; 163c29fa5a6Sopenharmony_ci int32_t GetHardwareCursorStats(uint32_t &frameCount, uint32_t &vsyncCount) override; 164c29fa5a6Sopenharmony_ci#ifdef OHOS_BUILD_ENABLE_MAGICCURSOR 165c29fa5a6Sopenharmony_ci int32_t GetPointerSnapshot(void *pixelMapPtr) override; 166c29fa5a6Sopenharmony_ci#endif // OHOS_BUILD_ENABLE_MAGICCURSOR 167c29fa5a6Sopenharmony_ci int32_t TransferBinderClientSrv(const sptr<IRemoteObject> &binderClientObject) override; 168c29fa5a6Sopenharmony_ci int32_t SetTouchpadScrollRows(int32_t rows) override; 169c29fa5a6Sopenharmony_ci int32_t GetTouchpadScrollRows(int32_t &rows) override; 170c29fa5a6Sopenharmony_ci int32_t SkipPointerLayer(bool isSkip) override; 171c29fa5a6Sopenharmony_ci void CalculateFuntionRunningTime(std::function<void()> func, const std::string &flag); 172c29fa5a6Sopenharmony_ci int32_t SetClientInfo(int32_t pid, uint64_t readThreadId) override; 173c29fa5a6Sopenharmony_ci int32_t GetIntervalSinceLastInput(int64_t &timeInterval) override; 174c29fa5a6Sopenharmony_ci#ifdef OHOS_BUILD_ENABLE_ANCO 175c29fa5a6Sopenharmony_ci void InitAncoUds(); 176c29fa5a6Sopenharmony_ci void StopAncoUds(); 177c29fa5a6Sopenharmony_ci int32_t InjectKeyEventExt(const std::shared_ptr<KeyEvent> keyEvent, int32_t pid, bool isNativeInject); 178c29fa5a6Sopenharmony_ci int32_t InjectPointerEventExt(const std::shared_ptr<PointerEvent> pointerEvent, int32_t pid, 179c29fa5a6Sopenharmony_ci bool isNativeInject, bool isShell); 180c29fa5a6Sopenharmony_ci int32_t AncoAddChannel(sptr<IAncoChannel> channel) override; 181c29fa5a6Sopenharmony_ci int32_t AncoRemoveChannel(sptr<IAncoChannel> channel) override; 182c29fa5a6Sopenharmony_ci#endif // OHOS_BUILD_ENABLE_ANCO 183c29fa5a6Sopenharmony_ci#if defined(OHOS_BUILD_ENABLE_MONITOR) && defined(PLAYER_FRAMEWORK_EXISTS) 184c29fa5a6Sopenharmony_ci static void ScreenCaptureCallback(int32_t pid, bool isStart); 185c29fa5a6Sopenharmony_ci void RegisterScreenCaptureCallback(); 186c29fa5a6Sopenharmony_ci#endif // OHOS_BUILD_ENABLE_MONITOR && PLAYER_FRAMEWORK_EXISTS 187c29fa5a6Sopenharmony_ci 188c29fa5a6Sopenharmony_ci int32_t OnGetAllSystemHotkey(std::vector<std::unique_ptr<KeyOption>> &keyOptions); 189c29fa5a6Sopenharmony_ci int32_t GetAllSystemHotkeys(std::vector<std::unique_ptr<KeyOption>> &keyOptions) override; 190c29fa5a6Sopenharmony_ci 191c29fa5a6Sopenharmony_ciprotected: 192c29fa5a6Sopenharmony_ci void OnConnected(SessionPtr s) override; 193c29fa5a6Sopenharmony_ci void OnDisconnected(SessionPtr s) override; 194c29fa5a6Sopenharmony_ci int32_t AddEpoll(EpollEventType type, int32_t fd) override; 195c29fa5a6Sopenharmony_ci int32_t DelEpoll(EpollEventType type, int32_t fd); 196c29fa5a6Sopenharmony_ci bool IsRunning() const override; 197c29fa5a6Sopenharmony_ci#if defined(OHOS_BUILD_ENABLE_POINTER) && defined(OHOS_BUILD_ENABLE_POINTER_DRAWING) 198c29fa5a6Sopenharmony_ci int32_t CheckPointerVisible(bool &visible); 199c29fa5a6Sopenharmony_ci#endif // OHOS_BUILD_ENABLE_POINTER && OHOS_BUILD_ENABLE_POINTER_DRAWING 200c29fa5a6Sopenharmony_ci#ifdef OHOS_BUILD_ENABLE_POINTER 201c29fa5a6Sopenharmony_ci int32_t ReadMouseScrollRows(int32_t &rows); 202c29fa5a6Sopenharmony_ci int32_t ReadPointerSize(int32_t &size); 203c29fa5a6Sopenharmony_ci int32_t ReadMousePrimaryButton(int32_t &primaryButton); 204c29fa5a6Sopenharmony_ci int32_t ReadPointerSpeed(int32_t &speed); 205c29fa5a6Sopenharmony_ci int32_t ReadHoverScrollState(bool &state); 206c29fa5a6Sopenharmony_ci int32_t ReadPointerColor(int32_t &color); 207c29fa5a6Sopenharmony_ci int32_t ReadTouchpadScrollSwich(bool &switchFlag); 208c29fa5a6Sopenharmony_ci int32_t ReadTouchpadScrollDirection(bool &state); 209c29fa5a6Sopenharmony_ci int32_t ReadTouchpadTapSwitch(bool &switchFlag); 210c29fa5a6Sopenharmony_ci int32_t ReadTouchpadPointerSpeed(int32_t &speed); 211c29fa5a6Sopenharmony_ci int32_t ReadTouchpadPinchSwitch(bool &switchFlag); 212c29fa5a6Sopenharmony_ci int32_t ReadTouchpadSwipeSwitch(bool &switchFlag); 213c29fa5a6Sopenharmony_ci int32_t ReadTouchpadRightMenuType(int32_t &type); 214c29fa5a6Sopenharmony_ci int32_t ReadTouchpadRotateSwitch(bool &rotateSwitch); 215c29fa5a6Sopenharmony_ci int32_t ReadTouchpadScrollRows(int32_t &rows); 216c29fa5a6Sopenharmony_ci#endif // OHOS_BUILD_ENABLE_POINTER 217c29fa5a6Sopenharmony_ci int32_t OnRegisterDevListener(int32_t pid); 218c29fa5a6Sopenharmony_ci int32_t OnUnregisterDevListener(int32_t pid); 219c29fa5a6Sopenharmony_ci int32_t OnGetDeviceIds(std::vector<int32_t> &ids); 220c29fa5a6Sopenharmony_ci int32_t OnGetDevice(int32_t deviceId, std::shared_ptr<InputDevice> &inputDevice); 221c29fa5a6Sopenharmony_ci int32_t OnSupportKeys(int32_t deviceId, std::vector<int32_t> &keys, std::vector<bool> &keystroke); 222c29fa5a6Sopenharmony_ci int32_t OnGetKeyboardType(int32_t deviceId, int32_t &keyboardType); 223c29fa5a6Sopenharmony_ci int32_t OnGetWindowPid(int32_t windowId, int32_t &windowPid); 224c29fa5a6Sopenharmony_ci#if defined(OHOS_BUILD_ENABLE_INTERCEPTOR) || defined(OHOS_BUILD_ENABLE_MONITOR) 225c29fa5a6Sopenharmony_ci int32_t CheckAddInput(int32_t pid, InputHandlerType handlerType, HandleEventType eventType, 226c29fa5a6Sopenharmony_ci int32_t priority, uint32_t deviceTags); 227c29fa5a6Sopenharmony_ci int32_t CheckRemoveInput(int32_t pid, InputHandlerType handlerType, HandleEventType eventType, 228c29fa5a6Sopenharmony_ci int32_t priority, uint32_t deviceTags); 229c29fa5a6Sopenharmony_ci int32_t CheckAddInput(int32_t pid, InputHandlerType handlerType, std::vector<int32_t> actionsType); 230c29fa5a6Sopenharmony_ci int32_t CheckRemoveInput(int32_t pid, InputHandlerType handlerType, std::vector<int32_t> actionsType); 231c29fa5a6Sopenharmony_ci int32_t ObserverAddInputHandler(int32_t pid); 232c29fa5a6Sopenharmony_ci#endif // OHOS_BUILD_ENABLE_INTERCEPTOR || OHOS_BUILD_ENABLE_MONITOR 233c29fa5a6Sopenharmony_ci int32_t CheckMarkConsumed(int32_t pid, int32_t eventId); 234c29fa5a6Sopenharmony_ci int32_t CheckInjectKeyEvent(const std::shared_ptr<KeyEvent> keyEvent, int32_t pid, bool isNativeInject); 235c29fa5a6Sopenharmony_ci#ifdef OHOS_BUILD_ENABLE_KEYBOARD 236c29fa5a6Sopenharmony_ci int32_t OnGetKeyState(std::vector<int32_t> &pressedKeys, std::map<int32_t, int32_t> &specialKeysState); 237c29fa5a6Sopenharmony_ci#endif // OHOS_BUILD_ENABLE_KEYBOARD 238c29fa5a6Sopenharmony_ci int32_t CheckInjectPointerEvent(const std::shared_ptr<PointerEvent> pointerEvent, 239c29fa5a6Sopenharmony_ci int32_t pid, bool isNativeInject, bool isShell); 240c29fa5a6Sopenharmony_ci bool InitLibinputService(); 241c29fa5a6Sopenharmony_ci bool InitService(); 242c29fa5a6Sopenharmony_ci bool InitSignalHandler(); 243c29fa5a6Sopenharmony_ci bool InitDelegateTasks(); 244c29fa5a6Sopenharmony_ci int32_t Init(); 245c29fa5a6Sopenharmony_ci void InitPreferences(); 246c29fa5a6Sopenharmony_ci 247c29fa5a6Sopenharmony_ci void OnThread(); 248c29fa5a6Sopenharmony_ci void OnSignalEvent(int32_t signalFd); 249c29fa5a6Sopenharmony_ci void OnDelegateTask(epoll_event& ev); 250c29fa5a6Sopenharmony_ci 251c29fa5a6Sopenharmony_ci void AddReloadDeviceTimer(); 252c29fa5a6Sopenharmony_ci#if defined(OHOS_BUILD_ENABLE_KEYBOARD) && defined(OHOS_BUILD_ENABLE_COMBINATION_KEY) 253c29fa5a6Sopenharmony_ci int32_t UpdateSettingsXml(const std::string &businessId, int32_t delay); 254c29fa5a6Sopenharmony_ci#endif // OHOS_BUILD_ENABLE_KEYBOARD && OHOS_BUILD_ENABLE_COMBINATION_KEY 255c29fa5a6Sopenharmony_ci void AddAppDebugListener(); 256c29fa5a6Sopenharmony_ci void RemoveAppDebugListener(); 257c29fa5a6Sopenharmony_ci#if defined(OHOS_BUILD_ENABLE_KEYBOARD) && defined(OHOS_BUILD_ENABLE_COMBINATION_KEY) 258c29fa5a6Sopenharmony_ci int32_t UpdateCombineKeyState(bool enable); 259c29fa5a6Sopenharmony_ci#endif // OHOS_BUILD_ENABLE_KEYBOARD && OHOS_BUILD_ENABLE_COMBINATION_KEY 260c29fa5a6Sopenharmony_ci int32_t OnAuthorize(bool isAuthorize); 261c29fa5a6Sopenharmony_ci int32_t OnCancelInjection(); 262c29fa5a6Sopenharmony_ci void InitPrintClientInfo(); 263c29fa5a6Sopenharmony_ciprivate: 264c29fa5a6Sopenharmony_ci MMIService(); 265c29fa5a6Sopenharmony_ci ~MMIService(); 266c29fa5a6Sopenharmony_ciprivate: 267c29fa5a6Sopenharmony_ci int32_t CheckPidPermission(int32_t pid); 268c29fa5a6Sopenharmony_ci void PrintLog(const std::string &flag, int32_t duration, int32_t pid, int32_t tid); 269c29fa5a6Sopenharmony_ci void OnSessionDelete(SessionPtr session); 270c29fa5a6Sopenharmony_ci std::atomic<ServiceRunningState> state_ = ServiceRunningState::STATE_NOT_START; 271c29fa5a6Sopenharmony_ci int32_t mmiFd_ { -1 }; 272c29fa5a6Sopenharmony_ci std::atomic<bool> isCesStart_ { false }; 273c29fa5a6Sopenharmony_ci std::mutex mu_; 274c29fa5a6Sopenharmony_ci std::thread t_; 275c29fa5a6Sopenharmony_ci std::thread eventMonitorThread_; 276c29fa5a6Sopenharmony_ci#ifdef OHOS_BUILD_ENABLE_ANCO 277c29fa5a6Sopenharmony_ci int32_t shellAssitentPid_ { -1 }; 278c29fa5a6Sopenharmony_ci#endif // OHOS_BUILD_ENABLE_ANCO 279c29fa5a6Sopenharmony_ci#ifdef OHOS_RSS_CLIENT 280c29fa5a6Sopenharmony_ci std::atomic<uint64_t> tid_ = 0; 281c29fa5a6Sopenharmony_ci#endif // OHOS_RSS_CLIENT 282c29fa5a6Sopenharmony_ci LibinputAdapter libinputAdapter_; 283c29fa5a6Sopenharmony_ci ServerMsgHandler sMsgHandler_; 284c29fa5a6Sopenharmony_ci DelegateTasks delegateTasks_; 285c29fa5a6Sopenharmony_ci#ifdef OHOS_BUILD_ENABLE_TOUCH 286c29fa5a6Sopenharmony_ci std::shared_ptr<TouchGestureAdapter> touchGestureAdapter_ { nullptr }; 287c29fa5a6Sopenharmony_ci#endif // OHOS_BUILD_ENABLE_TOUCH 288c29fa5a6Sopenharmony_ci std::shared_ptr<DelegateInterface> delegateInterface_ { nullptr }; 289c29fa5a6Sopenharmony_ci sptr<AppDebugListener> appDebugListener_; 290c29fa5a6Sopenharmony_ci std::atomic_bool threadStatusFlag_ { false }; 291c29fa5a6Sopenharmony_ci struct ClientInfo { 292c29fa5a6Sopenharmony_ci int32_t pid { -1 }; 293c29fa5a6Sopenharmony_ci uint64_t readThreadId { -1 }; 294c29fa5a6Sopenharmony_ci }; 295c29fa5a6Sopenharmony_ci std::map<std::string, ClientInfo> clientInfos_; 296c29fa5a6Sopenharmony_ci std::mutex mutex_; 297c29fa5a6Sopenharmony_ci#if defined(OHOS_BUILD_ENABLE_MONITOR) && defined(PLAYER_FRAMEWORK_EXISTS) 298c29fa5a6Sopenharmony_ci bool hasRegisterListener_ { false }; 299c29fa5a6Sopenharmony_ci#endif // OHOS_BUILD_ENABLE_MONITOR && PLAYER_FRAMEWORK_EXISTS 300c29fa5a6Sopenharmony_ci#ifdef OHOS_BUILD_ENABLE_VKEYBOARD 301c29fa5a6Sopenharmony_ci std::atomic_bool isHPR_ { false }; 302c29fa5a6Sopenharmony_ci#endif // OHOS_BUILD_ENABLE_VKEYBOARD 303c29fa5a6Sopenharmony_ci}; 304c29fa5a6Sopenharmony_ci} // namespace MMI 305c29fa5a6Sopenharmony_ci} // namespace OHOS 306c29fa5a6Sopenharmony_ci#endif // MMI_SERVICE_H 307