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,bool isUseDma)65 std::shared_ptr<Media::PixelMap> DisplayManager::GetScreenshot(DisplayId displayId, DmErrorCode* errorCode,
66 bool isUseDma)
67 {
68 return nullptr;
69 }
70
GetScreenshot(DisplayId displayId,const Media::Rect & rect,const Media::Size & size,int rotation,DmErrorCode * errorCode)71 std::shared_ptr<Media::PixelMap> DisplayManager::GetScreenshot(DisplayId displayId,
72 const Media::Rect& rect, const Media::Size& size, int rotation, DmErrorCode* errorCode)
73 {
74 return nullptr;
75 }
76
GetDefaultDisplay()77 sptr<Display> DisplayManager::GetDefaultDisplay()
78 {
79 return GetDisplayById(GetDefaultDisplayId());
80 }
81
GetAllDisplayIds()82 std::vector<DisplayId> DisplayManager::GetAllDisplayIds()
83 {
84 std::vector<DisplayId> res = {};
85 return res;
86 }
87
GetAllDisplays()88 std::vector<sptr<Display>> DisplayManager::GetAllDisplays()
89 {
90 std::vector<sptr<Display>> res;
91 return res;
92 }
93
RegisterDisplayListener(sptr<IDisplayListener> listener)94 DMError DisplayManager::RegisterDisplayListener(sptr<IDisplayListener> listener)
95 {
96 return DMError::DM_OK;
97 }
98
UnregisterDisplayListener(sptr<IDisplayListener> listener)99 DMError DisplayManager::UnregisterDisplayListener(sptr<IDisplayListener> listener)
100 {
101 return DMError::DM_OK;
102 }
103
RegisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener)104 DMError DisplayManager::RegisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener)
105 {
106 return DMError::DM_OK;
107 }
108
UnregisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener)109 DMError DisplayManager::UnregisterDisplayPowerEventListener(sptr<IDisplayPowerEventListener> listener)
110 {
111 return DMError::DM_OK;
112 }
113
WakeUpBegin(PowerStateChangeReason reason)114 bool DisplayManager::WakeUpBegin(PowerStateChangeReason reason)
115 {
116 return true;
117 }
118
WakeUpEnd()119 bool DisplayManager::WakeUpEnd()
120 {
121 return true;
122 }
123
SuspendBegin(PowerStateChangeReason reason)124 bool DisplayManager::SuspendBegin(PowerStateChangeReason reason)
125 {
126 return true;
127 }
128
SuspendEnd()129 bool DisplayManager::SuspendEnd()
130 {
131 return true;
132 }
133
SetDisplayState(DisplayState state,DisplayStateCallback callback)134 bool DisplayManager::SetDisplayState(DisplayState state, DisplayStateCallback callback)
135 {
136 return true;
137 }
138
GetDisplayState(DisplayId displayId)139 DisplayState DisplayManager::GetDisplayState(DisplayId displayId)
140 {
141 DisplayState state = DisplayState::UNKNOWN;
142 return state;
143 }
144
SetScreenBrightness(uint64_t screenId,uint32_t level)145 bool DisplayManager::SetScreenBrightness(uint64_t screenId, uint32_t level)
146 {
147 return true;
148 }
149
GetScreenBrightness(uint64_t screenId) const150 uint32_t DisplayManager::GetScreenBrightness(uint64_t screenId) const
151 {
152 return 0;
153 }
154
NotifyDisplayEvent(DisplayEvent event)155 void DisplayManager::NotifyDisplayEvent(DisplayEvent event)
156 {}
157 } // namespace OHOS::Rosen