1 /*
2 * Copyright (c) 2021-2024 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 #include "input_monitor_manager.h"
17
18 #include "multimodal_input_connect_manager.h"
19 #include "util.h"
20
21 #undef MMI_LOG_TAG
22 #define MMI_LOG_TAG "InputMonitorManager"
23
24 namespace OHOS {
25 namespace MMI {
InputMonitorManager()26 InputMonitorManager::InputMonitorManager() {}
~InputMonitorManager()27 InputMonitorManager::~InputMonitorManager() {}
28
AddMonitor(std::shared_ptr<IInputEventConsumer> monitor,HandleEventType eventType)29 int32_t InputMonitorManager::AddMonitor(std::shared_ptr<IInputEventConsumer> monitor, HandleEventType eventType)
30 {
31 CHKPR(monitor, INVALID_HANDLER_ID);
32 return AddHandler(InputHandlerType::MONITOR, monitor, eventType);
33 }
34
RemoveMonitor(int32_t monitorId)35 int32_t InputMonitorManager::RemoveMonitor(int32_t monitorId)
36 {
37 return RemoveHandler(monitorId, InputHandlerType::MONITOR);
38 }
39
MarkConsumed(int32_t monitorId,int32_t eventId)40 void InputMonitorManager::MarkConsumed(int32_t monitorId, int32_t eventId)
41 {
42 MMI_HILOGD("Mark consumed state, monitor:%{public}d,event:%{public}d", monitorId, eventId);
43 if (!HasHandler(monitorId)) {
44 MMI_HILOGW("Failed to find the monitorId");
45 return;
46 }
47 int32_t ret = MULTIMODAL_INPUT_CONNECT_MGR->MarkEventConsumed(eventId);
48 if (ret != RET_OK) {
49 MMI_HILOGE("Send to server failed, ret:%{public}d", ret);
50 }
51 }
52 } // namespace MMI
53 } // namespace OHOS
54