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_SCENE_SESSION_MANAGER_LITE_H
17 #define OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_MANAGER_LITE_H
18 
19 #include <mutex>
20 #include <shared_mutex>
21 #include "session_manager/include/zidl/scene_session_manager_lite_stub.h"
22 #include "wm_single_instance.h"
23 
24 
25 namespace OHOS::Rosen {
26 
27 class SceneSessionManagerLite : public SceneSessionManagerLiteStub {
28 WM_DECLARE_SINGLE_INSTANCE_BASE(SceneSessionManagerLite)
29 public:
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     WSError GetMainWindowStatesByPid(int32_t pid, std::vector<MainWindowState>& windowStates) override;
43     WSError GetSessionInfo(const std::string& deviceId, int32_t persistentId, SessionInfoBean& sessionInfo) override;
44     WSError GetSessionInfoByContinueSessionId(const std::string& continueSessionId,
45         SessionInfoBean& sessionInfo) override;
46     WSError TerminateSessionNew(
47         const sptr<AAFwk::SessionInfo> info, bool needStartCaller, bool isFromBroker = false) override;
48     WSError GetSessionSnapshot(const std::string& deviceId, int32_t persistentId,
49                                SessionSnapshot& snapshot, bool isLowResolution) override;
50     WSError SetSessionContinueState(const sptr<IRemoteObject>& token, const ContinueState& continueState) override;
51     WSError ClearSession(int32_t persistentId) override;
52     WSError ClearAllSessions() override;
53     WSError LockSession(int32_t sessionId) override;
54     WSError UnlockSession(int32_t sessionId) override;
55     WSError MoveSessionsToForeground(const std::vector<int32_t>& sessionIds, int32_t topSessionId) override;
56     WSError MoveSessionsToBackground(const std::vector<int32_t>& sessionIds, std::vector<int32_t>& result) override;
57 
58     void GetFocusWindowInfo(FocusChangeInfo& focusInfo) override;
59     WMError RegisterWindowManagerAgent(WindowManagerAgentType type,
60         const sptr<IWindowManagerAgent>& windowManagerAgent) override;
61     WMError UnregisterWindowManagerAgent(WindowManagerAgentType type,
62         const sptr<IWindowManagerAgent>& windowManagerAgent) override;
63     WMError CheckWindowId(int32_t windowId, int32_t& pid) override;
64     WMError CheckUIExtensionCreation(int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName& element,
65         AppExecFwk::ExtensionAbilityType extensionAbilityType, int32_t& pid) override;
66     WMError GetVisibilityWindowInfo(std::vector<sptr<WindowVisibilityInfo>>& infos) override;
67     WSError UpdateWindowMode(int32_t persistentId, int32_t windowMode);
68     WMError GetWindowModeType(WindowModeType& windowModeType) override;
69     WSError RaiseWindowToTop(int32_t persistentId) override;
70     WMError GetMainWindowInfos(int32_t topNum, std::vector<MainWindowInfo>& topNInfo) override;
71     WSError RegisterIAbilityManagerCollaborator(int32_t type,
72         const sptr<AAFwk::IAbilityManagerCollaborator>& impl) override;
73     WSError UnregisterIAbilityManagerCollaborator(int32_t type) override;
74     WMError GetAllMainWindowInfos(std::vector<MainWindowInfo>& infos) override;
75     WMError ClearMainSessions(const std::vector<int32_t>& persistentIds, std::vector<int32_t>& clearFailedIds) override;
76     WMError GetWindowStyleType(WindowStyleType& windowStyletype) override;
77     WMError TerminateSessionByPersistentId(int32_t persistentId) override;
78     WMError GetAccessibilityWindowInfo(std::vector<sptr<AccessibilityWindowInfo>>& infos) override;
79     WMError CloseTargetFloatWindow(const std::string& bundleName) override;
80     WMError CloseTargetPiPWindow(const std::string& bundleName) override;
81     WMError GetCurrentPiPWindowInfo(std::string& bundleName) override;
82     WSError NotifyAppUseControlList(ControlAppType type, int32_t userId,
83         const std::vector<AppUseControlInfo>& controlList) override;
84     WMError GetRootMainWindowId(int32_t persistentId, int32_t& hostWindowId) override;
85 
86 protected:
87     SceneSessionManagerLite() = default;
88     virtual ~SceneSessionManagerLite() = default;
89 };
90 } // namespace OHOS::Rosen
91 
92 #endif // OHOS_ROSEN_WINDOW_SCENE_SCENE_SESSION_MANAGER_LITE_H
93