• 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/host/include/zidl/session_stub.h"
17 
18 #include "ability_start_setting.h"
19 #include <ipc_types.h>
20 #include <ui/rs_surface_node.h>
21 #include "want.h"
22 #include "pointer_event.h"
23 #include "key_event.h"
24 
25 #include "accessibility_event_info_parcel.h"
26 #include "session/host/include/zidl/session_ipc_interface_code.h"
27 #include "window_manager_hilog.h"
28 
29 namespace OHOS::Accessibility {
30 class AccessibilityEventInfo;
31 }
32 namespace OHOS::Rosen {
33 namespace {
34 constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionStub" };
35 } // namespace
36 
37 const std::map<uint32_t, SessionStubFunc> SessionStub::stubFuncMap_ {
38     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_CONNECT),
39         &SessionStub::HandleConnect),
40     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_FOREGROUND),
41         &SessionStub::HandleForeground),
42     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_BACKGROUND),
43         &SessionStub::HandleBackground),
44     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_DISCONNECT),
45         &SessionStub::HandleDisconnect),
46     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SHOW),
47         &SessionStub::HandleShow),
48     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_HIDE),
49         &SessionStub::HandleHide),
50 
51     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_ACTIVE_STATUS),
52         &SessionStub::HandleUpdateActivateStatus),
53     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SESSION_EVENT),
54         &SessionStub::HandleSessionEvent),
55     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_SESSION_RECT),
56         &SessionStub::HandleUpdateSessionRect),
57     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_RAISE_TO_APP_TOP),
58         &SessionStub::HandleRaiseToAppTop),
59     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_BACKPRESSED),
60         &SessionStub::HandleBackPressed),
61     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_MARK_PROCESSED),
62         &SessionStub::HandleMarkProcessed),
63     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_MAXIMIZE_MODE),
64         &SessionStub::HandleSetGlobalMaximizeMode),
65     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_MAXIMIZE_MODE),
66         &SessionStub::HandleGetGlobalMaximizeMode),
67     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NEED_AVOID),
68         &SessionStub::HandleNeedAvoid),
69     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_GET_AVOID_AREA),
70         &SessionStub::HandleGetAvoidAreaByType),
71     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_SESSION_PROPERTY),
72         &SessionStub::HandleSetSessionProperty),
73     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SET_ASPECT_RATIO),
74         &SessionStub::HandleSetAspectRatio),
75     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_WINDOW_ANIMATION_FLAG),
76         &SessionStub::HandleSetWindowAnimationFlag),
77     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_CUSTOM_ANIMATION),
78         &SessionStub::HandleUpdateWindowSceneAfterCustomAnimation),
79     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_RAISE_ABOVE_TARGET),
80         &SessionStub::HandleRaiseAboveTarget),
81     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_RAISE_APP_MAIN_WINDOW),
82         &SessionStub::HandleRaiseAppMainWindowToTop),
83     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_ACTIVE_PENDING_SESSION),
84         &SessionStub::HandlePendingSessionActivation),
85     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TERMINATE),
86         &SessionStub::HandleTerminateSession),
87     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_EXCEPTION),
88         &SessionStub::HandleSessionException),
89     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_PROCESS_POINT_DOWN_SESSION),
90         &SessionStub::HandleProcessPointDownSession),
91     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_SEND_POINTEREVENT_FOR_MOVE_DRAG),
92         &SessionStub::HandleSendPointerEvenForMoveDrag),
93 
94     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TRANSFER_ABILITY_RESULT),
95         &SessionStub::HandleTransferAbilityResult),
96     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TRANSFER_EXTENSION_DATA),
97         &SessionStub::HandleTransferExtensionData),
98     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_REMOTE_READY),
99         &SessionStub::HandleNotifyRemoteReady),
100     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_ASYNC_ON),
101         &SessionStub::HandleNotifyAsyncOn),
102     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_SYNC_ON),
103         &SessionStub::HandleNotifySyncOn),
104     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_EXTENSION_DIED),
105         &SessionStub::HandleNotifyExtensionDied),
106     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_TRIGGER_BIND_MODAL_UI_EXTENSION),
107         &SessionStub::HandleTriggerBindModalUIExtension),
108     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_REPORT_ACCESSIBILITY_EVENT),
109         &SessionStub::HandleTransferAccessibilityEvent),
110     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_NOTIFY_PIP_WINDOW_PREPARE_CLOSE),
111         &SessionStub::HandleNotifyPiPWindowPrepareClose),
112     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_UPDATE_PIP_RECT),
113         &SessionStub::HandleUpdatePiPRect),
114     std::make_pair(static_cast<uint32_t>(SessionInterfaceCode::TRANS_ID_RECOVERY_PULL_PIP_MAIN_WINDOW),
115         &SessionStub::HandleRecoveryPullPiPMainWindow)
116 };
117 
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)118 int SessionStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
119 {
120     WLOGFD("Scene session on remote request!, code: %{public}u", code);
121     if (data.ReadInterfaceToken() != GetDescriptor()) {
122         WLOGFE("Failed to check interface token!");
123         return ERR_INVALID_STATE;
124     }
125 
126     const auto& func = stubFuncMap_.find(code);
127     if (func == stubFuncMap_.end()) {
128         WLOGFE("Failed to find function handler!");
129         return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
130     }
131 
132     return (this->*(func->second))(data, reply);
133 }
134 
HandleSetWindowAnimationFlag(MessageParcel & data,MessageParcel & reply)135 int SessionStub::HandleSetWindowAnimationFlag(MessageParcel& data, MessageParcel& reply)
136 {
137     WLOGFD("HandleSetWindowAnimationFlag!");
138     bool isNeedWindowAnimationFlag = data.ReadBool();
139     const WSError& errCode = UpdateWindowAnimationFlag(isNeedWindowAnimationFlag);
140     reply.WriteUint32(static_cast<uint32_t>(errCode));
141     return ERR_NONE;
142 }
143 
HandleForeground(MessageParcel & data,MessageParcel & reply)144 int SessionStub::HandleForeground(MessageParcel& data, MessageParcel& reply)
145 {
146     WLOGFD("[WMSCom] Foreground!");
147     sptr<WindowSessionProperty> property = nullptr;
148     if (data.ReadBool()) {
149         property = data.ReadStrongParcelable<WindowSessionProperty>();
150     } else {
151         WLOGFW("[WMSCom] Property not exist!");
152         property = new WindowSessionProperty();
153     }
154     const WSError& errCode = Foreground(property);
155     reply.WriteUint32(static_cast<uint32_t>(errCode));
156     return ERR_NONE;
157 }
158 
HandleBackground(MessageParcel & data,MessageParcel & reply)159 int SessionStub::HandleBackground(MessageParcel& data, MessageParcel& reply)
160 {
161     WLOGFD("[WMSCom] Background!");
162     const WSError& errCode = Background();
163     reply.WriteUint32(static_cast<uint32_t>(errCode));
164     return ERR_NONE;
165 }
166 
HandleDisconnect(MessageParcel & data,MessageParcel & reply)167 int SessionStub::HandleDisconnect(MessageParcel& data, MessageParcel& reply)
168 {
169     WLOGFD("Disconnect!");
170     bool isFromClient = data.ReadBool();
171     const WSError& errCode = Disconnect(isFromClient);
172     reply.WriteUint32(static_cast<uint32_t>(errCode));
173     return ERR_NONE;
174 }
175 
HandleShow(MessageParcel & data,MessageParcel & reply)176 int SessionStub::HandleShow(MessageParcel& data, MessageParcel& reply)
177 {
178     WLOGFD("Show!");
179     sptr<WindowSessionProperty> property = nullptr;
180     if (data.ReadBool()) {
181         property = data.ReadStrongParcelable<WindowSessionProperty>();
182     } else {
183         WLOGFW("Property not exist!");
184         property = new WindowSessionProperty();
185     }
186     const WSError& errCode = Show(property);
187     reply.WriteUint32(static_cast<uint32_t>(errCode));
188     return ERR_NONE;
189 }
190 
HandleHide(MessageParcel & data,MessageParcel & reply)191 int SessionStub::HandleHide(MessageParcel& data, MessageParcel& reply)
192 {
193     WLOGFD("Hide!");
194     const WSError& errCode = Hide();
195     reply.WriteUint32(static_cast<uint32_t>(errCode));
196     return ERR_NONE;
197 }
198 
HandleConnect(MessageParcel & data,MessageParcel & reply)199 int SessionStub::HandleConnect(MessageParcel& data, MessageParcel& reply)
200 {
201     WLOGFD("Connect!");
202     sptr<IRemoteObject> sessionStageObject = data.ReadRemoteObject();
203     sptr<ISessionStage> sessionStage = iface_cast<ISessionStage>(sessionStageObject);
204     sptr<IRemoteObject> eventChannelObject = data.ReadRemoteObject();
205     sptr<IWindowEventChannel> eventChannel = iface_cast<IWindowEventChannel>(eventChannelObject);
206     std::shared_ptr<RSSurfaceNode> surfaceNode = RSSurfaceNode::Unmarshalling(data);
207     if (sessionStage == nullptr || eventChannel == nullptr || surfaceNode == nullptr) {
208         WLOGFE("Failed to read scene session stage object or event channel object!");
209         return ERR_INVALID_DATA;
210     }
211 
212     sptr<WindowSessionProperty> property = nullptr;
213     if (data.ReadBool()) {
214         property = data.ReadStrongParcelable<WindowSessionProperty>();
215     } else {
216         WLOGFW("Property not exist!");
217     }
218 
219     sptr<IRemoteObject> token = nullptr;
220     if (property && property->GetTokenState()) {
221         token = data.ReadRemoteObject();
222     } else {
223         WLOGI("accept token is nullptr");
224     }
225     SystemSessionConfig systemConfig;
226     WSError errCode = Connect(sessionStage, eventChannel, surfaceNode, systemConfig, property, token);
227     reply.WriteParcelable(&systemConfig);
228     if (property) {
229         reply.WriteInt32(property->GetPersistentId());
230         bool needUpdate = property->GetIsNeedUpdateWindowMode();
231         reply.WriteBool(needUpdate);
232         if (needUpdate) {
233             reply.WriteUint32(static_cast<uint32_t>(property->GetWindowMode()));
234         }
235         property->SetIsNeedUpdateWindowMode(false);
236     }
237     reply.WriteUint32(static_cast<uint32_t>(errCode));
238     return ERR_NONE;
239 }
240 
HandleSessionEvent(MessageParcel & data,MessageParcel & reply)241 int SessionStub::HandleSessionEvent(MessageParcel& data, MessageParcel& reply)
242 {
243     uint32_t eventId = data.ReadUint32();
244     WLOGFD("HandleSessionEvent eventId: %{public}d", eventId);
245     WSError errCode = OnSessionEvent(static_cast<SessionEvent>(eventId));
246     reply.WriteUint32(static_cast<uint32_t>(errCode));
247     return ERR_NONE;
248 }
249 
HandleTerminateSession(MessageParcel & data,MessageParcel & reply)250 int SessionStub::HandleTerminateSession(MessageParcel& data, MessageParcel& reply)
251 {
252     WLOGFD("run HandleTerminateSession");
253     sptr<AAFwk::SessionInfo> abilitySessionInfo(new AAFwk::SessionInfo());
254     std::shared_ptr<AAFwk::Want> localWant(data.ReadParcelable<AAFwk::Want>());
255     abilitySessionInfo->want = *localWant;
256     if (data.ReadBool()) {
257         abilitySessionInfo->callerToken = data.ReadRemoteObject();
258     }
259     abilitySessionInfo->resultCode = data.ReadInt32();
260     const WSError& errCode = TerminateSession(abilitySessionInfo);
261     reply.WriteUint32(static_cast<uint32_t>(errCode));
262     return ERR_NONE;
263 }
264 
HandleSessionException(MessageParcel & data,MessageParcel & reply)265 int SessionStub::HandleSessionException(MessageParcel& data, MessageParcel& reply)
266 {
267     WLOGFD("run HandleSessionException");
268     sptr<AAFwk::SessionInfo> abilitySessionInfo(new AAFwk::SessionInfo());
269     std::shared_ptr<AAFwk::Want> localWant(data.ReadParcelable<AAFwk::Want>());
270     abilitySessionInfo->want = *localWant;
271     if (data.ReadBool()) {
272         abilitySessionInfo->callerToken = data.ReadRemoteObject();
273     }
274 
275     abilitySessionInfo->persistentId = data.ReadInt32();
276     abilitySessionInfo->errorCode = data.ReadInt32();
277     abilitySessionInfo->errorReason = data.ReadString();
278     const WSError& errCode = NotifySessionException(abilitySessionInfo);
279     reply.WriteUint32(static_cast<uint32_t>(errCode));
280     return ERR_NONE;
281 }
282 
HandlePendingSessionActivation(MessageParcel & data,MessageParcel & reply)283 int SessionStub::HandlePendingSessionActivation(MessageParcel& data, MessageParcel& reply)
284 {
285     WLOGFD("PendingSessionActivation!");
286     sptr<AAFwk::SessionInfo> abilitySessionInfo(new AAFwk::SessionInfo());
287     sptr<AAFwk::Want> localWant = data.ReadParcelable<AAFwk::Want>();
288     abilitySessionInfo->want = *localWant;
289     abilitySessionInfo->requestCode = data.ReadInt32();
290     abilitySessionInfo->persistentId = data.ReadInt32();
291     abilitySessionInfo->state = static_cast<AAFwk::CallToState>(data.ReadInt32());
292     abilitySessionInfo->uiAbilityId = data.ReadInt64();
293     abilitySessionInfo->callingTokenId = data.ReadUint32();
294     abilitySessionInfo->reuse = data.ReadBool();
295     if (data.ReadBool()) {
296         abilitySessionInfo->callerToken = data.ReadRemoteObject();
297     }
298     if (data.ReadBool()) {
299         abilitySessionInfo->startSetting.reset(data.ReadParcelable<AAFwk::AbilityStartSetting>());
300     }
301     const WSError& errCode = PendingSessionActivation(abilitySessionInfo);
302     reply.WriteUint32(static_cast<uint32_t>(errCode));
303     return ERR_NONE;
304 }
305 
HandleUpdateActivateStatus(MessageParcel & data,MessageParcel & reply)306 int SessionStub::HandleUpdateActivateStatus(MessageParcel& data, MessageParcel& reply)
307 {
308     WLOGFD("HandleUpdateActivateStatus!");
309     bool isActive = data.ReadBool();
310     const WSError& errCode = UpdateActiveStatus(isActive);
311     reply.WriteUint32(static_cast<uint32_t>(errCode));
312     return ERR_NONE;
313 }
314 
HandleUpdateSessionRect(MessageParcel & data,MessageParcel & reply)315 int SessionStub::HandleUpdateSessionRect(MessageParcel& data, MessageParcel& reply)
316 {
317     WLOGFD("HandleUpdateSessionRect!");
318     auto posX = data.ReadInt32();
319     auto posY = data.ReadInt32();
320     auto width = data.ReadUint32();
321     auto height = data.ReadUint32();
322     WSRect rect = {posX, posY, width, height};
323     WLOGFI("HandleUpdateSessionRect [%{public}d, %{public}d, %{public}u, %{public}u]", posX, posY,
324         width, height);
325     const SizeChangeReason& reason = static_cast<SizeChangeReason>(data.ReadUint32());
326     const WSError& errCode = UpdateSessionRect(rect, reason);
327     reply.WriteUint32(static_cast<uint32_t>(errCode));
328     return ERR_NONE;
329 }
330 
HandleRaiseToAppTop(MessageParcel & data,MessageParcel & reply)331 int SessionStub::HandleRaiseToAppTop(MessageParcel& data, MessageParcel& reply)
332 {
333     WLOGFD("RaiseToAppTop!");
334     const WSError& errCode = RaiseToAppTop();
335     reply.WriteUint32(static_cast<uint32_t>(errCode));
336     return ERR_NONE;
337 }
338 
HandleRaiseAboveTarget(MessageParcel & data,MessageParcel & reply)339 int SessionStub::HandleRaiseAboveTarget(MessageParcel& data, MessageParcel& reply)
340 {
341     WLOGFD("RaiseAboveTarget!");
342     auto subWindowId = data.ReadInt32();
343     const WSError& errCode = RaiseAboveTarget(subWindowId);
344     reply.WriteUint32(static_cast<uint32_t>(errCode));
345     return ERR_NONE;
346 }
347 
HandleRaiseAppMainWindowToTop(MessageParcel & data,MessageParcel & reply)348 int SessionStub::HandleRaiseAppMainWindowToTop(MessageParcel& data, MessageParcel& reply)
349 {
350     WLOGFD("RaiseAppMainWindowToTop!");
351     const WSError& errCode = RaiseAppMainWindowToTop();
352     reply.WriteUint32(static_cast<uint32_t>(errCode));
353     return ERR_NONE;
354 }
355 
HandleBackPressed(MessageParcel & data,MessageParcel & reply)356 int SessionStub::HandleBackPressed(MessageParcel& data, MessageParcel& reply)
357 {
358     WLOGFD("HandleBackPressed!");
359     bool needMoveToBackground = false;
360     if (!data.ReadBool(needMoveToBackground)) {
361         WLOGFE("Read needMoveToBackground from parcel failed!");
362         return ERR_INVALID_DATA;
363     }
364     WSError errCode = RequestSessionBack(needMoveToBackground);
365     reply.WriteUint32(static_cast<uint32_t>(errCode));
366     return ERR_NONE;
367 }
368 
HandleMarkProcessed(MessageParcel & data,MessageParcel & reply)369 int SessionStub::HandleMarkProcessed(MessageParcel& data, MessageParcel& reply)
370 {
371     WLOGFD("HandleMarkProcessed!");
372     int32_t eventId = 0;
373     if (!data.ReadInt32(eventId)) {
374         WLOGFE("Read eventId from parcel failed!");
375         return ERR_INVALID_DATA;
376     }
377     WSError errCode = MarkProcessed(eventId);
378     reply.WriteUint32(static_cast<uint32_t>(errCode));
379     return ERR_NONE;
380 }
381 
HandleSetGlobalMaximizeMode(MessageParcel & data,MessageParcel & reply)382 int SessionStub::HandleSetGlobalMaximizeMode(MessageParcel &data, MessageParcel &reply)
383 {
384     WLOGFD("HandleSetGlobalMaximizeMode!");
385     auto mode = data.ReadUint32();
386     WSError errCode = SetGlobalMaximizeMode(static_cast<MaximizeMode>(mode));
387     reply.WriteUint32(static_cast<uint32_t>(errCode));
388     return ERR_NONE;
389 }
390 
HandleGetGlobalMaximizeMode(MessageParcel & data,MessageParcel & reply)391 int SessionStub::HandleGetGlobalMaximizeMode(MessageParcel &data, MessageParcel &reply)
392 {
393     WLOGFD("HandleGetGlobalMaximizeMode!");
394     MaximizeMode mode = MaximizeMode::MODE_FULL_FILL;
395     WSError errCode = GetGlobalMaximizeMode(mode);
396     reply.WriteUint32(static_cast<uint32_t>(mode));
397     reply.WriteUint32(static_cast<uint32_t>(errCode));
398     return ERR_NONE;
399 }
400 
HandleNeedAvoid(MessageParcel & data,MessageParcel & reply)401 int SessionStub::HandleNeedAvoid(MessageParcel& data, MessageParcel& reply)
402 {
403     bool status = static_cast<bool>(data.ReadUint32());
404     WLOGFD("HandleNeedAvoid status:%{public}d", static_cast<int32_t>(status));
405     WSError errCode = OnNeedAvoid(status);
406     reply.WriteUint32(static_cast<uint32_t>(errCode));
407     return ERR_NONE;
408 }
409 
HandleGetAvoidAreaByType(MessageParcel & data,MessageParcel & reply)410 int SessionStub::HandleGetAvoidAreaByType(MessageParcel& data, MessageParcel& reply)
411 {
412     AvoidAreaType type = static_cast<AvoidAreaType>(data.ReadUint32());
413     WLOGFD("HandleGetAvoidArea type:%{public}d", static_cast<int32_t>(type));
414     AvoidArea avoidArea = GetAvoidAreaByType(type);
415     reply.WriteParcelable(&avoidArea);
416     return ERR_NONE;
417 }
418 
HandleSetSessionProperty(MessageParcel & data,MessageParcel & reply)419 int SessionStub::HandleSetSessionProperty(MessageParcel& data, MessageParcel& reply)
420 {
421     WLOGFD("HandleSetSessionProperty!");
422     auto property = data.ReadStrongParcelable<WindowSessionProperty>();
423     auto errCode = SetSessionProperty(property);
424     reply.WriteUint32(static_cast<uint32_t>(errCode));
425     return ERR_NONE;
426 }
427 
HandleSetAspectRatio(MessageParcel & data,MessageParcel & reply)428 int SessionStub::HandleSetAspectRatio(MessageParcel& data, MessageParcel& reply)
429 {
430     WLOGFD("HandleSetAspectRatio!");
431     float ratio = data.ReadFloat();
432     const WSError& errCode = SetAspectRatio(ratio);
433     reply.WriteUint32(static_cast<uint32_t>(errCode));
434     return ERR_NONE;
435 }
436 
HandleUpdateWindowSceneAfterCustomAnimation(MessageParcel & data,MessageParcel & reply)437 int SessionStub::HandleUpdateWindowSceneAfterCustomAnimation(MessageParcel& data, MessageParcel& reply)
438 {
439     WLOGD("HandleUpdateWindowSceneAfterCustomAnimation!");
440     bool isAdd = data.ReadBool();
441     const WSError& errCode = UpdateWindowSceneAfterCustomAnimation(isAdd);
442     reply.WriteUint32(static_cast<uint32_t>(errCode));
443     return ERR_NONE;
444 }
445 
HandleTransferAbilityResult(MessageParcel & data,MessageParcel & reply)446 int SessionStub::HandleTransferAbilityResult(MessageParcel& data, MessageParcel& reply)
447 {
448     WLOGFD("HandleTransferAbilityResult!");
449     uint32_t resultCode = data.ReadUint32();
450     std::shared_ptr<AAFwk::Want> want(data.ReadParcelable<AAFwk::Want>());
451     if (want == nullptr) {
452         WLOGFE("want is nullptr");
453         return ERR_INVALID_VALUE;
454     }
455     WSError errCode = TransferAbilityResult(resultCode, *want);
456     reply.WriteUint32(static_cast<uint32_t>(errCode));
457     return ERR_NONE;
458 }
459 
HandleTransferExtensionData(MessageParcel & data,MessageParcel & reply)460 int SessionStub::HandleTransferExtensionData(MessageParcel& data, MessageParcel& reply)
461 {
462     WLOGFD("HandleTransferExtensionData!");
463     std::shared_ptr<AAFwk::WantParams> wantParams(data.ReadParcelable<AAFwk::WantParams>());
464     if (wantParams == nullptr) {
465         WLOGFE("wantParams is nullptr");
466         return ERR_INVALID_VALUE;
467     }
468     WSError errCode = TransferExtensionData(*wantParams);
469     reply.WriteUint32(static_cast<uint32_t>(errCode));
470     return ERR_NONE;
471 }
472 
HandleNotifyRemoteReady(MessageParcel & data,MessageParcel & reply)473 int SessionStub::HandleNotifyRemoteReady(MessageParcel& data, MessageParcel& reply)
474 {
475     WLOGFD("HandleNotifyRemoteReady!");
476     NotifyRemoteReady();
477     return ERR_NONE;
478 }
479 
HandleNotifySyncOn(MessageParcel & data,MessageParcel & reply)480 int SessionStub::HandleNotifySyncOn(MessageParcel& data, MessageParcel& reply)
481 {
482     NotifySyncOn();
483     return ERR_NONE;
484 }
485 
HandleNotifyAsyncOn(MessageParcel & data,MessageParcel & reply)486 int SessionStub::HandleNotifyAsyncOn(MessageParcel& data, MessageParcel& reply)
487 {
488     NotifyAsyncOn();
489     return ERR_NONE;
490 }
491 
HandleNotifyExtensionDied(MessageParcel & data,MessageParcel & reply)492 int SessionStub::HandleNotifyExtensionDied(MessageParcel& data, MessageParcel& reply)
493 {
494     WLOGFD("called");
495     NotifyExtensionDied();
496     return ERR_NONE;
497 }
498 
HandleTriggerBindModalUIExtension(MessageParcel & data,MessageParcel & reply)499 int SessionStub::HandleTriggerBindModalUIExtension(MessageParcel& data, MessageParcel& reply)
500 {
501     WLOGFD("called");
502     TriggerBindModalUIExtension();
503     return ERR_NONE;
504 }
505 
HandleTransferAccessibilityEvent(MessageParcel & data,MessageParcel & reply)506 int SessionStub::HandleTransferAccessibilityEvent(MessageParcel& data, MessageParcel& reply)
507 {
508     sptr<Accessibility::AccessibilityEventInfoParcel> infoPtr =
509         data.ReadStrongParcelable<Accessibility::AccessibilityEventInfoParcel>();
510     int64_t uiExtensionIdLevel = 0;
511     if (!data.ReadInt64(uiExtensionIdLevel)) {
512         WLOGFE("read uiExtensionIdLevel error");
513         return ERR_INVALID_DATA;
514     }
515     NotifyTransferAccessibilityEvent(*infoPtr, uiExtensionIdLevel);
516     return ERR_NONE;
517 }
518 
HandleNotifyPiPWindowPrepareClose(MessageParcel & data,MessageParcel & reply)519 int SessionStub::HandleNotifyPiPWindowPrepareClose(MessageParcel& data, MessageParcel& reply)
520 {
521     WLOGFD("HandleNotifyPiPWindowPrepareClose");
522     NotifyPiPWindowPrepareClose();
523     return ERR_NONE;
524 }
525 
HandleUpdatePiPRect(MessageParcel & data,MessageParcel & reply)526 int SessionStub::HandleUpdatePiPRect(MessageParcel& data, MessageParcel& reply)
527 {
528     WLOGFD("HandleUpdatePiPRect!");
529     uint32_t width = data.ReadUint32();
530     uint32_t height = data.ReadUint32();
531     auto reason = static_cast<PiPRectUpdateReason>(data.ReadInt32());
532     WSError errCode = UpdatePiPRect(width, height, reason);
533     reply.WriteUint32(static_cast<uint32_t>(errCode));
534     return ERR_NONE;
535 }
536 
HandleRecoveryPullPiPMainWindow(MessageParcel & data,MessageParcel & reply)537 int SessionStub::HandleRecoveryPullPiPMainWindow(MessageParcel& data, MessageParcel& reply)
538 {
539     WLOGFD("HandleNotifyRecoveryPullPiPMainWindow");
540     int32_t persistentId = 0;
541     if (!data.ReadInt32(persistentId)) {
542         WLOGFE("Read eventId from parcel failed!");
543         return ERR_INVALID_DATA;
544     }
545     Rect rect = {data.ReadInt32(), data.ReadInt32(), data.ReadUint32(), data.ReadUint32()};
546     WSError errCode = RecoveryPullPiPMainWindow(persistentId, rect);
547     reply.WriteUint32(static_cast<uint32_t>(errCode));
548     return ERR_NONE;
549 }
550 
HandleProcessPointDownSession(MessageParcel & data,MessageParcel & reply)551 int SessionStub::HandleProcessPointDownSession(MessageParcel& data, MessageParcel& reply)
552 {
553     WLOGFD("HandleProcessPointDownSession!");
554     uint32_t posX = data.ReadInt32();
555     uint32_t posY = data.ReadInt32();
556     WSError errCode = ProcessPointDownSession(posX, posY);
557     reply.WriteUint32(static_cast<uint32_t>(errCode));
558     return ERR_NONE;
559 }
560 
HandleSendPointerEvenForMoveDrag(MessageParcel & data,MessageParcel & reply)561 int SessionStub::HandleSendPointerEvenForMoveDrag(MessageParcel& data, MessageParcel& reply)
562 {
563     WLOGFD("HandleSendPointerEvenForMoveDrag!");
564     auto pointerEvent = MMI::PointerEvent::Create();
565     if (!pointerEvent->ReadFromParcel(data)) {
566         WLOGFE("Read pointer event failed");
567         return -1;
568     }
569     WSError errCode = SendPointEventForMoveDrag(pointerEvent);
570     reply.WriteUint32(static_cast<uint32_t>(errCode));
571     return ERR_NONE;
572 }
573 } // namespace OHOS::Rosen
574