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 #ifndef FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_H
17 #define FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_H
18 
19 #include <iremote_broker.h>
20 #include <pixel_map.h>
21 #include <surface.h>
22 #include <set>
23 
24 #include "display_cutout_controller.h"
25 #include "display_info.h"
26 #include "dm_common.h"
27 #include "fold_screen_info.h"
28 #include "screen.h"
29 #include "screen_info.h"
30 #include "screen_group_info.h"
31 #include "display_manager_interface_code.h"
32 #include "zidl/display_manager_agent_interface.h"
33 
34 namespace OHOS::Rosen {
35 class IDisplayManager : public IRemoteBroker {
36 public:
37     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.IDisplayManager");
38 
39     virtual sptr<DisplayInfo> GetDefaultDisplayInfo() = 0;
40     virtual sptr<DisplayInfo> GetDisplayInfoById(DisplayId displayId) = 0;
41     virtual sptr<DisplayInfo> GetDisplayInfoByScreen(ScreenId screenId) = 0;
42     virtual DMError HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow) = 0;
ConvertScreenIdToRsScreenId(ScreenId screenId, ScreenId& rsScreenId)43     virtual bool ConvertScreenIdToRsScreenId(ScreenId screenId, ScreenId& rsScreenId) { return false; };
UpdateDisplayHookInfo(int32_t uid, bool enable, const DMHookInfo& hookInfo)44     virtual void UpdateDisplayHookInfo(int32_t uid, bool enable, const DMHookInfo& hookInfo) {};
45 
46     virtual ScreenId CreateVirtualScreen(VirtualScreenOption option,
47         const sptr<IRemoteObject>& displayManagerAgent) = 0;
48     virtual DMError DestroyVirtualScreen(ScreenId screenId) = 0;
49     virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr<IBufferProducer> surface) = 0;
SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool rotate)50     virtual DMError SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool rotate) { return DMError::DM_OK; }
SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode)51     virtual DMError SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode)
52     {
53         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
54     }
55     virtual DMError SetOrientation(ScreenId screenId, Orientation orientation) = 0;
56     virtual std::shared_ptr<Media::PixelMap> GetDisplaySnapshot(DisplayId displayId,
57         DmErrorCode* errorCode = nullptr) = 0;
GetSnapshotByPicker(Media::Rect &rect, DmErrorCode* errorCode = nullptr)58     virtual std::shared_ptr<Media::PixelMap> GetSnapshotByPicker(Media::Rect &rect, DmErrorCode* errorCode = nullptr)
59     {
60         *errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT;
61         return nullptr;
62     }
63     virtual DMError SetScreenRotationLocked(bool isLocked) = 0;
64     virtual DMError SetScreenRotationLockedFromJs(bool isLocked) = 0;
65     virtual DMError IsScreenRotationLocked(bool& isLocked) = 0;
66 
67     // colorspace, gamut
68     virtual DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector<ScreenColorGamut>& colorGamuts) = 0;
69     virtual DMError GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) = 0;
70     virtual DMError SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) = 0;
71     virtual DMError GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap) = 0;
72     virtual DMError SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) = 0;
73     virtual DMError SetScreenColorTransform(ScreenId screenId) = 0;
74 
GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat)75     virtual DMError GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat)
76     {
77         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
78     }
SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat)79     virtual DMError SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat)
80     {
81         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
82     }
GetSupportedHDRFormats(ScreenId screenId, std::vector<ScreenHDRFormat>& hdrFormats)83     virtual DMError GetSupportedHDRFormats(ScreenId screenId,
84         std::vector<ScreenHDRFormat>& hdrFormats)
85     {
86         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
87     }
GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat)88     virtual DMError GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat)
89     {
90         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
91     }
SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx)92     virtual DMError SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx)
93     {
94         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
95     }
GetSupportedColorSpaces(ScreenId screenId, std::vector<GraphicCM_ColorSpaceType>& colorSpaces)96     virtual DMError GetSupportedColorSpaces(ScreenId screenId,
97         std::vector<GraphicCM_ColorSpaceType>& colorSpaces)
98     {
99         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
100     }
GetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType& colorSpace)101     virtual DMError GetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType& colorSpace)
102     {
103         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
104     }
SetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType colorSpace)105     virtual DMError SetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType colorSpace)
106     {
107         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
108     }
109 
110     virtual DMError RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
111         DisplayManagerAgentType type) = 0;
112     virtual DMError UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
113         DisplayManagerAgentType type) = 0;
114     virtual bool WakeUpBegin(PowerStateChangeReason reason) = 0;
115     virtual bool WakeUpEnd() = 0;
116     virtual bool SuspendBegin(PowerStateChangeReason reason) = 0;
117     virtual bool SuspendEnd() = 0;
GetInternalScreenId()118     virtual ScreenId GetInternalScreenId() { return SCREEN_ID_INVALID; }
SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason)119     virtual bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason)
120     {
121         return false;
122     }
123     virtual bool SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) = 0;
124     virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) = 0;
125     virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId) = 0;
126     virtual bool SetDisplayState(DisplayState state) = 0;
127     virtual DisplayState GetDisplayState(DisplayId displayId) = 0;
128     virtual bool TryToCancelScreenOff() = 0;
SetScreenBrightness(uint64_t screenId, uint32_t level)129     virtual bool SetScreenBrightness(uint64_t screenId, uint32_t level) { return false; }
GetScreenBrightness(uint64_t screenId)130     virtual uint32_t GetScreenBrightness(uint64_t screenId) { return 0; }
131     virtual std::vector<DisplayId> GetAllDisplayIds() = 0;
132     virtual sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId) = 0;
133     virtual void NotifyDisplayEvent(DisplayEvent event) = 0;
134     virtual bool SetFreeze(std::vector<DisplayId> displayIds, bool isFreeze) = 0;
135     virtual sptr<ScreenInfo> GetScreenInfoById(ScreenId screenId) = 0;
136     virtual sptr<ScreenGroupInfo> GetScreenGroupInfoById(ScreenId screenId) = 0;
137     virtual DMError GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos) = 0;
138     virtual DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenIds,
139         ScreenId& screenGroupId) = 0;
SetMultiScreenMode(ScreenId mainScreenId, ScreenId secondaryScreenId, MultiScreenMode screenMode)140     virtual DMError SetMultiScreenMode(ScreenId mainScreenId, ScreenId secondaryScreenId,
141         MultiScreenMode screenMode)
142     {
143         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
144     }
SetMultiScreenRelativePosition(MultiScreenPositionOptions mainScreenOptions, MultiScreenPositionOptions secondScreenOption)145     virtual DMError SetMultiScreenRelativePosition(MultiScreenPositionOptions mainScreenOptions,
146         MultiScreenPositionOptions secondScreenOption)
147     {
148         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
149     }
150     virtual DMError MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoints,
151         ScreenId& screenGroupId) = 0;
152     virtual DMError StopMirror(const std::vector<ScreenId>& mirrorScreenIds) = 0;
153     virtual DMError StopExpand(const std::vector<ScreenId>& expandScreenIds) = 0;
DisableMirror(bool disableOrNot)154     virtual DMError DisableMirror(bool disableOrNot) { return DMError::DM_ERROR_INVALID_PERMISSION; }
155     virtual void RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens) = 0;
156     virtual DMError SetScreenActiveMode(ScreenId screenId, uint32_t modeId) = 0;
157     virtual DMError SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) = 0;
SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio)158     virtual DMError SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio)
159     {
160         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
161     }
162     virtual DMError SetResolution(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio) = 0;
163     virtual DMError GetDensityInCurResolution(ScreenId screenId, float& virtualPixelRatio) = 0;
ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height)164     virtual DMError ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height) { return DMError::DM_OK; }
165     virtual DMError AddSurfaceNodeToDisplay(DisplayId displayId,
166         std::shared_ptr<class RSSurfaceNode>& surfaceNode, bool onTop = true) = 0;
167     virtual DMError RemoveSurfaceNodeFromDisplay(DisplayId displayId,
168         std::shared_ptr<class RSSurfaceNode>& surfaceNode) = 0;
GetAvailableArea(DisplayId displayId, DMRect& area)169     virtual DMError GetAvailableArea(DisplayId displayId, DMRect& area) { return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; }
IsFoldable()170     virtual bool IsFoldable() { return false; }
IsCaptured()171     virtual bool IsCaptured() { return false; }
172 
GetFoldStatus()173     virtual FoldStatus GetFoldStatus() { return FoldStatus::UNKNOWN; }
174 
GetFoldDisplayMode()175     virtual FoldDisplayMode GetFoldDisplayMode() { return FoldDisplayMode::UNKNOWN; }
176 
SetFoldDisplayMode(const FoldDisplayMode)177     virtual void SetFoldDisplayMode(const FoldDisplayMode) {}
178 
SetFoldDisplayModeFromJs(const FoldDisplayMode)179     virtual DMError SetFoldDisplayModeFromJs(const FoldDisplayMode) { return DMError::DM_OK; }
180 
SetDisplayScale(ScreenId screenId, float scaleX, float scaleY, float pivotX, float pivotY)181     virtual void SetDisplayScale(ScreenId screenId, float scaleX, float scaleY, float pivotX, float pivotY) {}
182 
SetFoldStatusLocked(bool locked)183     virtual void SetFoldStatusLocked(bool locked) {}
184 
SetFoldStatusLockedFromJs(bool locked)185     virtual DMError SetFoldStatusLockedFromJs(bool locked) { return DMError::DM_OK; }
186 
GetCurrentFoldCreaseRegion()187     virtual sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion() { return nullptr; }
188 
HasImmersiveWindow(ScreenId screenId, bool& immersive)189     virtual DMError HasImmersiveWindow(ScreenId screenId, bool& immersive)
190     {
191         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
192     }
193 
194     // unique screen
MakeUniqueScreen(const std::vector<ScreenId>& screenIds)195     virtual DMError MakeUniqueScreen(const std::vector<ScreenId>& screenIds) { return DMError::DM_OK; }
196 
GetVirtualScreenFlag(ScreenId screenId)197     virtual VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId)
198     {
199         return VirtualScreenFlag::DEFAULT;
200     }
SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag)201     virtual DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag)
202     {
203         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
204     }
SetVirtualScreenRefreshRate(ScreenId screenId, uint32_t refreshInterval)205     virtual DMError SetVirtualScreenRefreshRate(ScreenId screenId, uint32_t refreshInterval)
206     {
207         return DMError::DM_OK;
208     }
ProxyForFreeze(const std::set<int32_t>& pidList, bool isProxy)209     virtual DMError ProxyForFreeze(const std::set<int32_t>& pidList, bool isProxy)
210     {
211         return DMError::DM_OK;
212     }
ResetAllFreezeStatus()213     virtual DMError ResetAllFreezeStatus()
214     {
215         return DMError::DM_OK;
216     }
SetVirtualScreenBlackList(ScreenId screenId, std::vector<uint64_t>& windowIdList)217     virtual void SetVirtualScreenBlackList(ScreenId screenId, std::vector<uint64_t>& windowIdList) {}
DisablePowerOffRenderControl(ScreenId screenId)218     virtual void DisablePowerOffRenderControl(ScreenId screenId) {}
219 
GetAllDisplayPhysicalResolution()220     virtual std::vector<DisplayPhysicalResolution> GetAllDisplayPhysicalResolution()
221     {
222         return std::vector<DisplayPhysicalResolution> {};
223     }
SetVirtualScreenStatus(ScreenId screenId, VirtualScreenStatus screenStatus)224     virtual bool SetVirtualScreenStatus(ScreenId screenId, VirtualScreenStatus screenStatus) { return false; }
SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid, std::vector<uint64_t>& windowIdList)225     virtual DMError SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid,
226         std::vector<uint64_t>& windowIdList)
227     {
228         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
229     }
SetVirtualScreenMaxRefreshRate(ScreenId id, uint32_t refreshRate, uint32_t& actualRefreshRate)230     virtual DMError SetVirtualScreenMaxRefreshRate(ScreenId id, uint32_t refreshRate,
231         uint32_t& actualRefreshRate)
232     {
233         return DMError::DM_OK;
234     }
235 };
236 } // namespace OHOS::Rosen
237 
238 #endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_H