1 /*
2 * Copyright (c) 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 "session/container/include/zidl/session_stage_stub.h"
17 #include "session/container/include/zidl/session_stage_ipc_interface_code.h"
18
19 #include <ipc_types.h>
20 #include <transaction/rs_transaction.h>
21
22 #include "window_manager_hilog.h"
23 #include "wm_common.h"
24
25 namespace OHOS::Rosen {
26 namespace {
27 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionStageStub"};
28 constexpr size_t MAX_PARCEL_CAPACITY = 100 * 1024 * 1024; // 100M
29 constexpr size_t CAPACITY_THRESHOLD = 8 * 100 * 1024; // 800k
30 constexpr size_t RESERVED_SPACE = 4 * 1024; // 4k
31
CalculateDumpInfoSize(const std::vector<std::string> & infos)32 bool CalculateDumpInfoSize(const std::vector<std::string>& infos)
33 {
34 size_t dataSize = 0;
35 for (const auto& info : infos) {
36 auto infoSize = info.length();
37 if (MAX_PARCEL_CAPACITY - dataSize < infoSize) {
38 return false;
39 }
40
41 dataSize += info.length();
42 }
43 return dataSize + RESERVED_SPACE <= CAPACITY_THRESHOLD;
44 }
45
WriteLittleStringVector(const std::vector<std::string> & infos,MessageParcel & reply)46 bool WriteLittleStringVector(const std::vector<std::string>& infos, MessageParcel& reply)
47 {
48 TLOGD(WmsLogTag::WMS_UIEXT, "entry");
49 reply.SetMaxCapacity(CAPACITY_THRESHOLD);
50 if (!reply.WriteStringVector(infos)) {
51 TLOGE(WmsLogTag::WMS_UIEXT, "write infos failed");
52 return false;
53 }
54 return true;
55 }
56
WriteLargeStringVector(const std::vector<std::string> & infos,MessageParcel & reply)57 bool WriteLargeStringVector(const std::vector<std::string>& infos, MessageParcel& reply)
58 {
59 Parcel writeParcel;
60 writeParcel.SetMaxCapacity(MAX_PARCEL_CAPACITY);
61 if (!writeParcel.WriteInt32(static_cast<int32_t>(infos.size()))) {
62 TLOGE(WmsLogTag::WMS_UIEXT, "write infosSize failed");
63 return false;
64 }
65
66 for (const auto& info : infos) {
67 if (!writeParcel.WriteString(info)) {
68 TLOGE(WmsLogTag::WMS_UIEXT, "write info failed");
69 return false;
70 }
71 }
72
73 size_t dataSize = writeParcel.GetDataSize();
74 TLOGD(WmsLogTag::WMS_UIEXT, "dataSize: %{public}zu", dataSize);
75 if (!reply.WriteInt32(static_cast<int32_t>(dataSize))) {
76 TLOGE(WmsLogTag::WMS_UIEXT, "write dataSize failed");
77 return false;
78 }
79
80 if (!reply.WriteRawData(
81 reinterpret_cast<uint8_t*>(writeParcel.GetData()), dataSize)) {
82 TLOGE(WmsLogTag::WMS_UIEXT, "write rawData failed");
83 return false;
84 }
85
86 return true;
87 }
88 }
89
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)90 int SessionStageStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
91 {
92 WLOGFD("Scene session stage on remote request!, code: %{public}u", code);
93 if (data.ReadInterfaceToken() != GetDescriptor()) {
94 WLOGFE("Failed to check interface token!");
95 return ERR_TRANSACTION_FAILED;
96 }
97
98 switch (code) {
99 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_ACTIVE):
100 return HandleSetActive(data, reply);
101 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SIZE_CHANGE):
102 return HandleUpdateRect(data, reply);
103 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DENSITY_CHANGE):
104 return HandleUpdateDensity(data, reply);
105 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_ORIENTATION_CHANGE):
106 return HandleUpdateOrientation(data, reply);
107 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_HANDLE_BACK_EVENT):
108 return HandleBackEventInner(data, reply);
109 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DESTROY):
110 return HandleNotifyDestroy(data, reply);
111 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_FOCUS_CHANGE):
112 return HandleUpdateFocus(data, reply);
113 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TRANSFER_COMPONENT_DATA):
114 return HandleNotifyTransferComponentData(data, reply);
115 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TRANSFER_COMPONENT_DATA_SYNC):
116 return HandleNotifyTransferComponentDataSync(data, reply);
117 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_OCCUPIED_AREA_CHANGE_INFO):
118 return HandleNotifyOccupiedAreaChange(data, reply);
119 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_UPDATE_AVOID_AREA):
120 return HandleUpdateAvoidArea(data, reply);
121 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SCREEN_SHOT):
122 return HandleNotifyScreenshot(data, reply);
123 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_DUMP_SESSSION_ELEMENT_INFO):
124 return HandleDumpSessionElementInfo(data, reply);
125 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TOUCH_OUTSIDE):
126 return HandleNotifyTouchOutside(data, reply);
127 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_MODE_CHANGE):
128 return HandleUpdateWindowMode(data, reply);
129 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_FOREGROUND_INTERACTIVE_STATUS):
130 return HandleNotifyForegroundInteractiveStatus(data, reply);
131 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_MAXIMIZE_MODE_CHANGE):
132 return HandleUpdateMaximizeMode(data, reply);
133 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_CLOSE_EXIST_PIP_WINDOW):
134 return HandleNotifyCloseExistPipWindow(data, reply);
135 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_FOREGROUND):
136 return HandleNotifySessionForeground(data, reply);
137 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_BACKGROUND):
138 return HandleNotifySessionBackground(data, reply);
139 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TITLE_POSITION_CHANGE):
140 return HandleUpdateTitleInTargetPos(data, reply);
141 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DENSITY_FOLLOW_HOST):
142 return HandleNotifyDensityFollowHost(data, reply);
143 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_VISIBILITY_CHANGE):
144 return HandleNotifyWindowVisibilityChange(data, reply);
145 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TRANSFORM_CHANGE):
146 return HandleNotifyTransformChange(data, reply);
147 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DIALOG_STATE_CHANGE):
148 return HandleNotifyDialogStateChange(data, reply);
149 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_PIP_ACTION_EVENT):
150 return HandleSetPipActionEvent(data, reply);
151 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_PIP_CONTROL_EVENT):
152 return HandleSetPiPControlEvent(data, reply);
153 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DISPLAYID_CHANGE):
154 return HandleUpdateDisplayId(data, reply);
155 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DISPLAY_MOVE):
156 return HandleNotifyDisplayMove(data, reply);
157 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SWITCH_FREEMULTIWINDOW):
158 return HandleSwitchFreeMultiWindow(data, reply);
159 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_GET_UI_CONTENT_REMOTE_OBJ):
160 return HandleGetUIContentRemoteObj(data, reply);
161 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_KEYBOARD_INFO_CHANGE):
162 return HandleNotifyKeyboardPanelInfoChange(data, reply);
163 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_COMPATIBLE_MODE_ENABLE):
164 return HandleNotifyCompatibleModeEnableInPad(data, reply);
165 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DENSITY_UNIQUE):
166 return HandleSetUniqueVirtualPixelRatio(data, reply);
167 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_FULLSCREEN):
168 return HandleNotifySessionFullScreen(data, reply);
169 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DUMP_INFO):
170 return HandleNotifyDumpInfo(data, reply);
171 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_ENABLE_DRAG_BY_SYSTEM):
172 return HandleSetEnableDragBySystem(data, reply);
173 default:
174 WLOGFE("Failed to find function handler!");
175 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
176 }
177 }
178
HandleSetActive(MessageParcel & data,MessageParcel & reply)179 int SessionStageStub::HandleSetActive(MessageParcel& data, MessageParcel& reply)
180 {
181 WLOGFD("SetActive!");
182 bool active = data.ReadBool();
183 WSError errCode = SetActive(active);
184 reply.WriteUint32(static_cast<uint32_t>(errCode));
185 return ERR_NONE;
186 }
187
HandleUpdateRect(MessageParcel & data,MessageParcel & reply)188 int SessionStageStub::HandleUpdateRect(MessageParcel& data, MessageParcel& reply)
189 {
190 WLOGFD("UpdateRect!");
191 WSRect rect = { data.ReadInt32(), data.ReadInt32(), data.ReadUint32(), data.ReadUint32() };
192 SizeChangeReason reason = static_cast<SizeChangeReason>(data.ReadUint32());
193 bool hasRSTransaction = data.ReadBool();
194 if (hasRSTransaction) {
195 std::shared_ptr<RSTransaction> transaction(data.ReadParcelable<RSTransaction>());
196 if (!transaction) {
197 WLOGFE("transaction unMarsh failed");
198 return -1;
199 }
200 SceneAnimationConfig config { .rsTransaction_ = transaction, .animationDuration_ = data.ReadInt32() };
201 WSError errCode = UpdateRect(rect, reason, config);
202 reply.WriteUint32(static_cast<uint32_t>(errCode));
203 } else {
204 SceneAnimationConfig config { .rsTransaction_ = nullptr, .animationDuration_ = data.ReadInt32() };
205 WSError errCode = UpdateRect(rect, reason, config);
206 reply.WriteUint32(static_cast<uint32_t>(errCode));
207 }
208 return ERR_NONE;
209 }
210
HandleUpdateDensity(MessageParcel & data,MessageParcel & reply)211 int SessionStageStub::HandleUpdateDensity(MessageParcel& data, MessageParcel& reply)
212 {
213 WLOGFD("UpdateDensity!");
214 UpdateDensity();
215 return ERR_NONE;
216 }
217
HandleUpdateOrientation(MessageParcel & data,MessageParcel & reply)218 int SessionStageStub::HandleUpdateOrientation(MessageParcel& data, MessageParcel& reply)
219 {
220 TLOGD(WmsLogTag::DMS, "HandleUpdateOrientation!");
221 WSError errCode = UpdateOrientation();
222 reply.WriteInt32(static_cast<int32_t>(errCode));
223 return ERR_NONE;
224 }
225
HandleBackEventInner(MessageParcel & data,MessageParcel & reply)226 int SessionStageStub::HandleBackEventInner(MessageParcel& data, MessageParcel& reply)
227 {
228 WLOGFD("HandleBackEventInner!");
229 WSError errCode = HandleBackEvent();
230 reply.WriteUint32(static_cast<uint32_t>(errCode));
231 return ERR_NONE;
232 }
233
HandleNotifyDestroy(MessageParcel & data,MessageParcel & reply)234 int SessionStageStub::HandleNotifyDestroy(MessageParcel& data, MessageParcel& reply)
235 {
236 WLOGFD("Notify Destroy");
237 WSError errCode = NotifyDestroy();
238 reply.WriteUint32(static_cast<uint32_t>(errCode));
239 return ERR_NONE;
240 }
241
HandleNotifyCloseExistPipWindow(MessageParcel & data,MessageParcel & reply)242 int SessionStageStub::HandleNotifyCloseExistPipWindow(MessageParcel& data, MessageParcel& reply)
243 {
244 TLOGD(WmsLogTag::WMS_PIP, "Notify Pip AlreadyExists");
245 WSError errCode = NotifyCloseExistPipWindow();
246 reply.WriteUint32(static_cast<uint32_t>(errCode));
247 return ERR_NONE;
248 }
249
HandleUpdateFocus(MessageParcel & data,MessageParcel & reply)250 int SessionStageStub::HandleUpdateFocus(MessageParcel& data, MessageParcel& reply)
251 {
252 WLOGFD("UpdateFocus!");
253 bool isFocused = data.ReadBool();
254 WSError errCode = UpdateFocus(isFocused);
255 reply.WriteUint32(static_cast<uint32_t>(errCode));
256 return ERR_NONE;
257 }
258
HandleNotifyTransferComponentData(MessageParcel & data,MessageParcel & reply)259 int SessionStageStub::HandleNotifyTransferComponentData(MessageParcel& data, MessageParcel& reply)
260 {
261 WLOGFD("HandleNotifyTransferComponentData!");
262 std::shared_ptr<AAFwk::WantParams> wantParams(data.ReadParcelable<AAFwk::WantParams>());
263 if (wantParams == nullptr) {
264 WLOGFE("wantParams is nullptr");
265 return ERR_INVALID_VALUE;
266 }
267 WSError errCode = NotifyTransferComponentData(*wantParams);
268 reply.WriteUint32(static_cast<uint32_t>(errCode));
269 return ERR_NONE;
270 }
271
HandleNotifyTransferComponentDataSync(MessageParcel & data,MessageParcel & reply)272 int SessionStageStub::HandleNotifyTransferComponentDataSync(MessageParcel& data, MessageParcel& reply)
273 {
274 std::shared_ptr<AAFwk::WantParams> wantParams(data.ReadParcelable<AAFwk::WantParams>());
275 if (wantParams == nullptr) {
276 WLOGFE("wantParams is nullptr");
277 return static_cast<int>(WSErrorCode::WS_ERROR_TRANSFER_DATA_FAILED);
278 }
279 AAFwk::WantParams reWantParams;
280 WSErrorCode errCode = NotifyTransferComponentDataSync(*wantParams, reWantParams);
281 if (errCode != WSErrorCode::WS_OK) {
282 return static_cast<int>(errCode);
283 }
284 if (!reply.WriteParcelable(&reWantParams)) {
285 WLOGFE("reWantParams write failed.");
286 return static_cast<int>(WSErrorCode::WS_ERROR_TRANSFER_DATA_FAILED);
287 }
288 return static_cast<int>(WSErrorCode::WS_OK);
289 }
290
HandleNotifyOccupiedAreaChange(MessageParcel & data,MessageParcel & reply)291 int SessionStageStub::HandleNotifyOccupiedAreaChange(MessageParcel& data, MessageParcel& reply)
292 {
293 TLOGD(WmsLogTag::WMS_KEYBOARD, "HandleNotifyOccupiedAreaChangeInfo!");
294 sptr<OccupiedAreaChangeInfo> info(data.ReadParcelable<OccupiedAreaChangeInfo>());
295 if (info == nullptr) {
296 TLOGE(WmsLogTag::WMS_KEYBOARD, "Occupied info is nullptr");
297 return ERR_INVALID_VALUE;
298 }
299
300 bool hasRSTransaction = data.ReadBool();
301 if (hasRSTransaction) {
302 std::shared_ptr<RSTransaction> transaction(data.ReadParcelable<RSTransaction>());
303 if (!transaction) {
304 TLOGE(WmsLogTag::WMS_KEYBOARD, "transaction unMarsh failed");
305 return ERR_INVALID_VALUE;
306 }
307 NotifyOccupiedAreaChangeInfo(info, transaction);
308 } else {
309 NotifyOccupiedAreaChangeInfo(info);
310 }
311
312 return ERR_NONE;
313 }
314
HandleUpdateAvoidArea(MessageParcel & data,MessageParcel & reply)315 int SessionStageStub::HandleUpdateAvoidArea(MessageParcel& data, MessageParcel& reply)
316 {
317 WLOGFD("HandleUpdateAvoidArea!");
318 sptr<AvoidArea> avoidArea = data.ReadStrongParcelable<AvoidArea>();
319 if (!avoidArea) {
320 return ERR_INVALID_VALUE;
321 }
322 uint32_t type;
323 if (!data.ReadUint32(type)) {
324 return ERR_INVALID_VALUE;
325 }
326 UpdateAvoidArea(avoidArea, static_cast<AvoidAreaType>(type));
327 return ERR_NONE;
328 }
329
HandleNotifyScreenshot(MessageParcel & data,MessageParcel & reply)330 int SessionStageStub::HandleNotifyScreenshot(MessageParcel& data, MessageParcel& reply)
331 {
332 WLOGFD("Notify Screen shot!");
333 NotifyScreenshot();
334 return ERR_NONE;
335 }
336
HandleDumpSessionElementInfo(MessageParcel & data,MessageParcel & reply)337 int SessionStageStub::HandleDumpSessionElementInfo(MessageParcel& data, MessageParcel& reply)
338 {
339 WLOGFD("HandleDumpSessionElementInfo!");
340 std::vector<std::string> params;
341 if (!data.ReadStringVector(¶ms)) {
342 WLOGFE("Fail to read params");
343 return -1;
344 }
345 DumpSessionElementInfo(params);
346 return ERR_NONE;
347 }
348
HandleNotifyTouchOutside(MessageParcel & data,MessageParcel & reply)349 int SessionStageStub::HandleNotifyTouchOutside(MessageParcel& data, MessageParcel& reply)
350 {
351 WLOGFD("HandleNotifyTouchOutside!");
352 NotifyTouchOutside();
353 return ERR_NONE;
354 }
355
HandleUpdateWindowMode(MessageParcel & data,MessageParcel & reply)356 int SessionStageStub::HandleUpdateWindowMode(MessageParcel& data, MessageParcel& reply)
357 {
358 WLOGFD("HandleUpdateWindowMode!");
359 WindowMode mode = static_cast<WindowMode>(data.ReadUint32());
360 WSError errCode = UpdateWindowMode(mode);
361 reply.WriteInt32(static_cast<int32_t>(errCode));
362 return ERR_NONE;
363 }
364
HandleNotifyWindowVisibilityChange(MessageParcel & data,MessageParcel & reply)365 int SessionStageStub::HandleNotifyWindowVisibilityChange(MessageParcel& data, MessageParcel& reply)
366 {
367 WLOGFD("HandleNotifyWindowVisibilityChange!");
368 bool isVisible = data.ReadBool();
369 WSError errCode = NotifyWindowVisibility(isVisible);
370 reply.WriteInt32(static_cast<int32_t>(errCode));
371 return ERR_NONE;
372 }
373
HandleNotifyForegroundInteractiveStatus(MessageParcel & data,MessageParcel & reply)374 int SessionStageStub::HandleNotifyForegroundInteractiveStatus(MessageParcel& data, MessageParcel& reply)
375 {
376 WLOGFD("NotifyForegroundInteractiveStatus!");
377 bool interactive = data.ReadBool();
378 NotifyForegroundInteractiveStatus(interactive);
379 return ERR_NONE;
380 }
381
HandleUpdateMaximizeMode(MessageParcel & data,MessageParcel & reply)382 int SessionStageStub::HandleUpdateMaximizeMode(MessageParcel& data, MessageParcel& reply)
383 {
384 WLOGFD("HandleUpdateMaximizeMode!");
385 MaximizeMode mode = static_cast<MaximizeMode>(data.ReadUint32());
386 WSError errCode = UpdateMaximizeMode(mode);
387 reply.WriteInt32(static_cast<int32_t>(errCode));
388 return ERR_NONE;
389 }
390
HandleNotifySessionForeground(MessageParcel & data,MessageParcel & reply)391 int SessionStageStub::HandleNotifySessionForeground(MessageParcel& data, MessageParcel& reply)
392 {
393 WLOGFD("HandleNotifySessionForeground");
394 uint32_t reason = data.ReadUint32();
395 bool withAnimation = data.ReadBool();
396 NotifySessionForeground(reason, withAnimation);
397 return ERR_NONE;
398 }
399
HandleNotifySessionFullScreen(MessageParcel & data,MessageParcel & reply)400 int SessionStageStub::HandleNotifySessionFullScreen(MessageParcel& data, MessageParcel& reply)
401 {
402 TLOGD(WmsLogTag::WMS_LAYOUT, "called");
403 bool fullScreen = data.ReadBool();
404 NotifySessionFullScreen(fullScreen);
405 return ERR_NONE;
406 }
407
HandleNotifySessionBackground(MessageParcel & data,MessageParcel & reply)408 int SessionStageStub::HandleNotifySessionBackground(MessageParcel& data, MessageParcel& reply)
409 {
410 WLOGFD("HandleNotifySessionBackground");
411 uint32_t reason = data.ReadUint32();
412 bool withAnimation = data.ReadBool();
413 bool isFromInnerkits = data.ReadBool();
414 NotifySessionBackground(reason, withAnimation, isFromInnerkits);
415 return ERR_NONE;
416 }
417
HandleUpdateTitleInTargetPos(MessageParcel & data,MessageParcel & reply)418 int SessionStageStub::HandleUpdateTitleInTargetPos(MessageParcel& data, MessageParcel& reply)
419 {
420 WLOGFD("HandleUpdateTitleInTargetPos!");
421 bool isShow = data.ReadBool();
422 int32_t height = data.ReadInt32();
423 WSError errCode = UpdateTitleInTargetPos(isShow, height);
424 reply.WriteInt32(static_cast<int32_t>(errCode));
425 return ERR_NONE;
426 }
427
HandleNotifyTransformChange(MessageParcel & data,MessageParcel & reply)428 int SessionStageStub::HandleNotifyTransformChange(MessageParcel& data, MessageParcel& reply)
429 {
430 WLOGFD("HandleNotifyTransformChange!");
431 Transform transform;
432 transform.Unmarshalling(data);
433 NotifyTransformChange(transform);
434 return ERR_NONE;
435 }
436
HandleNotifyDensityFollowHost(MessageParcel & data,MessageParcel & reply)437 int SessionStageStub::HandleNotifyDensityFollowHost(MessageParcel& data, MessageParcel& reply)
438 {
439 TLOGD(WmsLogTag::WMS_UIEXT, "HandleNotifyDensityFollowHost");
440 bool isFollowHost = data.ReadBool();
441 float densityValue = data.ReadFloat();
442 NotifyDensityFollowHost(isFollowHost, densityValue);
443 return ERR_NONE;
444 }
445
HandleNotifyDialogStateChange(MessageParcel & data,MessageParcel & reply)446 int SessionStageStub::HandleNotifyDialogStateChange(MessageParcel& data, MessageParcel& reply)
447 {
448 WLOGD("HandleNotifyDialogStateChange!");
449 bool isForeground = data.ReadBool();
450 NotifyDialogStateChange(isForeground);
451 return ERR_NONE;
452 }
453
HandleSetPipActionEvent(MessageParcel & data,MessageParcel & reply)454 int SessionStageStub::HandleSetPipActionEvent(MessageParcel& data, MessageParcel& reply)
455 {
456 TLOGD(WmsLogTag::WMS_PIP, "HandleSetPipActionEvent");
457 std::string action = data.ReadString();
458 if (action.empty()) {
459 TLOGE(WmsLogTag::WMS_PIP, "SessionStageStub pip action event is nullptr");
460 return ERR_INVALID_VALUE;
461 }
462 int32_t status;
463 if (!data.ReadInt32(status)) {
464 return ERR_INVALID_VALUE;
465 }
466 SetPipActionEvent(action, status);
467 return ERR_NONE;
468 }
469
HandleSetPiPControlEvent(MessageParcel & data,MessageParcel & reply)470 int SessionStageStub::HandleSetPiPControlEvent(MessageParcel& data, MessageParcel& reply)
471 {
472 TLOGD(WmsLogTag::WMS_PIP, "called");
473 uint32_t controlType;
474 if (!data.ReadUint32(controlType)) {
475 return ERR_INVALID_VALUE;
476 }
477 int32_t status;
478 if (!data.ReadInt32(status)) {
479 return ERR_INVALID_VALUE;
480 }
481 SetPiPControlEvent(static_cast<WsPiPControlType>(controlType), static_cast<WsPiPControlStatus>(status));
482 return ERR_NONE;
483 }
484
HandleUpdateDisplayId(MessageParcel & data,MessageParcel & reply)485 int SessionStageStub::HandleUpdateDisplayId(MessageParcel& data, MessageParcel& reply)
486 {
487 WLOGD("UpdateDisplayId!");
488 uint64_t displayId = data.ReadUint64();
489 WSError errCode = UpdateDisplayId(displayId);
490 reply.WriteInt32(static_cast<int32_t>(errCode));
491 return ERR_NONE;
492 }
493
HandleNotifyDisplayMove(MessageParcel & data,MessageParcel & reply)494 int SessionStageStub::HandleNotifyDisplayMove(MessageParcel& data, MessageParcel& reply)
495 {
496 WLOGD("HandleNotifyDisplayMove!");
497 DisplayId from = static_cast<DisplayId>(data.ReadUint64());
498 DisplayId to = static_cast<DisplayId>(data.ReadUint64());
499 NotifyDisplayMove(from, to);
500 return ERR_NONE;
501 }
502
HandleSwitchFreeMultiWindow(MessageParcel & data,MessageParcel & reply)503 int SessionStageStub::HandleSwitchFreeMultiWindow(MessageParcel& data, MessageParcel& reply)
504 {
505 TLOGD(WmsLogTag::WMS_LAYOUT, "HandleSwitchFreeMultiWindow!");
506 bool enable = data.ReadBool();
507 WSError errCode = SwitchFreeMultiWindow(enable);
508 reply.WriteInt32(static_cast<int32_t>(errCode));
509
510 return ERR_NONE;
511 }
512
HandleGetUIContentRemoteObj(MessageParcel & data,MessageParcel & reply)513 int SessionStageStub::HandleGetUIContentRemoteObj(MessageParcel& data, MessageParcel& reply)
514 {
515 TLOGI(WmsLogTag::DEFAULT, "Called");
516 sptr<IRemoteObject> uiContentRemoteObj;
517 WSError errCode = GetUIContentRemoteObj(uiContentRemoteObj);
518 reply.WriteRemoteObject(uiContentRemoteObj);
519 reply.WriteInt32(static_cast<int32_t>(errCode));
520 return ERR_NONE;
521 }
522
HandleNotifyKeyboardPanelInfoChange(MessageParcel & data,MessageParcel & reply)523 int SessionStageStub::HandleNotifyKeyboardPanelInfoChange(MessageParcel& data, MessageParcel& reply)
524 {
525 TLOGD(WmsLogTag::WMS_KEYBOARD, "HandleNotifyKeyboardPanelInfoChange!");
526 sptr<KeyboardPanelInfo> keyboardPanelInfo = data.ReadParcelable<KeyboardPanelInfo>();
527 if (keyboardPanelInfo == nullptr) {
528 TLOGE(WmsLogTag::WMS_KEYBOARD, "keyboardPanelInfo is nullptr!");
529 return ERR_INVALID_VALUE;
530 }
531 NotifyKeyboardPanelInfoChange(*keyboardPanelInfo);
532
533 return ERR_NONE;
534 }
535
HandleSetUniqueVirtualPixelRatio(MessageParcel & data,MessageParcel & reply)536 int SessionStageStub::HandleSetUniqueVirtualPixelRatio(MessageParcel& data, MessageParcel& reply)
537 {
538 TLOGD(WmsLogTag::DEFAULT, "HandleSetUniqueVirtualPixelRatio!");
539 bool useUniqueDensity = data.ReadBool();
540 float densityValue = data.ReadFloat();
541 SetUniqueVirtualPixelRatio(useUniqueDensity, densityValue);
542 return ERR_NONE;
543 }
544
HandleNotifyCompatibleModeEnableInPad(MessageParcel & data,MessageParcel & reply)545 int SessionStageStub::HandleNotifyCompatibleModeEnableInPad(MessageParcel& data, MessageParcel& reply)
546 {
547 bool enable = data.ReadBool();
548 WSError errCode = NotifyCompatibleModeEnableInPad(enable);
549 reply.WriteInt32(static_cast<int32_t>(errCode));
550 return ERR_NONE;
551 }
552
HandleSetEnableDragBySystem(MessageParcel & data,MessageParcel & reply)553 int SessionStageStub::HandleSetEnableDragBySystem(MessageParcel& data, MessageParcel& reply)
554 {
555 TLOGD(WmsLogTag::WMS_LAYOUT, "in");
556 bool enableDrag = true;
557 if (!data.ReadBool(enableDrag)) {
558 TLOGE(WmsLogTag::WMS_LAYOUT, "Read enableDrag failed.");
559 return ERR_INVALID_DATA;
560 }
561 SetEnableDragBySystem(enableDrag);
562 return ERR_NONE;
563 }
564
HandleNotifyDumpInfo(MessageParcel & data,MessageParcel & reply)565 int SessionStageStub::HandleNotifyDumpInfo(MessageParcel& data, MessageParcel& reply)
566 {
567 TLOGD(WmsLogTag::WMS_UIEXT, "entry");
568 std::vector<std::string> params;
569 if (!data.ReadStringVector(¶ms)) {
570 TLOGE(WmsLogTag::WMS_UIEXT, "Failed to read string vector");
571 return ERR_INVALID_VALUE;
572 }
573 std::vector<std::string> infos;
574 WSError errCode = NotifyDumpInfo(params, infos);
575 bool isLittleSize = CalculateDumpInfoSize(infos);
576 if (!reply.WriteBool(isLittleSize)) {
577 TLOGE(WmsLogTag::WMS_UIEXT, "Write isLittleSize failed");
578 return ERR_TRANSACTION_FAILED;
579 }
580
581 bool writeResult = isLittleSize ? WriteLittleStringVector(infos, reply) :
582 WriteLargeStringVector(infos, reply);
583 if (!writeResult) {
584 TLOGE(WmsLogTag::WMS_UIEXT, "write data failed");
585 return ERR_TRANSACTION_FAILED;
586 }
587
588 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
589 TLOGE(WmsLogTag::WMS_UIEXT, "write errCode failed");
590 return ERR_TRANSACTION_FAILED;
591 }
592
593 return ERR_NONE;
594 }
595 } // namespace OHOS::Rosen
596