• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_NOTIFY_SCREEN_SHOT_APP_EVENT):
126             return HandleNotifyScreenshotAppEvent(data, reply);
127         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_DUMP_SESSSION_ELEMENT_INFO):
128             return HandleDumpSessionElementInfo(data, reply);
129         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TOUCH_OUTSIDE):
130             return HandleNotifyTouchOutside(data, reply);
131         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SECURE_LIMIT_CHANGE):
132             return HandleNotifySecureLimitChange(data, reply);
133         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_MODE_CHANGE):
134             return HandleUpdateWindowMode(data, reply);
135         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_GET_TOP_NAV_DEST_NAME):
136             return HandleGetTopNavDestinationName(data, reply);
137         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_LAYOUT_FINISH_AFTER_WINDOW_MODE_CHANGE):
138             return HandleNotifyLayoutFinishAfterWindowModeChange(data, reply);
139         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_FOREGROUND_INTERACTIVE_STATUS):
140             return HandleNotifyForegroundInteractiveStatus(data, reply);
141         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_MAXIMIZE_MODE_CHANGE):
142             return HandleUpdateMaximizeMode(data, reply);
143         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_CLOSE_EXIST_PIP_WINDOW):
144             return HandleNotifyCloseExistPipWindow(data, reply);
145         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_FOREGROUND):
146             return HandleNotifySessionForeground(data, reply);
147         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_BACKGROUND):
148             return HandleNotifySessionBackground(data, reply);
149         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TITLE_POSITION_CHANGE):
150             return HandleUpdateTitleInTargetPos(data, reply);
151         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DENSITY_FOLLOW_HOST):
152             return HandleNotifyDensityFollowHost(data, reply);
153         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_VISIBILITY_CHANGE):
154             return HandleNotifyWindowVisibilityChange(data, reply);
155         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TRANSFORM_CHANGE):
156             return HandleNotifyTransformChange(data, reply);
157         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SINGLE_HAND_TRANSFORM):
158             return HandleNotifySingleHandTransformChange(data, reply);
159         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DIALOG_STATE_CHANGE):
160             return HandleNotifyDialogStateChange(data, reply);
161         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_PIP_ACTION_EVENT):
162             return HandleSetPipActionEvent(data, reply);
163         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_PIP_CONTROL_EVENT):
164             return HandleSetPiPControlEvent(data, reply);
165         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DISPLAYID_CHANGE):
166             return HandleUpdateDisplayId(data, reply);
167         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DISPLAY_MOVE):
168             return HandleNotifyDisplayMove(data, reply);
169         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SWITCH_FREEMULTIWINDOW):
170             return HandleSwitchFreeMultiWindow(data, reply);
171         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_GET_UI_CONTENT_REMOTE_OBJ):
172             return HandleGetUIContentRemoteObj(data, reply);
173         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_KEYBOARD_INFO_CHANGE):
174             return HandleNotifyKeyboardPanelInfoChange(data, reply);
175         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_PCAPPINPADNORMAL_CLOSE):
176             return HandlePcAppInPadNormalClose(data, reply);
177         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_COMPATIBLE_MODE_PROPERTY_CHANGE):
178             return HandleNotifyCompatibleModePropertyChange(data, reply);
179         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DENSITY_UNIQUE):
180             return HandleSetUniqueVirtualPixelRatio(data, reply);
181         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_FULLSCREEN):
182             return HandleNotifySessionFullScreen(data, reply);
183         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DUMP_INFO):
184             return HandleNotifyDumpInfo(data, reply);
185         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_SPLIT_BUTTON_VISIBLE):
186             return HandleSetSplitButtonVisible(data, reply);
187         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_ENABLE_DRAG_BY_SYSTEM):
188             return HandleSetEnableDragBySystem(data, reply);
189         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_FULLSCREEN_WATERFALL_MODE):
190             return HandleSetFullScreenWaterfallMode(data, reply);
191         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_SUPPORT_ENTER_WATERFALL_MODE):
192             return HandleSetSupportEnterWaterfallMode(data, reply);
193         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SEND_EXTENSION_DATA):
194             return HandleExtensionHostData(data, reply, option);
195         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_LINK_KEYFRAME_CANVAS_NODE):
196             return HandleLinkKeyFrameCanvasNode(data, reply);
197         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_KEYFRAME_POLICY):
198             return HandleSetKeyFramePolicy(data, reply);
199         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SEND_CONTAINER_MODAL_EVENT):
200             return HandleSendContainerModalEvent(data, reply);
201         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_DRAG_ACTIVATED):
202             return HandleSetDragActivated(data, reply);
203         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_HIGHLIGHT_CHANGE):
204             return HandleNotifyHighlightChange(data, reply);
205         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_CROSS_AXIS):
206             return HandleNotifyWindowCrossAxisChange(data, reply);
207         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_PIPSIZE_CHANGE):
208             return HandleNotifyPipSizeChange(data, reply);
209         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_ATTACH_STATE_CHANGE):
210             return HandleNotifyWindowAttachStateChange(data, reply);
211         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_KEYBOARD_ANIMATION_COMPLETED):
212             return HandleNotifyKeyboardAnimationCompleted(data, reply);
213         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_KEYBOARD_ANIMATION_WILLBEGIN):
214             return HandleNotifyKeyboardAnimationWillBegin(data, reply);
215         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_ROTATION_PROPERTY):
216             return HandleNotifyRotationProperty(data, reply);
217         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_ROTATION_CHANGE):
218             return HandleNotifyRotationChange(data, reply);
219         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_CURRENT_ROTATION):
220             return HandleSetCurrentRotation(data, reply);
221         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_APP_FORCE_LANDSCAPE_CONFIG_UPDATED):
222             return HandleNotifyAppForceLandscapeConfigUpdated(data, reply);
223         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_APP_HOOK_WINDOW_INFO_UPDATED):
224             return HandleNotifyAppHookWindowInfoUpdated(data, reply);
225         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_PAUSED_STATUS):
226             return HandleNotifyPausedStatus();
227         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_USE_CONTROL_STATUS):
228             return HandleNotifyAppUseControlStatus(data, reply);
229         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_CLOSE_SPECIFIC_SCENE):
230             return HandleCloseSpecificScene(data, reply);
231         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_GET_ROUTER_STACK_INFO):
232             return HandleGetRouterStackInfo(data, reply);
233         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_UPDATE_WINDOW_MODE_FOR_UI_TEST):
234             return HandleUpdateWindowModeForUITest(data, reply);
235         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_UPDATE_GLOBAL_DISPLAY_RECT):
236             return HandleUpdateGlobalDisplayRectFromServer(data, reply);
237         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SEND_FB_ACTION_EVENT):
238             return HandleSendFbActionEvent(data, reply);
239         default:
240             WLOGFE("Failed to find function handler!");
241             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
242     }
243 }
244 
HandleSetActive(MessageParcel & data,MessageParcel & reply)245 int SessionStageStub::HandleSetActive(MessageParcel& data, MessageParcel& reply)
246 {
247     WLOGFD("SetActive!");
248     bool active = data.ReadBool();
249     WSError errCode = SetActive(active);
250     reply.WriteUint32(static_cast<uint32_t>(errCode));
251     return ERR_NONE;
252 }
253 
HandleUpdateRect(MessageParcel & data,MessageParcel & reply)254 int SessionStageStub::HandleUpdateRect(MessageParcel& data, MessageParcel& reply)
255 {
256     TLOGD(WmsLogTag::WMS_LAYOUT, "in");
257     int32_t posX = 0;
258     int32_t posY = 0;
259     uint32_t width = 0;
260     uint32_t height = 0;
261     if (!data.ReadInt32(posX) || !data.ReadInt32(posY) || !data.ReadUint32(width) || !data.ReadUint32(height)) {
262         TLOGE(WmsLogTag::WMS_LAYOUT, "read rect failed");
263         return -1;
264     }
265     WSRect rect = { posX, posY, width, height };
266     uint32_t reasonType = 0;
267     if (!data.ReadUint32(reasonType) || reasonType > static_cast<uint32_t>(SizeChangeReason::END)) {
268         TLOGE(WmsLogTag::WMS_LAYOUT, "read reasonType failed");
269         return -1;
270     }
271     SizeChangeReason reason = static_cast<SizeChangeReason>(reasonType);
272     bool hasRSTransaction = false;
273     if (!data.ReadBool(hasRSTransaction)) {
274         TLOGE(WmsLogTag::WMS_LAYOUT, "read hasRSTransaction failed.");
275         return -1;
276     }
277     SceneAnimationConfig config { .rsTransaction_ = nullptr, .animationDuration_ = 0 };
278     if (hasRSTransaction) {
279         std::shared_ptr<RSTransaction> transaction(data.ReadParcelable<RSTransaction>());
280         if (!transaction) {
281             TLOGE(WmsLogTag::WMS_LAYOUT, "transaction unMarsh failed.");
282             return -1;
283         }
284         config.rsTransaction_ = transaction;
285     }
286     if (!data.ReadInt32(config.animationDuration_)) {
287         TLOGE(WmsLogTag::WMS_LAYOUT, "read animationDuration failed");
288         return -1;
289     }
290     std::map<AvoidAreaType, AvoidArea> avoidAreas;
291     uint32_t size = 0;
292     if (!data.ReadUint32(size)) {
293         TLOGE(WmsLogTag::WMS_IMMS, "read avoid area size failed");
294         return -1;
295     }
296     constexpr uint32_t AVOID_AREA_TYPE_MAX_SIZE = 100;
297     if (size > AVOID_AREA_TYPE_MAX_SIZE) {
298         TLOGE(WmsLogTag::WMS_IMMS, "avoid area size is invalid");
299         return -1;
300     }
301     for (uint32_t i = 0; i < size; i++) {
302         uint32_t type = data.ReadUint32();
303         if (type < static_cast<uint32_t>(AvoidAreaType::TYPE_START) ||
304             type >= static_cast<uint32_t>(AvoidAreaType::TYPE_END)) {
305             TLOGE(WmsLogTag::WMS_IMMS, "read avoid area type failed");
306             return -1;
307         }
308         sptr<AvoidArea> area = data.ReadParcelable<AvoidArea>();
309         if (area == nullptr) {
310             TLOGE(WmsLogTag::WMS_IMMS, "read avoid area failed");
311             return -1;
312         }
313         avoidAreas[static_cast<AvoidAreaType>(type)] = *area;
314     }
315     WSError errCode = UpdateRect(rect, reason, config, avoidAreas);
316     reply.WriteUint32(static_cast<uint32_t>(errCode));
317     return ERR_NONE;
318 }
319 
HandleUpdateGlobalDisplayRectFromServer(MessageParcel & data,MessageParcel & reply)320 int SessionStageStub::HandleUpdateGlobalDisplayRectFromServer(MessageParcel& data, MessageParcel& reply)
321 {
322     int32_t posX = 0;
323     int32_t posY = 0;
324     int32_t width = 0;
325     int32_t height = 0;
326     if (!data.ReadInt32(posX) || !data.ReadInt32(posY) || !data.ReadInt32(width) || !data.ReadInt32(height)) {
327         TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to read rect");
328         return ERR_INVALID_DATA;
329     }
330     WSRect globalDisplayRect = { posX, posY, width, height };
331 
332     uint32_t reasonValue = 0;
333     if (!data.ReadUint32(reasonValue)) {
334         TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to read reason");
335         return ERR_INVALID_DATA;
336     }
337     SizeChangeReason reason = static_cast<SizeChangeReason>(reasonValue);
338     if (reason < SizeChangeReason::UNDEFINED || reason >= SizeChangeReason::END) {
339         TLOGE(WmsLogTag::WMS_LAYOUT, "Invalid reason: %{public}u", reasonValue);
340         return ERR_INVALID_DATA;
341     }
342     UpdateGlobalDisplayRectFromServer(globalDisplayRect, reason);
343     return ERR_NONE;
344 }
345 
HandleUpdateDensity(MessageParcel & data,MessageParcel & reply)346 int SessionStageStub::HandleUpdateDensity(MessageParcel& data, MessageParcel& reply)
347 {
348     WLOGFD("UpdateDensity!");
349     UpdateDensity();
350     return ERR_NONE;
351 }
352 
HandleUpdateOrientation(MessageParcel & data,MessageParcel & reply)353 int SessionStageStub::HandleUpdateOrientation(MessageParcel& data, MessageParcel& reply)
354 {
355     TLOGD(WmsLogTag::DMS, "HandleUpdateOrientation!");
356     WSError errCode = UpdateOrientation();
357     reply.WriteInt32(static_cast<int32_t>(errCode));
358     return ERR_NONE;
359 }
360 
HandleUpdateSessionViewportConfig(MessageParcel & data,MessageParcel & reply)361 int SessionStageStub::HandleUpdateSessionViewportConfig(MessageParcel& data, MessageParcel& reply)
362 {
363     TLOGD(WmsLogTag::WMS_UIEXT, "HandleUpdateSessionViewportConfig!");
364     SessionViewportConfig config;
365     if (!data.ReadBool(config.isDensityFollowHost_) || !data.ReadFloat(config.density_) ||
366         !data.ReadUint64(config.displayId_) || !data.ReadInt32(config.orientation_) ||
367         !data.ReadUint32(config.transform_)) {
368         TLOGE(WmsLogTag::WMS_UIEXT, "Read HandleUpdateSessionViewportConfig data failed!");
369         return ERR_INVALID_DATA;
370     };
371     UpdateSessionViewportConfig(config);
372     return ERR_NONE;
373 }
374 
HandleBackEventInner(MessageParcel & data,MessageParcel & reply)375 int SessionStageStub::HandleBackEventInner(MessageParcel& data, MessageParcel& reply)
376 {
377     WLOGFD("HandleBackEventInner!");
378     WSError errCode = HandleBackEvent();
379     reply.WriteUint32(static_cast<uint32_t>(errCode));
380     return ERR_NONE;
381 }
382 
HandleNotifyDestroy(MessageParcel & data,MessageParcel & reply)383 int SessionStageStub::HandleNotifyDestroy(MessageParcel& data, MessageParcel& reply)
384 {
385     WLOGFD("Notify Destroy");
386     WSError errCode = NotifyDestroy();
387     reply.WriteUint32(static_cast<uint32_t>(errCode));
388     return ERR_NONE;
389 }
390 
HandleNotifyCloseExistPipWindow(MessageParcel & data,MessageParcel & reply)391 int SessionStageStub::HandleNotifyCloseExistPipWindow(MessageParcel& data, MessageParcel& reply)
392 {
393     TLOGD(WmsLogTag::WMS_PIP, "Notify Pip AlreadyExists");
394     WSError errCode = NotifyCloseExistPipWindow();
395     reply.WriteUint32(static_cast<uint32_t>(errCode));
396     return ERR_NONE;
397 }
398 
HandleUpdateFocus(MessageParcel & data,MessageParcel & reply)399 int SessionStageStub::HandleUpdateFocus(MessageParcel& data, MessageParcel& reply)
400 {
401     WLOGFD("UpdateFocus!");
402     bool isFocused = data.ReadBool();
403     WSError errCode = UpdateFocus(isFocused);
404     reply.WriteUint32(static_cast<uint32_t>(errCode));
405     return ERR_NONE;
406 }
407 
HandleNotifyTransferComponentData(MessageParcel & data,MessageParcel & reply)408 int SessionStageStub::HandleNotifyTransferComponentData(MessageParcel& data, MessageParcel& reply)
409 {
410     WLOGFD("HandleNotifyTransferComponentData!");
411     std::shared_ptr<AAFwk::WantParams> wantParams(data.ReadParcelable<AAFwk::WantParams>());
412     if (wantParams == nullptr) {
413         WLOGFE("wantParams is nullptr");
414         return ERR_INVALID_VALUE;
415     }
416     WSError errCode = NotifyTransferComponentData(*wantParams);
417     reply.WriteUint32(static_cast<uint32_t>(errCode));
418     return ERR_NONE;
419 }
420 
HandleNotifyTransferComponentDataSync(MessageParcel & data,MessageParcel & reply)421 int SessionStageStub::HandleNotifyTransferComponentDataSync(MessageParcel& data, MessageParcel& reply)
422 {
423     std::shared_ptr<AAFwk::WantParams> wantParams(data.ReadParcelable<AAFwk::WantParams>());
424     if (wantParams == nullptr) {
425         WLOGFE("wantParams is nullptr");
426         return static_cast<int>(WSErrorCode::WS_ERROR_TRANSFER_DATA_FAILED);
427     }
428     AAFwk::WantParams reWantParams;
429     WSErrorCode errCode = NotifyTransferComponentDataSync(*wantParams, reWantParams);
430     if (errCode != WSErrorCode::WS_OK) {
431         return static_cast<int>(errCode);
432     }
433     if (!reply.WriteParcelable(&reWantParams)) {
434         WLOGFE("reWantParams write failed.");
435         return static_cast<int>(WSErrorCode::WS_ERROR_TRANSFER_DATA_FAILED);
436     }
437     return static_cast<int>(WSErrorCode::WS_OK);
438 }
439 
HandleNotifyOccupiedAreaChange(MessageParcel & data,MessageParcel & reply)440 int SessionStageStub::HandleNotifyOccupiedAreaChange(MessageParcel& data, MessageParcel& reply)
441 {
442     TLOGD(WmsLogTag::WMS_KEYBOARD, "HandleNotifyOccupiedAreaChangeInfo!");
443     sptr<OccupiedAreaChangeInfo> info(data.ReadParcelable<OccupiedAreaChangeInfo>());
444     if (info == nullptr) {
445         TLOGE(WmsLogTag::WMS_KEYBOARD, "Occupied info is nullptr");
446         return ERR_INVALID_VALUE;
447     }
448     int32_t posX = 0;
449     int32_t posY = 0;
450     uint32_t width = 0;
451     uint32_t height = 0;
452     if (!(data.ReadInt32(posX) && data.ReadInt32(posY) && data.ReadUint32(width) && data.ReadUint32(height))) {
453         TLOGE(WmsLogTag::WMS_KEYBOARD, "Read callingSessionRect failed");
454         return ERR_INVALID_VALUE;
455     }
456     Rect callingSessionRect = { posX, posY, width, height };
457     std::map<AvoidAreaType, AvoidArea> avoidAreas = {};
458     uint32_t size = 0;
459     if (!data.ReadUint32(size)) {
460         TLOGE(WmsLogTag::WMS_KEYBOARD, "Read avoid area size failed");
461         return ERR_INVALID_VALUE;
462     }
463     constexpr uint32_t AVOID_AREA_TYPE_MAX_SIZE = 100;
464     if (size > AVOID_AREA_TYPE_MAX_SIZE) {
465         TLOGE(WmsLogTag::WMS_KEYBOARD, "Avoid area size: %{public}d is invalid", size);
466         return ERR_INVALID_VALUE;
467     }
468     for (uint32_t i = 0; i < size; i++) {
469         uint32_t type = static_cast<uint32_t>(AvoidAreaType::TYPE_START);
470         if (!data.ReadUint32(type)) {
471             TLOGE(WmsLogTag::WMS_KEYBOARD, "Read avoid area size failed");
472             return ERR_INVALID_VALUE;
473         }
474         if (type < static_cast<uint32_t>(AvoidAreaType::TYPE_START) ||
475             type >= static_cast<uint32_t>(AvoidAreaType::TYPE_END)) {
476             TLOGE(WmsLogTag::WMS_KEYBOARD, "invalid avoid area type: %{public}d", type);
477             return ERR_INVALID_VALUE;
478         }
479         sptr<AvoidArea> area = data.ReadParcelable<AvoidArea>();
480         if (area == nullptr) {
481             TLOGE(WmsLogTag::WMS_KEYBOARD, "Read avoid area failed");
482             return ERR_INVALID_VALUE;
483         }
484         avoidAreas[static_cast<AvoidAreaType>(type)] = *area;
485     }
486     bool hasRSTransaction = data.ReadBool();
487     if (hasRSTransaction) {
488         std::shared_ptr<RSTransaction> transaction(data.ReadParcelable<RSTransaction>());
489         if (!transaction) {
490             TLOGE(WmsLogTag::WMS_KEYBOARD, "transaction unMarsh failed");
491             return ERR_INVALID_VALUE;
492         }
493         NotifyOccupiedAreaChangeInfo(info, transaction, callingSessionRect, avoidAreas);
494     } else {
495         NotifyOccupiedAreaChangeInfo(info, nullptr, callingSessionRect, avoidAreas);
496     }
497 
498     return ERR_NONE;
499 }
500 
HandleUpdateAvoidArea(MessageParcel & data,MessageParcel & reply)501 int SessionStageStub::HandleUpdateAvoidArea(MessageParcel& data, MessageParcel& reply)
502 {
503     WLOGFD("HandleUpdateAvoidArea!");
504     sptr<AvoidArea> avoidArea = data.ReadStrongParcelable<AvoidArea>();
505     if (!avoidArea) {
506         return ERR_INVALID_VALUE;
507     }
508     uint32_t type = 0;
509     if (!data.ReadUint32(type) ||
510         type >= static_cast<uint32_t>(AvoidAreaType::TYPE_END)) {
511         return ERR_INVALID_VALUE;
512     }
513     UpdateAvoidArea(avoidArea, static_cast<AvoidAreaType>(type));
514     return ERR_NONE;
515 }
516 
HandleNotifyScreenshot(MessageParcel & data,MessageParcel & reply)517 int SessionStageStub::HandleNotifyScreenshot(MessageParcel& data, MessageParcel& reply)
518 {
519     WLOGFD("Notify Screen shot!");
520     NotifyScreenshot();
521     return ERR_NONE;
522 }
523 
HandleNotifyScreenshotAppEvent(MessageParcel & data,MessageParcel & reply)524 int SessionStageStub::HandleNotifyScreenshotAppEvent(MessageParcel& data, MessageParcel& reply)
525 {
526     TLOGD(WmsLogTag::WMS_ATTRIBUTE, "called");
527     int32_t screenshotEventType = static_cast<int32_t>(ScreenshotEventType::END);
528     if (!data.ReadInt32(screenshotEventType)) {
529         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read screenshotEventType failed");
530         return ERR_INVALID_VALUE;
531     }
532     NotifyScreenshotAppEvent(static_cast<ScreenshotEventType>(screenshotEventType));
533     return ERR_NONE;
534 }
535 
HandleDumpSessionElementInfo(MessageParcel & data,MessageParcel & reply)536 int SessionStageStub::HandleDumpSessionElementInfo(MessageParcel& data, MessageParcel& reply)
537 {
538     WLOGFD("HandleDumpSessionElementInfo!");
539     std::vector<std::string> params;
540     if (!data.ReadStringVector(&params)) {
541         WLOGFE("Fail to read params");
542         return -1;
543     }
544     DumpSessionElementInfo(params);
545     return ERR_NONE;
546 }
547 
HandleNotifyTouchOutside(MessageParcel & data,MessageParcel & reply)548 int SessionStageStub::HandleNotifyTouchOutside(MessageParcel& data, MessageParcel& reply)
549 {
550     WLOGFD("HandleNotifyTouchOutside!");
551     NotifyTouchOutside();
552     return ERR_NONE;
553 }
554 
HandleNotifySecureLimitChange(MessageParcel & data,MessageParcel & reply)555 int SessionStageStub::HandleNotifySecureLimitChange(MessageParcel& data, MessageParcel& reply)
556 {
557     TLOGD(WmsLogTag::WMS_UIEXT, "HandleNotifySecureLimitChange!");
558     bool isLimit = true;
559     if (!data.ReadBool(isLimit)) {
560         TLOGE(WmsLogTag::WMS_LAYOUT, "Read isLimit failed.");
561         return ERR_INVALID_DATA;
562     }
563     NotifyExtensionSecureLimitChange(isLimit);
564     return ERR_NONE;
565 }
566 
HandleUpdateWindowMode(MessageParcel & data,MessageParcel & reply)567 int SessionStageStub::HandleUpdateWindowMode(MessageParcel& data, MessageParcel& reply)
568 {
569     WLOGFD("HandleUpdateWindowMode!");
570     WindowMode mode = static_cast<WindowMode>(data.ReadUint32());
571     WSError errCode = UpdateWindowMode(mode);
572     reply.WriteInt32(static_cast<int32_t>(errCode));
573     return ERR_NONE;
574 }
575 
HandleGetTopNavDestinationName(MessageParcel & data,MessageParcel & reply)576 int SessionStageStub::HandleGetTopNavDestinationName(MessageParcel& data, MessageParcel& reply)
577 {
578     std::string topNavDestName;
579     WSError errCode = GetTopNavDestinationName(topNavDestName);
580     if (errCode != WSError::WS_OK) {
581         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "get stage failed, errCode=%{public}d", static_cast<int32_t>(errCode));
582         return ERR_INVALID_DATA;
583     }
584     uint32_t size = static_cast<uint32_t>(topNavDestName.length());
585     if (!reply.WriteUint32(size)) {
586         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write the size of stage top page name failed, size=%{public}u", size);
587         return ERR_INVALID_DATA;
588     }
589     if (size > 0 && !reply.WriteRawData(topNavDestName.c_str(), size)) {
590         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write stage top page name failed, name=%{public}s", topNavDestName.c_str());
591         return ERR_INVALID_DATA;
592     }
593     if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
594         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write stage error code failed");
595         return ERR_INVALID_DATA;
596     }
597     return ERR_NONE;
598 }
599 
HandleNotifyLayoutFinishAfterWindowModeChange(MessageParcel & data,MessageParcel & reply)600 int SessionStageStub::HandleNotifyLayoutFinishAfterWindowModeChange(MessageParcel& data, MessageParcel& reply)
601 {
602     TLOGD(WmsLogTag::WMS_LAYOUT, "in");
603     uint32_t mode = static_cast<uint32_t>(WindowMode::WINDOW_MODE_UNDEFINED);
604     if (!data.ReadUint32(mode)) {
605         TLOGW(WmsLogTag::WMS_LAYOUT, "Failed to read mode");
606         return ERR_INVALID_DATA;
607     }
608     WSError errCode = NotifyLayoutFinishAfterWindowModeChange(static_cast<WindowMode>(mode));
609     reply.WriteInt32(static_cast<int32_t>(errCode));
610     return ERR_NONE;
611 }
612 
HandleUpdateWindowModeForUITest(MessageParcel & data,MessageParcel & reply)613 int SessionStageStub::HandleUpdateWindowModeForUITest(MessageParcel& data, MessageParcel& reply)
614 {
615     TLOGD(WmsLogTag::WMS_LAYOUT, "in");
616     int32_t updateMode = 0;
617     if (!data.ReadInt32(updateMode)) {
618         TLOGW(WmsLogTag::WMS_LAYOUT, "Failed to read updateMode");
619         return ERR_INVALID_DATA;
620     }
621     WMError errCode = UpdateWindowModeForUITest(updateMode);
622     if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
623         TLOGE(WmsLogTag::WMS_LAYOUT, "Failed to write errCode");
624         return ERR_INVALID_DATA;
625     }
626     return ERR_NONE;
627 }
628 
HandleNotifyWindowVisibilityChange(MessageParcel & data,MessageParcel & reply)629 int SessionStageStub::HandleNotifyWindowVisibilityChange(MessageParcel& data, MessageParcel& reply)
630 {
631     WLOGFD("HandleNotifyWindowVisibilityChange!");
632     bool isVisible = data.ReadBool();
633     WSError errCode = NotifyWindowVisibility(isVisible);
634     reply.WriteInt32(static_cast<int32_t>(errCode));
635     return ERR_NONE;
636 }
637 
HandleNotifyForegroundInteractiveStatus(MessageParcel & data,MessageParcel & reply)638 int SessionStageStub::HandleNotifyForegroundInteractiveStatus(MessageParcel& data, MessageParcel& reply)
639 {
640     WLOGFD("NotifyForegroundInteractiveStatus!");
641     bool interactive = data.ReadBool();
642     NotifyForegroundInteractiveStatus(interactive);
643     return ERR_NONE;
644 }
645 
HandleNotifyAppUseControlStatus(MessageParcel & data,MessageParcel & reply)646 int SessionStageStub::HandleNotifyAppUseControlStatus(MessageParcel& data, MessageParcel& reply)
647 {
648     TLOGD(WmsLogTag::WMS_LIFE, "called");
649     bool useControlState = false;
650     if (!data.ReadBool(useControlState)) {
651         TLOGE(WmsLogTag::WMS_LIFE, "Failed to read useControlState");
652         return ERR_INVALID_DATA;
653     }
654     NotifyAppUseControlStatus(useControlState);
655     return ERR_NONE;
656 }
657 
HandleNotifyPausedStatus()658 int SessionStageStub::HandleNotifyPausedStatus()
659 {
660     TLOGD(WmsLogTag::WMS_LIFE, "called");
661     NotifyLifecyclePausedStatus();
662     return ERR_NONE;
663 }
664 
HandleUpdateMaximizeMode(MessageParcel & data,MessageParcel & reply)665 int SessionStageStub::HandleUpdateMaximizeMode(MessageParcel& data, MessageParcel& reply)
666 {
667     WLOGFD("HandleUpdateMaximizeMode!");
668     MaximizeMode mode = static_cast<MaximizeMode>(data.ReadUint32());
669     WSError errCode = UpdateMaximizeMode(mode);
670     reply.WriteInt32(static_cast<int32_t>(errCode));
671     return ERR_NONE;
672 }
673 
HandleNotifySessionForeground(MessageParcel & data,MessageParcel & reply)674 int SessionStageStub::HandleNotifySessionForeground(MessageParcel& data, MessageParcel& reply)
675 {
676     WLOGFD("HandleNotifySessionForeground");
677     uint32_t reason = data.ReadUint32();
678     bool withAnimation = data.ReadBool();
679     NotifySessionForeground(reason, withAnimation);
680     return ERR_NONE;
681 }
682 
HandleNotifySessionFullScreen(MessageParcel & data,MessageParcel & reply)683 int SessionStageStub::HandleNotifySessionFullScreen(MessageParcel& data, MessageParcel& reply)
684 {
685     TLOGD(WmsLogTag::WMS_LAYOUT_PC, "called");
686     bool fullScreen = data.ReadBool();
687     NotifySessionFullScreen(fullScreen);
688     return ERR_NONE;
689 }
690 
HandleNotifySessionBackground(MessageParcel & data,MessageParcel & reply)691 int SessionStageStub::HandleNotifySessionBackground(MessageParcel& data, MessageParcel& reply)
692 {
693     WLOGFD("HandleNotifySessionBackground");
694     uint32_t reason = data.ReadUint32();
695     bool withAnimation = data.ReadBool();
696     bool isFromInnerkits = data.ReadBool();
697     NotifySessionBackground(reason, withAnimation, isFromInnerkits);
698     return ERR_NONE;
699 }
700 
HandleUpdateTitleInTargetPos(MessageParcel & data,MessageParcel & reply)701 int SessionStageStub::HandleUpdateTitleInTargetPos(MessageParcel& data, MessageParcel& reply)
702 {
703     TLOGD(WmsLogTag::WMS_DECOR, "called");
704     bool isShow = data.ReadBool();
705     int32_t height = data.ReadInt32();
706     WSError errCode = UpdateTitleInTargetPos(isShow, height);
707     reply.WriteInt32(static_cast<int32_t>(errCode));
708     return ERR_NONE;
709 }
710 
HandleNotifyTransformChange(MessageParcel & data,MessageParcel & reply)711 int SessionStageStub::HandleNotifyTransformChange(MessageParcel& data, MessageParcel& reply)
712 {
713     WLOGFD("HandleNotifyTransformChange!");
714     Transform transform;
715     transform.Unmarshalling(data);
716     NotifyTransformChange(transform);
717     return ERR_NONE;
718 }
719 
HandleNotifySingleHandTransformChange(MessageParcel & data,MessageParcel & reply)720 int SessionStageStub::HandleNotifySingleHandTransformChange(MessageParcel& data, MessageParcel& reply)
721 {
722     TLOGD(WmsLogTag::WMS_LAYOUT, "in");
723     SingleHandTransform singleHandTransform;
724     singleHandTransform.Unmarshalling(data);
725     NotifySingleHandTransformChange(singleHandTransform);
726     return ERR_NONE;
727 }
728 
HandleNotifyDensityFollowHost(MessageParcel & data,MessageParcel & reply)729 int SessionStageStub::HandleNotifyDensityFollowHost(MessageParcel& data, MessageParcel& reply)
730 {
731     TLOGD(WmsLogTag::WMS_UIEXT, "HandleNotifyDensityFollowHost");
732     bool isFollowHost = data.ReadBool();
733     float densityValue = data.ReadFloat();
734     NotifyDensityFollowHost(isFollowHost, densityValue);
735     return ERR_NONE;
736 }
737 
HandleNotifyDialogStateChange(MessageParcel & data,MessageParcel & reply)738 int SessionStageStub::HandleNotifyDialogStateChange(MessageParcel& data, MessageParcel& reply)
739 {
740     WLOGD("HandleNotifyDialogStateChange!");
741     bool isForeground = data.ReadBool();
742     NotifyDialogStateChange(isForeground);
743     return ERR_NONE;
744 }
745 
HandleSetPipActionEvent(MessageParcel & data,MessageParcel & reply)746 int SessionStageStub::HandleSetPipActionEvent(MessageParcel& data, MessageParcel& reply)
747 {
748     TLOGD(WmsLogTag::WMS_PIP, "HandleSetPipActionEvent");
749     std::string action = data.ReadString();
750     if (action.empty()) {
751         TLOGE(WmsLogTag::WMS_PIP, "SessionStageStub pip action event is nullptr");
752         return ERR_INVALID_VALUE;
753     }
754     int32_t status;
755     if (!data.ReadInt32(status)) {
756         return ERR_INVALID_VALUE;
757     }
758     SetPipActionEvent(action, status);
759     return ERR_NONE;
760 }
761 
HandleSendFbActionEvent(MessageParcel & data,MessageParcel & reply)762 int SessionStageStub::HandleSendFbActionEvent(MessageParcel& data, MessageParcel& reply)
763 {
764     TLOGD(WmsLogTag::WMS_SYSTEM, "HandleSendFbActionEvent");
765     std::string action;
766     if (!data.ReadString(action)) {
767         TLOGE(WmsLogTag::WMS_SYSTEM, "Read action failed.");
768         reply.WriteInt32(static_cast<int32_t>(WSError::WS_ERROR_IPC_FAILED));
769         return ERR_INVALID_VALUE;
770     }
771     auto error = SendFbActionEvent(action);
772     if (!reply.WriteInt32(static_cast<int32_t>(error))) {
773         return ERR_INVALID_VALUE;
774     }
775     return ERR_NONE;
776 }
777 
HandleSetPiPControlEvent(MessageParcel & data,MessageParcel & reply)778 int SessionStageStub::HandleSetPiPControlEvent(MessageParcel& data, MessageParcel& reply)
779 {
780     TLOGD(WmsLogTag::WMS_PIP, "called");
781     uint32_t controlType;
782     if (!data.ReadUint32(controlType)) {
783         return ERR_INVALID_VALUE;
784     }
785     int32_t status;
786     if (!data.ReadInt32(status)) {
787         return ERR_INVALID_VALUE;
788     }
789     SetPiPControlEvent(static_cast<WsPiPControlType>(controlType), static_cast<WsPiPControlStatus>(status));
790     return ERR_NONE;
791 }
792 
HandleUpdateDisplayId(MessageParcel & data,MessageParcel & reply)793 int SessionStageStub::HandleUpdateDisplayId(MessageParcel& data, MessageParcel& reply)
794 {
795     WLOGD("UpdateDisplayId!");
796     uint64_t displayId = data.ReadUint64();
797     WSError errCode = UpdateDisplayId(displayId);
798     reply.WriteInt32(static_cast<int32_t>(errCode));
799     return ERR_NONE;
800 }
801 
HandleNotifyDisplayMove(MessageParcel & data,MessageParcel & reply)802 int SessionStageStub::HandleNotifyDisplayMove(MessageParcel& data, MessageParcel& reply)
803 {
804     WLOGD("HandleNotifyDisplayMove!");
805     DisplayId from = static_cast<DisplayId>(data.ReadUint64());
806     DisplayId to = static_cast<DisplayId>(data.ReadUint64());
807     NotifyDisplayMove(from, to);
808     return ERR_NONE;
809 }
810 
HandleSwitchFreeMultiWindow(MessageParcel & data,MessageParcel & reply)811 int SessionStageStub::HandleSwitchFreeMultiWindow(MessageParcel& data, MessageParcel& reply)
812 {
813     TLOGD(WmsLogTag::WMS_LAYOUT_PC, "called!");
814     bool enable = data.ReadBool();
815     WSError errCode = SwitchFreeMultiWindow(enable);
816     reply.WriteInt32(static_cast<int32_t>(errCode));
817     return ERR_NONE;
818 }
819 
HandleGetUIContentRemoteObj(MessageParcel & data,MessageParcel & reply)820 int SessionStageStub::HandleGetUIContentRemoteObj(MessageParcel& data, MessageParcel& reply)
821 {
822     TLOGI(WmsLogTag::WMS_ATTRIBUTE, "Called");
823     sptr<IRemoteObject> uiContentRemoteObj;
824     WSError errCode = GetUIContentRemoteObj(uiContentRemoteObj);
825     reply.WriteRemoteObject(uiContentRemoteObj);
826     reply.WriteInt32(static_cast<int32_t>(errCode));
827     return ERR_NONE;
828 }
829 
HandleNotifyKeyboardPanelInfoChange(MessageParcel & data,MessageParcel & reply)830 int SessionStageStub::HandleNotifyKeyboardPanelInfoChange(MessageParcel& data, MessageParcel& reply)
831 {
832     TLOGD(WmsLogTag::WMS_KEYBOARD, "HandleNotifyKeyboardPanelInfoChange!");
833     sptr<KeyboardPanelInfo> keyboardPanelInfo = data.ReadParcelable<KeyboardPanelInfo>();
834     if (keyboardPanelInfo == nullptr) {
835         TLOGE(WmsLogTag::WMS_KEYBOARD, "keyboardPanelInfo is nullptr!");
836         return ERR_INVALID_VALUE;
837     }
838     NotifyKeyboardPanelInfoChange(*keyboardPanelInfo);
839 
840     return ERR_NONE;
841 }
842 
HandlePcAppInPadNormalClose(MessageParcel & data,MessageParcel & reply)843 int SessionStageStub::HandlePcAppInPadNormalClose(MessageParcel& data, MessageParcel& reply)
844 {
845     WSError errCode = PcAppInPadNormalClose();
846     return ERR_NONE;
847 }
848 
HandleNotifyCompatibleModePropertyChange(MessageParcel & data,MessageParcel & reply)849 int SessionStageStub::HandleNotifyCompatibleModePropertyChange(MessageParcel& data, MessageParcel& reply)
850 {
851     sptr<CompatibleModeProperty> property = data.ReadParcelable<CompatibleModeProperty>();
852     WSError errCode = NotifyCompatibleModePropertyChange(property);
853     reply.WriteInt32(static_cast<int32_t>(errCode));
854     return ERR_NONE;
855 }
856 
HandleSetUniqueVirtualPixelRatio(MessageParcel & data,MessageParcel & reply)857 int SessionStageStub::HandleSetUniqueVirtualPixelRatio(MessageParcel& data, MessageParcel& reply)
858 {
859     TLOGD(WmsLogTag::WMS_ATTRIBUTE, "HandleSetUniqueVirtualPixelRatio!");
860     bool useUniqueDensity = data.ReadBool();
861     float densityValue = data.ReadFloat();
862     SetUniqueVirtualPixelRatio(useUniqueDensity, densityValue);
863     return ERR_NONE;
864 }
865 
HandleSetSplitButtonVisible(MessageParcel & data,MessageParcel & reply)866 int SessionStageStub::HandleSetSplitButtonVisible(MessageParcel& data, MessageParcel& reply)
867 {
868     TLOGD(WmsLogTag::WMS_LAYOUT, "in");
869     bool isVisible = true;
870     if (!data.ReadBool(isVisible)) {
871         TLOGE(WmsLogTag::WMS_LAYOUT, "Read isVisible failed.");
872         return ERR_INVALID_DATA;
873     }
874     SetSplitButtonVisible(isVisible);
875     return ERR_NONE;
876 }
877 
HandleSetEnableDragBySystem(MessageParcel & data,MessageParcel & reply)878 int SessionStageStub::HandleSetEnableDragBySystem(MessageParcel& data, MessageParcel& reply)
879 {
880     TLOGD(WmsLogTag::WMS_LAYOUT, "in");
881     bool enableDrag = true;
882     if (!data.ReadBool(enableDrag)) {
883         TLOGE(WmsLogTag::WMS_LAYOUT, "Read enableDrag failed.");
884         return ERR_INVALID_DATA;
885     }
886     SetEnableDragBySystem(enableDrag);
887     return ERR_NONE;
888 }
889 
HandleSetDragActivated(MessageParcel & data,MessageParcel & reply)890 int SessionStageStub::HandleSetDragActivated(MessageParcel& data, MessageParcel& reply)
891 {
892     TLOGD(WmsLogTag::WMS_LAYOUT, "in");
893     bool dragActivated = true;
894     if (!data.ReadBool(dragActivated)) {
895         TLOGE(WmsLogTag::WMS_LAYOUT, "Read dragActivated failed.");
896         return ERR_INVALID_DATA;
897     }
898     SetDragActivated(dragActivated);
899     return ERR_NONE;
900 }
901 
HandleSetFullScreenWaterfallMode(MessageParcel & data,MessageParcel & reply)902 int SessionStageStub::HandleSetFullScreenWaterfallMode(MessageParcel& data, MessageParcel& reply)
903 {
904     TLOGD(WmsLogTag::WMS_LAYOUT, "in");
905     bool isWaterfallMode = false;
906     if (!data.ReadBool(isWaterfallMode)) {
907         TLOGE(WmsLogTag::WMS_LAYOUT, "Read isWaterfallMode failed.");
908         return ERR_INVALID_DATA;
909     }
910     SetFullScreenWaterfallMode(isWaterfallMode);
911     return ERR_NONE;
912 }
913 
HandleSetSupportEnterWaterfallMode(MessageParcel & data,MessageParcel & reply)914 int SessionStageStub::HandleSetSupportEnterWaterfallMode(MessageParcel& data, MessageParcel& reply)
915 {
916     TLOGD(WmsLogTag::WMS_LAYOUT_PC, "in");
917     bool isSupportEnter = false;
918     if (!data.ReadBool(isSupportEnter)) {
919         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Read isSupportEnter failed.");
920         return ERR_INVALID_DATA;
921     }
922     SetSupportEnterWaterfallMode(isSupportEnter);
923     return ERR_NONE;
924 }
925 
HandleNotifyDumpInfo(MessageParcel & data,MessageParcel & reply)926 int SessionStageStub::HandleNotifyDumpInfo(MessageParcel& data, MessageParcel& reply)
927 {
928     TLOGD(WmsLogTag::WMS_UIEXT, "entry");
929     std::vector<std::string> params;
930     if (!data.ReadStringVector(&params)) {
931         TLOGE(WmsLogTag::WMS_UIEXT, "Failed to read string vector");
932         return ERR_INVALID_VALUE;
933     }
934     std::vector<std::string> infos;
935     WSError errCode = NotifyDumpInfo(params, infos);
936     bool isLittleSize = CalculateDumpInfoSize(infos);
937     if (!reply.WriteBool(isLittleSize)) {
938         TLOGE(WmsLogTag::WMS_UIEXT, "Write isLittleSize failed");
939         return ERR_TRANSACTION_FAILED;
940     }
941 
942     bool writeResult = isLittleSize ? WriteLittleStringVector(infos, reply) :
943         WriteLargeStringVector(infos, reply);
944     if (!writeResult) {
945         TLOGE(WmsLogTag::WMS_UIEXT, "write data failed");
946         return ERR_TRANSACTION_FAILED;
947     }
948 
949     if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
950         TLOGE(WmsLogTag::WMS_UIEXT, "write errCode failed");
951         return ERR_TRANSACTION_FAILED;
952     }
953 
954     return ERR_NONE;
955 }
956 
HandleExtensionHostData(MessageParcel & data,MessageParcel & reply,MessageOption & option)957 int SessionStageStub::HandleExtensionHostData(MessageParcel& data, MessageParcel& reply, MessageOption& option)
958 {
959     TLOGD(WmsLogTag::WMS_UIEXT, "in");
960     static_cast<void>(SendExtensionData(data, reply, option));
961     return ERR_NONE;
962 }
963 
HandleLinkKeyFrameCanvasNode(MessageParcel & data,MessageParcel & reply)964 int SessionStageStub::HandleLinkKeyFrameCanvasNode(MessageParcel& data, MessageParcel& reply)
965 {
966     TLOGD(WmsLogTag::WMS_LAYOUT, "in");
967     auto rsCanvasNode = RSCanvasNode::Unmarshalling(data);
968     if (!rsCanvasNode) {
969         TLOGE(WmsLogTag::WMS_LAYOUT, "fail get rsCanvasNode");
970         return ERR_INVALID_DATA;
971     }
972     LinkKeyFrameCanvasNode(rsCanvasNode);
973     return ERR_NONE;
974 }
975 
HandleSetKeyFramePolicy(MessageParcel & data,MessageParcel & reply)976 int SessionStageStub::HandleSetKeyFramePolicy(MessageParcel& data, MessageParcel& reply)
977 {
978     TLOGD(WmsLogTag::WMS_LAYOUT, "in");
979     sptr<KeyFramePolicy> keyFramePolicy = data.ReadParcelable<KeyFramePolicy>();
980     if (!keyFramePolicy) {
981         TLOGE(WmsLogTag::WMS_LAYOUT, "Read keyFramePolicy failed.");
982         return ERR_INVALID_DATA;
983     }
984     SetKeyFramePolicy(*keyFramePolicy);
985     return ERR_NONE;
986 }
987 
HandleSendContainerModalEvent(MessageParcel & data,MessageParcel & reply)988 int SessionStageStub::HandleSendContainerModalEvent(MessageParcel& data, MessageParcel& reply)
989 {
990     TLOGD(WmsLogTag::WMS_EVENT, "in");
991     std::string eventName = data.ReadString();
992     if (eventName.empty()) {
993         TLOGE(WmsLogTag::WMS_EVENT, "event name is nullptr");
994         return ERR_INVALID_VALUE;
995     }
996     std::string eventValue = data.ReadString();
997     if (eventValue.empty()) {
998         TLOGE(WmsLogTag::WMS_EVENT, "event value  is nullptr");
999         return ERR_INVALID_VALUE;
1000     }
1001     SendContainerModalEvent(eventName, eventValue);
1002     return ERR_NONE;
1003 }
1004 
HandleNotifyHighlightChange(MessageParcel & data,MessageParcel & reply)1005 int SessionStageStub::HandleNotifyHighlightChange(MessageParcel& data, MessageParcel& reply)
1006 {
1007     TLOGD(WmsLogTag::WMS_FOCUS, "called!");
1008     bool isHighlight = false;
1009     if (!data.ReadBool(isHighlight)) {
1010         TLOGE(WmsLogTag::WMS_FOCUS, "Read isHighlight failed.");
1011         return ERR_INVALID_DATA;
1012     }
1013     NotifyHighlightChange(isHighlight);
1014     return ERR_NONE;
1015 }
1016 
HandleNotifyWindowCrossAxisChange(MessageParcel & data,MessageParcel & reply)1017 int SessionStageStub::HandleNotifyWindowCrossAxisChange(MessageParcel& data, MessageParcel& reply)
1018 {
1019     TLOGD(WmsLogTag::WMS_LAYOUT_PC, "in");
1020     uint32_t state = 0;
1021     if (!data.ReadUint32(state)) {
1022         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "Read cross axis state failed.");
1023         return ERR_INVALID_DATA;
1024     }
1025     if (state >= static_cast<uint32_t>(CrossAxisState::STATE_END)) {
1026         TLOGE(WmsLogTag::WMS_LAYOUT_PC, "invalid cross axis state.");
1027         return ERR_INVALID_DATA;
1028     }
1029     NotifyWindowCrossAxisChange(static_cast<CrossAxisState>(state));
1030     return ERR_NONE;
1031 }
1032 
HandleNotifyPipSizeChange(MessageParcel & data,MessageParcel & reply)1033 int SessionStageStub::HandleNotifyPipSizeChange(MessageParcel& data, MessageParcel& reply)
1034 {
1035     TLOGD(WmsLogTag::WMS_PIP, "in");
1036     double width;
1037     if (!data.ReadDouble(width)) {
1038         return ERR_INVALID_VALUE;
1039     }
1040     double height;
1041     if (!data.ReadDouble(height)) {
1042         return ERR_INVALID_VALUE;
1043     }
1044     double scale;
1045     if (!data.ReadDouble(scale)) {
1046         return ERR_INVALID_VALUE;
1047     }
1048     NotifyPipWindowSizeChange(width, height, scale);
1049     return ERR_NONE;
1050 }
1051 
HandleNotifyWindowAttachStateChange(MessageParcel & data,MessageParcel & reply)1052 int SessionStageStub::HandleNotifyWindowAttachStateChange(MessageParcel& data, MessageParcel& reply)
1053 {
1054     TLOGD(WmsLogTag::WMS_SUB, "in");
1055     bool isAttach = false;
1056     if (!data.ReadBool(isAttach)) {
1057         return ERR_INVALID_DATA;
1058     }
1059     NotifyWindowAttachStateChange(isAttach);
1060     return ERR_NONE;
1061 }
1062 
HandleNotifyKeyboardAnimationCompleted(MessageParcel & data,MessageParcel & reply)1063 int SessionStageStub::HandleNotifyKeyboardAnimationCompleted(MessageParcel& data, MessageParcel& reply)
1064 {
1065     TLOGD(WmsLogTag::WMS_KEYBOARD, "in");
1066     sptr<KeyboardPanelInfo> keyboardPanelInfo = data.ReadParcelable<KeyboardPanelInfo>();
1067     if (keyboardPanelInfo == nullptr) {
1068         TLOGE(WmsLogTag::WMS_KEYBOARD, "keyboardPanelInfo is nullptr!");
1069         return ERR_INVALID_VALUE;
1070     }
1071     NotifyKeyboardAnimationCompleted(*keyboardPanelInfo);
1072     return ERR_NONE;
1073 }
1074 
HandleNotifyRotationProperty(MessageParcel & data,MessageParcel & reply)1075 int SessionStageStub::HandleNotifyRotationProperty(MessageParcel& data, MessageParcel& reply)
1076 {
1077     TLOGD(WmsLogTag::WMS_ROTATION, "in");
1078     uint32_t rotation = 0;
1079     if (!data.ReadUint32(rotation)) {
1080         TLOGE(WmsLogTag::WMS_ROTATION, "read rotation failed");
1081         return ERR_INVALID_VALUE;
1082     }
1083 
1084     Rect rect = {0, 0, 0, 0};
1085     if (!data.ReadInt32(rect.posX_) || !data.ReadInt32(rect.posY_) ||
1086         !data.ReadUint32(rect.width_) ||!data.ReadUint32(rect.height_)) {
1087         TLOGE(WmsLogTag::WMS_ROTATION, "read rect failed");
1088         return ERR_INVALID_VALUE;
1089     }
1090     std::map<AvoidAreaType, AvoidArea> avoidAreas;
1091     uint32_t size = 0;
1092     if (!data.ReadUint32(size)) {
1093         TLOGE(WmsLogTag::WMS_ROTATION, "read avoid area size failed");
1094         return ERR_INVALID_VALUE;
1095     }
1096     constexpr uint32_t AVOID_AREA_TYPE_MAX_SIZE = 100;
1097     if (size > AVOID_AREA_TYPE_MAX_SIZE) {
1098         TLOGE(WmsLogTag::WMS_ROTATION, "avoid area size is invalid");
1099         return ERR_INVALID_VALUE;
1100     }
1101     for (uint32_t i = 0; i < size; i++) {
1102         uint32_t type = data.ReadUint32();
1103         if (type < static_cast<uint32_t>(AvoidAreaType::TYPE_START) ||
1104             type >= static_cast<uint32_t>(AvoidAreaType::TYPE_END)) {
1105             TLOGE(WmsLogTag::WMS_ROTATION, "avoid area type invalid");
1106             return ERR_INVALID_VALUE;
1107         }
1108         sptr<AvoidArea> area = data.ReadParcelable<AvoidArea>();
1109         if (area == nullptr) {
1110             TLOGE(WmsLogTag::WMS_ROTATION, "read avoid area invalid");
1111             return ERR_INVALID_VALUE;
1112         }
1113         avoidAreas[static_cast<AvoidAreaType>(type)] = *area;
1114     }
1115 
1116     OrientationInfo info = { rotation, rect, avoidAreas };
1117     NotifyTargetRotationInfo(info);
1118     return ERR_NONE;
1119 }
1120 
HandleNotifyRotationChange(MessageParcel & data,MessageParcel & reply)1121 int SessionStageStub::HandleNotifyRotationChange(MessageParcel& data, MessageParcel& reply)
1122 {
1123     TLOGD(WmsLogTag::WMS_ROTATION, "in");
1124     uint32_t type = 0;
1125     if (!data.ReadUint32(type)) {
1126         TLOGE(WmsLogTag::WMS_ROTATION, "read type failed");
1127         return ERR_INVALID_DATA;
1128     }
1129     uint32_t orientation = 0;
1130     if (!data.ReadUint32(orientation)) {
1131         TLOGE(WmsLogTag::WMS_ROTATION, "read orientation failed");
1132         return ERR_INVALID_DATA;
1133     }
1134     uint64_t displayId = 0;
1135     if (!data.ReadUint64(displayId)) {
1136         TLOGE(WmsLogTag::WMS_ROTATION, "read displayId failed");
1137         return ERR_INVALID_DATA;
1138     }
1139 
1140     Rect rect = { 0, 0, 0, 0 };
1141     if (!data.ReadInt32(rect.posX_) || !data.ReadInt32(rect.posY_) ||
1142         !data.ReadUint32(rect.width_) || !data.ReadUint32(rect.height_)) {
1143         TLOGE(WmsLogTag::WMS_ROTATION, "read rect failed");
1144         return ERR_INVALID_DATA;
1145     }
1146     RotationChangeInfo rotationChangeInfo = { static_cast<RotationChangeType>(type), orientation, displayId, rect };
1147     RotationChangeResult rotationChangeResult = NotifyRotationChange(rotationChangeInfo);
1148     if (rotationChangeInfo.type_ == RotationChangeType::WINDOW_DID_ROTATE) {
1149         TLOGI(WmsLogTag::WMS_ROTATION, "WINDOW_DID_ROTATE return");
1150         return ERR_NONE;
1151     }
1152     if (!reply.WriteUint32(static_cast<uint32_t>(rotationChangeResult.rectType_))) {
1153         TLOGE(WmsLogTag::WMS_ROTATION, "send rectType failed");
1154         return ERR_INVALID_DATA;
1155     }
1156     if (!reply.WriteInt32(rotationChangeResult.windowRect_.posX_) ||
1157         !reply.WriteInt32(rotationChangeResult.windowRect_.posY_) ||
1158         !reply.WriteUint32(rotationChangeResult.windowRect_.width_) ||
1159         !reply.WriteUint32(rotationChangeResult.windowRect_.height_)) {
1160         TLOGE(WmsLogTag::WMS_ROTATION, "send window rect failed");
1161         return ERR_INVALID_DATA;
1162     }
1163     TLOGI(WmsLogTag::WMS_ROTATION, "send type:%{public}d, rect: [%{public}d, %{public}d, %{public}d, %{public}d]",
1164         rotationChangeResult.rectType_, rotationChangeResult.windowRect_.posX_, rotationChangeResult.windowRect_.posY_,
1165         rotationChangeResult.windowRect_.width_, rotationChangeResult.windowRect_.height_);
1166     return ERR_NONE;
1167 }
1168 
HandleSetCurrentRotation(MessageParcel & data,MessageParcel & reply)1169 int SessionStageStub::HandleSetCurrentRotation(MessageParcel& data, MessageParcel& reply)
1170 {
1171     TLOGD(WmsLogTag::WMS_ROTATION, "in");
1172     int32_t currentRotation;
1173     if (!data.ReadInt32(currentRotation)) {
1174         return ERR_INVALID_VALUE;
1175     }
1176     SetCurrentRotation(currentRotation);
1177     return ERR_NONE;
1178 }
1179 
HandleNotifyAppForceLandscapeConfigUpdated(MessageParcel & data,MessageParcel & reply)1180 int SessionStageStub::HandleNotifyAppForceLandscapeConfigUpdated(MessageParcel& data, MessageParcel& reply)
1181 {
1182     TLOGD(WmsLogTag::DEFAULT, "in");
1183     NotifyAppForceLandscapeConfigUpdated();
1184     return ERR_NONE;
1185 }
1186 
HandleNotifyAppHookWindowInfoUpdated(MessageParcel & data,MessageParcel & reply)1187 int SessionStageStub::HandleNotifyAppHookWindowInfoUpdated(MessageParcel& data, MessageParcel& reply)
1188 {
1189     TLOGD(WmsLogTag::WMS_LAYOUT, "in");
1190     NotifyAppHookWindowInfoUpdated();
1191     return ERR_NONE;
1192 }
1193 
HandleNotifyKeyboardAnimationWillBegin(MessageParcel & data,MessageParcel & reply)1194 int SessionStageStub::HandleNotifyKeyboardAnimationWillBegin(MessageParcel& data, MessageParcel& reply)
1195 {
1196     TLOGD(WmsLogTag::WMS_KEYBOARD, "in");
1197     sptr<KeyboardAnimationInfo> keyboardAnimationInfo = data.ReadParcelable<KeyboardAnimationInfo>();
1198     if (keyboardAnimationInfo == nullptr) {
1199         TLOGE(WmsLogTag::WMS_KEYBOARD, "keyboardAnimationInfo is nullptr!");
1200         return ERR_INVALID_VALUE;
1201     }
1202 
1203     std::shared_ptr<RSTransaction> transaction(data.ReadParcelable<RSTransaction>());
1204     NotifyKeyboardAnimationWillBegin(*keyboardAnimationInfo, transaction);
1205     return ERR_NONE;
1206 }
1207 
HandleGetRouterStackInfo(MessageParcel & data,MessageParcel & reply)1208 int SessionStageStub::HandleGetRouterStackInfo(MessageParcel& data, MessageParcel& reply)
1209 {
1210     std::string routerStackInfo;
1211     WMError errCode = GetRouterStackInfo(routerStackInfo);
1212     if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
1213         return ERR_INVALID_DATA;
1214     }
1215     if (!reply.WriteString(routerStackInfo)) {
1216         return ERR_INVALID_DATA;
1217     }
1218     return ERR_NONE;
1219 }
1220 
HandleCloseSpecificScene(MessageParcel & data,MessageParcel & reply)1221 int SessionStageStub::HandleCloseSpecificScene(MessageParcel& data, MessageParcel& reply)
1222 {
1223     TLOGD(WmsLogTag::WMS_EVENT, "in");
1224     CloseSpecificScene();
1225     return ERR_NONE;
1226 }
1227 } // namespace OHOS::Rosen
1228