1 /*
2 * Copyright (C) 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 <cinttypes>
17 #include "display_manager.h"
18 #include "display.h"
19 #include "dm_common.h"
20 #include "singleton_delegator.h"
21 #include "window/window_manager/utils/include/display_info.h"
22
23 namespace OHOS::Rosen {
24 WM_IMPLEMENT_SINGLE_INSTANCE(DisplayManager)
25 class DisplayManager::Impl : public RefBase {
26 friend class DisplayManager;
27
28 private:
29 bool CheckRectValid(const Media::Rect& rect, int32_t oriHeight, int32_t oriWidth) const;
30 bool CheckSizeValid(const Media::Size& size, int32_t oriHeight, int32_t oriWidth) const;
31 void ClearDisplayStateCallback();
32 };
33
CheckRectValid(const Media::Rect& rect, int32_t oriHeight, int32_t oriWidth) const34 bool DisplayManager::Impl::CheckRectValid(const Media::Rect& rect, int32_t oriHeight, int32_t oriWidth) const
35 {
36 return true;
37 }
38
CheckSizeValid(const Media::Size& size, int32_t oriHeight, int32_t oriWidth) const39 bool DisplayManager::Impl::CheckSizeValid(const Media::Size& size, int32_t oriHeight, int32_t oriWidth) const
40 {
41 return true;
42 }
43
ClearDisplayStateCallback()44 void DisplayManager::Impl::ClearDisplayStateCallback()
45 {}
46
DisplayManager()47 DisplayManager::DisplayManager()
48 {}
49
~DisplayManager()50 DisplayManager::~DisplayManager()
51 {}
52
GetDefaultDisplayId()53 DisplayId DisplayManager::GetDefaultDisplayId()
54 {
55 DisplayId id {0};
56 return id;
57 }
58
GetDisplayById(DisplayId displayId)59 sptr<Display> DisplayManager::GetDisplayById(DisplayId displayId)
60 {
61 sptr<Display> display = new Display("display_mock", nullptr);
62 return display;
63 }
64
GetScreenshot(DisplayId displayId, DmErrorCode* errorCode)65 std::shared_ptr<Media::PixelMap> DisplayManager::GetScreenshot(DisplayId displayId, DmErrorCode* errorCode)
66 {
67 return nullptr;
68 }
69
GetScreenshot(DisplayId displayId, const Media::Rect& rect, const Media::Size& size, int rotation, DmErrorCode* errorCode)70 std::shared_ptr<Media::PixelMap> DisplayManager::GetScreenshot(DisplayId displayId,
71 const Media::Rect& rect, const Media::Size& size, int rotation, DmErrorCode* errorCode)
72 {
73 return nullptr;
74 }
75
GetDefaultDisplay()76 sptr<Display> DisplayManager::GetDefaultDisplay()
77 {
78 return GetDisplayById(GetDefaultDisplayId());
79 }
80
GetAllDisplayIds()81 std::vector<DisplayId> DisplayManager::GetAllDisplayIds()
82 {
83 std::vector<DisplayId> res = {};
84 return res;
85 }
86
GetAllDisplays()87 std::vector<sptr<Display>> DisplayManager::GetAllDisplays()
88 {
89 std::vector<sptr<Display>> res;
90 return res;
91 }
92
RegisterDisplayListener(sptr<IDisplayListener> listener)93 DMError DisplayManager::RegisterDisplayListener(sptr<IDisplayListener> listener)
94 {
95 return DMError::DM_OK;
96 }
97
UnregisterDisplayListener(sptr<IDisplayListener> listener)98 DMError DisplayManager::UnregisterDisplayListener(sptr<IDisplayListener> listener)
99 {
100 return DMError::DM_OK;
101 }
102
RegisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener)103 DMError DisplayManager::RegisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener)
104 {
105 return DMError::DM_OK;
106 }
107
UnregisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener)108 DMError DisplayManager::UnregisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener)
109 {
110 return DMError::DM_OK;
111 }
112
WakeUpBegin(PowerStateChangeReason reason)113 bool DisplayManager::WakeUpBegin(PowerStateChangeReason reason)
114 {
115 return true;
116 }
117
WakeUpEnd()118 bool DisplayManager::WakeUpEnd()
119 {
120 return true;
121 }
122
SuspendBegin(PowerStateChangeReason reason)123 bool DisplayManager::SuspendBegin(PowerStateChangeReason reason)
124 {
125 return true;
126 }
127
SuspendEnd()128 bool DisplayManager::SuspendEnd()
129 {
130 return true;
131 }
132
SetDisplayState(DisplayState state, DisplayStateCallback callback)133 bool DisplayManager::SetDisplayState(DisplayState state, DisplayStateCallback callback)
134 {
135 return true;
136 }
137
GetDisplayState(DisplayId displayId)138 DisplayState DisplayManager::GetDisplayState(DisplayId displayId)
139 {
140 DisplayState state = DisplayState::UNKNOWN;
141 return state;
142 }
143
SetScreenBrightness(uint64_t screenId, uint32_t level)144 bool DisplayManager::SetScreenBrightness(uint64_t screenId, uint32_t level)
145 {
146 return true;
147 }
148
GetScreenBrightness(uint64_t screenId) const149 uint32_t DisplayManager::GetScreenBrightness(uint64_t screenId) const
150 {
151 return 0;
152 }
153
NotifyDisplayEvent(DisplayEvent event)154 void DisplayManager::NotifyDisplayEvent(DisplayEvent event)
155 {}
156 } // namespace OHOS::Rosen