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_LITE_PROXY_H
17 #define OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_LITE_PROXY_H
18 
19 #include <iremote_proxy.h>
20 
21 #include "session_manager/include/zidl/scene_session_manager_lite_interface.h"
22 
23 namespace OHOS::Rosen {
24 class SceneSessionManagerLiteProxy : public IRemoteProxy<ISceneSessionManagerLite> {
25 public:
SceneSessionManagerLiteProxy(const sptr<IRemoteObject> & impl)26     explicit SceneSessionManagerLiteProxy(const sptr<IRemoteObject>& impl)
27         : IRemoteProxy<ISceneSessionManagerLite>(impl) {}
28     virtual ~SceneSessionManagerLiteProxy() = default;
29 
30     WSError SetSessionLabel(const sptr<IRemoteObject>& token, const std::string& label) override;
31     WSError SetSessionIcon(const sptr<IRemoteObject>& token, const std::shared_ptr<Media::PixelMap>& icon) override;
32     WSError IsValidSessionIds(const std::vector<int32_t>& sessionIds, std::vector<bool>& results) override;
33     WSError PendingSessionToForeground(const sptr<IRemoteObject>& token) override;
34     WSError PendingSessionToBackgroundForDelegator(const sptr<IRemoteObject>& token,
35         bool shouldBackToCaller = true) override;
36     WSError GetFocusSessionToken(sptr<IRemoteObject>& token) override;
37     WSError GetFocusSessionElement(AppExecFwk::ElementName& element) override;
38     WSError RegisterSessionListener(const sptr<ISessionListener>& listener) override;
39     WSError UnRegisterSessionListener(const sptr<ISessionListener>& listener) override;
40     WSError GetSessionInfos(const std::string& deviceId, int32_t numMax,
41                             std::vector<SessionInfoBean>& sessionInfos) override;
42     /**
43      * @brief Obtains main window state list by pid
44      * @caller SA
45      * @permission SA permission
46      *
47      * @param pid Target pid
48      * @param windowStates Window state list
49      */
50     WSError GetMainWindowStatesByPid(int32_t pid, std::vector<MainWindowState>& windowStates) override;
51     WSError GetSessionInfo(const std::string& deviceId, int32_t persistentId, SessionInfoBean& sessionInfo) override;
52     WSError GetSessionInfoByContinueSessionId(const std::string& continueSessionId,
53         SessionInfoBean& sessionInfo) override;
54     WSError SetSessionContinueState(const sptr<IRemoteObject>& token, const ContinueState& continueState) override;
55     WSError TerminateSessionNew(
56         const sptr<AAFwk::SessionInfo> info, bool needStartCaller, bool isFromBroker = false) override;
57     WSError GetSessionSnapshot(const std::string& deviceId, int32_t persistentId,
58                                SessionSnapshot& snapshot, bool isLowResolution) override;
59     WSError LockSession(int32_t persistentId) override;
60     WSError UnlockSession(int32_t persistentId) override;
61     WSError MoveSessionsToForeground(const std::vector<int32_t>& sessionIds, int32_t topSessionId) override;
62     WSError MoveSessionsToBackground(const std::vector<int32_t>& sessionIds, std::vector<int32_t>& result) override;
63     WSError ClearSession(int32_t persistentId) override;
64     WSError ClearAllSessions() override;
65 
66     void GetFocusWindowInfo(FocusChangeInfo& focusInfo) override;
67     WMError RegisterWindowManagerAgent(WindowManagerAgentType type,
68         const sptr<IWindowManagerAgent>& windowManagerAgent) override;
69     WMError UnregisterWindowManagerAgent(WindowManagerAgentType type,
70         const sptr<IWindowManagerAgent>& windowManagerAgent) override;
71     WMError CheckWindowId(int32_t windowId, int32_t& pid) override;
72     WMError CheckUIExtensionCreation(int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName& element,
73         AppExecFwk::ExtensionAbilityType extensionAbilityType, int32_t& pid) override;
74     WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) override;
75     WMError GetWindowModeType(WindowModeType& windowModeType) override;
76     WSError RaiseWindowToTop(int32_t persistentId) override;
77     WMError GetMainWindowInfos(int32_t topNum, std::vector<MainWindowInfo>& topNInfo) override;
78     WSError RegisterIAbilityManagerCollaborator(int32_t type,
79         const sptr<AAFwk::IAbilityManagerCollaborator>& impl) override;
80     WSError UnregisterIAbilityManagerCollaborator(int32_t type) override;
81     WMError GetAllMainWindowInfos(std::vector<MainWindowInfo>& infos) override;
82     WMError ClearMainSessions(const std::vector<int32_t>& persistentIds, std::vector<int32_t>& clearFailedIds) override;
83     WMError GetWindowStyleType(WindowStyleType& windowModeType) override;
84     WMError TerminateSessionByPersistentId(int32_t persistentId) override;
85     WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos) override;
86     WMError CloseTargetFloatWindow(const std::string& bundleName) override;
87     WMError CloseTargetPiPWindow(const std::string& bundleName) override;
88     WMError GetCurrentPiPWindowInfo(std::string& bundleName) override;
89     WSError NotifyAppUseControlList(ControlAppType type, int32_t userId,
90         const std::vector<AppUseControlInfo>& controlList) override;
91     WMError GetRootMainWindowId(int32_t persistentId, int32_t& hostWindowId) override;
92 
93 private:
94     template<typename T>
95     WSError GetParcelableInfos(MessageParcel& reply, std::vector<T>& parcelableInfos);
96 };
97 } // namespace OHOS::Rosen
98 
99 #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_LITE_PROXY_H
100