• 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 #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> GetVisibleAreaDisplayInfoById(DisplayId displayId) = 0;
42     virtual sptr<DisplayInfo> GetDisplayInfoByScreen(ScreenId screenId) = 0;
43     virtual DMError HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow) = 0;
ConvertScreenIdToRsScreenId(ScreenId screenId,ScreenId & rsScreenId)44     virtual bool ConvertScreenIdToRsScreenId(ScreenId screenId, ScreenId& rsScreenId) { return false; };
UpdateDisplayHookInfo(int32_t uid,bool enable,const DMHookInfo & hookInfo)45     virtual void UpdateDisplayHookInfo(int32_t uid, bool enable, const DMHookInfo& hookInfo) {};
GetDisplayHookInfo(int32_t uid,DMHookInfo & hookInfo)46     virtual void GetDisplayHookInfo(int32_t uid, DMHookInfo& hookInfo) {};
47 
48     virtual ScreenId CreateVirtualScreen(VirtualScreenOption option,
49         const sptr<IRemoteObject>& displayManagerAgent) = 0;
50     virtual DMError DestroyVirtualScreen(ScreenId screenId) = 0;
51     virtual DMError SetVirtualScreenSurface(ScreenId screenId, sptr<IBufferProducer> surface) = 0;
AddVirtualScreenBlockList(const std::vector<int32_t> & persistentIds)52     virtual DMError AddVirtualScreenBlockList(
53         const std::vector<int32_t>& persistentIds) { return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; }
RemoveVirtualScreenBlockList(const std::vector<int32_t> & persistentIds)54     virtual DMError RemoveVirtualScreenBlockList(
55         const std::vector<int32_t>& persistentIds) { return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; }
SetScreenPrivacyMaskImage(ScreenId screenId,const std::shared_ptr<Media::PixelMap> & privacyMaskImg)56     virtual DMError SetScreenPrivacyMaskImage(ScreenId screenId, const std::shared_ptr<Media::PixelMap>& privacyMaskImg)
57     {
58         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
59     }
SetVirtualMirrorScreenCanvasRotation(ScreenId screenId,bool rotate)60     virtual DMError SetVirtualMirrorScreenCanvasRotation(ScreenId screenId, bool rotate) { return DMError::DM_OK; }
SetVirtualMirrorScreenScaleMode(ScreenId screenId,ScreenScaleMode scaleMode)61     virtual DMError SetVirtualMirrorScreenScaleMode(ScreenId screenId, ScreenScaleMode scaleMode)
62     {
63         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
64     }
65     virtual DMError SetOrientation(ScreenId screenId, Orientation orientation) = 0;
66     virtual std::shared_ptr<Media::PixelMap> GetDisplaySnapshot(DisplayId displayId,
67         DmErrorCode* errorCode = nullptr, bool isUseDma = false) = 0;
68     virtual std::shared_ptr<Media::PixelMap> GetSnapshotByPicker(Media::Rect &rect, DmErrorCode* errorCode = nullptr)
69     {
70         *errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT;
71         return nullptr;
72     }
73     virtual DMError SetScreenRotationLocked(bool isLocked) = 0;
74     virtual DMError SetScreenRotationLockedFromJs(bool isLocked) = 0;
75     virtual DMError IsScreenRotationLocked(bool& isLocked) = 0;
76 
77     // colorspace, gamut
78     virtual DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector<ScreenColorGamut>& colorGamuts) = 0;
79     virtual DMError GetScreenColorGamut(ScreenId screenId, ScreenColorGamut& colorGamut) = 0;
80     virtual DMError SetScreenColorGamut(ScreenId screenId, int32_t colorGamutIdx) = 0;
81     virtual DMError GetScreenGamutMap(ScreenId screenId, ScreenGamutMap& gamutMap) = 0;
82     virtual DMError SetScreenGamutMap(ScreenId screenId, ScreenGamutMap gamutMap) = 0;
83     virtual DMError SetScreenColorTransform(ScreenId screenId) = 0;
84 
GetPixelFormat(ScreenId screenId,GraphicPixelFormat & pixelFormat)85     virtual DMError GetPixelFormat(ScreenId screenId, GraphicPixelFormat& pixelFormat)
86     {
87         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
88     }
SetPixelFormat(ScreenId screenId,GraphicPixelFormat pixelFormat)89     virtual DMError SetPixelFormat(ScreenId screenId, GraphicPixelFormat pixelFormat)
90     {
91         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
92     }
GetSupportedHDRFormats(ScreenId screenId,std::vector<ScreenHDRFormat> & hdrFormats)93     virtual DMError GetSupportedHDRFormats(ScreenId screenId,
94         std::vector<ScreenHDRFormat>& hdrFormats)
95     {
96         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
97     }
GetScreenHDRFormat(ScreenId screenId,ScreenHDRFormat & hdrFormat)98     virtual DMError GetScreenHDRFormat(ScreenId screenId, ScreenHDRFormat& hdrFormat)
99     {
100         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
101     }
SetScreenHDRFormat(ScreenId screenId,int32_t modeIdx)102     virtual DMError SetScreenHDRFormat(ScreenId screenId, int32_t modeIdx)
103     {
104         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
105     }
GetSupportedColorSpaces(ScreenId screenId,std::vector<GraphicCM_ColorSpaceType> & colorSpaces)106     virtual DMError GetSupportedColorSpaces(ScreenId screenId,
107         std::vector<GraphicCM_ColorSpaceType>& colorSpaces)
108     {
109         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
110     }
GetScreenColorSpace(ScreenId screenId,GraphicCM_ColorSpaceType & colorSpace)111     virtual DMError GetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType& colorSpace)
112     {
113         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
114     }
SetScreenColorSpace(ScreenId screenId,GraphicCM_ColorSpaceType colorSpace)115     virtual DMError SetScreenColorSpace(ScreenId screenId, GraphicCM_ColorSpaceType colorSpace)
116     {
117         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
118     }
119 
120     virtual DMError RegisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
121         DisplayManagerAgentType type) = 0;
122     virtual DMError UnregisterDisplayManagerAgent(const sptr<IDisplayManagerAgent>& displayManagerAgent,
123         DisplayManagerAgentType type) = 0;
124     virtual bool WakeUpBegin(PowerStateChangeReason reason) = 0;
125     virtual bool WakeUpEnd() = 0;
126     virtual bool SuspendBegin(PowerStateChangeReason reason) = 0;
127     virtual bool SuspendEnd() = 0;
GetInternalScreenId()128     virtual ScreenId GetInternalScreenId() { return SCREEN_ID_INVALID; }
SetScreenPowerById(ScreenId screenId,ScreenPowerState state,PowerStateChangeReason reason)129     virtual bool SetScreenPowerById(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason)
130     {
131         return false;
132     }
133     virtual bool SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) = 0;
134     virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) = 0;
135     virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId) = 0;
GetScreenPower()136     virtual ScreenPowerState GetScreenPower() { return ScreenPowerState::INVALID_STATE; }
137     virtual bool SetDisplayState(DisplayState state) = 0;
138     virtual DisplayState GetDisplayState(DisplayId displayId) = 0;
139     virtual bool TryToCancelScreenOff() = 0;
SetScreenBrightness(uint64_t screenId,uint32_t level)140     virtual bool SetScreenBrightness(uint64_t screenId, uint32_t level) { return false; }
GetScreenBrightness(uint64_t screenId)141     virtual uint32_t GetScreenBrightness(uint64_t screenId) { return 0; }
142     virtual std::vector<DisplayId> GetAllDisplayIds() = 0;
143     virtual sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId) = 0;
144     virtual void NotifyDisplayEvent(DisplayEvent event) = 0;
145     virtual bool SetFreeze(std::vector<DisplayId> displayIds, bool isFreeze) = 0;
146     virtual sptr<ScreenInfo> GetScreenInfoById(ScreenId screenId) = 0;
147     virtual sptr<ScreenGroupInfo> GetScreenGroupInfoById(ScreenId screenId) = 0;
148     virtual DMError GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos) = 0;
149     virtual DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenIds,
150         ScreenId& screenGroupId) = 0;
MakeMirrorForRecord(ScreenId mainScreenId,std::vector<ScreenId> mirrorScreenIds,ScreenId & screenGroupId)151     virtual DMError MakeMirrorForRecord(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenIds,
152         ScreenId& screenGroupId)
153     {
154         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
155     }
MakeMirror(ScreenId mainScreenId,std::vector<ScreenId> mirrorScreenIds,DMRect mainScreenRegion,ScreenId & screenGroupId)156     virtual DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenIds,
157         DMRect mainScreenRegion, ScreenId& screenGroupId)
158     {
159         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
160     }
SetMultiScreenMode(ScreenId mainScreenId,ScreenId secondaryScreenId,MultiScreenMode screenMode)161     virtual DMError SetMultiScreenMode(ScreenId mainScreenId, ScreenId secondaryScreenId,
162         MultiScreenMode screenMode)
163     {
164         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
165     }
SetMultiScreenRelativePosition(MultiScreenPositionOptions mainScreenOptions,MultiScreenPositionOptions secondScreenOption)166     virtual DMError SetMultiScreenRelativePosition(MultiScreenPositionOptions mainScreenOptions,
167         MultiScreenPositionOptions secondScreenOption)
168     {
169         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
170     }
171     virtual DMError MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoints,
172         ScreenId& screenGroupId) = 0;
173     virtual DMError StopMirror(const std::vector<ScreenId>& mirrorScreenIds) = 0;
174     virtual DMError StopExpand(const std::vector<ScreenId>& expandScreenIds) = 0;
DisableMirror(bool disableOrNot)175     virtual DMError DisableMirror(bool disableOrNot) { return DMError::DM_ERROR_INVALID_PERMISSION; }
176     virtual void RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens) = 0;
177     virtual DMError SetScreenActiveMode(ScreenId screenId, uint32_t modeId) = 0;
178     virtual DMError SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) = 0;
SetVirtualPixelRatioSystem(ScreenId screenId,float virtualPixelRatio)179     virtual DMError SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio)
180     {
181         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
182     }
SetDefaultDensityDpi(ScreenId screenId,float virtualPixelRatio)183     virtual DMError SetDefaultDensityDpi(ScreenId screenId, float virtualPixelRatio)
184     {
185         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
186     }
187     virtual DMError SetResolution(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio) = 0;
188     virtual DMError GetDensityInCurResolution(ScreenId screenId, float& virtualPixelRatio) = 0;
ResizeVirtualScreen(ScreenId screenId,uint32_t width,uint32_t height)189     virtual DMError ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height) { return DMError::DM_OK; }
190     virtual DMError AddSurfaceNodeToDisplay(DisplayId displayId,
191         std::shared_ptr<class RSSurfaceNode>& surfaceNode, bool onTop = true) = 0;
192     virtual DMError RemoveSurfaceNodeFromDisplay(DisplayId displayId,
193         std::shared_ptr<class RSSurfaceNode>& surfaceNode) = 0;
GetAvailableArea(DisplayId displayId,DMRect & area)194     virtual DMError GetAvailableArea(DisplayId displayId, DMRect& area) { return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; }
GetExpandAvailableArea(DisplayId displayId,DMRect & area)195     virtual DMError GetExpandAvailableArea(DisplayId displayId, DMRect& area)
196     {
197         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
198     }
IsOrientationNeedChanged()199     virtual bool IsOrientationNeedChanged() {return false;}
IsFoldable()200     virtual bool IsFoldable() { return false; }
IsCaptured()201     virtual bool IsCaptured() { return false; }
202 
GetFoldStatus()203     virtual FoldStatus GetFoldStatus() { return FoldStatus::UNKNOWN; }
204 
GetFoldDisplayMode()205     virtual FoldDisplayMode GetFoldDisplayMode() { return FoldDisplayMode::UNKNOWN; }
206 
SetFoldDisplayMode(const FoldDisplayMode)207     virtual void SetFoldDisplayMode(const FoldDisplayMode) {}
208 
209     virtual DMError SetFoldDisplayModeFromJs(const FoldDisplayMode, std::string reason = "") { return DMError::DM_OK; }
210 
SetDisplayScale(ScreenId screenId,float scaleX,float scaleY,float pivotX,float pivotY)211     virtual void SetDisplayScale(ScreenId screenId, float scaleX, float scaleY, float pivotX, float pivotY) {}
212 
SetFoldStatusLocked(bool locked)213     virtual void SetFoldStatusLocked(bool locked) {}
214 
SetFoldStatusLockedFromJs(bool locked)215     virtual DMError SetFoldStatusLockedFromJs(bool locked) { return DMError::DM_OK; }
216 
GetCurrentFoldCreaseRegion()217     virtual sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion() { return nullptr; }
218 
HasImmersiveWindow(ScreenId screenId,bool & immersive)219     virtual DMError HasImmersiveWindow(ScreenId screenId, bool& immersive)
220     {
221         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
222     }
223 
224     // unique screen
MakeUniqueScreen(const std::vector<ScreenId> & screenIds,std::vector<DisplayId> & displayIds)225     virtual DMError MakeUniqueScreen(const std::vector<ScreenId>& screenIds,
226         std::vector<DisplayId>& displayIds)
227     {
228         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
229     }
230 
GetVirtualScreenFlag(ScreenId screenId)231     virtual VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId)
232     {
233         return VirtualScreenFlag::DEFAULT;
234     }
SetVirtualScreenFlag(ScreenId screenId,VirtualScreenFlag screenFlag)235     virtual DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag)
236     {
237         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
238     }
SetVirtualScreenRefreshRate(ScreenId screenId,uint32_t refreshInterval)239     virtual DMError SetVirtualScreenRefreshRate(ScreenId screenId, uint32_t refreshInterval)
240     {
241         return DMError::DM_OK;
242     }
ProxyForFreeze(const std::set<int32_t> & pidList,bool isProxy)243     virtual DMError ProxyForFreeze(const std::set<int32_t>& pidList, bool isProxy)
244     {
245         return DMError::DM_OK;
246     }
ResetAllFreezeStatus()247     virtual DMError ResetAllFreezeStatus()
248     {
249         return DMError::DM_OK;
250     }
251     virtual void SetVirtualScreenBlackList(ScreenId screenId, std::vector<uint64_t>& windowIdList,
252         std::vector<uint64_t> surfaceIdList = {}) {}
SetVirtualDisplayMuteFlag(ScreenId screenId,bool muteFlag)253     virtual void SetVirtualDisplayMuteFlag(ScreenId screenId, bool muteFlag) {}
DisablePowerOffRenderControl(ScreenId screenId)254     virtual void DisablePowerOffRenderControl(ScreenId screenId) {}
255 
GetAllDisplayPhysicalResolution()256     virtual std::vector<DisplayPhysicalResolution> GetAllDisplayPhysicalResolution()
257     {
258         return std::vector<DisplayPhysicalResolution> {};
259     }
GetDisplayCapability(std::string & capabilitInfo)260     virtual DMError GetDisplayCapability(std::string& capabilitInfo)
261     {
262         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
263     }
SetVirtualScreenStatus(ScreenId screenId,VirtualScreenStatus screenStatus)264     virtual bool SetVirtualScreenStatus(ScreenId screenId, VirtualScreenStatus screenStatus) { return false; }
SetVirtualScreenSecurityExemption(ScreenId screenId,uint32_t pid,std::vector<uint64_t> & windowIdList)265     virtual DMError SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid,
266         std::vector<uint64_t>& windowIdList)
267     {
268         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
269     }
SetVirtualScreenMaxRefreshRate(ScreenId id,uint32_t refreshRate,uint32_t & actualRefreshRate)270     virtual DMError SetVirtualScreenMaxRefreshRate(ScreenId id, uint32_t refreshRate,
271         uint32_t& actualRefreshRate)
272     {
273         return DMError::DM_OK;
274     }
275 
276     virtual std::shared_ptr<Media::PixelMap> GetScreenCapture(const CaptureOption& captureOption,
277         DmErrorCode* errorCode = nullptr)
278     {
279         *errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT;
280         return nullptr;
281     }
282 
GetPrimaryDisplayInfo()283     virtual sptr<DisplayInfo> GetPrimaryDisplayInfo()
284     {
285         return nullptr;
286     }
287     virtual std::shared_ptr<Media::PixelMap> GetDisplaySnapshotWithOption(const CaptureOption& captureOption,
288         DmErrorCode* errorCode = nullptr)
289     {
290         *errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT;
291         return nullptr;
292     }
293 
SetScreenSkipProtectedWindow(const std::vector<ScreenId> & screenIds,bool isEnable)294     virtual DMError SetScreenSkipProtectedWindow(const std::vector<ScreenId>& screenIds, bool isEnable)
295     {
296         return DMError::DM_OK;
297     }
298 
299     virtual DMError SetSystemKeyboardStatus(bool isOn = false)
300     {
301         return DMError::DM_ERROR_DEVICE_NOT_SUPPORT;
302     }
303 };
304 } // namespace OHOS::Rosen
305 
306 #endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_H
307