• 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 #include "session_manager_agent_controller.h"
17 #include "window_manager_hilog.h"
18 #include "wm_common.h"
19 
20 namespace OHOS {
21 namespace Rosen {
22 namespace {
23     constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "SessionManagerAgentController"};
24 }
WM_IMPLEMENT_SINGLE_INSTANCE(SessionManagerAgentController)25 WM_IMPLEMENT_SINGLE_INSTANCE(SessionManagerAgentController)
26 
27 WMError SessionManagerAgentController::RegisterWindowManagerAgent(const sptr<IWindowManagerAgent>& windowManagerAgent,
28     WindowManagerAgentType type)
29 {
30     WLOGFD("RegisterWindowManagerAgent");
31     return smAgentContainer_.RegisterAgent(windowManagerAgent, type) ? WMError::WM_OK : WMError::WM_ERROR_NULLPTR;
32 }
33 
UnregisterWindowManagerAgent(const sptr<IWindowManagerAgent> & windowManagerAgent,WindowManagerAgentType type)34 WMError SessionManagerAgentController::UnregisterWindowManagerAgent(const sptr<IWindowManagerAgent>& windowManagerAgent,
35     WindowManagerAgentType type)
36 {
37     WLOGFD("UnregisterWindowManagerAgent");
38     return smAgentContainer_.UnregisterAgent(windowManagerAgent, type) ? WMError::WM_OK : WMError::WM_ERROR_NULLPTR;
39 }
40 
UpdateCameraFloatWindowStatus(uint32_t accessTokenId,bool isShowing)41 void SessionManagerAgentController::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing)
42 {
43     for (auto& agent : smAgentContainer_.GetAgentsByType(
44         WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT)) {
45         if (agent != nullptr) {
46             agent->UpdateCameraFloatWindowStatus(accessTokenId, isShowing);
47         }
48     }
49 }
50 
UpdateFocusChangeInfo(const sptr<FocusChangeInfo> & focusChangeInfo,bool isFocused)51 void SessionManagerAgentController::UpdateFocusChangeInfo(const sptr<FocusChangeInfo>& focusChangeInfo, bool isFocused)
52 {
53     for (auto& agent : smAgentContainer_.GetAgentsByType(
54         WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS)) {
55         if (agent != nullptr) {
56             agent->UpdateFocusChangeInfo(focusChangeInfo, isFocused);
57         }
58     }
59 }
60 
NotifyAccessibilityWindowInfo(const std::vector<sptr<AccessibilityWindowInfo>> & infos,WindowUpdateType type)61 void SessionManagerAgentController::NotifyAccessibilityWindowInfo(
62     const std::vector<sptr<AccessibilityWindowInfo>>& infos, WindowUpdateType type)
63 {
64     for (auto& agent : smAgentContainer_.GetAgentsByType(
65         WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_UPDATE)) {
66         if (agent != nullptr) {
67             agent->NotifyAccessibilityWindowInfo(infos, type);
68         }
69     }
70 }
71 
NotifyWaterMarkFlagChangedResult(bool hasWaterMark)72 void SessionManagerAgentController::NotifyWaterMarkFlagChangedResult(bool hasWaterMark)
73 {
74     WLOGFD("NotifyWaterMarkFlagChanged with result:%{public}u", static_cast<uint32_t>(hasWaterMark));
75     for (auto& agent : smAgentContainer_.GetAgentsByType(
76         WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WATER_MARK_FLAG)) {
77         if (agent != nullptr) {
78             agent->NotifyWaterMarkFlagChangedResult(hasWaterMark);
79         }
80     }
81 }
82 
UpdateWindowVisibilityInfo(const std::vector<sptr<WindowVisibilityInfo>> & windowVisibilityInfos)83 void SessionManagerAgentController::UpdateWindowVisibilityInfo(
84     const std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfos)
85 {
86     WLOGFD("Size:%{public}zu", windowVisibilityInfos.size());
87     for (auto& agent : smAgentContainer_.GetAgentsByType(
88         WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY)) {
89         agent->UpdateWindowVisibilityInfo(windowVisibilityInfos);
90     }
91 }
92 
93 } // namespace Rosen
94 } // namespace OHOS