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