1 /*
2 * Copyright (c) 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 #include "input_client_service_impl.h"
17
18 #include "input_client_stub.h"
19 #include "ime_event_monitor_manager_impl.h"
20 #include "input_method_controller.h"
21
22 namespace OHOS {
23 namespace MiscServices {
24
InputClientServiceImpl()25 InputClientServiceImpl::InputClientServiceImpl() {}
26
~InputClientServiceImpl()27 InputClientServiceImpl::~InputClientServiceImpl() {}
28
OnInputReady(const sptr<IRemoteObject> & agent,const BindImeInfo & imeInfo)29 ErrCode InputClientServiceImpl::OnInputReady(const sptr<IRemoteObject> &agent, const BindImeInfo &imeInfo)
30 {
31 IMSA_HILOGI("ClientStub start.");
32 auto instance = InputMethodController::GetInstance();
33 if (instance != nullptr) {
34 instance->OnInputReady(agent, imeInfo);
35 } else {
36 IMSA_HILOGW("failed to get InputMethodController instance!");
37 }
38 return ERR_OK;
39 }
40
OnInputStop(bool isStopInactiveClient,const sptr<IRemoteObject> & object)41 ErrCode InputClientServiceImpl::OnInputStop(bool isStopInactiveClient, const sptr<IRemoteObject> &object)
42 {
43 auto instance = InputMethodController::GetInstance();
44 if (instance != nullptr) {
45 instance->OnInputStop(isStopInactiveClient, object);
46 } else {
47 IMSA_HILOGW("failed to get InputMethodController instance!");
48 }
49 return ERR_OK;
50 }
51
OnInputStopAsync(bool isStopInactiveClient)52 ErrCode InputClientServiceImpl::OnInputStopAsync(bool isStopInactiveClient)
53 {
54 auto instance = InputMethodController::GetInstance();
55 if (instance != nullptr) {
56 instance->OnInputStop(isStopInactiveClient, nullptr);
57 } else {
58 IMSA_HILOGW("failed to get InputMethodController instance!");
59 }
60 return ERR_OK;
61 }
62
OnImeMirrorStop(const sptr<IRemoteObject> & object)63 ErrCode InputClientServiceImpl::OnImeMirrorStop(const sptr<IRemoteObject> &object)
64 {
65 auto instance = InputMethodController::GetInstance();
66 if (instance != nullptr) {
67 instance->OnImeMirrorStop(object);
68 } else {
69 IMSA_HILOGW("[ImeMirrorTag]failed to get InputMethodController instance!");
70 }
71 return ERR_OK;
72 }
73
OnSwitchInput(const Property & property,const SubProperty & subProperty)74 ErrCode InputClientServiceImpl::OnSwitchInput(const Property &property, const SubProperty &subProperty)
75 {
76 return ImeEventMonitorManagerImpl::GetInstance().OnImeChange(property, subProperty);
77 }
78
OnPanelStatusChange(const uint32_t status,const ImeWindowInfo & info)79 ErrCode InputClientServiceImpl::OnPanelStatusChange(const uint32_t status, const ImeWindowInfo& info)
80 {
81 return ImeEventMonitorManagerImpl::GetInstance().OnPanelStatusChange(static_cast<InputWindowStatus>(status), info);
82 }
83
NotifyInputStart(uint32_t callingWndId,int32_t requestKeyboardReason)84 ErrCode InputClientServiceImpl::NotifyInputStart(uint32_t callingWndId, int32_t requestKeyboardReason)
85 {
86 return ImeEventMonitorManagerImpl::GetInstance().OnInputStart(callingWndId, requestKeyboardReason);
87 }
88
NotifyInputStop()89 ErrCode InputClientServiceImpl::NotifyInputStop()
90 {
91 return ImeEventMonitorManagerImpl::GetInstance().OnInputStop();
92 }
93
DeactivateClient()94 ErrCode InputClientServiceImpl::DeactivateClient()
95 {
96 auto instance = InputMethodController::GetInstance();
97 if (instance != nullptr) {
98 instance->DeactivateClient();
99 } else {
100 IMSA_HILOGW("failed to get InputMethodController instance!");
101 }
102 return ERR_OK;
103 }
104 } // namespace MiscServices
105 } // namespace OHOS