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 <array>
17 #include <hdf_base.h>
18 #include <hdf_log.h>
19 #include <hdf_sbuf_ipc.h>
20 #include "input_server_stub.h"
21 #include "securec.h"
22
23 #define HDF_LOG_TAG InputServerStub
24
25 namespace OHOS {
26 namespace Input {
InputServerStub()27 InputServerStub::InputServerStub() {}
28
InputServerStubScanInputDevice(MessageParcel & data,MessageParcel & reply,MessageOption & option) const29 int32_t InputServerStub::InputServerStubScanInputDevice(MessageParcel &data,
30 MessageParcel &reply,
31 MessageOption &option) const
32 {
33 if (data.ReadInterfaceToken() != InputServerStub::GetDescriptor()) {
34 return HDF_ERR_INVALID_PARAM;
35 }
36 uint32_t arrLen = data.ReadUint32();
37 if (arrLen > 32) { // 32:max devices num
38 HDF_LOGE("InputServerStub %{public}s: ScanInputDevice failed line %{public}d", __func__, __LINE__);
39 return HDF_FAILURE;
40 }
41 DevDesc* staArr = new DevDesc[arrLen];
42 memset_s(staArr, sizeof(DevDesc) * arrLen, 0, sizeof(DevDesc) * arrLen);
43 int32_t ret = mService_->ScanInputDevice(staArr, arrLen);
44 if (ret != INPUT_SUCCESS) {
45 HDF_LOGE("InputServerStub %{public}s: ScanInputDevice failed line %{public}d", __func__, __LINE__);
46 return HDF_FAILURE;
47 }
48 if (!reply.WriteUint32(sizeof(DevDesc) * arrLen)) {
49 HDF_LOGE("InputServerStub %{public}s: ScanInputDevice failed line %{public}d", __func__, __LINE__);
50 return HDF_FAILURE;
51 }
52 if (!reply.WriteBuffer((void*)staArr, sizeof(DevDesc) * arrLen)) {
53 HDF_LOGE("InputServerStub %{public}s: ScanInputDevice failed line %{public}d", __func__, __LINE__);
54 return HDF_FAILURE;
55 }
56 return HDF_SUCCESS;
57 }
58
InputServerStubOpenInputDevice(MessageParcel & data,MessageParcel & reply,MessageOption & option) const59 int32_t InputServerStub::InputServerStubOpenInputDevice(MessageParcel &data,
60 MessageParcel &reply,
61 MessageOption &option) const
62 {
63 if (data.ReadInterfaceToken() != InputServerStub::GetDescriptor()) {
64 return HDF_ERR_INVALID_PARAM;
65 }
66 HDF_LOGE("InputHostStub:: %{public}s:called", __func__);
67 int32_t index = data.ReadUint32();
68 int32_t ret = mService_->OpenInputDevice(index);
69 if (ret != INPUT_SUCCESS) {
70 HDF_LOGE("InputServerStub %{public}s: OpenInputDevice failed line %{public}d", __func__, __LINE__);
71 return HDF_FAILURE;
72 }
73 if (!reply.WriteInt32(ret)) {
74 HDF_LOGE("InputServerStub %{public}s: OpenInputDevice failed", __func__);
75 return HDF_FAILURE;
76 }
77 return HDF_SUCCESS;
78 }
79
InputServerStubCloseInputDevice(MessageParcel & data,MessageParcel & reply,MessageOption & option) const80 int32_t InputServerStub::InputServerStubCloseInputDevice(MessageParcel &data,
81 MessageParcel &reply,
82 MessageOption &option) const
83 {
84 if (data.ReadInterfaceToken() != InputServerStub::GetDescriptor()) {
85 return HDF_ERR_INVALID_PARAM;
86 }
87 HDF_LOGE("InputServerStub:: %{public}s:called", __func__);
88 int32_t index = data.ReadUint32();
89 int32_t ret = mService_->CloseInputDevice(index);
90 if (ret != INPUT_SUCCESS) {
91 HDF_LOGE("InputServerStub %{public}s: CloseInputDevice failed line %{public}d", __func__, __LINE__);
92 return HDF_FAILURE;
93 }
94 if (!reply.WriteInt32(ret)) {
95 HDF_LOGE("InputServerStub %{public}s: CloseInputDevice failed", __func__);
96 return HDF_FAILURE;
97 }
98 return HDF_SUCCESS;
99 }
100
InputServerStubGetInputDevice(MessageParcel & data,MessageParcel & reply,MessageOption & option) const101 int32_t InputServerStub::InputServerStubGetInputDevice(MessageParcel &data,
102 MessageParcel &reply,
103 MessageOption &option) const
104 {
105 if (data.ReadInterfaceToken() != InputServerStub::GetDescriptor()) {
106 return HDF_ERR_INVALID_PARAM;
107 }
108 int32_t index = data.ReadUint32();
109 HDF_LOGE("InputServerStub:: %{public}s:called line%{public}d index:%{public}d", __func__, __LINE__, index);
110 DeviceInfo* devInfo = (DeviceInfo*)new DeviceInfo();
111 if (devInfo == nullptr) {
112 HDF_LOGE("InputServerStub:: %{public}s:called failed line%{public}d", __func__, __LINE__);
113 return HDF_FAILURE;
114 }
115 int32_t ret = mService_->GetInputDevice(index, &devInfo);
116 if (ret != INPUT_SUCCESS) {
117 HDF_LOGE("InputServerStub:: %{public}s:called failed line%{public}d", __func__, __LINE__);
118 return HDF_FAILURE;
119 }
120 if (!reply.WriteUint32(sizeof(DeviceInfo))) {
121 HDF_LOGE("InputServerStub %{public}s: GetInputDevice failed line %{public}d", __func__, __LINE__);
122 return HDF_FAILURE;
123 }
124 if (!reply.WriteBuffer((void*)devInfo, sizeof(DeviceInfo))) {
125 HDF_LOGE("InputServerStub %{public}s: GetInputDevice failed line %{public}d", __func__, __LINE__);
126 return HDF_FAILURE;
127 }
128 HDF_LOGE("InputServerStub:: %{public}s:called line%{public}d", __func__, __LINE__);
129 return HDF_SUCCESS;
130 }
131
InputServerStubGetInputDeviceList(MessageParcel & data,MessageParcel & reply,MessageOption & option) const132 int32_t InputServerStub::InputServerStubGetInputDeviceList(MessageParcel &data,
133 MessageParcel &reply,
134 MessageOption &option) const
135 {
136 if (data.ReadInterfaceToken() != InputServerStub::GetDescriptor()) {
137 return HDF_ERR_INVALID_PARAM;
138 }
139 HDF_LOGE("InputServerStub:: %{public}s:called line%{public}d", __func__, __LINE__);
140 uint32_t devNum = MAX_INPUT_DEV_NUM;
141 uint32_t size = data.ReadUint32();
142 DeviceInfo* devInfo = new DeviceInfo[devNum];
143 if (devInfo == nullptr) {
144 HDF_LOGE("InputServerStub:: %{public}s:called failed line%{public}d", __func__, __LINE__);
145 return HDF_FAILURE;
146 }
147 int32_t ret = mService_->GetInputDeviceList(&devNum, &devInfo, size);
148 if (ret != INPUT_SUCCESS) {
149 HDF_LOGE("InputServerStub:: %{public}s:called failed line%{public}d", __func__, __LINE__);
150 return HDF_FAILURE;
151 }
152 HDF_LOGE("InputServerStub:: %{public}s:called line%{public}d devNum:%{public}d", __func__, __LINE__, devNum);
153 if (!reply.WriteUint32(devNum)) {
154 HDF_LOGE("InputServerStub %{public}s: ScanInputDevice failed line %{public}d", __func__, __LINE__);
155 return HDF_FAILURE;
156 }
157 if (!reply.WriteUint32(sizeof(DeviceInfo) * devNum)) {
158 HDF_LOGE("InputServerStub %{public}s: ScanInputDevice failed line %{public}d", __func__, __LINE__);
159 return HDF_FAILURE;
160 }
161 if (!reply.WriteBuffer((void*)devInfo, sizeof(DeviceInfo) * devNum)) {
162 HDF_LOGE("InputServerStub %{public}s: ScanInputDevice failed line %{public}d", __func__, __LINE__);
163 return HDF_FAILURE;
164 }
165 HDF_LOGE("InputServerStub:: %{public}s:called line%{public}d", __func__, __LINE__);
166 return HDF_SUCCESS;
167 }
168
InputServerStubSetPowerStatus(MessageParcel & data,MessageParcel & reply,MessageOption & option) const169 int32_t InputServerStub::InputServerStubSetPowerStatus(MessageParcel &data,
170 MessageParcel &reply,
171 MessageOption &option) const
172 {
173 if (data.ReadInterfaceToken() != InputServerStub::GetDescriptor()) {
174 return HDF_ERR_INVALID_PARAM;
175 }
176 HDF_LOGE("InputServerStub::%{public}s start", __func__);
177 int32_t index = data.ReadUint32();
178 uint32_t status = data.ReadUint32();
179 int32_t ret = mService_->SetPowerStatus(index, status);
180 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
181 HDF_LOGE("InputServerStub %{public}s: SetPowerStatus failed line:%{public}d", __func__, __LINE__);
182 return HDF_FAILURE;
183 }
184 HDF_LOGE("InputServerStub::%{public}s end", __func__);
185 return HDF_SUCCESS;
186 }
187
InputServerStubGetPowerStatus(MessageParcel & data,MessageParcel & reply,MessageOption & option) const188 int32_t InputServerStub::InputServerStubGetPowerStatus(MessageParcel &data,
189 MessageParcel &reply,
190 MessageOption &option) const
191 {
192 if (data.ReadInterfaceToken() != InputServerStub::GetDescriptor()) {
193 return HDF_ERR_INVALID_PARAM;
194 }
195 HDF_LOGE("InputServerStub::%{public}s start", __func__);
196 int32_t index = data.ReadInt32();
197 uint32_t status {};
198 int32_t ret = mService_->GetPowerStatus(index, &status);
199 if (ret != INPUT_SUCCESS) {
200 HDF_LOGE("InputServerStub %{public}s: GetDeviceType failed line:%{public}d", __func__, __LINE__);
201 return HDF_FAILURE;
202 }
203 if (!reply.WriteUint32(status)) {
204 HDF_LOGE("InputServerStub %{public}s: GetDeviceType failed line:%{public}d", __func__, __LINE__);
205 return HDF_FAILURE;
206 }
207 HDF_LOGE("InputServerStub::%{public}s end", __func__);
208 return HDF_SUCCESS;
209 }
210
InputServerStubGetDeviceType(MessageParcel & data,MessageParcel & reply,MessageOption & option) const211 int32_t InputServerStub::InputServerStubGetDeviceType(MessageParcel &data,
212 MessageParcel &reply,
213 MessageOption &option) const
214 {
215 if (data.ReadInterfaceToken() != InputServerStub::GetDescriptor()) {
216 return HDF_ERR_INVALID_PARAM;
217 }
218 HDF_LOGE("InputServerStub::%{public}s", __func__);
219 int32_t index = data.ReadInt32();
220 uint32_t deviceType {};
221 int32_t ret = mService_->GetDeviceType(index, &deviceType);
222 if (ret != INPUT_SUCCESS) {
223 HDF_LOGE("InputServerStub %{public}s: GetDeviceType failed line:%{public}d", __func__, __LINE__);
224 return HDF_FAILURE;
225 }
226 if (!reply.WriteUint32(deviceType)) {
227 HDF_LOGE("InputServerStub %{public}s: GetDeviceType failed line:%{public}d", __func__, __LINE__);
228 return HDF_FAILURE;
229 }
230 return HDF_SUCCESS;
231 }
232
InputServerStubGetChipInfo(MessageParcel & data,MessageParcel & reply,MessageOption & option) const233 int32_t InputServerStub::InputServerStubGetChipInfo(MessageParcel &data,
234 MessageParcel &reply,
235 MessageOption &option) const
236 {
237 if (data.ReadInterfaceToken() != InputServerStub::GetDescriptor()) {
238 return HDF_ERR_INVALID_PARAM;
239 }
240 int32_t index = data.ReadInt32();
241 uint32_t length = data.ReadUint32();
242 char* chipInfo = new char[MAX_NODE_PATH_LEN];
243 int32_t ret = mService_->GetChipInfo(index, chipInfo, length);
244 if (ret != INPUT_SUCCESS) {
245 HDF_LOGE("InputServerStub %{public}s: GetChipInfo failed line:%{public}d", __func__, __LINE__);
246 return HDF_FAILURE;
247 }
248 if (!reply.WriteUint32(strlen(chipInfo) + 1)) {
249 HDF_LOGE("InputServerStub %{public}s: GetChipInfo failed line:%{public}d", __func__, __LINE__);
250 return HDF_FAILURE;
251 }
252 if (!reply.WriteBuffer(chipInfo, strlen(chipInfo) + 1)) {
253 HDF_LOGE("InputServerStub %{public}s: GetChipInfo failed line:%{public}d", __func__, __LINE__);
254 return HDF_FAILURE;
255 }
256 return HDF_SUCCESS;
257 }
258
InputServerStubGetVendorName(MessageParcel & data,MessageParcel & reply,MessageOption & option) const259 int32_t InputServerStub::InputServerStubGetVendorName(MessageParcel &data,
260 MessageParcel &reply,
261 MessageOption &option) const
262 {
263 if (data.ReadInterfaceToken() != InputServerStub::GetDescriptor()) {
264 return HDF_ERR_INVALID_PARAM;
265 }
266 HDF_LOGE("InputServerStub::%{public}s", __func__);
267 int32_t index = data.ReadInt32();
268 uint32_t length = data.ReadUint32();
269 char* vendorName = new char[MAX_NODE_PATH_LEN];
270 int32_t ret = mService_->GetVendorName(index, vendorName, length);
271 if (ret != INPUT_SUCCESS) {
272 HDF_LOGE("InputServerStub %{public}s: GetVendorName failed line:%{public}d", __func__, __LINE__);
273 return HDF_FAILURE;
274 }
275 HDF_LOGE("InputServerStub %{public}s: GetVendorName line:%{public}d vendorName:%{public}s",
276 __func__, __LINE__, vendorName);
277 if (!reply.WriteUint32(strlen(vendorName) + 1)) {
278 HDF_LOGE("InputServerStub %{public}s: GetVendorName failed line:%{public}d", __func__, __LINE__);
279 return HDF_FAILURE;
280 }
281 if (!reply.WriteBuffer(vendorName, strlen(vendorName) + 1)) {
282 HDF_LOGE("InputServerStub %{public}s: GetVendorName failed line:%{public}d", __func__, __LINE__);
283 return HDF_FAILURE;
284 }
285 return HDF_SUCCESS;
286 }
287
InputServerStubGetChipName(MessageParcel & data,MessageParcel & reply,MessageOption & option) const288 int32_t InputServerStub::InputServerStubGetChipName(MessageParcel &data,
289 MessageParcel &reply,
290 MessageOption &option) const
291 {
292 if (data.ReadInterfaceToken() != InputServerStub::GetDescriptor()) {
293 return HDF_ERR_INVALID_PARAM;
294 }
295 HDF_LOGE("InputServerStub::%{public}s", __func__);
296 int32_t index = data.ReadInt32();
297 uint32_t length = data.ReadUint32();
298 char* chipName = new char[MAX_NODE_PATH_LEN];
299 int32_t ret = mService_->GetChipName(index, chipName, length);
300 if (ret != INPUT_SUCCESS) {
301 HDF_LOGE("InputServerStub %{public}s: GetChipName failed line:%{public}d", __func__, __LINE__);
302 return HDF_FAILURE;
303 }
304 if (!reply.WriteUint32(strlen(chipName) + 1)) {
305 HDF_LOGE("InputServerStub %{public}s: GetChipName failed line:%{public}d", __func__, __LINE__);
306 return HDF_FAILURE;
307 }
308 if (!reply.WriteBuffer(chipName, strlen(chipName) + 1)) {
309 HDF_LOGE("InputServerStub %{public}s: GetChipName failed line:%{public}d", __func__, __LINE__);
310 return HDF_FAILURE;
311 }
312 return HDF_SUCCESS;
313 }
314
InputServerStubSetGestureMode(MessageParcel & data,MessageParcel & reply,MessageOption & option) const315 int32_t InputServerStub::InputServerStubSetGestureMode(MessageParcel &data,
316 MessageParcel &reply,
317 MessageOption &option) const
318 {
319 if (data.ReadInterfaceToken() != InputServerStub::GetDescriptor()) {
320 return HDF_ERR_INVALID_PARAM;
321 }
322 HDF_LOGI("InputServerStub::%{public}s", __func__);
323 return HDF_SUCCESS;
324 }
InputServerStubRunCapacitanceTest(MessageParcel & data,MessageParcel & reply,MessageOption & option) const325 int32_t InputServerStub::InputServerStubRunCapacitanceTest(MessageParcel &data,
326 MessageParcel &reply,
327 MessageOption &option) const
328 {
329 if (data.ReadInterfaceToken() != InputServerStub::GetDescriptor()) {
330 return HDF_ERR_INVALID_PARAM;
331 }
332 HDF_LOGI("InputServerStub::%{public}s", __func__);
333 return HDF_SUCCESS;
334 }
335
InputServerStubRunExtraCommand(MessageParcel & data,MessageParcel & reply,MessageOption & option) const336 int32_t InputServerStub::InputServerStubRunExtraCommand(MessageParcel &data,
337 MessageParcel &reply,
338 MessageOption &option) const
339 {
340 if (data.ReadInterfaceToken() != InputServerStub::GetDescriptor()) {
341 return HDF_ERR_INVALID_PARAM;
342 }
343 HDF_LOGI("InputServerStub::%{public}s", __func__);
344 return HDF_SUCCESS;
345 }
346
InputServerStubRegisterReportCallback(MessageParcel & data,MessageParcel & reply,MessageOption & option) const347 int32_t InputServerStub::InputServerStubRegisterReportCallback(MessageParcel &data,
348 MessageParcel &reply,
349 MessageOption &option) const
350 {
351 if (data.ReadInterfaceToken() != InputServerStub::GetDescriptor()) {
352 return HDF_ERR_INVALID_PARAM;
353 }
354 int32_t index = data.ReadInt32();
355 bool flag = data.ReadBool();
356 HDF_LOGI("InputServerStub:: send flag:%{public}d", flag);
357 sptr<IRemoteObject> remote = data.ReadRemoteObject();
358 sptr<InputReportEventCb> callBackInfo = iface_cast<InputReportEventCb>(remote);
359 if (callBackInfo == nullptr) {
360 HDF_LOGE("InputServerStub %{public}s: callBackInfo is nullptr", __func__);
361 return HDF_FAILURE;
362 }
363 int32_t ret = mService_->RegisterReportCallback(index, callBackInfo);
364 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
365 HDF_LOGE("InputServerStub %{public}s: RegisterReportCallback failed", __func__);
366 return HDF_FAILURE;
367 }
368 return HDF_SUCCESS;
369 }
370
InputServerStubUnregisterReportCallback(MessageParcel & data,MessageParcel & reply,MessageOption & option) const371 int32_t InputServerStub::InputServerStubUnregisterReportCallback(MessageParcel &data,
372 MessageParcel &reply,
373 MessageOption &option) const
374 {
375 if (data.ReadInterfaceToken() != InputServerStub::GetDescriptor()) {
376 return HDF_ERR_INVALID_PARAM;
377 }
378 int32_t index = data.ReadInt32();
379 int32_t ret = mService_->UnregisterReportCallback(index);
380 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
381 HDF_LOGE("InputServerStub %{public}s: UnregisterReportCallback failed", __func__);
382 return HDF_FAILURE;
383 }
384 return HDF_SUCCESS;
385 }
386
InputServerStubRegisterHotPlugCallback(MessageParcel & data,MessageParcel & reply,MessageOption & option) const387 int32_t InputServerStub::InputServerStubRegisterHotPlugCallback(MessageParcel &data,
388 MessageParcel &reply,
389 MessageOption &option) const
390 {
391 if (data.ReadInterfaceToken() != InputServerStub::GetDescriptor()) {
392 return HDF_ERR_INVALID_PARAM;
393 }
394 bool flag = data.ReadBool();
395 HDF_LOGE("InputServerStub::%{public}s send flag:%{public}d", __func__, flag);
396 sptr<IRemoteObject> remote = data.ReadRemoteObject();
397 const sptr<InputReportHostCb> callBackInfo = iface_cast<InputReportHostCb>(remote);
398 if (callBackInfo == nullptr) {
399 HDF_LOGE("InputServerStub %{public}s: callBackInfo is nullptr", __func__);
400 return HDF_FAILURE;
401 }
402 int32_t ret = mService_->RegisterHotPlugCallback(callBackInfo);
403 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
404 HDF_LOGE("InputServerStub %{public}s: RegisterReportCallback failed", __func__);
405 return HDF_FAILURE;
406 }
407 return HDF_SUCCESS;
408 }
409
InputServerStubUnregisterHotPlugCallback(MessageParcel & data,MessageParcel & reply,MessageOption & option) const410 int32_t InputServerStub::InputServerStubUnregisterHotPlugCallback(MessageParcel &data,
411 MessageParcel &reply,
412 MessageOption &option) const
413 {
414 if (data.ReadInterfaceToken() != InputServerStub::GetDescriptor()) {
415 return HDF_ERR_INVALID_PARAM;
416 }
417 int32_t ret = mService_->UnregisterHotPlugCallback();
418 if (!reply.WriteInt32(static_cast<int32_t>(ret))) {
419 HDF_LOGE("InputServerStub %{public}s: UnregisterHotPlugCallback failed", __func__);
420 return HDF_FAILURE;
421 }
422 return HDF_SUCCESS;
423 }
424
InputServerStubOnRemoteRequest(int32_t cmdId,MessageParcel & data,MessageParcel & reply,MessageOption & option)425 int32_t InputServerStub::InputServerStubOnRemoteRequest(int32_t cmdId,
426 MessageParcel& data,
427 MessageParcel& reply,
428 MessageOption& option)
429 {
430 switch (cmdId) {
431 case CMD_INPUT_SCAN_DEVICE: {
432 return InputServerStubScanInputDevice(data, reply, option);
433 }
434 case CMD_INPUT_OPNE_DEVICE: {
435 return InputServerStubOpenInputDevice(data, reply, option);
436 }
437 case CMD_INPUT_CLOSE_DEVICE: {
438 return InputServerStubCloseInputDevice(data, reply, option);
439 }
440 case CMD_INPUT_GET_DEVICE: {
441 return InputServerStubGetInputDevice(data, reply, option);
442 }
443 case CMD_INPUT_GET_DEVICE_LIST: {
444 return InputServerStubGetInputDeviceList(data, reply, option);
445 }
446 case CMD_INPUT_GET_CHIP_INFO: {
447 return InputServerStubGetChipInfo(data, reply, option);
448 }
449 case CMD_INPUT_GET_VENDOR_NAME: {
450 return InputServerStubGetVendorName(data, reply, option);
451 }
452 case CMD_INPUT_GET_CHIP_NAME: {
453 return InputServerStubGetChipName(data, reply, option);
454 }
455 case CMD_INPUT_REGISTER_DEVICE: {
456 return InputServerStubRegisterReportCallback(data, reply, option);
457 }
458 case CMD_INPUT_UNREGISTER_DEVICE: {
459 return InputServerStubUnregisterReportCallback(data, reply, option);
460 }
461 case CMD_INPUT_REGISTER_HOT_PLAUS_DEVICE: {
462 return InputServerStubRegisterHotPlugCallback(data, reply, option);
463 }
464 case CMD_INPUT_UNREGISTER_HOT_PLAUS_DEVICE: {
465 return InputServerStubUnregisterHotPlugCallback(data, reply, option);
466 }
467 default: {
468 return HDF_ERR_INVALID_PARAM;
469 }
470 }
471 }
472 } // namespace Input
473 } // namespace OHOS
474
InputStubInstance()475 void *InputStubInstance()
476 {
477 HDF_LOGI("%{public}s: line%{public}d!", __func__, __LINE__);
478 using namespace OHOS::Input;
479 return reinterpret_cast<void *>(new InputServerStub());
480 }
481
InputStubRelease(void * obj)482 void InputStubRelease(void *obj)
483 {
484 using namespace OHOS::Input;
485 delete reinterpret_cast<InputServerStub *>(obj);
486 }
487
InputServiceOnRemoteRequest(void * stub,int32_t cmdId,struct HdfSBuf & data,struct HdfSBuf & reply)488 int32_t InputServiceOnRemoteRequest(void *stub, int32_t cmdId, struct HdfSBuf& data, struct HdfSBuf& reply)
489 {
490 HDF_LOGI("%{public}s: line%{public}d!", __func__, __LINE__);
491 using namespace OHOS::Input;
492 InputServerStub *inuptStub = reinterpret_cast<InputServerStub *>(stub);
493 OHOS::MessageParcel *dataParcel = nullptr;
494 OHOS::MessageParcel *replyParcel = nullptr;
495 (void)SbufToParcel(&reply, &replyParcel);
496 if (SbufToParcel(&data, &dataParcel) != HDF_SUCCESS) {
497 HDF_LOGE("%s:invalid data sbuf object to dispatch", __func__);
498 return HDF_ERR_INVALID_PARAM;
499 }
500 OHOS::MessageOption option;
501 return inuptStub->InputServerStubOnRemoteRequest(cmdId, *dataParcel, *replyParcel, option);
502 }
503