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 "miscdevice_service_proxy.h"
17
18 #include "hisysevent.h"
19 #include "securec.h"
20
21 #include "sensors_errors.h"
22
23 #undef LOG_TAG
24 #define LOG_TAG "MiscdeviceServiceProxy"
25
26 namespace OHOS {
27 namespace Sensors {
28 using namespace OHOS::HiviewDFX;
29
30 namespace {
31 constexpr int32_t MAX_LIGHT_COUNT = 0XFF;
32 } // namespace
33
MiscdeviceServiceProxy(const sptr<IRemoteObject> & impl)34 MiscdeviceServiceProxy::MiscdeviceServiceProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IMiscdeviceService>(impl)
35 {}
36
Vibrate(int32_t vibratorId,int32_t timeOut,int32_t usage,bool systemUsage)37 int32_t MiscdeviceServiceProxy::Vibrate(int32_t vibratorId, int32_t timeOut, int32_t usage, bool systemUsage)
38 {
39 MessageParcel data;
40 if (!data.WriteInterfaceToken(MiscdeviceServiceProxy::GetDescriptor())) {
41 MISC_HILOGE("Write descriptor failed");
42 return WRITE_MSG_ERR;
43 }
44 if (!data.WriteInt32(vibratorId)) {
45 MISC_HILOGE("WriteInt32 vibratorId failed");
46 return WRITE_MSG_ERR;
47 }
48 if (!data.WriteInt32(timeOut)) {
49 MISC_HILOGE("WriteUint32 timeOut failed");
50 return WRITE_MSG_ERR;
51 }
52 if (!data.WriteInt32(usage)) {
53 MISC_HILOGE("WriteUint32 usage failed");
54 return WRITE_MSG_ERR;
55 }
56 if (!data.WriteBool(systemUsage)) {
57 MISC_HILOGE("WritBool systemUsage failed");
58 return WRITE_MSG_ERR;
59 }
60 sptr<IRemoteObject> remote = Remote();
61 CHKPR(remote, ERROR);
62 MessageParcel reply;
63 MessageOption option;
64 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MiscdeviceInterfaceCode::VIBRATE),
65 data, reply, option);
66 if (ret != NO_ERROR) {
67 HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION",
68 HiSysEvent::EventType::FAULT, "PKG_NAME", "Vibrate", "ERROR_CODE", ret);
69 MISC_HILOGD("SendRequest failed, ret:%{public}d", ret);
70 }
71 return ret;
72 }
73
StopVibrator(int32_t vibratorId)74 int32_t MiscdeviceServiceProxy::StopVibrator(int32_t vibratorId)
75 {
76 MessageParcel data;
77 if (!data.WriteInterfaceToken(MiscdeviceServiceProxy::GetDescriptor())) {
78 MISC_HILOGE("Write descriptor failed");
79 return WRITE_MSG_ERR;
80 }
81 if (!data.WriteInt32(vibratorId)) {
82 MISC_HILOGE("WriteInt32 vibratorId failed");
83 return WRITE_MSG_ERR;
84 }
85 sptr<IRemoteObject> remote = Remote();
86 CHKPR(remote, ERROR);
87 MessageParcel reply;
88 MessageOption option;
89 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MiscdeviceInterfaceCode::STOP_VIBRATOR_ALL),
90 data, reply, option);
91 if (ret != NO_ERROR) {
92 HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION",
93 HiSysEvent::EventType::FAULT, "PKG_NAME", "StopVibrator", "ERROR_CODE", ret);
94 MISC_HILOGD("SendRequest failed, ret:%{public}d", ret);
95 }
96 return ret;
97 }
98
PlayVibratorEffect(int32_t vibratorId,const std::string & effect,int32_t loopCount,int32_t usage,bool systemUsage)99 int32_t MiscdeviceServiceProxy::PlayVibratorEffect(int32_t vibratorId, const std::string &effect,
100 int32_t loopCount, int32_t usage, bool systemUsage)
101 {
102 MessageParcel data;
103 if (!data.WriteInterfaceToken(MiscdeviceServiceProxy::GetDescriptor())) {
104 MISC_HILOGE("Write descriptor failed");
105 return WRITE_MSG_ERR;
106 }
107 if (!data.WriteInt32(vibratorId)) {
108 MISC_HILOGE("WriteInt32 vibratorId failed");
109 return WRITE_MSG_ERR;
110 }
111 if (!data.WriteString(effect)) {
112 MISC_HILOGE("WriteString effect failed");
113 return WRITE_MSG_ERR;
114 }
115 if (!data.WriteInt32(loopCount)) {
116 MISC_HILOGE("WriteInt32 loopCount failed");
117 return WRITE_MSG_ERR;
118 }
119 if (!data.WriteInt32(usage)) {
120 MISC_HILOGE("Writeint32 usage failed");
121 return WRITE_MSG_ERR;
122 }
123 if (!data.WriteBool(systemUsage)) {
124 MISC_HILOGE("Writebool systemUsage failed");
125 return WRITE_MSG_ERR;
126 }
127 sptr<IRemoteObject> remote = Remote();
128 CHKPR(remote, ERROR);
129 MessageParcel reply;
130 MessageOption option;
131 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MiscdeviceInterfaceCode::PLAY_VIBRATOR_EFFECT),
132 data, reply, option);
133 if (ret != NO_ERROR) {
134 HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION",
135 HiSysEvent::EventType::FAULT, "PKG_NAME", "PlayVibratorEffect", "ERROR_CODE", ret);
136 MISC_HILOGD("SendRequest failed, ret:%{public}d", ret);
137 }
138 return ret;
139 }
140
StopVibrator(int32_t vibratorId,const std::string & mode)141 int32_t MiscdeviceServiceProxy::StopVibrator(int32_t vibratorId, const std::string &mode)
142 {
143 MessageParcel data;
144 if (!data.WriteInterfaceToken(MiscdeviceServiceProxy::GetDescriptor())) {
145 MISC_HILOGE("Write descriptor failed");
146 return WRITE_MSG_ERR;
147 }
148 if (!data.WriteInt32(vibratorId)) {
149 MISC_HILOGE("WriteInt32 vibratorId failed");
150 return WRITE_MSG_ERR;
151 }
152 if (!data.WriteString(mode)) {
153 MISC_HILOGE("WriteString mode failed");
154 return WRITE_MSG_ERR;
155 }
156 sptr<IRemoteObject> remote = Remote();
157 CHKPR(remote, ERROR);
158 MessageParcel reply;
159 MessageOption option;
160 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MiscdeviceInterfaceCode::STOP_VIBRATOR_BY_MODE),
161 data, reply, option);
162 if (ret != NO_ERROR) {
163 HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION",
164 HiSysEvent::EventType::FAULT, "PKG_NAME", "StopVibrator", "ERROR_CODE", ret);
165 MISC_HILOGD("SendRequest failed, ret:%{public}d", ret);
166 }
167 return ret;
168 }
169
IsSupportEffect(const std::string & effect,bool & state)170 int32_t MiscdeviceServiceProxy::IsSupportEffect(const std::string &effect, bool &state)
171 {
172 MessageParcel data;
173 if (!data.WriteInterfaceToken(MiscdeviceServiceProxy::GetDescriptor())) {
174 MISC_HILOGE("Write descriptor failed");
175 return WRITE_MSG_ERR;
176 }
177 if (!data.WriteString(effect)) {
178 MISC_HILOGE("WriteString effect failed");
179 return WRITE_MSG_ERR;
180 }
181 sptr<IRemoteObject> remote = Remote();
182 CHKPR(remote, ERROR);
183 MessageParcel reply;
184 MessageOption option;
185 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MiscdeviceInterfaceCode::IS_SUPPORT_EFFECT),
186 data, reply, option);
187 if (ret != NO_ERROR) {
188 HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION",
189 HiSysEvent::EventType::FAULT, "PKG_NAME", "IsSupportEffect", "ERROR_CODE", ret);
190 MISC_HILOGD("SendRequest failed, ret:%{public}d", ret);
191 return ret;
192 }
193 if (!reply.ReadBool(state)) {
194 MISC_HILOGE("Parcel read state failed");
195 return READ_MSG_ERR;
196 }
197 return ret;
198 }
199
200 #ifdef OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM
PlayVibratorCustom(int32_t vibratorId,const RawFileDescriptor & rawFd,int32_t usage,bool systemUsage,const VibrateParameter & parameter)201 int32_t MiscdeviceServiceProxy::PlayVibratorCustom(int32_t vibratorId, const RawFileDescriptor &rawFd, int32_t usage,
202 bool systemUsage, const VibrateParameter ¶meter)
203 {
204 MessageParcel data;
205 if (!data.WriteInterfaceToken(MiscdeviceServiceProxy::GetDescriptor())) {
206 MISC_HILOGE("Write descriptor failed");
207 return WRITE_MSG_ERR;
208 }
209 if (!data.WriteInt32(vibratorId)) {
210 MISC_HILOGE("WriteInt32 vibratorId failed");
211 return WRITE_MSG_ERR;
212 }
213 if (!data.WriteInt32(usage)) {
214 MISC_HILOGE("Writeint32 usage failed");
215 return WRITE_MSG_ERR;
216 }
217 if (!data.WriteBool(systemUsage)) {
218 MISC_HILOGE("Writebool systemUsage failed");
219 return WRITE_MSG_ERR;
220 }
221 if (!parameter.Marshalling(data)) {
222 MISC_HILOGE("Write adjust parameter failed");
223 return WRITE_MSG_ERR;
224 }
225 if (!data.WriteInt64(rawFd.offset)) {
226 MISC_HILOGE("Writeint64 offset failed");
227 return WRITE_MSG_ERR;
228 }
229 if (!data.WriteInt64(rawFd.length)) {
230 MISC_HILOGE("Writeint64 length failed");
231 return WRITE_MSG_ERR;
232 }
233 if (!data.WriteFileDescriptor(rawFd.fd)) {
234 MISC_HILOGE("WriteFileDescriptor fd failed");
235 return WRITE_MSG_ERR;
236 }
237 sptr<IRemoteObject> remote = Remote();
238 CHKPR(remote, ERROR);
239 MessageParcel reply;
240 MessageOption option;
241 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MiscdeviceInterfaceCode::PLAY_VIBRATOR_CUSTOM),
242 data, reply, option);
243 if (ret != NO_ERROR) {
244 HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION",
245 HiSysEvent::EventType::FAULT, "PKG_NAME", "PlayVibratorCustom", "ERROR_CODE", ret);
246 MISC_HILOGD("SendRequest failed, ret:%{public}d", ret);
247 }
248 return ret;
249 }
250 #endif // OHOS_BUILD_ENABLE_VIBRATOR_CUSTOM
251
GetLightList()252 std::vector<LightInfoIPC> MiscdeviceServiceProxy::GetLightList()
253 {
254 MessageParcel data;
255 std::vector<LightInfoIPC> lightInfos;
256 if (!data.WriteInterfaceToken(MiscdeviceServiceProxy::GetDescriptor())) {
257 MISC_HILOGE("WriteInterfaceToken failed");
258 return lightInfos;
259 }
260 sptr<IRemoteObject> remote = Remote();
261 if (remote == nullptr) {
262 MISC_HILOGE("remote is nullptr");
263 return lightInfos;
264 }
265 MessageParcel reply;
266 MessageOption option;
267 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MiscdeviceInterfaceCode::GET_LIGHT_LIST),
268 data, reply, option);
269 if (ret != NO_ERROR) {
270 MISC_HILOGE("SendRequest failed, ret:%{public}d", ret);
271 return lightInfos;
272 }
273 uint32_t lightCount = 0;
274 if (!reply.ReadUint32(lightCount)) {
275 MISC_HILOGE("Parcel read failed");
276 return lightInfos;
277 }
278 if (lightCount > MAX_LIGHT_COUNT) {
279 lightCount = MAX_LIGHT_COUNT;
280 }
281 LightInfoIPC lightInfo;
282 for (uint32_t i = 0; i < lightCount; ++i) {
283 auto tmpLightInfo = lightInfo.Unmarshalling(reply);
284 CHKPC(tmpLightInfo);
285 lightInfos.push_back(*tmpLightInfo);
286 }
287 return lightInfos;
288 }
289
TurnOn(int32_t lightId,const LightColor & color,const LightAnimationIPC & animation)290 int32_t MiscdeviceServiceProxy::TurnOn(int32_t lightId, const LightColor &color, const LightAnimationIPC &animation)
291 {
292 MessageParcel data;
293 if (!data.WriteInterfaceToken(MiscdeviceServiceProxy::GetDescriptor())) {
294 MISC_HILOGE("Write descriptor failed");
295 return WRITE_MSG_ERR;
296 }
297 if (!data.WriteInt32(lightId)) {
298 MISC_HILOGE("WriteUint32 lightId failed");
299 return WRITE_MSG_ERR;
300 }
301 if (!data.WriteInt32(color.singleColor)) {
302 MISC_HILOGE("Write color failed");
303 return WRITE_MSG_ERR;
304 }
305 if (!animation.Marshalling(data)) {
306 MISC_HILOGE("Write animation failed");
307 return WRITE_MSG_ERR;
308 }
309 sptr<IRemoteObject> remote = Remote();
310 CHKPR(remote, ERROR);
311 MessageParcel reply;
312 MessageOption option;
313 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MiscdeviceInterfaceCode::TURN_ON),
314 data, reply, option);
315 if (ret != NO_ERROR) {
316 HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION",
317 HiSysEvent::EventType::FAULT, "PKG_NAME", "TurnOn", "ERROR_CODE", ret);
318 MISC_HILOGE("SendRequest failed, ret:%{public}d", ret);
319 }
320 return ret;
321 }
322
TurnOff(int32_t lightId)323 int32_t MiscdeviceServiceProxy::TurnOff(int32_t lightId)
324 {
325 MessageParcel data;
326 if (!data.WriteInterfaceToken(MiscdeviceServiceProxy::GetDescriptor())) {
327 MISC_HILOGE("Write descriptor failed");
328 return WRITE_MSG_ERR;
329 }
330 if (!data.WriteInt32(lightId)) {
331 MISC_HILOGE("WriteInt32 lightId failed");
332 return WRITE_MSG_ERR;
333 }
334 sptr<IRemoteObject> remote = Remote();
335 CHKPR(remote, ERROR);
336 MessageParcel reply;
337 MessageOption option;
338 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MiscdeviceInterfaceCode::TURN_OFF),
339 data, reply, option);
340 if (ret != NO_ERROR) {
341 HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION",
342 HiSysEvent::EventType::FAULT, "PKG_NAME", "TurnOff", "ERROR_CODE", ret);
343 MISC_HILOGE("SendRequest failed, ret:%{public}d", ret);
344 }
345 return ret;
346 }
347
GetDelayTime(int32_t & delayTime)348 int32_t MiscdeviceServiceProxy::GetDelayTime(int32_t &delayTime)
349 {
350 MessageParcel data;
351 if (!data.WriteInterfaceToken(MiscdeviceServiceProxy::GetDescriptor())) {
352 MISC_HILOGE("Write descriptor failed");
353 return WRITE_MSG_ERR;
354 }
355 sptr<IRemoteObject> remote = Remote();
356 CHKPR(remote, ERROR);
357 MessageParcel reply;
358 MessageOption option;
359 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MiscdeviceInterfaceCode::GET_DELAY_TIME),
360 data, reply, option);
361 if (ret != NO_ERROR) {
362 HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION",
363 HiSysEvent::EventType::FAULT, "PKG_NAME", "GetDelayTime", "ERROR_CODE", ret);
364 MISC_HILOGD("SendRequest failed, ret:%{public}d", ret);
365 }
366 if (!reply.ReadInt32(delayTime)) {
367 MISC_HILOGE("Parcel read failed");
368 return ERROR;
369 }
370 return ret;
371 }
372
PlayPattern(const VibratePattern & pattern,int32_t usage,bool systemUsage,const VibrateParameter & parameter)373 int32_t MiscdeviceServiceProxy::PlayPattern(const VibratePattern &pattern, int32_t usage,
374 bool systemUsage, const VibrateParameter ¶meter)
375 {
376 MessageParcel data;
377 if (!data.WriteInterfaceToken(MiscdeviceServiceProxy::GetDescriptor())) {
378 MISC_HILOGE("Write descriptor failed");
379 return WRITE_MSG_ERR;
380 }
381 if (!pattern.Marshalling(data)) {
382 MISC_HILOGE("Marshalling failed");
383 return WRITE_MSG_ERR;
384 }
385 if (!data.WriteInt32(usage)) {
386 MISC_HILOGE("WriteUint32 usage failed");
387 return WRITE_MSG_ERR;
388 }
389 if (!data.WriteBool(systemUsage)) {
390 MISC_HILOGE("WriteBool systemUsage failed");
391 return WRITE_MSG_ERR;
392 }
393 if (!parameter.Marshalling(data)) {
394 MISC_HILOGE("Write adjust parameter failed");
395 return WRITE_MSG_ERR;
396 }
397 sptr<IRemoteObject> remote = Remote();
398 CHKPR(remote, ERROR);
399 MessageParcel reply;
400 MessageOption option;
401 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MiscdeviceInterfaceCode::PlAY_PATTERN),
402 data, reply, option);
403 if (ret != NO_ERROR) {
404 HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION",
405 HiSysEvent::EventType::FAULT, "PKG_NAME", "PlayPattern", "ERROR_CODE", ret);
406 MISC_HILOGD("SendRequest failed, ret:%{public}d", ret);
407 }
408 return ret;
409 }
410
TransferClientRemoteObject(const sptr<IRemoteObject> & vibratorClient)411 int32_t MiscdeviceServiceProxy::TransferClientRemoteObject(const sptr<IRemoteObject> &vibratorClient)
412 {
413 MessageParcel data;
414 MessageParcel reply;
415 MessageOption option;
416 if (!data.WriteInterfaceToken(MiscdeviceServiceProxy::GetDescriptor())) {
417 MISC_HILOGE("Write descriptor failed");
418 return WRITE_MSG_ERR;
419 }
420 if (!data.WriteRemoteObject(vibratorClient)) {
421 MISC_HILOGE("Parcel writeRemoteObject failed");
422 return WRITE_MSG_ERR;
423 }
424 sptr<IRemoteObject> remote = Remote();
425 CHKPR(remote, ERROR);
426 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MiscdeviceInterfaceCode::TRANSFER_CLIENT_REMOTE_OBJECT),
427 data, reply, option);
428 if (ret != NO_ERROR) {
429 HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION",
430 HiSysEvent::EventType::FAULT, "PKG_NAME", "TransferClientRemoteObject", "ERROR_CODE", ret);
431 MISC_HILOGE("SendRequest failed, ret:%{public}d", ret);
432 }
433 return ret;
434 }
435
PlayPrimitiveEffect(int32_t vibratorId,const std::string & effect,int32_t intensity,int32_t usage,bool systemUsage,int32_t count)436 int32_t MiscdeviceServiceProxy::PlayPrimitiveEffect(int32_t vibratorId, const std::string &effect, int32_t intensity,
437 int32_t usage, bool systemUsage, int32_t count)
438 {
439 MessageParcel data;
440 if (!data.WriteInterfaceToken(MiscdeviceServiceProxy::GetDescriptor())) {
441 MISC_HILOGE("Write descriptor failed");
442 return WRITE_MSG_ERR;
443 }
444 if (!data.WriteInt32(vibratorId)) {
445 MISC_HILOGE("WriteInt32 vibratorId failed");
446 return WRITE_MSG_ERR;
447 }
448 if (!data.WriteString(effect)) {
449 MISC_HILOGE("WriteString effect failed");
450 return WRITE_MSG_ERR;
451 }
452 if (!data.WriteInt32(intensity)) {
453 MISC_HILOGE("WriteInt32 intensity failed");
454 return WRITE_MSG_ERR;
455 }
456 if (!data.WriteInt32(usage)) {
457 MISC_HILOGE("Writeint32 usage failed");
458 return WRITE_MSG_ERR;
459 }
460 if (!data.WriteBool(systemUsage)) {
461 MISC_HILOGE("WriteBool systemUsage failed");
462 return WRITE_MSG_ERR;
463 }
464 if (!data.WriteInt32(count)) {
465 MISC_HILOGE("Writeint32 count failed");
466 return WRITE_MSG_ERR;
467 }
468 sptr<IRemoteObject> remote = Remote();
469 CHKPR(remote, ERROR);
470 MessageParcel reply;
471 MessageOption option;
472 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MiscdeviceInterfaceCode::PLAY_PRIMITIVE_EFFECT),
473 data, reply, option);
474 if (ret != NO_ERROR) {
475 HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION",
476 HiSysEvent::EventType::FAULT, "PKG_NAME", "PlayPrimitiveEffect", "ERROR_CODE", ret);
477 MISC_HILOGD("SendRequest failed, ret:%{public}d", ret);
478 }
479 return ret;
480 }
481
GetVibratorCapacity(VibratorCapacity & capacity)482 int32_t MiscdeviceServiceProxy::GetVibratorCapacity(VibratorCapacity &capacity)
483 {
484 MessageParcel data;
485 if (!data.WriteInterfaceToken(MiscdeviceServiceProxy::GetDescriptor())) {
486 MISC_HILOGE("Write descriptor failed");
487 return WRITE_MSG_ERR;
488 }
489 sptr<IRemoteObject> remote = Remote();
490 CHKPR(remote, ERROR);
491 MessageParcel reply;
492 MessageOption option;
493 int32_t ret = remote->SendRequest(static_cast<uint32_t>(MiscdeviceInterfaceCode::GET_VIBRATOR_CAPACITY),
494 data, reply, option);
495 if (ret != NO_ERROR) {
496 HiSysEventWrite(HiSysEvent::Domain::MISCDEVICE, "MISC_SERVICE_IPC_EXCEPTION",
497 HiSysEvent::EventType::FAULT, "PKG_NAME", "GetVibratorCapacity", "ERROR_CODE", ret);
498 MISC_HILOGE("SendRequest failed, ret:%{public}d", ret);
499 return ret;
500 }
501 auto vibratorCapacity = capacity.Unmarshalling(reply);
502 if (!vibratorCapacity.has_value()) {
503 MISC_HILOGE("VibratorCapacity Unmarshalling failed");
504 return ERROR;
505 }
506 capacity = vibratorCapacity.value();
507 return ret;
508 }
509 } // namespace Sensors
510 } // namespace OHOS
511