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