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_manager/include/zidl/scene_session_manager_proxy.h"
17
18 #include <ipc_types.h>
19 #include <message_option.h>
20 #include <message_parcel.h>
21 #include <ui/rs_surface_node.h>
22
23 #include "marshalling_helper.h"
24 #include "permission.h"
25 #include "window_manager.h"
26 #include "window_manager_hilog.h"
27
28 namespace OHOS::Rosen {
29 namespace {
30 constexpr int32_t CYCLE_LIMIT = 1000;
31 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SceneSessionManagerProxy"};
32 }
CreateAndConnectSpecificSession(const sptr<ISessionStage> & sessionStage,const sptr<IWindowEventChannel> & eventChannel,const std::shared_ptr<RSSurfaceNode> & surfaceNode,sptr<WindowSessionProperty> property,int32_t & persistentId,sptr<ISession> & session,SystemSessionConfig & systemConfig,sptr<IRemoteObject> token)33 WSError SceneSessionManagerProxy::CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage,
34 const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
35 sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session,
36 SystemSessionConfig& systemConfig, sptr<IRemoteObject> token)
37 {
38 MessageOption option(MessageOption::TF_SYNC);
39 MessageParcel data;
40 MessageParcel reply;
41 if (!data.WriteInterfaceToken(GetDescriptor())) {
42 WLOGFE("Write InterfaceToken failed!");
43 return WSError::WS_ERROR_IPC_FAILED;
44 }
45 if (!data.WriteRemoteObject(sessionStage->AsObject())) {
46 WLOGFE("Write ISessionStage failed!");
47 return WSError::WS_ERROR_IPC_FAILED;
48 }
49 if (!data.WriteRemoteObject(eventChannel->AsObject())) {
50 WLOGFE("Write IWindowEventChannel failed!");
51 return WSError::WS_ERROR_IPC_FAILED;
52 }
53 if (!surfaceNode || !surfaceNode->Marshalling(data)) {
54 WLOGFE("Write surfaceNode failed");
55 return WSError::WS_ERROR_IPC_FAILED;
56 }
57
58 if (property) {
59 if (!data.WriteBool(true) || !data.WriteParcelable(property.GetRefPtr())) {
60 return WSError::WS_ERROR_IPC_FAILED;
61 }
62 } else {
63 if (!data.WriteBool(false)) {
64 return WSError::WS_ERROR_IPC_FAILED;
65 }
66 }
67 if (token != nullptr) {
68 if (!data.WriteRemoteObject(token)) {
69 return WSError::WS_ERROR_IPC_FAILED;
70 }
71 }
72
73 sptr<IRemoteObject> remote = Remote();
74 if (remote == nullptr) {
75 WLOGFE("remote is null");
76 return WSError::WS_ERROR_IPC_FAILED;
77 }
78 if (remote->SendRequest(static_cast<uint32_t>(
79 SceneSessionManagerMessage::TRANS_ID_CREATE_AND_CONNECT_SPECIFIC_SESSION), data, reply, option) != ERR_NONE) {
80 WLOGFE("SendRequest failed");
81 return WSError::WS_ERROR_IPC_FAILED;
82 }
83 persistentId = reply.ReadInt32();
84 sptr<IRemoteObject> sessionObject = reply.ReadRemoteObject();
85 if (sessionObject == nullptr) {
86 WLOGFE("ReadRemoteObject failed");
87 return WSError::WS_ERROR_IPC_FAILED;
88 }
89 session = iface_cast<ISession>(sessionObject);
90 sptr<SystemSessionConfig> config = reply.ReadParcelable<SystemSessionConfig>();
91 if (config) {
92 systemConfig = *config;
93 }
94 int32_t ret = reply.ReadInt32();
95 return static_cast<WSError>(ret);
96 }
97
RecoverAndConnectSpecificSession(const sptr<ISessionStage> & sessionStage,const sptr<IWindowEventChannel> & eventChannel,const std::shared_ptr<RSSurfaceNode> & surfaceNode,sptr<WindowSessionProperty> property,sptr<ISession> & session,sptr<IRemoteObject> token)98 WSError SceneSessionManagerProxy::RecoverAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage,
99 const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
100 sptr<WindowSessionProperty> property, sptr<ISession>& session, sptr<IRemoteObject> token)
101 {
102 MessageParcel data;
103 MessageParcel reply;
104 MessageOption option;
105 if (!data.WriteInterfaceToken(GetDescriptor())) {
106 WLOGFE("Write InterfaceToken failed!");
107 return WSError::WS_ERROR_IPC_FAILED;
108 }
109 if (!sessionStage || !data.WriteRemoteObject(sessionStage->AsObject())) {
110 WLOGFE("Write ISessionStage failed!");
111 return WSError::WS_ERROR_IPC_FAILED;
112 }
113 if (!eventChannel || !data.WriteRemoteObject(eventChannel->AsObject())) {
114 WLOGFE("Write IWindowEventChannel failed!");
115 return WSError::WS_ERROR_IPC_FAILED;
116 }
117 if (!surfaceNode || !surfaceNode->Marshalling(data)) {
118 WLOGFE("Write surfaceNode failed");
119 return WSError::WS_ERROR_IPC_FAILED;
120 }
121
122 if (property) {
123 if (!data.WriteBool(true) || !data.WriteParcelable(property.GetRefPtr())) {
124 return WSError::WS_ERROR_IPC_FAILED;
125 }
126 } else {
127 if (!data.WriteBool(false)) {
128 return WSError::WS_ERROR_IPC_FAILED;
129 }
130 }
131 if (token != nullptr && !data.WriteRemoteObject(token)) {
132 return WSError::WS_ERROR_IPC_FAILED;
133 }
134
135 sptr<IRemoteObject> remote = Remote();
136 if (remote == nullptr) {
137 WLOGFE("remote is null");
138 return WSError::WS_ERROR_IPC_FAILED;
139 }
140 if (remote->SendRequest(static_cast<uint32_t>(
141 SceneSessionManagerMessage::TRANS_ID_RECOVER_AND_CONNECT_SPECIFIC_SESSION),
142 data, reply, option) != ERR_NONE) {
143 WLOGFE("SendRequest failed");
144 return WSError::WS_ERROR_IPC_FAILED;
145 }
146 sptr<IRemoteObject> sessionObject = reply.ReadRemoteObject();
147 if (sessionObject == nullptr) {
148 WLOGFE("ReadRemoteObject failed");
149 return WSError::WS_ERROR_IPC_FAILED;
150 }
151 session = iface_cast<ISession>(sessionObject);
152 int32_t ret = reply.ReadInt32();
153 return static_cast<WSError>(ret);
154 }
RecoverAndReconnectSceneSession(const sptr<ISessionStage> & sessionStage,const sptr<IWindowEventChannel> & eventChannel,const std::shared_ptr<RSSurfaceNode> & surfaceNode,sptr<ISession> & session,sptr<WindowSessionProperty> property,sptr<IRemoteObject> token)155 WSError SceneSessionManagerProxy::RecoverAndReconnectSceneSession(const sptr<ISessionStage>& sessionStage,
156 const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
157 sptr<ISession>& session, sptr<WindowSessionProperty> property, sptr<IRemoteObject> token)
158 {
159 MessageOption option(MessageOption::TF_SYNC);
160 MessageParcel data;
161 MessageParcel reply;
162 if (!data.WriteInterfaceToken(GetDescriptor())) {
163 WLOGFE("Write InterfaceToken failed!");
164 return WSError::WS_ERROR_IPC_FAILED;
165 }
166 if (!sessionStage || !data.WriteRemoteObject(sessionStage->AsObject())) {
167 WLOGFE("Write ISessionStage failed!");
168 return WSError::WS_ERROR_IPC_FAILED;
169 }
170 if (!eventChannel || !data.WriteRemoteObject(eventChannel->AsObject())) {
171 WLOGFE("Write IWindowEventChannel failed!");
172 return WSError::WS_ERROR_IPC_FAILED;
173 }
174 if (!surfaceNode || !surfaceNode->Marshalling(data)) {
175 WLOGFE("Write surfaceNode failed");
176 return WSError::WS_ERROR_IPC_FAILED;
177 }
178
179 if (property) {
180 if (!data.WriteBool(true) || !data.WriteParcelable(property.GetRefPtr())) {
181 return WSError::WS_ERROR_IPC_FAILED;
182 }
183 } else {
184 if (!data.WriteBool(false)) {
185 return WSError::WS_ERROR_IPC_FAILED;
186 }
187 }
188 if (token != nullptr && !data.WriteRemoteObject(token)) {
189 return WSError::WS_ERROR_IPC_FAILED;
190 }
191
192 sptr<IRemoteObject> remote = Remote();
193 if (remote == nullptr) {
194 WLOGFE("remote is null");
195 return WSError::WS_ERROR_IPC_FAILED;
196 }
197 if (remote->SendRequest(
198 static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_RECOVER_AND_RECONNECT_SCENE_SESSION), data, reply,
199 option) != ERR_NONE) {
200 WLOGFE("SendRequest failed");
201 return WSError::WS_ERROR_IPC_FAILED;
202 }
203 sptr<IRemoteObject> sessionObject = reply.ReadRemoteObject();
204 if (sessionObject == nullptr) {
205 WLOGFE("ReadRemoteObject failed");
206 return WSError::WS_ERROR_IPC_FAILED;
207 }
208 session = iface_cast<ISession>(sessionObject);
209 int32_t ret = reply.ReadInt32();
210 return static_cast<WSError>(ret);
211 }
212
GetSessionSnapshotById(int32_t persistentId,SessionSnapshot & snapshot)213 WMError SceneSessionManagerProxy::GetSessionSnapshotById(int32_t persistentId, SessionSnapshot& snapshot)
214 {
215 MessageParcel data;
216 MessageParcel reply;
217 MessageOption option;
218 if (!data.WriteInterfaceToken(GetDescriptor())) {
219 TLOGE(WmsLogTag::WMS_SYSTEM, "WriteInterfaceToken failed");
220 return WMError::WM_ERROR_IPC_FAILED;
221 }
222 if (!data.WriteInt32(persistentId)) {
223 TLOGE(WmsLogTag::WMS_SYSTEM, "Write persistentId failed");
224 return WMError::WM_ERROR_IPC_FAILED;
225 }
226
227 sptr<IRemoteObject> remote = Remote();
228 if (remote == nullptr) {
229 TLOGE(WmsLogTag::WMS_SYSTEM, "remote is null");
230 return WMError::WM_ERROR_IPC_FAILED;
231 }
232 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_SESSION_SNAPSHOT_BY_ID),
233 data, reply, option) != ERR_NONE) {
234 TLOGE(WmsLogTag::WMS_SYSTEM, "SendRequest failed");
235 return WMError::WM_ERROR_IPC_FAILED;
236 }
237 sptr<SessionSnapshot> info(reply.ReadParcelable<SessionSnapshot>());
238 if (info) {
239 snapshot = *info;
240 } else {
241 TLOGE(WmsLogTag::WMS_SYSTEM, "Read snapshot is null.");
242 }
243 return static_cast<WMError>(reply.ReadInt32());
244 }
245
GetSnapshotByWindowId(int32_t persistentId,std::shared_ptr<Media::PixelMap> & pixelMap)246 WMError SceneSessionManagerProxy::GetSnapshotByWindowId(int32_t persistentId,
247 std::shared_ptr<Media::PixelMap>& pixelMap)
248 {
249 SessionSnapshot snapshot;
250 WMError ret = GetSessionSnapshotById(persistentId, snapshot);
251 if (ret == WMError::WM_OK) {
252 pixelMap = snapshot.snapshot;
253 }
254 return ret;
255 }
256
DestroyAndDisconnectSpecificSession(const int32_t persistentId)257 WSError SceneSessionManagerProxy::DestroyAndDisconnectSpecificSession(const int32_t persistentId)
258 {
259 MessageParcel data;
260 MessageParcel reply;
261 MessageOption option(MessageOption::TF_SYNC);
262 if (!data.WriteInterfaceToken(GetDescriptor())) {
263 TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
264 return WSError::WS_ERROR_IPC_FAILED;
265 }
266 if (!data.WriteInt32(persistentId)) {
267 TLOGE(WmsLogTag::WMS_LIFE, "Write persistentId failed");
268 return WSError::WS_ERROR_IPC_FAILED;
269 }
270 sptr<IRemoteObject> remote = Remote();
271 if (remote == nullptr) {
272 TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
273 return WSError::WS_ERROR_IPC_FAILED;
274 }
275 if (remote->SendRequest(static_cast<uint32_t>(
276 SceneSessionManagerMessage::TRANS_ID_DESTROY_AND_DISCONNECT_SPECIFIC_SESSION),
277 data, reply, option) != ERR_NONE) {
278 TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed");
279 return WSError::WS_ERROR_IPC_FAILED;
280 }
281 int32_t ret = reply.ReadInt32();
282 return static_cast<WSError>(ret);
283 }
284
DestroyAndDisconnectSpecificSessionWithDetachCallback(const int32_t persistentId,const sptr<IRemoteObject> & callback)285 WSError SceneSessionManagerProxy::DestroyAndDisconnectSpecificSessionWithDetachCallback(const int32_t persistentId,
286 const sptr<IRemoteObject>& callback)
287 {
288 MessageParcel data;
289 MessageParcel reply;
290 MessageOption option(MessageOption::TF_SYNC);
291 if (!data.WriteInterfaceToken(GetDescriptor())) {
292 TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
293 return WSError::WS_ERROR_IPC_FAILED;
294 }
295 if (!data.WriteInt32(persistentId)) {
296 TLOGE(WmsLogTag::WMS_LIFE, "Write persistentId failed");
297 return WSError::WS_ERROR_IPC_FAILED;
298 }
299 if (callback == nullptr || !data.WriteRemoteObject(callback)) {
300 TLOGE(WmsLogTag::WMS_LIFE, "Write callback failed");
301 return WSError::WS_ERROR_IPC_FAILED;
302 }
303 sptr<IRemoteObject> remote = Remote();
304 if (remote == nullptr) {
305 TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
306 return WSError::WS_ERROR_IPC_FAILED;
307 }
308 if (remote->SendRequest(static_cast<uint32_t>(
309 SceneSessionManagerMessage::TRANS_ID_DESTROY_AND_DISCONNECT_SPECIFIC_SESSION_WITH_DETACH_CALLBACK),
310 data, reply, option) != ERR_NONE) {
311 TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed");
312 return WSError::WS_ERROR_IPC_FAILED;
313 }
314 int32_t ret = reply.ReadInt32();
315 return static_cast<WSError>(ret);
316 }
317
RequestFocusStatus(int32_t persistentId,bool isFocused,bool byForeground,FocusChangeReason reason)318 WMError SceneSessionManagerProxy::RequestFocusStatus(int32_t persistentId, bool isFocused, bool byForeground,
319 FocusChangeReason reason)
320 {
321 TLOGI(WmsLogTag::WMS_FOCUS, "SceneSessionManagerProxy::RequestFocusStatus id: %{public}d, focusState:\
322 %{public}u, byForeground: %{public}d, reason: %{public}d", persistentId, isFocused, byForeground, reason);
323 MessageParcel data;
324 MessageParcel reply;
325 MessageOption option(MessageOption::TF_SYNC);
326 if (!data.WriteInterfaceToken(GetDescriptor())) {
327 WLOGFE("WriteInterfaceToken failed");
328 return WMError::WM_ERROR_IPC_FAILED;
329 }
330 if (!data.WriteInt32(persistentId)) {
331 WLOGFE("Write persistentId failed");
332 return WMError::WM_ERROR_IPC_FAILED;
333 }
334 if (!data.WriteBool(isFocused)) {
335 WLOGFE("Write isFocused failed");
336 return WMError::WM_ERROR_IPC_FAILED;
337 }
338
339 sptr<IRemoteObject> remote = Remote();
340 if (remote == nullptr) {
341 WLOGFE("remote is null");
342 return WMError::WM_ERROR_IPC_FAILED;
343 }
344 if (remote->SendRequest(static_cast<uint32_t>(
345 SceneSessionManagerMessage::TRANS_ID_REQUEST_FOCUS),
346 data, reply, option) != ERR_NONE) {
347 WLOGFE("SendRequest failed");
348 return WMError::WM_ERROR_IPC_FAILED;
349 }
350 int32_t ret = reply.ReadInt32();
351 return static_cast<WMError>(ret);
352 }
353
RaiseWindowToTop(int32_t persistentId)354 WSError SceneSessionManagerProxy::RaiseWindowToTop(int32_t persistentId)
355 {
356 MessageParcel data;
357 MessageParcel reply;
358 MessageOption option(MessageOption::TF_SYNC);
359 if (!data.WriteInterfaceToken(GetDescriptor())) {
360 WLOGFE("WriteInterfaceToken failed");
361 return WSError::WS_ERROR_IPC_FAILED;
362 }
363 if (!data.WriteInt32(persistentId)) {
364 WLOGFE("Write persistentId failed");
365 return WSError::WS_ERROR_IPC_FAILED;
366 }
367
368 sptr<IRemoteObject> remote = Remote();
369 if (remote == nullptr) {
370 WLOGFE("remote is null");
371 return WSError::WS_ERROR_IPC_FAILED;
372 }
373 if (remote->SendRequest(static_cast<uint32_t>(
374 SceneSessionManagerMessage::TRANS_ID_RAISE_WINDOW_TO_TOP),
375 data, reply, option) != ERR_NONE) {
376 WLOGFE("SendRequest failed");
377 return WSError::WS_ERROR_IPC_FAILED;
378 }
379 int32_t ret = reply.ReadInt32();
380 return static_cast<WSError>(ret);
381 }
382
BindDialogSessionTarget(uint64_t persistentId,sptr<IRemoteObject> targetToken)383 WSError SceneSessionManagerProxy::BindDialogSessionTarget(uint64_t persistentId, sptr<IRemoteObject> targetToken)
384 {
385 MessageParcel data;
386 MessageParcel reply;
387 MessageOption option(MessageOption::TF_SYNC);
388 if (!data.WriteInterfaceToken(GetDescriptor())) {
389 WLOGFE("WriteInterfaceToken failed");
390 return WSError::WS_ERROR_IPC_FAILED;
391 }
392 if (!data.WriteUint64(persistentId)) {
393 WLOGFE("Write PropertyChangeAction failed");
394 return WSError::WS_ERROR_IPC_FAILED;
395 }
396 if (targetToken != nullptr) {
397 if (!data.WriteRemoteObject(targetToken)) {
398 WLOGFE("Write targetToken failed");
399 return WSError::WS_ERROR_IPC_FAILED;
400 }
401 }
402
403 sptr<IRemoteObject> remote = Remote();
404 if (remote == nullptr) {
405 WLOGFE("remote is null");
406 return WSError::WS_ERROR_IPC_FAILED;
407 }
408 if (remote->SendRequest(static_cast<uint32_t>(
409 SceneSessionManagerMessage::TRANS_ID_BIND_DIALOG_TARGET),
410 data, reply, option) != ERR_NONE) {
411 WLOGFE("SendRequest failed");
412 return WSError::WS_ERROR_IPC_FAILED;
413 }
414 int32_t ret = reply.ReadInt32();
415 return static_cast<WSError>(ret);
416 }
417
UpdateSessionAvoidAreaListener(int32_t & persistentId,bool haveListener)418 WSError SceneSessionManagerProxy::UpdateSessionAvoidAreaListener(int32_t& persistentId, bool haveListener)
419 {
420 MessageParcel data;
421 MessageParcel reply;
422 MessageOption option(MessageOption::TF_SYNC);
423
424 if (!data.WriteInterfaceToken(GetDescriptor())) {
425 WLOGFE("WriteInterfaceToken failed");
426 return WSError::WS_ERROR_IPC_FAILED;
427 }
428 if (!data.WriteInt32(persistentId)) {
429 WLOGFE("Write persistentId failed");
430 return WSError::WS_ERROR_IPC_FAILED;
431 }
432 if (!data.WriteBool(haveListener)) {
433 WLOGFE("Write avoid area listener failed");
434 return WSError::WS_ERROR_IPC_FAILED;
435 }
436 sptr<IRemoteObject> remote = Remote();
437 if (remote == nullptr) {
438 WLOGFE("remote is null");
439 return WSError::WS_ERROR_IPC_FAILED;
440 }
441 if (remote->SendRequest(static_cast<uint32_t>(
442 SceneSessionManagerMessage::TRANS_ID_UPDATE_AVOIDAREA_LISTENER),
443 data, reply, option) != ERR_NONE) {
444 return WSError::WS_ERROR_IPC_FAILED;
445 }
446 return static_cast<WSError>(reply.ReadInt32());
447 }
448
UpdateSessionTouchOutsideListener(int32_t & persistentId,bool haveListener)449 WSError SceneSessionManagerProxy::UpdateSessionTouchOutsideListener(int32_t& persistentId, bool haveListener)
450 {
451 MessageParcel data;
452 MessageParcel reply;
453 MessageOption option(MessageOption::TF_SYNC);
454
455 if (!data.WriteInterfaceToken(GetDescriptor())) {
456 WLOGFE("WriteInterfaceToken failed");
457 return WSError::WS_ERROR_IPC_FAILED;
458 }
459 if (!data.WriteInt32(persistentId)) {
460 WLOGFE("Write persistentId failed");
461 return WSError::WS_ERROR_IPC_FAILED;
462 }
463 if (!data.WriteBool(haveListener)) {
464 WLOGFE("Write avoid area listener failed");
465 return WSError::WS_ERROR_IPC_FAILED;
466 }
467 sptr<IRemoteObject> remote = Remote();
468 if (remote == nullptr) {
469 WLOGFE("remote is null");
470 return WSError::WS_ERROR_IPC_FAILED;
471 }
472 if (remote->SendRequest(static_cast<uint32_t>(
473 SceneSessionManagerMessage::TRANS_ID_UPDATE_TOUCHOUTSIDE_LISTENER),
474 data, reply, option) != ERR_NONE) {
475 return WSError::WS_ERROR_IPC_FAILED;
476 }
477 return static_cast<WSError>(reply.ReadInt32());
478 }
479
UpdateSessionWindowVisibilityListener(int32_t persistentId,bool haveListener)480 WSError SceneSessionManagerProxy::UpdateSessionWindowVisibilityListener(int32_t persistentId, bool haveListener)
481 {
482 MessageParcel data;
483 MessageParcel reply;
484 MessageOption option(MessageOption::TF_SYNC);
485
486 if (!data.WriteInterfaceToken(GetDescriptor())) {
487 WLOGFE("WriteInterfaceToken failed");
488 return WSError::WS_ERROR_IPC_FAILED;
489 }
490 if (!data.WriteInt32(persistentId)) {
491 WLOGFE("Write persistentId failed");
492 return WSError::WS_ERROR_IPC_FAILED;
493 }
494 if (!data.WriteBool(haveListener)) {
495 WLOGFE("Write avoid area listener failed");
496 return WSError::WS_ERROR_IPC_FAILED;
497 }
498 sptr<IRemoteObject> remote = Remote();
499 if (remote == nullptr) {
500 WLOGFE("remote is null");
501 return WSError::WS_ERROR_IPC_FAILED;
502 }
503 if (remote->SendRequest(static_cast<uint32_t>(
504 SceneSessionManagerMessage::TRANS_ID_UPDATE_WINDOW_VISIBILITY_LISTENER),
505 data, reply, option) != ERR_NONE) {
506 return WSError::WS_ERROR_IPC_FAILED;
507 }
508 return static_cast<WSError>(reply.ReadInt32());
509 }
510
RegisterWindowManagerAgent(WindowManagerAgentType type,const sptr<IWindowManagerAgent> & windowManagerAgent)511 WMError SceneSessionManagerProxy::RegisterWindowManagerAgent(WindowManagerAgentType type,
512 const sptr<IWindowManagerAgent>& windowManagerAgent)
513 {
514 MessageOption option;
515 MessageParcel reply;
516 MessageParcel data;
517 if (!data.WriteInterfaceToken(GetDescriptor())) {
518 WLOGFE("Write InterfaceToken failed");
519 return WMError::WM_ERROR_IPC_FAILED;
520 }
521
522 if (!data.WriteUint32(static_cast<uint32_t>(type))) {
523 WLOGFE("Write type failed");
524 return WMError::WM_ERROR_IPC_FAILED;
525 }
526
527 if (!data.WriteRemoteObject(windowManagerAgent->AsObject())) {
528 WLOGFE("Write IWindowManagerAgent failed");
529 return WMError::WM_ERROR_IPC_FAILED;
530 }
531
532 sptr<IRemoteObject> remote = Remote();
533 if (remote == nullptr) {
534 WLOGFE("remote is null");
535 return WMError::WM_ERROR_IPC_FAILED;
536 }
537 if (remote->SendRequest(static_cast<uint32_t>(
538 SceneSessionManagerMessage::TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT),
539 data, reply, option) != ERR_NONE) {
540 WLOGFE("SendRequest failed");
541 return WMError::WM_ERROR_IPC_FAILED;
542 }
543
544 return static_cast<WMError>(reply.ReadInt32());
545 }
546
UnregisterWindowManagerAgent(WindowManagerAgentType type,const sptr<IWindowManagerAgent> & windowManagerAgent)547 WMError SceneSessionManagerProxy::UnregisterWindowManagerAgent(WindowManagerAgentType type,
548 const sptr<IWindowManagerAgent>& windowManagerAgent)
549 {
550 MessageParcel reply;
551 MessageOption option;
552 MessageParcel data;
553 if (!data.WriteInterfaceToken(GetDescriptor())) {
554 WLOGFE("Write InterfaceToken failed");
555 return WMError::WM_ERROR_IPC_FAILED;
556 }
557
558 if (!data.WriteUint32(static_cast<uint32_t>(type))) {
559 WLOGFE("Write type failed");
560 return WMError::WM_ERROR_IPC_FAILED;
561 }
562
563 if (!data.WriteRemoteObject(windowManagerAgent->AsObject())) {
564 WLOGFE("Write IWindowManagerAgent failed");
565 return WMError::WM_ERROR_IPC_FAILED;
566 }
567
568 sptr<IRemoteObject> remote = Remote();
569 if (remote == nullptr) {
570 WLOGFE("remote is null");
571 return WMError::WM_ERROR_IPC_FAILED;
572 }
573 if (remote->SendRequest(static_cast<uint32_t>(
574 SceneSessionManagerMessage::TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT),
575 data, reply, option) != ERR_NONE) {
576 WLOGFE("SendRequest failed");
577 return WMError::WM_ERROR_IPC_FAILED;
578 }
579
580 return static_cast<WMError>(reply.ReadInt32());
581 }
582
SetGestureNavigaionEnabled(bool enable)583 WMError SceneSessionManagerProxy::SetGestureNavigaionEnabled(bool enable)
584 {
585 MessageParcel data;
586 MessageParcel reply;
587 MessageOption option(MessageOption::TF_SYNC);
588 if (!data.WriteInterfaceToken(GetDescriptor())) {
589 WLOGFE("Write InterfaceToken failed");
590 return WMError::WM_ERROR_IPC_FAILED;
591 }
592
593 if (!data.WriteBool(enable)) {
594 WLOGFE("Write enable failed");
595 return WMError::WM_ERROR_IPC_FAILED;
596 }
597
598 sptr<IRemoteObject> remote = Remote();
599 if (remote == nullptr) {
600 WLOGFE("remote is null");
601 return WMError::WM_ERROR_IPC_FAILED;
602 }
603 if (remote->SendRequest(static_cast<uint32_t>(
604 SceneSessionManagerMessage::TRANS_ID_SET_GESTURE_NAVIGATION_ENABLED), data, reply, option) != ERR_NONE) {
605 WLOGFE("SendRequest failed");
606 return WMError::WM_ERROR_IPC_FAILED;
607 }
608 int32_t ret = reply.ReadInt32();
609 return static_cast<WMError>(ret);
610 }
611
GetFocusWindowInfo(FocusChangeInfo & focusInfo)612 void SceneSessionManagerProxy::GetFocusWindowInfo(FocusChangeInfo& focusInfo)
613 {
614 MessageParcel data;
615 MessageParcel reply;
616 MessageOption option;
617 if (!data.WriteInterfaceToken(GetDescriptor())) {
618 WLOGFE("WriteInterfaceToken failed");
619 return;
620 }
621
622 sptr<IRemoteObject> remote = Remote();
623 if (remote == nullptr) {
624 WLOGFE("remote is null");
625 return;
626 }
627 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_FOCUS_SESSION_INFO),
628 data, reply, option) != ERR_NONE) {
629 WLOGFE("SendRequest failed");
630 return;
631 }
632 sptr<FocusChangeInfo> info = reply.ReadParcelable<FocusChangeInfo>();
633 if (info) {
634 focusInfo = *info;
635 } else {
636 WLOGFE("info is null.");
637 }
638 }
639
SetSessionLabel(const sptr<IRemoteObject> & token,const std::string & label)640 WSError SceneSessionManagerProxy::SetSessionLabel(const sptr<IRemoteObject>& token, const std::string& label)
641 {
642 WLOGFI("run SceneSessionManagerProxy::SetSessionLabel");
643 MessageParcel data;
644 MessageParcel reply;
645 MessageOption option;
646 if (!data.WriteInterfaceToken(GetDescriptor())) {
647 WLOGFE("WriteInterfaceToken failed");
648 return WSError::WS_ERROR_IPC_FAILED;
649 }
650 if (!data.WriteRemoteObject(token)) {
651 WLOGFE("Write token failed");
652 return WSError::WS_ERROR_IPC_FAILED;
653 }
654 if (!data.WriteString(label)) {
655 WLOGFE("Write label failed");
656 return WSError::WS_ERROR_IPC_FAILED;
657 }
658
659 sptr<IRemoteObject> remote = Remote();
660 if (remote == nullptr) {
661 WLOGFE("remote is null");
662 return WSError::WS_ERROR_IPC_FAILED;
663 }
664 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_SESSION_LABEL),
665 data, reply, option) != ERR_NONE) {
666 WLOGFE("SendRequest failed");
667 return WSError::WS_ERROR_IPC_FAILED;
668 }
669 return static_cast<WSError>(reply.ReadInt32());
670 }
671
SetSessionIcon(const sptr<IRemoteObject> & token,const std::shared_ptr<Media::PixelMap> & icon)672 WSError SceneSessionManagerProxy::SetSessionIcon(const sptr<IRemoteObject>& token,
673 const std::shared_ptr<Media::PixelMap>& icon)
674 {
675 WLOGFI("run SceneSessionManagerProxy::SetSessionIcon");
676 MessageParcel data;
677 MessageParcel reply;
678 MessageOption option;
679 if (!data.WriteInterfaceToken(GetDescriptor())) {
680 WLOGFE("WriteInterfaceToken failed");
681 return WSError::WS_ERROR_IPC_FAILED;
682 }
683 if (!data.WriteRemoteObject(token)) {
684 WLOGFE("Write token failed");
685 return WSError::WS_ERROR_IPC_FAILED;
686 }
687 if (!data.WriteParcelable(icon.get())) {
688 WLOGFE("Write icon failed");
689 return WSError::WS_ERROR_IPC_FAILED;
690 }
691
692 sptr<IRemoteObject> remote = Remote();
693 if (remote == nullptr) {
694 WLOGFE("remote is null");
695 return WSError::WS_ERROR_IPC_FAILED;
696 }
697 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_SESSION_ICON),
698 data, reply, option) != ERR_NONE) {
699 WLOGFE("SendRequest failed");
700 return WSError::WS_ERROR_IPC_FAILED;
701 }
702 return static_cast<WSError>(reply.ReadInt32());
703 }
704
IsValidSessionIds(const std::vector<int32_t> & sessionIds,std::vector<bool> & results)705 WSError SceneSessionManagerProxy::IsValidSessionIds(
706 const std::vector<int32_t>& sessionIds, std::vector<bool>& results)
707 {
708 WLOGFI("run SceneSessionManagerProxy::IsValidSessionIds");
709 MessageParcel data;
710 MessageParcel reply;
711 MessageOption option;
712 if (!data.WriteInterfaceToken(GetDescriptor())) {
713 WLOGFE("WriteInterfaceToken failed");
714 return WSError::WS_ERROR_IPC_FAILED;
715 }
716 if (!data.WriteInt32Vector(sessionIds)) {
717 WLOGFE("Write sessionIds failed");
718 return WSError::WS_ERROR_IPC_FAILED;
719 }
720
721 sptr<IRemoteObject> remote = Remote();
722 if (remote == nullptr) {
723 WLOGFE("remote is null");
724 return WSError::WS_ERROR_IPC_FAILED;
725 }
726 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_IS_VALID_SESSION_IDS),
727 data, reply, option) != ERR_NONE) {
728 WLOGFE("SendRequest failed");
729 return WSError::WS_ERROR_IPC_FAILED;
730 }
731
732 reply.ReadBoolVector(&results);
733 return static_cast<WSError>(reply.ReadInt32());
734 }
735
GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>> & infos)736 WMError SceneSessionManagerProxy::GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos)
737 {
738 MessageOption option;
739 MessageParcel reply;
740 MessageParcel data;
741 if (!data.WriteInterfaceToken(GetDescriptor())) {
742 WLOGFE("Write InterfaceToken failed");
743 return WMError::WM_ERROR_IPC_FAILED;
744 }
745
746 sptr<IRemoteObject> remote = Remote();
747 if (remote == nullptr) {
748 WLOGFE("remote is null");
749 return WMError::WM_ERROR_IPC_FAILED;
750 }
751 if (remote->SendRequest(static_cast<uint32_t>(
752 SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_INFO),
753 data, reply, option) != ERR_NONE) {
754 WLOGFE("SendRequest failed");
755 return WMError::WM_ERROR_IPC_FAILED;
756 }
757
758 if (!MarshallingHelper::UnmarshallingVectorParcelableObj<AccessibilityWindowInfo>(reply, infos)) {
759 WLOGFE("read window info failed.");
760 return WMError::WM_ERROR_IPC_FAILED;
761 }
762 return static_cast<WMError>(reply.ReadUint32());
763 }
764
GetUnreliableWindowInfo(int32_t windowId,std::vector<sptr<UnreliableWindowInfo>> & infos)765 WMError SceneSessionManagerProxy::GetUnreliableWindowInfo(int32_t windowId,
766 std::vector<sptr<UnreliableWindowInfo>>& infos)
767 {
768 TLOGD(WmsLogTag::DEFAULT, "run!");
769 MessageOption option;
770 MessageParcel reply;
771 MessageParcel data;
772 if (!data.WriteInterfaceToken(GetDescriptor())) {
773 TLOGE(WmsLogTag::DEFAULT, "Write InterfaceToken failed");
774 return WMError::WM_ERROR_IPC_FAILED;
775 }
776
777 if (!data.WriteInt32(windowId)) {
778 TLOGE(WmsLogTag::DEFAULT, "Write windowId failed");
779 return WMError::WM_ERROR_IPC_FAILED;
780 }
781
782 sptr<IRemoteObject> remote = Remote();
783 if (remote == nullptr) {
784 TLOGE(WmsLogTag::DEFAULT, "remote is null");
785 return WMError::WM_ERROR_IPC_FAILED;
786 }
787 if (remote->SendRequest(static_cast<uint32_t>(
788 SceneSessionManagerMessage::TRANS_ID_GET_UNRELIABLE_WINDOW_INFO),
789 data, reply, option) != ERR_NONE) {
790 TLOGE(WmsLogTag::DEFAULT, "SendRequest failed");
791 return WMError::WM_ERROR_IPC_FAILED;
792 }
793
794 if (!MarshallingHelper::UnmarshallingVectorParcelableObj<UnreliableWindowInfo>(reply, infos)) {
795 TLOGE(WmsLogTag::DEFAULT, "read window info failed.");
796 return WMError::WM_ERROR_IPC_FAILED;
797 }
798 return static_cast<WMError>(reply.ReadInt32());
799 }
800
PendingSessionToForeground(const sptr<IRemoteObject> & token)801 WSError SceneSessionManagerProxy::PendingSessionToForeground(const sptr<IRemoteObject>& token)
802 {
803 WLOGFI("run SceneSessionManagerProxy::PendingSessionToForeground");
804 MessageParcel data;
805 MessageParcel reply;
806 MessageOption option;
807 if (!data.WriteInterfaceToken(GetDescriptor())) {
808 WLOGFE("Write interfaceToken failed");
809 return WSError::WS_ERROR_IPC_FAILED;
810 }
811
812 if (!data.WriteRemoteObject(token)) {
813 WLOGFE("Write token failed");
814 return WSError::WS_ERROR_IPC_FAILED;
815 }
816
817 sptr<IRemoteObject> remote = Remote();
818 if (remote == nullptr) {
819 WLOGFE("remote is null");
820 return WSError::WS_ERROR_IPC_FAILED;
821 }
822 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_PENDING_SESSION_TO_FOREGROUND),
823 data, reply, option) != ERR_NONE) {
824 WLOGFE("SendRequest failed");
825 return WSError::WS_ERROR_IPC_FAILED;
826 }
827 return static_cast<WSError>(reply.ReadInt32());
828 }
829
PendingSessionToBackgroundForDelegator(const sptr<IRemoteObject> & token,bool shouldBackToCaller)830 WSError SceneSessionManagerProxy::PendingSessionToBackgroundForDelegator(const sptr<IRemoteObject>& token,
831 bool shouldBackToCaller)
832 {
833 TLOGD(WmsLogTag::WMS_LIFE, "run");
834 MessageParcel data;
835 MessageParcel reply;
836 MessageOption option;
837 if (!data.WriteInterfaceToken(GetDescriptor())) {
838 TLOGE(WmsLogTag::WMS_LIFE, "Write interfaceToken failed");
839 return WSError::WS_ERROR_IPC_FAILED;
840 }
841
842 if (!data.WriteRemoteObject(token)) {
843 TLOGE(WmsLogTag::WMS_LIFE, "Write token failed");
844 return WSError::WS_ERROR_IPC_FAILED;
845 }
846
847 if (!data.WriteBool(shouldBackToCaller)) {
848 TLOGE(WmsLogTag::WMS_LIFE, "Write shouldBackToCaller failed");
849 return WSError::WS_ERROR_IPC_FAILED;
850 }
851
852 sptr<IRemoteObject> remote = Remote();
853 if (remote == nullptr) {
854 TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
855 return WSError::WS_ERROR_IPC_FAILED;
856 }
857 if (remote->SendRequest(static_cast<uint32_t>(
858 SceneSessionManagerMessage::TRANS_ID_PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR),
859 data, reply, option) != ERR_NONE) {
860 TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed");
861 return WSError::WS_ERROR_IPC_FAILED;
862 }
863 return static_cast<WSError>(reply.ReadInt32());
864 }
865
RegisterSessionListener(const sptr<ISessionListener> & listener)866 WSError SceneSessionManagerProxy::RegisterSessionListener(const sptr<ISessionListener>& listener)
867 {
868 WLOGFI("run SceneSessionManagerProxy::RegisterSessionListener");
869 MessageParcel data;
870 MessageParcel reply;
871 MessageOption option(MessageOption::TF_SYNC);
872 if (listener == nullptr) {
873 WLOGFE("register mission listener, listener is nullptr");
874 return WSError::WS_ERROR_INVALID_PARAM;
875 }
876 if (!data.WriteInterfaceToken(GetDescriptor())) {
877 WLOGFE("WriteInterfaceToken failed");
878 return WSError::WS_ERROR_IPC_FAILED;
879 }
880 if (!data.WriteRemoteObject(listener->AsObject())) {
881 WLOGFE("write mission listener failed when register mission listener.");
882 return WSError::WS_ERROR_IPC_FAILED;
883 }
884 sptr<IRemoteObject> remote = Remote();
885 if (remote == nullptr) {
886 WLOGFE("remote is null");
887 return WSError::WS_ERROR_IPC_FAILED;
888 }
889 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REGISTER_SESSION_LISTENER),
890 data, reply, option) != ERR_NONE) {
891 WLOGFE("SendRequest failed");
892 return WSError::WS_ERROR_IPC_FAILED;
893 }
894 return static_cast<WSError>(reply.ReadInt32());
895 }
896
UnRegisterSessionListener(const sptr<ISessionListener> & listener)897 WSError SceneSessionManagerProxy::UnRegisterSessionListener(const sptr<ISessionListener>& listener)
898 {
899 WLOGFI("run SceneSessionManagerProxy::UnRegisterSessionListener");
900 if (listener == nullptr) {
901 WLOGFE("unregister mission listener, listener is nullptr");
902 return WSError::WS_ERROR_INVALID_PARAM;
903 }
904 MessageParcel data;
905 MessageParcel reply;
906 MessageOption option(MessageOption::TF_SYNC);
907 if (!data.WriteInterfaceToken(GetDescriptor())) {
908 WLOGFE("WriteInterfaceToken failed");
909 return WSError::WS_ERROR_IPC_FAILED;
910 }
911 if (!data.WriteRemoteObject(listener->AsObject())) {
912 WLOGFE("write mission listener failed when unregister mission listener.");
913 return WSError::WS_ERROR_IPC_FAILED;
914 }
915 sptr<IRemoteObject> remote = Remote();
916 if (remote == nullptr) {
917 WLOGFE("remote is null");
918 return WSError::WS_ERROR_IPC_FAILED;
919 }
920 if (remote->SendRequest(
921 static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UNREGISTER_SESSION_LISTENER),
922 data, reply, option) != ERR_NONE) {
923 WLOGFE("SendRequest failed");
924 return WSError::WS_ERROR_IPC_FAILED;
925 }
926 return static_cast<WSError>(reply.ReadInt32());
927 }
928
GetSessionInfos(const std::string & deviceId,int32_t numMax,std::vector<SessionInfoBean> & sessionInfos)929 WSError SceneSessionManagerProxy::GetSessionInfos(const std::string& deviceId, int32_t numMax,
930 std::vector<SessionInfoBean>& sessionInfos)
931 {
932 WLOGFI("run SceneSessionManagerProxy::GetSessionInfos");
933 MessageParcel data;
934 MessageParcel reply;
935 MessageOption option(MessageOption::TF_SYNC);
936 if (!data.WriteInterfaceToken(GetDescriptor())) {
937 WLOGFE("WriteInterfaceToken failed");
938 return WSError::WS_ERROR_IPC_FAILED;
939 }
940 if (!data.WriteString16(Str8ToStr16(deviceId))) {
941 WLOGFE("GetSessionInfos write deviceId failed.");
942 return WSError::WS_ERROR_IPC_FAILED;
943 }
944 if (!data.WriteInt32(numMax)) {
945 WLOGFE("GetSessionInfos numMax write failed.");
946 return WSError::WS_ERROR_IPC_FAILED;
947 }
948 sptr<IRemoteObject> remote = Remote();
949 if (remote == nullptr) {
950 WLOGFE("remote is null");
951 return WSError::WS_ERROR_IPC_FAILED;
952 }
953 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_MISSION_INFOS),
954 data, reply, option) != ERR_NONE) {
955 WLOGFE("SendRequest failed");
956 return WSError::WS_ERROR_IPC_FAILED;
957 }
958 WSError error = GetParcelableInfos(reply, sessionInfos);
959 if (error != WSError::WS_OK) {
960 WLOGFE("GetSessionInfos error");
961 return error;
962 }
963 return static_cast<WSError>(reply.ReadInt32());
964 }
965
GetSessionInfo(const std::string & deviceId,int32_t persistentId,SessionInfoBean & sessionInfo)966 WSError SceneSessionManagerProxy::GetSessionInfo(const std::string& deviceId, int32_t persistentId,
967 SessionInfoBean& sessionInfo)
968 {
969 WLOGFI("run SceneSessionManagerProxy::GetSessionInfo");
970 MessageParcel data;
971 MessageParcel reply;
972 MessageOption option(MessageOption::TF_SYNC);
973 if (!data.WriteInterfaceToken(GetDescriptor())) {
974 WLOGFE("WriteInterfaceToken failed");
975 return WSError::WS_ERROR_IPC_FAILED;
976 }
977 if (!data.WriteString16(Str8ToStr16(deviceId))) {
978 WLOGFE("GetSessionInfo write deviceId failed.");
979 return WSError::WS_ERROR_IPC_FAILED;
980 }
981 if (!data.WriteInt32(persistentId)) {
982 WLOGFE("GetSessionInfo write persistentId failed.");
983 return WSError::WS_ERROR_IPC_FAILED;
984 }
985 sptr<IRemoteObject> remote = Remote();
986 if (remote == nullptr) {
987 WLOGFE("remote is null");
988 return WSError::WS_ERROR_IPC_FAILED;
989 }
990 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_MISSION_INFO_BY_ID),
991 data, reply, option) != ERR_NONE) {
992 WLOGFE("SendRequest failed");
993 return WSError::WS_ERROR_IPC_FAILED;
994 }
995 std::unique_ptr<SessionInfoBean> info(reply.ReadParcelable<SessionInfoBean>());
996 if (info == nullptr) {
997 WLOGFE("read missioninfo failed.");
998 return WSError::WS_ERROR_IPC_FAILED;
999 }
1000 sessionInfo = *info;
1001 return static_cast<WSError>(reply.ReadInt32());
1002 }
1003
GetSessionInfoByContinueSessionId(const std::string & continueSessionId,SessionInfoBean & sessionInfo)1004 WSError SceneSessionManagerProxy::GetSessionInfoByContinueSessionId(
1005 const std::string& continueSessionId, SessionInfoBean& sessionInfo)
1006 {
1007 TLOGD(WmsLogTag::WMS_LIFE, "run query session info");
1008 MessageParcel data;
1009 MessageParcel reply;
1010 MessageOption option(MessageOption::TF_SYNC);
1011 if (!data.WriteInterfaceToken(GetDescriptor())) {
1012 TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
1013 return WSError::WS_ERROR_IPC_FAILED;
1014 }
1015 if (!data.WriteString(continueSessionId)) {
1016 TLOGE(WmsLogTag::WMS_LIFE, "GetSessionInfoByContinueSessionId write continueSessionId failed.");
1017 return WSError::WS_ERROR_IPC_FAILED;
1018 }
1019 sptr<IRemoteObject> remote = Remote();
1020 if (remote == nullptr) {
1021 TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
1022 return WSError::WS_ERROR_IPC_FAILED;
1023 }
1024 if (remote->SendRequest(static_cast<uint32_t>(
1025 SceneSessionManagerMessage::TRANS_ID_GET_SESSION_INFO_BY_CONTINUE_SESSION_ID),
1026 data, reply, option) != ERR_NONE) {
1027 TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed");
1028 return WSError::WS_ERROR_IPC_FAILED;
1029 }
1030 sptr<SessionInfoBean> info(reply.ReadParcelable<SessionInfoBean>());
1031 if (info == nullptr) {
1032 TLOGE(WmsLogTag::WMS_LIFE, "read sessioninfo failed.");
1033 return WSError::WS_ERROR_IPC_FAILED;
1034 }
1035 sessionInfo = *info;
1036 return static_cast<WSError>(reply.ReadInt32());
1037 }
1038
DumpSessionAll(std::vector<std::string> & infos)1039 WSError SceneSessionManagerProxy::DumpSessionAll(std::vector<std::string>& infos)
1040 {
1041 WLOGFI("run SceneSessionManagerProxy::DumpSessionAll");
1042 MessageParcel data;
1043 MessageParcel reply;
1044 MessageOption option(MessageOption::TF_SYNC);
1045 if (!data.WriteInterfaceToken(GetDescriptor())) {
1046 WLOGFE("DumpSessionAll write interface token failed.");
1047 return WSError::WS_ERROR_IPC_FAILED;
1048 }
1049 sptr<IRemoteObject> remote = Remote();
1050 if (remote == nullptr) {
1051 WLOGFE("remote is null");
1052 return WSError::WS_ERROR_IPC_FAILED;
1053 }
1054 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_DUMP_SESSION_ALL),
1055 data, reply, option) != ERR_NONE) {
1056 WLOGFE("DumpSessionAll sendRequest failed.");
1057 return WSError::WS_ERROR_IPC_FAILED;
1058 }
1059 if (!reply.ReadStringVector(&infos)) {
1060 WLOGFE("DumpSessionAll read session info failed.");
1061 return WSError::WS_ERROR_IPC_FAILED;
1062 }
1063 return static_cast<WSError>(reply.ReadInt32());
1064 }
1065
DumpSessionWithId(int32_t persistentId,std::vector<std::string> & infos)1066 WSError SceneSessionManagerProxy::DumpSessionWithId(int32_t persistentId, std::vector<std::string>& infos)
1067 {
1068 WLOGFI("run SceneSessionManagerProxy::DumpSessionWithId");
1069 MessageParcel data;
1070 MessageParcel reply;
1071 MessageOption option(MessageOption::TF_SYNC);
1072 if (!data.WriteInterfaceToken(GetDescriptor())) {
1073 WLOGFE("DumpSessionWithId write interface token failed.");
1074 return WSError::WS_ERROR_IPC_FAILED;
1075 }
1076 if (!data.WriteInt32(persistentId)) {
1077 WLOGFE("DumpSessionWithId write persistentId failed.");
1078 return WSError::WS_ERROR_IPC_FAILED;
1079 }
1080 sptr<IRemoteObject> remote = Remote();
1081 if (remote == nullptr) {
1082 WLOGFE("remote is null");
1083 return WSError::WS_ERROR_IPC_FAILED;
1084 }
1085 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_DUMP_SESSION_WITH_ID),
1086 data, reply, option) != ERR_NONE) {
1087 WLOGFE("DumpSessionWithId sendRequest failed.");
1088 return WSError::WS_ERROR_IPC_FAILED;
1089 }
1090 if (!reply.ReadStringVector(&infos)) {
1091 WLOGFE("DumpSessionWithId read session info failed.");
1092 return WSError::WS_ERROR_IPC_FAILED;
1093 }
1094 return static_cast<WSError>(reply.ReadInt32());
1095 }
1096
1097 template<typename T>
GetParcelableInfos(MessageParcel & reply,std::vector<T> & parcelableInfos)1098 WSError SceneSessionManagerProxy::GetParcelableInfos(MessageParcel& reply, std::vector<T>& parcelableInfos)
1099 {
1100 int32_t infoSize = reply.ReadInt32();
1101 if (infoSize > CYCLE_LIMIT) {
1102 WLOGFE("infoSize is too large");
1103 return WSError::WS_ERROR_IPC_FAILED;
1104 }
1105
1106 for (int32_t i = 0; i < infoSize; i++) {
1107 std::unique_ptr<T> info(reply.ReadParcelable<T>());
1108 if (!info) {
1109 WLOGFE("Read Parcelable infos failed.");
1110 return WSError::WS_ERROR_IPC_FAILED;
1111 }
1112 parcelableInfos.emplace_back(*info);
1113 }
1114 return WSError::WS_OK;
1115 }
1116
TerminateSessionNew(const sptr<AAFwk::SessionInfo> abilitySessionInfo,bool needStartCaller,bool isFromBroker)1117 WSError SceneSessionManagerProxy::TerminateSessionNew(const sptr<AAFwk::SessionInfo> abilitySessionInfo,
1118 bool needStartCaller, bool isFromBroker)
1119 {
1120 if (abilitySessionInfo == nullptr) {
1121 WLOGFE("abilitySessionInfo is null");
1122 return WSError::WS_ERROR_INVALID_SESSION;
1123 }
1124 MessageParcel data, reply;
1125 MessageOption option(MessageOption::TF_ASYNC);
1126 if (!data.WriteInterfaceToken(GetDescriptor())) {
1127 WLOGFE("WriteInterfaceToken failed");
1128 return WSError::WS_ERROR_IPC_FAILED;
1129 }
1130 if (!data.WriteParcelable(abilitySessionInfo)) {
1131 WLOGFE("write abilitySessionInfo failed");
1132 return WSError::WS_ERROR_IPC_FAILED;
1133 }
1134 if (!data.WriteBool(needStartCaller)) {
1135 WLOGFE("Write needStartCaller failed");
1136 return WSError::WS_ERROR_IPC_FAILED;
1137 }
1138 if (!data.WriteBool(isFromBroker)) {
1139 WLOGFE("Write isFromBroker failed");
1140 return WSError::WS_ERROR_IPC_FAILED;
1141 }
1142 sptr<IRemoteObject> remote = Remote();
1143 if (remote == nullptr) {
1144 WLOGFE("remote is null");
1145 return WSError::WS_ERROR_IPC_FAILED;
1146 }
1147 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_TERMINATE_SESSION_NEW),
1148 data, reply, option) != ERR_NONE) {
1149 WLOGFE("SendRequest failed");
1150 return WSError::WS_ERROR_IPC_FAILED;
1151 }
1152 return static_cast<WSError>(reply.ReadInt32());
1153 }
1154
GetFocusSessionToken(sptr<IRemoteObject> & token)1155 WSError SceneSessionManagerProxy::GetFocusSessionToken(sptr<IRemoteObject>& token)
1156 {
1157 WLOGFD("run SceneSessionManagerProxy::GetFocusSessionToken");
1158 MessageParcel data;
1159 MessageParcel reply;
1160 MessageOption option;
1161 if (!data.WriteInterfaceToken(GetDescriptor())) {
1162 WLOGFE("Write interfaceToken failed");
1163 return WSError::WS_ERROR_IPC_FAILED;
1164 }
1165
1166 sptr<IRemoteObject> remote = Remote();
1167 if (remote == nullptr) {
1168 WLOGFE("remote is null");
1169 return WSError::WS_ERROR_IPC_FAILED;
1170 }
1171 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_FOCUS_SESSION_TOKEN),
1172 data, reply, option) != ERR_NONE) {
1173 WLOGFE("SendRequest failed");
1174 return WSError::WS_ERROR_IPC_FAILED;
1175 }
1176 token = reply.ReadRemoteObject();
1177 if (token == nullptr) {
1178 WLOGFD("get token nullptr.");
1179 }
1180 return static_cast<WSError>(reply.ReadInt32());
1181 }
1182
GetFocusSessionElement(AppExecFwk::ElementName & element)1183 WSError SceneSessionManagerProxy::GetFocusSessionElement(AppExecFwk::ElementName& element)
1184 {
1185 WLOGFD("run SceneSessionManagerProxy::GetFocusSessionElement");
1186 MessageParcel data;
1187 MessageParcel reply;
1188 MessageOption option;
1189 if (!data.WriteInterfaceToken(GetDescriptor())) {
1190 WLOGFE("Write interfaceToken failed");
1191 return WSError::WS_ERROR_IPC_FAILED;
1192 }
1193 sptr<IRemoteObject> remote = Remote();
1194 if (remote == nullptr) {
1195 WLOGFE("remote is null");
1196 return WSError::WS_ERROR_IPC_FAILED;
1197 }
1198 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_FOCUS_SESSION_ELEMENT),
1199 data, reply, option) != ERR_NONE) {
1200 WLOGFE("SendRequest failed");
1201 return WSError::WS_ERROR_IPC_FAILED;
1202 }
1203 sptr<AppExecFwk::ElementName> ret = reply.ReadParcelable<AppExecFwk::ElementName>();
1204 if (ret) {
1205 element = *ret;
1206 } else {
1207 WLOGFD("get element null.");
1208 }
1209 return static_cast<WSError>(reply.ReadInt32());
1210 }
1211
CheckWindowId(int32_t windowId,int32_t & pid)1212 WMError SceneSessionManagerProxy::CheckWindowId(int32_t windowId, int32_t& pid)
1213 {
1214 MessageParcel data;
1215 MessageParcel reply;
1216 MessageOption option;
1217 if (!data.WriteInterfaceToken(GetDescriptor())) {
1218 WLOGFE("Failed to write interfaceToken");
1219 return WMError::WM_ERROR_IPC_FAILED;
1220 }
1221 if (!data.WriteInt32(windowId)) {
1222 WLOGFE("Failed to write windowId");
1223 return WMError::WM_ERROR_IPC_FAILED;
1224 }
1225 sptr<IRemoteObject> remote = Remote();
1226 if (remote == nullptr) {
1227 WLOGFE("remote is nullptr");
1228 return WMError::WM_ERROR_NULLPTR;
1229 }
1230 int32_t ret = remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_CHECK_WINDOW_ID),
1231 data, reply, option);
1232 if (ret != ERR_NONE) {
1233 WLOGFE("Send request failed, ret:%{public}d", ret);
1234 return WMError::WM_ERROR_IPC_FAILED;
1235 }
1236 if (!reply.ReadInt32(pid)) {
1237 WLOGFE("Failed to read pid");
1238 return WMError::WM_ERROR_IPC_FAILED;
1239 }
1240 return WMError::WM_OK;
1241 }
1242
GetSessionDumpInfo(const std::vector<std::string> & params,std::string & info)1243 WSError SceneSessionManagerProxy::GetSessionDumpInfo(const std::vector<std::string>& params, std::string& info)
1244 {
1245 MessageParcel data;
1246 MessageParcel reply;
1247 MessageOption option;
1248 if (!data.WriteInterfaceToken(GetDescriptor())) {
1249 WLOGFE("WriteInterfaceToken failed");
1250 return WSError::WS_ERROR_INVALID_PARAM;
1251 }
1252 if (!data.WriteStringVector(params)) {
1253 WLOGFE("Write params failed");
1254 return WSError::WS_ERROR_IPC_FAILED;
1255 }
1256 sptr<IRemoteObject> remote = Remote();
1257 if (remote == nullptr) {
1258 WLOGFE("remote is null");
1259 return WSError::WS_ERROR_IPC_FAILED;
1260 }
1261 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_SESSION_DUMP_INFO),
1262 data, reply, option) != ERR_NONE) {
1263 WLOGFE("SendRequest failed");
1264 return WSError::WS_ERROR_IPC_FAILED;
1265 }
1266
1267 auto infoSize = reply.ReadUint32();
1268 if (infoSize != 0) {
1269 const char* infoPtr = nullptr;
1270 infoPtr = reinterpret_cast<const char*>(reply.ReadRawData(infoSize));
1271 info = (infoPtr) ? std::string(infoPtr, infoSize) : "";
1272 }
1273 WLOGFD("GetSessionDumpInfo, infoSize: %{public}d", infoSize);
1274 return static_cast<WSError>(reply.ReadInt32());
1275 }
1276
GetSessionSnapshot(const std::string & deviceId,int32_t persistentId,SessionSnapshot & snapshot,bool isLowResolution)1277 WSError SceneSessionManagerProxy::GetSessionSnapshot(const std::string& deviceId, int32_t persistentId,
1278 SessionSnapshot& snapshot, bool isLowResolution)
1279 {
1280 MessageParcel data;
1281 MessageParcel reply;
1282 MessageOption option;
1283 if (!data.WriteInterfaceToken(GetDescriptor())) {
1284 WLOGFE("WriteInterfaceToken failed");
1285 return WSError::WS_ERROR_INVALID_PARAM;
1286 }
1287 if (!data.WriteString16(Str8ToStr16(deviceId))) {
1288 WLOGFE("Write deviceId failed.");
1289 return WSError::WS_ERROR_IPC_FAILED;
1290 }
1291 if (!data.WriteInt32(persistentId)) {
1292 WLOGFE("Write persistentId failed");
1293 return WSError::WS_ERROR_INVALID_PARAM;
1294 }
1295
1296 if (!data.WriteBool(isLowResolution)) {
1297 WLOGFE("Write isLowResolution failed");
1298 return WSError::WS_ERROR_INVALID_PARAM;
1299 }
1300
1301 sptr<IRemoteObject> remote = Remote();
1302 if (remote == nullptr) {
1303 WLOGFE("remote is null");
1304 return WSError::WS_ERROR_IPC_FAILED;
1305 }
1306 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_SESSION_SNAPSHOT),
1307 data, reply, option) != ERR_NONE) {
1308 WLOGFE("SendRequest failed");
1309 return WSError::WS_ERROR_IPC_FAILED;
1310 }
1311 std::unique_ptr<SessionSnapshot> info(reply.ReadParcelable<SessionSnapshot>());
1312 if (info) {
1313 snapshot = *info;
1314 } else {
1315 WLOGFW("Read SessionSnapshot is null.");
1316 }
1317 return static_cast<WSError>(reply.ReadInt32());
1318 }
1319
GetUIContentRemoteObj(int32_t persistentId,sptr<IRemoteObject> & uiContentRemoteObj)1320 WSError SceneSessionManagerProxy::GetUIContentRemoteObj(int32_t persistentId, sptr<IRemoteObject>& uiContentRemoteObj)
1321 {
1322 MessageParcel data;
1323 MessageParcel reply;
1324 MessageOption option;
1325 if (!data.WriteInterfaceToken(GetDescriptor())) {
1326 TLOGE(WmsLogTag::DEFAULT, "WriteInterfaceToken failed");
1327 return WSError::WS_ERROR_INVALID_PARAM;
1328 }
1329 if (!data.WriteInt32(persistentId)) {
1330 TLOGE(WmsLogTag::DEFAULT, "Write persistentId failed");
1331 return WSError::WS_ERROR_INVALID_PARAM;
1332 }
1333
1334 sptr<IRemoteObject> remote = Remote();
1335 if (remote == nullptr) {
1336 TLOGE(WmsLogTag::DEFAULT, "remote is null");
1337 return WSError::WS_ERROR_IPC_FAILED;
1338 }
1339 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_UI_CONTENT_REMOTE_OBJ),
1340 data, reply, option) != ERR_NONE) {
1341 TLOGE(WmsLogTag::DEFAULT, "SendRequest failed");
1342 return WSError::WS_ERROR_IPC_FAILED;
1343 }
1344 sptr<IRemoteObject> remoteObj = reply.ReadRemoteObject();
1345 if (remoteObj == nullptr) {
1346 TLOGE(WmsLogTag::DEFAULT, "ReadRemoteObject failed");
1347 return WSError::WS_ERROR_IPC_FAILED;
1348 }
1349 uiContentRemoteObj = remoteObj;
1350 return static_cast<WSError>(reply.ReadUint32());
1351 }
1352
SetSessionContinueState(const sptr<IRemoteObject> & token,const ContinueState & continueState)1353 WSError SceneSessionManagerProxy::SetSessionContinueState(const sptr<IRemoteObject>& token,
1354 const ContinueState& continueState)
1355 {
1356 MessageParcel data;
1357 MessageParcel reply;
1358 MessageOption option;
1359 if (!data.WriteInterfaceToken(GetDescriptor())) {
1360 WLOGFE("WriteInterfaceToken failed");
1361 return WSError::WS_ERROR_INVALID_PARAM;
1362 }
1363 if (!data.WriteRemoteObject(token)) {
1364 WLOGFE("Write token failed");
1365 return WSError::WS_ERROR_IPC_FAILED;
1366 }
1367 if (!data.WriteInt32(static_cast<int32_t>(continueState))) {
1368 WLOGFE("Write continueState failed");
1369 return WSError::WS_ERROR_IPC_FAILED;
1370 }
1371 sptr<IRemoteObject> remote = Remote();
1372 if (remote == nullptr) {
1373 WLOGFE("remote is null");
1374 return WSError::WS_ERROR_IPC_FAILED;
1375 }
1376 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_SESSION_CONTINUE_STATE),
1377 data, reply, option) != ERR_NONE) {
1378 WLOGFE("SendRequest failed");
1379 return WSError::WS_ERROR_IPC_FAILED;
1380 }
1381 return static_cast<WSError>(reply.ReadInt32());
1382 }
1383
NotifyDumpInfoResult(const std::vector<std::string> & info)1384 void SceneSessionManagerProxy::NotifyDumpInfoResult(const std::vector<std::string>& info)
1385 {
1386 MessageParcel data;
1387 MessageParcel reply;
1388 MessageOption option(MessageOption::TF_ASYNC);
1389 if (!data.WriteInterfaceToken(GetDescriptor())) {
1390 WLOGFE("WriteInterfaceToken pfailed");
1391 return;
1392 }
1393 uint32_t vectorSize = static_cast<uint32_t>(info.size());
1394 if (!data.WriteUint32(vectorSize)) {
1395 WLOGFE("Write vector size failed");
1396 return;
1397 }
1398 for (const auto& elem : info) {
1399 const char* curInfo = elem.c_str();
1400 uint32_t curSize = static_cast<uint32_t>(strlen(curInfo));
1401 WLOGFD("NotifyDumpInfoResult infoSize: %{public}u", curSize);
1402 if (!data.WriteUint32(curSize)) {
1403 WLOGFE("Write info size failed");
1404 return;
1405 }
1406 if (curSize != 0) {
1407 if (!data.WriteRawData(curInfo, curSize)) {
1408 WLOGFE("Write info failed");
1409 return;
1410 }
1411 }
1412 }
1413 sptr<IRemoteObject> remote = Remote();
1414 if (remote == nullptr) {
1415 WLOGFE("remote is null");
1416 return;
1417 }
1418 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_NOTIFY_DUMP_INFO_RESULT),
1419 data, reply, option) != ERR_NONE) {
1420 WLOGFE("SendRequest failed");
1421 return;
1422 }
1423 }
1424
LockSession(int32_t sessionId)1425 WSError SceneSessionManagerProxy::LockSession(int32_t sessionId)
1426 {
1427 WLOGFI("run SceneSessionManagerProxy::LockSession");
1428 MessageParcel data;
1429 MessageParcel reply;
1430 MessageOption option;
1431
1432 if (!data.WriteInterfaceToken(GetDescriptor())) {
1433 WLOGFE("Write interface token failed.");
1434 return WSError::WS_ERROR_INVALID_PARAM;
1435 }
1436 if (!data.WriteInt32(sessionId)) {
1437 WLOGFE("Write persistentId failed");
1438 return WSError::WS_ERROR_INVALID_PARAM;
1439 }
1440 sptr<IRemoteObject> remote = Remote();
1441 if (remote == nullptr) {
1442 WLOGFE("remote is null");
1443 return WSError::WS_ERROR_IPC_FAILED;
1444 }
1445 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_LOCK_SESSION),
1446 data, reply, option) != ERR_NONE) {
1447 WLOGFE("SendRequest failed");
1448 return WSError::WS_ERROR_IPC_FAILED;
1449 }
1450 return static_cast<WSError>(reply.ReadInt32());
1451 }
1452
UnlockSession(int32_t sessionId)1453 WSError SceneSessionManagerProxy::UnlockSession(int32_t sessionId)
1454 {
1455 WLOGFI("run SceneSessionManagerProxy::UnlockSession");
1456 MessageParcel data;
1457 MessageParcel reply;
1458 MessageOption option;
1459
1460 if (!data.WriteInterfaceToken(GetDescriptor())) {
1461 WLOGFE("Write interface token failed.");
1462 return WSError::WS_ERROR_INVALID_PARAM;
1463 }
1464 if (!data.WriteInt32(sessionId)) {
1465 WLOGFE("Write persistentId failed");
1466 return WSError::WS_ERROR_INVALID_PARAM;
1467 }
1468 sptr<IRemoteObject> remote = Remote();
1469 if (remote == nullptr) {
1470 WLOGFE("remote is null");
1471 return WSError::WS_ERROR_IPC_FAILED;
1472 }
1473 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UNLOCK_SESSION),
1474 data, reply, option) != ERR_NONE) {
1475 WLOGFE("SendRequest failed");
1476 return WSError::WS_ERROR_IPC_FAILED;
1477 }
1478 return static_cast<WSError>(reply.ReadInt32());
1479 }
1480
MoveSessionsToForeground(const std::vector<std::int32_t> & sessionIds,int32_t topSessionId)1481 WSError SceneSessionManagerProxy::MoveSessionsToForeground(const std::vector<std::int32_t>& sessionIds,
1482 int32_t topSessionId)
1483 {
1484 WLOGFI("run SceneSessionManagerProxy::MoveSessionsToForeground");
1485 MessageParcel data;
1486 MessageParcel reply;
1487 MessageOption option;
1488 if (!data.WriteInterfaceToken(GetDescriptor())) {
1489 WLOGFE("WriteInterfaceToken failed");
1490 return WSError::WS_ERROR_INVALID_PARAM;
1491 }
1492 if (!data.WriteInt32Vector(sessionIds)) {
1493 WLOGFE("Write sessionIds failed");
1494 return WSError::WS_ERROR_INVALID_PARAM;
1495 }
1496 if (!data.WriteInt32(topSessionId)) {
1497 WLOGFE("Write topSessionId failed");
1498 return WSError::WS_ERROR_INVALID_PARAM;
1499 }
1500 sptr<IRemoteObject> remote = Remote();
1501 if (remote == nullptr) {
1502 WLOGFE("remote is null");
1503 return WSError::WS_ERROR_IPC_FAILED;
1504 }
1505 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_MOVE_MISSIONS_TO_FOREGROUND),
1506 data, reply, option) != ERR_NONE) {
1507 WLOGFE("SendRequest failed");
1508 return WSError::WS_ERROR_IPC_FAILED;
1509 }
1510 return static_cast<WSError>(reply.ReadInt32());
1511 }
1512
MoveSessionsToBackground(const std::vector<std::int32_t> & sessionIds,std::vector<int32_t> & result)1513 WSError SceneSessionManagerProxy::MoveSessionsToBackground(const std::vector<std::int32_t>& sessionIds,
1514 std::vector<int32_t>& result)
1515 {
1516 WLOGFI("run SceneSessionManagerProxy::MoveSessionsToBackground");
1517 MessageParcel data;
1518 MessageParcel reply;
1519 MessageOption option;
1520 if (!data.WriteInterfaceToken(GetDescriptor())) {
1521 WLOGFE("WriteInterfaceToken failed");
1522 return WSError::WS_ERROR_INVALID_PARAM;
1523 }
1524 if (!data.WriteInt32Vector(sessionIds)) {
1525 WLOGFE("Write sessionIds failed");
1526 return WSError::WS_ERROR_INVALID_PARAM;
1527 }
1528 if (!data.WriteInt32Vector(result)) {
1529 WLOGFE("Write result failed");
1530 return WSError::WS_ERROR_INVALID_PARAM;
1531 }
1532 sptr<IRemoteObject> remote = Remote();
1533 if (remote == nullptr) {
1534 WLOGFE("remote is null");
1535 return WSError::WS_ERROR_IPC_FAILED;
1536 }
1537 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_MOVE_MISSIONS_TO_BACKGROUND),
1538 data, reply, option) != ERR_NONE) {
1539 WLOGFE("SendRequest failed");
1540 return WSError::WS_ERROR_IPC_FAILED;
1541 }
1542 reply.ReadInt32Vector(&result);
1543 return static_cast<WSError>(reply.ReadInt32());
1544 }
1545
ClearSession(int32_t persistentId)1546 WSError SceneSessionManagerProxy::ClearSession(int32_t persistentId)
1547 {
1548 WLOGFI("run SceneSessionManagerProxy::ClearSession");
1549 MessageParcel data;
1550 MessageParcel reply;
1551 MessageOption option;
1552 if (!data.WriteInterfaceToken(GetDescriptor())) {
1553 WLOGFE("ClearSession WriteInterfaceToken failed");
1554 return WSError::WS_ERROR_INVALID_PARAM;
1555 }
1556
1557 if (!data.WriteInt32(persistentId)) {
1558 WLOGFE("Write persistentId failed");
1559 return WSError::WS_ERROR_INVALID_PARAM;
1560 }
1561
1562 sptr<IRemoteObject> remote = Remote();
1563 if (remote == nullptr) {
1564 WLOGFE("remote is null");
1565 return WSError::WS_ERROR_IPC_FAILED;
1566 }
1567 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_CLEAR_SESSION),
1568 data, reply, option) != ERR_NONE) {
1569 WLOGFE("SendRequest failed");
1570 return WSError::WS_ERROR_IPC_FAILED;
1571 }
1572 return static_cast<WSError>(reply.ReadInt32());
1573 }
1574
ClearAllSessions()1575 WSError SceneSessionManagerProxy::ClearAllSessions()
1576 {
1577 WLOGFI("run SceneSessionManagerProxy::ClearSession");
1578 MessageParcel data;
1579 MessageParcel reply;
1580 MessageOption option;
1581 if (!data.WriteInterfaceToken(GetDescriptor())) {
1582 WLOGFE("ClearAllSessions WriteInterfaceToken failed");
1583 return WSError::WS_ERROR_INVALID_PARAM;
1584 }
1585
1586 sptr<IRemoteObject> remote = Remote();
1587 if (remote == nullptr) {
1588 WLOGFE("remote is null");
1589 return WSError::WS_ERROR_IPC_FAILED;
1590 }
1591 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_CLEAR_ALL_SESSIONS),
1592 data, reply, option) != ERR_NONE) {
1593 WLOGFE("SendRequest failed");
1594 return WSError::WS_ERROR_IPC_FAILED;
1595 }
1596 return static_cast<WSError>(reply.ReadInt32());
1597 }
1598
RegisterIAbilityManagerCollaborator(int32_t type,const sptr<AAFwk::IAbilityManagerCollaborator> & impl)1599 WSError SceneSessionManagerProxy::RegisterIAbilityManagerCollaborator(int32_t type,
1600 const sptr<AAFwk::IAbilityManagerCollaborator>& impl)
1601 {
1602 WLOGFI("run SceneSessionManagerProxy::RegisterIAbilityManagerCollaborator");
1603 if (!impl) {
1604 WLOGFE("impl is nullptr");
1605 return WSError::WS_ERROR_INVALID_PARAM;
1606 }
1607 MessageParcel data;
1608 MessageParcel reply;
1609 MessageOption option;
1610
1611 if (!data.WriteInterfaceToken(GetDescriptor())) {
1612 WLOGFE("Write interface token failed.");
1613 return WSError::WS_ERROR_INVALID_PARAM;
1614 }
1615 if (!data.WriteInt32(type)) {
1616 WLOGFE("type write failed.");
1617 return WSError::WS_ERROR_INVALID_PARAM;
1618 }
1619 if (!data.WriteRemoteObject(impl->AsObject())) {
1620 WLOGFE("impl write failed.");
1621 return WSError::WS_ERROR_INVALID_PARAM;
1622 }
1623
1624 sptr<IRemoteObject> remote = Remote();
1625 if (remote == nullptr) {
1626 WLOGFE("remote is null");
1627 return WSError::WS_ERROR_IPC_FAILED;
1628 }
1629 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REGISTER_COLLABORATOR),
1630 data, reply, option) != ERR_NONE) {
1631 WLOGFE("SendRequest failed");
1632 return WSError::WS_ERROR_IPC_FAILED;
1633 }
1634 return static_cast<WSError>(reply.ReadInt32());
1635 }
1636
UnregisterIAbilityManagerCollaborator(int32_t type)1637 WSError SceneSessionManagerProxy::UnregisterIAbilityManagerCollaborator(int32_t type)
1638 {
1639 WLOGFI("run SceneSessionManagerProxy::UnregisterIAbilityManagerCollaborator");
1640 MessageParcel data;
1641 MessageParcel reply;
1642 MessageOption option;
1643
1644 if (!data.WriteInterfaceToken(GetDescriptor())) {
1645 WLOGFE("Write interface token failed.");
1646 return WSError::WS_ERROR_INVALID_PARAM;
1647 }
1648 if (!data.WriteInt32(type)) {
1649 WLOGFE("type write failed.");
1650 return WSError::WS_ERROR_INVALID_PARAM;
1651 }
1652
1653 sptr<IRemoteObject> remote = Remote();
1654 if (remote == nullptr) {
1655 WLOGFE("remote is null");
1656 return WSError::WS_ERROR_IPC_FAILED;
1657 }
1658 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UNREGISTER_COLLABORATOR),
1659 data, reply, option) != ERR_NONE) {
1660 WLOGFE("SendRequest failed");
1661 return WSError::WS_ERROR_IPC_FAILED;
1662 }
1663 return static_cast<WSError>(reply.ReadInt32());
1664 }
1665
NotifyWindowExtensionVisibilityChange(int32_t pid,int32_t uid,bool visible)1666 WSError SceneSessionManagerProxy::NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible)
1667 {
1668 WLOGFI("run SceneSessionManagerProxy::NotifyWindowExtensionVisibilityChange");
1669 MessageParcel data;
1670 MessageParcel reply;
1671 MessageOption option(MessageOption::TF_ASYNC);
1672
1673 if (!data.WriteInterfaceToken(GetDescriptor())) {
1674 WLOGFE("Write interface token failed.");
1675 return WSError::WS_ERROR_INVALID_PARAM;
1676 }
1677
1678 if (!data.WriteInt32(pid)) {
1679 WLOGFE("pid write failed.");
1680 return WSError::WS_ERROR_INVALID_PARAM;
1681 }
1682
1683 if (!data.WriteInt32(uid)) {
1684 WLOGFE("uid write failed.");
1685 return WSError::WS_ERROR_INVALID_PARAM;
1686 }
1687 if (!data.WriteBool(visible)) {
1688 WLOGFE("pid write failed.");
1689 return WSError::WS_ERROR_INVALID_PARAM;
1690 }
1691
1692 sptr<IRemoteObject> remote = Remote();
1693 if (remote == nullptr) {
1694 WLOGFE("remote is null");
1695 return WSError::WS_ERROR_IPC_FAILED;
1696 }
1697 if (remote->SendRequest(static_cast<uint32_t>(
1698 SceneSessionManagerMessage::TRANS_ID_NOTIFY_WINDOW_EXTENSION_VISIBILITY_CHANGE),
1699 data, reply, option) != ERR_NONE) {
1700 WLOGFE("SendRequest failed");
1701 return WSError::WS_ERROR_IPC_FAILED;
1702 }
1703 return static_cast<WSError>(reply.ReadInt32());
1704 }
1705
GetTopWindowId(uint32_t mainWinId,uint32_t & topWinId)1706 WMError SceneSessionManagerProxy::GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId)
1707 {
1708 WLOGFD("[GetTopWin] mainId: %{public}d", mainWinId);
1709 MessageParcel data;
1710 MessageParcel reply;
1711 MessageOption option;
1712 if (!data.WriteInterfaceToken(GetDescriptor())) {
1713 WLOGFE("Write interface token failed.");
1714 return WMError::WM_ERROR_IPC_FAILED;
1715 }
1716
1717 if (!data.WriteUint32(mainWinId)) {
1718 WLOGFE("Write mainWinId failed");
1719 return WMError::WM_ERROR_IPC_FAILED;
1720 }
1721
1722 sptr<IRemoteObject> remote = Remote();
1723 if (remote == nullptr) {
1724 WLOGFE("remote is null");
1725 return WMError::WM_ERROR_IPC_FAILED;
1726 }
1727 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_TOP_WINDOW_ID),
1728 data, reply, option) != ERR_NONE) {
1729 WLOGFE("SendRequest failed");
1730 return WMError::WM_ERROR_IPC_FAILED;
1731 }
1732
1733 topWinId = reply.ReadUint32();
1734 int32_t ret = reply.ReadInt32();
1735 return static_cast<WMError>(ret);
1736 }
1737
GetParentMainWindowId(int32_t windowId,int32_t & mainWindowId)1738 WMError SceneSessionManagerProxy::GetParentMainWindowId(int32_t windowId, int32_t& mainWindowId)
1739 {
1740 MessageParcel data;
1741 MessageParcel reply;
1742 MessageOption option(MessageOption::TF_SYNC);
1743 if (!data.WriteInterfaceToken(GetDescriptor())) {
1744 TLOGE(WmsLogTag::WMS_SUB, "WriteInterfaceToken failed");
1745 return WMError::WM_ERROR_IPC_FAILED;
1746 }
1747 if (!data.WriteInt32(windowId)) {
1748 TLOGE(WmsLogTag::WMS_SUB, "Write windowId failed");
1749 return WMError::WM_ERROR_IPC_FAILED;
1750 }
1751 sptr<IRemoteObject> remote = Remote();
1752 if (remote == nullptr) {
1753 TLOGE(WmsLogTag::WMS_SUB, "Remote is null");
1754 return WMError::WM_ERROR_IPC_FAILED;
1755 }
1756 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_PARENT_MAIN_WINDOW_ID),
1757 data, reply, option) != ERR_NONE) {
1758 TLOGE(WmsLogTag::WMS_SUB, "SendRequest failed");
1759 return WMError::WM_ERROR_IPC_FAILED;
1760 }
1761 int32_t replyMainWindowId = INVALID_SESSION_ID;
1762 if (!reply.ReadInt32(replyMainWindowId)) {
1763 return WMError::WM_ERROR_IPC_FAILED;
1764 }
1765 int32_t ret = 0;
1766 if (!reply.ReadInt32(ret)) {
1767 return WMError::WM_ERROR_IPC_FAILED;
1768 }
1769 mainWindowId = replyMainWindowId;
1770 return static_cast<WMError>(ret);
1771 }
1772
GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>> & infos)1773 WMError SceneSessionManagerProxy::GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos)
1774 {
1775 MessageParcel data;
1776 MessageParcel reply;
1777 MessageOption option;
1778 if (!data.WriteInterfaceToken(GetDescriptor())) {
1779 WLOGFE("GetVisibilityWindowInfo Write interfaceToken failed");
1780 return WMError::WM_ERROR_IPC_FAILED;
1781 }
1782 sptr<IRemoteObject> remote = Remote();
1783 if (remote == nullptr) {
1784 WLOGFE("remote is null");
1785 return WMError::WM_ERROR_IPC_FAILED;
1786 }
1787 if (remote->SendRequest(static_cast<uint32_t>(
1788 SceneSessionManagerMessage::TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID), data, reply, option) != ERR_NONE) {
1789 return WMError::WM_ERROR_IPC_FAILED;
1790 }
1791 if (!MarshallingHelper::UnmarshallingVectorParcelableObj<WindowVisibilityInfo>(reply, infos)) {
1792 WLOGFE("read visibility window infos failed");
1793 return WMError::WM_ERROR_IPC_FAILED;
1794 }
1795 return static_cast<WMError>(reply.ReadInt32());
1796 }
1797
ShiftAppWindowFocus(int32_t sourcePersistentId,int32_t targetPersistentId)1798 WSError SceneSessionManagerProxy::ShiftAppWindowFocus(int32_t sourcePersistentId, int32_t targetPersistentId)
1799 {
1800 WLOGFD("run SceneSessionManagerProxy::ShiftAppWindowFocus");
1801 MessageParcel data;
1802 MessageParcel reply;
1803 MessageOption option(MessageOption::TF_SYNC);
1804 if (!data.WriteInterfaceToken(GetDescriptor())) {
1805 WLOGFE("Write interface token failed.");
1806 return WSError::WS_ERROR_INVALID_PARAM;
1807 }
1808
1809 if (!data.WriteUint32(sourcePersistentId)) {
1810 WLOGFE("Write sourcePersistentId failed");
1811 return WSError::WS_ERROR_INVALID_PARAM;
1812 }
1813
1814 if (!data.WriteUint32(targetPersistentId)) {
1815 WLOGFE("Write targetPersistentId failed");
1816 return WSError::WS_ERROR_INVALID_PARAM;
1817 }
1818
1819 sptr<IRemoteObject> remote = Remote();
1820 if (remote == nullptr) {
1821 WLOGFE("remote is null");
1822 return WSError::WS_ERROR_IPC_FAILED;
1823 }
1824 if (remote->SendRequest(static_cast<uint32_t>(
1825 SceneSessionManagerMessage::TRANS_ID_SHIFT_APP_WINDOW_FOCUS),
1826 data, reply, option) != ERR_NONE) {
1827 WLOGFE("SendRequest failed");
1828 return WSError::WS_ERROR_IPC_FAILED;
1829 }
1830 return static_cast<WSError>(reply.ReadInt32());
1831 }
1832
UpdateModalExtensionRect(const sptr<IRemoteObject> & token,Rect rect)1833 void SceneSessionManagerProxy::UpdateModalExtensionRect(const sptr<IRemoteObject>& token, Rect rect)
1834 {
1835 MessageOption option(MessageOption::TF_SYNC);
1836 MessageParcel data;
1837 MessageParcel reply;
1838 if (!data.WriteInterfaceToken(GetDescriptor())) {
1839 TLOGE(WmsLogTag::WMS_UIEXT, "Write interface token failed.");
1840 return;
1841 }
1842 if (!data.WriteRemoteObject(token)) {
1843 TLOGE(WmsLogTag::WMS_UIEXT, "Write token failed");
1844 return;
1845 }
1846 if (!data.WriteInt32(rect.posX_)) {
1847 TLOGE(WmsLogTag::WMS_UIEXT, "Write posX_ failed");
1848 return;
1849 }
1850 if (!data.WriteInt32(rect.posY_)) {
1851 TLOGE(WmsLogTag::WMS_UIEXT, "Write posY_ failed");
1852 return;
1853 }
1854 if (!data.WriteInt32(rect.width_)) {
1855 TLOGE(WmsLogTag::WMS_UIEXT, "Write width_ failed");
1856 return;
1857 }
1858 if (!data.WriteInt32(rect.height_)) {
1859 TLOGE(WmsLogTag::WMS_UIEXT, "Write height_ failed");
1860 return;
1861 }
1862 sptr<IRemoteObject> remote = Remote();
1863 if (remote == nullptr) {
1864 TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
1865 return;
1866 }
1867 if (remote->SendRequest(static_cast<uint32_t>(
1868 SceneSessionManagerMessage::TRANS_ID_UPDATE_MODALEXTENSION_RECT_TO_SCB),
1869 data, reply, option) != ERR_NONE) {
1870 TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed");
1871 }
1872 }
1873
ProcessModalExtensionPointDown(const sptr<IRemoteObject> & token,int32_t posX,int32_t posY)1874 void SceneSessionManagerProxy::ProcessModalExtensionPointDown(const sptr<IRemoteObject>& token, int32_t posX,
1875 int32_t posY)
1876 {
1877 MessageOption option(MessageOption::TF_SYNC);
1878 MessageParcel data;
1879 MessageParcel reply;
1880 if (!data.WriteInterfaceToken(GetDescriptor())) {
1881 TLOGE(WmsLogTag::WMS_UIEXT, "Write interface token failed.");
1882 return;
1883 }
1884 if (!data.WriteRemoteObject(token)) {
1885 TLOGE(WmsLogTag::WMS_UIEXT, "Write token failed");
1886 return;
1887 }
1888 if (!data.WriteInt32(posX)) {
1889 TLOGE(WmsLogTag::WMS_UIEXT, "Write posX failed");
1890 return;
1891 }
1892 if (!data.WriteInt32(posY)) {
1893 TLOGE(WmsLogTag::WMS_UIEXT, "Write posY failed");
1894 return;
1895 }
1896 sptr<IRemoteObject> remote = Remote();
1897 if (remote == nullptr) {
1898 TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
1899 return;
1900 }
1901 if (remote->SendRequest(static_cast<uint32_t>(
1902 SceneSessionManagerMessage::TRANS_ID_PROCESS_MODALEXTENSION_POINTDOWN_TO_SCB),
1903 data, reply, option) != ERR_NONE) {
1904 TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed");
1905 }
1906 }
1907
AddExtensionWindowStageToSCB(const sptr<ISessionStage> & sessionStage,const sptr<IRemoteObject> & token,uint64_t surfaceNodeId)1908 void SceneSessionManagerProxy::AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage,
1909 const sptr<IRemoteObject>& token, uint64_t surfaceNodeId)
1910 {
1911 if (sessionStage == nullptr || token == nullptr) {
1912 TLOGE(WmsLogTag::WMS_UIEXT, "input is nullptr");
1913 return;
1914 }
1915 MessageOption option(MessageOption::TF_SYNC);
1916 MessageParcel data;
1917 MessageParcel reply;
1918 if (!data.WriteInterfaceToken(GetDescriptor())) {
1919 TLOGE(WmsLogTag::WMS_UIEXT, "Write InterfaceToken failed!");
1920 return;
1921 }
1922 if (!data.WriteRemoteObject(sessionStage->AsObject())) {
1923 TLOGE(WmsLogTag::WMS_UIEXT, "Write ISessionStage failed!");
1924 return;
1925 }
1926 if (!data.WriteRemoteObject(token)) {
1927 TLOGE(WmsLogTag::WMS_UIEXT, "Write token failed");
1928 return;
1929 }
1930 if (!data.WriteUint64(static_cast<uint64_t>(surfaceNodeId))) {
1931 TLOGE(WmsLogTag::WMS_UIEXT, "Write surfaceNodeId failed");
1932 return;
1933 }
1934 sptr<IRemoteObject> remote = Remote();
1935 if (remote == nullptr) {
1936 TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
1937 return;
1938 }
1939 if (remote->SendRequest(static_cast<uint32_t>(
1940 SceneSessionManagerMessage::TRANS_ID_ADD_EXTENSION_WINDOW_STAGE_TO_SCB),
1941 data, reply, option) != ERR_NONE) {
1942 TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed");
1943 }
1944 }
1945
RemoveExtensionWindowStageFromSCB(const sptr<ISessionStage> & sessionStage,const sptr<IRemoteObject> & token)1946 void SceneSessionManagerProxy::RemoveExtensionWindowStageFromSCB(const sptr<ISessionStage>& sessionStage,
1947 const sptr<IRemoteObject>& token)
1948 {
1949 if (sessionStage == nullptr || token == nullptr) {
1950 TLOGE(WmsLogTag::WMS_UIEXT, "input is nullptr");
1951 return;
1952 }
1953 MessageOption option(MessageOption::TF_SYNC);
1954 MessageParcel data;
1955 MessageParcel reply;
1956 if (!data.WriteInterfaceToken(GetDescriptor())) {
1957 TLOGE(WmsLogTag::WMS_UIEXT, "Write InterfaceToken failed!");
1958 return;
1959 }
1960 if (!data.WriteRemoteObject(sessionStage->AsObject())) {
1961 TLOGE(WmsLogTag::WMS_UIEXT, "Write ISessionStage failed!");
1962 return;
1963 }
1964 if (!data.WriteRemoteObject(token)) {
1965 TLOGE(WmsLogTag::WMS_UIEXT, "Write token failed");
1966 return;
1967 }
1968 sptr<IRemoteObject> remote = Remote();
1969 if (remote == nullptr) {
1970 TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
1971 return;
1972 }
1973 if (remote->SendRequest(static_cast<uint32_t>(
1974 SceneSessionManagerMessage::TRANS_ID_REMOVE_EXTENSION_WINDOW_STAGE_FROM_SCB),
1975 data, reply, option) != ERR_NONE) {
1976 TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed");
1977 }
1978 }
1979
AddOrRemoveSecureSession(int32_t persistentId,bool shouldHide)1980 WSError SceneSessionManagerProxy::AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide)
1981 {
1982 MessageParcel data;
1983 MessageParcel reply;
1984 MessageOption option(MessageOption::TF_SYNC);
1985 if (!data.WriteInterfaceToken(GetDescriptor())) {
1986 TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
1987 return WSError::WS_ERROR_IPC_FAILED;
1988 }
1989 if (!data.WriteInt32(persistentId)) {
1990 TLOGE(WmsLogTag::WMS_UIEXT, "Write persistentId failed");
1991 return WSError::WS_ERROR_IPC_FAILED;
1992 }
1993 if (!data.WriteBool(shouldHide)) {
1994 TLOGE(WmsLogTag::WMS_UIEXT, "Write shouldHide failed");
1995 return WSError::WS_ERROR_IPC_FAILED;
1996 }
1997 sptr<IRemoteObject> remote = Remote();
1998 if (remote == nullptr) {
1999 TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
2000 return WSError::WS_ERROR_IPC_FAILED;
2001 }
2002 if (remote->SendRequest(static_cast<uint32_t>(
2003 SceneSessionManagerMessage::TRANS_ID_ADD_OR_REMOVE_SECURE_SESSION),
2004 data, reply, option) != ERR_NONE) {
2005 TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed");
2006 return WSError::WS_ERROR_IPC_FAILED;
2007 }
2008 return static_cast<WSError>(reply.ReadInt32());
2009 }
2010
UpdateExtWindowFlags(const sptr<IRemoteObject> & token,uint32_t extWindowFlags,uint32_t extWindowActions)2011 WSError SceneSessionManagerProxy::UpdateExtWindowFlags(const sptr<IRemoteObject>& token, uint32_t extWindowFlags,
2012 uint32_t extWindowActions)
2013 {
2014 TLOGD(WmsLogTag::WMS_UIEXT, "run SceneSessionManagerProxy::UpdateExtWindowFlags");
2015 MessageParcel data;
2016 MessageParcel reply;
2017 MessageOption option(MessageOption::TF_SYNC);
2018 if (!data.WriteInterfaceToken(GetDescriptor())) {
2019 TLOGE(WmsLogTag::WMS_UIEXT, "Write interface token failed.");
2020 return WSError::WS_ERROR_IPC_FAILED;
2021 }
2022 if (!data.WriteRemoteObject(token)) {
2023 TLOGE(WmsLogTag::WMS_UIEXT, "Write token failed");
2024 return WSError::WS_ERROR_IPC_FAILED;
2025 }
2026 if (!data.WriteUint32(extWindowFlags)) {
2027 TLOGE(WmsLogTag::WMS_UIEXT, "Write extWindowFlags failed");
2028 return WSError::WS_ERROR_IPC_FAILED;
2029 }
2030 if (!data.WriteUint32(extWindowActions)) {
2031 TLOGE(WmsLogTag::WMS_UIEXT, "Write extWindowActions failed");
2032 return WSError::WS_ERROR_IPC_FAILED;
2033 }
2034 sptr<IRemoteObject> remote = Remote();
2035 if (remote == nullptr) {
2036 TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
2037 return WSError::WS_ERROR_IPC_FAILED;
2038 }
2039 if (remote->SendRequest(
2040 static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UPDATE_EXTENSION_WINDOW_FLAGS),
2041 data, reply, option) != ERR_NONE) {
2042 TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest AddExtensionSessionInfo failed");
2043 return WSError::WS_ERROR_IPC_FAILED;
2044 }
2045 return static_cast<WSError>(reply.ReadInt32());
2046 }
2047
GetHostWindowRect(int32_t hostWindowId,Rect & rect)2048 WSError SceneSessionManagerProxy::GetHostWindowRect(int32_t hostWindowId, Rect& rect)
2049 {
2050 TLOGD(WmsLogTag::WMS_UIEXT, "run SceneSessionManagerProxy::GetHostWindowRect");
2051 MessageParcel data;
2052 MessageParcel reply;
2053 MessageOption option;
2054 if (!data.WriteInterfaceToken(GetDescriptor())) {
2055 TLOGE(WmsLogTag::WMS_UIEXT, "Write interface token failed.");
2056 return WSError::WS_ERROR_IPC_FAILED;
2057 }
2058 if (!data.WriteInt32(hostWindowId)) {
2059 TLOGE(WmsLogTag::WMS_UIEXT, "Write hostWindowId failed");
2060 return WSError::WS_ERROR_IPC_FAILED;
2061 }
2062 sptr<IRemoteObject> remote = Remote();
2063 if (remote == nullptr) {
2064 TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
2065 return WSError::WS_ERROR_IPC_FAILED;
2066 }
2067 if (remote->SendRequest(
2068 static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_HOST_WINDOW_RECT),
2069 data, reply, option) != ERR_NONE) {
2070 TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest GetHostWindowRect failed");
2071 return WSError::WS_ERROR_IPC_FAILED;
2072 }
2073 auto posX = reply.ReadInt32();
2074 auto posY = reply.ReadInt32();
2075 auto width = reply.ReadUint32();
2076 auto height = reply.ReadUint32();
2077 rect = {posX, posY, width, height};
2078 return static_cast<WSError>(reply.ReadInt32());
2079 }
2080
GetFreeMultiWindowEnableState(bool & enable)2081 WSError SceneSessionManagerProxy::GetFreeMultiWindowEnableState(bool& enable)
2082 {
2083 TLOGD(WmsLogTag::WMS_MULTI_WINDOW, "run SceneSessionManagerProxy::GetFreeMultiWindowEnableState");
2084 MessageParcel data;
2085 MessageParcel reply;
2086 MessageOption option;
2087 if (!data.WriteInterfaceToken(GetDescriptor())) {
2088 TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "Write interface token failed.");
2089 return WSError::WS_ERROR_IPC_FAILED;
2090 }
2091 sptr<IRemoteObject> remote = Remote();
2092 if (remote == nullptr) {
2093 TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "remote is nullptr");
2094 return WSError::WS_ERROR_NULLPTR;
2095 }
2096 if (remote->SendRequest(
2097 static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_FREE_MULTI_WINDOW_ENABLE_STATE),
2098 data, reply, option) != ERR_NONE) {
2099 TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "SendRequest GetFreeMultiWindowEnableState failed");
2100 return WSError::WS_ERROR_IPC_FAILED;
2101 }
2102 auto isEnable = reply.ReadBool();
2103 enable = isEnable;
2104 return static_cast<WSError>(reply.ReadInt32());
2105 }
2106
GetCallingWindowWindowStatus(int32_t persistentId,WindowStatus & windowStatus)2107 WMError SceneSessionManagerProxy::GetCallingWindowWindowStatus(int32_t persistentId, WindowStatus& windowStatus)
2108 {
2109 MessageParcel data;
2110 MessageParcel reply;
2111 MessageOption option;
2112
2113 if (!data.WriteInterfaceToken(GetDescriptor())) {
2114 TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed");
2115 return WMError::WM_ERROR_IPC_FAILED;
2116 }
2117 if (!data.WriteInt32(persistentId)) {
2118 TLOGE(WmsLogTag::WMS_KEYBOARD, "Write windowId failed");
2119 return WMError::WM_ERROR_IPC_FAILED;
2120 }
2121 sptr<IRemoteObject> remote = Remote();
2122 if (remote == nullptr) {
2123 TLOGE(WmsLogTag::WMS_KEYBOARD, "remote is null");
2124 return WMError::WM_ERROR_IPC_FAILED;
2125 }
2126 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_STATUS),
2127 data, reply, option) != ERR_NONE) {
2128 TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
2129 return WMError::WM_ERROR_IPC_FAILED;
2130 }
2131 auto ret = static_cast<WMError>(reply.ReadInt32());
2132 if (ret == WMError::WM_OK) {
2133 windowStatus = static_cast<WindowStatus>(reply.ReadUint32());
2134 }
2135 return ret;
2136 }
2137
GetCallingWindowRect(int32_t persistentId,Rect & rect)2138 WMError SceneSessionManagerProxy::GetCallingWindowRect(int32_t persistentId, Rect& rect)
2139 {
2140 MessageParcel data;
2141 MessageParcel reply;
2142 MessageOption option;
2143 if (!data.WriteInterfaceToken(GetDescriptor())) {
2144 TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed");
2145 return WMError::WM_ERROR_IPC_FAILED;
2146 }
2147 if (!data.WriteInt32(persistentId)) {
2148 TLOGE(WmsLogTag::WMS_KEYBOARD, "Write windowId failed");
2149 return WMError::WM_ERROR_IPC_FAILED;
2150 }
2151 sptr<IRemoteObject> remote = Remote();
2152 if (remote == nullptr) {
2153 TLOGE(WmsLogTag::WMS_KEYBOARD, "remote is null");
2154 return WMError::WM_ERROR_IPC_FAILED;
2155 }
2156 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_RECT),
2157 data, reply, option) != ERR_NONE) {
2158 TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
2159 return WMError::WM_ERROR_IPC_FAILED;
2160 }
2161 auto ret = static_cast<WMError>(reply.ReadInt32());
2162 if (ret == WMError::WM_OK) {
2163 rect.posX_ = reply.ReadInt32();
2164 rect.posY_ = reply.ReadInt32();
2165 rect.width_ = reply.ReadUint32();
2166 rect.height_ = reply.ReadUint32();
2167 }
2168 return ret;
2169 }
2170
GetWindowModeType(WindowModeType & windowModeType)2171 WMError SceneSessionManagerProxy::GetWindowModeType(WindowModeType& windowModeType)
2172 {
2173 MessageParcel data;
2174 MessageParcel reply;
2175 MessageOption option;
2176 if (!data.WriteInterfaceToken(GetDescriptor())) {
2177 WLOGFE("GetWindowModeType Write interfaceToken failed");
2178 return WMError::WM_ERROR_IPC_FAILED;
2179 }
2180 sptr<IRemoteObject> remote = Remote();
2181 if (remote == nullptr) {
2182 WLOGFE("remote is null");
2183 return WMError::WM_ERROR_IPC_FAILED;
2184 }
2185 if (remote->SendRequest(static_cast<uint32_t>(
2186 SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_MODE_TYPE), data, reply, option) != ERR_NONE) {
2187 return WMError::WM_ERROR_IPC_FAILED;
2188 }
2189 windowModeType = static_cast<WindowModeType>(reply.ReadUint32());
2190 return static_cast<WMError>(reply.ReadInt32());
2191 }
2192
MinimizeAllAppWindows(DisplayId displayId)2193 WMError SceneSessionManagerProxy::MinimizeAllAppWindows(DisplayId displayId)
2194 {
2195 if (!Permission::IsSystemCallingOrStartByHdcd(true)) {
2196 TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right, displayId %{public}" PRIu64, displayId);
2197 return WMError::WM_ERROR_NOT_SYSTEM_APP;
2198 }
2199 TLOGE(WmsLogTag::WMS_LIFE, "Not support minimize, displayId %{public}" PRIu64, displayId);
2200 return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
2201 }
2202
ToggleShownStateForAllAppWindows()2203 WMError SceneSessionManagerProxy::ToggleShownStateForAllAppWindows()
2204 {
2205 if (!Permission::IsSystemCallingOrStartByHdcd(true)) {
2206 TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right");
2207 return WMError::WM_ERROR_NOT_SYSTEM_APP;
2208 }
2209 TLOGE(WmsLogTag::WMS_LIFE, "Not support call toggleShownState");
2210 return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
2211 }
2212
GetWindowStyleType(WindowStyleType & windowStyleType)2213 WMError SceneSessionManagerProxy::GetWindowStyleType(WindowStyleType& windowStyleType)
2214 {
2215 MessageParcel data;
2216 MessageParcel reply;
2217 MessageOption option;
2218 if (!data.WriteInterfaceToken(GetDescriptor())) {
2219 TLOGE(WmsLogTag::WMS_LIFE, "GetwindowStyleType Write interfaceToken failed");
2220 return WMError::WM_ERROR_IPC_FAILED;
2221 }
2222 if (Remote()->SendRequest(static_cast<uint32_t>(
2223 SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_STYLE_TYPE), data, reply, option) != ERR_NONE) {
2224 return WMError::WM_ERROR_IPC_FAILED;
2225 }
2226 windowStyleType = static_cast<WindowStyleType>(reply.ReadUint32());
2227 return static_cast<WMError>(reply.ReadInt32());
2228 }
2229
GetProcessSurfaceNodeIdByPersistentId(const int32_t pid,const std::vector<int32_t> & persistentIds,std::vector<uint64_t> & surfaceNodeIds)2230 WMError SceneSessionManagerProxy::GetProcessSurfaceNodeIdByPersistentId(const int32_t pid,
2231 const std::vector<int32_t>& persistentIds, std::vector<uint64_t>& surfaceNodeIds)
2232 {
2233 MessageParcel data;
2234 MessageParcel reply;
2235 MessageOption option;
2236 if (!data.WriteInterfaceToken(GetDescriptor())) {
2237 TLOGE(WmsLogTag::DEFAULT, "Write interfaceToken failed");
2238 return WMError::WM_ERROR_IPC_FAILED;
2239 }
2240 if (!data.WriteInt32(pid)) {
2241 TLOGE(WmsLogTag::DEFAULT, "Write pid failed");
2242 return WMError::WM_ERROR_IPC_FAILED;
2243 }
2244 if (!data.WriteInt32Vector(persistentIds)) {
2245 TLOGE(WmsLogTag::DEFAULT, "Write persistentIds failed");
2246 return WMError::WM_ERROR_IPC_FAILED;
2247 }
2248 sptr<IRemoteObject> remote = Remote();
2249 if (remote == nullptr) {
2250 TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
2251 return WMError::WM_ERROR_IPC_FAILED;
2252 }
2253 if (remote->SendRequest(static_cast<uint32_t>(
2254 SceneSessionManagerMessage::TRANS_ID_GET_PROCESS_SURFACENODEID_BY_PERSISTENTID),
2255 data, reply, option) != ERR_NONE) {
2256 TLOGE(WmsLogTag::DEFAULT, "SendRequest failed");
2257 return WMError::WM_ERROR_IPC_FAILED;
2258 }
2259 reply.ReadUInt64Vector(&surfaceNodeIds);
2260 return static_cast<WMError>(reply.ReadInt32());
2261 }
2262
GetWindowIdsByCoordinate(DisplayId displayId,int32_t windowNumber,int32_t x,int32_t y,std::vector<int32_t> & windowIds)2263 WMError SceneSessionManagerProxy::GetWindowIdsByCoordinate(DisplayId displayId, int32_t windowNumber,
2264 int32_t x, int32_t y, std::vector<int32_t>& windowIds)
2265 {
2266 MessageParcel data;
2267 MessageParcel reply;
2268 MessageOption option;
2269 if (!data.WriteInterfaceToken(GetDescriptor())) {
2270 TLOGE(WmsLogTag::DEFAULT, "Write interfaceToken failed");
2271 return WMError::WM_ERROR_IPC_FAILED;
2272 }
2273 if (!data.WriteUint64(displayId)) {
2274 TLOGE(WmsLogTag::DEFAULT, "Write displayId failed");
2275 return WMError::WM_ERROR_IPC_FAILED;
2276 }
2277 if (!data.WriteInt32(windowNumber)) {
2278 TLOGE(WmsLogTag::DEFAULT, "Write windowNumber failed");
2279 return WMError::WM_ERROR_IPC_FAILED;
2280 }
2281 if (!data.WriteInt32(x)) {
2282 TLOGE(WmsLogTag::DEFAULT, "Write x failed");
2283 return WMError::WM_ERROR_IPC_FAILED;
2284 }
2285 if (!data.WriteInt32(y)) {
2286 TLOGE(WmsLogTag::DEFAULT, "Write y failed");
2287 return WMError::WM_ERROR_IPC_FAILED;
2288 }
2289 sptr<IRemoteObject> remote = Remote();
2290 if (remote == nullptr) {
2291 TLOGE(WmsLogTag::DEFAULT, "remote is null");
2292 return WMError::WM_ERROR_IPC_FAILED;
2293 }
2294 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_IDS_BY_COORDINATE),
2295 data, reply, option) != ERR_NONE) {
2296 TLOGE(WmsLogTag::DEFAULT, "SendRequest failed");
2297 return WMError::WM_ERROR_IPC_FAILED;
2298 }
2299 auto ret = static_cast<WMError>(reply.ReadInt32());
2300 if (ret == WMError::WM_OK) {
2301 reply.ReadInt32Vector(&windowIds);
2302 }
2303 return ret;
2304 }
2305
ReleaseForegroundSessionScreenLock()2306 WMError SceneSessionManagerProxy::ReleaseForegroundSessionScreenLock()
2307 {
2308 MessageParcel data;
2309 MessageParcel reply;
2310 MessageOption option;
2311 if (!data.WriteInterfaceToken(GetDescriptor())) {
2312 TLOGE(WmsLogTag::DEFAULT, "WriteInterfaceToken failed");
2313 return WMError::WM_ERROR_IPC_FAILED;
2314 }
2315 if (Remote()->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_RELEASE_SESSION_SCREEN_LOCK),
2316 data, reply, option) != ERR_NONE) {
2317 TLOGE(WmsLogTag::DEFAULT, "SendRequest failed");
2318 return WMError::WM_ERROR_IPC_FAILED;
2319 }
2320 return static_cast<WMError>(reply.ReadInt32());
2321 }
2322
GetDisplayIdByWindowId(const std::vector<uint64_t> & windowIds,std::unordered_map<uint64_t,DisplayId> & windowDisplayIdMap)2323 WMError SceneSessionManagerProxy::GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds,
2324 std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap)
2325 {
2326 MessageParcel data;
2327 MessageParcel reply;
2328 MessageOption option;
2329 if (!data.WriteInterfaceToken(GetDescriptor())) {
2330 TLOGE(WmsLogTag::DEFAULT, "WriteInterfaceToken failed");
2331 return WMError::WM_ERROR_IPC_FAILED;
2332 }
2333 if (!data.WriteUInt64Vector(windowIds)) {
2334 TLOGE(WmsLogTag::DEFAULT, "Write windowIds failed");
2335 return WMError::WM_ERROR_IPC_FAILED;
2336 }
2337 if (Remote()->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_DISPLAYID_BY_WINDOWID),
2338 data, reply, option) != ERR_NONE) {
2339 TLOGE(WmsLogTag::DEFAULT, "SendRequest failed");
2340 return WMError::WM_ERROR_IPC_FAILED;
2341 }
2342 int32_t mapSize;
2343 if (!reply.ReadInt32(mapSize)) {
2344 TLOGE(WmsLogTag::DEFAULT, "Fail to read mapSize");
2345 return WMError::WM_ERROR_IPC_FAILED;
2346 }
2347 for (int32_t i = 0; i < mapSize; i++) {
2348 uint64_t windowId;
2349 if (!reply.ReadUint64(windowId)) {
2350 TLOGE(WmsLogTag::DEFAULT, "Fail to read windowId");
2351 return WMError::WM_ERROR_IPC_FAILED;
2352 }
2353 uint64_t displayId;
2354 if (!reply.ReadUint64(displayId)) {
2355 TLOGE(WmsLogTag::DEFAULT, "Fail to read displayId");
2356 return WMError::WM_ERROR_IPC_FAILED;
2357 }
2358 windowDisplayIdMap[windowId] = displayId;
2359 }
2360 return static_cast<WMError>(reply.ReadInt32());
2361 }
2362
IsPcOrPadFreeMultiWindowMode(bool & isPcOrPadFreeMultiWindowMode)2363 WMError SceneSessionManagerProxy::IsPcOrPadFreeMultiWindowMode(bool& isPcOrPadFreeMultiWindowMode)
2364 {
2365 MessageParcel data;
2366 MessageParcel reply;
2367 MessageOption option;
2368 if (!data.WriteInterfaceToken(GetDescriptor())) {
2369 TLOGE(WmsLogTag::WMS_SUB, "Write interfaceToken failed");
2370 return WMError::WM_ERROR_IPC_FAILED;
2371 }
2372 sptr<IRemoteObject> remote = Remote();
2373 if (remote == nullptr) {
2374 TLOGE(WmsLogTag::WMS_SUB, "Remote is null");
2375 return WMError::WM_ERROR_IPC_FAILED;
2376 }
2377 if (remote->SendRequest(static_cast<uint32_t>(
2378 SceneSessionManagerMessage::TRANS_ID_IS_PC_OR_PAD_FREE_MULTI_WINDOW_MODE),
2379 data, reply, option) != ERR_NONE) {
2380 TLOGE(WmsLogTag::WMS_SUB, "SendRequest failed");
2381 return WMError::WM_ERROR_IPC_FAILED;
2382 }
2383 bool repliedValue = false;
2384 if (!reply.ReadBool(repliedValue)) {
2385 TLOGE(WmsLogTag::WMS_SUB, "Read isPcOrPadFreeMultiWindowMode failed");
2386 return WMError::WM_ERROR_IPC_FAILED;
2387 }
2388 int32_t ret = 0;
2389 if (!reply.ReadInt32(ret)) {
2390 TLOGE(WmsLogTag::WMS_SUB, "Read ret failed");
2391 return WMError::WM_ERROR_IPC_FAILED;
2392 }
2393 isPcOrPadFreeMultiWindowMode = repliedValue;
2394 return static_cast<WMError>(ret);
2395 }
2396
IsPcWindow(bool & isPcWindow)2397 WMError SceneSessionManagerProxy::IsPcWindow(bool& isPcWindow)
2398 {
2399 MessageParcel data;
2400 MessageParcel reply;
2401 MessageOption option;
2402 if (!data.WriteInterfaceToken(GetDescriptor())) {
2403 TLOGE(WmsLogTag::WMS_UIEXT, "Write interfaceToken failed");
2404 return WMError::WM_ERROR_IPC_FAILED;
2405 }
2406 sptr<IRemoteObject> remote = Remote();
2407 if (remote == nullptr) {
2408 TLOGE(WmsLogTag::WMS_UIEXT, "Remote is null");
2409 return WMError::WM_ERROR_IPC_FAILED;
2410 }
2411 if (remote->SendRequest(static_cast<uint32_t>(
2412 SceneSessionManagerMessage::TRANS_ID_IS_PC_WINDOW),
2413 data, reply, option) != ERR_NONE) {
2414 TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed");
2415 return WMError::WM_ERROR_IPC_FAILED;
2416 }
2417 bool result = false;
2418 if (!reply.ReadBool(result)) {
2419 TLOGE(WmsLogTag::WMS_UIEXT, "Read isPcWindow failed");
2420 return WMError::WM_ERROR_IPC_FAILED;
2421 }
2422 int32_t ret = 0;
2423 if (!reply.ReadInt32(ret)) {
2424 TLOGE(WmsLogTag::WMS_UIEXT, "Read ret failed");
2425 return WMError::WM_ERROR_IPC_FAILED;
2426 }
2427 isPcWindow = result;
2428 return static_cast<WMError>(ret);
2429 }
2430
IsWindowRectAutoSave(const std::string & key,bool & enabled)2431 WMError SceneSessionManagerProxy::IsWindowRectAutoSave(const std::string& key, bool& enabled)
2432 {
2433 MessageParcel data;
2434 MessageParcel reply;
2435 MessageOption option;
2436 if (!data.WriteInterfaceToken(GetDescriptor())) {
2437 TLOGE(WmsLogTag::WMS_MAIN, "Write interfaceToken failed");
2438 return WMError::WM_ERROR_IPC_FAILED;
2439 }
2440 if (!data.WriteString(key)) {
2441 TLOGE(WmsLogTag::WMS_MAIN, "Write key failed");
2442 return WMError::WM_ERROR_IPC_FAILED;
2443 }
2444 sptr<IRemoteObject> remote = Remote();
2445 if (remote == nullptr) {
2446 TLOGE(WmsLogTag::WMS_MAIN, "remote is null");
2447 return WMError::WM_ERROR_IPC_FAILED;
2448 }
2449 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_IS_WINDOW_RECT_AUTO_SAVE),
2450 data, reply, option) != ERR_NONE) {
2451 TLOGE(WmsLogTag::WMS_MAIN, "SendRequest failed");
2452 return WMError::WM_ERROR_IPC_FAILED;
2453 }
2454 if (!reply.ReadBool(enabled)) {
2455 TLOGE(WmsLogTag::WMS_MAIN, "Read enable failed");
2456 return WMError::WM_ERROR_IPC_FAILED;
2457 }
2458 uint32_t ret = 0;
2459 if (!reply.ReadUint32(ret)) {
2460 TLOGE(WmsLogTag::WMS_MAIN, "Read ret failed");
2461 return WMError::WM_ERROR_IPC_FAILED;
2462 }
2463 return static_cast<WMError>(ret);
2464 }
2465
SetGlobalDragResizeType(DragResizeType dragResizeType)2466 WMError SceneSessionManagerProxy::SetGlobalDragResizeType(DragResizeType dragResizeType)
2467 {
2468 MessageParcel data;
2469 MessageParcel reply;
2470 MessageOption option;
2471 if (!data.WriteInterfaceToken(GetDescriptor())) {
2472 TLOGE(WmsLogTag::WMS_LAYOUT, "Write interfaceToken failed");
2473 return WMError::WM_ERROR_IPC_FAILED;
2474 }
2475 if (!data.WriteUint32(static_cast<uint32_t>(dragResizeType))) {
2476 TLOGE(WmsLogTag::WMS_LAYOUT, "Write dragResizeType failed");
2477 return WMError::WM_ERROR_IPC_FAILED;
2478 }
2479 sptr<IRemoteObject> remote = Remote();
2480 if (remote == nullptr) {
2481 TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
2482 return WMError::WM_ERROR_IPC_FAILED;
2483 }
2484 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_GLOBAL_DRAG_RESIZE_TYPE),
2485 data, reply, option) != ERR_NONE) {
2486 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
2487 return WMError::WM_ERROR_IPC_FAILED;
2488 }
2489 uint32_t ret = 0;
2490 if (!reply.ReadUint32(ret)) {
2491 TLOGE(WmsLogTag::WMS_LAYOUT, "Read ret failed");
2492 return WMError::WM_ERROR_IPC_FAILED;
2493 }
2494 return static_cast<WMError>(ret);
2495 }
2496
GetGlobalDragResizeType(DragResizeType & dragResizeType)2497 WMError SceneSessionManagerProxy::GetGlobalDragResizeType(DragResizeType& dragResizeType)
2498 {
2499 MessageParcel data;
2500 MessageParcel reply;
2501 MessageOption option;
2502 if (!data.WriteInterfaceToken(GetDescriptor())) {
2503 TLOGE(WmsLogTag::WMS_LAYOUT, "Write interfaceToken failed");
2504 return WMError::WM_ERROR_IPC_FAILED;
2505 }
2506 sptr<IRemoteObject> remote = Remote();
2507 if (remote == nullptr) {
2508 TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
2509 return WMError::WM_ERROR_IPC_FAILED;
2510 }
2511 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_GLOBAL_DRAG_RESIZE_TYPE),
2512 data, reply, option) != ERR_NONE) {
2513 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
2514 return WMError::WM_ERROR_IPC_FAILED;
2515 }
2516 uint32_t obtainedDragResizeType = 0;
2517 if (!reply.ReadUint32(obtainedDragResizeType)) {
2518 TLOGE(WmsLogTag::WMS_LAYOUT, "Read dragResizeType failed");
2519 return WMError::WM_ERROR_IPC_FAILED;
2520 }
2521 if (obtainedDragResizeType > static_cast<uint32_t>(DragResizeType::RESIZE_WHEN_DRAG_END)) {
2522 TLOGE(WmsLogTag::WMS_LAYOUT, "bad dragResizeType value");
2523 return WMError::WM_ERROR_IPC_FAILED;
2524 }
2525 dragResizeType = static_cast<DragResizeType>(obtainedDragResizeType);
2526 uint32_t ret = 0;
2527 if (!reply.ReadUint32(ret)) {
2528 TLOGE(WmsLogTag::WMS_LAYOUT, "Read ret failed");
2529 return WMError::WM_ERROR_IPC_FAILED;
2530 }
2531 return static_cast<WMError>(ret);
2532 }
2533
SetAppDragResizeType(const std::string & bundleName,DragResizeType dragResizeType)2534 WMError SceneSessionManagerProxy::SetAppDragResizeType(const std::string& bundleName, DragResizeType dragResizeType)
2535 {
2536 MessageParcel data;
2537 MessageParcel reply;
2538 MessageOption option;
2539 if (!data.WriteInterfaceToken(GetDescriptor())) {
2540 TLOGE(WmsLogTag::WMS_LAYOUT, "Write interfaceToken failed");
2541 return WMError::WM_ERROR_IPC_FAILED;
2542 }
2543 if (!data.WriteString(bundleName)) {
2544 TLOGE(WmsLogTag::WMS_LAYOUT, "Write bundleName failed");
2545 return WMError::WM_ERROR_IPC_FAILED;
2546 }
2547 if (!data.WriteUint32(static_cast<uint32_t>(dragResizeType))) {
2548 TLOGE(WmsLogTag::WMS_LAYOUT, "Write dragResizeType failed");
2549 return WMError::WM_ERROR_IPC_FAILED;
2550 }
2551 sptr<IRemoteObject> remote = Remote();
2552 if (remote == nullptr) {
2553 TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
2554 return WMError::WM_ERROR_IPC_FAILED;
2555 }
2556 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_APP_DRAG_RESIZE_TYPE),
2557 data, reply, option) != ERR_NONE) {
2558 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
2559 return WMError::WM_ERROR_IPC_FAILED;
2560 }
2561 uint32_t ret = 0;
2562 if (!reply.ReadUint32(ret)) {
2563 TLOGE(WmsLogTag::WMS_LAYOUT, "Read ret failed");
2564 return WMError::WM_ERROR_IPC_FAILED;
2565 }
2566 return static_cast<WMError>(ret);
2567 }
2568
GetAppDragResizeType(const std::string & bundleName,DragResizeType & dragResizeType)2569 WMError SceneSessionManagerProxy::GetAppDragResizeType(const std::string& bundleName, DragResizeType& dragResizeType)
2570 {
2571 MessageParcel data;
2572 MessageParcel reply;
2573 MessageOption option;
2574 if (!data.WriteInterfaceToken(GetDescriptor())) {
2575 TLOGE(WmsLogTag::WMS_LAYOUT, "Write interfaceToken failed");
2576 return WMError::WM_ERROR_IPC_FAILED;
2577 }
2578 if (!data.WriteString(bundleName)) {
2579 TLOGE(WmsLogTag::WMS_LAYOUT, "Write bundleName failed");
2580 return WMError::WM_ERROR_IPC_FAILED;
2581 }
2582 sptr<IRemoteObject> remote = Remote();
2583 if (remote == nullptr) {
2584 TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
2585 return WMError::WM_ERROR_IPC_FAILED;
2586 }
2587 if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_APP_DRAG_RESIZE_TYPE),
2588 data, reply, option) != ERR_NONE) {
2589 TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
2590 return WMError::WM_ERROR_IPC_FAILED;
2591 }
2592 uint32_t obtainedDragResizeType = 0;
2593 if (!reply.ReadUint32(obtainedDragResizeType)) {
2594 TLOGE(WmsLogTag::WMS_LAYOUT, "Read dragResizeType failed");
2595 return WMError::WM_ERROR_IPC_FAILED;
2596 }
2597 if (obtainedDragResizeType > static_cast<uint32_t>(DragResizeType::RESIZE_WHEN_DRAG_END)) {
2598 TLOGE(WmsLogTag::WMS_LAYOUT, "bad dragResizeType value");
2599 return WMError::WM_ERROR_IPC_FAILED;
2600 }
2601 dragResizeType = static_cast<DragResizeType>(obtainedDragResizeType);
2602 uint32_t ret = 0;
2603 if (!reply.ReadUint32(ret)) {
2604 TLOGE(WmsLogTag::WMS_LAYOUT, "Read ret failed");
2605 return WMError::WM_ERROR_IPC_FAILED;
2606 }
2607 return static_cast<WMError>(ret);
2608 }
2609
2610 } // namespace OHOS::Rosen
2611