• 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_HANDLE_BACK_EVENT):
108             return HandleBackEventInner(data, reply);
109         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DESTROY):
110             return HandleNotifyDestroy(data, reply);
111         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_FOCUS_CHANGE):
112             return HandleUpdateFocus(data, reply);
113         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TRANSFER_COMPONENT_DATA):
114             return HandleNotifyTransferComponentData(data, reply);
115         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TRANSFER_COMPONENT_DATA_SYNC):
116             return HandleNotifyTransferComponentDataSync(data, reply);
117         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_OCCUPIED_AREA_CHANGE_INFO):
118             return HandleNotifyOccupiedAreaChange(data, reply);
119         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_UPDATE_AVOID_AREA):
120             return HandleUpdateAvoidArea(data, reply);
121         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SCREEN_SHOT):
122             return HandleNotifyScreenshot(data, reply);
123         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_DUMP_SESSSION_ELEMENT_INFO):
124             return HandleDumpSessionElementInfo(data, reply);
125         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TOUCH_OUTSIDE):
126             return HandleNotifyTouchOutside(data, reply);
127         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_MODE_CHANGE):
128             return HandleUpdateWindowMode(data, reply);
129         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_FOREGROUND_INTERACTIVE_STATUS):
130             return HandleNotifyForegroundInteractiveStatus(data, reply);
131         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_MAXIMIZE_MODE_CHANGE):
132             return HandleUpdateMaximizeMode(data, reply);
133         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_CLOSE_EXIST_PIP_WINDOW):
134             return HandleNotifyCloseExistPipWindow(data, reply);
135         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_FOREGROUND):
136             return HandleNotifySessionForeground(data, reply);
137         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_BACKGROUND):
138             return HandleNotifySessionBackground(data, reply);
139         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TITLE_POSITION_CHANGE):
140             return HandleUpdateTitleInTargetPos(data, reply);
141         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DENSITY_FOLLOW_HOST):
142             return HandleNotifyDensityFollowHost(data, reply);
143         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_VISIBILITY_CHANGE):
144             return HandleNotifyWindowVisibilityChange(data, reply);
145         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_TRANSFORM_CHANGE):
146             return HandleNotifyTransformChange(data, reply);
147         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SINGLE_HAND_TRANSFORM):
148             return HandleNotifySingleHandTransformChange(data, reply);
149         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DIALOG_STATE_CHANGE):
150             return HandleNotifyDialogStateChange(data, reply);
151         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_PIP_ACTION_EVENT):
152             return HandleSetPipActionEvent(data, reply);
153         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_PIP_CONTROL_EVENT):
154             return HandleSetPiPControlEvent(data, reply);
155         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DISPLAYID_CHANGE):
156             return HandleUpdateDisplayId(data, reply);
157         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DISPLAY_MOVE):
158             return HandleNotifyDisplayMove(data, reply);
159         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SWITCH_FREEMULTIWINDOW):
160             return HandleSwitchFreeMultiWindow(data, reply);
161         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_GET_UI_CONTENT_REMOTE_OBJ):
162             return HandleGetUIContentRemoteObj(data, reply);
163         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_KEYBOARD_INFO_CHANGE):
164             return HandleNotifyKeyboardPanelInfoChange(data, reply);
165         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_COMPATIBLE_MODE_ENABLE):
166             return HandleNotifyCompatibleModeEnableInPad(data, reply);
167         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DENSITY_UNIQUE):
168             return HandleSetUniqueVirtualPixelRatio(data, reply);
169         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_FULLSCREEN):
170             return HandleNotifySessionFullScreen(data, reply);
171         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_DUMP_INFO):
172             return HandleNotifyDumpInfo(data, reply);
173         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_ENABLE_DRAG_BY_SYSTEM):
174             return HandleSetEnableDragBySystem(data, reply);
175         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SEND_EXTENSION_DATA):
176             return HandleExtensionHostData(data, reply, option);
177         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_SET_DRAG_ACTIVATED):
178             return HandleSetDragActivated(data, reply);
179         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_PIPSIZE_CHANGE):
180             return HandleNotifyPipSizeChange(data, reply);
181         case static_cast<uint32_t>(SessionStageInterfaceCode::TRANS_ID_NOTIFY_WINDOW_ATTACH_STATE_CHANGE):
182             return HandleNotifyWindowAttachStateChange(data, reply);
183         default:
184             WLOGFE("Failed to find function handler!");
185             return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
186     }
187 }
188 
HandleSetActive(MessageParcel & data,MessageParcel & reply)189 int SessionStageStub::HandleSetActive(MessageParcel& data, MessageParcel& reply)
190 {
191     WLOGFD("SetActive!");
192     bool active = data.ReadBool();
193     WSError errCode = SetActive(active);
194     reply.WriteUint32(static_cast<uint32_t>(errCode));
195     return ERR_NONE;
196 }
197 
HandleUpdateRect(MessageParcel & data,MessageParcel & reply)198 int SessionStageStub::HandleUpdateRect(MessageParcel& data, MessageParcel& reply)
199 {
200     WLOGFD("UpdateRect!");
201     WSRect rect = { data.ReadInt32(), data.ReadInt32(), data.ReadUint32(), data.ReadUint32() };
202     SizeChangeReason reason = static_cast<SizeChangeReason>(data.ReadUint32());
203     SceneAnimationConfig config { .rsTransaction_ = nullptr, .animationDuration_ = 0 };
204     bool hasRSTransaction = data.ReadBool();
205     if (hasRSTransaction) {
206         std::shared_ptr<RSTransaction> transaction(data.ReadParcelable<RSTransaction>());
207         if (!transaction) {
208             WLOGFE("transaction unMarsh failed");
209             return -1;
210         }
211         config.rsTransaction_ = transaction;
212     }
213     if (!data.ReadInt32(config.animationDuration_)) {
214         TLOGE(WmsLogTag::WMS_LAYOUT, "read animationDuration failed");
215         return -1;
216     }
217     std::map<AvoidAreaType, AvoidArea> avoidAreas;
218     uint32_t size = 0;
219     if (!data.ReadUint32(size)) {
220         TLOGE(WmsLogTag::WMS_IMMS, "read avoid area size failed");
221         return -1;
222     }
223     constexpr uint32_t AVOID_AREA_TYPE_MAX_SIZE = 100;
224     if (size > AVOID_AREA_TYPE_MAX_SIZE) {
225         TLOGE(WmsLogTag::WMS_IMMS, "avoid area size is invalid");
226         return -1;
227     }
228     for (uint32_t i = 0; i < size; i++) {
229         uint32_t type = data.ReadUint32();
230         if (type < static_cast<uint32_t>(AvoidAreaType::TYPE_SYSTEM) ||
231             type > static_cast<uint32_t>(AvoidAreaType::TYPE_NAVIGATION_INDICATOR)) {
232             TLOGE(WmsLogTag::WMS_IMMS, "read avoid area type failed");
233             return -1;
234         }
235         sptr<AvoidArea> area = data.ReadParcelable<AvoidArea>();
236         if (area == nullptr) {
237             TLOGE(WmsLogTag::WMS_IMMS, "read avoid area failed");
238             return -1;
239         }
240         avoidAreas[static_cast<AvoidAreaType>(type)] = *area;
241     }
242     WSError errCode = UpdateRect(rect, reason, config, avoidAreas);
243     reply.WriteUint32(static_cast<uint32_t>(errCode));
244     return ERR_NONE;
245 }
246 
HandleUpdateDensity(MessageParcel & data,MessageParcel & reply)247 int SessionStageStub::HandleUpdateDensity(MessageParcel& data, MessageParcel& reply)
248 {
249     WLOGFD("UpdateDensity!");
250     UpdateDensity();
251     return ERR_NONE;
252 }
253 
HandleUpdateOrientation(MessageParcel & data,MessageParcel & reply)254 int SessionStageStub::HandleUpdateOrientation(MessageParcel& data, MessageParcel& reply)
255 {
256     TLOGD(WmsLogTag::DMS, "HandleUpdateOrientation!");
257     WSError errCode = UpdateOrientation();
258     reply.WriteInt32(static_cast<int32_t>(errCode));
259     return ERR_NONE;
260 }
261 
HandleBackEventInner(MessageParcel & data,MessageParcel & reply)262 int SessionStageStub::HandleBackEventInner(MessageParcel& data, MessageParcel& reply)
263 {
264     WLOGFD("HandleBackEventInner!");
265     WSError errCode = HandleBackEvent();
266     reply.WriteUint32(static_cast<uint32_t>(errCode));
267     return ERR_NONE;
268 }
269 
HandleNotifyDestroy(MessageParcel & data,MessageParcel & reply)270 int SessionStageStub::HandleNotifyDestroy(MessageParcel& data, MessageParcel& reply)
271 {
272     WLOGFD("Notify Destroy");
273     WSError errCode = NotifyDestroy();
274     reply.WriteUint32(static_cast<uint32_t>(errCode));
275     return ERR_NONE;
276 }
277 
HandleNotifyCloseExistPipWindow(MessageParcel & data,MessageParcel & reply)278 int SessionStageStub::HandleNotifyCloseExistPipWindow(MessageParcel& data, MessageParcel& reply)
279 {
280     TLOGD(WmsLogTag::WMS_PIP, "Notify Pip AlreadyExists");
281     WSError errCode = NotifyCloseExistPipWindow();
282     reply.WriteUint32(static_cast<uint32_t>(errCode));
283     return ERR_NONE;
284 }
285 
HandleUpdateFocus(MessageParcel & data,MessageParcel & reply)286 int SessionStageStub::HandleUpdateFocus(MessageParcel& data, MessageParcel& reply)
287 {
288     WLOGFD("UpdateFocus!");
289     bool isFocused = data.ReadBool();
290     WSError errCode = UpdateFocus(isFocused);
291     reply.WriteUint32(static_cast<uint32_t>(errCode));
292     return ERR_NONE;
293 }
294 
HandleNotifyTransferComponentData(MessageParcel & data,MessageParcel & reply)295 int SessionStageStub::HandleNotifyTransferComponentData(MessageParcel& data, MessageParcel& reply)
296 {
297     WLOGFD("HandleNotifyTransferComponentData!");
298     std::shared_ptr<AAFwk::WantParams> wantParams(data.ReadParcelable<AAFwk::WantParams>());
299     if (wantParams == nullptr) {
300         WLOGFE("wantParams is nullptr");
301         return ERR_INVALID_VALUE;
302     }
303     WSError errCode = NotifyTransferComponentData(*wantParams);
304     reply.WriteUint32(static_cast<uint32_t>(errCode));
305     return ERR_NONE;
306 }
307 
HandleNotifyTransferComponentDataSync(MessageParcel & data,MessageParcel & reply)308 int SessionStageStub::HandleNotifyTransferComponentDataSync(MessageParcel& data, MessageParcel& reply)
309 {
310     std::shared_ptr<AAFwk::WantParams> wantParams(data.ReadParcelable<AAFwk::WantParams>());
311     if (wantParams == nullptr) {
312         WLOGFE("wantParams is nullptr");
313         return static_cast<int>(WSErrorCode::WS_ERROR_TRANSFER_DATA_FAILED);
314     }
315     AAFwk::WantParams reWantParams;
316     WSErrorCode errCode = NotifyTransferComponentDataSync(*wantParams, reWantParams);
317     if (errCode != WSErrorCode::WS_OK) {
318         return static_cast<int>(errCode);
319     }
320     if (!reply.WriteParcelable(&reWantParams)) {
321         WLOGFE("reWantParams write failed.");
322         return static_cast<int>(WSErrorCode::WS_ERROR_TRANSFER_DATA_FAILED);
323     }
324     return static_cast<int>(WSErrorCode::WS_OK);
325 }
326 
HandleNotifyOccupiedAreaChange(MessageParcel & data,MessageParcel & reply)327 int SessionStageStub::HandleNotifyOccupiedAreaChange(MessageParcel& data, MessageParcel& reply)
328 {
329     TLOGD(WmsLogTag::WMS_KEYBOARD, "HandleNotifyOccupiedAreaChangeInfo!");
330     sptr<OccupiedAreaChangeInfo> info(data.ReadParcelable<OccupiedAreaChangeInfo>());
331     if (info == nullptr) {
332         TLOGE(WmsLogTag::WMS_KEYBOARD, "Occupied info is nullptr");
333         return ERR_INVALID_VALUE;
334     }
335 
336     bool hasRSTransaction = data.ReadBool();
337     if (hasRSTransaction) {
338         std::shared_ptr<RSTransaction> transaction(data.ReadParcelable<RSTransaction>());
339         if (!transaction) {
340             TLOGE(WmsLogTag::WMS_KEYBOARD, "transaction unMarsh failed");
341             return ERR_INVALID_VALUE;
342         }
343         NotifyOccupiedAreaChangeInfo(info, transaction);
344     } else {
345         NotifyOccupiedAreaChangeInfo(info);
346     }
347 
348     return ERR_NONE;
349 }
350 
HandleUpdateAvoidArea(MessageParcel & data,MessageParcel & reply)351 int SessionStageStub::HandleUpdateAvoidArea(MessageParcel& data, MessageParcel& reply)
352 {
353     WLOGFD("HandleUpdateAvoidArea!");
354     sptr<AvoidArea> avoidArea = data.ReadStrongParcelable<AvoidArea>();
355     if (!avoidArea) {
356         return ERR_INVALID_VALUE;
357     }
358     uint32_t type;
359     if (!data.ReadUint32(type)) {
360         return ERR_INVALID_VALUE;
361     }
362     UpdateAvoidArea(avoidArea, static_cast<AvoidAreaType>(type));
363     return ERR_NONE;
364 }
365 
HandleNotifyScreenshot(MessageParcel & data,MessageParcel & reply)366 int SessionStageStub::HandleNotifyScreenshot(MessageParcel& data, MessageParcel& reply)
367 {
368     WLOGFD("Notify Screen shot!");
369     NotifyScreenshot();
370     return ERR_NONE;
371 }
372 
HandleDumpSessionElementInfo(MessageParcel & data,MessageParcel & reply)373 int SessionStageStub::HandleDumpSessionElementInfo(MessageParcel& data, MessageParcel& reply)
374 {
375     WLOGFD("HandleDumpSessionElementInfo!");
376     std::vector<std::string> params;
377     if (!data.ReadStringVector(&params)) {
378         WLOGFE("Fail to read params");
379         return -1;
380     }
381     DumpSessionElementInfo(params);
382     return ERR_NONE;
383 }
384 
HandleNotifyTouchOutside(MessageParcel & data,MessageParcel & reply)385 int SessionStageStub::HandleNotifyTouchOutside(MessageParcel& data, MessageParcel& reply)
386 {
387     WLOGFD("HandleNotifyTouchOutside!");
388     NotifyTouchOutside();
389     return ERR_NONE;
390 }
391 
HandleUpdateWindowMode(MessageParcel & data,MessageParcel & reply)392 int SessionStageStub::HandleUpdateWindowMode(MessageParcel& data, MessageParcel& reply)
393 {
394     WLOGFD("HandleUpdateWindowMode!");
395     WindowMode mode = static_cast<WindowMode>(data.ReadUint32());
396     WSError errCode = UpdateWindowMode(mode);
397     reply.WriteInt32(static_cast<int32_t>(errCode));
398     return ERR_NONE;
399 }
400 
HandleNotifyWindowVisibilityChange(MessageParcel & data,MessageParcel & reply)401 int SessionStageStub::HandleNotifyWindowVisibilityChange(MessageParcel& data, MessageParcel& reply)
402 {
403     WLOGFD("HandleNotifyWindowVisibilityChange!");
404     bool isVisible = data.ReadBool();
405     WSError errCode = NotifyWindowVisibility(isVisible);
406     reply.WriteInt32(static_cast<int32_t>(errCode));
407     return ERR_NONE;
408 }
409 
HandleNotifyForegroundInteractiveStatus(MessageParcel & data,MessageParcel & reply)410 int SessionStageStub::HandleNotifyForegroundInteractiveStatus(MessageParcel& data, MessageParcel& reply)
411 {
412     WLOGFD("NotifyForegroundInteractiveStatus!");
413     bool interactive = data.ReadBool();
414     NotifyForegroundInteractiveStatus(interactive);
415     return ERR_NONE;
416 }
417 
HandleUpdateMaximizeMode(MessageParcel & data,MessageParcel & reply)418 int SessionStageStub::HandleUpdateMaximizeMode(MessageParcel& data, MessageParcel& reply)
419 {
420     WLOGFD("HandleUpdateMaximizeMode!");
421     MaximizeMode mode = static_cast<MaximizeMode>(data.ReadUint32());
422     WSError errCode = UpdateMaximizeMode(mode);
423     reply.WriteInt32(static_cast<int32_t>(errCode));
424     return ERR_NONE;
425 }
426 
HandleNotifySessionForeground(MessageParcel & data,MessageParcel & reply)427 int SessionStageStub::HandleNotifySessionForeground(MessageParcel& data, MessageParcel& reply)
428 {
429     WLOGFD("HandleNotifySessionForeground");
430     uint32_t reason = data.ReadUint32();
431     bool withAnimation = data.ReadBool();
432     NotifySessionForeground(reason, withAnimation);
433     return ERR_NONE;
434 }
435 
HandleNotifySessionFullScreen(MessageParcel & data,MessageParcel & reply)436 int SessionStageStub::HandleNotifySessionFullScreen(MessageParcel& data, MessageParcel& reply)
437 {
438     TLOGD(WmsLogTag::WMS_LAYOUT, "called");
439     bool fullScreen = data.ReadBool();
440     NotifySessionFullScreen(fullScreen);
441     return ERR_NONE;
442 }
443 
HandleNotifySessionBackground(MessageParcel & data,MessageParcel & reply)444 int SessionStageStub::HandleNotifySessionBackground(MessageParcel& data, MessageParcel& reply)
445 {
446     WLOGFD("HandleNotifySessionBackground");
447     uint32_t reason = data.ReadUint32();
448     bool withAnimation = data.ReadBool();
449     bool isFromInnerkits = data.ReadBool();
450     NotifySessionBackground(reason, withAnimation, isFromInnerkits);
451     return ERR_NONE;
452 }
453 
HandleUpdateTitleInTargetPos(MessageParcel & data,MessageParcel & reply)454 int SessionStageStub::HandleUpdateTitleInTargetPos(MessageParcel& data, MessageParcel& reply)
455 {
456     WLOGFD("HandleUpdateTitleInTargetPos!");
457     bool isShow = data.ReadBool();
458     int32_t height = data.ReadInt32();
459     WSError errCode = UpdateTitleInTargetPos(isShow, height);
460     reply.WriteInt32(static_cast<int32_t>(errCode));
461     return ERR_NONE;
462 }
463 
HandleNotifyTransformChange(MessageParcel & data,MessageParcel & reply)464 int SessionStageStub::HandleNotifyTransformChange(MessageParcel& data, MessageParcel& reply)
465 {
466     WLOGFD("HandleNotifyTransformChange!");
467     Transform transform;
468     transform.Unmarshalling(data);
469     NotifyTransformChange(transform);
470     return ERR_NONE;
471 }
472 
HandleNotifySingleHandTransformChange(MessageParcel & data,MessageParcel & reply)473 int SessionStageStub::HandleNotifySingleHandTransformChange(MessageParcel& data, MessageParcel& reply)
474 {
475     TLOGD(WmsLogTag::WMS_LAYOUT, "in");
476     SingleHandTransform singleHandTransform;
477     singleHandTransform.Unmarshalling(data);
478     NotifySingleHandTransformChange(singleHandTransform);
479     return ERR_NONE;
480 }
481 
HandleNotifyDensityFollowHost(MessageParcel & data,MessageParcel & reply)482 int SessionStageStub::HandleNotifyDensityFollowHost(MessageParcel& data, MessageParcel& reply)
483 {
484     TLOGD(WmsLogTag::WMS_UIEXT, "HandleNotifyDensityFollowHost");
485     bool isFollowHost = data.ReadBool();
486     float densityValue = data.ReadFloat();
487     NotifyDensityFollowHost(isFollowHost, densityValue);
488     return ERR_NONE;
489 }
490 
HandleNotifyDialogStateChange(MessageParcel & data,MessageParcel & reply)491 int SessionStageStub::HandleNotifyDialogStateChange(MessageParcel& data, MessageParcel& reply)
492 {
493     WLOGD("HandleNotifyDialogStateChange!");
494     bool isForeground = data.ReadBool();
495     NotifyDialogStateChange(isForeground);
496     return ERR_NONE;
497 }
498 
HandleSetPipActionEvent(MessageParcel & data,MessageParcel & reply)499 int SessionStageStub::HandleSetPipActionEvent(MessageParcel& data, MessageParcel& reply)
500 {
501     TLOGD(WmsLogTag::WMS_PIP, "HandleSetPipActionEvent");
502     std::string action = data.ReadString();
503     if (action.empty()) {
504         TLOGE(WmsLogTag::WMS_PIP, "SessionStageStub pip action event is nullptr");
505         return ERR_INVALID_VALUE;
506     }
507     int32_t status;
508     if (!data.ReadInt32(status)) {
509         return ERR_INVALID_VALUE;
510     }
511     SetPipActionEvent(action, status);
512     return ERR_NONE;
513 }
514 
HandleSetPiPControlEvent(MessageParcel & data,MessageParcel & reply)515 int SessionStageStub::HandleSetPiPControlEvent(MessageParcel& data, MessageParcel& reply)
516 {
517     TLOGD(WmsLogTag::WMS_PIP, "called");
518     uint32_t controlType;
519     if (!data.ReadUint32(controlType)) {
520         return ERR_INVALID_VALUE;
521     }
522     int32_t status;
523     if (!data.ReadInt32(status)) {
524         return ERR_INVALID_VALUE;
525     }
526     SetPiPControlEvent(static_cast<WsPiPControlType>(controlType), static_cast<WsPiPControlStatus>(status));
527     return ERR_NONE;
528 }
529 
HandleUpdateDisplayId(MessageParcel & data,MessageParcel & reply)530 int SessionStageStub::HandleUpdateDisplayId(MessageParcel& data, MessageParcel& reply)
531 {
532     WLOGD("UpdateDisplayId!");
533     uint64_t displayId = data.ReadUint64();
534     WSError errCode = UpdateDisplayId(displayId);
535     reply.WriteInt32(static_cast<int32_t>(errCode));
536     return ERR_NONE;
537 }
538 
HandleNotifyDisplayMove(MessageParcel & data,MessageParcel & reply)539 int SessionStageStub::HandleNotifyDisplayMove(MessageParcel& data, MessageParcel& reply)
540 {
541     WLOGD("HandleNotifyDisplayMove!");
542     DisplayId from = static_cast<DisplayId>(data.ReadUint64());
543     DisplayId to = static_cast<DisplayId>(data.ReadUint64());
544     NotifyDisplayMove(from, to);
545     return ERR_NONE;
546 }
547 
HandleSwitchFreeMultiWindow(MessageParcel & data,MessageParcel & reply)548 int SessionStageStub::HandleSwitchFreeMultiWindow(MessageParcel& data, MessageParcel& reply)
549 {
550     TLOGD(WmsLogTag::WMS_LAYOUT, "HandleSwitchFreeMultiWindow!");
551     bool enable = data.ReadBool();
552     WSError errCode = SwitchFreeMultiWindow(enable);
553     reply.WriteInt32(static_cast<int32_t>(errCode));
554 
555     return ERR_NONE;
556 }
557 
HandleGetUIContentRemoteObj(MessageParcel & data,MessageParcel & reply)558 int SessionStageStub::HandleGetUIContentRemoteObj(MessageParcel& data, MessageParcel& reply)
559 {
560     TLOGI(WmsLogTag::DEFAULT, "Called");
561     sptr<IRemoteObject> uiContentRemoteObj;
562     WSError errCode = GetUIContentRemoteObj(uiContentRemoteObj);
563     reply.WriteRemoteObject(uiContentRemoteObj);
564     reply.WriteInt32(static_cast<int32_t>(errCode));
565     return ERR_NONE;
566 }
567 
HandleNotifyKeyboardPanelInfoChange(MessageParcel & data,MessageParcel & reply)568 int SessionStageStub::HandleNotifyKeyboardPanelInfoChange(MessageParcel& data, MessageParcel& reply)
569 {
570     TLOGD(WmsLogTag::WMS_KEYBOARD, "HandleNotifyKeyboardPanelInfoChange!");
571     sptr<KeyboardPanelInfo> keyboardPanelInfo = data.ReadParcelable<KeyboardPanelInfo>();
572     if (keyboardPanelInfo == nullptr) {
573         TLOGE(WmsLogTag::WMS_KEYBOARD, "keyboardPanelInfo is nullptr!");
574         return ERR_INVALID_VALUE;
575     }
576     NotifyKeyboardPanelInfoChange(*keyboardPanelInfo);
577 
578     return ERR_NONE;
579 }
580 
HandleSetUniqueVirtualPixelRatio(MessageParcel & data,MessageParcel & reply)581 int SessionStageStub::HandleSetUniqueVirtualPixelRatio(MessageParcel& data, MessageParcel& reply)
582 {
583     TLOGD(WmsLogTag::DEFAULT, "HandleSetUniqueVirtualPixelRatio!");
584     bool useUniqueDensity = data.ReadBool();
585     float densityValue = data.ReadFloat();
586     SetUniqueVirtualPixelRatio(useUniqueDensity, densityValue);
587     return ERR_NONE;
588 }
589 
HandleNotifyCompatibleModeEnableInPad(MessageParcel & data,MessageParcel & reply)590 int SessionStageStub::HandleNotifyCompatibleModeEnableInPad(MessageParcel& data, MessageParcel& reply)
591 {
592     bool enable = data.ReadBool();
593     WSError errCode = NotifyCompatibleModeEnableInPad(enable);
594     reply.WriteInt32(static_cast<int32_t>(errCode));
595     return ERR_NONE;
596 }
597 
HandleSetEnableDragBySystem(MessageParcel & data,MessageParcel & reply)598 int SessionStageStub::HandleSetEnableDragBySystem(MessageParcel& data, MessageParcel& reply)
599 {
600     TLOGD(WmsLogTag::WMS_LAYOUT, "in");
601     bool enableDrag = true;
602     if (!data.ReadBool(enableDrag)) {
603         TLOGE(WmsLogTag::WMS_LAYOUT, "Read enableDrag failed.");
604         return ERR_INVALID_DATA;
605     }
606     SetEnableDragBySystem(enableDrag);
607     return ERR_NONE;
608 }
609 
HandleSetDragActivated(MessageParcel & data,MessageParcel & reply)610 int SessionStageStub::HandleSetDragActivated(MessageParcel& data, MessageParcel& reply)
611 {
612     TLOGD(WmsLogTag::WMS_LAYOUT, "in");
613     bool dragActivated = true;
614     if (!data.ReadBool(dragActivated)) {
615         TLOGE(WmsLogTag::WMS_LAYOUT, "Read dragActivated failed.");
616         return ERR_INVALID_DATA;
617     }
618     SetDragActivated(dragActivated);
619     return ERR_NONE;
620 }
621 
HandleNotifyDumpInfo(MessageParcel & data,MessageParcel & reply)622 int SessionStageStub::HandleNotifyDumpInfo(MessageParcel& data, MessageParcel& reply)
623 {
624     TLOGD(WmsLogTag::WMS_UIEXT, "entry");
625     std::vector<std::string> params;
626     if (!data.ReadStringVector(&params)) {
627         TLOGE(WmsLogTag::WMS_UIEXT, "Failed to read string vector");
628         return ERR_INVALID_VALUE;
629     }
630     std::vector<std::string> infos;
631     WSError errCode = NotifyDumpInfo(params, infos);
632     bool isLittleSize = CalculateDumpInfoSize(infos);
633     if (!reply.WriteBool(isLittleSize)) {
634         TLOGE(WmsLogTag::WMS_UIEXT, "Write isLittleSize failed");
635         return ERR_TRANSACTION_FAILED;
636     }
637 
638     bool writeResult = isLittleSize ? WriteLittleStringVector(infos, reply) :
639         WriteLargeStringVector(infos, reply);
640     if (!writeResult) {
641         TLOGE(WmsLogTag::WMS_UIEXT, "write data failed");
642         return ERR_TRANSACTION_FAILED;
643     }
644 
645     if (!reply.WriteInt32(static_cast<int32_t>(errCode))) {
646         TLOGE(WmsLogTag::WMS_UIEXT, "write errCode failed");
647         return ERR_TRANSACTION_FAILED;
648     }
649 
650     return ERR_NONE;
651 }
652 
HandleExtensionHostData(MessageParcel & data,MessageParcel & reply,MessageOption & option)653 int SessionStageStub::HandleExtensionHostData(MessageParcel& data, MessageParcel& reply, MessageOption& option)
654 {
655     TLOGD(WmsLogTag::WMS_UIEXT, "in");
656     static_cast<void>(SendExtensionData(data, reply, option));
657     return ERR_NONE;
658 }
659 
HandleNotifyPipSizeChange(MessageParcel & data,MessageParcel & reply)660 int SessionStageStub::HandleNotifyPipSizeChange(MessageParcel& data, MessageParcel& reply)
661 {
662     TLOGD(WmsLogTag::WMS_PIP, "in");
663     uint32_t width;
664     if (!data.ReadUint32(width)) {
665         return ERR_INVALID_VALUE;
666     }
667     uint32_t height;
668     if (!data.ReadUint32(height)) {
669         return ERR_INVALID_VALUE;
670     }
671     float scale;
672     if (!data.ReadFloat(scale)) {
673         return ERR_INVALID_VALUE;
674     }
675     NotifyPipWindowSizeChange(width, height, scale);
676     return ERR_NONE;
677 }
678 
HandleNotifyHighlightChange(MessageParcel & data,MessageParcel & reply)679 int SessionStageStub::HandleNotifyHighlightChange(MessageParcel& data, MessageParcel& reply)
680 {
681     TLOGD(WmsLogTag::WMS_FOCUS, "called!");
682     bool isHighlight = false;
683     if (!data.ReadBool(isHighlight)) {
684         TLOGE(WmsLogTag::WMS_FOCUS, "Read isHighlight failed.");
685         return ERR_INVALID_DATA;
686     }
687     NotifyHighlightChange(isHighlight);
688     return ERR_NONE;
689 }
690 
HandleNotifyWindowAttachStateChange(MessageParcel & data,MessageParcel & reply)691 int SessionStageStub::HandleNotifyWindowAttachStateChange(MessageParcel& data, MessageParcel& reply)
692 {
693     TLOGD(WmsLogTag::WMS_SUB, "in");
694     bool isAttach = false;
695     if (!data.ReadBool(isAttach)) {
696         return ERR_INVALID_DATA;
697     }
698     NotifyWindowAttachStateChange(isAttach);
699     return ERR_NONE;
700 }
701 
702 } // namespace OHOS::Rosen
703