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, bool isUseDma = false) = 0; 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; 118 virtual bool SetSpecifiedScreenPower(ScreenId screenId, ScreenPowerState state, PowerStateChangeReason reason) = 0; 119 virtual bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) = 0; 120 virtual ScreenPowerState GetScreenPower(ScreenId dmsScreenId) = 0; 121 virtual bool SetDisplayState(DisplayState state) = 0; 122 virtual DisplayState GetDisplayState(DisplayId displayId) = 0; 123 virtual bool TryToCancelScreenOff() = 0; SetScreenBrightness(uint64_t screenId,uint32_t level)124 virtual bool SetScreenBrightness(uint64_t screenId, uint32_t level) { return false; } GetScreenBrightness(uint64_t screenId)125 virtual uint32_t GetScreenBrightness(uint64_t screenId) { return 0; } 126 virtual std::vector<DisplayId> GetAllDisplayIds() = 0; 127 virtual sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId) = 0; 128 virtual void NotifyDisplayEvent(DisplayEvent event) = 0; 129 virtual bool SetFreeze(std::vector<DisplayId> displayIds, bool isFreeze) = 0; 130 virtual sptr<ScreenInfo> GetScreenInfoById(ScreenId screenId) = 0; 131 virtual sptr<ScreenGroupInfo> GetScreenGroupInfoById(ScreenId screenId) = 0; 132 virtual DMError GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos) = 0; 133 virtual DMError MakeMirror(ScreenId mainScreenId, std::vector<ScreenId> mirrorScreenIds, 134 ScreenId& screenGroupId) = 0; 135 virtual DMError MakeExpand(std::vector<ScreenId> screenId, std::vector<Point> startPoints, 136 ScreenId& screenGroupId) = 0; 137 virtual DMError StopMirror(const std::vector<ScreenId>& mirrorScreenIds) = 0; 138 virtual DMError StopExpand(const std::vector<ScreenId>& expandScreenIds) = 0; DisableMirror(bool disableOrNot)139 virtual DMError DisableMirror(bool disableOrNot) { return DMError::DM_ERROR_INVALID_PERMISSION; } 140 virtual void RemoveVirtualScreenFromGroup(std::vector<ScreenId> screens) = 0; 141 virtual DMError SetScreenActiveMode(ScreenId screenId, uint32_t modeId) = 0; 142 virtual DMError SetVirtualPixelRatio(ScreenId screenId, float virtualPixelRatio) = 0; SetVirtualPixelRatioSystem(ScreenId screenId,float virtualPixelRatio)143 virtual DMError SetVirtualPixelRatioSystem(ScreenId screenId, float virtualPixelRatio) 144 { 145 return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; 146 } 147 virtual DMError SetResolution(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio) = 0; 148 virtual DMError GetDensityInCurResolution(ScreenId screenId, float& virtualPixelRatio) = 0; ResizeVirtualScreen(ScreenId screenId,uint32_t width,uint32_t height)149 virtual DMError ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height) { return DMError::DM_OK; } 150 virtual DMError AddSurfaceNodeToDisplay(DisplayId displayId, 151 std::shared_ptr<class RSSurfaceNode>& surfaceNode, bool onTop = true) = 0; 152 virtual DMError RemoveSurfaceNodeFromDisplay(DisplayId displayId, 153 std::shared_ptr<class RSSurfaceNode>& surfaceNode) = 0; GetAvailableArea(DisplayId displayId,DMRect & area)154 virtual DMError GetAvailableArea(DisplayId displayId, DMRect& area) { return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } IsFoldable()155 virtual bool IsFoldable() { return false; } IsCaptured()156 virtual bool IsCaptured() { return false; } 157 GetFoldStatus()158 virtual FoldStatus GetFoldStatus() { return FoldStatus::UNKNOWN; } 159 GetFoldDisplayMode()160 virtual FoldDisplayMode GetFoldDisplayMode() { return FoldDisplayMode::UNKNOWN; } 161 SetFoldDisplayMode(const FoldDisplayMode)162 virtual void SetFoldDisplayMode(const FoldDisplayMode) {} 163 SetFoldDisplayModeFromJs(const FoldDisplayMode)164 virtual DMError SetFoldDisplayModeFromJs(const FoldDisplayMode) { return DMError::DM_OK; } 165 SetDisplayScale(ScreenId screenId,float scaleX,float scaleY,float pivotX,float pivotY)166 virtual void SetDisplayScale(ScreenId screenId, float scaleX, float scaleY, float pivotX, float pivotY) {} 167 SetFoldStatusLocked(bool locked)168 virtual void SetFoldStatusLocked(bool locked) {} 169 SetFoldStatusLockedFromJs(bool locked)170 virtual DMError SetFoldStatusLockedFromJs(bool locked) { return DMError::DM_OK; } 171 GetCurrentFoldCreaseRegion()172 virtual sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion() { return nullptr; } 173 HasImmersiveWindow(bool & immersive)174 virtual DMError HasImmersiveWindow(bool& immersive) { return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; } 175 176 // unique screen MakeUniqueScreen(const std::vector<ScreenId> & screenIds)177 virtual DMError MakeUniqueScreen(const std::vector<ScreenId>& screenIds) { return DMError::DM_OK; } 178 GetVirtualScreenFlag(ScreenId screenId)179 virtual VirtualScreenFlag GetVirtualScreenFlag(ScreenId screenId) 180 { 181 return VirtualScreenFlag::DEFAULT; 182 } SetVirtualScreenFlag(ScreenId screenId,VirtualScreenFlag screenFlag)183 virtual DMError SetVirtualScreenFlag(ScreenId screenId, VirtualScreenFlag screenFlag) 184 { 185 return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; 186 } SetVirtualScreenRefreshRate(ScreenId screenId,uint32_t refreshInterval)187 virtual DMError SetVirtualScreenRefreshRate(ScreenId screenId, uint32_t refreshInterval) 188 { 189 return DMError::DM_OK; 190 } ProxyForFreeze(const std::set<int32_t> & pidList,bool isProxy)191 virtual DMError ProxyForFreeze(const std::set<int32_t>& pidList, bool isProxy) 192 { 193 return DMError::DM_OK; 194 } ResetAllFreezeStatus()195 virtual DMError ResetAllFreezeStatus() 196 { 197 return DMError::DM_OK; 198 } SetVirtualScreenBlackList(ScreenId screenId,std::vector<uint64_t> & windowIdList)199 virtual void SetVirtualScreenBlackList(ScreenId screenId, std::vector<uint64_t>& windowIdList) {} DisablePowerOffRenderControl(ScreenId screenId)200 virtual void DisablePowerOffRenderControl(ScreenId screenId) {} 201 GetAllDisplayPhysicalResolution()202 virtual std::vector<DisplayPhysicalResolution> GetAllDisplayPhysicalResolution() 203 { 204 return std::vector<DisplayPhysicalResolution> {}; 205 } SetVirtualScreenSecurityExemption(ScreenId screenId,uint32_t pid,std::vector<uint64_t> & windowIdList)206 virtual DMError SetVirtualScreenSecurityExemption(ScreenId screenId, uint32_t pid, 207 std::vector<uint64_t>& windowIdList) 208 { 209 return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; 210 } 211 SetVirtualScreenMaxRefreshRate(ScreenId id,uint32_t refreshRate,uint32_t & actualRefreshRate)212 virtual DMError SetVirtualScreenMaxRefreshRate(ScreenId id, uint32_t refreshRate, 213 uint32_t& actualRefreshRate) 214 { 215 return DMError::DM_ERROR_DEVICE_NOT_SUPPORT; 216 } 217 218 virtual std::shared_ptr<Media::PixelMap> GetScreenCapture(const CaptureOption& captureOption, 219 DmErrorCode* errorCode = nullptr) 220 { 221 *errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT; 222 return nullptr; 223 } 224 GetPrimaryDisplayInfo()225 virtual sptr<DisplayInfo> GetPrimaryDisplayInfo() 226 { 227 return nullptr; 228 } 229 virtual std::shared_ptr<Media::PixelMap> GetDisplaySnapshotWithOption(const CaptureOption& captureOption, 230 DmErrorCode* errorCode = nullptr) 231 { 232 *errorCode = DmErrorCode::DM_ERROR_DEVICE_NOT_SUPPORT; 233 return nullptr; 234 } 235 }; 236 } // namespace OHOS::Rosen 237 238 #endif // FOUNDATION_DMSERVER_DISPLAY_MANAGER_INTERFACE_H