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_stub.h"
17
18 #include "message_parcel.h"
19 #include "pixel_map.h"
20
21 #include "devicestatus_callback_proxy.h"
22 #include "devicestatus_common.h"
23 #include "devicestatus_define.h"
24 #include "devicestatus_service.h"
25 #include "devicestatus_srv_proxy.h"
26 #include "fi_log.h"
27 #include "stationary_callback.h"
28 #include "stationary_data.h"
29 #include "util.h"
30
31 namespace OHOS {
32 namespace Msdp {
33 namespace DeviceStatus {
34 namespace {
35 constexpr OHOS::HiviewDFX::HiLogLabel LABEL { LOG_CORE, MSDP_DOMAIN_ID, "DeviceStatusSrvStub" };
36 } // namespace
37
DeviceStatusSrvStub()38 DeviceStatusSrvStub::DeviceStatusSrvStub()
39 {
40 mapConnFunc_ = {
41 {static_cast<uint32_t>(DeviceInterfaceCode::DEVICESTATUS_SUBSCRIBE),
42 &DeviceStatusSrvStub::SubscribeStub},
43 {static_cast<uint32_t>(DeviceInterfaceCode::DEVICESTATUS_UNSUBSCRIBE),
44 &DeviceStatusSrvStub::UnsubscribeStub},
45 {static_cast<uint32_t>(DeviceInterfaceCode::DEVICESTATUS_GETCACHE),
46 &DeviceStatusSrvStub::GetLatestDeviceStatusDataStub},
47 {static_cast<uint32_t>(DeviceInterfaceCode::REGISTER_COORDINATION_MONITOR),
48 &DeviceStatusSrvStub::RegisterCoordinationMonitorStub},
49 {static_cast<uint32_t>(DeviceInterfaceCode::UNREGISTER_COORDINATION_MONITOR),
50 &DeviceStatusSrvStub::UnregisterCoordinationMonitorStub},
51 {static_cast<uint32_t>(DeviceInterfaceCode::PREPARE_COORDINATION),
52 &DeviceStatusSrvStub::PrepareCoordinationStub},
53 {static_cast<uint32_t>(DeviceInterfaceCode::UNPREPARE_COORDINATION),
54 &DeviceStatusSrvStub::UnPrepareCoordinationStub},
55 {static_cast<uint32_t>(DeviceInterfaceCode::START_COORDINATION),
56 &DeviceStatusSrvStub::ActivateCoordinationStub},
57 {static_cast<uint32_t>(DeviceInterfaceCode::STOP_COORDINATION),
58 &DeviceStatusSrvStub::DeactivateCoordinationStub},
59 {static_cast<uint32_t>(DeviceInterfaceCode::GET_COORDINATION_STATE),
60 &DeviceStatusSrvStub::GetCoordinationStateStub},
61 {static_cast<uint32_t>(DeviceInterfaceCode::ALLOC_SOCKET_FD),
62 &DeviceStatusSrvStub::HandleAllocSocketFdStub},
63 {static_cast<uint32_t>(DeviceInterfaceCode::START_DRAG),
64 &DeviceStatusSrvStub::StartDragStub},
65 {static_cast<uint32_t>(DeviceInterfaceCode::STOP_DRAG),
66 &DeviceStatusSrvStub::StopDragStub},
67 {static_cast<uint32_t>(DeviceInterfaceCode::UPDATED_DRAG_STYLE),
68 &DeviceStatusSrvStub::UpdateDragStyleStub},
69 {static_cast<uint32_t>(DeviceInterfaceCode::GET_DRAG_TARGET_PID),
70 &DeviceStatusSrvStub::GetDragTargetPidStub},
71 {static_cast<uint32_t>(DeviceInterfaceCode::GET_DRAG_TARGET_UDKEY),
72 &DeviceStatusSrvStub::GetUdKeyStub},
73 {static_cast<uint32_t>(DeviceInterfaceCode::REGISTER_DRAG_MONITOR),
74 &DeviceStatusSrvStub::AddDraglistenerStub},
75 {static_cast<uint32_t>(DeviceInterfaceCode::UNREGISTER_DRAG_MONITOR),
76 &DeviceStatusSrvStub::RemoveDraglistenerStub},
77 {static_cast<uint32_t>(DeviceInterfaceCode::SET_DRAG_WINDOW_VISIBLE),
78 &DeviceStatusSrvStub::SetDragWindowVisibleStub},
79 {static_cast<uint32_t>(DeviceInterfaceCode::GET_SHADOW_OFFSET),
80 &DeviceStatusSrvStub::GetShadowOffsetStub},
81 {static_cast<uint32_t>(DeviceInterfaceCode::UPDATE_SHADOW_PIC),
82 &DeviceStatusSrvStub::UpdateShadowPicStub}
83 };
84 }
85
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)86 int32_t DeviceStatusSrvStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
87 MessageOption &option)
88 {
89 FI_HILOGD("cmd:%{public}d, flags:%{public}d", code, option.GetFlags());
90 std::u16string descriptor = DeviceStatusSrvStub::GetDescriptor();
91 std::u16string remoteDescriptor = data.ReadInterfaceToken();
92 if (descriptor != remoteDescriptor) {
93 FI_HILOGE("DeviceStatusSrvStub::OnRemoteRequest failed, descriptor is not matched");
94 return E_DEVICESTATUS_GET_SERVICE_FAILED;
95 }
96 auto it = mapConnFunc_.find(code);
97 if (it != mapConnFunc_.end()) {
98 return (this->*it->second)(data, reply);
99 }
100 FI_HILOGE("Unknown code:%{public}u", code);
101 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
102 }
103
SubscribeStub(MessageParcel & data,MessageParcel & reply)104 int32_t DeviceStatusSrvStub::SubscribeStub(MessageParcel& data, MessageParcel& reply)
105 {
106 CALL_DEBUG_ENTER;
107 int32_t type = -1;
108 READINT32(data, type, E_DEVICESTATUS_READ_PARCEL_ERROR);
109 FI_HILOGD("Read type successfully");
110 int32_t event = -1;
111 READINT32(data, event, E_DEVICESTATUS_READ_PARCEL_ERROR);
112 FI_HILOGD("Read event successfully");
113 FI_HILOGD("event:%{public}d", event);
114 int32_t latency = -1;
115 READINT32(data, latency, E_DEVICESTATUS_READ_PARCEL_ERROR);
116 FI_HILOGD("Read latency successfully");
117 sptr<IRemoteObject> obj = data.ReadRemoteObject();
118 CHKPR(obj, E_DEVICESTATUS_READ_PARCEL_ERROR);
119 FI_HILOGI("Read remote obj successfully");
120 sptr<IRemoteDevStaCallback> callback = iface_cast<IRemoteDevStaCallback>(obj);
121 CHKPR(callback, E_DEVICESTATUS_READ_PARCEL_ERROR);
122 FI_HILOGI("Read callback successfully");
123 Subscribe(static_cast<Type>(type), static_cast<ActivityEvent>(event),
124 static_cast<ReportLatencyNs>(latency), callback);
125 return RET_OK;
126 }
127
UnsubscribeStub(MessageParcel & data,MessageParcel & reply)128 int32_t DeviceStatusSrvStub::UnsubscribeStub(MessageParcel& data, MessageParcel& reply)
129 {
130 CALL_DEBUG_ENTER;
131 int32_t type = -1;
132 READINT32(data, type, E_DEVICESTATUS_READ_PARCEL_ERROR);
133 int32_t event = -1;
134 READINT32(data, event, E_DEVICESTATUS_READ_PARCEL_ERROR);
135 FI_HILOGE("UNevent:%{public}d", event);
136 sptr<IRemoteObject> obj = data.ReadRemoteObject();
137 CHKPR(obj, E_DEVICESTATUS_READ_PARCEL_ERROR);
138 sptr<IRemoteDevStaCallback> callback = iface_cast<IRemoteDevStaCallback>(obj);
139 CHKPR(callback, E_DEVICESTATUS_READ_PARCEL_ERROR);
140 Unsubscribe(static_cast<Type>(type), static_cast<ActivityEvent>(event), callback);
141 return RET_OK;
142 }
143
GetLatestDeviceStatusDataStub(MessageParcel & data,MessageParcel & reply)144 int32_t DeviceStatusSrvStub::GetLatestDeviceStatusDataStub(MessageParcel& data, MessageParcel& reply)
145 {
146 CALL_DEBUG_ENTER;
147 int32_t type = -1;
148 READINT32(data, type, E_DEVICESTATUS_READ_PARCEL_ERROR);
149 Data devicestatusData = GetCache(static_cast<Type>(type));
150 FI_HILOGD("devicestatusData.type:%{public}d", devicestatusData.type);
151 FI_HILOGD("devicestatusData.value:%{public}d", devicestatusData.value);
152 WRITEINT32(reply, devicestatusData.type, E_DEVICESTATUS_WRITE_PARCEL_ERROR);
153 WRITEINT32(reply, devicestatusData.value, E_DEVICESTATUS_WRITE_PARCEL_ERROR);
154 return RET_OK;
155 }
156
RegisterCoordinationMonitorStub(MessageParcel & data,MessageParcel & reply)157 int32_t DeviceStatusSrvStub::RegisterCoordinationMonitorStub(MessageParcel& data, MessageParcel& reply)
158 {
159 CALL_DEBUG_ENTER;
160 int32_t ret = RegisterCoordinationListener();
161 if (ret != RET_OK) {
162 FI_HILOGE("Call registerCoordinationEvent failed, ret:%{public}d", ret);
163 }
164 return ret;
165 }
166
UnregisterCoordinationMonitorStub(MessageParcel & data,MessageParcel & reply)167 int32_t DeviceStatusSrvStub::UnregisterCoordinationMonitorStub(MessageParcel& data, MessageParcel& reply)
168 {
169 CALL_DEBUG_ENTER;
170 int32_t ret = UnregisterCoordinationListener();
171 if (ret != RET_OK) {
172 FI_HILOGE("Call unregisterCoordinationEvent failed, ret:%{public}d", ret);
173 }
174 return ret;
175 }
176
PrepareCoordinationStub(MessageParcel & data,MessageParcel & reply)177 int32_t DeviceStatusSrvStub::PrepareCoordinationStub(MessageParcel& data, MessageParcel& reply)
178 {
179 CALL_DEBUG_ENTER;
180 int32_t userData = 0;
181 READINT32(data, userData, E_DEVICESTATUS_READ_PARCEL_ERROR);
182 int32_t ret = PrepareCoordination(userData);
183 if (ret != RET_OK) {
184 FI_HILOGE("Call prepareCoordination failed, ret:%{public}d", ret);
185 }
186 return ret;
187 }
188
UnPrepareCoordinationStub(MessageParcel & data,MessageParcel & reply)189 int32_t DeviceStatusSrvStub::UnPrepareCoordinationStub(MessageParcel& data, MessageParcel& reply)
190 {
191 CALL_DEBUG_ENTER;
192 int32_t userData = 0;
193 READINT32(data, userData, E_DEVICESTATUS_READ_PARCEL_ERROR);
194 int32_t ret = UnprepareCoordination(userData);
195 if (ret != RET_OK) {
196 FI_HILOGE("Call unprepareCoordination failed, ret:%{public}d", ret);
197 }
198 return ret;
199 }
200
ActivateCoordinationStub(MessageParcel & data,MessageParcel & reply)201 int32_t DeviceStatusSrvStub::ActivateCoordinationStub(MessageParcel& data, MessageParcel& reply)
202 {
203 CALL_DEBUG_ENTER;
204 int32_t userData = 0;
205 READINT32(data, userData, E_DEVICESTATUS_READ_PARCEL_ERROR);
206 std::string remoteNetworkId;
207 READSTRING(data, remoteNetworkId, E_DEVICESTATUS_READ_PARCEL_ERROR);
208 int32_t startDeviceId = 0;
209 READINT32(data, startDeviceId, E_DEVICESTATUS_READ_PARCEL_ERROR);
210 int32_t ret = ActivateCoordination(userData, remoteNetworkId, startDeviceId);
211 if (ret != RET_OK) {
212 FI_HILOGE("Call ActivateCoordination failed, ret:%{public}d", ret);
213 }
214 return ret;
215 }
216
DeactivateCoordinationStub(MessageParcel & data,MessageParcel & reply)217 int32_t DeviceStatusSrvStub::DeactivateCoordinationStub(MessageParcel& data, MessageParcel& reply)
218 {
219 CALL_DEBUG_ENTER;
220 int32_t userData = 0;
221 READINT32(data, userData, E_DEVICESTATUS_READ_PARCEL_ERROR);
222 bool isUnchained = false;
223 READBOOL(data, isUnchained, E_DEVICESTATUS_READ_PARCEL_ERROR);
224 int32_t ret = DeactivateCoordination(userData, isUnchained);
225 if (ret != RET_OK) {
226 FI_HILOGE("Call DeactivateCoordination failed, ret:%{public}d", ret);
227 }
228 return ret;
229 }
230
GetCoordinationStateStub(MessageParcel & data,MessageParcel & reply)231 int32_t DeviceStatusSrvStub::GetCoordinationStateStub(MessageParcel& data, MessageParcel& reply)
232 {
233 CALL_DEBUG_ENTER;
234 int32_t userData = 0;
235 READINT32(data, userData, E_DEVICESTATUS_READ_PARCEL_ERROR);
236 std::string deviceId;
237 READSTRING(data, deviceId, E_DEVICESTATUS_READ_PARCEL_ERROR);
238 int32_t ret = GetCoordinationState(userData, deviceId);
239 if (ret != RET_OK) {
240 FI_HILOGE("Call RegisterCoordinationEvent failed, ret:%{public}d", ret);
241 }
242 return ret;
243 }
244
UpdateDragStyleStub(MessageParcel & data,MessageParcel & reply)245 int32_t DeviceStatusSrvStub::UpdateDragStyleStub(MessageParcel& data, MessageParcel& reply)
246 {
247 CALL_DEBUG_ENTER;
248 int32_t style = 0;
249 READINT32(data, style, E_DEVICESTATUS_READ_PARCEL_ERROR);
250 int32_t ret = UpdateDragStyle(static_cast<DragCursorStyle>(style));
251 if (ret != RET_OK) {
252 FI_HILOGE("Call UpdateDragStyle failed, ret:%{public}d", ret);
253 }
254 return ret;
255 }
256
GetDragTargetPidStub(MessageParcel & data,MessageParcel & reply)257 int32_t DeviceStatusSrvStub::GetDragTargetPidStub(MessageParcel& data, MessageParcel& reply)
258 {
259 CALL_DEBUG_ENTER;
260 int32_t pid = GetDragTargetPid();
261 WRITEINT32(reply, pid, IPC_STUB_WRITE_PARCEL_ERR);
262 return RET_OK;
263 }
264
GetUdKeyStub(MessageParcel & data,MessageParcel & reply)265 int32_t DeviceStatusSrvStub::GetUdKeyStub(MessageParcel& data, MessageParcel& reply)
266 {
267 CALL_DEBUG_ENTER;
268 std::string udKey;
269 int32_t ret = GetUdKey(udKey);
270 if (ret != RET_OK) {
271 FI_HILOGE("Get udKey failed, ret:%{public}d", ret);
272 }
273 WRITESTRING(reply, udKey, IPC_STUB_WRITE_PARCEL_ERR);
274 FI_HILOGD("Target udKey:%{public}s", udKey.c_str());
275 return RET_OK;
276 }
277
HandleAllocSocketFdStub(MessageParcel & data,MessageParcel & reply)278 int32_t DeviceStatusSrvStub::HandleAllocSocketFdStub(MessageParcel& data, MessageParcel& reply)
279 {
280 int32_t pid = GetCallingPid();
281 if (!IsRunning()) {
282 FI_HILOGE("Service is not running, pid:%{public}d, go switch default", pid);
283 return SERVICE_NOT_RUNNING;
284 }
285 int32_t moduleId = 0;
286 READINT32(data, moduleId, E_DEVICESTATUS_READ_PARCEL_ERROR);
287 std::string clientName;
288 READSTRING(data, clientName, E_DEVICESTATUS_READ_PARCEL_ERROR);
289
290 int32_t clientFd = -1;
291 uint32_t tokenId = GetCallingTokenID();
292 int32_t tokenType = AccessTokenKit::GetTokenTypeFlag(tokenId);
293 int32_t ret = AllocSocketFd(clientName, moduleId, clientFd, tokenType);
294 if (ret != RET_OK) {
295 FI_HILOGE("AllocSocketFd failed, pid:%{public}d, go switch default", pid);
296 if (clientFd >= 0) {
297 if (close(clientFd) < 0) {
298 FI_HILOGE("Close client fd failed, error:%{public}s, clientFd:%{public}d", strerror(errno), clientFd);
299 }
300 }
301 return ret;
302 }
303
304 if (!reply.WriteFileDescriptor(clientFd)) {
305 FI_HILOGE("Write file descriptor failed");
306 if (close(clientFd) < 0) {
307 FI_HILOGE("Close client fd failed, error:%{public}s, clientFd:%{public}d", strerror(errno), clientFd);
308 }
309 return IPC_STUB_WRITE_PARCEL_ERR;
310 }
311
312 WRITEINT32(reply, tokenType, IPC_STUB_WRITE_PARCEL_ERR);
313 FI_HILOGD("Send clientFd to client, clientFd:%{public}d, tokenType:%{public}d", clientFd, tokenType);
314 if (close(clientFd) < 0) {
315 FI_HILOGE("Close client fd failed, error:%{public}s, clientFd:%{public}d", strerror(errno), clientFd);
316 }
317 return RET_OK;
318 }
319
StartDragStub(MessageParcel & data,MessageParcel & reply)320 int32_t DeviceStatusSrvStub::StartDragStub(MessageParcel& data, MessageParcel& reply)
321 {
322 CALL_DEBUG_ENTER;
323 auto pixelMap = OHOS::Media::PixelMap::Unmarshalling(data);
324 CHKPR(pixelMap, RET_ERR);
325 DragData dragData;
326 dragData.shadowInfo.pixelMap = std::shared_ptr<OHOS::Media::PixelMap> (pixelMap);
327 READINT32(data, dragData.shadowInfo.x, E_DEVICESTATUS_READ_PARCEL_ERROR);
328 READINT32(data, dragData.shadowInfo.y, E_DEVICESTATUS_READ_PARCEL_ERROR);
329 READUINT8VECTOR(data, dragData.buffer, E_DEVICESTATUS_READ_PARCEL_ERROR);
330 READSTRING(data, dragData.udKey, E_DEVICESTATUS_READ_PARCEL_ERROR);
331 READINT32(data, dragData.sourceType, E_DEVICESTATUS_READ_PARCEL_ERROR);
332 READINT32(data, dragData.dragNum, E_DEVICESTATUS_READ_PARCEL_ERROR);
333 READINT32(data, dragData.pointerId, E_DEVICESTATUS_READ_PARCEL_ERROR);
334 READINT32(data, dragData.displayX, E_DEVICESTATUS_READ_PARCEL_ERROR);
335 READINT32(data, dragData.displayY, E_DEVICESTATUS_READ_PARCEL_ERROR);
336 READINT32(data, dragData.displayId, E_DEVICESTATUS_READ_PARCEL_ERROR);
337 READBOOL(data, dragData.hasCanceledAnimation, E_DEVICESTATUS_READ_PARCEL_ERROR);
338 if ((dragData.shadowInfo.x > 0) || (dragData.shadowInfo.y > 0) ||
339 (dragData.shadowInfo.x < -dragData.shadowInfo.pixelMap->GetWidth()) ||
340 (dragData.shadowInfo.y < -dragData.shadowInfo.pixelMap->GetHeight())) {
341 FI_HILOGE("Invalid parameter, shadowInfox:%{public}d, shadowInfoy:%{public}d",
342 dragData.shadowInfo.x, dragData.shadowInfo.y);
343 return RET_ERR;
344 }
345 if ((dragData.dragNum <= 0) || (dragData.buffer.size() > MAX_BUFFER_SIZE) ||
346 (dragData.displayX < 0) || (dragData.displayY < 0)) {
347 FI_HILOGE("Invalid parameter, dragNum:%{public}d, bufferSize:%{public}zu, "
348 "displayX:%{public}d, displayY:%{public}d",
349 dragData.dragNum, dragData.buffer.size(), dragData.displayX, dragData.displayY);
350 return RET_ERR;
351 }
352 int32_t ret = StartDrag(dragData);
353 if (ret != RET_OK) {
354 FI_HILOGE("Call StartDrag failed, ret:%{public}d", ret);
355 }
356 WRITEINT32(reply, ret, IPC_STUB_WRITE_PARCEL_ERR);
357 return ret;
358 }
359
StopDragStub(MessageParcel & data,MessageParcel & reply)360 int32_t DeviceStatusSrvStub::StopDragStub(MessageParcel& data, MessageParcel& reply)
361 {
362 CALL_DEBUG_ENTER;
363 int32_t result = 0;
364 READINT32(data, result, E_DEVICESTATUS_READ_PARCEL_ERROR);
365 if ((result < static_cast<int32_t>(DragResult::DRAG_SUCCESS)) ||
366 (result > static_cast<int32_t>(DragResult::DRAG_EXCEPTION))) {
367 FI_HILOGE("Invalid result:%{public}d", result);
368 return RET_ERR;
369 }
370 bool hasCustomAnimation = false;
371 READBOOL(data, hasCustomAnimation, E_DEVICESTATUS_READ_PARCEL_ERROR);
372 int32_t ret = StopDrag(static_cast<DragResult>(result), hasCustomAnimation);
373 if (ret != RET_OK) {
374 FI_HILOGE("Call StopDrag failed, ret:%{public}d", ret);
375 }
376 WRITEINT32(reply, ret, IPC_STUB_WRITE_PARCEL_ERR);
377 return ret;
378 }
379
AddDraglistenerStub(MessageParcel & data,MessageParcel & reply)380 int32_t DeviceStatusSrvStub::AddDraglistenerStub(MessageParcel& data, MessageParcel& reply)
381 {
382 CALL_DEBUG_ENTER;
383 int32_t ret = AddDraglistener();
384 if (ret != RET_OK) {
385 FI_HILOGE("Call AddDraglistener failed, ret:%{public}d", ret);
386 }
387 return ret;
388 }
389
RemoveDraglistenerStub(MessageParcel & data,MessageParcel & reply)390 int32_t DeviceStatusSrvStub::RemoveDraglistenerStub(MessageParcel& data, MessageParcel& reply)
391 {
392 CALL_DEBUG_ENTER;
393 int32_t ret = RemoveDraglistener();
394 if (ret != RET_OK) {
395 FI_HILOGE("Call RemoveDraglistener failed, ret:%{public}d", ret);
396 }
397 return ret;
398 }
399
SetDragWindowVisibleStub(MessageParcel & data,MessageParcel & reply)400 int32_t DeviceStatusSrvStub::SetDragWindowVisibleStub(MessageParcel& data, MessageParcel& reply)
401 {
402 CALL_DEBUG_ENTER;
403 bool visible = false;
404 READBOOL(data, visible, E_DEVICESTATUS_READ_PARCEL_ERROR);
405 int32_t ret = SetDragWindowVisible(visible);
406 if (ret != RET_OK) {
407 FI_HILOGE("Call SetDragWindowVisible failed, ret:%{public}d", ret);
408 }
409 return ret;
410 }
411
GetShadowOffsetStub(MessageParcel & data,MessageParcel & reply)412 int32_t DeviceStatusSrvStub::GetShadowOffsetStub(MessageParcel& data, MessageParcel& reply)
413 {
414 CALL_DEBUG_ENTER;
415 int32_t offsetX = 0;
416 int32_t offsetY = 0;
417 int32_t width = 0;
418 int32_t height = 0;
419 int32_t ret = GetShadowOffset(offsetX, offsetY, width, height);
420 if (ret != RET_OK) {
421 FI_HILOGE("Call GetShadowOffsetStub failed, ret:%{public}d", ret);
422 }
423 WRITEINT32(reply, offsetX, IPC_STUB_WRITE_PARCEL_ERR);
424 WRITEINT32(reply, offsetY, IPC_STUB_WRITE_PARCEL_ERR);
425 WRITEINT32(reply, width, IPC_STUB_WRITE_PARCEL_ERR);
426 WRITEINT32(reply, height, IPC_STUB_WRITE_PARCEL_ERR);
427 return ret;
428 }
429
UpdateShadowPicStub(MessageParcel & data,MessageParcel & reply)430 int32_t DeviceStatusSrvStub::UpdateShadowPicStub(MessageParcel& data, MessageParcel& reply)
431 {
432 CALL_DEBUG_ENTER;
433 auto pixelMap = Media::PixelMap::Unmarshalling(data);
434 CHKPR(pixelMap, RET_ERR);
435 ShadowInfo shadowInfo;
436 shadowInfo.pixelMap = std::shared_ptr<OHOS::Media::PixelMap>(pixelMap);
437 READINT32(data, shadowInfo.x, E_DEVICESTATUS_READ_PARCEL_ERROR);
438 READINT32(data, shadowInfo.y, E_DEVICESTATUS_READ_PARCEL_ERROR);
439 if ((shadowInfo.x > 0) || (shadowInfo.y > 0) ||
440 (shadowInfo.x < -shadowInfo.pixelMap->GetWidth()) ||
441 (shadowInfo.y < -shadowInfo.pixelMap->GetHeight())) {
442 FI_HILOGE("Invalid parameter, shadowInfox:%{public}d, shadowInfoy:%{public}d",
443 shadowInfo.x, shadowInfo.y);
444 return RET_ERR;
445 }
446 int32_t ret = UpdateShadowPic(shadowInfo);
447 if (ret != RET_OK) {
448 FI_HILOGE("Call Update shadow picture failed, ret:%{public}d", ret);
449 }
450 return ret;
451 }
452 } // namespace DeviceStatus
453 } // namespace Msdp
454 } // namespace OHOS