• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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_method_system_ability_stub.h"
17 
18 #include <chrono>
19 #include <cinttypes>
20 #include <memory>
21 
22 #include "element_name.h"
23 #include "input_client_proxy.h"
24 #include "input_method_core_proxy.h"
25 #include "ipc_skeleton.h"
26 #include "itypes_util.h"
27 #include "xcollie/xcollie.h"
28 #include "xcollie/xcollie_define.h"
29 namespace OHOS {
30 namespace MiscServices {
31 using namespace std::chrono;
32 using namespace HiviewDFX;
33 constexpr uint32_t FATAL_TIMEOUT = 30;    // 30s
34 constexpr int64_t WARNING_TIMEOUT = 5000; // 5s
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)35 int32_t InputMethodSystemAbilityStub::OnRemoteRequest(
36     uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
37 {
38     if (code != static_cast<uint32_t>(InputMethodInterfaceCode::RELEASE_INPUT)) {
39         IMSA_HILOGI("IMSA, code = %{public}u, callingPid/Uid/timestamp: %{public}d/%{public}d/%{public}lld", code,
40             IPCSkeleton::GetCallingPid(), IPCSkeleton::GetCallingUid(),
41             std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch())
42                 .count());
43     }
44     std::u16string remoteDescriptor = data.ReadInterfaceToken();
45     if (remoteDescriptor != IInputMethodSystemAbility::GetDescriptor()) {
46         IMSA_HILOGE("%{public}s descriptor failed!", __func__);
47         return ErrorCode::ERROR_STATUS_UNKNOWN_TRANSACTION;
48     }
49     if (code >= static_cast<uint32_t>(InputMethodInterfaceCode::IMS_CMD_BEGIN) &&
50         code < static_cast<uint32_t>(InputMethodInterfaceCode::IMS_CMD_END)) {
51         // service reboot when timeout 30s
52         auto id = XCollie::GetInstance().SetTimer("IMSA_API[" + std::to_string(code) + "]", FATAL_TIMEOUT, nullptr,
53             nullptr, XCOLLIE_FLAG_DEFAULT);
54         int64_t startPoint = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
55         auto ret = (this->*HANDLERS[code])(data, reply);
56         int64_t costTime = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count() - startPoint;
57         // log warning when timeout 5s
58         if (costTime > WARNING_TIMEOUT) {
59             IMSA_HILOGW("code: %{public}d, pid: %{public}d, uid: %{public}d, cost: %{public}" PRId64 "", code,
60                 IPCSkeleton::GetCallingPid(), IPCSkeleton::GetCallingUid(), costTime);
61         }
62         XCollie::GetInstance().CancelTimer(id);
63         return ret;
64     } else {
65         IMSA_HILOGE("code error, code = %{public}u, callingPid: %{public}d, callingUid: %{public}d.", code,
66             IPCSkeleton::GetCallingPid(), IPCSkeleton::GetCallingUid());
67         return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
68     }
69 }
70 
StartInputOnRemote(MessageParcel & data,MessageParcel & reply)71 int32_t InputMethodSystemAbilityStub::StartInputOnRemote(MessageParcel &data, MessageParcel &reply)
72 {
73     InputClientInfo clientInfo;
74     sptr<IRemoteObject> client = nullptr;
75     if (!ITypesUtil::Unmarshal(data, clientInfo, client, clientInfo.channel)) {
76         IMSA_HILOGE("read clientInfo failed!");
77         return ErrorCode::ERROR_EX_PARCELABLE;
78     }
79     clientInfo.client = iface_cast<IInputClient>(client);
80     sptr<IRemoteObject> agent = nullptr;
81     int32_t ret = StartInput(clientInfo, agent);
82     return reply.WriteInt32(ret) && reply.WriteRemoteObject(agent) ? ErrorCode::NO_ERROR
83                                                                    : ErrorCode::ERROR_EX_PARCELABLE;
84 }
85 
ShowCurrentInputOnRemote(MessageParcel & data,MessageParcel & reply)86 int32_t InputMethodSystemAbilityStub::ShowCurrentInputOnRemote(MessageParcel &data, MessageParcel &reply)
87 {
88     int32_t ret = ShowCurrentInput();
89     return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
90 }
91 
HideCurrentInputOnRemote(MessageParcel & data,MessageParcel & reply)92 int32_t InputMethodSystemAbilityStub::HideCurrentInputOnRemote(MessageParcel &data, MessageParcel &reply)
93 {
94     int32_t ret = HideCurrentInput();
95     return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
96 }
97 
StopInputSessionOnRemote(MessageParcel & data,MessageParcel & reply)98 int32_t InputMethodSystemAbilityStub::StopInputSessionOnRemote(MessageParcel &data, MessageParcel &reply)
99 {
100     int32_t ret = StopInputSession();
101     return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
102 }
103 
ShowInputOnRemote(MessageParcel & data,MessageParcel & reply)104 int32_t InputMethodSystemAbilityStub::ShowInputOnRemote(MessageParcel &data, MessageParcel &reply)
105 {
106     auto clientObject = data.ReadRemoteObject();
107     if (clientObject == nullptr) {
108         IMSA_HILOGE("clientObject is nullptr!");
109         return ErrorCode::ERROR_EX_PARCELABLE;
110     }
111     int32_t ret = ShowInput(iface_cast<IInputClient>(clientObject));
112     return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
113 }
114 
HideInputOnRemote(MessageParcel & data,MessageParcel & reply)115 int32_t InputMethodSystemAbilityStub::HideInputOnRemote(MessageParcel &data, MessageParcel &reply)
116 {
117     auto clientObject = data.ReadRemoteObject();
118     if (clientObject == nullptr) {
119         IMSA_HILOGE("clientObject is nullptr!");
120         return ErrorCode::ERROR_EX_PARCELABLE;
121     }
122     int32_t ret = HideInput(iface_cast<IInputClient>(clientObject));
123     return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
124 }
125 
ReleaseInputOnRemote(MessageParcel & data,MessageParcel & reply)126 int32_t InputMethodSystemAbilityStub::ReleaseInputOnRemote(MessageParcel &data, MessageParcel &reply)
127 {
128     auto clientObject = data.ReadRemoteObject();
129     if (clientObject == nullptr) {
130         IMSA_HILOGE("clientObject is nullptr!");
131         return ErrorCode::ERROR_EX_PARCELABLE;
132     }
133     int32_t ret = ReleaseInput(iface_cast<IInputClient>(clientObject));
134     return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
135 }
136 
RequestShowInputOnRemote(MessageParcel & data,MessageParcel & reply)137 int32_t InputMethodSystemAbilityStub::RequestShowInputOnRemote(MessageParcel &data, MessageParcel &reply)
138 {
139     return reply.WriteInt32(RequestShowInput()) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
140 }
141 
RequestHideInputOnRemote(MessageParcel & data,MessageParcel & reply)142 int32_t InputMethodSystemAbilityStub::RequestHideInputOnRemote(MessageParcel &data, MessageParcel &reply)
143 {
144     return reply.WriteInt32(RequestHideInput()) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
145 }
146 
DisplayOptionalInputMethodOnRemote(MessageParcel & data,MessageParcel & reply)147 int32_t InputMethodSystemAbilityStub::DisplayOptionalInputMethodOnRemote(MessageParcel &data, MessageParcel &reply)
148 {
149     int32_t ret = DisplayOptionalInputMethod();
150     return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
151 }
152 
SetCoreAndAgentOnRemote(MessageParcel & data,MessageParcel & reply)153 int32_t InputMethodSystemAbilityStub::SetCoreAndAgentOnRemote(MessageParcel &data, MessageParcel &reply)
154 {
155     auto coreObject = data.ReadRemoteObject();
156     if (coreObject == nullptr) {
157         IMSA_HILOGE("coreObject is nullptr!");
158         return ErrorCode::ERROR_EX_PARCELABLE;
159     }
160     auto agentObject = data.ReadRemoteObject();
161     if (agentObject == nullptr) {
162         IMSA_HILOGE("agentObject is nullptr!");
163         return ErrorCode::ERROR_EX_PARCELABLE;
164     }
165     int32_t ret = SetCoreAndAgent(iface_cast<IInputMethodCore>(coreObject), agentObject);
166     return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
167 }
168 
GetDefaultInputMethodOnRemote(MessageParcel & data,MessageParcel & reply)169 int32_t InputMethodSystemAbilityStub::GetDefaultInputMethodOnRemote(MessageParcel &data, MessageParcel &reply)
170 {
171     std::shared_ptr<Property> prop = std::make_shared<Property>();
172     bool isBrief = false;
173     auto ret = data.ReadBool(isBrief);
174     if (!ret) {
175         IMSA_HILOGE("read isBrief failed!");
176     }
177     ret = GetDefaultInputMethod(prop, isBrief);
178     if (prop == nullptr) {
179         return ErrorCode::ERROR_EX_PARCELABLE;
180     }
181     return ITypesUtil::Marshal(reply, ret, *prop) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
182 }
183 
GetInputMethodConfigOnRemote(MessageParcel & data,MessageParcel & reply)184 int32_t InputMethodSystemAbilityStub::GetInputMethodConfigOnRemote(MessageParcel &data, MessageParcel &reply)
185 {
186     OHOS::AppExecFwk::ElementName inputMethodConfig;
187     auto ret = GetInputMethodConfig(inputMethodConfig);
188     IMSA_HILOGD("GetInputMethodConfigOnRemote inputMethodConfig is %{public}s, %{public}s",
189         inputMethodConfig.GetBundleName().c_str(), inputMethodConfig.GetAbilityName().c_str());
190     return ITypesUtil::Marshal(reply, ret, inputMethodConfig) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
191 }
192 
GetSecurityModeOnRemote(MessageParcel & data,MessageParcel & reply)193 int32_t InputMethodSystemAbilityStub::GetSecurityModeOnRemote(MessageParcel &data, MessageParcel &reply)
194 {
195     IMSA_HILOGD("GetSecurityModeOnRemote start.");
196     int32_t security;
197     auto ret = GetSecurityMode(security);
198     IMSA_HILOGD("GetSecurityModeOnRemote, security: %{public}d", security);
199     return ITypesUtil::Marshal(reply, ret, security) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
200 }
201 
GetCurrentInputMethodOnRemote(MessageParcel & data,MessageParcel & reply)202 int32_t InputMethodSystemAbilityStub::GetCurrentInputMethodOnRemote(MessageParcel &data, MessageParcel &reply)
203 {
204     auto property = GetCurrentInputMethod();
205     if (property == nullptr) {
206         IMSA_HILOGE("property is nullptr!");
207         return reply.WriteInt32(ErrorCode::ERROR_EX_NULL_POINTER) ? ErrorCode::NO_ERROR
208                                                                   : ErrorCode::ERROR_EX_PARCELABLE;
209     }
210     if (!ITypesUtil::Marshal(reply, ErrorCode::NO_ERROR, *property)) {
211         IMSA_HILOGE("marshal failed!");
212         return ErrorCode::ERROR_EX_PARCELABLE;
213     }
214     return ErrorCode::NO_ERROR;
215 }
216 
GetCurrentInputMethodSubtypeOnRemote(MessageParcel & data,MessageParcel & reply)217 int32_t InputMethodSystemAbilityStub::GetCurrentInputMethodSubtypeOnRemote(MessageParcel &data, MessageParcel &reply)
218 {
219     auto property = GetCurrentInputMethodSubtype();
220     if (property == nullptr) {
221         IMSA_HILOGE("property is nullptr!");
222         return reply.WriteInt32(ErrorCode::ERROR_EX_NULL_POINTER) ? ErrorCode::NO_ERROR
223                                                                   : ErrorCode::ERROR_EX_PARCELABLE;
224     }
225     if (!ITypesUtil::Marshal(reply, ErrorCode::NO_ERROR, *property)) {
226         IMSA_HILOGE("marshal failed");
227         return ErrorCode::ERROR_EX_PARCELABLE;
228     }
229     return ErrorCode::NO_ERROR;
230 }
231 
ListInputMethodOnRemote(MessageParcel & data,MessageParcel & reply)232 int32_t InputMethodSystemAbilityStub::ListInputMethodOnRemote(MessageParcel &data, MessageParcel &reply)
233 {
234     uint32_t status;
235     if (!ITypesUtil::Unmarshal(data, status)) {
236         IMSA_HILOGE("read status failed!");
237         return ErrorCode::ERROR_EX_PARCELABLE;
238     }
239     std::vector<Property> properties = {};
240     auto ret = ListInputMethod(InputMethodStatus(status), properties);
241     if (!ITypesUtil::Marshal(reply, ret, properties)) {
242         IMSA_HILOGE("marshal failed");
243         return ErrorCode::ERROR_EX_PARCELABLE;
244     }
245     return ErrorCode::NO_ERROR;
246 }
247 
ListInputMethodSubtypeOnRemote(MessageParcel & data,MessageParcel & reply)248 int32_t InputMethodSystemAbilityStub::ListInputMethodSubtypeOnRemote(MessageParcel &data, MessageParcel &reply)
249 {
250     std::string bundleName;
251     if (!ITypesUtil::Unmarshal(data, bundleName)) {
252         IMSA_HILOGE("read bundleName failed!");
253         return ErrorCode::ERROR_EX_PARCELABLE;
254     }
255     std::vector<SubProperty> subProps = {};
256     auto ret = ListInputMethodSubtype(bundleName, subProps);
257     if (!ITypesUtil::Marshal(reply, ret, subProps)) {
258         IMSA_HILOGE("marshal failed!");
259         return ErrorCode::ERROR_EX_PARCELABLE;
260     }
261     return ErrorCode::NO_ERROR;
262 }
263 
ListCurrentInputMethodSubtypeOnRemote(MessageParcel & data,MessageParcel & reply)264 int32_t InputMethodSystemAbilityStub::ListCurrentInputMethodSubtypeOnRemote(MessageParcel &data, MessageParcel &reply)
265 {
266     std::vector<SubProperty> subProps = {};
267     auto ret = ListCurrentInputMethodSubtype(subProps);
268     if (!ITypesUtil::Marshal(reply, ret, subProps)) {
269         IMSA_HILOGE("marshal failed!");
270         return ErrorCode::ERROR_EX_PARCELABLE;
271     }
272     return ErrorCode::NO_ERROR;
273 }
274 
SwitchInputMethodOnRemote(MessageParcel & data,MessageParcel & reply)275 int32_t InputMethodSystemAbilityStub::SwitchInputMethodOnRemote(MessageParcel &data, MessageParcel &reply)
276 {
277     std::string name;
278     std::string subName;
279     SwitchTrigger trigger;
280     if (!ITypesUtil::Unmarshal(data, name, subName, trigger)) {
281         IMSA_HILOGE("unmarshal failed!");
282         return ErrorCode::ERROR_EX_PARCELABLE;
283     }
284     return reply.WriteInt32(SwitchInputMethod(name, subName, trigger)) ? ErrorCode::NO_ERROR
285                                                                        : ErrorCode::ERROR_EX_PARCELABLE;
286 }
287 
PanelStatusChangeOnRemote(MessageParcel & data,MessageParcel & reply)288 int32_t InputMethodSystemAbilityStub::PanelStatusChangeOnRemote(MessageParcel &data, MessageParcel &reply)
289 {
290     uint32_t status = 0;
291     ImeWindowInfo info;
292     if (!ITypesUtil::Unmarshal(data, status, info)) {
293         IMSA_HILOGE("unmarshal failed!");
294         return ErrorCode::ERROR_EX_PARCELABLE;
295     }
296     int32_t ret = PanelStatusChange(static_cast<InputWindowStatus>(status), info);
297     return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
298 }
299 
UpdateListenEventFlagOnRemote(MessageParcel & data,MessageParcel & reply)300 int32_t InputMethodSystemAbilityStub::UpdateListenEventFlagOnRemote(MessageParcel &data, MessageParcel &reply)
301 {
302     InputClientInfo clientInfo;
303     sptr<IRemoteObject> client = nullptr;
304     uint32_t eventFlag = 0;
305     if (!ITypesUtil::Unmarshal(data, clientInfo, client, clientInfo.channel, eventFlag)) {
306         IMSA_HILOGE("unmarshal failed!");
307         return ErrorCode::ERROR_EX_PARCELABLE;
308     }
309     clientInfo.client = iface_cast<IInputClient>(client);
310     int32_t ret = UpdateListenEventFlag(clientInfo, eventFlag);
311     return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
312 }
313 
ShowCurrentInputOnRemoteDeprecated(MessageParcel & data,MessageParcel & reply)314 int32_t InputMethodSystemAbilityStub::ShowCurrentInputOnRemoteDeprecated(MessageParcel &data, MessageParcel &reply)
315 {
316     int32_t ret = ShowCurrentInputDeprecated();
317     return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
318 }
319 
HideCurrentInputOnRemoteDeprecated(MessageParcel & data,MessageParcel & reply)320 int32_t InputMethodSystemAbilityStub::HideCurrentInputOnRemoteDeprecated(MessageParcel &data, MessageParcel &reply)
321 {
322     int32_t ret = HideCurrentInputDeprecated();
323     return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
324 }
325 
IsCurrentImeOnRemote(MessageParcel & data,MessageParcel & reply)326 int32_t InputMethodSystemAbilityStub::IsCurrentImeOnRemote(MessageParcel &data, MessageParcel &reply)
327 {
328     return ITypesUtil::Marshal(reply, ErrorCode::NO_ERROR, IsCurrentIme()) ? ErrorCode::NO_ERROR
329                                                                            : ErrorCode::ERROR_EX_PARCELABLE;
330 }
331 
UnRegisteredProxyImeOnRemote(MessageParcel & data,MessageParcel & reply)332 int32_t InputMethodSystemAbilityStub::UnRegisteredProxyImeOnRemote(MessageParcel &data, MessageParcel &reply)
333 {
334     int32_t type = -1;
335     sptr<IRemoteObject> coreObject = nullptr;
336     if (!ITypesUtil::Unmarshal(data, type, coreObject) || coreObject == nullptr) {
337         IMSA_HILOGE("coreObject is nullptr!");
338         return ErrorCode::ERROR_EX_PARCELABLE;
339     }
340     int32_t ret = UnRegisteredProxyIme(static_cast<UnRegisteredType>(type), iface_cast<IInputMethodCore>(coreObject));
341     return reply.WriteInt32(ret) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
342 }
343 
IsInputTypeSupportedOnRemote(MessageParcel & data,MessageParcel & reply)344 int32_t InputMethodSystemAbilityStub::IsInputTypeSupportedOnRemote(MessageParcel &data, MessageParcel &reply)
345 {
346     InputType type;
347     if (!ITypesUtil::Unmarshal(data, type)) {
348         IMSA_HILOGE("unmarshal failed!");
349         return ErrorCode::ERROR_EX_PARCELABLE;
350     }
351     return ITypesUtil::Marshal(reply, ErrorCode::NO_ERROR, IsInputTypeSupported(type)) ? ErrorCode::NO_ERROR
352                                                                                        : ErrorCode::ERROR_EX_PARCELABLE;
353 }
354 
StartInputTypeOnRemote(MessageParcel & data,MessageParcel & reply)355 int32_t InputMethodSystemAbilityStub::StartInputTypeOnRemote(MessageParcel &data, MessageParcel &reply)
356 {
357     InputType type;
358     if (!ITypesUtil::Unmarshal(data, type)) {
359         IMSA_HILOGE("unmarshal failed!");
360         return ErrorCode::ERROR_EX_PARCELABLE;
361     }
362     return ITypesUtil::Marshal(reply, StartInputType(type)) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
363 }
364 
ExitCurrentInputTypeOnRemote(MessageParcel & data,MessageParcel & reply)365 int32_t InputMethodSystemAbilityStub::ExitCurrentInputTypeOnRemote(MessageParcel &data, MessageParcel &reply)
366 {
367     return ITypesUtil::Marshal(reply, ExitCurrentInputType()) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
368 }
369 
IsPanelShownOnRemote(MessageParcel & data,MessageParcel & reply)370 int32_t InputMethodSystemAbilityStub::IsPanelShownOnRemote(MessageParcel &data, MessageParcel &reply)
371 {
372     PanelInfo info;
373     if (!ITypesUtil::Unmarshal(data, info)) {
374         IMSA_HILOGE("unmarshal failed!");
375         return ErrorCode::ERROR_EX_PARCELABLE;
376     }
377     bool isShown = false;
378     int32_t ret = IsPanelShown(info, isShown);
379     return ITypesUtil::Marshal(reply, ret, isShown) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
380 }
381 
IsDefaultImeOnRemote(MessageParcel & data,MessageParcel & reply)382 int32_t InputMethodSystemAbilityStub::IsDefaultImeOnRemote(MessageParcel &data, MessageParcel &reply)
383 {
384     return ITypesUtil::Marshal(reply, IsDefaultIme()) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
385 }
386 
ConnectSystemCmdOnRemote(MessageParcel & data,MessageParcel & reply)387 int32_t InputMethodSystemAbilityStub::ConnectSystemCmdOnRemote(MessageParcel &data, MessageParcel &reply)
388 {
389     auto systemCmdStub = data.ReadRemoteObject();
390     if (systemCmdStub == nullptr) {
391         IMSA_HILOGE("systemCmdStub is nullptr!");
392         return ErrorCode::ERROR_EX_PARCELABLE;
393     }
394     sptr<IRemoteObject> agent = nullptr;
395     int32_t ret = ConnectSystemCmd(systemCmdStub, agent);
396     return reply.WriteInt32(ret) && reply.WriteRemoteObject(agent) ? ErrorCode::NO_ERROR
397                                                                    : ErrorCode::ERROR_EX_PARCELABLE;
398 }
399 
IsCurrentImeByPidOnRemote(MessageParcel & data,MessageParcel & reply)400 int32_t InputMethodSystemAbilityStub::IsCurrentImeByPidOnRemote(MessageParcel &data, MessageParcel &reply)
401 {
402     int32_t pid = -1;
403     if (!ITypesUtil::Unmarshal(data, pid)) {
404         IMSA_HILOGE("unmarshal failed!");
405         return ErrorCode::ERROR_EX_PARCELABLE;
406     }
407     return ITypesUtil::Marshal(reply, ErrorCode::NO_ERROR, IsCurrentImeByPid(pid)) ? ErrorCode::NO_ERROR
408                                                                            : ErrorCode::ERROR_EX_PARCELABLE;
409 }
410 
InitConnectOnRemote(MessageParcel & data,MessageParcel & reply)411 int32_t InputMethodSystemAbilityStub::InitConnectOnRemote(MessageParcel &data, MessageParcel &reply)
412 {
413     return reply.WriteInt32(InitConnect()) ? ErrorCode::NO_ERROR : ErrorCode::ERROR_EX_PARCELABLE;
414 }
415 } // namespace MiscServices
416 } // namespace OHOS