• 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 bool WindowManagerAgentController::RegisterWindowManagerAgent(const sptr<IWindowManagerAgent>& windowManagerAgent,
28     WindowManagerAgentType type)
29 {
30     return wmAgentContainer_.RegisterAgent(windowManagerAgent, type);
31 }
32 
UnregisterWindowManagerAgent(const sptr<IWindowManagerAgent> & windowManagerAgent,WindowManagerAgentType type)33 bool WindowManagerAgentController::UnregisterWindowManagerAgent(const sptr<IWindowManagerAgent>& windowManagerAgent,
34     WindowManagerAgentType type)
35 {
36     return wmAgentContainer_.UnregisterAgent(windowManagerAgent, type);
37 }
38 
UpdateFocusChangeInfo(const sptr<FocusChangeInfo> & focusChangeInfo,bool focused)39 void WindowManagerAgentController::UpdateFocusChangeInfo(const sptr<FocusChangeInfo>& focusChangeInfo, bool focused)
40 {
41     for (auto& agent : wmAgentContainer_.GetAgentsByType(WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_FOCUS)) {
42         agent->UpdateFocusChangeInfo(focusChangeInfo, focused);
43     }
44 }
45 
UpdateSystemBarRegionTints(DisplayId displayId,const SystemBarRegionTints & tints)46 void WindowManagerAgentController::UpdateSystemBarRegionTints(DisplayId displayId, const SystemBarRegionTints& tints)
47 {
48     WLOGFD("tints size: %{public}u", static_cast<uint32_t>(tints.size()));
49     if (tints.empty()) {
50         return;
51     }
52     for (auto& agent : wmAgentContainer_.GetAgentsByType(
53         WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_SYSTEM_BAR)) {
54         agent->UpdateSystemBarRegionTints(displayId, tints);
55     }
56 }
57 
NotifyAccessibilityWindowInfo(const std::vector<sptr<AccessibilityWindowInfo>> & infos,WindowUpdateType type)58 void WindowManagerAgentController::NotifyAccessibilityWindowInfo(
59     const std::vector<sptr<AccessibilityWindowInfo>>& infos, WindowUpdateType type)
60 {
61     WLOGFD("NotifyAccessibilityWindowInfo");
62     for (auto& agent : wmAgentContainer_.GetAgentsByType(
63         WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_UPDATE)) {
64         agent->NotifyAccessibilityWindowInfo(infos, type);
65     }
66 }
67 
UpdateWindowVisibilityInfo(const std::vector<sptr<WindowVisibilityInfo>> & windowVisibilityInfos)68 void WindowManagerAgentController::UpdateWindowVisibilityInfo(
69     const std::vector<sptr<WindowVisibilityInfo>>& windowVisibilityInfos)
70 {
71     WLOGFD("UpdateWindowVisibilityInfo size:%{public}zu", windowVisibilityInfos.size());
72     for (auto& agent : wmAgentContainer_.GetAgentsByType(
73         WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_WINDOW_VISIBILITY)) {
74         agent->UpdateWindowVisibilityInfo(windowVisibilityInfos);
75     }
76 }
77 
UpdateCameraFloatWindowStatus(uint32_t accessTokenId,bool isShowing)78 void WindowManagerAgentController::UpdateCameraFloatWindowStatus(uint32_t accessTokenId, bool isShowing)
79 {
80     for (auto& agent : wmAgentContainer_.GetAgentsByType(
81         WindowManagerAgentType::WINDOW_MANAGER_AGENT_TYPE_CAMERA_FLOAT)) {
82         agent->UpdateCameraFloatWindowStatus(accessTokenId, isShowing);
83     }
84 }
85 } // namespace Rosen
86 } // namespace OHOS