• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #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 #include "ui_effect_controller_interface.h"
31 #include "ui_effect_controller_client_interface.h"
32 
33 namespace OHOS::Rosen {
34 namespace {
35 constexpr int32_t CYCLE_LIMIT = 1000;
36 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SceneSessionManagerProxy"};
37 constexpr DisplayId VIRTUAL_DISPLAY_ID = 999;
38 }
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)39 WSError SceneSessionManagerProxy::CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage,
40     const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
41     sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session,
42     SystemSessionConfig& systemConfig, sptr<IRemoteObject> token)
43 {
44     MessageOption option(MessageOption::TF_SYNC);
45     MessageParcel data;
46     MessageParcel reply;
47     if (!data.WriteInterfaceToken(GetDescriptor())) {
48         TLOGE(WmsLogTag::WMS_LIFE, "Write InterfaceToken failed!");
49         return WSError::WS_ERROR_IPC_FAILED;
50     }
51     if (!data.WriteRemoteObject(sessionStage->AsObject())) {
52         TLOGE(WmsLogTag::WMS_LIFE, "Write ISessionStage failed!");
53         return WSError::WS_ERROR_IPC_FAILED;
54     }
55     if (!data.WriteRemoteObject(eventChannel->AsObject())) {
56         TLOGE(WmsLogTag::WMS_LIFE, "Write IWindowEventChannel failed!");
57         return WSError::WS_ERROR_IPC_FAILED;
58     }
59     if (!surfaceNode || !surfaceNode->Marshalling(data)) {
60         TLOGE(WmsLogTag::WMS_LIFE, "Write surfaceNode failed");
61         return WSError::WS_ERROR_IPC_FAILED;
62     }
63     if (!property || !data.WriteStrongParcelable(property)) {
64         TLOGE(WmsLogTag::WMS_LIFE, "Write property failed");
65         return WSError::WS_ERROR_IPC_FAILED;
66     }
67     if (token != nullptr) {
68         if (!data.WriteRemoteObject(token)) {
69             return WSError::WS_ERROR_IPC_FAILED;
70         }
71     }
72 
73     sptr<IRemoteObject> remote = Remote();
74     if (remote == nullptr) {
75         TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
76         return WSError::WS_ERROR_IPC_FAILED;
77     }
78     if (remote->SendRequest(static_cast<uint32_t>(
79         SceneSessionManagerMessage::TRANS_ID_CREATE_AND_CONNECT_SPECIFIC_SESSION), data, reply, option) != ERR_NONE) {
80         TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed");
81         return WSError::WS_ERROR_IPC_FAILED;
82     }
83     persistentId = reply.ReadInt32();
84     sptr<IRemoteObject> sessionObject = reply.ReadRemoteObject();
85     if (sessionObject == nullptr) {
86         TLOGE(WmsLogTag::WMS_LIFE, "ReadRemoteObject failed");
87         return WSError::WS_ERROR_IPC_FAILED;
88     }
89     session = iface_cast<ISession>(sessionObject);
90     sptr<SystemSessionConfig> config = reply.ReadParcelable<SystemSessionConfig>();
91     if (config) {
92         systemConfig = *config;
93     }
94     uint32_t level = 0;
95     if (!reply.ReadUint32(level)) {
96         TLOGE(WmsLogTag::WMS_LIFE, "Read level failed");
97         return WSError::WS_ERROR_IPC_FAILED;
98     }
99     property->SetSubWindowLevel(level);
100     uint64_t displayId = 0;
101     if (!reply.ReadUint64(displayId)) {
102         TLOGE(WmsLogTag::WMS_LIFE, "Read displayId failed");
103         return WSError::WS_ERROR_IPC_FAILED;
104     }
105     if (property->GetDisplayId() != VIRTUAL_DISPLAY_ID) {
106         property->SetDisplayId(displayId);
107     }
108     int32_t ret = reply.ReadInt32();
109     return static_cast<WSError>(ret);
110 }
111 
RecoverAndConnectSpecificSession(const sptr<ISessionStage> & sessionStage,const sptr<IWindowEventChannel> & eventChannel,const std::shared_ptr<RSSurfaceNode> & surfaceNode,sptr<WindowSessionProperty> property,sptr<ISession> & session,sptr<IRemoteObject> token)112 WSError SceneSessionManagerProxy::RecoverAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage,
113     const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
114     sptr<WindowSessionProperty> property, sptr<ISession>& session, sptr<IRemoteObject> token)
115 {
116     MessageParcel data;
117     MessageParcel reply;
118     MessageOption option;
119     if (!data.WriteInterfaceToken(GetDescriptor())) {
120         WLOGFE("Write InterfaceToken failed!");
121         return WSError::WS_ERROR_IPC_FAILED;
122     }
123     if (!sessionStage || !data.WriteRemoteObject(sessionStage->AsObject())) {
124         WLOGFE("Write ISessionStage failed!");
125         return WSError::WS_ERROR_IPC_FAILED;
126     }
127     if (!eventChannel || !data.WriteRemoteObject(eventChannel->AsObject())) {
128         WLOGFE("Write IWindowEventChannel failed!");
129         return WSError::WS_ERROR_IPC_FAILED;
130     }
131     if (!surfaceNode || !surfaceNode->Marshalling(data)) {
132         WLOGFE("Write surfaceNode failed");
133         return WSError::WS_ERROR_IPC_FAILED;
134     }
135 
136     if (property) {
137         if (!data.WriteBool(true) || !data.WriteParcelable(property.GetRefPtr())) {
138             return WSError::WS_ERROR_IPC_FAILED;
139         }
140     } else {
141         if (!data.WriteBool(false)) {
142             return WSError::WS_ERROR_IPC_FAILED;
143         }
144     }
145     if (token != nullptr && !data.WriteRemoteObject(token)) {
146         return WSError::WS_ERROR_IPC_FAILED;
147     }
148 
149     sptr<IRemoteObject> remote = Remote();
150     if (remote == nullptr) {
151         WLOGFE("remote is null");
152         return WSError::WS_ERROR_IPC_FAILED;
153     }
154     if (remote->SendRequest(static_cast<uint32_t>(
155         SceneSessionManagerMessage::TRANS_ID_RECOVER_AND_CONNECT_SPECIFIC_SESSION),
156         data, reply, option) != ERR_NONE) {
157         WLOGFE("SendRequest failed");
158         return WSError::WS_ERROR_IPC_FAILED;
159     }
160     sptr<IRemoteObject> sessionObject = reply.ReadRemoteObject();
161     if (sessionObject == nullptr) {
162         WLOGFE("ReadRemoteObject failed");
163         return WSError::WS_ERROR_IPC_FAILED;
164     }
165     session = iface_cast<ISession>(sessionObject);
166     int32_t ret = reply.ReadInt32();
167     return static_cast<WSError>(ret);
168 }
RecoverAndReconnectSceneSession(const sptr<ISessionStage> & sessionStage,const sptr<IWindowEventChannel> & eventChannel,const std::shared_ptr<RSSurfaceNode> & surfaceNode,sptr<ISession> & session,sptr<WindowSessionProperty> property,sptr<IRemoteObject> token)169 WSError SceneSessionManagerProxy::RecoverAndReconnectSceneSession(const sptr<ISessionStage>& sessionStage,
170     const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
171     sptr<ISession>& session, sptr<WindowSessionProperty> property, sptr<IRemoteObject> token)
172 {
173     MessageOption option(MessageOption::TF_SYNC);
174     MessageParcel data;
175     MessageParcel reply;
176     if (!data.WriteInterfaceToken(GetDescriptor())) {
177         WLOGFE("Write InterfaceToken failed!");
178         return WSError::WS_ERROR_IPC_FAILED;
179     }
180     if (!sessionStage || !data.WriteRemoteObject(sessionStage->AsObject())) {
181         WLOGFE("Write ISessionStage failed!");
182         return WSError::WS_ERROR_IPC_FAILED;
183     }
184     if (!eventChannel || !data.WriteRemoteObject(eventChannel->AsObject())) {
185         WLOGFE("Write IWindowEventChannel failed!");
186         return WSError::WS_ERROR_IPC_FAILED;
187     }
188     if (!surfaceNode || !surfaceNode->Marshalling(data)) {
189         WLOGFE("Write surfaceNode failed");
190         return WSError::WS_ERROR_IPC_FAILED;
191     }
192 
193     if (property) {
194         if (!data.WriteBool(true) || !data.WriteParcelable(property.GetRefPtr())) {
195             return WSError::WS_ERROR_IPC_FAILED;
196         }
197     } else {
198         if (!data.WriteBool(false)) {
199             return WSError::WS_ERROR_IPC_FAILED;
200         }
201     }
202     if (token != nullptr && !data.WriteRemoteObject(token)) {
203         return WSError::WS_ERROR_IPC_FAILED;
204     }
205 
206     sptr<IRemoteObject> remote = Remote();
207     if (remote == nullptr) {
208         WLOGFE("remote is null");
209         return WSError::WS_ERROR_IPC_FAILED;
210     }
211     if (remote->SendRequest(
212         static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_RECOVER_AND_RECONNECT_SCENE_SESSION), data, reply,
213         option) != ERR_NONE) {
214         WLOGFE("SendRequest failed");
215         return WSError::WS_ERROR_IPC_FAILED;
216     }
217     sptr<IRemoteObject> sessionObject = reply.ReadRemoteObject();
218     if (sessionObject == nullptr) {
219         WLOGFE("ReadRemoteObject failed");
220         return WSError::WS_ERROR_IPC_FAILED;
221     }
222     session = iface_cast<ISession>(sessionObject);
223     int32_t ret = reply.ReadInt32();
224     return static_cast<WSError>(ret);
225 }
226 
SetParentWindow(int32_t subWindowId,int32_t newParentWindowId)227 WMError SceneSessionManagerProxy::SetParentWindow(int32_t subWindowId, int32_t newParentWindowId)
228 {
229     MessageParcel data;
230     MessageParcel reply;
231     MessageOption option;
232     if (!data.WriteInterfaceToken(GetDescriptor())) {
233         TLOGE(WmsLogTag::WMS_SUB, "Write interfaceToken failed");
234         return WMError::WM_ERROR_IPC_FAILED;
235     }
236     if (!data.WriteInt32(subWindowId)) {
237         TLOGE(WmsLogTag::WMS_SUB, "Write subWindowId failed");
238         return WMError::WM_ERROR_IPC_FAILED;
239     }
240     if (!data.WriteInt32(newParentWindowId)) {
241         TLOGE(WmsLogTag::WMS_SUB, "Write newParentWindowId failed");
242         return WMError::WM_ERROR_IPC_FAILED;
243     }
244     sptr<IRemoteObject> remote = Remote();
245     if (remote == nullptr) {
246         TLOGE(WmsLogTag::WMS_SUB, "remote is null");
247         return WMError::WM_ERROR_IPC_FAILED;
248     }
249     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_PARENT_WINDOW),
250         data, reply, option) != ERR_NONE) {
251         TLOGE(WmsLogTag::WMS_SUB, "SendRequest failed");
252         return WMError::WM_ERROR_IPC_FAILED;
253     }
254     uint32_t ret = 0;
255     if (!reply.ReadUint32(ret)) {
256         TLOGE(WmsLogTag::WMS_SUB, "Read ret failed");
257         return WMError::WM_ERROR_IPC_FAILED;
258     }
259     return static_cast<WMError>(ret);
260 }
261 
GetSessionSnapshotById(int32_t persistentId,SessionSnapshot & snapshot)262 WMError SceneSessionManagerProxy::GetSessionSnapshotById(int32_t persistentId, SessionSnapshot& snapshot)
263 {
264     MessageParcel data;
265     MessageParcel reply;
266     MessageOption option;
267     if (!data.WriteInterfaceToken(GetDescriptor())) {
268         TLOGE(WmsLogTag::WMS_SYSTEM, "WriteInterfaceToken failed");
269         return WMError::WM_ERROR_IPC_FAILED;
270     }
271     if (!data.WriteInt32(persistentId)) {
272         TLOGE(WmsLogTag::WMS_SYSTEM, "Write persistentId failed");
273         return WMError::WM_ERROR_IPC_FAILED;
274     }
275 
276     sptr<IRemoteObject> remote = Remote();
277     if (remote == nullptr) {
278         TLOGE(WmsLogTag::WMS_SYSTEM, "remote is null");
279         return WMError::WM_ERROR_IPC_FAILED;
280     }
281     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_SESSION_SNAPSHOT_BY_ID),
282         data, reply, option) != ERR_NONE) {
283         TLOGE(WmsLogTag::WMS_SYSTEM, "SendRequest failed");
284         return WMError::WM_ERROR_IPC_FAILED;
285     }
286     sptr<SessionSnapshot> info(reply.ReadParcelable<SessionSnapshot>());
287     if (info) {
288         snapshot = *info;
289     } else {
290         TLOGE(WmsLogTag::WMS_SYSTEM, "Read snapshot is null.");
291     }
292     return static_cast<WMError>(reply.ReadInt32());
293 }
294 
GetSnapshotByWindowId(int32_t persistentId,std::shared_ptr<Media::PixelMap> & pixelMap)295 WMError SceneSessionManagerProxy::GetSnapshotByWindowId(int32_t persistentId,
296     std::shared_ptr<Media::PixelMap>& pixelMap)
297 {
298     SessionSnapshot snapshot;
299     WMError ret = GetSessionSnapshotById(persistentId, snapshot);
300     if (ret == WMError::WM_OK) {
301         pixelMap = snapshot.snapshot;
302     }
303     return ret;
304 }
305 
DestroyAndDisconnectSpecificSession(const int32_t persistentId)306 WSError SceneSessionManagerProxy::DestroyAndDisconnectSpecificSession(const int32_t persistentId)
307 {
308     MessageParcel data;
309     MessageParcel reply;
310     MessageOption option(MessageOption::TF_SYNC);
311     if (!data.WriteInterfaceToken(GetDescriptor())) {
312         TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
313         return WSError::WS_ERROR_IPC_FAILED;
314     }
315     if (!data.WriteInt32(persistentId)) {
316         TLOGE(WmsLogTag::WMS_LIFE, "Write persistentId failed");
317         return WSError::WS_ERROR_IPC_FAILED;
318     }
319     sptr<IRemoteObject> remote = Remote();
320     if (remote == nullptr) {
321         TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
322         return WSError::WS_ERROR_IPC_FAILED;
323     }
324     if (remote->SendRequest(static_cast<uint32_t>(
325         SceneSessionManagerMessage::TRANS_ID_DESTROY_AND_DISCONNECT_SPECIFIC_SESSION),
326         data, reply, option) != ERR_NONE) {
327         TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed");
328         return WSError::WS_ERROR_IPC_FAILED;
329     }
330     int32_t ret = reply.ReadInt32();
331     return static_cast<WSError>(ret);
332 }
333 
DestroyAndDisconnectSpecificSessionWithDetachCallback(const int32_t persistentId,const sptr<IRemoteObject> & callback)334 WSError SceneSessionManagerProxy::DestroyAndDisconnectSpecificSessionWithDetachCallback(const int32_t persistentId,
335     const sptr<IRemoteObject>& callback)
336 {
337     MessageParcel data;
338     MessageParcel reply;
339     MessageOption option(MessageOption::TF_SYNC);
340     if (!data.WriteInterfaceToken(GetDescriptor())) {
341         TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
342         return WSError::WS_ERROR_IPC_FAILED;
343     }
344     if (!data.WriteInt32(persistentId)) {
345         TLOGE(WmsLogTag::WMS_LIFE, "Write persistentId failed");
346         return WSError::WS_ERROR_IPC_FAILED;
347     }
348     if (callback == nullptr || !data.WriteRemoteObject(callback)) {
349         TLOGE(WmsLogTag::WMS_LIFE, "Write callback failed");
350         return WSError::WS_ERROR_IPC_FAILED;
351     }
352     sptr<IRemoteObject> remote = Remote();
353     if (remote == nullptr) {
354         TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
355         return WSError::WS_ERROR_IPC_FAILED;
356     }
357     if (remote->SendRequest(static_cast<uint32_t>(
358         SceneSessionManagerMessage::TRANS_ID_DESTROY_AND_DISCONNECT_SPECIFIC_SESSION_WITH_DETACH_CALLBACK),
359         data, reply, option) != ERR_NONE) {
360         TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed");
361         return WSError::WS_ERROR_IPC_FAILED;
362     }
363     int32_t ret = reply.ReadInt32();
364     return static_cast<WSError>(ret);
365 }
366 
RequestFocusStatus(int32_t persistentId,bool isFocused,bool byForeground,FocusChangeReason reason)367 WMError SceneSessionManagerProxy::RequestFocusStatus(int32_t persistentId, bool isFocused, bool byForeground,
368     FocusChangeReason reason)
369 {
370     TLOGI(WmsLogTag::WMS_FOCUS, "SceneSessionManagerProxy::RequestFocusStatus id: %{public}d, focusState:\
371         %{public}u, byForeground: %{public}d, reason: %{public}d", persistentId, isFocused, byForeground, reason);
372     MessageParcel data;
373     MessageParcel reply;
374     MessageOption option(MessageOption::TF_SYNC);
375     if (!data.WriteInterfaceToken(GetDescriptor())) {
376         WLOGFE("WriteInterfaceToken failed");
377         return WMError::WM_ERROR_IPC_FAILED;
378     }
379     if (!data.WriteInt32(persistentId)) {
380         WLOGFE("Write persistentId failed");
381         return WMError::WM_ERROR_IPC_FAILED;
382     }
383     if (!data.WriteBool(isFocused)) {
384         WLOGFE("Write isFocused failed");
385         return WMError::WM_ERROR_IPC_FAILED;
386     }
387 
388     sptr<IRemoteObject> remote = Remote();
389     if (remote == nullptr) {
390         WLOGFE("remote is null");
391         return WMError::WM_ERROR_IPC_FAILED;
392     }
393     if (remote->SendRequest(static_cast<uint32_t>(
394         SceneSessionManagerMessage::TRANS_ID_REQUEST_FOCUS),
395         data, reply, option) != ERR_NONE) {
396         WLOGFE("SendRequest failed");
397         return WMError::WM_ERROR_IPC_FAILED;
398     }
399     int32_t ret = reply.ReadInt32();
400     return static_cast<WMError>(ret);
401 }
402 
RequestFocusStatusBySA(int32_t persistentId,bool isFocused,bool byForeground,FocusChangeReason reason)403 WMError SceneSessionManagerProxy::RequestFocusStatusBySA(int32_t persistentId, bool isFocused,
404     bool byForeground, FocusChangeReason reason)
405 {
406     TLOGI(WmsLogTag::WMS_FOCUS,
407         "id: %{public}d, focusState: %{public}d, byForeground: %{public}d, reason: %{public}d",
408         persistentId, isFocused, byForeground, static_cast<int32_t>(reason));
409     MessageParcel data;
410     MessageParcel reply;
411     MessageOption option(MessageOption::TF_SYNC);
412     if (!data.WriteInterfaceToken(GetDescriptor())) {
413         TLOGE(WmsLogTag::WMS_FOCUS, "WriteInterfaceToken failed");
414         return WMError::WM_ERROR_IPC_FAILED;
415     }
416     if (!data.WriteInt32(persistentId)) {
417         TLOGE(WmsLogTag::WMS_FOCUS, "Write persistentId failed");
418         return WMError::WM_ERROR_IPC_FAILED;
419     }
420     if (!data.WriteBool(isFocused)) {
421         TLOGE(WmsLogTag::WMS_FOCUS, "Write isFocused failed");
422         return WMError::WM_ERROR_IPC_FAILED;
423     }
424     if (!data.WriteBool(byForeground)) {
425         TLOGE(WmsLogTag::WMS_FOCUS, "Write byForeground failed");
426         return WMError::WM_ERROR_IPC_FAILED;
427     }
428     if (!data.WriteInt32(static_cast<int32_t>(reason))) {
429         TLOGE(WmsLogTag::WMS_FOCUS, "Write reason failed");
430         return WMError::WM_ERROR_IPC_FAILED;
431     }
432 
433     sptr<IRemoteObject> remote = Remote();
434     if (remote == nullptr) {
435         TLOGE(WmsLogTag::WMS_FOCUS, "remote is null");
436         return WMError::WM_ERROR_IPC_FAILED;
437     }
438     if (remote->SendRequest(static_cast<uint32_t>(
439         SceneSessionManagerMessage::TRANS_ID_REQUEST_FOCUS_STATUS_BY_SA),
440         data, reply, option) != ERR_NONE) {
441         TLOGE(WmsLogTag::WMS_FOCUS, "SendRequest failed");
442         return WMError::WM_ERROR_IPC_FAILED;
443     }
444     int32_t ret = reply.ReadInt32();
445     return static_cast<WMError>(ret);
446 }
447 
RaiseWindowToTop(int32_t persistentId)448 WSError SceneSessionManagerProxy::RaiseWindowToTop(int32_t persistentId)
449 {
450     MessageParcel data;
451     MessageParcel reply;
452     MessageOption option(MessageOption::TF_SYNC);
453     if (!data.WriteInterfaceToken(GetDescriptor())) {
454         WLOGFE("WriteInterfaceToken failed");
455         return WSError::WS_ERROR_IPC_FAILED;
456     }
457     if (!data.WriteInt32(persistentId)) {
458         WLOGFE("Write persistentId failed");
459         return WSError::WS_ERROR_IPC_FAILED;
460     }
461 
462     sptr<IRemoteObject> remote = Remote();
463     if (remote == nullptr) {
464         WLOGFE("remote is null");
465         return WSError::WS_ERROR_IPC_FAILED;
466     }
467     if (remote->SendRequest(static_cast<uint32_t>(
468         SceneSessionManagerMessage::TRANS_ID_RAISE_WINDOW_TO_TOP),
469         data, reply, option) != ERR_NONE) {
470         WLOGFE("SendRequest failed");
471         return WSError::WS_ERROR_IPC_FAILED;
472     }
473     int32_t ret = reply.ReadInt32();
474     return static_cast<WSError>(ret);
475 }
476 
BindDialogSessionTarget(uint64_t persistentId,sptr<IRemoteObject> targetToken)477 WSError SceneSessionManagerProxy::BindDialogSessionTarget(uint64_t persistentId, sptr<IRemoteObject> targetToken)
478 {
479     MessageParcel data;
480     MessageParcel reply;
481     MessageOption option(MessageOption::TF_SYNC);
482     if (!data.WriteInterfaceToken(GetDescriptor())) {
483         WLOGFE("WriteInterfaceToken failed");
484         return WSError::WS_ERROR_IPC_FAILED;
485     }
486     if (!data.WriteUint64(persistentId)) {
487         WLOGFE("Write PropertyChangeAction failed");
488         return WSError::WS_ERROR_IPC_FAILED;
489     }
490     if (targetToken != nullptr) {
491         if (!data.WriteRemoteObject(targetToken)) {
492             WLOGFE("Write targetToken failed");
493             return WSError::WS_ERROR_IPC_FAILED;
494         }
495     }
496 
497     sptr<IRemoteObject> remote = Remote();
498     if (remote == nullptr) {
499         WLOGFE("remote is null");
500         return WSError::WS_ERROR_IPC_FAILED;
501     }
502     if (remote->SendRequest(static_cast<uint32_t>(
503         SceneSessionManagerMessage::TRANS_ID_BIND_DIALOG_TARGET),
504         data, reply, option) != ERR_NONE) {
505         WLOGFE("SendRequest failed");
506         return WSError::WS_ERROR_IPC_FAILED;
507     }
508     int32_t ret = reply.ReadInt32();
509     return static_cast<WSError>(ret);
510 }
511 
UpdateSessionAvoidAreaListener(int32_t persistentId,bool haveListener)512 WSError SceneSessionManagerProxy::UpdateSessionAvoidAreaListener(int32_t persistentId, bool haveListener)
513 {
514     MessageParcel data;
515     MessageParcel reply;
516     MessageOption option(MessageOption::TF_SYNC);
517 
518     if (!data.WriteInterfaceToken(GetDescriptor())) {
519         WLOGFE("WriteInterfaceToken failed");
520         return WSError::WS_ERROR_IPC_FAILED;
521     }
522     if (!data.WriteInt32(persistentId)) {
523         WLOGFE("Write persistentId failed");
524         return WSError::WS_ERROR_IPC_FAILED;
525     }
526     if (!data.WriteBool(haveListener)) {
527         WLOGFE("Write avoid area listener failed");
528         return WSError::WS_ERROR_IPC_FAILED;
529     }
530     sptr<IRemoteObject> remote = Remote();
531     if (remote == nullptr) {
532         WLOGFE("remote is null");
533         return WSError::WS_ERROR_IPC_FAILED;
534     }
535     if (remote->SendRequest(static_cast<uint32_t>(
536         SceneSessionManagerMessage::TRANS_ID_UPDATE_AVOIDAREA_LISTENER),
537         data, reply, option) != ERR_NONE) {
538         return WSError::WS_ERROR_IPC_FAILED;
539     }
540     return static_cast<WSError>(reply.ReadInt32());
541 }
542 
NotifyScreenshotEvent(ScreenshotEventType type)543 WMError SceneSessionManagerProxy::NotifyScreenshotEvent(ScreenshotEventType type)
544 {
545     MessageParcel data;
546     MessageParcel reply;
547     MessageOption option(MessageOption::TF_SYNC);
548     if (!data.WriteInterfaceToken(GetDescriptor())) {
549         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write interfaceToken failed");
550         return WMError::WM_ERROR_IPC_FAILED;
551     }
552     if (!data.WriteInt32(static_cast<int32_t>(type))) {
553         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write screenshot event type failed");
554         return WMError::WM_ERROR_IPC_FAILED;
555     }
556     sptr<IRemoteObject> remote = Remote();
557     if (remote == nullptr) {
558         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
559         return WMError::WM_ERROR_IPC_FAILED;
560     }
561     if (remote->SendRequest(static_cast<uint32_t>(
562         SceneSessionManagerMessage::TRANS_ID_NOTIFY_SCREEN_SHOT_EVENT), data, reply, option) != ERR_NONE) {
563         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
564         return WMError::WM_ERROR_IPC_FAILED;
565     }
566     int32_t errCode = 0;
567     if (!reply.ReadInt32(errCode)) {
568         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read errcode failed");
569         return WMError::WM_ERROR_IPC_FAILED;
570     }
571     return static_cast<WMError>(errCode);
572 }
573 
UpdateSessionTouchOutsideListener(int32_t & persistentId,bool haveListener)574 WSError SceneSessionManagerProxy::UpdateSessionTouchOutsideListener(int32_t& persistentId, bool haveListener)
575 {
576     MessageParcel data;
577     MessageParcel reply;
578     MessageOption option(MessageOption::TF_SYNC);
579 
580     if (!data.WriteInterfaceToken(GetDescriptor())) {
581         WLOGFE("WriteInterfaceToken failed");
582         return WSError::WS_ERROR_IPC_FAILED;
583     }
584     if (!data.WriteInt32(persistentId)) {
585         WLOGFE("Write persistentId failed");
586         return WSError::WS_ERROR_IPC_FAILED;
587     }
588     if (!data.WriteBool(haveListener)) {
589         WLOGFE("Write avoid area listener failed");
590         return WSError::WS_ERROR_IPC_FAILED;
591     }
592     sptr<IRemoteObject> remote = Remote();
593     if (remote == nullptr) {
594         WLOGFE("remote is null");
595         return WSError::WS_ERROR_IPC_FAILED;
596     }
597     if (remote->SendRequest(static_cast<uint32_t>(
598         SceneSessionManagerMessage::TRANS_ID_UPDATE_TOUCHOUTSIDE_LISTENER),
599         data, reply, option) != ERR_NONE) {
600         return WSError::WS_ERROR_IPC_FAILED;
601     }
602     return static_cast<WSError>(reply.ReadInt32());
603 }
604 
UpdateSessionWindowVisibilityListener(int32_t persistentId,bool haveListener)605 WSError SceneSessionManagerProxy::UpdateSessionWindowVisibilityListener(int32_t persistentId, bool haveListener)
606 {
607     MessageParcel data;
608     MessageParcel reply;
609     MessageOption option(MessageOption::TF_SYNC);
610 
611     if (!data.WriteInterfaceToken(GetDescriptor())) {
612         WLOGFE("WriteInterfaceToken failed");
613         return WSError::WS_ERROR_IPC_FAILED;
614     }
615     if (!data.WriteInt32(persistentId)) {
616         WLOGFE("Write persistentId failed");
617         return WSError::WS_ERROR_IPC_FAILED;
618     }
619     if (!data.WriteBool(haveListener)) {
620         WLOGFE("Write avoid area listener failed");
621         return WSError::WS_ERROR_IPC_FAILED;
622     }
623     sptr<IRemoteObject> remote = Remote();
624     if (remote == nullptr) {
625         WLOGFE("remote is null");
626         return WSError::WS_ERROR_IPC_FAILED;
627     }
628     if (remote->SendRequest(static_cast<uint32_t>(
629         SceneSessionManagerMessage::TRANS_ID_UPDATE_WINDOW_VISIBILITY_LISTENER),
630         data, reply, option) != ERR_NONE) {
631         return WSError::WS_ERROR_IPC_FAILED;
632     }
633     return static_cast<WSError>(reply.ReadInt32());
634 }
635 
RecoverWindowPropertyChangeFlag(uint32_t observedFlags,uint32_t interestedFlags)636 WMError SceneSessionManagerProxy::RecoverWindowPropertyChangeFlag(uint32_t observedFlags, uint32_t interestedFlags)
637 {
638     MessageOption option;
639     MessageParcel reply;
640     MessageParcel data;
641     if (!data.WriteInterfaceToken(GetDescriptor())) {
642         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write InterfaceToken failed");
643         return WMError::WM_ERROR_IPC_FAILED;
644     }
645 
646     if (!data.WriteUint32(observedFlags)) {
647         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write observedFlags failed");
648         return WMError::WM_ERROR_IPC_FAILED;
649     }
650 
651     if (!data.WriteUint32(interestedFlags)) {
652         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write interestedFlags failed");
653         return WMError::WM_ERROR_IPC_FAILED;
654     }
655 
656     sptr<IRemoteObject> remote = Remote();
657     if (remote == nullptr) {
658         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
659         return WMError::WM_ERROR_IPC_FAILED;
660     }
661     if (remote->SendRequest(static_cast<uint32_t>(
662         SceneSessionManagerMessage::TRANS_ID_RECOVER_WINDOW_PROPERTY_CHANGE_FLAG),
663         data, reply, option) != ERR_NONE) {
664         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
665         return WMError::WM_ERROR_IPC_FAILED;
666     }
667 
668     int32_t ret = 0;
669     if (!reply.ReadInt32(ret)) {
670         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read ret failed");
671         return WMError::WM_ERROR_IPC_FAILED;
672     }
673     return static_cast<WMError>(ret);
674 }
675 
RegisterWindowManagerAgent(WindowManagerAgentType type,const sptr<IWindowManagerAgent> & windowManagerAgent)676 WMError SceneSessionManagerProxy::RegisterWindowManagerAgent(WindowManagerAgentType type,
677     const sptr<IWindowManagerAgent>& windowManagerAgent)
678 {
679     MessageOption option;
680     MessageParcel reply;
681     MessageParcel data;
682     if (!data.WriteInterfaceToken(GetDescriptor())) {
683         WLOGFE("Write InterfaceToken failed");
684         return WMError::WM_ERROR_IPC_FAILED;
685     }
686 
687     if (!data.WriteUint32(static_cast<uint32_t>(type))) {
688         WLOGFE("Write type failed");
689         return WMError::WM_ERROR_IPC_FAILED;
690     }
691 
692     if (!data.WriteRemoteObject(windowManagerAgent->AsObject())) {
693         WLOGFE("Write IWindowManagerAgent failed");
694         return WMError::WM_ERROR_IPC_FAILED;
695     }
696 
697     sptr<IRemoteObject> remote = Remote();
698     if (remote == nullptr) {
699         WLOGFE("remote is null");
700         return WMError::WM_ERROR_IPC_FAILED;
701     }
702     if (remote->SendRequest(static_cast<uint32_t>(
703         SceneSessionManagerMessage::TRANS_ID_REGISTER_WINDOW_MANAGER_AGENT),
704         data, reply, option) != ERR_NONE) {
705         WLOGFE("SendRequest failed");
706         return WMError::WM_ERROR_IPC_FAILED;
707     }
708 
709     return static_cast<WMError>(reply.ReadInt32());
710 }
711 
UnregisterWindowManagerAgent(WindowManagerAgentType type,const sptr<IWindowManagerAgent> & windowManagerAgent)712 WMError SceneSessionManagerProxy::UnregisterWindowManagerAgent(WindowManagerAgentType type,
713     const sptr<IWindowManagerAgent>& windowManagerAgent)
714 {
715     MessageParcel reply;
716     MessageOption option;
717     MessageParcel data;
718     if (!data.WriteInterfaceToken(GetDescriptor())) {
719         WLOGFE("Write InterfaceToken failed");
720         return WMError::WM_ERROR_IPC_FAILED;
721     }
722 
723     if (!data.WriteUint32(static_cast<uint32_t>(type))) {
724         WLOGFE("Write type failed");
725         return WMError::WM_ERROR_IPC_FAILED;
726     }
727 
728     if (!data.WriteRemoteObject(windowManagerAgent->AsObject())) {
729         WLOGFE("Write IWindowManagerAgent failed");
730         return WMError::WM_ERROR_IPC_FAILED;
731     }
732 
733     sptr<IRemoteObject> remote = Remote();
734     if (remote == nullptr) {
735         WLOGFE("remote is null");
736         return WMError::WM_ERROR_IPC_FAILED;
737     }
738     if (remote->SendRequest(static_cast<uint32_t>(
739         SceneSessionManagerMessage::TRANS_ID_UNREGISTER_WINDOW_MANAGER_AGENT),
740         data, reply, option) != ERR_NONE) {
741         WLOGFE("SendRequest failed");
742         return WMError::WM_ERROR_IPC_FAILED;
743     }
744 
745     return static_cast<WMError>(reply.ReadInt32());
746 }
747 
RegisterWindowPropertyChangeAgent(WindowInfoKey windowInfoKey,uint32_t interestInfo,const sptr<IWindowManagerAgent> & windowManagerAgent)748 WMError SceneSessionManagerProxy::RegisterWindowPropertyChangeAgent(WindowInfoKey windowInfoKey, uint32_t interestInfo,
749     const sptr<IWindowManagerAgent>& windowManagerAgent)
750 {
751     MessageOption option;
752     MessageParcel reply;
753     MessageParcel data;
754     if (!data.WriteInterfaceToken(GetDescriptor())) {
755         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write InterfaceToken failed");
756         return WMError::WM_ERROR_IPC_FAILED;
757     }
758 
759     if (!data.WriteInt32(static_cast<int32_t>(windowInfoKey))) {
760         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write windowInfoKey failed");
761         return WMError::WM_ERROR_IPC_FAILED;
762     }
763 
764     if (!data.WriteUint32(interestInfo)) {
765         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write interestInfo failed");
766         return WMError::WM_ERROR_IPC_FAILED;
767     }
768 
769     if (!windowManagerAgent) {
770         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "windowManagerAgent is nullptr");
771         return WMError::WM_ERROR_NULLPTR;
772     }
773 
774     if (!data.WriteRemoteObject(windowManagerAgent->AsObject())) {
775         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write IWindowManagerAgent failed");
776         return WMError::WM_ERROR_IPC_FAILED;
777     }
778 
779     sptr<IRemoteObject> remote = Remote();
780     if (remote == nullptr) {
781         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
782         return WMError::WM_ERROR_IPC_FAILED;
783     }
784     if (remote->SendRequest(static_cast<uint32_t>(
785         SceneSessionManagerMessage::TRANS_ID_REGISTER_WINDOW_PROPERTY_CHANGE_AGENT),
786         data, reply, option) != ERR_NONE) {
787         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
788         return WMError::WM_ERROR_IPC_FAILED;
789     }
790 
791     return static_cast<WMError>(reply.ReadInt32());
792 }
793 
UnregisterWindowPropertyChangeAgent(WindowInfoKey windowInfoKey,uint32_t interestInfo,const sptr<IWindowManagerAgent> & windowManagerAgent)794 WMError SceneSessionManagerProxy::UnregisterWindowPropertyChangeAgent(WindowInfoKey windowInfoKey,
795     uint32_t interestInfo, const sptr<IWindowManagerAgent>& windowManagerAgent)
796 {
797     MessageOption option;
798     MessageParcel reply;
799     MessageParcel data;
800     if (!data.WriteInterfaceToken(GetDescriptor())) {
801         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write InterfaceToken failed");
802         return WMError::WM_ERROR_IPC_FAILED;
803     }
804 
805     if (!data.WriteInt32(static_cast<int32_t>(windowInfoKey))) {
806         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write windowInfoKey failed");
807         return WMError::WM_ERROR_IPC_FAILED;
808     }
809 
810     if (!data.WriteUint32(interestInfo)) {
811         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write interestInfo failed");
812         return WMError::WM_ERROR_IPC_FAILED;
813     }
814 
815     if (!windowManagerAgent) {
816         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "windowManagerAgent is nullptr");
817         return WMError::WM_ERROR_NULLPTR;
818     }
819 
820     if (!data.WriteRemoteObject(windowManagerAgent->AsObject())) {
821         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write IWindowManagerAgent failed");
822         return WMError::WM_ERROR_IPC_FAILED;
823     }
824 
825     sptr<IRemoteObject> remote = Remote();
826     if (remote == nullptr) {
827         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
828         return WMError::WM_ERROR_IPC_FAILED;
829     }
830     if (remote->SendRequest(static_cast<uint32_t>(
831         SceneSessionManagerMessage::TRANS_ID_UNREGISTER_WINDOW_PROPERTY_CHANGE_AGENT),
832         data, reply, option) != ERR_NONE) {
833         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
834         return WMError::WM_ERROR_IPC_FAILED;
835     }
836 
837     return static_cast<WMError>(reply.ReadInt32());
838 }
839 
SetGestureNavigationEnabled(bool enable)840 WMError SceneSessionManagerProxy::SetGestureNavigationEnabled(bool enable)
841 {
842     MessageParcel data;
843     MessageParcel reply;
844     MessageOption option(MessageOption::TF_SYNC);
845     if (!data.WriteInterfaceToken(GetDescriptor())) {
846         WLOGFE("Write InterfaceToken failed");
847         return WMError::WM_ERROR_IPC_FAILED;
848     }
849 
850     if (!data.WriteBool(enable)) {
851         WLOGFE("Write enable failed");
852         return WMError::WM_ERROR_IPC_FAILED;
853     }
854 
855     sptr<IRemoteObject> remote = Remote();
856     if (remote == nullptr) {
857         WLOGFE("remote is null");
858         return WMError::WM_ERROR_IPC_FAILED;
859     }
860     if (remote->SendRequest(static_cast<uint32_t>(
861         SceneSessionManagerMessage::TRANS_ID_SET_GESTURE_NAVIGATION_ENABLED), data, reply, option) != ERR_NONE) {
862         WLOGFE("SendRequest failed");
863         return WMError::WM_ERROR_IPC_FAILED;
864     }
865     int32_t ret = reply.ReadInt32();
866     return static_cast<WMError>(ret);
867 }
868 
GetFocusWindowInfo(FocusChangeInfo & focusInfo,DisplayId displayId)869 void SceneSessionManagerProxy::GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId)
870 {
871     MessageParcel data;
872     MessageParcel reply;
873     MessageOption option;
874     if (!data.WriteInterfaceToken(GetDescriptor())) {
875         WLOGFE("WriteInterfaceToken failed");
876         return;
877     }
878     if (!data.WriteUint64(displayId)) {
879         TLOGE(WmsLogTag::WMS_FOCUS, "write displayId failed");
880         return;
881     }
882     sptr<IRemoteObject> remote = Remote();
883     if (remote == nullptr) {
884         WLOGFE("remote is null");
885         return;
886     }
887     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_FOCUS_SESSION_INFO),
888         data, reply, option) != ERR_NONE) {
889         WLOGFE("SendRequest failed");
890         return;
891     }
892     sptr<FocusChangeInfo> info = reply.ReadParcelable<FocusChangeInfo>();
893     if (info) {
894         focusInfo = *info;
895     } else {
896         WLOGFE("info is null.");
897     }
898 }
899 
SetSessionLabel(const sptr<IRemoteObject> & token,const std::string & label)900 WSError SceneSessionManagerProxy::SetSessionLabel(const sptr<IRemoteObject>& token, const std::string& label)
901 {
902     WLOGFI("run SceneSessionManagerProxy::SetSessionLabel");
903     MessageParcel data;
904     MessageParcel reply;
905     MessageOption option;
906     if (!data.WriteInterfaceToken(GetDescriptor())) {
907         WLOGFE("WriteInterfaceToken failed");
908         return WSError::WS_ERROR_IPC_FAILED;
909     }
910     if (!data.WriteRemoteObject(token)) {
911         WLOGFE("Write token failed");
912         return WSError::WS_ERROR_IPC_FAILED;
913     }
914     if (!data.WriteString(label)) {
915         WLOGFE("Write label failed");
916         return WSError::WS_ERROR_IPC_FAILED;
917     }
918 
919     sptr<IRemoteObject> remote = Remote();
920     if (remote == nullptr) {
921         WLOGFE("remote is null");
922         return WSError::WS_ERROR_IPC_FAILED;
923     }
924     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_SESSION_LABEL),
925         data, reply, option) != ERR_NONE) {
926         WLOGFE("SendRequest failed");
927         return WSError::WS_ERROR_IPC_FAILED;
928     }
929     return static_cast<WSError>(reply.ReadInt32());
930 }
931 
SetSessionIcon(const sptr<IRemoteObject> & token,const std::shared_ptr<Media::PixelMap> & icon)932 WSError SceneSessionManagerProxy::SetSessionIcon(const sptr<IRemoteObject>& token,
933     const std::shared_ptr<Media::PixelMap>& icon)
934 {
935     WLOGFI("run SceneSessionManagerProxy::SetSessionIcon");
936     MessageParcel data;
937     MessageParcel reply;
938     MessageOption option;
939     if (!data.WriteInterfaceToken(GetDescriptor())) {
940         WLOGFE("WriteInterfaceToken failed");
941         return WSError::WS_ERROR_IPC_FAILED;
942     }
943     if (!data.WriteRemoteObject(token)) {
944         WLOGFE("Write token failed");
945         return WSError::WS_ERROR_IPC_FAILED;
946     }
947     if (!data.WriteParcelable(icon.get())) {
948         WLOGFE("Write icon failed");
949         return WSError::WS_ERROR_IPC_FAILED;
950     }
951 
952     sptr<IRemoteObject> remote = Remote();
953     if (remote == nullptr) {
954         WLOGFE("remote is null");
955         return WSError::WS_ERROR_IPC_FAILED;
956     }
957     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_SESSION_ICON),
958         data, reply, option) != ERR_NONE) {
959         WLOGFE("SendRequest failed");
960         return WSError::WS_ERROR_IPC_FAILED;
961     }
962     return static_cast<WSError>(reply.ReadInt32());
963 }
964 
IsValidSessionIds(const std::vector<int32_t> & sessionIds,std::vector<bool> & results)965 WSError SceneSessionManagerProxy::IsValidSessionIds(
966     const std::vector<int32_t>& sessionIds, std::vector<bool>& results)
967 {
968     WLOGFI("run SceneSessionManagerProxy::IsValidSessionIds");
969     MessageParcel data;
970     MessageParcel reply;
971     MessageOption option;
972     if (!data.WriteInterfaceToken(GetDescriptor())) {
973         WLOGFE("WriteInterfaceToken failed");
974         return WSError::WS_ERROR_IPC_FAILED;
975     }
976     if (!data.WriteInt32Vector(sessionIds)) {
977         WLOGFE("Write sessionIds failed");
978         return WSError::WS_ERROR_IPC_FAILED;
979     }
980 
981     sptr<IRemoteObject> remote = Remote();
982     if (remote == nullptr) {
983         WLOGFE("remote is null");
984         return WSError::WS_ERROR_IPC_FAILED;
985     }
986     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_IS_VALID_SESSION_IDS),
987         data, reply, option) != ERR_NONE) {
988         WLOGFE("SendRequest failed");
989         return WSError::WS_ERROR_IPC_FAILED;
990     }
991 
992     reply.ReadBoolVector(&results);
993     return static_cast<WSError>(reply.ReadInt32());
994 }
995 
GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>> & infos)996 WMError SceneSessionManagerProxy::GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos)
997 {
998     MessageOption option;
999     MessageParcel reply;
1000     MessageParcel data;
1001     if (!data.WriteInterfaceToken(GetDescriptor())) {
1002         WLOGFE("Write InterfaceToken failed");
1003         return WMError::WM_ERROR_IPC_FAILED;
1004     }
1005 
1006     sptr<IRemoteObject> remote = Remote();
1007     if (remote == nullptr) {
1008         WLOGFE("remote is null");
1009         return WMError::WM_ERROR_IPC_FAILED;
1010     }
1011     if (remote->SendRequest(static_cast<uint32_t>(
1012         SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_INFO),
1013         data, reply, option) != ERR_NONE) {
1014         WLOGFE("SendRequest failed");
1015         return WMError::WM_ERROR_IPC_FAILED;
1016     }
1017 
1018     if (!MarshallingHelper::UnmarshallingVectorParcelableObj<AccessibilityWindowInfo>(reply, infos)) {
1019         WLOGFE("read window info failed.");
1020         return WMError::WM_ERROR_IPC_FAILED;
1021     }
1022     return static_cast<WMError>(reply.ReadUint32());
1023 }
1024 
GetUnreliableWindowInfo(int32_t windowId,std::vector<sptr<UnreliableWindowInfo>> & infos)1025 WMError SceneSessionManagerProxy::GetUnreliableWindowInfo(int32_t windowId,
1026     std::vector<sptr<UnreliableWindowInfo>>& infos)
1027 {
1028     TLOGD(WmsLogTag::DEFAULT, "run!");
1029     MessageOption option;
1030     MessageParcel reply;
1031     MessageParcel data;
1032     if (!data.WriteInterfaceToken(GetDescriptor())) {
1033         TLOGE(WmsLogTag::DEFAULT, "Write InterfaceToken failed");
1034         return WMError::WM_ERROR_IPC_FAILED;
1035     }
1036 
1037     if (!data.WriteInt32(windowId)) {
1038         TLOGE(WmsLogTag::DEFAULT, "Write windowId failed");
1039         return WMError::WM_ERROR_IPC_FAILED;
1040     }
1041 
1042     sptr<IRemoteObject> remote = Remote();
1043     if (remote == nullptr) {
1044         TLOGE(WmsLogTag::DEFAULT, "remote is null");
1045         return WMError::WM_ERROR_IPC_FAILED;
1046     }
1047     if (remote->SendRequest(static_cast<uint32_t>(
1048         SceneSessionManagerMessage::TRANS_ID_GET_UNRELIABLE_WINDOW_INFO),
1049         data, reply, option) != ERR_NONE) {
1050         TLOGE(WmsLogTag::DEFAULT, "SendRequest failed");
1051         return WMError::WM_ERROR_IPC_FAILED;
1052     }
1053 
1054     if (!MarshallingHelper::UnmarshallingVectorParcelableObj<UnreliableWindowInfo>(reply, infos)) {
1055         TLOGE(WmsLogTag::DEFAULT, "read window info failed.");
1056         return WMError::WM_ERROR_IPC_FAILED;
1057     }
1058     return static_cast<WMError>(reply.ReadInt32());
1059 }
1060 
PendingSessionToForeground(const sptr<IRemoteObject> & token)1061 WSError SceneSessionManagerProxy::PendingSessionToForeground(const sptr<IRemoteObject>& token)
1062 {
1063     WLOGFI("run SceneSessionManagerProxy::PendingSessionToForeground");
1064     MessageParcel data;
1065     MessageParcel reply;
1066     MessageOption option;
1067     if (!data.WriteInterfaceToken(GetDescriptor())) {
1068         WLOGFE("Write interfaceToken failed");
1069         return WSError::WS_ERROR_IPC_FAILED;
1070     }
1071 
1072     if (!data.WriteRemoteObject(token)) {
1073         WLOGFE("Write token failed");
1074         return WSError::WS_ERROR_IPC_FAILED;
1075     }
1076 
1077     sptr<IRemoteObject> remote = Remote();
1078     if (remote == nullptr) {
1079         WLOGFE("remote is null");
1080         return WSError::WS_ERROR_IPC_FAILED;
1081     }
1082     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_PENDING_SESSION_TO_FOREGROUND),
1083         data, reply, option) != ERR_NONE) {
1084         WLOGFE("SendRequest failed");
1085         return WSError::WS_ERROR_IPC_FAILED;
1086     }
1087     return static_cast<WSError>(reply.ReadInt32());
1088 }
1089 
PendingSessionToBackgroundForDelegator(const sptr<IRemoteObject> & token,bool shouldBackToCaller)1090 WSError SceneSessionManagerProxy::PendingSessionToBackgroundForDelegator(const sptr<IRemoteObject>& token,
1091     bool shouldBackToCaller)
1092 {
1093     TLOGD(WmsLogTag::WMS_LIFE, "run");
1094     MessageParcel data;
1095     MessageParcel reply;
1096     MessageOption option;
1097     if (!data.WriteInterfaceToken(GetDescriptor())) {
1098         TLOGE(WmsLogTag::WMS_LIFE, "Write interfaceToken failed");
1099         return WSError::WS_ERROR_IPC_FAILED;
1100     }
1101 
1102     if (!data.WriteRemoteObject(token)) {
1103         TLOGE(WmsLogTag::WMS_LIFE, "Write token failed");
1104         return WSError::WS_ERROR_IPC_FAILED;
1105     }
1106 
1107     if (!data.WriteBool(shouldBackToCaller)) {
1108         TLOGE(WmsLogTag::WMS_LIFE, "Write shouldBackToCaller failed");
1109         return WSError::WS_ERROR_IPC_FAILED;
1110     }
1111 
1112     sptr<IRemoteObject> remote = Remote();
1113     if (remote == nullptr) {
1114         TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
1115         return WSError::WS_ERROR_IPC_FAILED;
1116     }
1117     if (remote->SendRequest(static_cast<uint32_t>(
1118         SceneSessionManagerMessage::TRANS_ID_PENDING_SESSION_TO_BACKGROUND_FOR_DELEGATOR),
1119         data, reply, option) != ERR_NONE) {
1120         TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed");
1121         return WSError::WS_ERROR_IPC_FAILED;
1122     }
1123     return static_cast<WSError>(reply.ReadInt32());
1124 }
1125 
RegisterSessionListener(const sptr<ISessionListener> & listener)1126 WSError SceneSessionManagerProxy::RegisterSessionListener(const sptr<ISessionListener>& listener)
1127 {
1128     WLOGFI("run SceneSessionManagerProxy::RegisterSessionListener");
1129     MessageParcel data;
1130     MessageParcel reply;
1131     MessageOption option(MessageOption::TF_SYNC);
1132     if (listener == nullptr) {
1133         WLOGFE("register mission listener, listener is nullptr");
1134         return WSError::WS_ERROR_INVALID_PARAM;
1135     }
1136     if (!data.WriteInterfaceToken(GetDescriptor())) {
1137         WLOGFE("WriteInterfaceToken failed");
1138         return WSError::WS_ERROR_IPC_FAILED;
1139     }
1140     if (!data.WriteRemoteObject(listener->AsObject())) {
1141         WLOGFE("write mission listener failed when register mission listener.");
1142         return WSError::WS_ERROR_IPC_FAILED;
1143     }
1144     sptr<IRemoteObject> remote = Remote();
1145     if (remote == nullptr) {
1146         WLOGFE("remote is null");
1147         return WSError::WS_ERROR_IPC_FAILED;
1148     }
1149     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REGISTER_SESSION_LISTENER),
1150         data, reply, option) != ERR_NONE) {
1151         WLOGFE("SendRequest failed");
1152         return WSError::WS_ERROR_IPC_FAILED;
1153     }
1154     return static_cast<WSError>(reply.ReadInt32());
1155 }
1156 
UnRegisterSessionListener(const sptr<ISessionListener> & listener)1157 WSError SceneSessionManagerProxy::UnRegisterSessionListener(const sptr<ISessionListener>& listener)
1158 {
1159     WLOGFI("run SceneSessionManagerProxy::UnRegisterSessionListener");
1160     if (listener == nullptr) {
1161         WLOGFE("unregister mission listener, listener is nullptr");
1162         return WSError::WS_ERROR_INVALID_PARAM;
1163     }
1164     MessageParcel data;
1165     MessageParcel reply;
1166     MessageOption option(MessageOption::TF_SYNC);
1167     if (!data.WriteInterfaceToken(GetDescriptor())) {
1168         WLOGFE("WriteInterfaceToken failed");
1169         return WSError::WS_ERROR_IPC_FAILED;
1170     }
1171     if (!data.WriteRemoteObject(listener->AsObject())) {
1172         WLOGFE("write mission listener failed when unregister mission listener.");
1173         return WSError::WS_ERROR_IPC_FAILED;
1174     }
1175     sptr<IRemoteObject> remote = Remote();
1176     if (remote == nullptr) {
1177         WLOGFE("remote is null");
1178         return WSError::WS_ERROR_IPC_FAILED;
1179     }
1180     if (remote->SendRequest(
1181         static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UNREGISTER_SESSION_LISTENER),
1182         data, reply, option) != ERR_NONE) {
1183         WLOGFE("SendRequest failed");
1184         return WSError::WS_ERROR_IPC_FAILED;
1185     }
1186     return static_cast<WSError>(reply.ReadInt32());
1187 }
1188 
GetSessionInfos(const std::string & deviceId,int32_t numMax,std::vector<SessionInfoBean> & sessionInfos)1189 WSError SceneSessionManagerProxy::GetSessionInfos(const std::string& deviceId, int32_t numMax,
1190                                                   std::vector<SessionInfoBean>& sessionInfos)
1191 {
1192     WLOGFI("run SceneSessionManagerProxy::GetSessionInfos");
1193     MessageParcel data;
1194     MessageParcel reply;
1195     MessageOption option(MessageOption::TF_SYNC);
1196     if (!data.WriteInterfaceToken(GetDescriptor())) {
1197         WLOGFE("WriteInterfaceToken failed");
1198         return WSError::WS_ERROR_IPC_FAILED;
1199     }
1200     if (!data.WriteString16(Str8ToStr16(deviceId))) {
1201         WLOGFE("GetSessionInfos write deviceId failed.");
1202         return WSError::WS_ERROR_IPC_FAILED;
1203     }
1204     if (!data.WriteInt32(numMax)) {
1205         WLOGFE("GetSessionInfos numMax write failed.");
1206         return WSError::WS_ERROR_IPC_FAILED;
1207     }
1208     sptr<IRemoteObject> remote = Remote();
1209     if (remote == nullptr) {
1210         WLOGFE("remote is null");
1211         return WSError::WS_ERROR_IPC_FAILED;
1212     }
1213     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_MISSION_INFOS),
1214         data, reply, option) != ERR_NONE) {
1215         WLOGFE("SendRequest failed");
1216         return WSError::WS_ERROR_IPC_FAILED;
1217     }
1218     WSError error = GetParcelableInfos(reply, sessionInfos);
1219     if (error != WSError::WS_OK) {
1220         WLOGFE("GetSessionInfos error");
1221         return error;
1222     }
1223     return static_cast<WSError>(reply.ReadInt32());
1224 }
1225 
GetSessionInfo(const std::string & deviceId,int32_t persistentId,SessionInfoBean & sessionInfo)1226 WSError SceneSessionManagerProxy::GetSessionInfo(const std::string& deviceId, int32_t persistentId,
1227                                                  SessionInfoBean& sessionInfo)
1228 {
1229     WLOGFI("run SceneSessionManagerProxy::GetSessionInfo");
1230     MessageParcel data;
1231     MessageParcel reply;
1232     MessageOption option(MessageOption::TF_SYNC);
1233     if (!data.WriteInterfaceToken(GetDescriptor())) {
1234         WLOGFE("WriteInterfaceToken failed");
1235         return WSError::WS_ERROR_IPC_FAILED;
1236     }
1237     if (!data.WriteString16(Str8ToStr16(deviceId))) {
1238         WLOGFE("GetSessionInfo write deviceId failed.");
1239         return WSError::WS_ERROR_IPC_FAILED;
1240     }
1241     if (!data.WriteInt32(persistentId)) {
1242         WLOGFE("GetSessionInfo write persistentId failed.");
1243         return WSError::WS_ERROR_IPC_FAILED;
1244     }
1245     sptr<IRemoteObject> remote = Remote();
1246     if (remote == nullptr) {
1247         WLOGFE("remote is null");
1248         return WSError::WS_ERROR_IPC_FAILED;
1249     }
1250     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_MISSION_INFO_BY_ID),
1251         data, reply, option) != ERR_NONE) {
1252         WLOGFE("SendRequest failed");
1253         return WSError::WS_ERROR_IPC_FAILED;
1254     }
1255     std::unique_ptr<SessionInfoBean> info(reply.ReadParcelable<SessionInfoBean>());
1256     if (info == nullptr) {
1257         WLOGFE("read missioninfo failed.");
1258         return WSError::WS_ERROR_IPC_FAILED;
1259     }
1260     sessionInfo = *info;
1261     return static_cast<WSError>(reply.ReadInt32());
1262 }
1263 
GetSessionInfoByContinueSessionId(const std::string & continueSessionId,SessionInfoBean & sessionInfo)1264 WSError SceneSessionManagerProxy::GetSessionInfoByContinueSessionId(
1265     const std::string& continueSessionId, SessionInfoBean& sessionInfo)
1266 {
1267     TLOGD(WmsLogTag::WMS_LIFE, "run query session info");
1268     MessageParcel data;
1269     MessageParcel reply;
1270     MessageOption option(MessageOption::TF_SYNC);
1271     if (!data.WriteInterfaceToken(GetDescriptor())) {
1272         TLOGE(WmsLogTag::WMS_LIFE, "WriteInterfaceToken failed");
1273         return WSError::WS_ERROR_IPC_FAILED;
1274     }
1275     if (!data.WriteString(continueSessionId)) {
1276         TLOGE(WmsLogTag::WMS_LIFE, "GetSessionInfoByContinueSessionId write continueSessionId failed.");
1277         return WSError::WS_ERROR_IPC_FAILED;
1278     }
1279     sptr<IRemoteObject> remote = Remote();
1280     if (remote == nullptr) {
1281         TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
1282         return WSError::WS_ERROR_IPC_FAILED;
1283     }
1284     if (remote->SendRequest(static_cast<uint32_t>(
1285         SceneSessionManagerMessage::TRANS_ID_GET_SESSION_INFO_BY_CONTINUE_SESSION_ID),
1286         data, reply, option) != ERR_NONE) {
1287         TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed");
1288         return WSError::WS_ERROR_IPC_FAILED;
1289     }
1290     sptr<SessionInfoBean> info(reply.ReadParcelable<SessionInfoBean>());
1291     if (info == nullptr) {
1292         TLOGE(WmsLogTag::WMS_LIFE, "read sessioninfo failed.");
1293         return WSError::WS_ERROR_IPC_FAILED;
1294     }
1295     sessionInfo = *info;
1296     return static_cast<WSError>(reply.ReadInt32());
1297 }
1298 
DumpSessionAll(std::vector<std::string> & infos)1299 WSError SceneSessionManagerProxy::DumpSessionAll(std::vector<std::string>& infos)
1300 {
1301     WLOGFI("run SceneSessionManagerProxy::DumpSessionAll");
1302     MessageParcel data;
1303     MessageParcel reply;
1304     MessageOption option(MessageOption::TF_SYNC);
1305     if (!data.WriteInterfaceToken(GetDescriptor())) {
1306         WLOGFE("DumpSessionAll write interface token failed.");
1307         return WSError::WS_ERROR_IPC_FAILED;
1308     }
1309     sptr<IRemoteObject> remote = Remote();
1310     if (remote == nullptr) {
1311         WLOGFE("remote is null");
1312         return WSError::WS_ERROR_IPC_FAILED;
1313     }
1314     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_DUMP_SESSION_ALL),
1315         data, reply, option) != ERR_NONE) {
1316         WLOGFE("DumpSessionAll sendRequest failed.");
1317         return WSError::WS_ERROR_IPC_FAILED;
1318     }
1319     if (!reply.ReadStringVector(&infos)) {
1320         WLOGFE("DumpSessionAll read session info failed.");
1321         return WSError::WS_ERROR_IPC_FAILED;
1322     }
1323     return static_cast<WSError>(reply.ReadInt32());
1324 }
1325 
DumpSessionWithId(int32_t persistentId,std::vector<std::string> & infos)1326 WSError SceneSessionManagerProxy::DumpSessionWithId(int32_t persistentId, std::vector<std::string>& infos)
1327 {
1328     WLOGFI("run SceneSessionManagerProxy::DumpSessionWithId");
1329     MessageParcel data;
1330     MessageParcel reply;
1331     MessageOption option(MessageOption::TF_SYNC);
1332     if (!data.WriteInterfaceToken(GetDescriptor())) {
1333         WLOGFE("DumpSessionWithId write interface token failed.");
1334         return WSError::WS_ERROR_IPC_FAILED;
1335     }
1336     if (!data.WriteInt32(persistentId)) {
1337         WLOGFE("DumpSessionWithId write persistentId failed.");
1338         return WSError::WS_ERROR_IPC_FAILED;
1339     }
1340     sptr<IRemoteObject> remote = Remote();
1341     if (remote == nullptr) {
1342         WLOGFE("remote is null");
1343         return WSError::WS_ERROR_IPC_FAILED;
1344     }
1345     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_DUMP_SESSION_WITH_ID),
1346         data, reply, option) != ERR_NONE) {
1347         WLOGFE("DumpSessionWithId sendRequest failed.");
1348         return WSError::WS_ERROR_IPC_FAILED;
1349     }
1350     if (!reply.ReadStringVector(&infos)) {
1351         WLOGFE("DumpSessionWithId read session info failed.");
1352         return WSError::WS_ERROR_IPC_FAILED;
1353     }
1354     return static_cast<WSError>(reply.ReadInt32());
1355 }
1356 
1357 template<typename T>
GetParcelableInfos(MessageParcel & reply,std::vector<T> & parcelableInfos)1358 WSError SceneSessionManagerProxy::GetParcelableInfos(MessageParcel& reply, std::vector<T>& parcelableInfos)
1359 {
1360     int32_t infoSize = reply.ReadInt32();
1361     if (infoSize > CYCLE_LIMIT || infoSize < 0) {
1362         WLOGFE("infoSize is too large or negative");
1363         return WSError::WS_ERROR_IPC_FAILED;
1364     }
1365 
1366     for (int32_t i = 0; i < infoSize; i++) {
1367         std::unique_ptr<T> info(reply.ReadParcelable<T>());
1368         if (!info) {
1369             WLOGFE("Read Parcelable infos failed.");
1370             return WSError::WS_ERROR_IPC_FAILED;
1371         }
1372         parcelableInfos.emplace_back(*info);
1373     }
1374     return WSError::WS_OK;
1375 }
1376 
TerminateSessionNew(const sptr<AAFwk::SessionInfo> abilitySessionInfo,bool needStartCaller,bool isFromBroker)1377 WSError SceneSessionManagerProxy::TerminateSessionNew(const sptr<AAFwk::SessionInfo> abilitySessionInfo,
1378     bool needStartCaller, bool isFromBroker)
1379 {
1380     if (abilitySessionInfo == nullptr) {
1381         WLOGFE("abilitySessionInfo is null");
1382         return WSError::WS_ERROR_INVALID_SESSION;
1383     }
1384     MessageParcel data, reply;
1385     MessageOption option(MessageOption::TF_ASYNC);
1386     if (!data.WriteInterfaceToken(GetDescriptor())) {
1387         WLOGFE("WriteInterfaceToken failed");
1388         return WSError::WS_ERROR_IPC_FAILED;
1389     }
1390     if (!data.WriteParcelable(abilitySessionInfo)) {
1391         WLOGFE("write abilitySessionInfo failed");
1392         return WSError::WS_ERROR_IPC_FAILED;
1393     }
1394     if (!data.WriteBool(needStartCaller)) {
1395         WLOGFE("Write needStartCaller failed");
1396         return WSError::WS_ERROR_IPC_FAILED;
1397     }
1398     if (!data.WriteBool(isFromBroker)) {
1399         WLOGFE("Write isFromBroker failed");
1400         return WSError::WS_ERROR_IPC_FAILED;
1401     }
1402     sptr<IRemoteObject> remote = Remote();
1403     if (remote == nullptr) {
1404         WLOGFE("remote is null");
1405         return WSError::WS_ERROR_IPC_FAILED;
1406     }
1407     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_TERMINATE_SESSION_NEW),
1408         data, reply, option) != ERR_NONE) {
1409         WLOGFE("SendRequest failed");
1410         return WSError::WS_ERROR_IPC_FAILED;
1411     }
1412     return static_cast<WSError>(reply.ReadInt32());
1413 }
1414 
GetFocusSessionToken(sptr<IRemoteObject> & token,DisplayId displayId)1415 WSError SceneSessionManagerProxy::GetFocusSessionToken(sptr<IRemoteObject>& token, DisplayId displayId)
1416 {
1417     WLOGFD("run SceneSessionManagerProxy::GetFocusSessionToken");
1418     MessageParcel data;
1419     MessageParcel reply;
1420     MessageOption option;
1421     if (!data.WriteInterfaceToken(GetDescriptor())) {
1422         WLOGFE("Write interfaceToken failed");
1423         return WSError::WS_ERROR_IPC_FAILED;
1424     }
1425     if (!data.WriteUint64(displayId)) {
1426         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write displayId failed");
1427         return WSError::WS_ERROR_IPC_FAILED;
1428     }
1429     sptr<IRemoteObject> remote = Remote();
1430     if (remote == nullptr) {
1431         WLOGFE("remote is null");
1432         return WSError::WS_ERROR_IPC_FAILED;
1433     }
1434     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_FOCUS_SESSION_TOKEN),
1435         data, reply, option) != ERR_NONE) {
1436         WLOGFE("SendRequest failed");
1437         return WSError::WS_ERROR_IPC_FAILED;
1438     }
1439     token = reply.ReadRemoteObject();
1440     if (token == nullptr) {
1441         WLOGFD("get token nullptr.");
1442     }
1443     return static_cast<WSError>(reply.ReadInt32());
1444 }
1445 
GetFocusSessionElement(AppExecFwk::ElementName & element,DisplayId displayId)1446 WSError SceneSessionManagerProxy::GetFocusSessionElement(AppExecFwk::ElementName& element, DisplayId displayId)
1447 {
1448     WLOGFD("run SceneSessionManagerProxy::GetFocusSessionElement");
1449     MessageParcel data;
1450     MessageParcel reply;
1451     MessageOption option;
1452     if (!data.WriteInterfaceToken(GetDescriptor())) {
1453         WLOGFE("Write interfaceToken failed");
1454         return WSError::WS_ERROR_IPC_FAILED;
1455     }
1456     if (!data.WriteUint64(displayId)) {
1457         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write displayId failed");
1458         return WSError::WS_ERROR_IPC_FAILED;
1459     }
1460     sptr<IRemoteObject> remote = Remote();
1461     if (remote == nullptr) {
1462         WLOGFE("remote is null");
1463         return WSError::WS_ERROR_IPC_FAILED;
1464     }
1465     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_FOCUS_SESSION_ELEMENT),
1466         data, reply, option) != ERR_NONE) {
1467         WLOGFE("SendRequest failed");
1468         return WSError::WS_ERROR_IPC_FAILED;
1469     }
1470     sptr<AppExecFwk::ElementName> ret = reply.ReadParcelable<AppExecFwk::ElementName>();
1471     if (ret) {
1472         element = *ret;
1473     } else {
1474         WLOGFD("get element null.");
1475     }
1476     return static_cast<WSError>(reply.ReadInt32());
1477 }
1478 
CheckWindowId(int32_t windowId,int32_t & pid)1479 WMError SceneSessionManagerProxy::CheckWindowId(int32_t windowId, int32_t& pid)
1480 {
1481     MessageParcel data;
1482     MessageParcel reply;
1483     MessageOption option;
1484     if (!data.WriteInterfaceToken(GetDescriptor())) {
1485         WLOGFE("Failed to write interfaceToken");
1486         return WMError::WM_ERROR_IPC_FAILED;
1487     }
1488     if (!data.WriteInt32(windowId)) {
1489         WLOGFE("Failed to write windowId");
1490         return WMError::WM_ERROR_IPC_FAILED;
1491     }
1492     sptr<IRemoteObject> remote = Remote();
1493     if (remote == nullptr) {
1494         WLOGFE("remote is nullptr");
1495         return WMError::WM_ERROR_NULLPTR;
1496     }
1497     int32_t ret = remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_CHECK_WINDOW_ID),
1498         data, reply, option);
1499     if (ret != ERR_NONE) {
1500         WLOGFE("Send request failed, ret:%{public}d", ret);
1501         return WMError::WM_ERROR_IPC_FAILED;
1502     }
1503     if (!reply.ReadInt32(pid)) {
1504         WLOGFE("Failed to read pid");
1505         return WMError::WM_ERROR_IPC_FAILED;
1506     }
1507     return WMError::WM_OK;
1508 }
1509 
GetSessionDumpInfo(const std::vector<std::string> & params,std::string & info)1510 WSError SceneSessionManagerProxy::GetSessionDumpInfo(const std::vector<std::string>& params, std::string& info)
1511 {
1512     MessageParcel data;
1513     MessageParcel reply;
1514     MessageOption option;
1515     if (!data.WriteInterfaceToken(GetDescriptor())) {
1516         WLOGFE("WriteInterfaceToken failed");
1517         return WSError::WS_ERROR_INVALID_PARAM;
1518     }
1519     if (!data.WriteStringVector(params)) {
1520         WLOGFE("Write params failed");
1521         return WSError::WS_ERROR_IPC_FAILED;
1522     }
1523     sptr<IRemoteObject> remote = Remote();
1524     if (remote == nullptr) {
1525         WLOGFE("remote is null");
1526         return WSError::WS_ERROR_IPC_FAILED;
1527     }
1528     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_SESSION_DUMP_INFO),
1529         data, reply, option) != ERR_NONE) {
1530         WLOGFE("SendRequest failed");
1531         return WSError::WS_ERROR_IPC_FAILED;
1532     }
1533 
1534     auto infoSize = reply.ReadUint32();
1535     if (infoSize != 0) {
1536         const char* infoPtr = nullptr;
1537         infoPtr = reinterpret_cast<const char*>(reply.ReadRawData(infoSize));
1538         info = (infoPtr) ? std::string(infoPtr, infoSize) : "";
1539     }
1540     WLOGFD("GetSessionDumpInfo, infoSize: %{public}d", infoSize);
1541     return static_cast<WSError>(reply.ReadInt32());
1542 }
1543 
GetSessionSnapshot(const std::string & deviceId,int32_t persistentId,SessionSnapshot & snapshot,bool isLowResolution)1544 WSError SceneSessionManagerProxy::GetSessionSnapshot(const std::string& deviceId, int32_t persistentId,
1545                                                      SessionSnapshot& snapshot, bool isLowResolution)
1546 {
1547     MessageParcel data;
1548     MessageParcel reply;
1549     MessageOption option;
1550     if (!data.WriteInterfaceToken(GetDescriptor())) {
1551         WLOGFE("WriteInterfaceToken failed");
1552         return WSError::WS_ERROR_INVALID_PARAM;
1553     }
1554     if (!data.WriteString16(Str8ToStr16(deviceId))) {
1555         WLOGFE("Write deviceId failed.");
1556         return WSError::WS_ERROR_IPC_FAILED;
1557     }
1558     if (!data.WriteInt32(persistentId)) {
1559         WLOGFE("Write persistentId failed");
1560         return WSError::WS_ERROR_INVALID_PARAM;
1561     }
1562 
1563     if (!data.WriteBool(isLowResolution)) {
1564         WLOGFE("Write isLowResolution failed");
1565         return WSError::WS_ERROR_INVALID_PARAM;
1566     }
1567 
1568     sptr<IRemoteObject> remote = Remote();
1569     if (remote == nullptr) {
1570         WLOGFE("remote is null");
1571         return WSError::WS_ERROR_IPC_FAILED;
1572     }
1573     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_SESSION_SNAPSHOT),
1574         data, reply, option) != ERR_NONE) {
1575         WLOGFE("SendRequest failed");
1576         return WSError::WS_ERROR_IPC_FAILED;
1577     }
1578     std::unique_ptr<SessionSnapshot> info(reply.ReadParcelable<SessionSnapshot>());
1579     if (info) {
1580         snapshot = *info;
1581     } else {
1582         WLOGFW("Read SessionSnapshot is null.");
1583     }
1584     return static_cast<WSError>(reply.ReadInt32());
1585 }
1586 
GetUIContentRemoteObj(int32_t persistentId,sptr<IRemoteObject> & uiContentRemoteObj)1587 WSError SceneSessionManagerProxy::GetUIContentRemoteObj(int32_t persistentId, sptr<IRemoteObject>& uiContentRemoteObj)
1588 {
1589     MessageParcel data;
1590     MessageParcel reply;
1591     MessageOption option;
1592     if (!data.WriteInterfaceToken(GetDescriptor())) {
1593         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "WriteInterfaceToken failed");
1594         return WSError::WS_ERROR_INVALID_PARAM;
1595     }
1596     if (!data.WriteInt32(persistentId)) {
1597         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write persistentId failed");
1598         return WSError::WS_ERROR_INVALID_PARAM;
1599     }
1600 
1601     sptr<IRemoteObject> remote = Remote();
1602     if (remote == nullptr) {
1603         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
1604         return WSError::WS_ERROR_IPC_FAILED;
1605     }
1606     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_UI_CONTENT_REMOTE_OBJ),
1607         data, reply, option) != ERR_NONE) {
1608         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
1609         return WSError::WS_ERROR_IPC_FAILED;
1610     }
1611     sptr<IRemoteObject> remoteObj = reply.ReadRemoteObject();
1612     if (remoteObj == nullptr) {
1613         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "ReadRemoteObject failed");
1614         return WSError::WS_ERROR_IPC_FAILED;
1615     }
1616     uiContentRemoteObj = remoteObj;
1617     return static_cast<WSError>(reply.ReadUint32());
1618 }
1619 
SetSessionContinueState(const sptr<IRemoteObject> & token,const ContinueState & continueState)1620 WSError SceneSessionManagerProxy::SetSessionContinueState(const sptr<IRemoteObject>& token,
1621     const ContinueState& continueState)
1622 {
1623     MessageParcel data;
1624     MessageParcel reply;
1625     MessageOption option;
1626     if (!data.WriteInterfaceToken(GetDescriptor())) {
1627         WLOGFE("WriteInterfaceToken failed");
1628         return WSError::WS_ERROR_INVALID_PARAM;
1629     }
1630     if (!data.WriteRemoteObject(token)) {
1631         WLOGFE("Write token failed");
1632         return WSError::WS_ERROR_IPC_FAILED;
1633     }
1634     if (!data.WriteInt32(static_cast<int32_t>(continueState))) {
1635         WLOGFE("Write continueState failed");
1636         return WSError::WS_ERROR_IPC_FAILED;
1637     }
1638     sptr<IRemoteObject> remote = Remote();
1639     if (remote == nullptr) {
1640         WLOGFE("remote is null");
1641         return WSError::WS_ERROR_IPC_FAILED;
1642     }
1643     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_SESSION_CONTINUE_STATE),
1644         data, reply, option) != ERR_NONE) {
1645         WLOGFE("SendRequest failed");
1646         return WSError::WS_ERROR_IPC_FAILED;
1647     }
1648     return static_cast<WSError>(reply.ReadInt32());
1649 }
1650 
NotifyDumpInfoResult(const std::vector<std::string> & info)1651 void SceneSessionManagerProxy::NotifyDumpInfoResult(const std::vector<std::string>& info)
1652 {
1653     MessageParcel data;
1654     MessageParcel reply;
1655     MessageOption option(MessageOption::TF_ASYNC);
1656     if (!data.WriteInterfaceToken(GetDescriptor())) {
1657         WLOGFE("WriteInterfaceToken pfailed");
1658         return;
1659     }
1660     uint32_t vectorSize = static_cast<uint32_t>(info.size());
1661     if (!data.WriteUint32(vectorSize)) {
1662         WLOGFE("Write vector size failed");
1663         return;
1664     }
1665     for (const auto& elem : info) {
1666         uint32_t curSize = static_cast<uint32_t>(elem.length());
1667         WLOGFD("NotifyDumpInfoResult infoSize: %{public}u", curSize);
1668         if (!data.WriteUint32(curSize)) {
1669             WLOGFE("Write info size failed");
1670             return;
1671         }
1672         if (curSize != 0) {
1673             if (!data.WriteRawData(elem.c_str(), curSize)) {
1674                 WLOGFE("Write info failed");
1675                 return;
1676             }
1677         }
1678     }
1679     sptr<IRemoteObject> remote = Remote();
1680     if (remote == nullptr) {
1681         WLOGFE("remote is null");
1682         return;
1683     }
1684     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_NOTIFY_DUMP_INFO_RESULT),
1685         data, reply, option) != ERR_NONE) {
1686         WLOGFE("SendRequest failed");
1687         return;
1688     }
1689 }
1690 
LockSession(int32_t sessionId)1691 WSError SceneSessionManagerProxy::LockSession(int32_t sessionId)
1692 {
1693     WLOGFI("run SceneSessionManagerProxy::LockSession");
1694     MessageParcel data;
1695     MessageParcel reply;
1696     MessageOption option;
1697 
1698     if (!data.WriteInterfaceToken(GetDescriptor())) {
1699         WLOGFE("Write interface token failed.");
1700         return WSError::WS_ERROR_INVALID_PARAM;
1701     }
1702     if (!data.WriteInt32(sessionId)) {
1703         WLOGFE("Write persistentId failed");
1704         return WSError::WS_ERROR_INVALID_PARAM;
1705     }
1706     sptr<IRemoteObject> remote = Remote();
1707     if (remote == nullptr) {
1708         WLOGFE("remote is null");
1709         return WSError::WS_ERROR_IPC_FAILED;
1710     }
1711     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_LOCK_SESSION),
1712         data, reply, option) != ERR_NONE) {
1713         WLOGFE("SendRequest failed");
1714         return WSError::WS_ERROR_IPC_FAILED;
1715     }
1716     return static_cast<WSError>(reply.ReadInt32());
1717 }
1718 
UnlockSession(int32_t sessionId)1719 WSError SceneSessionManagerProxy::UnlockSession(int32_t sessionId)
1720 {
1721     WLOGFI("run SceneSessionManagerProxy::UnlockSession");
1722     MessageParcel data;
1723     MessageParcel reply;
1724     MessageOption option;
1725 
1726     if (!data.WriteInterfaceToken(GetDescriptor())) {
1727         WLOGFE("Write interface token failed.");
1728         return WSError::WS_ERROR_INVALID_PARAM;
1729     }
1730     if (!data.WriteInt32(sessionId)) {
1731         WLOGFE("Write persistentId failed");
1732         return WSError::WS_ERROR_INVALID_PARAM;
1733     }
1734     sptr<IRemoteObject> remote = Remote();
1735     if (remote == nullptr) {
1736         WLOGFE("remote is null");
1737         return WSError::WS_ERROR_IPC_FAILED;
1738     }
1739     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UNLOCK_SESSION),
1740         data, reply, option) != ERR_NONE) {
1741         WLOGFE("SendRequest failed");
1742         return WSError::WS_ERROR_IPC_FAILED;
1743     }
1744     return static_cast<WSError>(reply.ReadInt32());
1745 }
1746 
MoveSessionsToForeground(const std::vector<std::int32_t> & sessionIds,int32_t topSessionId)1747 WSError SceneSessionManagerProxy::MoveSessionsToForeground(const std::vector<std::int32_t>& sessionIds,
1748     int32_t topSessionId)
1749 {
1750     WLOGFI("run SceneSessionManagerProxy::MoveSessionsToForeground");
1751     MessageParcel data;
1752     MessageParcel reply;
1753     MessageOption option;
1754     if (!data.WriteInterfaceToken(GetDescriptor())) {
1755         WLOGFE("WriteInterfaceToken failed");
1756         return WSError::WS_ERROR_INVALID_PARAM;
1757     }
1758     if (!data.WriteInt32Vector(sessionIds)) {
1759         WLOGFE("Write sessionIds failed");
1760         return WSError::WS_ERROR_INVALID_PARAM;
1761     }
1762     if (!data.WriteInt32(topSessionId)) {
1763         WLOGFE("Write topSessionId failed");
1764         return WSError::WS_ERROR_INVALID_PARAM;
1765     }
1766     sptr<IRemoteObject> remote = Remote();
1767     if (remote == nullptr) {
1768         WLOGFE("remote is null");
1769         return WSError::WS_ERROR_IPC_FAILED;
1770     }
1771     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_MOVE_MISSIONS_TO_FOREGROUND),
1772         data, reply, option) != ERR_NONE) {
1773         WLOGFE("SendRequest failed");
1774         return WSError::WS_ERROR_IPC_FAILED;
1775     }
1776     return static_cast<WSError>(reply.ReadInt32());
1777 }
1778 
MoveSessionsToBackground(const std::vector<std::int32_t> & sessionIds,std::vector<int32_t> & result)1779 WSError SceneSessionManagerProxy::MoveSessionsToBackground(const std::vector<std::int32_t>& sessionIds,
1780     std::vector<int32_t>& result)
1781 {
1782     WLOGFI("run SceneSessionManagerProxy::MoveSessionsToBackground");
1783     MessageParcel data;
1784     MessageParcel reply;
1785     MessageOption option;
1786     if (!data.WriteInterfaceToken(GetDescriptor())) {
1787         WLOGFE("WriteInterfaceToken failed");
1788         return WSError::WS_ERROR_INVALID_PARAM;
1789     }
1790     if (!data.WriteInt32Vector(sessionIds)) {
1791         WLOGFE("Write sessionIds failed");
1792         return WSError::WS_ERROR_INVALID_PARAM;
1793     }
1794     if (!data.WriteInt32Vector(result)) {
1795         WLOGFE("Write result failed");
1796         return WSError::WS_ERROR_INVALID_PARAM;
1797     }
1798     sptr<IRemoteObject> remote = Remote();
1799     if (remote == nullptr) {
1800         WLOGFE("remote is null");
1801         return WSError::WS_ERROR_IPC_FAILED;
1802     }
1803     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_MOVE_MISSIONS_TO_BACKGROUND),
1804         data, reply, option) != ERR_NONE) {
1805         WLOGFE("SendRequest failed");
1806         return WSError::WS_ERROR_IPC_FAILED;
1807     }
1808     reply.ReadInt32Vector(&result);
1809     return static_cast<WSError>(reply.ReadInt32());
1810 }
1811 
ClearSession(int32_t persistentId)1812 WSError SceneSessionManagerProxy::ClearSession(int32_t persistentId)
1813 {
1814     WLOGFI("run SceneSessionManagerProxy::ClearSession");
1815     MessageParcel data;
1816     MessageParcel reply;
1817     MessageOption option;
1818     if (!data.WriteInterfaceToken(GetDescriptor())) {
1819         WLOGFE("ClearSession WriteInterfaceToken failed");
1820         return WSError::WS_ERROR_INVALID_PARAM;
1821     }
1822 
1823     if (!data.WriteInt32(persistentId)) {
1824         WLOGFE("Write persistentId failed");
1825         return WSError::WS_ERROR_INVALID_PARAM;
1826     }
1827 
1828     sptr<IRemoteObject> remote = Remote();
1829     if (remote == nullptr) {
1830         WLOGFE("remote is null");
1831         return WSError::WS_ERROR_IPC_FAILED;
1832     }
1833     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_CLEAR_SESSION),
1834         data, reply, option) != ERR_NONE) {
1835         WLOGFE("SendRequest failed");
1836         return WSError::WS_ERROR_IPC_FAILED;
1837     }
1838     return static_cast<WSError>(reply.ReadInt32());
1839 }
1840 
ClearAllSessions()1841 WSError SceneSessionManagerProxy::ClearAllSessions()
1842 {
1843     WLOGFI("run SceneSessionManagerProxy::ClearSession");
1844     MessageParcel data;
1845     MessageParcel reply;
1846     MessageOption option;
1847     if (!data.WriteInterfaceToken(GetDescriptor())) {
1848         WLOGFE("ClearAllSessions WriteInterfaceToken failed");
1849         return WSError::WS_ERROR_INVALID_PARAM;
1850     }
1851 
1852     sptr<IRemoteObject> remote = Remote();
1853     if (remote == nullptr) {
1854         WLOGFE("remote is null");
1855         return WSError::WS_ERROR_IPC_FAILED;
1856     }
1857     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_CLEAR_ALL_SESSIONS),
1858         data, reply, option) != ERR_NONE) {
1859         WLOGFE("SendRequest failed");
1860         return WSError::WS_ERROR_IPC_FAILED;
1861     }
1862     return static_cast<WSError>(reply.ReadInt32());
1863 }
1864 
RegisterIAbilityManagerCollaborator(int32_t type,const sptr<AAFwk::IAbilityManagerCollaborator> & impl)1865 WSError SceneSessionManagerProxy::RegisterIAbilityManagerCollaborator(int32_t type,
1866     const sptr<AAFwk::IAbilityManagerCollaborator>& impl)
1867 {
1868     WLOGFI("run SceneSessionManagerProxy::RegisterIAbilityManagerCollaborator");
1869     if (!impl) {
1870         WLOGFE("impl is nullptr");
1871         return WSError::WS_ERROR_INVALID_PARAM;
1872     }
1873     MessageParcel data;
1874     MessageParcel reply;
1875     MessageOption option;
1876 
1877     if (!data.WriteInterfaceToken(GetDescriptor())) {
1878         WLOGFE("Write interface token failed.");
1879         return WSError::WS_ERROR_INVALID_PARAM;
1880     }
1881     if (!data.WriteInt32(type)) {
1882         WLOGFE("type write failed.");
1883         return WSError::WS_ERROR_INVALID_PARAM;
1884     }
1885     if (!data.WriteRemoteObject(impl->AsObject())) {
1886         WLOGFE("impl write failed.");
1887         return WSError::WS_ERROR_INVALID_PARAM;
1888     }
1889 
1890     sptr<IRemoteObject> remote = Remote();
1891     if (remote == nullptr) {
1892         WLOGFE("remote is null");
1893         return WSError::WS_ERROR_IPC_FAILED;
1894     }
1895     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REGISTER_COLLABORATOR),
1896         data, reply, option) != ERR_NONE) {
1897         WLOGFE("SendRequest failed");
1898         return WSError::WS_ERROR_IPC_FAILED;
1899     }
1900     return static_cast<WSError>(reply.ReadInt32());
1901 }
1902 
UnregisterIAbilityManagerCollaborator(int32_t type)1903 WSError SceneSessionManagerProxy::UnregisterIAbilityManagerCollaborator(int32_t type)
1904 {
1905     WLOGFI("run SceneSessionManagerProxy::UnregisterIAbilityManagerCollaborator");
1906     MessageParcel data;
1907     MessageParcel reply;
1908     MessageOption option;
1909 
1910     if (!data.WriteInterfaceToken(GetDescriptor())) {
1911         WLOGFE("Write interface token failed.");
1912         return WSError::WS_ERROR_INVALID_PARAM;
1913     }
1914     if (!data.WriteInt32(type)) {
1915         WLOGFE("type write failed.");
1916         return WSError::WS_ERROR_INVALID_PARAM;
1917     }
1918 
1919     sptr<IRemoteObject> remote = Remote();
1920     if (remote == nullptr) {
1921         WLOGFE("remote is null");
1922         return WSError::WS_ERROR_IPC_FAILED;
1923     }
1924     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UNREGISTER_COLLABORATOR),
1925         data, reply, option) != ERR_NONE) {
1926         WLOGFE("SendRequest failed");
1927         return WSError::WS_ERROR_IPC_FAILED;
1928     }
1929     return static_cast<WSError>(reply.ReadInt32());
1930 }
1931 
NotifyWindowExtensionVisibilityChange(int32_t pid,int32_t uid,bool visible)1932 WSError SceneSessionManagerProxy::NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible)
1933 {
1934     WLOGFI("run SceneSessionManagerProxy::NotifyWindowExtensionVisibilityChange");
1935     MessageParcel data;
1936     MessageParcel reply;
1937     MessageOption option(MessageOption::TF_ASYNC);
1938 
1939     if (!data.WriteInterfaceToken(GetDescriptor())) {
1940         WLOGFE("Write interface token failed.");
1941         return WSError::WS_ERROR_INVALID_PARAM;
1942     }
1943 
1944     if (!data.WriteInt32(pid)) {
1945         WLOGFE("pid write failed.");
1946         return WSError::WS_ERROR_INVALID_PARAM;
1947     }
1948 
1949     if (!data.WriteInt32(uid)) {
1950         WLOGFE("uid write failed.");
1951         return WSError::WS_ERROR_INVALID_PARAM;
1952     }
1953     if (!data.WriteBool(visible)) {
1954         WLOGFE("pid write failed.");
1955         return WSError::WS_ERROR_INVALID_PARAM;
1956     }
1957 
1958     sptr<IRemoteObject> remote = Remote();
1959     if (remote == nullptr) {
1960         WLOGFE("remote is null");
1961         return WSError::WS_ERROR_IPC_FAILED;
1962     }
1963     if (remote->SendRequest(static_cast<uint32_t>(
1964         SceneSessionManagerMessage::TRANS_ID_NOTIFY_WINDOW_EXTENSION_VISIBILITY_CHANGE),
1965         data, reply, option) != ERR_NONE) {
1966         WLOGFE("SendRequest failed");
1967         return WSError::WS_ERROR_IPC_FAILED;
1968     }
1969     return static_cast<WSError>(reply.ReadInt32());
1970 }
1971 
GetTopWindowId(uint32_t mainWinId,uint32_t & topWinId)1972 WMError SceneSessionManagerProxy::GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId)
1973 {
1974     WLOGFD("[GetTopWin] mainId: %{public}d", mainWinId);
1975     MessageParcel data;
1976     MessageParcel reply;
1977     MessageOption option;
1978     if (!data.WriteInterfaceToken(GetDescriptor())) {
1979         WLOGFE("Write interface token failed.");
1980         return WMError::WM_ERROR_IPC_FAILED;
1981     }
1982 
1983     if (!data.WriteUint32(mainWinId)) {
1984         WLOGFE("Write mainWinId failed");
1985         return WMError::WM_ERROR_IPC_FAILED;
1986     }
1987 
1988     sptr<IRemoteObject> remote = Remote();
1989     if (remote == nullptr) {
1990         WLOGFE("remote is null");
1991         return WMError::WM_ERROR_IPC_FAILED;
1992     }
1993     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_TOP_WINDOW_ID),
1994         data, reply, option) != ERR_NONE) {
1995         WLOGFE("SendRequest failed");
1996         return WMError::WM_ERROR_IPC_FAILED;
1997     }
1998 
1999     topWinId = reply.ReadUint32();
2000     int32_t ret = reply.ReadInt32();
2001     return static_cast<WMError>(ret);
2002 }
2003 
NotifyWatchGestureConsumeResult(int32_t keyCode,bool isConsumed)2004 WMError SceneSessionManagerProxy::NotifyWatchGestureConsumeResult(int32_t keyCode, bool isConsumed)
2005 {
2006     TLOGD(WmsLogTag::WMS_EVENT, "keyCode:%{public}d isConsumed:%{public}d", keyCode, isConsumed);
2007     MessageParcel data;
2008     MessageParcel reply;
2009     MessageOption option;
2010     if (!data.WriteInterfaceToken(GetDescriptor())) {
2011         TLOGE(WmsLogTag::WMS_EVENT, "Write interface token failed.");
2012         return WMError::WM_ERROR_IPC_FAILED;
2013     }
2014     if (!data.WriteInt32(keyCode)) {
2015         TLOGE(WmsLogTag::WMS_EVENT, "Write keyCode failed");
2016         return WMError::WM_ERROR_IPC_FAILED;
2017     }
2018     if (!data.WriteBool(isConsumed)) {
2019         TLOGE(WmsLogTag::WMS_EVENT, "Write isConsumed failed");
2020         return WMError::WM_ERROR_IPC_FAILED;
2021     }
2022 
2023     sptr<IRemoteObject> remote = Remote();
2024     if (remote == nullptr) {
2025         TLOGE(WmsLogTag::WMS_EVENT, "remote is null");
2026         return WMError::WM_ERROR_IPC_FAILED;
2027     }
2028     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_WATCH_GESTURE_CONSUME_RESULT),
2029         data, reply, option) != ERR_NONE) {
2030         TLOGE(WmsLogTag::WMS_EVENT, "SendRequest failed");
2031         return WMError::WM_ERROR_IPC_FAILED;
2032     }
2033     int32_t ret = 0;
2034     if (!reply.ReadInt32(ret)) {
2035         return WMError::WM_ERROR_IPC_FAILED;
2036     }
2037     return static_cast<WMError>(ret);
2038 }
2039 
NotifyWatchFocusActiveChange(bool isActive)2040 WMError SceneSessionManagerProxy::NotifyWatchFocusActiveChange(bool isActive)
2041 {
2042     TLOGD(WmsLogTag::WMS_EVENT, "isActive:%{public}d", isActive);
2043     MessageParcel data;
2044     MessageParcel reply;
2045     MessageOption option;
2046     if (!data.WriteInterfaceToken(GetDescriptor())) {
2047         TLOGE(WmsLogTag::WMS_EVENT, "Write interface token failed.");
2048         return WMError::WM_ERROR_IPC_FAILED;
2049     }
2050     if (!data.WriteBool(isActive)) {
2051         TLOGE(WmsLogTag::WMS_EVENT, "Write isActive failed");
2052         return WMError::WM_ERROR_IPC_FAILED;
2053     }
2054 
2055     sptr<IRemoteObject> remote = Remote();
2056     if (remote == nullptr) {
2057         TLOGE(WmsLogTag::WMS_EVENT, "remote is null");
2058         return WMError::WM_ERROR_IPC_FAILED;
2059     }
2060     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_WATCH_FOCUS_ACTIVE_CHANGE),
2061         data, reply, option) != ERR_NONE) {
2062         TLOGE(WmsLogTag::WMS_EVENT, "SendRequest failed");
2063         return WMError::WM_ERROR_IPC_FAILED;
2064     }
2065     int32_t ret = 0;
2066     if (!reply.ReadInt32(ret)) {
2067         return WMError::WM_ERROR_IPC_FAILED;
2068     }
2069     return static_cast<WMError>(ret);
2070 }
2071 
GetParentMainWindowId(int32_t windowId,int32_t & mainWindowId)2072 WMError SceneSessionManagerProxy::GetParentMainWindowId(int32_t windowId, int32_t& mainWindowId)
2073 {
2074     MessageParcel data;
2075     MessageParcel reply;
2076     MessageOption option(MessageOption::TF_SYNC);
2077     if (!data.WriteInterfaceToken(GetDescriptor())) {
2078         TLOGE(WmsLogTag::WMS_SUB, "WriteInterfaceToken failed");
2079         return WMError::WM_ERROR_IPC_FAILED;
2080     }
2081     if (!data.WriteInt32(windowId)) {
2082         TLOGE(WmsLogTag::WMS_SUB, "Write windowId failed");
2083         return WMError::WM_ERROR_IPC_FAILED;
2084     }
2085     sptr<IRemoteObject> remote = Remote();
2086     if (remote == nullptr) {
2087         TLOGE(WmsLogTag::WMS_SUB, "Remote is null");
2088         return WMError::WM_ERROR_IPC_FAILED;
2089     }
2090     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_PARENT_MAIN_WINDOW_ID),
2091         data, reply, option) != ERR_NONE) {
2092         TLOGE(WmsLogTag::WMS_SUB, "SendRequest failed");
2093         return WMError::WM_ERROR_IPC_FAILED;
2094     }
2095     int32_t replyMainWindowId = INVALID_SESSION_ID;
2096     if (!reply.ReadInt32(replyMainWindowId)) {
2097         return WMError::WM_ERROR_IPC_FAILED;
2098     }
2099     int32_t ret = 0;
2100     if (!reply.ReadInt32(ret)) {
2101         return WMError::WM_ERROR_IPC_FAILED;
2102     }
2103     mainWindowId = replyMainWindowId;
2104     return static_cast<WMError>(ret);
2105 }
2106 
ListWindowInfo(const WindowInfoOption & windowInfoOption,std::vector<sptr<WindowInfo>> & infos)2107 WMError SceneSessionManagerProxy::ListWindowInfo(const WindowInfoOption& windowInfoOption,
2108     std::vector<sptr<WindowInfo>>& infos)
2109 {
2110     MessageParcel data;
2111     MessageParcel reply;
2112     MessageOption option;
2113     if (!data.WriteInterfaceToken(GetDescriptor())) {
2114         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write interfaceToken failed");
2115         return WMError::WM_ERROR_IPC_FAILED;
2116     }
2117     if (!data.WriteUint8(static_cast<WindowInfoFilterOptionDataType>(windowInfoOption.windowInfoFilterOption))) {
2118         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write windowInfoFilterOption failed");
2119         return WMError::WM_ERROR_IPC_FAILED;
2120     }
2121     if (!data.WriteUint8(static_cast<WindowInfoTypeOptionDataType>(windowInfoOption.windowInfoTypeOption))) {
2122         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write windowInfoTypeOption failed");
2123         return WMError::WM_ERROR_IPC_FAILED;
2124     }
2125     if (!data.WriteUint64(windowInfoOption.displayId)) {
2126         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write displayId failed");
2127         return WMError::WM_ERROR_IPC_FAILED;
2128     }
2129     if (!data.WriteInt32(windowInfoOption.windowId)) {
2130         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write windowId failed");
2131         return WMError::WM_ERROR_IPC_FAILED;
2132     }
2133     sptr<IRemoteObject> remote = Remote();
2134     if (remote == nullptr) {
2135         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
2136         return WMError::WM_ERROR_IPC_FAILED;
2137     }
2138     if (remote->SendRequest(static_cast<uint32_t>(
2139         SceneSessionManagerMessage::TRANS_ID_LIST_WINDOW_INFO), data, reply, option) != ERR_NONE) {
2140         return WMError::WM_ERROR_IPC_FAILED;
2141     }
2142     if (!MarshallingHelper::UnmarshallingVectorParcelableObj<WindowInfo>(reply, infos)) {
2143         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read window info failed");
2144         return WMError::WM_ERROR_IPC_FAILED;
2145     }
2146     int32_t errCode = 0;
2147     if (!reply.ReadInt32(errCode)) {
2148         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read errcode failed");
2149         return WMError::WM_ERROR_IPC_FAILED;
2150     }
2151     return static_cast<WMError>(errCode);
2152 }
2153 
GetAllWindowLayoutInfo(DisplayId displayId,std::vector<sptr<WindowLayoutInfo>> & infos)2154 WMError SceneSessionManagerProxy::GetAllWindowLayoutInfo(DisplayId displayId,
2155     std::vector<sptr<WindowLayoutInfo>>& infos)
2156 {
2157     MessageParcel data;
2158     MessageParcel reply;
2159     MessageOption option;
2160     if (!data.WriteInterfaceToken(GetDescriptor())) {
2161         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write interfaceToken failed");
2162         return WMError::WM_ERROR_IPC_FAILED;
2163     }
2164     if (!data.WriteUint64(displayId)) {
2165         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write displayId failed");
2166         return WMError::WM_ERROR_IPC_FAILED;
2167     }
2168     sptr<IRemoteObject> remote = Remote();
2169     if (remote == nullptr) {
2170         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
2171         return WMError::WM_ERROR_IPC_FAILED;
2172     }
2173     if (remote->SendRequest(static_cast<uint32_t>(
2174         SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_LAYOUT_INFO), data, reply, option) != ERR_NONE) {
2175         return WMError::WM_ERROR_IPC_FAILED;
2176     }
2177     if (!MarshallingHelper::UnmarshallingVectorParcelableObj<WindowLayoutInfo>(reply, infos)) {
2178         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read window layout info failed");
2179         return WMError::WM_ERROR_IPC_FAILED;
2180     }
2181     int32_t errCode = 0;
2182     if (!reply.ReadInt32(errCode)) {
2183         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read errcode failed");
2184         return WMError::WM_ERROR_IPC_FAILED;
2185     }
2186     return static_cast<WMError>(errCode);
2187 }
2188 
GetGlobalWindowMode(DisplayId displayId,GlobalWindowMode & globalWinMode)2189 WMError SceneSessionManagerProxy::GetGlobalWindowMode(DisplayId displayId, GlobalWindowMode& globalWinMode)
2190 {
2191     MessageParcel data;
2192     MessageParcel reply;
2193     MessageOption option;
2194     if (!data.WriteInterfaceToken(GetDescriptor())) {
2195         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write interfaceToken failed");
2196         return WMError::WM_ERROR_IPC_FAILED;
2197     }
2198     if (!data.WriteUint64(displayId)) {
2199         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write displayId failed");
2200         return WMError::WM_ERROR_IPC_FAILED;
2201     }
2202     sptr<IRemoteObject> remote = Remote();
2203     if (remote == nullptr) {
2204         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
2205         return WMError::WM_ERROR_IPC_FAILED;
2206     }
2207     auto reqErrCode = remote->SendRequest(
2208         static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_GLOBAL_WINDOW_MODE), data, reply, option);
2209     if (reqErrCode != ERR_NONE) {
2210         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "send request failed, errCode: %{public}d", reqErrCode);
2211         return WMError::WM_ERROR_IPC_FAILED;
2212     }
2213     int32_t errCode = 0;
2214     if (!reply.ReadInt32(errCode)) {
2215         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read errcode failed");
2216         return WMError::WM_ERROR_IPC_FAILED;
2217     }
2218     uint32_t mode = 0;
2219     if (!reply.ReadUint32(mode)) {
2220         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read global window mode failed");
2221         return WMError::WM_ERROR_IPC_FAILED;
2222     }
2223     globalWinMode = static_cast<GlobalWindowMode>(mode);
2224     return static_cast<WMError>(errCode);
2225 }
2226 
GetTopNavDestinationName(int32_t windowId,std::string & topNavDestName)2227 WMError SceneSessionManagerProxy::GetTopNavDestinationName(int32_t windowId, std::string& topNavDestName)
2228 {
2229     MessageParcel data;
2230     MessageParcel reply;
2231     MessageOption option;
2232     if (!data.WriteInterfaceToken(GetDescriptor())) {
2233         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write interfaceToken failed");
2234         return WMError::WM_ERROR_IPC_FAILED;
2235     }
2236     if (!data.WriteInt32(windowId)) {
2237         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write windowId failed");
2238         return WMError::WM_ERROR_IPC_FAILED;
2239     }
2240     sptr<IRemoteObject> remote = Remote();
2241     if (remote == nullptr) {
2242         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null");
2243         return WMError::WM_ERROR_IPC_FAILED;
2244     }
2245     auto reqErrCode = remote->SendRequest(
2246         static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_TOP_NAV_DEST_NAME), data, reply, option);
2247     if (reqErrCode != ERR_NONE) {
2248         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "send request failed, errCode: %{public}d", reqErrCode);
2249         return WMError::WM_ERROR_IPC_FAILED;
2250     }
2251     const char* namePtr = nullptr;
2252     auto size = reply.ReadUint32();
2253     if (size != 0) {
2254         namePtr = reinterpret_cast<const char*>(reply.ReadRawData(size));
2255     }
2256     topNavDestName = (namePtr != nullptr) ? std::string(namePtr, size) : "";
2257     int32_t errCode = 0;
2258     if (!reply.ReadInt32(errCode)) {
2259         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read errcode failed");
2260         return WMError::WM_ERROR_IPC_FAILED;
2261     }
2262     return static_cast<WMError>(errCode);
2263 }
2264 
GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>> & infos)2265 WMError SceneSessionManagerProxy::GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos)
2266 {
2267     MessageParcel data;
2268     MessageParcel reply;
2269     MessageOption option;
2270     if (!data.WriteInterfaceToken(GetDescriptor())) {
2271         WLOGFE("GetVisibilityWindowInfo Write interfaceToken failed");
2272         return WMError::WM_ERROR_IPC_FAILED;
2273     }
2274     sptr<IRemoteObject> remote = Remote();
2275     if (remote == nullptr) {
2276         WLOGFE("remote is null");
2277         return WMError::WM_ERROR_IPC_FAILED;
2278     }
2279     if (remote->SendRequest(static_cast<uint32_t>(
2280         SceneSessionManagerMessage::TRANS_ID_GET_VISIBILITY_WINDOW_INFO_ID), data, reply, option) != ERR_NONE) {
2281         return WMError::WM_ERROR_IPC_FAILED;
2282     }
2283     if (!MarshallingHelper::UnmarshallingVectorParcelableObj<WindowVisibilityInfo>(reply, infos)) {
2284         WLOGFE("read visibility window infos failed");
2285         return WMError::WM_ERROR_IPC_FAILED;
2286     }
2287     return static_cast<WMError>(reply.ReadInt32());
2288 }
2289 
ShiftAppWindowFocus(int32_t sourcePersistentId,int32_t targetPersistentId)2290 WSError SceneSessionManagerProxy::ShiftAppWindowFocus(int32_t sourcePersistentId, int32_t targetPersistentId)
2291 {
2292     WLOGFD("run SceneSessionManagerProxy::ShiftAppWindowFocus");
2293     MessageParcel data;
2294     MessageParcel reply;
2295     MessageOption option(MessageOption::TF_SYNC);
2296     if (!data.WriteInterfaceToken(GetDescriptor())) {
2297         WLOGFE("Write interface token failed.");
2298         return WSError::WS_ERROR_INVALID_PARAM;
2299     }
2300 
2301     if (!data.WriteUint32(sourcePersistentId)) {
2302         WLOGFE("Write sourcePersistentId failed");
2303         return WSError::WS_ERROR_INVALID_PARAM;
2304     }
2305 
2306     if (!data.WriteUint32(targetPersistentId)) {
2307         WLOGFE("Write targetPersistentId failed");
2308         return WSError::WS_ERROR_INVALID_PARAM;
2309     }
2310 
2311     sptr<IRemoteObject> remote = Remote();
2312     if (remote == nullptr) {
2313         WLOGFE("remote is null");
2314         return WSError::WS_ERROR_IPC_FAILED;
2315     }
2316     if (remote->SendRequest(static_cast<uint32_t>(
2317         SceneSessionManagerMessage::TRANS_ID_SHIFT_APP_WINDOW_FOCUS),
2318         data, reply, option) != ERR_NONE) {
2319         WLOGFE("SendRequest failed");
2320         return WSError::WS_ERROR_IPC_FAILED;
2321     }
2322     return static_cast<WSError>(reply.ReadInt32());
2323 }
2324 
UpdateModalExtensionRect(const sptr<IRemoteObject> & token,Rect rect)2325 void SceneSessionManagerProxy::UpdateModalExtensionRect(const sptr<IRemoteObject>& token, Rect rect)
2326 {
2327     MessageOption option(MessageOption::TF_SYNC);
2328     MessageParcel data;
2329     MessageParcel reply;
2330     if (!data.WriteInterfaceToken(GetDescriptor())) {
2331         TLOGE(WmsLogTag::WMS_UIEXT, "Write interface token failed.");
2332         return;
2333     }
2334     if (!data.WriteRemoteObject(token)) {
2335         TLOGE(WmsLogTag::WMS_UIEXT, "Write token failed");
2336         return;
2337     }
2338     if (!data.WriteInt32(rect.posX_)) {
2339         TLOGE(WmsLogTag::WMS_UIEXT, "Write posX_ failed");
2340         return;
2341     }
2342     if (!data.WriteInt32(rect.posY_)) {
2343         TLOGE(WmsLogTag::WMS_UIEXT, "Write posY_ failed");
2344         return;
2345     }
2346     if (!data.WriteInt32(rect.width_)) {
2347         TLOGE(WmsLogTag::WMS_UIEXT, "Write width_ failed");
2348         return;
2349     }
2350     if (!data.WriteInt32(rect.height_)) {
2351         TLOGE(WmsLogTag::WMS_UIEXT, "Write height_ failed");
2352         return;
2353     }
2354     sptr<IRemoteObject> remote = Remote();
2355     if (remote == nullptr) {
2356         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
2357         return;
2358     }
2359     if (remote->SendRequest(static_cast<uint32_t>(
2360                             SceneSessionManagerMessage::TRANS_ID_UPDATE_MODALEXTENSION_RECT_TO_SCB),
2361                             data, reply, option) != ERR_NONE) {
2362         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed");
2363     }
2364 }
2365 
ProcessModalExtensionPointDown(const sptr<IRemoteObject> & token,int32_t posX,int32_t posY)2366 void SceneSessionManagerProxy::ProcessModalExtensionPointDown(const sptr<IRemoteObject>& token, int32_t posX,
2367     int32_t posY)
2368 {
2369     MessageOption option(MessageOption::TF_SYNC);
2370     MessageParcel data;
2371     MessageParcel reply;
2372     if (!data.WriteInterfaceToken(GetDescriptor())) {
2373         TLOGE(WmsLogTag::WMS_UIEXT, "Write interface token failed.");
2374         return;
2375     }
2376     if (!data.WriteRemoteObject(token)) {
2377         TLOGE(WmsLogTag::WMS_UIEXT, "Write token failed");
2378         return;
2379     }
2380     if (!data.WriteInt32(posX)) {
2381         TLOGE(WmsLogTag::WMS_UIEXT, "Write posX failed");
2382         return;
2383     }
2384     if (!data.WriteInt32(posY)) {
2385         TLOGE(WmsLogTag::WMS_UIEXT, "Write posY failed");
2386         return;
2387     }
2388     sptr<IRemoteObject> remote = Remote();
2389     if (remote == nullptr) {
2390         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
2391         return;
2392     }
2393     if (remote->SendRequest(static_cast<uint32_t>(
2394                             SceneSessionManagerMessage::TRANS_ID_PROCESS_MODALEXTENSION_POINTDOWN_TO_SCB),
2395                             data, reply, option) != ERR_NONE) {
2396         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed");
2397     }
2398 }
2399 
AddExtensionWindowStageToSCB(const sptr<ISessionStage> & sessionStage,const sptr<IRemoteObject> & token,uint64_t surfaceNodeId,bool isConstrainedModal)2400 void SceneSessionManagerProxy::AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage,
2401     const sptr<IRemoteObject>& token, uint64_t surfaceNodeId, bool isConstrainedModal)
2402 {
2403     if (sessionStage == nullptr || token == nullptr) {
2404         TLOGE(WmsLogTag::WMS_UIEXT, "input is nullptr");
2405         return;
2406     }
2407     MessageOption option(MessageOption::TF_SYNC);
2408     MessageParcel data;
2409     MessageParcel reply;
2410     if (!data.WriteInterfaceToken(GetDescriptor())) {
2411         TLOGE(WmsLogTag::WMS_UIEXT, "Write InterfaceToken failed!");
2412         return;
2413     }
2414     if (!data.WriteRemoteObject(sessionStage->AsObject())) {
2415         TLOGE(WmsLogTag::WMS_UIEXT, "Write ISessionStage failed!");
2416         return;
2417     }
2418     if (!data.WriteRemoteObject(token)) {
2419         TLOGE(WmsLogTag::WMS_UIEXT, "Write token failed");
2420         return;
2421     }
2422     if (!data.WriteUint64(static_cast<uint64_t>(surfaceNodeId))) {
2423         TLOGE(WmsLogTag::WMS_UIEXT, "Write surfaceNodeId failed");
2424         return;
2425     }
2426     if (!data.WriteBool(isConstrainedModal)) {
2427         TLOGE(WmsLogTag::WMS_UIEXT, "Write isConstrainedModal failed");
2428         return;
2429     }
2430     sptr<IRemoteObject> remote = Remote();
2431     if (remote == nullptr) {
2432         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
2433         return;
2434     }
2435     if (remote->SendRequest(static_cast<uint32_t>(
2436                             SceneSessionManagerMessage::TRANS_ID_ADD_EXTENSION_WINDOW_STAGE_TO_SCB),
2437                             data, reply, option) != ERR_NONE) {
2438         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed");
2439     }
2440 }
2441 
RemoveExtensionWindowStageFromSCB(const sptr<ISessionStage> & sessionStage,const sptr<IRemoteObject> & token,bool isConstrainedModal)2442 void SceneSessionManagerProxy::RemoveExtensionWindowStageFromSCB(const sptr<ISessionStage>& sessionStage,
2443     const sptr<IRemoteObject>& token, bool isConstrainedModal)
2444 {
2445     if (sessionStage == nullptr || token == nullptr) {
2446         TLOGE(WmsLogTag::WMS_UIEXT, "input is nullptr");
2447         return;
2448     }
2449     MessageOption option(MessageOption::TF_SYNC);
2450     MessageParcel data;
2451     MessageParcel reply;
2452     if (!data.WriteInterfaceToken(GetDescriptor())) {
2453         TLOGE(WmsLogTag::WMS_UIEXT, "Write InterfaceToken failed!");
2454         return;
2455     }
2456     if (!data.WriteRemoteObject(sessionStage->AsObject())) {
2457         TLOGE(WmsLogTag::WMS_UIEXT, "Write ISessionStage failed!");
2458         return;
2459     }
2460     if (!data.WriteRemoteObject(token)) {
2461         TLOGE(WmsLogTag::WMS_UIEXT, "Write token failed");
2462         return;
2463     }
2464     if (!data.WriteBool(isConstrainedModal)) {
2465         TLOGE(WmsLogTag::WMS_UIEXT, "Write isConstrainedModal failed");
2466         return;
2467     }
2468     sptr<IRemoteObject> remote = Remote();
2469     if (remote == nullptr) {
2470         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
2471         return;
2472     }
2473     if (remote->SendRequest(static_cast<uint32_t>(
2474                             SceneSessionManagerMessage::TRANS_ID_REMOVE_EXTENSION_WINDOW_STAGE_FROM_SCB),
2475                             data, reply, option) != ERR_NONE) {
2476         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed");
2477     }
2478 }
2479 
AddOrRemoveSecureSession(int32_t persistentId,bool shouldHide)2480 WSError SceneSessionManagerProxy::AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide)
2481 {
2482     MessageParcel data;
2483     MessageParcel reply;
2484     MessageOption option(MessageOption::TF_SYNC);
2485     if (!data.WriteInterfaceToken(GetDescriptor())) {
2486         TLOGE(WmsLogTag::WMS_UIEXT, "WriteInterfaceToken failed");
2487         return WSError::WS_ERROR_IPC_FAILED;
2488     }
2489     if (!data.WriteInt32(persistentId)) {
2490         TLOGE(WmsLogTag::WMS_UIEXT, "Write persistentId failed");
2491         return WSError::WS_ERROR_IPC_FAILED;
2492     }
2493     if (!data.WriteBool(shouldHide)) {
2494         TLOGE(WmsLogTag::WMS_UIEXT, "Write shouldHide failed");
2495         return WSError::WS_ERROR_IPC_FAILED;
2496     }
2497     sptr<IRemoteObject> remote = Remote();
2498     if (remote == nullptr) {
2499         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
2500         return WSError::WS_ERROR_IPC_FAILED;
2501     }
2502     if (remote->SendRequest(static_cast<uint32_t>(
2503                             SceneSessionManagerMessage::TRANS_ID_ADD_OR_REMOVE_SECURE_SESSION),
2504                             data, reply, option) != ERR_NONE) {
2505         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed");
2506         return WSError::WS_ERROR_IPC_FAILED;
2507     }
2508     return static_cast<WSError>(reply.ReadInt32());
2509 }
2510 
UpdateExtWindowFlags(const sptr<IRemoteObject> & token,uint32_t extWindowFlags,uint32_t extWindowActions)2511 WSError SceneSessionManagerProxy::UpdateExtWindowFlags(const sptr<IRemoteObject>& token, uint32_t extWindowFlags,
2512     uint32_t extWindowActions)
2513 {
2514     TLOGD(WmsLogTag::WMS_UIEXT, "run SceneSessionManagerProxy::UpdateExtWindowFlags");
2515     MessageParcel data;
2516     MessageParcel reply;
2517     MessageOption option(MessageOption::TF_SYNC);
2518     if (!data.WriteInterfaceToken(GetDescriptor())) {
2519         TLOGE(WmsLogTag::WMS_UIEXT, "Write interface token failed.");
2520         return WSError::WS_ERROR_IPC_FAILED;
2521     }
2522     if (!data.WriteRemoteObject(token)) {
2523         TLOGE(WmsLogTag::WMS_UIEXT, "Write token failed");
2524         return WSError::WS_ERROR_IPC_FAILED;
2525     }
2526     if (!data.WriteUint32(extWindowFlags)) {
2527         TLOGE(WmsLogTag::WMS_UIEXT, "Write extWindowFlags failed");
2528         return WSError::WS_ERROR_IPC_FAILED;
2529     }
2530     if (!data.WriteUint32(extWindowActions)) {
2531         TLOGE(WmsLogTag::WMS_UIEXT, "Write extWindowActions failed");
2532         return WSError::WS_ERROR_IPC_FAILED;
2533     }
2534     sptr<IRemoteObject> remote = Remote();
2535     if (remote == nullptr) {
2536         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
2537         return WSError::WS_ERROR_IPC_FAILED;
2538     }
2539     if (remote->SendRequest(
2540         static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UPDATE_EXTENSION_WINDOW_FLAGS),
2541         data, reply, option) != ERR_NONE) {
2542         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest AddExtensionSessionInfo failed");
2543         return WSError::WS_ERROR_IPC_FAILED;
2544     }
2545     return static_cast<WSError>(reply.ReadInt32());
2546 }
2547 
GetHostWindowRect(int32_t hostWindowId,Rect & rect)2548 WSError SceneSessionManagerProxy::GetHostWindowRect(int32_t hostWindowId, Rect& rect)
2549 {
2550     TLOGD(WmsLogTag::WMS_UIEXT, "run SceneSessionManagerProxy::GetHostWindowRect");
2551     MessageParcel data;
2552     MessageParcel reply;
2553     MessageOption option;
2554     if (!data.WriteInterfaceToken(GetDescriptor())) {
2555         TLOGE(WmsLogTag::WMS_UIEXT, "Write interface token failed.");
2556         return WSError::WS_ERROR_IPC_FAILED;
2557     }
2558     if (!data.WriteInt32(hostWindowId)) {
2559         TLOGE(WmsLogTag::WMS_UIEXT, "Write hostWindowId failed");
2560         return WSError::WS_ERROR_IPC_FAILED;
2561     }
2562     sptr<IRemoteObject> remote = Remote();
2563     if (remote == nullptr) {
2564         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
2565         return WSError::WS_ERROR_IPC_FAILED;
2566     }
2567     if (remote->SendRequest(
2568         static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_HOST_WINDOW_RECT),
2569         data, reply, option) != ERR_NONE) {
2570         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest GetHostWindowRect failed");
2571         return WSError::WS_ERROR_IPC_FAILED;
2572     }
2573     auto posX = reply.ReadInt32();
2574     auto posY = reply.ReadInt32();
2575     auto width = reply.ReadUint32();
2576     auto height = reply.ReadUint32();
2577     rect = {posX, posY, width, height};
2578     return static_cast<WSError>(reply.ReadInt32());
2579 }
2580 
GetHostGlobalScaledRect(int32_t hostWindowId,Rect & globalScaledRect)2581 WSError SceneSessionManagerProxy::GetHostGlobalScaledRect(int32_t hostWindowId, Rect& globalScaledRect)
2582 {
2583     TLOGD(WmsLogTag::WMS_UIEXT, "in");
2584     MessageParcel data;
2585     MessageParcel reply;
2586     MessageOption option;
2587     if (!data.WriteInterfaceToken(GetDescriptor())) {
2588         TLOGE(WmsLogTag::WMS_UIEXT, "Write interface token failed.");
2589         return WSError::WS_ERROR_IPC_FAILED;
2590     }
2591     if (!data.WriteInt32(hostWindowId)) {
2592         TLOGE(WmsLogTag::WMS_UIEXT, "Write hostWindowId failed");
2593         return WSError::WS_ERROR_IPC_FAILED;
2594     }
2595     sptr<IRemoteObject> remote = Remote();
2596     if (remote == nullptr) {
2597         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
2598         return WSError::WS_ERROR_IPC_FAILED;
2599     }
2600     auto errorCode = remote->SendRequest(
2601         static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_HOST_GLOBAL_SCALE_RECT), data, reply, option);
2602     if (errorCode != ERR_NONE) {
2603         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed code: %{public}d", errorCode);
2604         return WSError::WS_ERROR_IPC_FAILED;
2605     }
2606     auto posX = reply.ReadInt32();
2607     auto posY = reply.ReadInt32();
2608     auto width = reply.ReadUint32();
2609     auto height = reply.ReadUint32();
2610     globalScaledRect = {posX, posY, width, height};
2611     return static_cast<WSError>(reply.ReadInt32());
2612 }
2613 
GetFreeMultiWindowEnableState(bool & enable)2614 WSError SceneSessionManagerProxy::GetFreeMultiWindowEnableState(bool& enable)
2615 {
2616     TLOGD(WmsLogTag::WMS_MULTI_WINDOW, "in");
2617     MessageParcel data;
2618     MessageParcel reply;
2619     MessageOption option;
2620     if (!data.WriteInterfaceToken(GetDescriptor())) {
2621         TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "Write interface token failed.");
2622         return WSError::WS_ERROR_IPC_FAILED;
2623     }
2624     sptr<IRemoteObject> remote = Remote();
2625     if (remote == nullptr) {
2626         TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "remote is nullptr");
2627         return WSError::WS_ERROR_NULLPTR;
2628     }
2629     if (remote->SendRequest(
2630         static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_FREE_MULTI_WINDOW_ENABLE_STATE),
2631         data, reply, option) != ERR_NONE) {
2632         TLOGE(WmsLogTag::WMS_MULTI_WINDOW, "SendRequest GetFreeMultiWindowEnableState failed");
2633         return WSError::WS_ERROR_IPC_FAILED;
2634     }
2635     auto isEnable = reply.ReadBool();
2636     enable = isEnable;
2637     return static_cast<WSError>(reply.ReadInt32());
2638 }
2639 
GetCallingWindowWindowStatus(int32_t persistentId,WindowStatus & windowStatus)2640 WMError SceneSessionManagerProxy::GetCallingWindowWindowStatus(int32_t persistentId, WindowStatus& windowStatus)
2641 {
2642     MessageParcel data;
2643     MessageParcel reply;
2644     MessageOption option;
2645 
2646     if (!data.WriteInterfaceToken(GetDescriptor())) {
2647         TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed");
2648         return WMError::WM_ERROR_IPC_FAILED;
2649     }
2650     if (!data.WriteInt32(persistentId)) {
2651         TLOGE(WmsLogTag::WMS_KEYBOARD, "Write windowId failed");
2652         return WMError::WM_ERROR_IPC_FAILED;
2653     }
2654     sptr<IRemoteObject> remote = Remote();
2655     if (remote == nullptr) {
2656         TLOGE(WmsLogTag::WMS_KEYBOARD, "remote is null");
2657         return WMError::WM_ERROR_IPC_FAILED;
2658     }
2659     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_STATUS),
2660         data, reply, option) != ERR_NONE) {
2661         TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
2662         return WMError::WM_ERROR_IPC_FAILED;
2663     }
2664     auto ret = static_cast<WMError>(reply.ReadInt32());
2665     if (ret == WMError::WM_OK) {
2666         windowStatus = static_cast<WindowStatus>(reply.ReadUint32());
2667     }
2668     return ret;
2669 }
2670 
GetCallingWindowRect(int32_t persistentId,Rect & rect)2671 WMError SceneSessionManagerProxy::GetCallingWindowRect(int32_t persistentId, Rect& rect)
2672 {
2673     MessageParcel data;
2674     MessageParcel reply;
2675     MessageOption option;
2676     if (!data.WriteInterfaceToken(GetDescriptor())) {
2677         TLOGE(WmsLogTag::WMS_KEYBOARD, "WriteInterfaceToken failed");
2678         return WMError::WM_ERROR_IPC_FAILED;
2679     }
2680     if (!data.WriteInt32(persistentId)) {
2681         TLOGE(WmsLogTag::WMS_KEYBOARD, "Write windowId failed");
2682         return WMError::WM_ERROR_IPC_FAILED;
2683     }
2684     sptr<IRemoteObject> remote = Remote();
2685     if (remote == nullptr) {
2686         TLOGE(WmsLogTag::WMS_KEYBOARD, "remote is null");
2687         return WMError::WM_ERROR_IPC_FAILED;
2688     }
2689     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_RECT),
2690         data, reply, option) != ERR_NONE) {
2691         TLOGE(WmsLogTag::WMS_KEYBOARD, "SendRequest failed");
2692         return WMError::WM_ERROR_IPC_FAILED;
2693     }
2694     auto ret = static_cast<WMError>(reply.ReadInt32());
2695     if (ret == WMError::WM_OK) {
2696         rect.posX_ = reply.ReadInt32();
2697         rect.posY_ = reply.ReadInt32();
2698         rect.width_ = reply.ReadUint32();
2699         rect.height_ = reply.ReadUint32();
2700     }
2701     return ret;
2702 }
2703 
GetWindowModeType(WindowModeType & windowModeType)2704 WMError SceneSessionManagerProxy::GetWindowModeType(WindowModeType& windowModeType)
2705 {
2706     MessageParcel data;
2707     MessageParcel reply;
2708     MessageOption option;
2709     if (!data.WriteInterfaceToken(GetDescriptor())) {
2710         TLOGD(WmsLogTag::DEFAULT, "Write interfaceToken failed");
2711         return WMError::WM_ERROR_IPC_FAILED;
2712     }
2713     sptr<IRemoteObject> remote = Remote();
2714     if (remote == nullptr) {
2715         TLOGE(WmsLogTag::DEFAULT, "Remote is null");
2716         return WMError::WM_ERROR_IPC_FAILED;
2717     }
2718     if (remote->SendRequest(static_cast<uint32_t>(
2719         SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_MODE_TYPE), data, reply, option) != ERR_NONE) {
2720         return WMError::WM_ERROR_IPC_FAILED;
2721     }
2722     windowModeType = static_cast<WindowModeType>(reply.ReadUint32());
2723     return static_cast<WMError>(reply.ReadInt32());
2724 }
2725 
MinimizeAllAppWindows(DisplayId displayId)2726 WMError SceneSessionManagerProxy::MinimizeAllAppWindows(DisplayId displayId)
2727 {
2728     if (!Permission::IsSystemCallingOrStartByHdcd(true)) {
2729         TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right, displayId %{public}" PRIu64, displayId);
2730         return WMError::WM_ERROR_NOT_SYSTEM_APP;
2731     }
2732     TLOGE(WmsLogTag::WMS_LIFE, "Not support minimize, displayId %{public}" PRIu64, displayId);
2733     return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
2734 }
2735 
ToggleShownStateForAllAppWindows()2736 WMError SceneSessionManagerProxy::ToggleShownStateForAllAppWindows()
2737 {
2738     if (!Permission::IsSystemCallingOrStartByHdcd(true)) {
2739         TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right");
2740         return WMError::WM_ERROR_NOT_SYSTEM_APP;
2741     }
2742     TLOGE(WmsLogTag::WMS_LIFE, "Not support call toggleShownState");
2743     return WMError::WM_ERROR_DEVICE_NOT_SUPPORT;
2744 }
2745 
GetWindowStyleType(WindowStyleType & windowStyleType)2746 WMError SceneSessionManagerProxy::GetWindowStyleType(WindowStyleType& windowStyleType)
2747 {
2748     MessageParcel data;
2749     MessageParcel reply;
2750     MessageOption option;
2751     if (!data.WriteInterfaceToken(GetDescriptor())) {
2752         TLOGE(WmsLogTag::WMS_LIFE, "GetwindowStyleType Write interfaceToken failed");
2753         return WMError::WM_ERROR_IPC_FAILED;
2754     }
2755     sptr<IRemoteObject> remote = Remote();
2756     if (remote == nullptr) {
2757         TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
2758         return WMError::WM_ERROR_IPC_FAILED;
2759     }
2760     if (remote->SendRequest(static_cast<uint32_t>(
2761         SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_STYLE_TYPE), data, reply, option) != ERR_NONE) {
2762         return WMError::WM_ERROR_IPC_FAILED;
2763     }
2764     windowStyleType = static_cast<WindowStyleType>(reply.ReadUint32());
2765     return static_cast<WMError>(reply.ReadInt32());
2766 }
2767 
GetProcessSurfaceNodeIdByPersistentId(const int32_t pid,const std::vector<int32_t> & persistentIds,std::vector<uint64_t> & surfaceNodeIds)2768 WMError SceneSessionManagerProxy::GetProcessSurfaceNodeIdByPersistentId(const int32_t pid,
2769     const std::vector<int32_t>& persistentIds, std::vector<uint64_t>& surfaceNodeIds)
2770 {
2771     MessageParcel data;
2772     MessageParcel reply;
2773     MessageOption option;
2774     if (!data.WriteInterfaceToken(GetDescriptor())) {
2775         TLOGE(WmsLogTag::DEFAULT, "Write interfaceToken failed");
2776         return WMError::WM_ERROR_IPC_FAILED;
2777     }
2778     if (!data.WriteInt32(pid)) {
2779         TLOGE(WmsLogTag::DEFAULT, "Write pid failed");
2780         return WMError::WM_ERROR_IPC_FAILED;
2781     }
2782     if (!data.WriteInt32Vector(persistentIds)) {
2783         TLOGE(WmsLogTag::DEFAULT, "Write persistentIds failed");
2784         return WMError::WM_ERROR_IPC_FAILED;
2785     }
2786     sptr<IRemoteObject> remote = Remote();
2787     if (remote == nullptr) {
2788         TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
2789         return WMError::WM_ERROR_IPC_FAILED;
2790     }
2791     if (remote->SendRequest(static_cast<uint32_t>(
2792         SceneSessionManagerMessage::TRANS_ID_GET_PROCESS_SURFACENODEID_BY_PERSISTENTID),
2793         data, reply, option) != ERR_NONE) {
2794         TLOGE(WmsLogTag::DEFAULT, "SendRequest failed");
2795         return WMError::WM_ERROR_IPC_FAILED;
2796     }
2797     reply.ReadUInt64Vector(&surfaceNodeIds);
2798     return static_cast<WMError>(reply.ReadInt32());
2799 }
2800 
SkipSnapshotForAppProcess(int32_t pid,bool skip)2801 WMError SceneSessionManagerProxy::SkipSnapshotForAppProcess(int32_t pid, bool skip)
2802 {
2803     MessageParcel data;
2804     MessageParcel reply;
2805     MessageOption option;
2806     if (!data.WriteInterfaceToken(GetDescriptor())) {
2807         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "WriteInterfaceToken failed");
2808         return WMError::WM_ERROR_IPC_FAILED;
2809     }
2810     if (!data.WriteInt32(pid)) {
2811         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write pid failed");
2812         return WMError::WM_ERROR_IPC_FAILED;
2813     }
2814     if (!data.WriteBool(skip)) {
2815         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write skip failed");
2816         return WMError::WM_ERROR_IPC_FAILED;
2817     }
2818     sptr<IRemoteObject> remote = Remote();
2819     if (remote == nullptr) {
2820         TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
2821         return WMError::WM_ERROR_IPC_FAILED;
2822     }
2823     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_PROCESS_SNAPSHOT_SKIP),
2824         data, reply, option) != ERR_NONE) {
2825         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
2826         return WMError::WM_ERROR_IPC_FAILED;
2827     }
2828 
2829     return static_cast<WMError>(reply.ReadInt32());
2830 }
2831 
SkipSnapshotByUserIdAndBundleNames(int32_t userId,const std::vector<std::string> & bundleNameList)2832 WMError SceneSessionManagerProxy::SkipSnapshotByUserIdAndBundleNames(int32_t userId,
2833     const std::vector<std::string>& bundleNameList)
2834 {
2835     MessageParcel data;
2836     MessageParcel reply;
2837     MessageOption option;
2838     if (!data.WriteInterfaceToken(GetDescriptor())) {
2839         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write interfaceToken failed");
2840         return WMError::WM_ERROR_IPC_FAILED;
2841     }
2842     if (!data.WriteInt32(userId)) {
2843         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write userId failed");
2844         return WMError::WM_ERROR_IPC_FAILED;
2845     }
2846     if (!data.WriteStringVector(bundleNameList)) {
2847         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write bundleNameList failed");
2848         return WMError::WM_ERROR_IPC_FAILED;
2849     }
2850     sptr<IRemoteObject> remote = Remote();
2851     if (remote == nullptr) {
2852         TLOGE(WmsLogTag::WMS_LIFE, "remote is null");
2853         return WMError::WM_ERROR_IPC_FAILED;
2854     }
2855     if (remote->SendRequest(static_cast<uint32_t>(
2856         SceneSessionManagerMessage::TRANS_ID_SET_SNAPSHOT_SKIP_BY_USERID_AND_BUNDLENAMES),
2857         data, reply, option) != ERR_NONE) {
2858         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
2859         return WMError::WM_ERROR_IPC_FAILED;
2860     }
2861     return static_cast<WMError>(reply.ReadInt32());
2862 }
2863 
SetProcessWatermark(int32_t pid,const std::string & watermarkName,bool isEnabled)2864 WMError SceneSessionManagerProxy::SetProcessWatermark(int32_t pid, const std::string& watermarkName, bool isEnabled)
2865 {
2866     MessageParcel data;
2867     MessageParcel reply;
2868     MessageOption option;
2869     if (!data.WriteInterfaceToken(GetDescriptor())) {
2870         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "WriteInterfaceToken failed");
2871         return WMError::WM_ERROR_IPC_FAILED;
2872     }
2873     if (!data.WriteInt32(pid)) {
2874         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write pid failed");
2875         return WMError::WM_ERROR_IPC_FAILED;
2876     }
2877     if (!data.WriteString(watermarkName)) {
2878         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write watermarkName failed");
2879         return WMError::WM_ERROR_IPC_FAILED;
2880     }
2881     if (!data.WriteBool(isEnabled)) {
2882         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write isEnabled failed");
2883         return WMError::WM_ERROR_IPC_FAILED;
2884     }
2885     if (Remote()->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_PROCESS_WATERMARK),
2886         data, reply, option) != ERR_NONE) {
2887         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
2888         return WMError::WM_ERROR_IPC_FAILED;
2889     }
2890 
2891     return static_cast<WMError>(reply.ReadInt32());
2892 }
2893 
GetWindowIdsByCoordinate(DisplayId displayId,int32_t windowNumber,int32_t x,int32_t y,std::vector<int32_t> & windowIds)2894 WMError SceneSessionManagerProxy::GetWindowIdsByCoordinate(DisplayId displayId, int32_t windowNumber,
2895     int32_t x, int32_t y, std::vector<int32_t>& windowIds)
2896 {
2897     MessageParcel data;
2898     MessageParcel reply;
2899     MessageOption option;
2900     if (!data.WriteInterfaceToken(GetDescriptor())) {
2901         TLOGE(WmsLogTag::DEFAULT, "Write interfaceToken failed");
2902         return WMError::WM_ERROR_IPC_FAILED;
2903     }
2904     if (!data.WriteUint64(displayId)) {
2905         TLOGE(WmsLogTag::DEFAULT, "Write displayId failed");
2906         return WMError::WM_ERROR_IPC_FAILED;
2907     }
2908     if (!data.WriteInt32(windowNumber)) {
2909         TLOGE(WmsLogTag::DEFAULT, "Write windowNumber failed");
2910         return WMError::WM_ERROR_IPC_FAILED;
2911     }
2912     if (!data.WriteInt32(x)) {
2913         TLOGE(WmsLogTag::DEFAULT, "Write x failed");
2914         return WMError::WM_ERROR_IPC_FAILED;
2915     }
2916     if (!data.WriteInt32(y)) {
2917         TLOGE(WmsLogTag::DEFAULT, "Write y failed");
2918         return WMError::WM_ERROR_IPC_FAILED;
2919     }
2920     sptr<IRemoteObject> remote = Remote();
2921     if (remote == nullptr) {
2922         TLOGE(WmsLogTag::DEFAULT, "remote is null");
2923         return WMError::WM_ERROR_IPC_FAILED;
2924     }
2925     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_WINDOW_IDS_BY_COORDINATE),
2926         data, reply, option) != ERR_NONE) {
2927         TLOGE(WmsLogTag::DEFAULT, "SendRequest failed");
2928         return WMError::WM_ERROR_IPC_FAILED;
2929     }
2930     auto ret = static_cast<WMError>(reply.ReadInt32());
2931     if (ret == WMError::WM_OK) {
2932         reply.ReadInt32Vector(&windowIds);
2933     }
2934     return ret;
2935 }
2936 
UpdateScreenLockStatusForApp(const std::string & bundleName,bool isRelease)2937 WMError SceneSessionManagerProxy::UpdateScreenLockStatusForApp(const std::string& bundleName, bool isRelease)
2938 {
2939     MessageParcel data;
2940     MessageParcel reply;
2941     MessageOption option;
2942     if (!data.WriteInterfaceToken(GetDescriptor())) {
2943         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "WriteInterfaceToken failed");
2944         return WMError::WM_ERROR_IPC_FAILED;
2945     }
2946     if (!data.WriteString(bundleName)) {
2947         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write bundleName failed");
2948         return WMError::WM_ERROR_IPC_FAILED;
2949     }
2950     if (!data.WriteBool(isRelease)) {
2951         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write isRelease failed");
2952         return WMError::WM_ERROR_IPC_FAILED;
2953     }
2954     if (Remote()->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_UPDATE_SESSION_SCREEN_LOCK),
2955         data, reply, option) != ERR_NONE) {
2956         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
2957         return WMError::WM_ERROR_IPC_FAILED;
2958     }
2959     return static_cast<WMError>(reply.ReadInt32());
2960 }
2961 
AddSkipSelfWhenShowOnVirtualScreenList(const std::vector<int32_t> & persistentIds)2962 WMError SceneSessionManagerProxy::AddSkipSelfWhenShowOnVirtualScreenList(const std::vector<int32_t>& persistentIds)
2963 {
2964     MessageParcel data;
2965     MessageParcel reply;
2966     MessageOption option;
2967     if (!data.WriteInterfaceToken(GetDescriptor())) {
2968         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write token failed");
2969         return WMError::WM_ERROR_IPC_FAILED;
2970     }
2971     if (!data.WriteUint64(persistentIds.size())) {
2972         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write size failed");
2973         return WMError::WM_ERROR_IPC_FAILED;
2974     }
2975     for (const auto persistentId: persistentIds) {
2976         if (!data.WriteInt32(persistentId)) {
2977             TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write persistentId failed");
2978             return WMError::WM_ERROR_IPC_FAILED;
2979         }
2980     }
2981     if (Remote()->SendRequest(
2982         static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_ADD_SKIP_SELF_ON_VIRTUAL_SCREEN),
2983         data, reply, option) != ERR_NONE) {
2984         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
2985         return WMError::WM_ERROR_IPC_FAILED;
2986     }
2987     return static_cast<WMError>(reply.ReadInt32());
2988 }
2989 
RemoveSkipSelfWhenShowOnVirtualScreenList(const std::vector<int32_t> & persistentIds)2990 WMError SceneSessionManagerProxy::RemoveSkipSelfWhenShowOnVirtualScreenList(const std::vector<int32_t>& persistentIds)
2991 {
2992     MessageParcel data;
2993     MessageParcel reply;
2994     MessageOption option;
2995     if (!data.WriteInterfaceToken(GetDescriptor())) {
2996         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write token failed");
2997         return WMError::WM_ERROR_IPC_FAILED;
2998     }
2999     if (!data.WriteUint64(persistentIds.size())) {
3000         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write size failed");
3001         return WMError::WM_ERROR_IPC_FAILED;
3002     }
3003     for (const auto persistentId: persistentIds) {
3004         if (!data.WriteInt32(persistentId)) {
3005             TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write persistentId failed");
3006             return WMError::WM_ERROR_IPC_FAILED;
3007         }
3008     }
3009     if (Remote()->SendRequest(
3010         static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REMOVE_SKIP_SELF_ON_VIRTUAL_SCREEN),
3011         data, reply, option) != ERR_NONE) {
3012         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
3013         return WMError::WM_ERROR_IPC_FAILED;
3014     }
3015     return static_cast<WMError>(reply.ReadInt32());
3016 }
3017 
SetScreenPrivacyWindowTagSwitch(uint64_t screenId,const std::vector<std::string> & privacyWindowTags,bool enable)3018 WMError SceneSessionManagerProxy::SetScreenPrivacyWindowTagSwitch(
3019     uint64_t screenId, const std::vector<std::string>& privacyWindowTags, bool enable)
3020 {
3021     MessageParcel data;
3022     MessageParcel reply;
3023     MessageOption option;
3024     if (!data.WriteInterfaceToken(GetDescriptor())) {
3025         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write token failed");
3026         return WMError::WM_ERROR_IPC_FAILED;
3027     }
3028     if (!data.WriteUint64(screenId)) {
3029         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write screenId failed");
3030         return WMError::WM_ERROR_IPC_FAILED;
3031     }
3032     if (!data.WriteUint64(privacyWindowTags.size())) {
3033         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write size failed");
3034         return WMError::WM_ERROR_IPC_FAILED;
3035     }
3036     for (const auto privacyWidnowTag: privacyWindowTags) {
3037         if (!data.WriteString(privacyWidnowTag)) {
3038             TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write privacyWidnowTag failed");
3039             return WMError::WM_ERROR_IPC_FAILED;
3040         }
3041     }
3042     if (!data.WriteBool(enable)) {
3043         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write enable failed");
3044         return WMError::WM_ERROR_IPC_FAILED;
3045     }
3046 
3047     sptr<IRemoteObject> remote = Remote();
3048     if (remote == nullptr) {
3049         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Remote is null");
3050         return WMError::WM_ERROR_IPC_FAILED;
3051     }
3052     if (remote->SendRequest(
3053         static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_SCREEN_PRIVACY_WINDOW_TAG_SWITCH),
3054         data, reply, option) != ERR_NONE) {
3055         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
3056         return WMError::WM_ERROR_IPC_FAILED;
3057     }
3058 
3059     int32_t ret = 0;
3060     if (!reply.ReadInt32(ret)) {
3061         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read ret failed");
3062         return WMError::WM_ERROR_IPC_FAILED;
3063     }
3064     return static_cast<WMError>(ret);
3065 }
3066 
IsPcOrPadFreeMultiWindowMode(bool & isPcOrPadFreeMultiWindowMode)3067 WMError SceneSessionManagerProxy::IsPcOrPadFreeMultiWindowMode(bool& isPcOrPadFreeMultiWindowMode)
3068 {
3069     MessageParcel data;
3070     MessageParcel reply;
3071     MessageOption option;
3072     if (!data.WriteInterfaceToken(GetDescriptor())) {
3073         TLOGE(WmsLogTag::WMS_SUB, "Write interfaceToken failed");
3074         return WMError::WM_ERROR_IPC_FAILED;
3075     }
3076     sptr<IRemoteObject> remote = Remote();
3077     if (remote == nullptr) {
3078         TLOGE(WmsLogTag::WMS_SUB, "Remote is null");
3079         return WMError::WM_ERROR_IPC_FAILED;
3080     }
3081     if (remote->SendRequest(static_cast<uint32_t>(
3082         SceneSessionManagerMessage::TRANS_ID_IS_PC_OR_PAD_FREE_MULTI_WINDOW_MODE),
3083         data, reply, option) != ERR_NONE) {
3084         TLOGE(WmsLogTag::WMS_SUB, "SendRequest failed");
3085         return WMError::WM_ERROR_IPC_FAILED;
3086     }
3087     bool repliedValue = false;
3088     if (!reply.ReadBool(repliedValue)) {
3089         TLOGE(WmsLogTag::WMS_SUB, "Read isPcOrPadFreeMultiWindowMode failed");
3090         return WMError::WM_ERROR_IPC_FAILED;
3091     }
3092     int32_t ret = 0;
3093     if (!reply.ReadInt32(ret)) {
3094         TLOGE(WmsLogTag::WMS_SUB, "Read ret failed");
3095         return WMError::WM_ERROR_IPC_FAILED;
3096     }
3097     isPcOrPadFreeMultiWindowMode = repliedValue;
3098     return static_cast<WMError>(ret);
3099 }
3100 
IsPcWindow(bool & isPcWindow)3101 WMError SceneSessionManagerProxy::IsPcWindow(bool& isPcWindow)
3102 {
3103     MessageParcel data;
3104     MessageParcel reply;
3105     MessageOption option;
3106     if (!data.WriteInterfaceToken(GetDescriptor())) {
3107         TLOGE(WmsLogTag::WMS_UIEXT, "Write interfaceToken failed");
3108         return WMError::WM_ERROR_IPC_FAILED;
3109     }
3110     sptr<IRemoteObject> remote = Remote();
3111     if (remote == nullptr) {
3112         TLOGE(WmsLogTag::WMS_UIEXT, "Remote is null");
3113         return WMError::WM_ERROR_IPC_FAILED;
3114     }
3115     if (remote->SendRequest(static_cast<uint32_t>(
3116         SceneSessionManagerMessage::TRANS_ID_IS_PC_WINDOW),
3117         data, reply, option) != ERR_NONE) {
3118         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest failed");
3119         return WMError::WM_ERROR_IPC_FAILED;
3120     }
3121     bool result = false;
3122     if (!reply.ReadBool(result)) {
3123         TLOGE(WmsLogTag::WMS_UIEXT, "Read isPcWindow failed");
3124         return WMError::WM_ERROR_IPC_FAILED;
3125     }
3126     int32_t ret = 0;
3127     if (!reply.ReadInt32(ret)) {
3128         TLOGE(WmsLogTag::WMS_UIEXT, "Read ret failed");
3129         return WMError::WM_ERROR_IPC_FAILED;
3130     }
3131     isPcWindow = result;
3132     return static_cast<WMError>(ret);
3133 }
3134 
IsFreeMultiWindow(bool & isFreeMultiWindow)3135 WMError SceneSessionManagerProxy::IsFreeMultiWindow(bool& isFreeMultiWindow)
3136 {
3137     MessageParcel data;
3138     MessageParcel reply;
3139     MessageOption option;
3140     if (!data.WriteInterfaceToken(GetDescriptor())) {
3141         TLOGE(WmsLogTag::WMS_PC, "Write interfaceToken failed");
3142         return WMError::WM_ERROR_IPC_FAILED;
3143     }
3144     sptr<IRemoteObject> remote = Remote();
3145     if (remote == nullptr) {
3146         TLOGE(WmsLogTag::WMS_PC, "Remote is null");
3147         return WMError::WM_ERROR_IPC_FAILED;
3148     }
3149     if (remote->SendRequest(static_cast<uint32_t>(
3150         SceneSessionManagerMessage::TRANS_ID_IS_FREE_MULTI_WINDOW),
3151         data, reply, option) != ERR_NONE) {
3152         TLOGE(WmsLogTag::WMS_PC, "SendRequest failed");
3153         return WMError::WM_ERROR_IPC_FAILED;
3154     }
3155     int32_t ret = 0;
3156     if (!reply.ReadInt32(ret)) {
3157         TLOGE(WmsLogTag::WMS_PC, "Read ret failed ret:%{public}d", ret);
3158         return WMError::WM_ERROR_IPC_FAILED;
3159     }
3160     auto ipcRes = static_cast<WMError>(ret);
3161     bool result = false;
3162     if (ipcRes == WMError::WM_OK && !reply.ReadBool(result)) {
3163         TLOGE(WmsLogTag::WMS_PC, "Read isFreeMultiWindow failed");
3164         return WMError::WM_ERROR_IPC_FAILED;
3165     }
3166 
3167     isFreeMultiWindow = result;
3168     return ipcRes;
3169 }
3170 
GetDisplayIdByWindowId(const std::vector<uint64_t> & windowIds,std::unordered_map<uint64_t,DisplayId> & windowDisplayIdMap)3171 WMError SceneSessionManagerProxy::GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds,
3172     std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap)
3173 {
3174     MessageParcel data;
3175     MessageParcel reply;
3176     MessageOption option;
3177     if (!data.WriteInterfaceToken(GetDescriptor())) {
3178         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "WriteInterfaceToken failed");
3179         return WMError::WM_ERROR_IPC_FAILED;
3180     }
3181     if (!data.WriteUInt64Vector(windowIds)) {
3182         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write windowIds failed");
3183         return WMError::WM_ERROR_IPC_FAILED;
3184     }
3185     if (Remote()->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_DISPLAYID_BY_WINDOWID),
3186         data, reply, option) != ERR_NONE) {
3187         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed");
3188         return WMError::WM_ERROR_IPC_FAILED;
3189     }
3190     int32_t mapSize;
3191     if (!reply.ReadInt32(mapSize)) {
3192         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Fail to read mapSize");
3193         return WMError::WM_ERROR_IPC_FAILED;
3194     }
3195     for (int32_t i = 0; i < mapSize; i++) {
3196         uint64_t windowId;
3197         if (!reply.ReadUint64(windowId)) {
3198             TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Fail to read windowId");
3199             return WMError::WM_ERROR_IPC_FAILED;
3200         }
3201         uint64_t displayId;
3202         if (!reply.ReadUint64(displayId)) {
3203             TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Fail to read displayId");
3204             return WMError::WM_ERROR_IPC_FAILED;
3205         }
3206         windowDisplayIdMap[windowId] = displayId;
3207     }
3208     return static_cast<WMError>(reply.ReadInt32());
3209 }
3210 
IsWindowRectAutoSave(const std::string & key,bool & enabled,int persistentId)3211 WMError SceneSessionManagerProxy::IsWindowRectAutoSave(const std::string& key, bool& enabled, int persistentId)
3212 {
3213     MessageParcel data;
3214     MessageParcel reply;
3215     MessageOption option;
3216     if (!data.WriteInterfaceToken(GetDescriptor())) {
3217         TLOGE(WmsLogTag::WMS_MAIN, "Write interfaceToken failed");
3218         return WMError::WM_ERROR_IPC_FAILED;
3219     }
3220     if (!data.WriteString(key)) {
3221         TLOGE(WmsLogTag::WMS_MAIN, "Write key failed");
3222         return WMError::WM_ERROR_IPC_FAILED;
3223     }
3224     if (!data.WriteInt32(persistentId)) {
3225         TLOGE(WmsLogTag::WMS_MAIN, "Write persistentId failed");
3226         return WMError::WM_ERROR_IPC_FAILED;
3227     }
3228     sptr<IRemoteObject> remote = Remote();
3229     if (remote == nullptr) {
3230         TLOGE(WmsLogTag::WMS_MAIN, "remote is null");
3231         return WMError::WM_ERROR_IPC_FAILED;
3232     }
3233     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_IS_WINDOW_RECT_AUTO_SAVE),
3234         data, reply, option) != ERR_NONE) {
3235         TLOGE(WmsLogTag::WMS_MAIN, "SendRequest failed");
3236         return WMError::WM_ERROR_IPC_FAILED;
3237     }
3238     if (!reply.ReadBool(enabled)) {
3239         TLOGE(WmsLogTag::WMS_MAIN, "Read enable failed");
3240         return WMError::WM_ERROR_IPC_FAILED;
3241     }
3242     uint32_t ret = 0;
3243     if (!reply.ReadUint32(ret)) {
3244         TLOGE(WmsLogTag::WMS_MAIN, "Read ret failed");
3245         return WMError::WM_ERROR_IPC_FAILED;
3246     }
3247     return static_cast<WMError>(ret);
3248 }
3249 
SetImageForRecent(uint32_t imgResourceId,ImageFit imageFit,int32_t persistentId)3250 WMError SceneSessionManagerProxy::SetImageForRecent(uint32_t imgResourceId, ImageFit imageFit, int32_t persistentId)
3251 {
3252     MessageParcel data;
3253     MessageParcel reply;
3254     MessageOption option;
3255     if (!data.WriteInterfaceToken(GetDescriptor())) {
3256         TLOGE(WmsLogTag::WMS_PATTERN, "Write interfaceToken failed");
3257         return WMError::WM_ERROR_IPC_FAILED;
3258     }
3259     if (!data.WriteUint32(imgResourceId)) {
3260         TLOGE(WmsLogTag::WMS_PATTERN, "Write imgResourceId failed");
3261         return WMError::WM_ERROR_IPC_FAILED;
3262     }
3263     if (!data.WriteUint32(static_cast<uint32_t>(imageFit))) {
3264         TLOGE(WmsLogTag::WMS_PATTERN, "Write ImageFit failed");
3265         return WMError::WM_ERROR_IPC_FAILED;
3266     }
3267     if (!data.WriteInt32(persistentId)) {
3268         TLOGE(WmsLogTag::WMS_PATTERN, "Write persistentId failed");
3269         return WMError::WM_ERROR_IPC_FAILED;
3270     }
3271     sptr<IRemoteObject> remote = Remote();
3272     if (remote == nullptr) {
3273         TLOGE(WmsLogTag::WMS_PATTERN, "remote is null");
3274         return WMError::WM_ERROR_IPC_FAILED;
3275     }
3276     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_IMAGE_FOR_RECENT),
3277         data, reply, option) != ERR_NONE) {
3278         TLOGE(WmsLogTag::WMS_PATTERN, "SendRequest failed");
3279         return WMError::WM_ERROR_IPC_FAILED;
3280     }
3281     uint32_t ret = 0;
3282     if (!reply.ReadUint32(ret)) {
3283         TLOGE(WmsLogTag::WMS_PATTERN, "Read ret failed");
3284         return WMError::WM_ERROR_IPC_FAILED;
3285     }
3286     return static_cast<WMError>(ret);
3287 }
3288 
SetGlobalDragResizeType(DragResizeType dragResizeType)3289 WMError SceneSessionManagerProxy::SetGlobalDragResizeType(DragResizeType dragResizeType)
3290 {
3291     MessageParcel data;
3292     MessageParcel reply;
3293     MessageOption option;
3294     if (!data.WriteInterfaceToken(GetDescriptor())) {
3295         TLOGE(WmsLogTag::WMS_LAYOUT, "Write interfaceToken failed");
3296         return WMError::WM_ERROR_IPC_FAILED;
3297     }
3298     if (!data.WriteUint32(static_cast<uint32_t>(dragResizeType))) {
3299         TLOGE(WmsLogTag::WMS_LAYOUT, "Write dragResizeType failed");
3300         return WMError::WM_ERROR_IPC_FAILED;
3301     }
3302     sptr<IRemoteObject> remote = Remote();
3303     if (remote == nullptr) {
3304         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
3305         return WMError::WM_ERROR_IPC_FAILED;
3306     }
3307     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_GLOBAL_DRAG_RESIZE_TYPE),
3308         data, reply, option) != ERR_NONE) {
3309         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
3310         return WMError::WM_ERROR_IPC_FAILED;
3311     }
3312     uint32_t ret = 0;
3313     if (!reply.ReadUint32(ret)) {
3314         TLOGE(WmsLogTag::WMS_LAYOUT, "Read ret failed");
3315         return WMError::WM_ERROR_IPC_FAILED;
3316     }
3317     return static_cast<WMError>(ret);
3318 }
3319 
GetGlobalDragResizeType(DragResizeType & dragResizeType)3320 WMError SceneSessionManagerProxy::GetGlobalDragResizeType(DragResizeType& dragResizeType)
3321 {
3322     MessageParcel data;
3323     MessageParcel reply;
3324     MessageOption option;
3325     if (!data.WriteInterfaceToken(GetDescriptor())) {
3326         TLOGE(WmsLogTag::WMS_LAYOUT, "Write interfaceToken failed");
3327         return WMError::WM_ERROR_IPC_FAILED;
3328     }
3329     sptr<IRemoteObject> remote = Remote();
3330     if (remote == nullptr) {
3331         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
3332         return WMError::WM_ERROR_IPC_FAILED;
3333     }
3334     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_GLOBAL_DRAG_RESIZE_TYPE),
3335         data, reply, option) != ERR_NONE) {
3336         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
3337         return WMError::WM_ERROR_IPC_FAILED;
3338     }
3339     uint32_t obtainedDragResizeType = 0;
3340     if (!reply.ReadUint32(obtainedDragResizeType)) {
3341         TLOGE(WmsLogTag::WMS_LAYOUT, "Read dragResizeType failed");
3342         return WMError::WM_ERROR_IPC_FAILED;
3343     }
3344     if (obtainedDragResizeType >= static_cast<uint32_t>(DragResizeType::RESIZE_MAX_VALUE)) {
3345         TLOGE(WmsLogTag::WMS_LAYOUT, "bad dragResizeType value");
3346         return WMError::WM_ERROR_IPC_FAILED;
3347     }
3348     dragResizeType = static_cast<DragResizeType>(obtainedDragResizeType);
3349     uint32_t ret = 0;
3350     if (!reply.ReadUint32(ret)) {
3351         TLOGE(WmsLogTag::WMS_LAYOUT, "Read ret failed");
3352         return WMError::WM_ERROR_IPC_FAILED;
3353     }
3354     return static_cast<WMError>(ret);
3355 }
3356 
SetAppDragResizeType(const std::string & bundleName,DragResizeType dragResizeType)3357 WMError SceneSessionManagerProxy::SetAppDragResizeType(const std::string& bundleName, DragResizeType dragResizeType)
3358 {
3359     MessageParcel data;
3360     MessageParcel reply;
3361     MessageOption option;
3362     if (!data.WriteInterfaceToken(GetDescriptor())) {
3363         TLOGE(WmsLogTag::WMS_LAYOUT, "Write interfaceToken failed");
3364         return WMError::WM_ERROR_IPC_FAILED;
3365     }
3366     if (!data.WriteString(bundleName)) {
3367         TLOGE(WmsLogTag::WMS_LAYOUT, "Write bundleName failed");
3368         return WMError::WM_ERROR_IPC_FAILED;
3369     }
3370     if (!data.WriteUint32(static_cast<uint32_t>(dragResizeType))) {
3371         TLOGE(WmsLogTag::WMS_LAYOUT, "Write dragResizeType failed");
3372         return WMError::WM_ERROR_IPC_FAILED;
3373     }
3374     sptr<IRemoteObject> remote = Remote();
3375     if (remote == nullptr) {
3376         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
3377         return WMError::WM_ERROR_IPC_FAILED;
3378     }
3379     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_APP_DRAG_RESIZE_TYPE),
3380         data, reply, option) != ERR_NONE) {
3381         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
3382         return WMError::WM_ERROR_IPC_FAILED;
3383     }
3384     uint32_t ret = 0;
3385     if (!reply.ReadUint32(ret)) {
3386         TLOGE(WmsLogTag::WMS_LAYOUT, "Read ret failed");
3387         return WMError::WM_ERROR_IPC_FAILED;
3388     }
3389     return static_cast<WMError>(ret);
3390 }
3391 
GetAppDragResizeType(const std::string & bundleName,DragResizeType & dragResizeType)3392 WMError SceneSessionManagerProxy::GetAppDragResizeType(const std::string& bundleName, DragResizeType& dragResizeType)
3393 {
3394     MessageParcel data;
3395     MessageParcel reply;
3396     MessageOption option;
3397     if (!data.WriteInterfaceToken(GetDescriptor())) {
3398         TLOGE(WmsLogTag::WMS_LAYOUT, "Write interfaceToken failed");
3399         return WMError::WM_ERROR_IPC_FAILED;
3400     }
3401     if (!data.WriteString(bundleName)) {
3402         TLOGE(WmsLogTag::WMS_LAYOUT, "Write bundleName failed");
3403         return WMError::WM_ERROR_IPC_FAILED;
3404     }
3405     sptr<IRemoteObject> remote = Remote();
3406     if (remote == nullptr) {
3407         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
3408         return WMError::WM_ERROR_IPC_FAILED;
3409     }
3410     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_APP_DRAG_RESIZE_TYPE),
3411         data, reply, option) != ERR_NONE) {
3412         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
3413         return WMError::WM_ERROR_IPC_FAILED;
3414     }
3415     uint32_t obtainedDragResizeType = 0;
3416     if (!reply.ReadUint32(obtainedDragResizeType)) {
3417         TLOGE(WmsLogTag::WMS_LAYOUT, "Read dragResizeType failed");
3418         return WMError::WM_ERROR_IPC_FAILED;
3419     }
3420     if (obtainedDragResizeType >= static_cast<uint32_t>(DragResizeType::RESIZE_MAX_VALUE)) {
3421         TLOGE(WmsLogTag::WMS_LAYOUT, "bad dragResizeType value");
3422         return WMError::WM_ERROR_IPC_FAILED;
3423     }
3424     dragResizeType = static_cast<DragResizeType>(obtainedDragResizeType);
3425     uint32_t ret = 0;
3426     if (!reply.ReadUint32(ret)) {
3427         TLOGE(WmsLogTag::WMS_LAYOUT, "Read ret failed");
3428         return WMError::WM_ERROR_IPC_FAILED;
3429     }
3430     return static_cast<WMError>(ret);
3431 }
3432 
SetAppKeyFramePolicy(const std::string & bundleName,const KeyFramePolicy & keyFramePolicy)3433 WMError SceneSessionManagerProxy::SetAppKeyFramePolicy(
3434     const std::string& bundleName, const KeyFramePolicy& keyFramePolicy)
3435 {
3436     MessageParcel data;
3437     MessageParcel reply;
3438     MessageOption option;
3439     if (!data.WriteInterfaceToken(GetDescriptor())) {
3440         TLOGE(WmsLogTag::WMS_LAYOUT, "Write interfaceToken failed");
3441         return WMError::WM_ERROR_IPC_FAILED;
3442     }
3443     if (!data.WriteString(bundleName)) {
3444         TLOGE(WmsLogTag::WMS_LAYOUT, "Write bundleName failed");
3445         return WMError::WM_ERROR_IPC_FAILED;
3446     }
3447     if (!data.WriteParcelable(&keyFramePolicy)) {
3448         TLOGE(WmsLogTag::WMS_LAYOUT, "Write keyFramePolicy failed");
3449         return WMError::WM_ERROR_IPC_FAILED;
3450     }
3451     sptr<IRemoteObject> remote = Remote();
3452     if (remote == nullptr) {
3453         TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null");
3454         return WMError::WM_ERROR_IPC_FAILED;
3455     }
3456     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_APP_KEY_FRAME_POLICY),
3457         data, reply, option) != ERR_NONE) {
3458         TLOGE(WmsLogTag::WMS_LAYOUT, "SendRequest failed");
3459         return WMError::WM_ERROR_IPC_FAILED;
3460     }
3461     int32_t ret = 0;
3462     if (!reply.ReadInt32(ret)) {
3463         TLOGE(WmsLogTag::WMS_LAYOUT, "Read ret failed");
3464         return WMError::WM_ERROR_IPC_FAILED;
3465     }
3466     return static_cast<WMError>(ret);
3467 }
3468 
ShiftAppWindowPointerEvent(int32_t sourcePersistentId,int32_t targetPersistentId,int32_t fingerId)3469 WMError SceneSessionManagerProxy::ShiftAppWindowPointerEvent(int32_t sourcePersistentId, int32_t targetPersistentId,
3470                                                              int32_t fingerId)
3471 {
3472     MessageParcel data;
3473     MessageParcel reply;
3474     MessageOption option;
3475     if (!data.WriteInterfaceToken(GetDescriptor())) {
3476         TLOGE(WmsLogTag::WMS_PC, "Write interfaceToken failed");
3477         return WMError::WM_ERROR_IPC_FAILED;
3478     }
3479     if (!data.WriteInt32(sourcePersistentId)) {
3480         TLOGE(WmsLogTag::WMS_PC, "Write sourcePersistentId failed");
3481         return WMError::WM_ERROR_IPC_FAILED;
3482     }
3483     if (!data.WriteInt32(targetPersistentId)) {
3484         TLOGE(WmsLogTag::WMS_PC, "Write targetPersistentId failed");
3485         return WMError::WM_ERROR_IPC_FAILED;
3486     }
3487     if (!data.WriteInt32(fingerId)) {
3488         TLOGE(WmsLogTag::WMS_PC, "Write fingerId failed");
3489         return WMError::WM_ERROR_IPC_FAILED;
3490     }
3491     sptr<IRemoteObject> remote = Remote();
3492     if (remote == nullptr) {
3493         TLOGE(WmsLogTag::WMS_PC, "remote is null");
3494         return WMError::WM_ERROR_IPC_FAILED;
3495     }
3496     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SHIFT_APP_WINDOW_POINTER_EVENT),
3497         data, reply, option) != ERR_NONE) {
3498         TLOGE(WmsLogTag::WMS_PC, "SendRequest failed");
3499         return WMError::WM_ERROR_IPC_FAILED;
3500     }
3501     return static_cast<WMError>(reply.ReadInt32());
3502 }
3503 
SetStartWindowBackgroundColor(const std::string & moduleName,const std::string & abilityName,uint32_t color,int32_t uid)3504 WMError SceneSessionManagerProxy::SetStartWindowBackgroundColor(
3505     const std::string& moduleName, const std::string& abilityName, uint32_t color, int32_t uid)
3506 {
3507     MessageParcel data;
3508     MessageParcel reply;
3509     MessageOption option;
3510     if (!data.WriteInterfaceToken(GetDescriptor())) {
3511         TLOGE(WmsLogTag::WMS_PATTERN, "Write interfaceToken failed");
3512         return WMError::WM_ERROR_IPC_FAILED;
3513     }
3514     if (!data.WriteString(moduleName)) {
3515         TLOGE(WmsLogTag::WMS_PATTERN, "Write moduleName failed");
3516         return WMError::WM_ERROR_IPC_FAILED;
3517     }
3518     if (!data.WriteString(abilityName)) {
3519         TLOGE(WmsLogTag::WMS_PATTERN, "Write abilityName failed");
3520         return WMError::WM_ERROR_IPC_FAILED;
3521     }
3522     if (!data.WriteUint32(color)) {
3523         TLOGE(WmsLogTag::WMS_PATTERN, "Write color failed");
3524         return WMError::WM_ERROR_IPC_FAILED;
3525     }
3526     if (!data.WriteInt32(uid)) {
3527         TLOGE(WmsLogTag::WMS_PATTERN, "Write uid failed");
3528         return WMError::WM_ERROR_IPC_FAILED;
3529     }
3530     sptr<IRemoteObject> remote = Remote();
3531     if (remote == nullptr) {
3532         TLOGE(WmsLogTag::WMS_PATTERN, "Remote is null");
3533         return WMError::WM_ERROR_IPC_FAILED;
3534     }
3535     if (remote->SendRequest(static_cast<uint32_t>(
3536         SceneSessionManagerMessage::TRANS_ID_SET_START_WINDOW_BACKGROUND_COLOR), data, reply, option) != ERR_NONE) {
3537         TLOGE(WmsLogTag::WMS_PATTERN, "SendRequest failed");
3538         return WMError::WM_ERROR_IPC_FAILED;
3539     }
3540     int32_t ret = 0;
3541     if (!reply.ReadInt32(ret)) {
3542         return WMError::WM_ERROR_IPC_FAILED;
3543     }
3544     return static_cast<WMError>(ret);
3545 }
3546 
MinimizeByWindowId(const std::vector<int32_t> & windowIds)3547 WMError SceneSessionManagerProxy::MinimizeByWindowId(const std::vector<int32_t>& windowIds)
3548 {
3549     MessageParcel data;
3550     MessageParcel reply;
3551     MessageOption option;
3552     if (!data.WriteInterfaceToken(GetDescriptor())) {
3553         TLOGE(WmsLogTag::WMS_LIFE, "Write interfaceToken failed");
3554         return WMError::WM_ERROR_IPC_FAILED;
3555     }
3556     if (!data.WriteInt32Vector(windowIds)) {
3557         TLOGE(WmsLogTag::WMS_LIFE, "Write int32Vector failed");
3558         return WMError::WM_ERROR_IPC_FAILED;
3559     }
3560     sptr<IRemoteObject> remote = Remote();
3561     if (remote == nullptr) {
3562         TLOGE(WmsLogTag::WMS_LIFE, "Remote is null");
3563         return WMError::WM_ERROR_IPC_FAILED;
3564     }
3565     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_MINIMIZE_BY_WINDOW_ID),
3566         data, reply, option) != ERR_NONE) {
3567         TLOGE(WmsLogTag::WMS_LIFE, "SendRequest failed");
3568         return WMError::WM_ERROR_IPC_FAILED;
3569     }
3570     return static_cast<WMError>(reply.ReadInt32());
3571 }
3572 
SetForegroundWindowNum(uint32_t windowNum)3573 WMError SceneSessionManagerProxy::SetForegroundWindowNum(uint32_t windowNum)
3574 {
3575     MessageParcel data;
3576     MessageParcel reply;
3577     MessageOption option;
3578     if (!data.WriteInterfaceToken(GetDescriptor())) {
3579         TLOGE(WmsLogTag::WMS_PC, "Write interfaceToken failed");
3580         return WMError::WM_ERROR_IPC_FAILED;
3581     }
3582     if (!data.WriteUint32(windowNum)) {
3583         TLOGE(WmsLogTag::WMS_PC, "Write windowNum failed");
3584         return WMError::WM_ERROR_IPC_FAILED;
3585     }
3586     sptr<IRemoteObject> remote = Remote();
3587     if (remote == nullptr) {
3588         TLOGE(WmsLogTag::WMS_PC, "Remote is null");
3589         return WMError::WM_ERROR_IPC_FAILED;
3590     }
3591     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_SET_FOREGROUND_WINDOW_NUM),
3592         data, reply, option) != ERR_NONE) {
3593         TLOGE(WmsLogTag::WMS_PC, "SendRequest failed");
3594         return WMError::WM_ERROR_IPC_FAILED;
3595     }
3596     return static_cast<WMError>(reply.ReadInt32());
3597 }
3598 
UseImplicitAnimation(int32_t hostWindowId,bool useImplicit)3599 WSError SceneSessionManagerProxy::UseImplicitAnimation(int32_t hostWindowId, bool useImplicit)
3600 {
3601     TLOGD(WmsLogTag::WMS_UIEXT, "run SceneSessionManagerProxy::GetHostWindowRect");
3602     MessageParcel data;
3603     MessageParcel reply;
3604     MessageOption option;
3605     if (!data.WriteInterfaceToken(GetDescriptor())) {
3606         TLOGE(WmsLogTag::WMS_UIEXT, "Write interface token failed.");
3607         return WSError::WS_ERROR_IPC_FAILED;
3608     }
3609     if (!data.WriteInt32(hostWindowId)) {
3610         TLOGE(WmsLogTag::WMS_UIEXT, "Write hostWindowId failed");
3611         return WSError::WS_ERROR_IPC_FAILED;
3612     }
3613     if (!data.WriteBool(useImplicit)) {
3614         TLOGE(WmsLogTag::WMS_UIEXT, "Write useImplicit failed");
3615         return WSError::WS_ERROR_IPC_FAILED;
3616     }
3617     sptr<IRemoteObject> remote = Remote();
3618     if (remote == nullptr) {
3619         TLOGE(WmsLogTag::WMS_UIEXT, "remote is null");
3620         return WSError::WS_ERROR_IPC_FAILED;
3621     }
3622     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_USE_IMPLICIT_ANIMATION),
3623         data, reply, option) != ERR_NONE) {
3624         TLOGE(WmsLogTag::WMS_UIEXT, "SendRequest UseImplicitAnimation failed");
3625         return WSError::WS_ERROR_IPC_FAILED;
3626     }
3627     int32_t ret = 0;
3628     if (!reply.ReadInt32(ret)) {
3629         return WSError::WS_ERROR_IPC_FAILED;
3630     }
3631     return static_cast<WSError>(ret);
3632 }
3633 
AnimateTo(int32_t windowId,const WindowAnimationProperty & animationProperty,const WindowAnimationOption & animationOption)3634 WMError SceneSessionManagerProxy::AnimateTo(int32_t windowId, const WindowAnimationProperty& animationProperty,
3635     const WindowAnimationOption& animationOption)
3636 {
3637     MessageParcel data;
3638     MessageParcel reply;
3639     MessageOption option;
3640     if (!data.WriteInterfaceToken(GetDescriptor())) {
3641         TLOGE(WmsLogTag::WMS_ANIMATION, "Write interfaceToken failed");
3642         return WMError::WM_ERROR_IPC_FAILED;
3643     }
3644     if (!data.WriteInt32(windowId)) {
3645         TLOGE(WmsLogTag::WMS_ANIMATION, "Write windowId failed");
3646         return WMError::WM_ERROR_IPC_FAILED;
3647     }
3648     if (!data.WriteParcelable(&animationProperty)) {
3649         TLOGE(WmsLogTag::WMS_ANIMATION, "Write animationProperty failed");
3650         return WMError::WM_ERROR_IPC_FAILED;
3651     }
3652     if (!data.WriteParcelable(&animationOption)) {
3653         TLOGE(WmsLogTag::WMS_ANIMATION, "Write animationOption failed");
3654         return WMError::WM_ERROR_IPC_FAILED;
3655     }
3656     sptr<IRemoteObject> remote = Remote();
3657     if (remote == nullptr) {
3658         TLOGE(WmsLogTag::WMS_ANIMATION, "Remote is null");
3659         return WMError::WM_ERROR_IPC_FAILED;
3660     }
3661     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_ANIMATE_TO_WINDOW),
3662         data, reply, option) != ERR_NONE) {
3663         TLOGE(WmsLogTag::WMS_ANIMATION, "SendRequest failed");
3664         return WMError::WM_ERROR_IPC_FAILED;
3665     }
3666     return static_cast<WMError>(reply.ReadInt32());
3667 }
3668 
CreateUIEffectController(const sptr<IUIEffectControllerClient> & controllerClient,sptr<IUIEffectController> & controller,int32_t & controllerId)3669 WMError SceneSessionManagerProxy::CreateUIEffectController(const sptr<IUIEffectControllerClient>& controllerClient,
3670     sptr<IUIEffectController>& controller, int32_t& controllerId)
3671 {
3672     MessageParcel data;
3673     MessageParcel reply;
3674     MessageOption option;
3675     if (!data.WriteInterfaceToken(GetDescriptor())) {
3676         TLOGE(WmsLogTag::WMS_ANIMATION, "Write interfaceToken failed");
3677         return WMError::WM_ERROR_IPC_FAILED;
3678     }
3679     if (!data.WriteRemoteObject(controllerClient->AsObject())) {
3680         TLOGE(WmsLogTag::WMS_ANIMATION, "Write controller client failed!");
3681         return WMError::WM_ERROR_IPC_FAILED;
3682     }
3683     sptr<IRemoteObject> remote = Remote();
3684     if (remote == nullptr) {
3685         TLOGE(WmsLogTag::WMS_ANIMATION, "Remote is null");
3686         return WMError::WM_ERROR_IPC_FAILED;
3687     }
3688     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_CREATE_UI_EFFECT_CONTROLLER),
3689         data, reply, option) != ERR_NONE) {
3690         TLOGE(WmsLogTag::WMS_ANIMATION, "SendRequest failed");
3691         return WMError::WM_ERROR_IPC_FAILED;
3692     }
3693     WMError err = static_cast<WMError>(reply.ReadInt32());
3694     if (err != WMError::WM_OK) {
3695         return err;
3696     }
3697     controllerId = reply.ReadInt32();
3698     sptr<IRemoteObject> controllerObject = reply.ReadRemoteObject();
3699     if (controllerObject == nullptr) {
3700         TLOGE(WmsLogTag::WMS_ANIMATION, "receive filter failed");
3701         return WMError::WM_ERROR_IPC_FAILED;
3702     }
3703     controller = iface_cast<IUIEffectController>(controllerObject);
3704     return err;
3705 }
3706 
AddSessionBlackList(const std::unordered_set<std::string> & bundleNames,const std::unordered_set<std::string> & privacyWindowTags)3707 WMError SceneSessionManagerProxy::AddSessionBlackList(
3708     const std::unordered_set<std::string>& bundleNames, const std::unordered_set<std::string>& privacyWindowTags)
3709 {
3710     MessageParcel data;
3711     MessageParcel reply;
3712     MessageOption option;
3713     if (!data.WriteInterfaceToken(GetDescriptor())) {
3714         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write interfaceToken failed");
3715         return WMError::WM_ERROR_IPC_FAILED;
3716     }
3717     if (!data.WriteUint64(bundleNames.size())) {
3718         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write size failed");
3719         return WMError::WM_ERROR_IPC_FAILED;
3720     }
3721     for (auto bundleName : bundleNames) {
3722         if (!data.WriteString(bundleName)) {
3723             TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write bundleName failed");
3724             return WMError::WM_ERROR_IPC_FAILED;
3725         }
3726     }
3727     if (!data.WriteUint64(privacyWindowTags.size())) {
3728         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write size failed");
3729         return WMError::WM_ERROR_IPC_FAILED;
3730     }
3731     for (auto privacyWindowTag : privacyWindowTags) {
3732         if (!data.WriteString(privacyWindowTag)) {
3733             TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write privacyWindowTag failed");
3734             return WMError::WM_ERROR_IPC_FAILED;
3735         }
3736     }
3737     sptr<IRemoteObject> remote = Remote();
3738     if (remote == nullptr) {
3739         TLOGE(WmsLogTag::WMS_ANIMATION, "Remote is null");
3740         return WMError::WM_ERROR_IPC_FAILED;
3741     }
3742     if (remote->SendRequest(
3743         static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_ADD_SESSION_BLACK_LIST),
3744         data, reply, option) != ERR_NONE) {
3745         TLOGE(WmsLogTag::WMS_ANIMATION, "SendRequest failed");
3746         return WMError::WM_ERROR_IPC_FAILED;
3747     }
3748     int32_t ret = 0;
3749     if (!reply.ReadInt32(ret)) {
3750         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read ret failed");
3751         return WMError::WM_ERROR_IPC_FAILED;
3752     }
3753     return static_cast<WMError>(ret);
3754 }
3755 
RemoveSessionBlackList(const std::unordered_set<std::string> & bundleNames,const std::unordered_set<std::string> & privacyWindowTags)3756 WMError SceneSessionManagerProxy::RemoveSessionBlackList(
3757     const std::unordered_set<std::string>& bundleNames, const std::unordered_set<std::string>& privacyWindowTags)
3758 {
3759     MessageParcel data;
3760     MessageParcel reply;
3761     MessageOption option;
3762     if (!data.WriteInterfaceToken(GetDescriptor())) {
3763         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write interfaceToken failed");
3764         return WMError::WM_ERROR_IPC_FAILED;
3765     }
3766     if (!data.WriteUint64(bundleNames.size())) {
3767         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write size failed");
3768         return WMError::WM_ERROR_IPC_FAILED;
3769     }
3770     for (auto bundleName : bundleNames) {
3771         if (!data.WriteString(bundleName)) {
3772             TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write bundleName failed");
3773             return WMError::WM_ERROR_IPC_FAILED;
3774         }
3775     }
3776     if (!data.WriteUint64(privacyWindowTags.size())) {
3777         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write size failed");
3778         return WMError::WM_ERROR_IPC_FAILED;
3779     }
3780     for (auto privacyWindowTag : privacyWindowTags) {
3781         if (!data.WriteString(privacyWindowTag)) {
3782             TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write privacyWindowTag failed");
3783             return WMError::WM_ERROR_IPC_FAILED;
3784         }
3785     }
3786     sptr<IRemoteObject> remote = Remote();
3787     if (remote == nullptr) {
3788         TLOGE(WmsLogTag::WMS_ANIMATION, "Remote is null");
3789         return WMError::WM_ERROR_IPC_FAILED;
3790     }
3791     if (remote->SendRequest(
3792         static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_REMOVE_SESSION_BLACK_LIST),
3793         data, reply, option) != ERR_NONE) {
3794         TLOGE(WmsLogTag::WMS_ANIMATION, "SendRequest failed");
3795         return WMError::WM_ERROR_IPC_FAILED;
3796     }
3797     int32_t ret = 0;
3798     if (!reply.ReadInt32(ret)) {
3799         TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Read ret failed");
3800         return WMError::WM_ERROR_IPC_FAILED;
3801     }
3802     return static_cast<WMError>(ret);
3803 }
3804 
GetPiPSettingSwitchStatus(bool & switchStatus)3805 WMError SceneSessionManagerProxy::GetPiPSettingSwitchStatus(bool& switchStatus)
3806 {
3807     MessageParcel data;
3808     MessageParcel reply;
3809     MessageOption option;
3810     if (!data.WriteInterfaceToken(GetDescriptor())) {
3811         TLOGE(WmsLogTag::WMS_PIP, "Write interfaceToken failed");
3812         return WMError::WM_ERROR_IPC_FAILED;
3813     }
3814     sptr remote = Remote();
3815     if (remote == nullptr) {
3816         TLOGE(WmsLogTag::WMS_PIP, "Remote is null");
3817         return WMError::WM_ERROR_IPC_FAILED;
3818     }
3819     if (remote->SendRequest(static_cast<uint32_t>(SceneSessionManagerMessage::TRANS_ID_GET_PIP_SWITCH_STATUS),
3820         data, reply, option) != ERR_NONE) {
3821         TLOGE(WmsLogTag::WMS_PIP, "SendRequest failed");
3822         return WMError::WM_ERROR_IPC_FAILED;
3823     }
3824     bool status = false;
3825     if (!reply.ReadBool(status)) {
3826         TLOGE(WmsLogTag::WMS_PIP, "Read status failed");
3827         return WMError::WM_ERROR_IPC_FAILED;
3828     }
3829     int32_t ret = 0;
3830     if (!reply.ReadInt32(ret)) {
3831         TLOGE(WmsLogTag::WMS_PIP, "Read ret failed");
3832         return WMError::WM_ERROR_IPC_FAILED;
3833     }
3834     switchStatus = status;
3835     return static_cast<WMError>(ret);
3836 }
3837 } // namespace OHOS::Rosen
3838