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 OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_PROXY_H
17 #define OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_PROXY_H
18 
19 #include <iremote_proxy.h>
20 
21 #include "session_manager/include/zidl/scene_session_manager_interface.h"
22 
23 namespace OHOS::Rosen {
24 class SceneSessionManagerProxy : public IRemoteProxy<ISceneSessionManager> {
25 public:
SceneSessionManagerProxy(const sptr<IRemoteObject> & impl)26     explicit SceneSessionManagerProxy(const sptr<IRemoteObject>& impl)
27         : IRemoteProxy<ISceneSessionManager>(impl) {}
28     virtual ~SceneSessionManagerProxy() = default;
29 
30     WSError CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage,
31         const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
32         sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session,
33         SystemSessionConfig& systemConfig, sptr<IRemoteObject> token = nullptr) override;
34     WSError RecoverAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage,
35         const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
36         sptr<WindowSessionProperty> property, sptr<ISession>& session, sptr<IRemoteObject> token = nullptr) override;
37     WSError RecoverAndReconnectSceneSession(const sptr<ISessionStage>& sessionStage,
38         const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
39         sptr<ISession>& session, sptr<WindowSessionProperty> property = nullptr,
40         sptr<IRemoteObject> token = nullptr) override;
41     WSError DestroyAndDisconnectSpecificSession(const int32_t persistentId) override;
42     WSError DestroyAndDisconnectSpecificSessionWithDetachCallback(const int32_t persistentId,
43         const sptr<IRemoteObject>& callback) override;
44     WSError BindDialogSessionTarget(uint64_t persistentId, sptr<IRemoteObject> targetToken) override;
45     WMError RequestFocusStatus(int32_t persistentId, bool isFocused, bool byForeground = true,
46         FocusChangeReason reason = FocusChangeReason::DEFAULT) override;
47     WSError RaiseWindowToTop(int32_t persistentId) override;
48 
49     WMError RegisterWindowManagerAgent(WindowManagerAgentType type,
50         const sptr<IWindowManagerAgent>& windowManagerAgent) override;
51     WMError UnregisterWindowManagerAgent(WindowManagerAgentType type,
52         const sptr<IWindowManagerAgent>& windowManagerAgent) override;
53     WMError SetGestureNavigaionEnabled(bool enable) override;
54     void GetFocusWindowInfo(FocusChangeInfo& focusInfo) override;
55     WSError SetSessionLabel(const sptr<IRemoteObject> &token, const std::string& label) override;
56     WSError SetSessionIcon(const sptr<IRemoteObject> &token, const std::shared_ptr<Media::PixelMap> &icon) override;
57     WSError IsValidSessionIds(const std::vector<int32_t> &sessionIds, std::vector<bool> &results) override;
58     WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos) override;
59     WMError GetUnreliableWindowInfo(int32_t windowId, std::vector<sptr<UnreliableWindowInfo>>& infos) override;
60     WSError PendingSessionToForeground(const sptr<IRemoteObject> &token) override;
61     WSError PendingSessionToBackgroundForDelegator(const sptr<IRemoteObject>& token,
62         bool shouldBackToCaller = true) override;
63     WMError GetSessionSnapshotById(int32_t persistentId, SessionSnapshot& snapshot) override;
64     WMError GetSnapshotByWindowId(int32_t persistentId, std::shared_ptr<Media::PixelMap>& pixelMap) override;
65     WSError GetFocusSessionToken(sptr<IRemoteObject> &token) override;
66     WSError GetFocusSessionElement(AppExecFwk::ElementName& element) override;
67     WMError CheckWindowId(int32_t windowId, int32_t& pid) override;
68 
69     WSError RegisterSessionListener(const sptr<ISessionListener>& listener) override;
70     WSError UnRegisterSessionListener(const sptr<ISessionListener>& listener) override;
71     WSError GetSessionInfos(const std::string& deviceId, int32_t numMax,
72                             std::vector<SessionInfoBean>& sessionInfos) override;
73     WSError GetSessionInfo(const std::string& deviceId, int32_t persistentId, SessionInfoBean& sessionInfo) override;
74     WSError GetSessionInfoByContinueSessionId(const std::string& continueSessionId,
75         SessionInfoBean& sessionInfo) override;
76 
77     WSError DumpSessionAll(std::vector<std::string> &infos) override;
78     WSError DumpSessionWithId(int32_t persistentId, std::vector<std::string> &infos) override;
79     WSError SetSessionContinueState(const sptr<IRemoteObject> &token, const ContinueState& continueState) override;
80     WSError TerminateSessionNew(
81         const sptr<AAFwk::SessionInfo> info, bool needStartCaller, bool isFromBroker = false) override;
82     WSError GetSessionDumpInfo(const std::vector<std::string>& params, std::string& info) override;
83     void NotifyDumpInfoResult(const std::vector<std::string>& info) override;
84     WSError UpdateSessionAvoidAreaListener(int32_t& persistentId, bool haveListener) override;
85     WSError UpdateSessionTouchOutsideListener(int32_t& persistentId, bool haveListener) override;
86     WSError UpdateSessionWindowVisibilityListener(int32_t persistentId, bool haveListener) override;
87     WSError GetSessionSnapshot(const std::string& deviceId, int32_t persistentId,
88                                SessionSnapshot& snapshot, bool isLowResolution) override;
89     WSError GetUIContentRemoteObj(int32_t persistentId, sptr<IRemoteObject>& uiContentRemoteObj) override;
90     WSError LockSession(int32_t persistentId) override;
91     WSError UnlockSession(int32_t persistentId) override;
92     WSError MoveSessionsToForeground(const std::vector<int32_t>& sessionIds, int32_t topSessionId) override;
93     WSError MoveSessionsToBackground(const std::vector<int32_t>& sessionIds, std::vector<int32_t>& result) override;
94     WSError ClearSession(int32_t persistentId) override;
95     WSError ClearAllSessions() override;
96     WSError RegisterIAbilityManagerCollaborator(int32_t type,
97         const sptr<AAFwk::IAbilityManagerCollaborator> &impl) override;
98     WSError UnregisterIAbilityManagerCollaborator(int32_t type) override;
99     WSError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible) override;
100     WMError GetTopWindowId(uint32_t mainWinId, uint32_t& topWinId) override;
101     WMError GetParentMainWindowId(int32_t windowId, int32_t& mainWindowId) override;
102     WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) override;
103     WSError ShiftAppWindowFocus(int32_t sourcePersistentId, int32_t targetPersistentId) override;
104     void AddExtensionWindowStageToSCB(const sptr<ISessionStage>& sessionStage,
105         const sptr<IRemoteObject>& token, uint64_t surfaceNodeId) override;
106     void RemoveExtensionWindowStageFromSCB(const sptr<ISessionStage>& sessionStage,
107         const sptr<IRemoteObject>& token) override;
108     void UpdateModalExtensionRect(const sptr<IRemoteObject>& token, Rect rect) override;
109     void ProcessModalExtensionPointDown(const sptr<IRemoteObject>& token, int32_t posX, int32_t posY) override;
110     WSError AddOrRemoveSecureSession(int32_t persistentId, bool shouldHide) override;
111     WSError UpdateExtWindowFlags(const sptr<IRemoteObject>& token, uint32_t extWindowFlags,
112         uint32_t extWindowActions) override;
113     WSError GetHostWindowRect(int32_t hostWindowId, Rect& rect) override;
114     WSError GetFreeMultiWindowEnableState(bool& enable) override;
115     WMError GetCallingWindowWindowStatus(int32_t persistentId, WindowStatus& windowStatus) override;
116     WMError GetCallingWindowRect(int32_t persistentId, Rect& rect) override;
117     WMError MinimizeAllAppWindows(DisplayId displayId) override;
118     WMError ToggleShownStateForAllAppWindows() override;
119     WMError GetWindowModeType(WindowModeType& windowModeType) override;
120     WMError GetWindowStyleType(WindowStyleType& windowStyleType) override;
121     WMError GetProcessSurfaceNodeIdByPersistentId(const int32_t pid,
122         const std::vector<int32_t>& persistentIds, std::vector<uint64_t>& surfaceNodeIds) override;
123     WMError GetWindowIdsByCoordinate(DisplayId displayId, int32_t windowNumber,
124         int32_t x, int32_t y, std::vector<int32_t>& windowIds) override;
125     WMError ReleaseForegroundSessionScreenLock() override;
126     WMError IsPcWindow(bool& isPcWindow) override;
127     WMError IsWindowRectAutoSave(const std::string& key, bool& enabled) override;
128     WMError GetDisplayIdByWindowId(const std::vector<uint64_t>& windowIds,
129         std::unordered_map<uint64_t, DisplayId>& windowDisplayIdMap) override;
130     WMError IsPcOrPadFreeMultiWindowMode(bool& isPcOrPadFreeMultiWindowMode) override;
131     WMError SetGlobalDragResizeType(DragResizeType dragResizeType) override;
132     WMError GetGlobalDragResizeType(DragResizeType& dragResizeType) override;
133     WMError SetAppDragResizeType(const std::string& bundleName, DragResizeType dragResizeType) override;
134     WMError GetAppDragResizeType(const std::string& bundleName, DragResizeType& dragResizeType) override;
135 
136 private:
137     template<typename T>
138     WSError GetParcelableInfos(MessageParcel& reply, std::vector<T>& parcelableInfos);
139     static inline BrokerDelegator<SceneSessionManagerProxy> delegator_;
140 };
141 } // namespace OHOS::Rosen
142 
143 #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_PROXY_H
144