• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "input_method_core_service_impl.h"
16 
17 #include <cstdint>
18 #include <string_ex.h>
19 
20 #include "iinput_data_channel.h"
21 #include "input_control_channel_proxy.h"
22 #include "input_method_ability.h"
23 #include "ipc_skeleton.h"
24 #include "itypes_util.h"
25 #include "message_parcel.h"
26 #include "system_cmd_channel_proxy.h"
27 #include "task_manager.h"
28 #include "tasks/task_imsa.h"
29 #include "input_method_tools.h"
30 
31 namespace OHOS {
32 namespace MiscServices {
33 using namespace MessageID;
InputMethodCoreServiceImpl()34 InputMethodCoreServiceImpl::InputMethodCoreServiceImpl() {}
35 
~InputMethodCoreServiceImpl()36 InputMethodCoreServiceImpl::~InputMethodCoreServiceImpl() {}
37 
InitInputControlChannel(const sptr<IInputControlChannel> & inputControlChannel)38 ErrCode InputMethodCoreServiceImpl::InitInputControlChannel(const sptr<IInputControlChannel> &inputControlChannel)
39 {
40     auto task = std::make_shared<TaskImsaInitInputCtrlChannel>(inputControlChannel->AsObject());
41     TaskManager::GetInstance().PostTask(task);
42     return ERR_OK;
43 }
44 
ShowKeyboard(int32_t requestKeyboardReason)45 ErrCode InputMethodCoreServiceImpl::ShowKeyboard(int32_t requestKeyboardReason)
46 {
47     auto task = std::make_shared<TaskImsaShowKeyboard>(requestKeyboardReason);
48     TaskManager::GetInstance().PostTask(task);
49     return ERR_OK;
50 }
51 
HideKeyboard()52 ErrCode InputMethodCoreServiceImpl::HideKeyboard()
53 {
54     auto task = std::make_shared<TaskImsaHideKeyboard>();
55     TaskManager::GetInstance().PostTask(task);
56     return ERR_OK;
57 }
58 
StopInputService(bool isTerminateIme)59 ErrCode InputMethodCoreServiceImpl::StopInputService(bool isTerminateIme)
60 {
61     auto task = std::make_shared<TaskImsaStopInputService>(isTerminateIme);
62     TaskManager::GetInstance().PostTask(task);
63     return ERR_OK;
64 }
65 
OnConnectSystemCmd(const sptr<IRemoteObject> & channel,sptr<IRemoteObject> & agent)66 ErrCode InputMethodCoreServiceImpl::OnConnectSystemCmd(
67     const sptr<IRemoteObject> &channel, sptr<IRemoteObject> &agent)
68 {
69     return InputMethodAbility::GetInstance().OnConnectSystemCmd(channel, agent);
70 }
71 
StartInput(const InputClientInfoInner & clientInfoInner,bool isBindFromClient)72 ErrCode InputMethodCoreServiceImpl::StartInput(const InputClientInfoInner &clientInfoInner, bool isBindFromClient)
73 {
74     InputClientInfo clientInfo =
75         InputMethodTools::GetInstance().InnerToInputClientInfo(clientInfoInner);
76     auto task = std::make_shared<TaskImsaStartInput>(clientInfo, isBindFromClient);
77     TaskManager::GetInstance().PostTask(task);
78     return ERR_OK;
79 }
80 
SetSubtype(const SubProperty & property)81 ErrCode InputMethodCoreServiceImpl::SetSubtype(const SubProperty &property)
82 {
83     auto task = std::make_shared<TaskImsaOnSetSubProperty>(property);
84     TaskManager::GetInstance().PostTask(task);
85     return ERR_OK;
86 }
87 
OnSecurityChange(int32_t security)88 ErrCode InputMethodCoreServiceImpl::OnSecurityChange(int32_t security)
89 {
90     return InputMethodAbility::GetInstance().OnSecurityChange(security);
91 }
92 
OnSetInputType(int32_t inputType)93 ErrCode InputMethodCoreServiceImpl::OnSetInputType(int32_t inputType)
94 {
95     InputMethodAbility::GetInstance().OnSetInputType(static_cast<InputType>(inputType));
96     return ERR_OK;
97 }
98 
StopInput(const sptr<IRemoteObject> & channel,uint32_t sessionId)99 ErrCode InputMethodCoreServiceImpl::StopInput(const sptr<IRemoteObject> &channel, uint32_t sessionId)
100 {
101     auto task = std::make_shared<TaskImsaStopInput>(channel, sessionId);
102     TaskManager::GetInstance().PostTask(task);
103     return ERR_OK;
104 }
105 
IsEnable(bool & resultValue)106 ErrCode InputMethodCoreServiceImpl::IsEnable(bool &resultValue)
107 {
108     resultValue = InputMethodAbility::GetInstance().IsEnable();
109     return ERR_OK;
110 }
111 
IsPanelShown(const PanelInfo & panelInfo,bool & isShown)112 ErrCode InputMethodCoreServiceImpl::IsPanelShown(const PanelInfo &panelInfo, bool &isShown)
113 {
114     return InputMethodAbility::GetInstance().IsPanelShown(panelInfo, isShown);
115 }
116 
OnClientInactive(const sptr<IRemoteObject> & channel)117 ErrCode InputMethodCoreServiceImpl::OnClientInactive(const sptr<IRemoteObject> &channel)
118 {
119     auto task = std::make_shared<TaskImsaOnClientInactive>(channel);
120     TaskManager::GetInstance().PostTask(task);
121     return ERR_OK;
122 }
123 
OnCallingDisplayIdChanged(uint64_t displayId)124 ErrCode InputMethodCoreServiceImpl::OnCallingDisplayIdChanged(uint64_t displayId)
125 {
126     return InputMethodAbility::GetInstance().OnCallingDisplayIdChanged(displayId);
127 }
128 
OnSendPrivateData(const Value & Value)129 ErrCode InputMethodCoreServiceImpl::OnSendPrivateData(const Value &Value)
130 {
131     std::unordered_map<std::string, PrivateDataValue> privateCommand;
132     privateCommand = Value.valueMap;
133     return InputMethodAbility::GetInstance().OnSendPrivateData(privateCommand);
134 }
NotifyPreemption()135 ErrCode InputMethodCoreServiceImpl::NotifyPreemption()
136 {
137     return InputMethodAbility::GetInstance().OnNotifyPreemption();
138 }
139 } // namespace MiscServices
140 } // namespace OHOS