1/*
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#include "window_adapter.h"
17#include <iservice_registry.h>
18#include <key_event.h>
19#include <system_ability_definition.h>
20#include <rs_window_animation_target.h>
21#include "window_manager.h"
22#include "window_manager_proxy.h"
23#include "window_manager_hilog.h"
24#include "wm_common.h"
25#include "scene_board_judgement.h"
26#include "session_manager.h"
27#include "focus_change_info.h"
28#include <unistd.h>
29#include "window_session_impl.h"
30
31namespace OHOS {
32namespace Rosen {
33namespace {
34constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowAdapter"};
35}
36WM_IMPLEMENT_SINGLE_INSTANCE(WindowAdapter)
37
38#define INIT_PROXY_CHECK_RETURN(ret)                             \
39    do {                                                         \
40        if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { \
41            if (!InitSSMProxy()) {                               \
42                WLOGFE("InitSSMProxy failed!");                  \
43                return ret;                                      \
44            }                                                    \
45        } else {                                                 \
46            if (!InitWMSProxy()) {                               \
47                WLOGFE("InitWMSProxy failed!");                  \
48                return ret;                                      \
49            }                                                    \
50        }                                                        \
51    } while (false)
52
53#define CHECK_PROXY_RETURN_ERROR_IF_NULL(proxy, ret)                      \
54    do {                                                                  \
55        if ((proxy) == nullptr) {                                         \
56            TLOGE(WmsLogTag::DEFAULT, "window manager proxy is nullptr"); \
57            return ret;                                                   \
58        }                                                                 \
59    } while (false)
60
61#define CHECK_PROXY_RETURN_IF_NULL(proxy)                                 \
62    do {                                                                  \
63        if ((proxy) == nullptr) {                                         \
64            TLOGE(WmsLogTag::DEFAULT, "window manager proxy is nullptr"); \
65            return;                                                       \
66        }                                                                 \
67    } while (false)
68
69WMError WindowAdapter::CreateWindow(sptr<IWindow>& window, sptr<WindowProperty>& windowProperty,
70    std::shared_ptr<RSSurfaceNode> surfaceNode, uint32_t& windowId, const sptr<IRemoteObject>& token)
71{
72    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
73
74    auto wmsProxy = GetWindowManagerServiceProxy();
75    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
76    return wmsProxy->CreateWindow(window, windowProperty, surfaceNode, windowId, token);
77}
78
79WMError WindowAdapter::AddWindow(sptr<WindowProperty>& windowProperty)
80{
81    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
82
83    auto wmsProxy = GetWindowManagerServiceProxy();
84    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
85    return wmsProxy->AddWindow(windowProperty);
86}
87
88WMError WindowAdapter::RemoveWindow(uint32_t windowId, bool isFromInnerkits)
89{
90    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
91
92    auto wmsProxy = GetWindowManagerServiceProxy();
93    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
94    return wmsProxy->RemoveWindow(windowId, isFromInnerkits);
95}
96
97WMError WindowAdapter::DestroyWindow(uint32_t windowId)
98{
99    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
100
101    auto wmsProxy = GetWindowManagerServiceProxy();
102    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
103    return wmsProxy->DestroyWindow(windowId);
104}
105
106WMError WindowAdapter::RequestFocus(uint32_t windowId)
107{
108    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
109
110    auto wmsProxy = GetWindowManagerServiceProxy();
111    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
112    return wmsProxy->RequestFocus(windowId);
113}
114
115WMError WindowAdapter::RegisterWindowManagerAgent(WindowManagerAgentType type,
116    const sptr<IWindowManagerAgent>& windowManagerAgent)
117{
118    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
119
120    auto wmsProxy = GetWindowManagerServiceProxy();
121    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
122
123    {
124        std::lock_guard<std::mutex> lock(mutex_);
125        if (windowManagerAgentMap_.find(type) == windowManagerAgentMap_.end()) {
126            windowManagerAgentMap_[type] = std::set<sptr<IWindowManagerAgent>>();
127        }
128        windowManagerAgentMap_[type].insert(windowManagerAgent);
129    }
130
131    return wmsProxy->RegisterWindowManagerAgent(type, windowManagerAgent);
132}
133
134WMError WindowAdapter::UnregisterWindowManagerAgent(WindowManagerAgentType type,
135    const sptr<IWindowManagerAgent>& windowManagerAgent)
136{
137    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
138
139    auto wmsProxy = GetWindowManagerServiceProxy();
140    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
141    auto ret = wmsProxy->UnregisterWindowManagerAgent(type, windowManagerAgent);
142
143    std::lock_guard<std::mutex> lock(mutex_);
144    if (windowManagerAgentMap_.find(type) == windowManagerAgentMap_.end()) {
145        WLOGFW("WindowManagerAgentType = %{public}d not found", type);
146        return ret;
147    }
148
149    auto& agentSet = windowManagerAgentMap_[type];
150    auto agent = std::find(agentSet.begin(), agentSet.end(), windowManagerAgent);
151    if (agent == agentSet.end()) {
152        WLOGFW("Cannot find agent,  type = %{public}d", type);
153        return ret;
154    }
155    agentSet.erase(agent);
156
157    return ret;
158}
159
160WMError WindowAdapter::CheckWindowId(int32_t windowId, int32_t& pid)
161{
162    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
163
164    auto wmsProxy = GetWindowManagerServiceProxy();
165    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
166    return wmsProxy->CheckWindowId(windowId, pid);
167}
168
169WMError WindowAdapter::GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos)
170{
171    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
172
173    auto wmsProxy = GetWindowManagerServiceProxy();
174    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
175    return wmsProxy->GetAccessibilityWindowInfo(infos);
176}
177
178WMError WindowAdapter::GetUnreliableWindowInfo(int32_t windowId,
179    std::vector<sptr<UnreliableWindowInfo>>& infos)
180{
181    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
182
183    auto wmsProxy = GetWindowManagerServiceProxy();
184    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
185    return wmsProxy->GetUnreliableWindowInfo(windowId, infos);
186}
187
188WMError WindowAdapter::GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos)
189{
190    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
191
192    auto wmsProxy = GetWindowManagerServiceProxy();
193    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
194    return wmsProxy->GetVisibilityWindowInfo(infos);
195}
196
197WMError WindowAdapter::SetWindowAnimationController(const sptr<RSIWindowAnimationController>& controller)
198{
199    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
200
201    auto wmsProxy = GetWindowManagerServiceProxy();
202    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
203    return wmsProxy->SetWindowAnimationController(controller);
204}
205
206WMError WindowAdapter::GetAvoidAreaByType(uint32_t windowId, AvoidAreaType type, AvoidArea& avoidArea)
207{
208    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
209
210    auto wmsProxy = GetWindowManagerServiceProxy();
211    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
212    avoidArea = wmsProxy->GetAvoidAreaByType(windowId, type);
213    return WMError::WM_OK;
214}
215
216void WindowAdapter::NotifyServerReadyToMoveOrDrag(uint32_t windowId, sptr<WindowProperty>& windowProperty,
217    sptr<MoveDragProperty>& moveDragProperty)
218{
219    INIT_PROXY_CHECK_RETURN();
220
221    auto wmsProxy = GetWindowManagerServiceProxy();
222    CHECK_PROXY_RETURN_IF_NULL(wmsProxy);
223    wmsProxy->NotifyServerReadyToMoveOrDrag(windowId, windowProperty, moveDragProperty);
224}
225
226void WindowAdapter::ProcessPointDown(uint32_t windowId, bool isPointDown)
227{
228    INIT_PROXY_CHECK_RETURN();
229
230    auto wmsProxy = GetWindowManagerServiceProxy();
231    CHECK_PROXY_RETURN_IF_NULL(wmsProxy);
232    wmsProxy->ProcessPointDown(windowId, isPointDown);
233}
234
235void WindowAdapter::ProcessPointUp(uint32_t windowId)
236{
237    INIT_PROXY_CHECK_RETURN();
238
239    auto wmsProxy = GetWindowManagerServiceProxy();
240    CHECK_PROXY_RETURN_IF_NULL(wmsProxy);
241    wmsProxy->ProcessPointUp(windowId);
242}
243
244WMError WindowAdapter::MinimizeAllAppWindows(DisplayId displayId)
245{
246    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
247
248    auto wmsProxy = GetWindowManagerServiceProxy();
249    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
250    return wmsProxy->MinimizeAllAppWindows(displayId);
251}
252
253WMError WindowAdapter::ToggleShownStateForAllAppWindows()
254{
255    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
256
257    auto wmsProxy = GetWindowManagerServiceProxy();
258    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
259    return wmsProxy->ToggleShownStateForAllAppWindows();
260}
261
262WMError WindowAdapter::GetSystemConfig(SystemConfig& systemConfig)
263{
264    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
265
266    auto wmsProxy = GetWindowManagerServiceProxy();
267    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
268    return wmsProxy->GetSystemConfig(systemConfig);
269}
270
271WMError WindowAdapter::GetModeChangeHotZones(DisplayId displayId, ModeChangeHotZones& hotZones)
272{
273    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
274
275    auto wmsProxy = GetWindowManagerServiceProxy();
276    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
277    return wmsProxy->GetModeChangeHotZones(displayId, hotZones);
278}
279
280bool WindowAdapter::InitWMSProxy()
281{
282    std::lock_guard<std::mutex> lock(mutex_);
283    if (!isProxyValid_) {
284        sptr<ISystemAbilityManager> systemAbilityManager =
285            SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
286        if (!systemAbilityManager) {
287            WLOGFE("Failed to get system ability mgr.");
288            return false;
289        }
290
291        sptr<IRemoteObject> remoteObject = systemAbilityManager->GetSystemAbility(WINDOW_MANAGER_SERVICE_ID);
292        if (!remoteObject) {
293            WLOGFE("Failed to get window manager service.");
294            return false;
295        }
296
297        windowManagerServiceProxy_ = iface_cast<IWindowManager>(remoteObject);
298        if (!windowManagerServiceProxy_ || !windowManagerServiceProxy_->AsObject()) {
299            WLOGFE("Failed to get system window manager services");
300            return false;
301        }
302
303        wmsDeath_ = new WMSDeathRecipient();
304        if (!wmsDeath_) {
305            WLOGFE("Failed to create death Recipient ptr WMSDeathRecipient");
306            return false;
307        }
308        if (remoteObject->IsProxyObject() && !remoteObject->AddDeathRecipient(wmsDeath_)) {
309            WLOGFE("Failed to add death recipient");
310            return false;
311        }
312        isProxyValid_ = true;
313    }
314    return true;
315}
316
317void WindowAdapter::RegisterSessionRecoverCallbackFunc(
318    int32_t persistentId, const SessionRecoverCallbackFunc& callbackFunc)
319{
320    TLOGI(WmsLogTag::WMS_RECOVER, "persistentId = %{public}d", persistentId);
321    std::lock_guard<std::mutex> lock(mutex_);
322    sessionRecoverCallbackFuncMap_[persistentId] = callbackFunc;
323}
324
325WMError WindowAdapter::GetSnapshotByWindowId(int32_t windowId, std::shared_ptr<Media::PixelMap>& pixelMap)
326{
327    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_IPC_FAILED);
328
329    auto wmsProxy = GetWindowManagerServiceProxy();
330    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_IPC_FAILED);
331    return wmsProxy->GetSnapshotByWindowId(windowId, pixelMap);
332}
333
334void WindowAdapter::UnregisterSessionRecoverCallbackFunc(int32_t persistentId)
335{
336    std::lock_guard<std::mutex> lock(mutex_);
337    auto it = sessionRecoverCallbackFuncMap_.find(persistentId);
338    if (it != sessionRecoverCallbackFuncMap_.end()) {
339        sessionRecoverCallbackFuncMap_.erase(it);
340    }
341}
342
343WMError WindowAdapter::RegisterWMSConnectionChangedListener(const WMSConnectionChangedCallbackFunc& callbackFunc)
344{
345    WLOGFI("RegisterWMSConnectionChangedListener in");
346    return SessionManager::GetInstance().RegisterWMSConnectionChangedListener(callbackFunc);
347}
348
349void WindowAdapter::WindowManagerAndSessionRecover()
350{
351    ClearWindowAdapter();
352    if (!InitSSMProxy()) {
353        TLOGE(WmsLogTag::WMS_RECOVER, "InitSSMProxy failed");
354        return;
355    }
356
357    ReregisterWindowManagerAgent();
358
359    std::map<int32_t, SessionRecoverCallbackFunc> sessionRecoverCallbackFuncMap;
360    {
361        std::lock_guard<std::mutex> lock(mutex_);
362        sessionRecoverCallbackFuncMap = sessionRecoverCallbackFuncMap_;
363    }
364    for (const auto& it : sessionRecoverCallbackFuncMap) {
365        TLOGD(WmsLogTag::WMS_RECOVER, "Session recover callback, persistentId = %{public}" PRId32, it.first);
366        auto ret = it.second();
367        if (ret != WMError::WM_OK) {
368            TLOGE(WmsLogTag::WMS_RECOVER, "Session recover callback, persistentId = %{public}" PRId32 " is error",
369                it.first);
370            return;
371        }
372    }
373}
374
375void WindowAdapter::ReregisterWindowManagerAgent()
376{
377    std::lock_guard<std::mutex> lock(mutex_);
378    if (!windowManagerServiceProxy_ || !windowManagerServiceProxy_->AsObject()) {
379        TLOGE(WmsLogTag::WMS_RECOVER, "proxy is null");
380        return;
381    }
382    for (const auto& it : windowManagerAgentMap_) {
383        TLOGI(WmsLogTag::WMS_RECOVER, "Window manager agent type = %{public}" PRIu32 ", size = %{public}" PRIu64,
384            it.first, static_cast<uint64_t>(it.second.size()));
385        for (auto& agent : it.second) {
386            if (windowManagerServiceProxy_->RegisterWindowManagerAgent(it.first, agent) != WMError::WM_OK) {
387                TLOGE(WmsLogTag::WMS_RECOVER, "failed");
388            }
389        }
390    }
391}
392
393void WindowAdapter::OnUserSwitch()
394{
395    TLOGI(WmsLogTag::WMS_MULTI_USER, "User switched");
396    ClearWindowAdapter();
397    InitSSMProxy();
398    ReregisterWindowManagerAgent();
399}
400
401bool WindowAdapter::InitSSMProxy()
402{
403    std::lock_guard<std::mutex> lock(mutex_);
404    if (!isProxyValid_) {
405        windowManagerServiceProxy_ = SessionManager::GetInstance().GetSceneSessionManagerProxy();
406        if (!windowManagerServiceProxy_ || !windowManagerServiceProxy_->AsObject()) {
407            WLOGFE("Failed to get system scene session manager services");
408            return false;
409        }
410        wmsDeath_ = new (std::nothrow) WMSDeathRecipient();
411        if (!wmsDeath_) {
412            WLOGFE("Failed to create death Recipient ptr WMSDeathRecipient");
413            return false;
414        }
415        sptr<IRemoteObject> remoteObject = windowManagerServiceProxy_->AsObject();
416        if (remoteObject->IsProxyObject() && !remoteObject->AddDeathRecipient(wmsDeath_)) {
417            WLOGFE("Failed to add death recipient");
418            return false;
419        }
420        if (!recoverInitialized_) {
421            SessionManager::GetInstance().RegisterWindowManagerRecoverCallbackFunc(
422                [this] { this->WindowManagerAndSessionRecover(); });
423            recoverInitialized_ = true;
424        }
425        // U0 system user needs to subscribe OnUserSwitch event
426        int32_t clientUserId = GetUserIdByUid(getuid());
427        if (clientUserId == SYSTEM_USERID && !isRegisteredUserSwitchListener_) {
428            SessionManager::GetInstance().RegisterUserSwitchListener([this]() { this->OnUserSwitch(); });
429            isRegisteredUserSwitchListener_ = true;
430        }
431        isProxyValid_ = true;
432    }
433    return true;
434}
435
436void WindowAdapter::ClearWindowAdapter()
437{
438    std::lock_guard<std::mutex> lock(mutex_);
439    if ((windowManagerServiceProxy_ != nullptr) && (windowManagerServiceProxy_->AsObject() != nullptr)) {
440        windowManagerServiceProxy_->AsObject()->RemoveDeathRecipient(wmsDeath_);
441    }
442    isProxyValid_ = false;
443    windowManagerServiceProxy_ = nullptr;
444}
445
446void WMSDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& wptrDeath)
447{
448    if (wptrDeath == nullptr) {
449        WLOGFE("wptrDeath is null");
450        return;
451    }
452
453    sptr<IRemoteObject> object = wptrDeath.promote();
454    if (!object) {
455        WLOGFE("object is null");
456        return;
457    }
458    WLOGI("wms OnRemoteDied");
459    SingletonContainer::Get<WindowAdapter>().ClearWindowAdapter();
460}
461
462WMError WindowAdapter::GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId)
463{
464    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
465
466    auto wmsProxy = GetWindowManagerServiceProxy();
467    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
468    return wmsProxy->GetTopWindowId(mainWinId, topWinId);
469}
470
471WMError WindowAdapter::GetParentMainWindowId(int32_t windowId, int32_t& mainWindowId)
472{
473    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
474
475    auto wmsProxy = GetWindowManagerServiceProxy();
476    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
477    return wmsProxy->GetParentMainWindowId(windowId, mainWindowId);
478}
479
480WMError WindowAdapter::SetWindowLayoutMode(WindowLayoutMode mode)
481{
482    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
483
484    auto wmsProxy = GetWindowManagerServiceProxy();
485    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
486    return wmsProxy->SetWindowLayoutMode(mode);
487}
488
489WMError WindowAdapter::UpdateProperty(sptr<WindowProperty>& windowProperty, PropertyChangeAction action)
490{
491    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
492
493    auto wmsProxy = GetWindowManagerServiceProxy();
494    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
495    return wmsProxy->UpdateProperty(windowProperty, action);
496}
497
498WMError WindowAdapter::SetWindowGravity(uint32_t windowId, WindowGravity gravity, uint32_t percent)
499{
500    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
501
502    auto wmsProxy = GetWindowManagerServiceProxy();
503    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
504    return wmsProxy->SetWindowGravity(windowId, gravity, percent);
505}
506
507WMError WindowAdapter::NotifyWindowTransition(sptr<WindowTransitionInfo> from, sptr<WindowTransitionInfo> to)
508{
509    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
510
511    auto wmsProxy = GetWindowManagerServiceProxy();
512    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
513    return wmsProxy->NotifyWindowTransition(from, to, true);
514}
515
516void WindowAdapter::MinimizeWindowsByLauncher(std::vector<uint32_t> windowIds, bool isAnimated,
517    sptr<RSIWindowAnimationFinishedCallback>& finishCallback)
518{
519    INIT_PROXY_CHECK_RETURN();
520
521    auto wmsProxy = GetWindowManagerServiceProxy();
522    CHECK_PROXY_RETURN_IF_NULL(wmsProxy);
523    wmsProxy->MinimizeWindowsByLauncher(windowIds, isAnimated, finishCallback);
524}
525
526WMError WindowAdapter::UpdateAvoidAreaListener(uint32_t windowId, bool haveListener)
527{
528    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
529
530    auto wmsProxy = GetWindowManagerServiceProxy();
531    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
532    return wmsProxy->UpdateAvoidAreaListener(windowId, haveListener);
533}
534
535WMError WindowAdapter::UpdateRsTree(uint32_t windowId, bool isAdd)
536{
537    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
538
539    auto wmsProxy = GetWindowManagerServiceProxy();
540    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
541    return wmsProxy->UpdateRsTree(windowId, isAdd);
542}
543
544WMError WindowAdapter::BindDialogTarget(uint32_t& windowId, sptr<IRemoteObject> targetToken)
545{
546    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
547
548    auto wmsProxy = GetWindowManagerServiceProxy();
549    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
550    return wmsProxy->BindDialogTarget(windowId, targetToken);
551}
552
553void WindowAdapter::SetAnchorAndScale(int32_t x, int32_t y, float scale)
554{
555    INIT_PROXY_CHECK_RETURN();
556
557    auto wmsProxy = GetWindowManagerServiceProxy();
558    CHECK_PROXY_RETURN_IF_NULL(wmsProxy);
559    wmsProxy->SetAnchorAndScale(x, y, scale);
560}
561
562void WindowAdapter::SetAnchorOffset(int32_t deltaX, int32_t deltaY)
563{
564    INIT_PROXY_CHECK_RETURN();
565
566    auto wmsProxy = GetWindowManagerServiceProxy();
567    CHECK_PROXY_RETURN_IF_NULL(wmsProxy);
568    wmsProxy->SetAnchorOffset(deltaX, deltaY);
569}
570
571void WindowAdapter::OffWindowZoom()
572{
573    INIT_PROXY_CHECK_RETURN();
574
575    auto wmsProxy = GetWindowManagerServiceProxy();
576    CHECK_PROXY_RETURN_IF_NULL(wmsProxy);
577    wmsProxy->OffWindowZoom();
578}
579
580/** @note @window.hierarchy */
581WMError WindowAdapter::RaiseToAppTop(uint32_t windowId)
582{
583    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
584
585    auto wmsProxy = GetWindowManagerServiceProxy();
586    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
587    return wmsProxy->RaiseToAppTop(windowId);
588}
589
590std::shared_ptr<Media::PixelMap> WindowAdapter::GetSnapshot(int32_t windowId)
591{
592    INIT_PROXY_CHECK_RETURN(nullptr);
593
594    auto wmsProxy = GetWindowManagerServiceProxy();
595    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, nullptr);
596    return wmsProxy->GetSnapshot(windowId);
597}
598
599WMError WindowAdapter::SetGestureNavigationEnabled(bool enable)
600{
601    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
602
603    auto wmsProxy = GetWindowManagerServiceProxy();
604    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
605    return wmsProxy->SetGestureNavigationEnabled(enable);
606}
607
608void WindowAdapter::DispatchKeyEvent(uint32_t windowId, std::shared_ptr<MMI::KeyEvent> event)
609{
610    INIT_PROXY_CHECK_RETURN();
611
612    auto wmsProxy = GetWindowManagerServiceProxy();
613    CHECK_PROXY_RETURN_IF_NULL(wmsProxy);
614    wmsProxy->DispatchKeyEvent(windowId, event);
615}
616
617void WindowAdapter::NotifyDumpInfoResult(const std::vector<std::string>& info)
618{
619    INIT_PROXY_CHECK_RETURN();
620
621    auto wmsProxy = GetWindowManagerServiceProxy();
622    CHECK_PROXY_RETURN_IF_NULL(wmsProxy);
623    wmsProxy->NotifyDumpInfoResult(info);
624}
625
626WMError WindowAdapter::DumpSessionAll(std::vector<std::string>& infos)
627{
628    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
629
630    auto wmsProxy = GetWindowManagerServiceProxy();
631    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
632    return static_cast<WMError>(wmsProxy->DumpSessionAll(infos));
633}
634
635WMError WindowAdapter::DumpSessionWithId(int32_t persistentId, std::vector<std::string>& infos)
636{
637    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
638
639    auto wmsProxy = GetWindowManagerServiceProxy();
640    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
641    return static_cast<WMError>(wmsProxy->DumpSessionWithId(persistentId, infos));
642}
643
644WMError WindowAdapter::GetUIContentRemoteObj(int32_t persistentId, sptr<IRemoteObject>& uiContentRemoteObj)
645{
646    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
647
648    auto wmsProxy = GetWindowManagerServiceProxy();
649    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
650    return static_cast<WMError>(wmsProxy->GetUIContentRemoteObj(persistentId, uiContentRemoteObj));
651}
652
653WMError WindowAdapter::GetWindowAnimationTargets(std::vector<uint32_t> missionIds,
654    std::vector<sptr<RSWindowAnimationTarget>>& targets)
655{
656    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
657
658    auto wmsProxy = GetWindowManagerServiceProxy();
659    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
660    return wmsProxy->GetWindowAnimationTargets(missionIds, targets);
661}
662
663void WindowAdapter::SetMaximizeMode(MaximizeMode maximizeMode)
664{
665    INIT_PROXY_CHECK_RETURN();
666
667    auto wmsProxy = GetWindowManagerServiceProxy();
668    CHECK_PROXY_RETURN_IF_NULL(wmsProxy);
669    wmsProxy->SetMaximizeMode(maximizeMode);
670}
671
672MaximizeMode WindowAdapter::GetMaximizeMode()
673{
674    INIT_PROXY_CHECK_RETURN(MaximizeMode::MODE_FULL_FILL);
675
676    auto wmsProxy = GetWindowManagerServiceProxy();
677    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, MaximizeMode::MODE_FULL_FILL);
678    return wmsProxy->GetMaximizeMode();
679}
680
681void WindowAdapter::GetFocusWindowInfo(FocusChangeInfo& focusInfo)
682{
683    INIT_PROXY_CHECK_RETURN();
684
685    auto wmsProxy = GetWindowManagerServiceProxy();
686    CHECK_PROXY_RETURN_IF_NULL(wmsProxy);
687    wmsProxy->GetFocusWindowInfo(focusInfo);
688}
689
690WMError WindowAdapter::UpdateSessionAvoidAreaListener(int32_t& persistentId, bool haveListener)
691{
692    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
693
694    auto wmsProxy = GetWindowManagerServiceProxy();
695    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
696    return static_cast<WMError>(wmsProxy->UpdateSessionAvoidAreaListener(persistentId, haveListener));
697}
698
699WMError WindowAdapter::UpdateSessionTouchOutsideListener(int32_t& persistentId, bool haveListener)
700{
701    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
702
703    auto wmsProxy = GetWindowManagerServiceProxy();
704    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
705    return static_cast<WMError>(
706        wmsProxy->UpdateSessionTouchOutsideListener(persistentId, haveListener));
707}
708
709WMError WindowAdapter::NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible)
710{
711    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
712
713    auto wmsProxy = GetWindowManagerServiceProxy();
714    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
715    return static_cast<WMError>(wmsProxy->NotifyWindowExtensionVisibilityChange(pid, uid, visible));
716}
717
718WMError WindowAdapter::RaiseWindowToTop(int32_t persistentId)
719{
720    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
721
722    auto wmsProxy = GetWindowManagerServiceProxy();
723    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
724    return static_cast<WMError>(wmsProxy->RaiseWindowToTop(persistentId));
725}
726
727WMError WindowAdapter::UpdateSessionWindowVisibilityListener(int32_t persistentId, bool haveListener)
728{
729    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
730
731    auto wmsProxy = GetWindowManagerServiceProxy();
732    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
733    WSError ret = wmsProxy->UpdateSessionWindowVisibilityListener(persistentId, haveListener);
734    return static_cast<WMError>(ret);
735}
736
737WMError WindowAdapter::ShiftAppWindowFocus(int32_t sourcePersistentId, int32_t targetPersistentId)
738{
739    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
740
741    auto wmsProxy = GetWindowManagerServiceProxy();
742    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
743    return static_cast<WMError>(
744        wmsProxy->ShiftAppWindowFocus(sourcePersistentId, targetPersistentId));
745}
746
747void WindowAdapter::CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage,
748    const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
749    sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session,
750    SystemSessionConfig& systemConfig, sptr<IRemoteObject> token)
751{
752    INIT_PROXY_CHECK_RETURN();
753
754    auto wmsProxy = GetWindowManagerServiceProxy();
755    CHECK_PROXY_RETURN_IF_NULL(wmsProxy);
756    wmsProxy->CreateAndConnectSpecificSession(sessionStage, eventChannel,
757        surfaceNode, property, persistentId, session, systemConfig, token);
758}
759
760void WindowAdapter::RecoverAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage,
761    const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
762    sptr<WindowSessionProperty> property, sptr<ISession>& session, sptr<IRemoteObject> token)
763{
764    INIT_PROXY_CHECK_RETURN();
765    TLOGI(WmsLogTag::WMS_RECOVER, "called");
766
767    auto wmsProxy = GetWindowManagerServiceProxy();
768    CHECK_PROXY_RETURN_IF_NULL(wmsProxy);
769    wmsProxy->RecoverAndConnectSpecificSession(
770        sessionStage, eventChannel, surfaceNode, property, session, token);
771}
772
773WMError WindowAdapter::DestroyAndDisconnectSpecificSession(const int32_t persistentId)
774{
775    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
776
777    auto wmsProxy = GetWindowManagerServiceProxy();
778    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
779    return static_cast<WMError>(wmsProxy->DestroyAndDisconnectSpecificSession(persistentId));
780}
781
782WMError WindowAdapter::DestroyAndDisconnectSpecificSessionWithDetachCallback(const int32_t persistentId,
783    const sptr<IRemoteObject>& callback)
784{
785    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
786
787    auto wmsProxy = GetWindowManagerServiceProxy();
788    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
789    return static_cast<WMError>(
790        wmsProxy->DestroyAndDisconnectSpecificSessionWithDetachCallback(persistentId, callback));
791}
792
793WMError WindowAdapter::RecoverAndReconnectSceneSession(const sptr<ISessionStage>& sessionStage,
794    const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
795    sptr<ISession>& session, sptr<WindowSessionProperty> property, sptr<IRemoteObject> token)
796{
797    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
798    TLOGI(WmsLogTag::WMS_RECOVER, "called");
799
800    auto wmsProxy = GetWindowManagerServiceProxy();
801    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
802    auto ret = wmsProxy->RecoverAndReconnectSceneSession(
803        sessionStage, eventChannel, surfaceNode, session, property, token);
804    if (ret != WSError::WS_OK) {
805        TLOGE(WmsLogTag::WMS_RECOVER, "failed, ret = %{public}d", ret);
806        return WMError::WM_DO_NOTHING;
807    }
808    return WMError::WM_OK;
809}
810
811WMError WindowAdapter::SetSessionGravity(int32_t persistentId, SessionGravity gravity, uint32_t percent)
812{
813    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
814
815    auto wmsProxy = GetWindowManagerServiceProxy();
816    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
817    return static_cast<WMError>(wmsProxy->SetSessionGravity(persistentId, gravity, percent));
818}
819
820WMError WindowAdapter::BindDialogSessionTarget(uint64_t persistentId, sptr<IRemoteObject> targetToken)
821{
822    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
823
824    auto wmsProxy = GetWindowManagerServiceProxy();
825    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
826    return static_cast<WMError>(wmsProxy->BindDialogSessionTarget(persistentId, targetToken));
827}
828
829WMError WindowAdapter::RequestFocusStatus(int32_t persistentId, bool isFocused)
830{
831    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
832
833    auto wmsProxy = GetWindowManagerServiceProxy();
834    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
835    return static_cast<WMError>(wmsProxy->RequestFocusStatus(persistentId, isFocused));
836}
837
838void WindowAdapter::AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage,
839    const sptr<IRemoteObject>& token, uint64_t surfaceNodeId)
840{
841    INIT_PROXY_CHECK_RETURN();
842
843    auto wmsProxy = GetWindowManagerServiceProxy();
844    CHECK_PROXY_RETURN_IF_NULL(wmsProxy);
845    wmsProxy->AddExtensionWindowStageToSCB(sessionStage, token, surfaceNodeId);
846}
847
848void WindowAdapter::RemoveExtensionWindowStageFromSCB(const sptr<ISessionStage>& sessionStage,
849    const sptr<IRemoteObject>& token)
850{
851    INIT_PROXY_CHECK_RETURN();
852
853    auto wmsProxy = GetWindowManagerServiceProxy();
854    CHECK_PROXY_RETURN_IF_NULL(wmsProxy);
855    wmsProxy->RemoveExtensionWindowStageFromSCB(sessionStage, token);
856}
857
858void WindowAdapter::ProcessModalExtensionPointDown(const sptr<IRemoteObject>& token, int32_t posX, int32_t posY)
859{
860    INIT_PROXY_CHECK_RETURN();
861
862    auto wmsProxy = GetWindowManagerServiceProxy();
863    CHECK_PROXY_RETURN_IF_NULL(wmsProxy);
864    wmsProxy->ProcessModalExtensionPointDown(token, posX, posY);
865}
866
867void WindowAdapter::UpdateModalExtensionRect(const sptr<IRemoteObject>& token, Rect rect)
868{
869    INIT_PROXY_CHECK_RETURN();
870
871    auto wmsProxy = GetWindowManagerServiceProxy();
872    CHECK_PROXY_RETURN_IF_NULL(wmsProxy);
873    wmsProxy->UpdateModalExtensionRect(token, rect);
874}
875
876WMError WindowAdapter::AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide)
877{
878    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
879
880    auto wmsProxy = GetWindowManagerServiceProxy();
881    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
882    return static_cast<WMError>(wmsProxy->AddOrRemoveSecureSession(persistentId, shouldHide));
883}
884
885WMError WindowAdapter::UpdateExtWindowFlags(const sptr<IRemoteObject>& token, uint32_t extWindowFlags,
886    uint32_t extWindowActions)
887{
888    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
889
890    auto wmsProxy = GetWindowManagerServiceProxy();
891    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
892    return static_cast<WMError>(wmsProxy->UpdateExtWindowFlags(token, extWindowFlags, extWindowActions));
893}
894
895WMError WindowAdapter::GetHostWindowRect(int32_t hostWindowId, Rect& rect)
896{
897    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
898
899    auto wmsProxy = GetWindowManagerServiceProxy();
900    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
901    return static_cast<WMError>(wmsProxy->GetHostWindowRect(hostWindowId, rect));
902}
903
904WMError WindowAdapter::GetFreeMultiWindowEnableState(bool& enable)
905{
906    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
907
908    auto wmsProxy = GetWindowManagerServiceProxy();
909    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
910    return static_cast<WMError>(wmsProxy->GetFreeMultiWindowEnableState(enable));
911}
912
913WMError WindowAdapter::GetCallingWindowWindowStatus(int32_t persistentId, WindowStatus& windowStatus)
914{
915    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
916
917    auto wmsProxy = GetWindowManagerServiceProxy();
918    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
919    return static_cast<WMError>(wmsProxy->GetCallingWindowWindowStatus(persistentId, windowStatus));
920}
921
922WMError WindowAdapter::GetCallingWindowRect(int32_t persistentId, Rect& rect)
923{
924    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
925
926    auto wmsProxy = GetWindowManagerServiceProxy();
927    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
928    return static_cast<WMError>(wmsProxy->GetCallingWindowRect(persistentId, rect));
929}
930
931WMError WindowAdapter::GetWindowModeType(WindowModeType& windowModeType)
932{
933    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
934
935    WLOGFD("get window mode type");
936    auto wmsProxy = GetWindowManagerServiceProxy();
937    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
938    return wmsProxy->GetWindowModeType(windowModeType);
939}
940
941WMError WindowAdapter::GetWindowStyleType(WindowStyleType& windowStyleType)
942{
943    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
944    auto wmsProxy = GetWindowManagerServiceProxy();
945    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
946    return wmsProxy->GetWindowStyleType(windowStyleType);
947}
948
949WMError WindowAdapter::GetWindowIdsByCoordinate(DisplayId displayId, int32_t windowNumber,
950    int32_t x, int32_t y, std::vector<int32_t>& windowIds)
951{
952    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
953    auto wmsProxy = GetWindowManagerServiceProxy();
954    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
955    return wmsProxy->GetWindowIdsByCoordinate(displayId, windowNumber, x, y, windowIds);
956}
957
958sptr<IWindowManager> WindowAdapter::GetWindowManagerServiceProxy() const
959{
960    std::lock_guard<std::mutex> lock(mutex_);
961    return windowManagerServiceProxy_;
962}
963
964WMError WindowAdapter::SkipSnapshotForAppProcess(int32_t pid, bool skip)
965{
966    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
967    auto wmsProxy = GetWindowManagerServiceProxy();
968    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
969    return wmsProxy->SkipSnapshotForAppProcess(pid, skip);
970}
971
972WMError WindowAdapter::SetProcessWatermark(int32_t pid, const std::string& watermarkName, bool isEnabled)
973{
974    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
975    auto wmsProxy = GetWindowManagerServiceProxy();
976    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
977    return wmsProxy->SetProcessWatermark(pid, watermarkName, isEnabled);
978}
979
980WMError WindowAdapter::ReleaseForegroundSessionScreenLock()
981{
982    INIT_PROXY_CHECK_RETURN(WMError::WM_DO_NOTHING);
983    auto wmsProxy = GetWindowManagerServiceProxy();
984    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_DO_NOTHING);
985    return wmsProxy->ReleaseForegroundSessionScreenLock();
986}
987
988WMError WindowAdapter::GetDisplayIdByPersistentId(int32_t persistentId, int32_t& displayId)
989{
990    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
991    auto wmsProxy = GetWindowManagerServiceProxy();
992    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
993    return wmsProxy->GetDisplayIdByPersistentId(persistentId, displayId);
994}
995
996WMError WindowAdapter::IsPcOrPadFreeMultiWindowMode(bool& isPcOrPadFreeMultiWindowMode)
997{
998    INIT_PROXY_CHECK_RETURN(WMError::WM_ERROR_SAMGR);
999    auto wmsProxy = GetWindowManagerServiceProxy();
1000    CHECK_PROXY_RETURN_ERROR_IF_NULL(wmsProxy, WMError::WM_ERROR_SAMGR);
1001    return wmsProxy->IsPcOrPadFreeMultiWindowMode(isPcOrPadFreeMultiWindowMode);
1002}
1003} // namespace Rosen
1004} // namespace OHOS
1005