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