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_UPDATE_SESSION_VIEWPORT_CONFIG):
108 return HandleUpdateSessionViewportConfig(data, reply);
109 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_HANDLE_BACK_EVENT):
110 return HandleBackEventInner(data, reply);
111 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DESTROY):
112 return HandleNotifyDestroy(data, reply);
113 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_FOCUS_CHANGE):
114 return HandleUpdateFocus(data, reply);
115 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TRANSFER_COMPONENT_DATA):
116 return HandleNotifyTransferComponentData(data, reply);
117 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TRANSFER_COMPONENT_DATA_SYNC):
118 return HandleNotifyTransferComponentDataSync(data, reply);
119 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_OCCUPIED_AREA_CHANGE_INFO):
120 return HandleNotifyOccupiedAreaChange(data, reply);
121 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_UPDATE_AVOID_AREA):
122 return HandleUpdateAvoidArea(data, reply);
123 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SCREEN_SHOT):
124 return HandleNotifyScreenshot(data, reply);
125 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_DUMP_SESSSION_ELEMENT_INFO):
126 return HandleDumpSessionElementInfo(data, reply);
127 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TOUCH_OUTSIDE):
128 return HandleNotifyTouchOutside(data, reply);
129 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_MODE_CHANGE):
130 return HandleUpdateWindowMode(data, reply);
131 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_FOREGROUND_INTERACTIVE_STATUS):
132 return HandleNotifyForegroundInteractiveStatus(data, reply);
133 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_MAXIMIZE_MODE_CHANGE):
134 return HandleUpdateMaximizeMode(data, reply);
135 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_CLOSE_EXIST_PIP_WINDOW):
136 return HandleNotifyCloseExistPipWindow(data, reply);
137 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_FOREGROUND):
138 return HandleNotifySessionForeground(data, reply);
139 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_BACKGROUND):
140 return HandleNotifySessionBackground(data, reply);
141 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TITLE_POSITION_CHANGE):
142 return HandleUpdateTitleInTargetPos(data, reply);
143 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DENSITY_FOLLOW_HOST):
144 return HandleNotifyDensityFollowHost(data, reply);
145 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_VISIBILITY_CHANGE):
146 return HandleNotifyWindowVisibilityChange(data, reply);
147 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TRANSFORM_CHANGE):
148 return HandleNotifyTransformChange(data, reply);
149 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SINGLE_HAND_TRANSFORM):
150 return HandleNotifySingleHandTransformChange(data, reply);
151 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DIALOG_STATE_CHANGE):
152 return HandleNotifyDialogStateChange(data, reply);
153 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_PIP_ACTION_EVENT):
154 return HandleSetPipActionEvent(data, reply);
155 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_PIP_CONTROL_EVENT):
156 return HandleSetPiPControlEvent(data, reply);
157 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DISPLAYID_CHANGE):
158 return HandleUpdateDisplayId(data, reply);
159 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DISPLAY_MOVE):
160 return HandleNotifyDisplayMove(data, reply);
161 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SWITCH_FREEMULTIWINDOW):
162 return HandleSwitchFreeMultiWindow(data, reply);
163 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_GET_UI_CONTENT_REMOTE_OBJ):
164 return HandleGetUIContentRemoteObj(data, reply);
165 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_KEYBOARD_INFO_CHANGE):
166 return HandleNotifyKeyboardPanelInfoChange(data, reply);
167 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_COMPATIBLE_FULLSCREEN_RECOVER):
168 return HandleCompatibleFullScreenRecover(data, reply);
169 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_COMPATIBLE_FULLSCREEN_MINIMIZE):
170 return HandleCompatibleFullScreenMinimize(data, reply);
171 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_COMPATIBLE_FULLSCREEN_CLOSE):
172 return HandleCompatibleFullScreenClose(data, reply);
173 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_PCAPPINPADNORMAL_CLOSE):
174 return HandlePcAppInPadNormalClose(data, reply);
175 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_COMPATIBLE_MODE_ENABLE):
176 return HandleNotifyCompatibleModeEnableInPad(data, reply);
177 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DENSITY_UNIQUE):
178 return HandleSetUniqueVirtualPixelRatio(data, reply);
179 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_FULLSCREEN):
180 return HandleNotifySessionFullScreen(data, reply);
181 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DUMP_INFO):
182 return HandleNotifyDumpInfo(data, reply);
183 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_SPLIT_BUTTON_VISIBLE):
184 return HandleSetSplitButtonVisible(data, reply);
185 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_ENABLE_DRAG_BY_SYSTEM):
186 return HandleSetEnableDragBySystem(data, reply);
187 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_FULLSCREEN_WATERFALL_MODE):
188 return HandleSetFullScreenWaterfallMode(data, reply);
189 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_SUPPORT_ENTER_WATERFALL_MODE):
190 return HandleSetSupportEnterWaterfallMode(data, reply);
191 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SEND_EXTENSION_DATA):
192 return HandleExtensionHostData(data, reply, option);
193 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SEND_CONTAINER_MODAL_EVENT):
194 return HandleSendContainerModalEvent(data, reply);
195 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_DRAG_ACTIVATED):
196 return HandleSetDragActivated(data, reply);
197 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_HIGHLIGHT_CHANGE):
198 return HandleNotifyHighlightChange(data, reply);
199 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_CROSS_AXIS):
200 return HandleNotifyWindowCrossAxisChange(data, reply);
201 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_PIPSIZE_CHANGE):
202 return HandleNotifyPipSizeChange(data, reply);
203 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_ATTACH_STATE_CHANGE):
204 return HandleNotifyWindowAttachStateChange(data, reply);
205 case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_KEYBOARD_ANIMATION_COMPLETED):
206 return HandleNotifyKeyboardAnimationCompleted(data, reply);
207 default:
208 WLOGFE("Failed to find function handler!");
209 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
210 }
211 }
212
HandleSetActive(MessageParcel & data,MessageParcel & reply)213 int SessionStageStub::HandleSetActive(MessageParcel& data, MessageParcel& reply)
214 {
215 WLOGFD("SetActive!");
216 bool active = data.ReadBool();
217 WSError errCode = SetActive(active);
218 reply.WriteUint32(static_cast<uint32_t>(errCode));
219 return ERR_NONE;
220 }
221
HandleUpdateRect(MessageParcel & data,MessageParcel & reply)222 int SessionStageStub::HandleUpdateRect(MessageParcel& data, MessageParcel& reply)
223 {
224 TLOGD(WmsLogTag::WMS_LAYOUT, "in");
225 int32_t posX = 0;
226 int32_t posY = 0;
227 uint32_t width = 0;
228 uint32_t height = 0;
229 if (!data.ReadInt32(posX) || !data.ReadInt32(posY) || !data.ReadUint32(width) || !data.ReadUint32(height)) {
230 TLOGE(WmsLogTag::WMS_LAYOUT, "read rect failed");
231 return -1;
232 }
233 WSRect rect = { posX, posY, width, height };
234 uint32_t reasonType = 0;
235 if (!data.ReadUint32(reasonType) || reasonType > static_cast<uint32_t>(SizeChangeReason::END)) {
236 TLOGE(WmsLogTag::WMS_LAYOUT, "read reasonType failed");
237 return -1;
238 }
239 SizeChangeReason reason = static_cast<SizeChangeReason>(reasonType);
240 bool hasRSTransaction = false;
241 if (!data.ReadBool(hasRSTransaction)) {
242 TLOGE(WmsLogTag::WMS_LAYOUT, "read hasRSTransaction failed.");
243 return -1;
244 }
245 SceneAnimationConfig config { .rsTransaction_ = nullptr, .animationDuration_ = 0 };
246 if (hasRSTransaction) {
247 std::shared_ptr<RSTransaction> transaction(data.ReadParcelable<RSTransaction>());
248 if (!transaction) {
249 TLOGE(WmsLogTag::WMS_LAYOUT, "transaction unMarsh failed.");
250 return -1;
251 }
252 config.rsTransaction_ = transaction;
253 }
254 if (!data.ReadInt32(config.animationDuration_)) {
255 TLOGE(WmsLogTag::WMS_LAYOUT, "read animationDuration failed");
256 return -1;
257 }
258 std::map<AvoidAreaType, AvoidArea> avoidAreas;
259 uint32_t size = 0;
260 if (!data.ReadUint32(size)) {
261 TLOGE(WmsLogTag::WMS_IMMS, "read avoid area size failed");
262 return -1;
263 }
264 constexpr uint32_t AVOID_AREA_TYPE_MAX_SIZE = 100;
265 if (size > AVOID_AREA_TYPE_MAX_SIZE) {
266 TLOGE(WmsLogTag::WMS_IMMS, "avoid area size is invalid");
267 return -1;
268 }
269 for (uint32_t i = 0; i < size; i++) {
270 uint32_t type = data.ReadUint32();
271 if (type < static_cast<uint32_t>(AvoidAreaType::TYPE_START) ||
272 type >= static_cast<uint32_t>(AvoidAreaType::TYPE_END)) {
273 TLOGE(WmsLogTag::WMS_IMMS, "read avoid area type failed");
274 return -1;
275 }
276 sptr<AvoidArea> area = data.ReadParcelable<AvoidArea>();
277 if (area == nullptr) {
278 TLOGE(WmsLogTag::WMS_IMMS, "read avoid area failed");
279 return -1;
280 }
281 avoidAreas[static_cast<AvoidAreaType>(type)] = *area;
282 }
283 WSError errCode = UpdateRect(rect, reason, config, avoidAreas);
284 reply.WriteUint32(static_cast<uint32_t>(errCode));
285 return ERR_NONE;
286 }
287
HandleUpdateDensity(MessageParcel & data,MessageParcel & reply)288 int SessionStageStub::HandleUpdateDensity(MessageParcel& data, MessageParcel& reply)
289 {
290 WLOGFD("UpdateDensity!");
291 UpdateDensity();
292 return ERR_NONE;
293 }
294
HandleUpdateOrientation(MessageParcel & data,MessageParcel & reply)295 int SessionStageStub::HandleUpdateOrientation(MessageParcel& data, MessageParcel& reply)
296 {
297 TLOGD(WmsLogTag::DMS, "HandleUpdateOrientation!");
298 WSError errCode = UpdateOrientation();
299 reply.WriteInt32(static_cast<int32_t>(errCode));
300 return ERR_NONE;
301 }
302
HandleUpdateSessionViewportConfig(MessageParcel & data,MessageParcel & reply)303 int SessionStageStub::HandleUpdateSessionViewportConfig(MessageParcel& data, MessageParcel& reply)
304 {
305 TLOGD(WmsLogTag::WMS_UIEXT, "HandleUpdateSessionViewportConfig!");
306 SessionViewportConfig config;
307 if (!data.ReadBool(config.isDensityFollowHost_) || !data.ReadFloat(config.density_) ||
308 !data.ReadUint64(config.displayId_) || !data.ReadInt32(config.orientation_) ||
309 !data.ReadUint32(config.transform_)) {
310 TLOGE(WmsLogTag::WMS_UIEXT, "Read HandleUpdateSessionViewportConfig data failed!");
311 return ERR_INVALID_DATA;
312 };
313 UpdateSessionViewportConfig(config);
314 return ERR_NONE;
315 }
316
HandleBackEventInner(MessageParcel & data,MessageParcel & reply)317 int SessionStageStub::HandleBackEventInner(MessageParcel& data, MessageParcel& reply)
318 {
319 WLOGFD("HandleBackEventInner!");
320 WSError errCode = HandleBackEvent();
321 reply.WriteUint32(static_cast<uint32_t>(errCode));
322 return ERR_NONE;
323 }
324
HandleNotifyDestroy(MessageParcel & data,MessageParcel & reply)325 int SessionStageStub::HandleNotifyDestroy(MessageParcel& data, MessageParcel& reply)
326 {
327 WLOGFD("Notify Destroy");
328 WSError errCode = NotifyDestroy();
329 reply.WriteUint32(static_cast<uint32_t>(errCode));
330 return ERR_NONE;
331 }
332
HandleNotifyCloseExistPipWindow(MessageParcel & data,MessageParcel & reply)333 int SessionStageStub::HandleNotifyCloseExistPipWindow(MessageParcel& data, MessageParcel& reply)
334 {
335 TLOGD(WmsLogTag::WMS_PIP, "Notify Pip AlreadyExists");
336 WSError errCode = NotifyCloseExistPipWindow();
337 reply.WriteUint32(static_cast<uint32_t>(errCode));
338 return ERR_NONE;
339 }
340
HandleUpdateFocus(MessageParcel & data,MessageParcel & reply)341 int SessionStageStub::HandleUpdateFocus(MessageParcel& data, MessageParcel& reply)
342 {
343 WLOGFD("UpdateFocus!");
344 bool isFocused = data.ReadBool();
345 WSError errCode = UpdateFocus(isFocused);
346 reply.WriteUint32(static_cast<uint32_t>(errCode));
347 return ERR_NONE;
348 }
349
HandleNotifyTransferComponentData(MessageParcel & data,MessageParcel & reply)350 int SessionStageStub::HandleNotifyTransferComponentData(MessageParcel& data, MessageParcel& reply)
351 {
352 WLOGFD("HandleNotifyTransferComponentData!");
353 std::shared_ptr<AAFwk::WantParams> wantParams(data.ReadParcelable<AAFwk::WantParams>());
354 if (wantParams == nullptr) {
355 WLOGFE("wantParams is nullptr");
356 return ERR_INVALID_VALUE;
357 }
358 WSError errCode = NotifyTransferComponentData(*wantParams);
359 reply.WriteUint32(static_cast<uint32_t>(errCode));
360 return ERR_NONE;
361 }
362
HandleNotifyTransferComponentDataSync(MessageParcel & data,MessageParcel & reply)363 int SessionStageStub::HandleNotifyTransferComponentDataSync(MessageParcel& data, MessageParcel& reply)
364 {
365 std::shared_ptr<AAFwk::WantParams> wantParams(data.ReadParcelable<AAFwk::WantParams>());
366 if (wantParams == nullptr) {
367 WLOGFE("wantParams is nullptr");
368 return static_cast<int>(WSErrorCode::WS_ERROR_TRANSFER_DATA_FAILED);
369 }
370 AAFwk::WantParams reWantParams;
371 WSErrorCode errCode = NotifyTransferComponentDataSync(*wantParams, reWantParams);
372 if (errCode != WSErrorCode::WS_OK) {
373 return static_cast<int>(errCode);
374 }
375 if (!reply.WriteParcelable(&reWantParams)) {
376 WLOGFE("reWantParams write failed.");
377 return static_cast<int>(WSErrorCode::WS_ERROR_TRANSFER_DATA_FAILED);
378 }
379 return static_cast<int>(WSErrorCode::WS_OK);
380 }
381
HandleNotifyOccupiedAreaChange(MessageParcel & data,MessageParcel & reply)382 int SessionStageStub::HandleNotifyOccupiedAreaChange(MessageParcel& data, MessageParcel& reply)
383 {
384 TLOGD(WmsLogTag::WMS_KEYBOARD, "HandleNotifyOccupiedAreaChangeInfo!");
385 sptr<OccupiedAreaChangeInfo> info(data.ReadParcelable<OccupiedAreaChangeInfo>());
386 if (info == nullptr) {
387 TLOGE(WmsLogTag::WMS_KEYBOARD, "Occupied info is nullptr");
388 return ERR_INVALID_VALUE;
389 }
390
391 bool hasRSTransaction = data.ReadBool();
392 if (hasRSTransaction) {
393 std::shared_ptr<RSTransaction> transaction(data.ReadParcelable<RSTransaction>());
394 if (!transaction) {
395 TLOGE(WmsLogTag::WMS_KEYBOARD, "transaction unMarsh failed");
396 return ERR_INVALID_VALUE;
397 }
398 NotifyOccupiedAreaChangeInfo(info, transaction);
399 } else {
400 NotifyOccupiedAreaChangeInfo(info);
401 }
402
403 return ERR_NONE;
404 }
405
HandleUpdateAvoidArea(MessageParcel & data,MessageParcel & reply)406 int SessionStageStub::HandleUpdateAvoidArea(MessageParcel& data, MessageParcel& reply)
407 {
408 WLOGFD("HandleUpdateAvoidArea!");
409 sptr<AvoidArea> avoidArea = data.ReadStrongParcelable<AvoidArea>();
410 if (!avoidArea) {
411 return ERR_INVALID_VALUE;
412 }
413 uint32_t type = 0;
414 if (!data.ReadUint32(type) ||
415 type >= static_cast<uint32_t>(AvoidAreaType::TYPE_END)) {
416 return ERR_INVALID_VALUE;
417 }
418 UpdateAvoidArea(avoidArea, static_cast<AvoidAreaType>(type));
419 return ERR_NONE;
420 }
421
HandleNotifyScreenshot(MessageParcel & data,MessageParcel & reply)422 int SessionStageStub::HandleNotifyScreenshot(MessageParcel& data, MessageParcel& reply)
423 {
424 WLOGFD("Notify Screen shot!");
425 NotifyScreenshot();
426 return ERR_NONE;
427 }
428
HandleDumpSessionElementInfo(MessageParcel & data,MessageParcel & reply)429 int SessionStageStub::HandleDumpSessionElementInfo(MessageParcel& data, MessageParcel& reply)
430 {
431 WLOGFD("HandleDumpSessionElementInfo!");
432 std::vector<std::string> params;
433 if (!data.ReadStringVector(¶ms)) {
434 WLOGFE("Fail to read params");
435 return -1;
436 }
437 DumpSessionElementInfo(params);
438 return ERR_NONE;
439 }
440
HandleNotifyTouchOutside(MessageParcel & data,MessageParcel & reply)441 int SessionStageStub::HandleNotifyTouchOutside(MessageParcel& data, MessageParcel& reply)
442 {
443 WLOGFD("HandleNotifyTouchOutside!");
444 NotifyTouchOutside();
445 return ERR_NONE;
446 }
447
HandleUpdateWindowMode(MessageParcel & data,MessageParcel & reply)448 int SessionStageStub::HandleUpdateWindowMode(MessageParcel& data, MessageParcel& reply)
449 {
450 WLOGFD("HandleUpdateWindowMode!");
451 WindowMode mode = static_cast<WindowMode>(data.ReadUint32());
452 WSError errCode = UpdateWindowMode(mode);
453 reply.WriteInt32(static_cast<int32_t>(errCode));
454 return ERR_NONE;
455 }
456
HandleNotifyWindowVisibilityChange(MessageParcel & data,MessageParcel & reply)457 int SessionStageStub::HandleNotifyWindowVisibilityChange(MessageParcel& data, MessageParcel& reply)
458 {
459 WLOGFD("HandleNotifyWindowVisibilityChange!");
460 bool isVisible = data.ReadBool();
461 WSError errCode = NotifyWindowVisibility(isVisible);
462 reply.WriteInt32(static_cast<int32_t>(errCode));
463 return ERR_NONE;
464 }
465
HandleNotifyForegroundInteractiveStatus(MessageParcel & data,MessageParcel & reply)466 int SessionStageStub::HandleNotifyForegroundInteractiveStatus(MessageParcel& data, MessageParcel& reply)
467 {
468 WLOGFD("NotifyForegroundInteractiveStatus!");
469 bool interactive = data.ReadBool();
470 NotifyForegroundInteractiveStatus(interactive);
471 return ERR_NONE;
472 }
473
HandleUpdateMaximizeMode(MessageParcel & data,MessageParcel & reply)474 int SessionStageStub::HandleUpdateMaximizeMode(MessageParcel& data, MessageParcel& reply)
475 {
476 WLOGFD("HandleUpdateMaximizeMode!");
477 MaximizeMode mode = static_cast<MaximizeMode>(data.ReadUint32());
478 WSError errCode = UpdateMaximizeMode(mode);
479 reply.WriteInt32(static_cast<int32_t>(errCode));
480 return ERR_NONE;
481 }
482
HandleNotifySessionForeground(MessageParcel & data,MessageParcel & reply)483 int SessionStageStub::HandleNotifySessionForeground(MessageParcel& data, MessageParcel& reply)
484 {
485 WLOGFD("HandleNotifySessionForeground");
486 uint32_t reason = data.ReadUint32();
487 bool withAnimation = data.ReadBool();
488 NotifySessionForeground(reason, withAnimation);
489 return ERR_NONE;
490 }
491
HandleNotifySessionFullScreen(MessageParcel & data,MessageParcel & reply)492 int SessionStageStub::HandleNotifySessionFullScreen(MessageParcel& data, MessageParcel& reply)
493 {
494 TLOGD(WmsLogTag::WMS_LAYOUT_PC, "called");
495 bool fullScreen = data.ReadBool();
496 NotifySessionFullScreen(fullScreen);
497 return ERR_NONE;
498 }
499
HandleNotifySessionBackground(MessageParcel & data,MessageParcel & reply)500 int SessionStageStub::HandleNotifySessionBackground(MessageParcel& data, MessageParcel& reply)
501 {
502 WLOGFD("HandleNotifySessionBackground");
503 uint32_t reason = data.ReadUint32();
504 bool withAnimation = data.ReadBool();
505 bool isFromInnerkits = data.ReadBool();
506 NotifySessionBackground(reason, withAnimation, isFromInnerkits);
507 return ERR_NONE;
508 }
509
HandleUpdateTitleInTargetPos(MessageParcel & data,MessageParcel & reply)510 int SessionStageStub::HandleUpdateTitleInTargetPos(MessageParcel& data, MessageParcel& reply)
511 {
512 TLOGD(WmsLogTag::WMS_DECOR, "called");
513 bool isShow = data.ReadBool();
514 int32_t height = data.ReadInt32();
515 WSError errCode = UpdateTitleInTargetPos(isShow, height);
516 reply.WriteInt32(static_cast<int32_t>(errCode));
517 return ERR_NONE;
518 }
519
HandleNotifyTransformChange(MessageParcel & data,MessageParcel & reply)520 int SessionStageStub::HandleNotifyTransformChange(MessageParcel& data, MessageParcel& reply)
521 {
522 WLOGFD("HandleNotifyTransformChange!");
523 Transform transform;
524 transform.Unmarshalling(data);
525 NotifyTransformChange(transform);
526 return ERR_NONE;
527 }
528
HandleNotifySingleHandTransformChange(MessageParcel & data,MessageParcel & reply)529 int SessionStageStub::HandleNotifySingleHandTransformChange(MessageParcel& data, MessageParcel& reply)
530 {
531 TLOGD(WmsLogTag::WMS_LAYOUT, "in");
532 SingleHandTransform singleHandTransform;
533 singleHandTransform.Unmarshalling(data);
534 NotifySingleHandTransformChange(singleHandTransform);
535 return ERR_NONE;
536 }
537
HandleNotifyDensityFollowHost(MessageParcel & data,MessageParcel & reply)538 int SessionStageStub::HandleNotifyDensityFollowHost(MessageParcel& data, MessageParcel& reply)
539 {
540 TLOGD(WmsLogTag::WMS_UIEXT, "HandleNotifyDensityFollowHost");
541 bool isFollowHost = data.ReadBool();
542 float densityValue = data.ReadFloat();
543 NotifyDensityFollowHost(isFollowHost, densityValue);
544 return ERR_NONE;
545 }
546
HandleNotifyDialogStateChange(MessageParcel & data,MessageParcel & reply)547 int SessionStageStub::HandleNotifyDialogStateChange(MessageParcel& data, MessageParcel& reply)
548 {
549 WLOGD("HandleNotifyDialogStateChange!");
550 bool isForeground = data.ReadBool();
551 NotifyDialogStateChange(isForeground);
552 return ERR_NONE;
553 }
554
HandleSetPipActionEvent(MessageParcel & data,MessageParcel & reply)555 int SessionStageStub::HandleSetPipActionEvent(MessageParcel& data, MessageParcel& reply)
556 {
557 TLOGD(WmsLogTag::WMS_PIP, "HandleSetPipActionEvent");
558 std::string action = data.ReadString();
559 if (action.empty()) {
560 TLOGE(WmsLogTag::WMS_PIP, "SessionStageStub pip action event is nullptr");
561 return ERR_INVALID_VALUE;
562 }
563 int32_t status;
564 if (!data.ReadInt32(status)) {
565 return ERR_INVALID_VALUE;
566 }
567 SetPipActionEvent(action, status);
568 return ERR_NONE;
569 }
570
HandleSetPiPControlEvent(MessageParcel & data,MessageParcel & reply)571 int SessionStageStub::HandleSetPiPControlEvent(MessageParcel& data, MessageParcel& reply)
572 {
573 TLOGD(WmsLogTag::WMS_PIP, "called");
574 uint32_t controlType;
575 if (!data.ReadUint32(controlType)) {
576 return ERR_INVALID_VALUE;
577 }
578 int32_t status;
579 if (!data.ReadInt32(status)) {
580 return ERR_INVALID_VALUE;
581 }
582 SetPiPControlEvent(static_cast<WsPiPControlType>(controlType), static_cast<WsPiPControlStatus>(status));
583 return ERR_NONE;
584 }
585
HandleUpdateDisplayId(MessageParcel & data,MessageParcel & reply)586 int SessionStageStub::HandleUpdateDisplayId(MessageParcel& data, MessageParcel& reply)
587 {
588 WLOGD("UpdateDisplayId!");
589 uint64_t displayId = data.ReadUint64();
590 WSError errCode = UpdateDisplayId(displayId);
591 reply.WriteInt32(static_cast<int32_t>(errCode));
592 return ERR_NONE;
593 }
594
HandleNotifyDisplayMove(MessageParcel & data,MessageParcel & reply)595 int SessionStageStub::HandleNotifyDisplayMove(MessageParcel& data, MessageParcel& reply)
596 {
597 WLOGD("HandleNotifyDisplayMove!");
598 DisplayId from = static_cast<DisplayId>(data.ReadUint64());
599 DisplayId to = static_cast<DisplayId>(data.ReadUint64());
600 NotifyDisplayMove(from, to);
601 return ERR_NONE;
602 }
603
HandleSwitchFreeMultiWindow(MessageParcel & data,MessageParcel & reply)604 int SessionStageStub::HandleSwitchFreeMultiWindow(MessageParcel& data, MessageParcel& reply)
605 {
606 TLOGD(WmsLogTag::WMS_LAYOUT_PC, "called!");
607 bool enable = data.ReadBool();
608 WSError errCode = SwitchFreeMultiWindow(enable);
609 reply.WriteInt32(static_cast<int32_t>(errCode));
610 return ERR_NONE;
611 }
612
HandleGetUIContentRemoteObj(MessageParcel & data,MessageParcel & reply)613 int SessionStageStub::HandleGetUIContentRemoteObj(MessageParcel& data, MessageParcel& reply)
614 {
615 TLOGI(WmsLogTag::WMS_ATTRIBUTE, "Called");
616 sptr<IRemoteObject> uiContentRemoteObj;
617 WSError errCode = GetUIContentRemoteObj(uiContentRemoteObj);
618 reply.WriteRemoteObject(uiContentRemoteObj);
619 reply.WriteInt32(static_cast<int32_t>(errCode));
620 return ERR_NONE;
621 }
622
HandleNotifyKeyboardPanelInfoChange(MessageParcel & data,MessageParcel & reply)623 int SessionStageStub::HandleNotifyKeyboardPanelInfoChange(MessageParcel& data, MessageParcel& reply)
624 {
625 TLOGD(WmsLogTag::WMS_KEYBOARD, "HandleNotifyKeyboardPanelInfoChange!");
626 sptr<KeyboardPanelInfo> keyboardPanelInfo = data.ReadParcelable<KeyboardPanelInfo>();
627 if (keyboardPanelInfo == nullptr) {
628 TLOGE(WmsLogTag::WMS_KEYBOARD, "keyboardPanelInfo is nullptr!");
629 return ERR_INVALID_VALUE;
630 }
631 NotifyKeyboardPanelInfoChange(*keyboardPanelInfo);
632
633 return ERR_NONE;
634 }
635
HandleCompatibleFullScreenRecover(MessageParcel & data,MessageParcel & reply)636 int SessionStageStub::HandleCompatibleFullScreenRecover(MessageParcel& data, MessageParcel& reply)
637 {
638 WSError errCode = CompatibleFullScreenRecover();
639 reply.WriteInt32(static_cast<int32_t>(errCode));
640 return ERR_NONE;
641 }
642
HandleCompatibleFullScreenMinimize(MessageParcel & data,MessageParcel & reply)643 int SessionStageStub::HandleCompatibleFullScreenMinimize(MessageParcel& data, MessageParcel& reply)
644 {
645 WSError errCode = CompatibleFullScreenMinimize();
646 reply.WriteInt32(static_cast<int32_t>(errCode));
647 return ERR_NONE;
648 }
649
HandleCompatibleFullScreenClose(MessageParcel & data,MessageParcel & reply)650 int SessionStageStub::HandleCompatibleFullScreenClose(MessageParcel& data, MessageParcel& reply)
651 {
652 WSError errCode = CompatibleFullScreenClose();
653 reply.WriteInt32(static_cast<int32_t>(errCode));
654 return ERR_NONE;
655 }
656
HandlePcAppInPadNormalClose(MessageParcel & data,MessageParcel & reply)657 int SessionStageStub::HandlePcAppInPadNormalClose(MessageParcel& data, MessageParcel& reply)
658 {
659 WSError errCode = PcAppInPadNormalClose();
660 return ERR_NONE;
661 }
662
HandleNotifyCompatibleModeEnableInPad(MessageParcel & data,MessageParcel & reply)663 int SessionStageStub::HandleNotifyCompatibleModeEnableInPad(MessageParcel& data, MessageParcel& reply)
664 {
665 bool enable = data.ReadBool();
666 WSError errCode = NotifyCompatibleModeEnableInPad(enable);
667 reply.WriteInt32(static_cast<int32_t>(errCode));
668 return ERR_NONE;
669 }
670
HandleSetUniqueVirtualPixelRatio(MessageParcel & data,MessageParcel & reply)671 int SessionStageStub::HandleSetUniqueVirtualPixelRatio(MessageParcel& data, MessageParcel& reply)
672 {
673 TLOGD(WmsLogTag::WMS_ATTRIBUTE, "HandleSetUniqueVirtualPixelRatio!");
674 bool useUniqueDensity = data.ReadBool();
675 float densityValue = data.ReadFloat();
676 SetUniqueVirtualPixelRatio(useUniqueDensity, densityValue);
677 return ERR_NONE;
678 }
679
HandleSetSplitButtonVisible(MessageParcel & data,MessageParcel & reply)680 int SessionStageStub::HandleSetSplitButtonVisible(MessageParcel& data, MessageParcel& reply)
681 {
682 TLOGD(WmsLogTag::WMS_LAYOUT, "in");
683 bool isVisible = true;
684 if (!data.ReadBool(isVisible)) {
685 TLOGE(WmsLogTag::WMS_LAYOUT, "Read isVisible failed.");
686 return ERR_INVALID_DATA;
687 }
688 SetSplitButtonVisible(isVisible);
689 return ERR_NONE;
690 }
691
HandleSetEnableDragBySystem(MessageParcel & data,MessageParcel & reply)692 int SessionStageStub::HandleSetEnableDragBySystem(MessageParcel& data, MessageParcel& reply)
693 {
694 TLOGD(WmsLogTag::WMS_LAYOUT, "in");
695 bool enableDrag = true;
696 if (!data.ReadBool(enableDrag)) {
697 TLOGE(WmsLogTag::WMS_LAYOUT, "Read enableDrag failed.");
698 return ERR_INVALID_DATA;
699 }
700 SetEnableDragBySystem(enableDrag);
701 return ERR_NONE;
702 }
703
HandleSetDragActivated(MessageParcel & data,MessageParcel & reply)704 int SessionStageStub::HandleSetDragActivated(MessageParcel& data, MessageParcel& reply)
705 {
706 TLOGD(WmsLogTag::WMS_LAYOUT, "in");
707 bool dragActivated = true;
708 if (!data.ReadBool(dragActivated)) {
709 TLOGE(WmsLogTag::WMS_LAYOUT, "Read dragActivated failed.");
710 return ERR_INVALID_DATA;
711 }
712 SetDragActivated(dragActivated);
713 return ERR_NONE;
714 }
715
HandleSetFullScreenWaterfallMode(MessageParcel & data,MessageParcel & reply)716 int SessionStageStub::HandleSetFullScreenWaterfallMode(MessageParcel& data, MessageParcel& reply)
717 {
718 TLOGD(WmsLogTag::WMS_LAYOUT, "in");
719 bool isWaterfallMode = false;
720 if (!data.ReadBool(isWaterfallMode)) {
721 TLOGE(WmsLogTag::WMS_LAYOUT, "Read isWaterfallMode failed.");
722 return ERR_INVALID_DATA;
723 }
724 SetFullScreenWaterfallMode(isWaterfallMode);
725 return ERR_NONE;
726 }
727
HandleSetSupportEnterWaterfallMode(MessageParcel & data,MessageParcel & reply)728 int SessionStageStub::HandleSetSupportEnterWaterfallMode(MessageParcel& data, MessageParcel& reply)
729 {
730 TLOGD(WmsLogTag::WMS_LAYOUT_PC, "in");
731 bool isSupportEnter = false;
732 if (!data.ReadBool(isSupportEnter)) {
733 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Read isSupportEnter failed.");
734 return ERR_INVALID_DATA;
735 }
736 SetSupportEnterWaterfallMode(isSupportEnter);
737 return ERR_NONE;
738 }
739
HandleNotifyDumpInfo(MessageParcel & data,MessageParcel & reply)740 int SessionStageStub::HandleNotifyDumpInfo(MessageParcel& data, MessageParcel& reply)
741 {
742 TLOGD(WmsLogTag::WMS_UIEXT, "entry");
743 std::vector<std::string> params;
744 if (!data.ReadStringVector(¶ms)) {
745 TLOGE(WmsLogTag::WMS_UIEXT, "Failed to read string vector");
746 return ERR_INVALID_VALUE;
747 }
748 std::vector<std::string> infos;
749 WSError errCode = NotifyDumpInfo(params, infos);
750 bool isLittleSize = CalculateDumpInfoSize(infos);
751 if (!reply.WriteBool(isLittleSize)) {
752 TLOGE(WmsLogTag::WMS_UIEXT, "Write isLittleSize failed");
753 return ERR_TRANSACTION_FAILED;
754 }
755
756 bool writeResult = isLittleSize ? WriteLittleStringVector(infos, reply) :
757 WriteLargeStringVector(infos, reply);
758 if (!writeResult) {
759 TLOGE(WmsLogTag::WMS_UIEXT, "write data failed");
760 return ERR_TRANSACTION_FAILED;
761 }
762
763 if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
764 TLOGE(WmsLogTag::WMS_UIEXT, "write errCode failed");
765 return ERR_TRANSACTION_FAILED;
766 }
767
768 return ERR_NONE;
769 }
770
HandleExtensionHostData(MessageParcel & data,MessageParcel & reply,MessageOption & option)771 int SessionStageStub::HandleExtensionHostData(MessageParcel& data, MessageParcel& reply, MessageOption& option)
772 {
773 TLOGD(WmsLogTag::WMS_UIEXT, "in");
774 static_cast<void>(SendExtensionData(data, reply, option));
775 return ERR_NONE;
776 }
777
HandleSendContainerModalEvent(MessageParcel & data,MessageParcel & reply)778 int SessionStageStub::HandleSendContainerModalEvent(MessageParcel& data, MessageParcel& reply)
779 {
780 TLOGD(WmsLogTag::WMS_EVENT, "in");
781 std::string eventName = data.ReadString();
782 if (eventName.empty()) {
783 TLOGE(WmsLogTag::WMS_EVENT, "event name is nullptr");
784 return ERR_INVALID_VALUE;
785 }
786 std::string eventValue = data.ReadString();
787 if (eventValue.empty()) {
788 TLOGE(WmsLogTag::WMS_EVENT, "event value is nullptr");
789 return ERR_INVALID_VALUE;
790 }
791 SendContainerModalEvent(eventName, eventValue);
792 return ERR_NONE;
793 }
794
HandleNotifyHighlightChange(MessageParcel & data,MessageParcel & reply)795 int SessionStageStub::HandleNotifyHighlightChange(MessageParcel& data, MessageParcel& reply)
796 {
797 TLOGD(WmsLogTag::WMS_FOCUS, "called!");
798 bool isHighlight = false;
799 if (!data.ReadBool(isHighlight)) {
800 TLOGE(WmsLogTag::WMS_FOCUS, "Read isHighlight failed.");
801 return ERR_INVALID_DATA;
802 }
803 NotifyHighlightChange(isHighlight);
804 return ERR_NONE;
805 }
806
HandleNotifyWindowCrossAxisChange(MessageParcel & data,MessageParcel & reply)807 int SessionStageStub::HandleNotifyWindowCrossAxisChange(MessageParcel& data, MessageParcel& reply)
808 {
809 TLOGD(WmsLogTag::WMS_LAYOUT_PC, "in");
810 uint32_t state = 0;
811 if (!data.ReadUint32(state)) {
812 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Read cross axis state failed.");
813 return ERR_INVALID_DATA;
814 }
815 if (state >= static_cast<uint32_t>(CrossAxisState::STATE_END)) {
816 TLOGE(WmsLogTag::WMS_LAYOUT_PC, "invalid cross axis state.");
817 return ERR_INVALID_DATA;
818 }
819 NotifyWindowCrossAxisChange(static_cast<CrossAxisState>(state));
820 return ERR_NONE;
821 }
822
HandleNotifyPipSizeChange(MessageParcel & data,MessageParcel & reply)823 int SessionStageStub::HandleNotifyPipSizeChange(MessageParcel& data, MessageParcel& reply)
824 {
825 TLOGD(WmsLogTag::WMS_PIP, "in");
826 double width;
827 if (!data.ReadDouble(width)) {
828 return ERR_INVALID_VALUE;
829 }
830 double height;
831 if (!data.ReadDouble(height)) {
832 return ERR_INVALID_VALUE;
833 }
834 double scale;
835 if (!data.ReadDouble(scale)) {
836 return ERR_INVALID_VALUE;
837 }
838 NotifyPipWindowSizeChange(width, height, scale);
839 return ERR_NONE;
840 }
841
HandleNotifyWindowAttachStateChange(MessageParcel & data,MessageParcel & reply)842 int SessionStageStub::HandleNotifyWindowAttachStateChange(MessageParcel& data, MessageParcel& reply)
843 {
844 TLOGD(WmsLogTag::WMS_SUB, "in");
845 bool isAttach = false;
846 if (!data.ReadBool(isAttach)) {
847 return ERR_INVALID_DATA;
848 }
849 NotifyWindowAttachStateChange(isAttach);
850 return ERR_NONE;
851 }
852
HandleNotifyKeyboardAnimationCompleted(MessageParcel & data,MessageParcel & reply)853 int SessionStageStub::HandleNotifyKeyboardAnimationCompleted(MessageParcel& data, MessageParcel& reply)
854 {
855 TLOGD(WmsLogTag::WMS_KEYBOARD, "in");
856 sptr<KeyboardPanelInfo> keyboardPanelInfo = data.ReadParcelable<KeyboardPanelInfo>();
857 if (keyboardPanelInfo == nullptr) {
858 TLOGE(WmsLogTag::WMS_KEYBOARD, "keyboardPanelInfo is nullptr!");
859 return ERR_INVALID_VALUE;
860 }
861 NotifyKeyboardAnimationCompleted(*keyboardPanelInfo);
862 return ERR_NONE;
863 }
864 } // namespace OHOS::Rosen
865