1 /*
2 * Copyright (c) 2022-2023 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 "devicestatus_srv_proxy.h"
17
18 #include "hitrace_meter.h"
19 #include "iremote_object.h"
20 #include <message_option.h>
21 #include <message_parcel.h>
22
23 #include "devicestatus_common.h"
24 #include "devicestatus_define.h"
25 #include "stationary_callback.h"
26 #include "stationary_data.h"
27
28 namespace OHOS {
29 namespace Msdp {
30 namespace DeviceStatus {
31 namespace {
32 constexpr OHOS::HiviewDFX::HiLogLabel LABEL { LOG_CORE, MSDP_DOMAIN_ID, "DeviceStatusSrvProxy" };
33 } // namespace
34
Subscribe(Type type,ActivityEvent event,ReportLatencyNs latency,sptr<IRemoteDevStaCallback> callback)35 void DeviceStatusSrvProxy::Subscribe(Type type, ActivityEvent event, ReportLatencyNs latency,
36 sptr<IRemoteDevStaCallback> callback)
37 {
38 CALL_DEBUG_ENTER;
39 FI_HILOGI("Enter event:%{public}d, latency:%{public}d", event, latency);
40 sptr<IRemoteObject> remote = Remote();
41 DEV_RET_IF_NULL((remote == nullptr) || (callback == nullptr));
42
43 MessageParcel data;
44 MessageParcel reply;
45 MessageOption option;
46
47 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
48 FI_HILOGE("Write descriptor failed");
49 return;
50 }
51
52 WRITEINT32(data, type);
53 WRITEINT32(data, event);
54 WRITEINT32(data, latency);
55 WRITEREMOTEOBJECT(data, callback->AsObject());
56
57 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::DEVICESTATUS_SUBSCRIBE),
58 data, reply, option);
59 if (ret != RET_OK) {
60 FI_HILOGE("SendRequest is failed, error code:%{public}d", ret);
61 return;
62 }
63 }
64
Unsubscribe(Type type,ActivityEvent event,sptr<IRemoteDevStaCallback> callback)65 void DeviceStatusSrvProxy::Unsubscribe(Type type, ActivityEvent event, sptr<IRemoteDevStaCallback> callback)
66 {
67 CALL_DEBUG_ENTER;
68 FI_HILOGD("Enter, event:%{public}d", event);
69 StartTrace(HITRACE_TAG_MSDP, "clientUnSubscribeStart");
70 sptr<IRemoteObject> remote = Remote();
71 DEV_RET_IF_NULL((remote == nullptr) || (callback == nullptr));
72
73 MessageParcel data;
74 MessageParcel reply;
75 MessageOption option;
76
77 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
78 FI_HILOGE("Write descriptor failed");
79 return;
80 }
81
82 WRITEINT32(data, type);
83 WRITEINT32(data, event);
84 WRITEREMOTEOBJECT(data, callback->AsObject());
85
86 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::DEVICESTATUS_UNSUBSCRIBE),
87 data, reply, option);
88 if (ret != RET_OK) {
89 FI_HILOGE("SendRequest is failed, error code:%{public}d", ret);
90 return;
91 }
92 }
93
GetCache(const Type & type)94 Data DeviceStatusSrvProxy::GetCache(const Type& type)
95 {
96 CALL_DEBUG_ENTER;
97 Data devicestatusData;
98 devicestatusData.type = Type::TYPE_INVALID;
99 devicestatusData.value = OnChangedValue::VALUE_INVALID;
100
101 sptr<IRemoteObject> remote = Remote();
102 DEV_RET_IF_NULL_WITH_RET((remote == nullptr), devicestatusData);
103
104 MessageParcel data;
105 MessageParcel reply;
106 MessageOption option;
107
108 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
109 FI_HILOGE("Write descriptor failed");
110 return devicestatusData;
111 }
112
113 WRITEINT32(data, type, devicestatusData);
114
115 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::DEVICESTATUS_GETCACHE),
116 data, reply, option);
117 if (ret != RET_OK) {
118 FI_HILOGE("SendRequest is failed, error code:%{public}d", ret);
119 return devicestatusData;
120 }
121
122 int32_t devicestatusType = -1;
123 int32_t devicestatusValue = -1;
124 READINT32(reply, devicestatusType, devicestatusData);
125 READINT32(reply, devicestatusValue, devicestatusData);
126 devicestatusData.type = static_cast<Type>(devicestatusType);
127 devicestatusData.value = static_cast<OnChangedValue>(devicestatusValue);
128 FI_HILOGD("type:%{public}d, value:%{public}d", devicestatusData.type, devicestatusData.value);
129 return devicestatusData;
130 }
131
RegisterCoordinationListener()132 int32_t DeviceStatusSrvProxy::RegisterCoordinationListener()
133 {
134 CALL_DEBUG_ENTER;
135 MessageParcel data;
136 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
137 FI_HILOGE("Failed to write descriptor");
138 return ERR_INVALID_VALUE;
139 }
140 MessageParcel reply;
141 MessageOption option;
142 sptr<IRemoteObject> remote = Remote();
143 CHKPR(remote, RET_ERR);
144 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::REGISTER_COORDINATION_MONITOR),
145 data, reply, option);
146 if (ret != RET_OK) {
147 FI_HILOGE("Send request fail, ret:%{public}d", ret);
148 }
149 return ret;
150 }
151
UnregisterCoordinationListener()152 int32_t DeviceStatusSrvProxy::UnregisterCoordinationListener()
153 {
154 CALL_DEBUG_ENTER;
155 MessageParcel data;
156 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
157 FI_HILOGE("Failed to write descriptor");
158 return ERR_INVALID_VALUE;
159 }
160 MessageParcel reply;
161 MessageOption option;
162 sptr<IRemoteObject> remote = Remote();
163 CHKPR(remote, RET_ERR);
164 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::UNREGISTER_COORDINATION_MONITOR),
165 data, reply, option);
166 if (ret != RET_OK) {
167 FI_HILOGE("Send request fail, ret:%{public}d", ret);
168 }
169 return ret;
170 }
171
PrepareCoordination(int32_t userData)172 int32_t DeviceStatusSrvProxy::PrepareCoordination(int32_t userData)
173 {
174 CALL_DEBUG_ENTER;
175 MessageParcel data;
176 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
177 FI_HILOGE("Failed to write descriptor");
178 return ERR_INVALID_VALUE;
179 }
180 WRITEINT32(data, userData, ERR_INVALID_VALUE);
181 MessageParcel reply;
182 MessageOption option;
183 sptr<IRemoteObject> remote = Remote();
184 CHKPR(remote, RET_ERR);
185 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::PREPARE_COORDINATION),
186 data, reply, option);
187 if (ret != RET_OK) {
188 FI_HILOGE("Send request fail, ret:%{public}d", ret);
189 }
190 return ret;
191 }
192
UnprepareCoordination(int32_t userData)193 int32_t DeviceStatusSrvProxy::UnprepareCoordination(int32_t userData)
194 {
195 CALL_DEBUG_ENTER;
196 MessageParcel data;
197 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
198 FI_HILOGE("Failed to write descriptor");
199 return ERR_INVALID_VALUE;
200 }
201 WRITEINT32(data, userData, ERR_INVALID_VALUE);
202 MessageParcel reply;
203 MessageOption option;
204 sptr<IRemoteObject> remote = Remote();
205 CHKPR(remote, RET_ERR);
206 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::UNPREPARE_COORDINATION),
207 data, reply, option);
208 if (ret != RET_OK) {
209 FI_HILOGE("Send request fail, ret:%{public}d", ret);
210 }
211 return ret;
212 }
213
ActivateCoordination(int32_t userData,const std::string & remoteNetworkId,int32_t startDeviceId)214 int32_t DeviceStatusSrvProxy::ActivateCoordination(int32_t userData, const std::string &remoteNetworkId,
215 int32_t startDeviceId)
216 {
217 CALL_DEBUG_ENTER;
218 MessageParcel data;
219 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
220 FI_HILOGE("Failed to write descriptor");
221 return ERR_INVALID_VALUE;
222 }
223 WRITEINT32(data, userData, ERR_INVALID_VALUE);
224 WRITESTRING(data, remoteNetworkId, ERR_INVALID_VALUE);
225 WRITEINT32(data, startDeviceId, ERR_INVALID_VALUE);
226 MessageParcel reply;
227 MessageOption option;
228 sptr<IRemoteObject> remote = Remote();
229 CHKPR(remote, RET_ERR);
230 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::START_COORDINATION),
231 data, reply, option);
232 if (ret != RET_OK) {
233 FI_HILOGE("Send request fail, ret:%{public}d", ret);
234 }
235 return ret;
236 }
237
DeactivateCoordination(int32_t userData,bool isUnchained)238 int32_t DeviceStatusSrvProxy::DeactivateCoordination(int32_t userData, bool isUnchained)
239 {
240 CALL_DEBUG_ENTER;
241 MessageParcel data;
242 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
243 FI_HILOGE("Failed to write descriptor");
244 return ERR_INVALID_VALUE;
245 }
246 WRITEINT32(data, userData, ERR_INVALID_VALUE);
247 WRITEBOOL(data, isUnchained, ERR_INVALID_VALUE);
248 MessageParcel reply;
249 MessageOption option;
250 sptr<IRemoteObject> remote = Remote();
251 CHKPR(remote, RET_ERR);
252 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::STOP_COORDINATION),
253 data, reply, option);
254 if (ret != RET_OK) {
255 FI_HILOGE("Send request fail, ret:%{public}d", ret);
256 }
257 return ret;
258 }
259
UpdateDragStyle(DragCursorStyle style)260 int32_t DeviceStatusSrvProxy::UpdateDragStyle(DragCursorStyle style)
261 {
262 CALL_DEBUG_ENTER;
263 MessageParcel data;
264 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
265 FI_HILOGE("Failed to write descriptor");
266 return ERR_INVALID_VALUE;
267 }
268 WRITEINT32(data, static_cast<int32_t>(style), ERR_INVALID_VALUE);
269 MessageParcel reply;
270 MessageOption option;
271 sptr<IRemoteObject> remote = Remote();
272 CHKPR(remote, RET_ERR);
273 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::UPDATED_DRAG_STYLE),
274 data, reply, option);
275 if (ret != RET_OK) {
276 FI_HILOGE("Send request fail, ret:%{public}d", ret);
277 }
278 return ret;
279 }
280
GetDragTargetPid()281 int32_t DeviceStatusSrvProxy::GetDragTargetPid()
282 {
283 CALL_DEBUG_ENTER;
284 MessageParcel data;
285 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
286 FI_HILOGE("Failed to write descriptor");
287 return ERR_INVALID_VALUE;
288 }
289 MessageParcel reply;
290 MessageOption option;
291 sptr<IRemoteObject> remote = Remote();
292 CHKPR(remote, RET_ERR);
293 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::GET_DRAG_TARGET_PID),
294 data, reply, option);
295 if (ret != RET_OK) {
296 FI_HILOGE("Send request fail, ret:%{public}d", ret);
297 return RET_ERR;
298 }
299 int32_t pid = 0;
300 READINT32(reply, pid, IPC_PROXY_DEAD_OBJECT_ERR);
301 return pid;
302 }
303
GetUdKey(std::string & udKey)304 int32_t DeviceStatusSrvProxy::GetUdKey(std::string &udKey)
305 {
306 CALL_DEBUG_ENTER;
307 MessageParcel data;
308 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
309 FI_HILOGE("Failed to write descriptor");
310 return ERR_INVALID_VALUE;
311 }
312 MessageParcel reply;
313 MessageOption option;
314 sptr<IRemoteObject> remote = Remote();
315 CHKPR(remote, RET_ERR);
316 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::GET_DRAG_TARGET_UDKEY),
317 data, reply, option);
318 if (ret != RET_OK) {
319 FI_HILOGE("Send request fail, ret:%{public}d", ret);
320 return RET_ERR;
321 }
322 READSTRING(reply, udKey, IPC_PROXY_DEAD_OBJECT_ERR);
323 return RET_OK;
324 }
325
GetCoordinationState(int32_t userData,const std::string & deviceId)326 int32_t DeviceStatusSrvProxy::GetCoordinationState(int32_t userData, const std::string &deviceId)
327 {
328 CALL_DEBUG_ENTER;
329 MessageParcel data;
330 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
331 FI_HILOGE("Failed to write descriptor");
332 return ERR_INVALID_VALUE;
333 }
334 WRITEINT32(data, userData, ERR_INVALID_VALUE);
335 WRITESTRING(data, deviceId, ERR_INVALID_VALUE);
336 MessageParcel reply;
337 MessageOption option;
338 sptr<IRemoteObject> remote = Remote();
339 CHKPR(remote, RET_ERR);
340 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::GET_COORDINATION_STATE),
341 data, reply, option);
342 if (ret != RET_OK) {
343 FI_HILOGE("Send request fail, ret:%{public}d", ret);
344 }
345 return ret;
346 }
347
StartDrag(const DragData & dragData)348 int32_t DeviceStatusSrvProxy::StartDrag(const DragData &dragData)
349 {
350 CALL_DEBUG_ENTER;
351 MessageParcel data;
352 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
353 FI_HILOGE("Failed to write descriptor");
354 return ERR_INVALID_VALUE;
355 }
356 CHKPR(dragData.shadowInfo.pixelMap, RET_ERR);
357 if (!dragData.shadowInfo.pixelMap->Marshalling(data)) {
358 FI_HILOGE("Failed to marshalling pixelMap");
359 return ERR_INVALID_VALUE;
360 }
361 WRITEINT32(data, dragData.shadowInfo.x, ERR_INVALID_VALUE);
362 WRITEINT32(data, dragData.shadowInfo.y, ERR_INVALID_VALUE);
363 WRITEUINT8VECTOR(data, dragData.buffer, ERR_INVALID_VALUE);
364 WRITESTRING(data, dragData.udKey, ERR_INVALID_VALUE);
365 WRITEINT32(data, dragData.sourceType, ERR_INVALID_VALUE);
366 WRITEINT32(data, dragData.dragNum, ERR_INVALID_VALUE);
367 WRITEINT32(data, dragData.pointerId, ERR_INVALID_VALUE);
368 WRITEINT32(data, dragData.displayX, ERR_INVALID_VALUE);
369 WRITEINT32(data, dragData.displayY, ERR_INVALID_VALUE);
370 WRITEINT32(data, dragData.displayId, ERR_INVALID_VALUE);
371 WRITEBOOL(data, dragData.hasCanceledAnimation, ERR_INVALID_VALUE);
372 MessageParcel reply;
373 MessageOption option;
374 sptr<IRemoteObject> remote = Remote();
375 CHKPR(remote, RET_ERR);
376 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::START_DRAG),
377 data, reply, option);
378 if (ret != RET_OK) {
379 FI_HILOGE("Send request fail, ret:%{public}d", ret);
380 }
381 READINT32(reply, ret, IPC_PROXY_DEAD_OBJECT_ERR);
382 return ret;
383 }
384
StopDrag(DragResult result,bool hasCustomAnimation)385 int32_t DeviceStatusSrvProxy::StopDrag(DragResult result, bool hasCustomAnimation)
386 {
387 CALL_DEBUG_ENTER;
388 MessageParcel data;
389 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
390 FI_HILOGE("Failed to write descriptor");
391 return ERR_INVALID_VALUE;
392 }
393 if (result < DragResult::DRAG_SUCCESS || result > DragResult::DRAG_EXCEPTION) {
394 FI_HILOGE("Invalid result:%{public}d", static_cast<int32_t>(result));
395 return RET_ERR;
396 }
397 WRITEINT32(data, static_cast<int32_t>(result), ERR_INVALID_VALUE);
398 WRITEBOOL(data, hasCustomAnimation, ERR_INVALID_VALUE);
399 MessageParcel reply;
400 MessageOption option;
401 sptr<IRemoteObject> remote = Remote();
402 CHKPR(remote, RET_ERR);
403 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::STOP_DRAG),
404 data, reply, option);
405 if (ret != RET_OK) {
406 FI_HILOGE("Send request fail, ret:%{public}d", ret);
407 }
408 READINT32(reply, ret, IPC_PROXY_DEAD_OBJECT_ERR);
409 return ret;
410 }
411
AllocSocketFd(const std::string & programName,int32_t moduleType,int32_t & socketFd,int32_t & tokenType)412 int32_t DeviceStatusSrvProxy::AllocSocketFd(const std::string &programName, int32_t moduleType,
413 int32_t &socketFd, int32_t &tokenType)
414 {
415 CALL_DEBUG_ENTER;
416 MessageParcel data;
417 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
418 FI_HILOGE("Failed to write descriptor");
419 return ERR_INVALID_VALUE;
420 }
421 WRITEINT32(data, moduleType, ERR_INVALID_VALUE);
422 WRITESTRING(data, programName, ERR_INVALID_VALUE);
423 MessageParcel reply;
424 MessageOption option;
425 sptr<IRemoteObject> remote = Remote();
426 CHKPR(remote, RET_ERR);
427 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::ALLOC_SOCKET_FD),
428 data, reply, option);
429 if (ret != RET_OK) {
430 FI_HILOGE("Send request failed, ret:%{public}d", ret);
431 return RET_ERR;
432 }
433 socketFd = reply.ReadFileDescriptor();
434 if (socketFd < RET_OK) {
435 FI_HILOGE("Read file descriptor failed, fd:%{public}d", socketFd);
436 return IPC_PROXY_DEAD_OBJECT_ERR;
437 }
438 READINT32(reply, tokenType, IPC_PROXY_DEAD_OBJECT_ERR);
439 FI_HILOGD("socketFd:%{public}d, tokenType:%{public}d", socketFd, tokenType);
440 return RET_OK;
441 }
442
AddDraglistener()443 int32_t DeviceStatusSrvProxy::AddDraglistener()
444 {
445 CALL_DEBUG_ENTER;
446 MessageParcel data;
447 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
448 FI_HILOGE("Failed to write descriptor");
449 return ERR_INVALID_VALUE;
450 }
451 MessageParcel reply;
452 MessageOption option;
453 sptr<IRemoteObject> remote = Remote();
454 CHKPR(remote, RET_ERR);
455 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::REGISTER_DRAG_MONITOR),
456 data, reply, option);
457 if (ret != RET_OK) {
458 FI_HILOGE("Send request failed, ret:%{public}d", ret);
459 }
460 return ret;
461 }
462
RemoveDraglistener()463 int32_t DeviceStatusSrvProxy::RemoveDraglistener()
464 {
465 CALL_DEBUG_ENTER;
466 MessageParcel data;
467 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
468 FI_HILOGE("Failed to write descriptor");
469 return ERR_INVALID_VALUE;
470 }
471 MessageParcel reply;
472 MessageOption option;
473 sptr<IRemoteObject> remote = Remote();
474 CHKPR(remote, RET_ERR);
475 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::UNREGISTER_DRAG_MONITOR),
476 data, reply, option);
477 if (ret != RET_OK) {
478 FI_HILOGE("Send request failed, ret:%{public}d", ret);
479 }
480 return ret;
481 }
482
SetDragWindowVisible(bool visible)483 int32_t DeviceStatusSrvProxy::SetDragWindowVisible(bool visible)
484 {
485 CALL_DEBUG_ENTER;
486 MessageParcel data;
487 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
488 FI_HILOGE("Failed to write descriptor");
489 return ERR_INVALID_VALUE;
490 }
491 WRITEBOOL(data, visible, ERR_INVALID_VALUE);
492 MessageParcel reply;
493 MessageOption option;
494 sptr<IRemoteObject> remote = Remote();
495 CHKPR(remote, RET_ERR);
496 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::SET_DRAG_WINDOW_VISIBLE),
497 data, reply, option);
498 if (ret != RET_OK) {
499 FI_HILOGE("Send request failed, ret:%{public}d", ret);
500 }
501 return ret;
502 }
503
GetShadowOffset(int32_t & offsetX,int32_t & offsetY,int32_t & width,int32_t & height)504 int32_t DeviceStatusSrvProxy::GetShadowOffset(int32_t& offsetX, int32_t& offsetY, int32_t& width, int32_t& height)
505 {
506 CALL_DEBUG_ENTER;
507 MessageParcel data;
508 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
509 FI_HILOGE("Failed to write descriptor");
510 return ERR_INVALID_VALUE;
511 }
512 MessageParcel reply;
513 MessageOption option;
514 sptr<IRemoteObject> remote = Remote();
515 CHKPR(remote, RET_ERR);
516 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::GET_SHADOW_OFFSET),
517 data, reply, option);
518 if (ret != RET_OK) {
519 FI_HILOGE("Send request failed, ret:%{public}d", ret);
520 }
521 READINT32(reply, offsetX, IPC_PROXY_DEAD_OBJECT_ERR);
522 READINT32(reply, offsetY, IPC_PROXY_DEAD_OBJECT_ERR);
523 READINT32(reply, width, IPC_PROXY_DEAD_OBJECT_ERR);
524 READINT32(reply, height, IPC_PROXY_DEAD_OBJECT_ERR);
525 FI_HILOGD("offsetX:%{public}d, offsetY:%{public}d, width:%{public}d, height:%{public}d",
526 offsetX, offsetY, width, height);
527 return ret;
528 }
529
UpdateShadowPic(const ShadowInfo & shadowInfo)530 int32_t DeviceStatusSrvProxy::UpdateShadowPic(const ShadowInfo &shadowInfo)
531 {
532 CALL_DEBUG_ENTER;
533 MessageParcel data;
534 if (!data.WriteInterfaceToken(DeviceStatusSrvProxy::GetDescriptor())) {
535 FI_HILOGE("Failed to write descriptor");
536 return ERR_INVALID_VALUE;
537 }
538 CHKPR(shadowInfo.pixelMap, RET_ERR);
539 if (!shadowInfo.pixelMap->Marshalling(data)) {
540 FI_HILOGE("Failed to marshalling pixelMap");
541 return ERR_INVALID_VALUE;
542 }
543 WRITEINT32(data, shadowInfo.x, ERR_INVALID_VALUE);
544 WRITEINT32(data, shadowInfo.y, ERR_INVALID_VALUE);
545 MessageParcel reply;
546 MessageOption option;
547 sptr<IRemoteObject> remote = Remote();
548 CHKPR(remote, RET_ERR);
549 int32_t ret = remote->SendRequest(static_cast<uint32_t>(DeviceInterfaceCode::UPDATE_SHADOW_PIC),
550 data, reply, option);
551 if (ret != RET_OK) {
552 FI_HILOGE("Send request fail, ret:%{public}d", ret);
553 }
554 return ret;
555 }
556 } // namespace DeviceStatus
557 } // namespace Msdp
558 } // namespace OHOS
559