• 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 OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_H
17 #define OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_H
18 
19 #include <shared_mutex>
20 #include "screenlock_manager_interface.h"
21 
22 #include "session_manager_service_interface.h"
23 #include "mock_session_manager_service_interface.h"
24 #include "zidl/scene_session_manager_interface.h"
25 #include "zidl/screen_session_manager_interface.h"
26 #include "wm_single_instance.h"
27 
28 namespace OHOS::Rosen {
29 class SessionManager {
30 WM_DECLARE_SINGLE_INSTANCE_BASE(SessionManager);
31 public:
32     void CreateAndConnectSpecificSession(const sptr<ISessionStage>& sessionStage,
33         const sptr<IWindowEventChannel>& eventChannel, const std::shared_ptr<RSSurfaceNode>& surfaceNode,
34         sptr<WindowSessionProperty> property, int32_t& persistentId, sptr<ISession>& session,
35         sptr<IRemoteObject> token = nullptr);
36     void DestroyAndDisconnectSpecificSession(const int32_t& persistentId);
37     WMError UpdateProperty(sptr<WindowSessionProperty>& property, WSPropertyChangeAction action);
38     WMError SetSessionGravity(int32_t persistentId, SessionGravity gravity, uint32_t percent);
39     WMError BindDialogTarget(uint64_t persistentId, sptr<IRemoteObject> targetToken);
40     void ClearSessionManagerProxy();
41 
42     sptr<ISceneSessionManager> GetSceneSessionManagerProxy();
43     sptr<IScreenSessionManager> GetScreenSessionManagerProxy();
44     sptr<ScreenLock::ScreenLockManagerInterface> GetScreenLockManagerProxy();
45 
46 protected:
47     SessionManager() = default;
48     virtual ~SessionManager() = default;
49 
50 private:
51     void InitSessionManagerServiceProxy();
52     void InitSceneSessionManagerProxy();
53     void InitScreenSessionManagerProxy();
54     void InitScreenLockManagerProxy();
55 
56     sptr<IMockSessionManagerInterface> mockSessionManagerServiceProxy_ = nullptr;
57     sptr<ISessionManagerService> sessionManagerServiceProxy_ = nullptr;
58     sptr<ISceneSessionManager> sceneSessionManagerProxy_ = nullptr;
59     sptr<IScreenSessionManager> screenSessionManagerProxy_ = nullptr;
60     sptr<ScreenLock::ScreenLockManagerInterface> screenLockManagerProxy_ = nullptr;
61     std::shared_mutex proxyMutex_;
62 };
63 } // namespace OHOS::Rosen
64 
65 #endif // OHOS_ROSEN_WINDOW_SCENE_SESSION_MANAGER_H
66