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_SESSION_MANAGER_AGENT_CONTROLLER_H 17 #define OHOS_ROSEN_SESSION_MANAGER_AGENT_CONTROLLER_H 18 #include <mutex> 19 20 #include "client_agent_container.h" 21 #include "window_manager.h" 22 #include "wm_single_instance.h" 23 #include "zidl/window_manager_agent_interface.h" 24 #include "window_visibility_info.h" 25 #include "window_drawing_content_info.h" 26 27 namespace OHOS { 28 namespace Rosen { 29 class SessionManagerAgentController { 30 WM_DECLARE_SINGLE_INSTANCE_BASE(SessionManagerAgentController) 31 public: 32 WMError RegisterWindowManagerAgent(const sptr<IWindowManagerAgent>& windowManagerAgent, 33 WindowManagerAgentType type, int32_t pid); 34 WMError UnregisterWindowManagerAgent(const sptr<IWindowManagerAgent>& windowManagerAgent, 35 WindowManagerAgentType type, int32_t pid); 36 37 void UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing); 38 void UpdateFocusChangeInfo(const sptr<FocusChangeInfo>& focusChangeInfo, bool focused); 39 void UpdateWindowModeTypeInfo(WindowModeType type); 40 void NotifyAccessibilityWindowInfo(const std::vector<sptr<AccessibilityWindowInfo>>& infos, 41 WindowUpdateType type); 42 void NotifyWaterMarkFlagChangedResult(bool hasWaterMark); 43 void UpdateWindowVisibilityInfo(const std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfos); 44 void UpdateVisibleWindowNum(const std::vector<VisibleWindowNumInfo>& visibleWindowNumInfo); 45 void UpdateWindowDrawingContentInfo(const std::vector<sptr<WindowDrawingContentInfo>>& windowDrawingContentInfos); 46 void UpdateCameraWindowStatus(uint32_t accessTokenId, bool isShowing); 47 void NotifyGestureNavigationEnabledResult(bool enable); 48 void NotifyWindowStyleChange(WindowStyleType type); 49 void UpdatePiPWindowStateChanged(const std::string& bundleName, bool isForeground); 50 51 private: SessionManagerAgentController()52 SessionManagerAgentController() 53 { 54 smAgentContainer_.SetAgentDeathCallback(([this](const sptr<IRemoteObject>& remoteObject) { 55 DoAfterAgentDeath(remoteObject); 56 })); 57 } 58 virtual ~SessionManagerAgentController() = default; 59 void DoAfterAgentDeath(const sptr<IRemoteObject>& remoteObject); 60 61 ClientAgentContainer<IWindowManagerAgent, WindowManagerAgentType> smAgentContainer_; 62 std::map<int32_t, std::map<WindowManagerAgentType, sptr<IWindowManagerAgent>>> windowManagerPidAgentMap_; 63 std::map<sptr<IRemoteObject>, std::pair<int32_t, WindowManagerAgentType>> windowManagerAgentPairMap_; 64 std::mutex windowManagerAgentPidMapMutex_; 65 }; 66 } 67 } 68 #endif // OHOS_ROSEN_WINDOW_MANAGER_AGENT_CONTROLLER_H 69