• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 "window_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, "WindowManagerAgentController"};
24 }
WM_IMPLEMENT_SINGLE_INSTANCE(WindowManagerAgentController)25 WM_IMPLEMENT_SINGLE_INSTANCE(WindowManagerAgentController)
26 
27 WMError WindowManagerAgentController::RegisterWindowManagerAgent(const sptr<IWindowManagerAgent>& windowManagerAgent,
28     WindowManagerAgentType type)
29 {
30     return wmAgentContainer_.RegisterAgent(windowManagerAgent, type) ? WMError::WM_OK :
31         WMError::WM_ERROR_REPEAT_OPERATION;
32 }
33 
UnregisterWindowManagerAgent(const sptr<IWindowManagerAgent> & windowManagerAgent,WindowManagerAgentType type)34 WMError WindowManagerAgentController::UnregisterWindowManagerAgent(const sptr<IWindowManagerAgent>& windowManagerAgent,
35     WindowManagerAgentType type)
36 {
37     return wmAgentContainer_.UnregisterAgent(windowManagerAgent, type) ? WMError::WM_OK : WMError::WM_ERROR_NULLPTR;
38 }
39 
UpdateFocusChangeInfo(const sptr<FocusChangeInfo> & focusChangeInfo,bool focused)40 void WindowManagerAgentController::UpdateFocusChangeInfo(const sptr<FocusChangeInfo>& focusChangeInfo, bool focused)
41 {
42     for (auto& agent : wmAgentContainer_.GetAgentsByType(WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS)) {
43         agent->UpdateFocusChangeInfo(focusChangeInfo, focused);
44     }
45 }
46 
UpdateSystemBarRegionTints(DisplayId displayId,const SystemBarRegionTints & tints)47 void WindowManagerAgentController::UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints)
48 {
49     WLOGFD("tints size: %{public}u", static_cast<uint32_t>(tints.size()));
50     if (tints.empty()) {
51         return;
52     }
53     for (auto& agent : wmAgentContainer_.GetAgentsByType(
54         WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_SYSTEM_BAR)) {
55         agent->UpdateSystemBarRegionTints(displayId, tints);
56     }
57 }
58 
NotifyAccessibilityWindowInfo(const std::vector<sptr<AccessibilityWindowInfo>> & infos,WindowUpdateType type)59 void WindowManagerAgentController::NotifyAccessibilityWindowInfo(
60     const std::vector<sptr<AccessibilityWindowInfo>>& infos, WindowUpdateType type)
61 {
62     WLOGD("NotifyAccessibilityWindowInfo");
63     for (auto& agent : wmAgentContainer_.GetAgentsByType(
64         WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_UPDATE)) {
65         agent->NotifyAccessibilityWindowInfo(infos, type);
66     }
67 }
68 
UpdateWindowVisibilityInfo(const std::vector<sptr<WindowVisibilityInfo>> & windowVisibilityInfos)69 void WindowManagerAgentController::UpdateWindowVisibilityInfo(
70     const std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfos)
71 {
72     WLOGFD("Size:%{public}zu", windowVisibilityInfos.size());
73     for (auto& agent : wmAgentContainer_.GetAgentsByType(
74         WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY)) {
75         agent->UpdateWindowVisibilityInfo(windowVisibilityInfos);
76     }
77 }
78 
UpdateCameraFloatWindowStatus(uint32_t accessTokenId,bool isShowing)79 void WindowManagerAgentController::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing)
80 {
81     for (auto& agent : wmAgentContainer_.GetAgentsByType(
82         WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT)) {
83         agent->UpdateCameraFloatWindowStatus(accessTokenId, isShowing);
84     }
85 }
86 
NotifyWaterMarkFlagChangedResult(bool showWaterMark)87 void WindowManagerAgentController::NotifyWaterMarkFlagChangedResult(bool showWaterMark)
88 {
89     WLOGFD("NotifyWaterMarkFlagChanged with result:%{public}d", showWaterMark);
90     for (auto& agent : wmAgentContainer_.GetAgentsByType(
91         WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WATER_MARK_FLAG)) {
92         agent->NotifyWaterMarkFlagChangedResult(showWaterMark);
93     }
94 }
95 
NotifyGestureNavigationEnabledResult(bool enable)96 void WindowManagerAgentController::NotifyGestureNavigationEnabledResult(bool enable)
97 {
98     WLOGFD("NotifyGestureNavigationEnabledResult with result:%{public}d", enable);
99     for (auto& agent : wmAgentContainer_.GetAgentsByType(
100         WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_GESTURE_NAVIGATION_ENABLED)) {
101         agent->NotifyGestureNavigationEnabledResult(enable);
102     }
103 }
104 } // namespace Rosen
105 } // namespace OHOS