diff --git a/interfaces/innerkits/dm/display.h b/interfaces/innerkits/dm/display.h index 1c0a8f3c950e1f67f0405a490bfa32e4654bd824..d8914718eb9a20ed2638bb7838b0c4d3fdbff6cd 100644 --- a/interfaces/innerkits/dm/display.h +++ b/interfaces/innerkits/dm/display.h @@ -36,17 +36,67 @@ public: Display(Display&&) = delete; Display& operator=(const Display&) = delete; Display& operator=(Display&&) = delete; + + /** + * @brief Get id of the display. + */ DisplayId GetId() const; + + /** + * @brief Get name of the display. + */ std::string GetName() const; + + /** + * @brief Get width of the display. + */ int32_t GetWidth() const; + + /** + * @brief Get height of the display. + */ int32_t GetHeight() const; + + /** + * @brief Get the refresh rate of the display. + */ uint32_t GetRefreshRate() const; + + /** + * @brief Get screen id. + */ ScreenId GetScreenId() const; + + /** + * @brief Get the virtual pixel ratio of the display. + */ float GetVirtualPixelRatio() const; + + /** + * @brief Get the Dpi of the display. + */ int GetDpi() const; + + /** + * @brief Get the rotation of the display. + */ Rotation GetRotation() const; + + /** + * @brief Get the Orientation of the display. + * + * @return Orientation indicates the direction of the display content. + */ Orientation GetOrientation() const; + + /** + * @brief Get info of the display. + */ sptr GetDisplayInfo() const; + + /** + * @brief Get cutout info of the display. + */ sptr GetCutoutInfo() const; protected: // No more methods or variables can be defined here. diff --git a/interfaces/innerkits/dm/display_manager.h b/interfaces/innerkits/dm/display_manager.h index d75758b318c669e835a1dde73c270f8f0a718db0..3b76e41fcc8f1e81b180d294813c21c0feedc2b7 100644 --- a/interfaces/innerkits/dm/display_manager.h +++ b/interfaces/innerkits/dm/display_manager.h @@ -32,55 +32,204 @@ friend class DMSDeathRecipient; public: class IDisplayListener : public virtual RefBase { public: + /** + * @brief Notify when a new display is created. + */ virtual void OnCreate(DisplayId) = 0; + + /** + * @brief Notify when the display is destroyed. + */ virtual void OnDestroy(DisplayId) = 0; + + /** + * @brief Notify when the state of a display changes + */ virtual void OnChange(DisplayId) = 0; }; class IScreenshotListener : public virtual RefBase { public: + /** + * @brief Notify when a screenshot event occurs. + */ virtual void OnScreenshot(const ScreenshotInfo info) {} }; class IPrivateWindowListener : public virtual RefBase { public: + /** + * @brief Monitor whether the existence of privacy window has changed + */ virtual void OnPrivateWindow(bool hasPrivate) {}; }; + /** + * @brief Obtain the All Displays object + */ std::vector> GetAllDisplays(); + + /** + * @brief Obtain the Id of the default display. + */ DisplayId GetDefaultDisplayId(); + + /** + * @brief Get the Default Display object. + */ sptr GetDefaultDisplay(); + + /** + * @brief Get the Default Display object by means of sync. + */ sptr GetDefaultDisplaySync(); + + /** + * @brief Get the Display object By Id. + * + * @param displayId Id of the target display. + */ sptr GetDisplayById(DisplayId displayId); + + /** + * @brief Get the Display Object By corresponding screenId. + * + * @param screenId Id the target screen. + */ sptr GetDisplayByScreen(ScreenId screenId); + + /** + * @brief Get the All Displays' Id. + */ std::vector GetAllDisplayIds(); + + /** + * @brief Get whether the target display contains privacy windows. + */ DMError HasPrivateWindow(DisplayId displayId, bool& hasPrivateWindow); + /** + * @brief Get screenshot of the target display. + */ std::shared_ptr GetScreenshot(DisplayId displayId); std::shared_ptr GetScreenshot(DisplayId displayId, const Media::Rect &rect, const Media::Size &size, int rotation); + + /** + * @brief Begin to wake screen. + */ bool WakeUpBegin(PowerStateChangeReason reason); + + /** + * @brief Wake up screen end. + */ bool WakeUpEnd(); + + /** + * @brief Begin to suspend the screen. + */ bool SuspendBegin(PowerStateChangeReason reason); + + /** + * @brief Suspend screen end. + * + * @return true + * @return false + */ bool SuspendEnd(); + + /** + * @brief Set the Display State object + */ bool SetDisplayState(DisplayState state, DisplayStateCallback callback); + + /** + * @brief Get the state of the target display. + */ DisplayState GetDisplayState(DisplayId displayId); + + /** + * @brief Set the brightness level of the target screen. + * + * @param screenId Target screen. + * @param level Brightness level. + */ bool SetScreenBrightness(uint64_t screenId, uint32_t level); + + /** + * @brief Get the brightness level of the target screen. + */ uint32_t GetScreenBrightness(uint64_t screenId) const; + + /** + * @brief Notify when events of certain types occur. + */ void NotifyDisplayEvent(DisplayEvent event); + + /** + * @brief Freeze target displays. + */ bool Freeze(std::vector displayIds); + + /** + * @brief Unfreeze target displays. + */ bool Unfreeze(std::vector displayIds); + /** + * @brief Resgister a display listener. + */ DMError RegisterDisplayListener(sptr listener); + + /** + * @brief Unregister an existed display listener. + */ DMError UnregisterDisplayListener(sptr listener); + + /** + * @brief Register a listener for display power events. + */ DMError RegisterDisplayPowerEventListener(sptr listener); + + /** + * @brief Unregiste an existed listener for display power events. + */ DMError UnregisterDisplayPowerEventListener(sptr listener); + + /** + * @brief Register a listener for screenshot event. + */ DMError RegisterScreenshotListener(sptr listener); + + /** + * @brief Unregister an existed listener for screenshot event. + */ DMError UnregisterScreenshotListener(sptr listener); + + /** + * @brief Register a listener for the event of private window. + */ DMError RegisterPrivateWindowListener(sptr listener); + + /** + * @brief Unregister an existed listener for the event of private window. + */ DMError UnregisterPrivateWindowListener(sptr listener); + /** + * @brief Add a surface node to the target display. + * + * @param displayId Target display. + * @param surfaceNode SurfaceNode object. + */ DMError AddSurfaceNodeToDisplay(DisplayId displayId, std::shared_ptr& surfaceNode); + + /** + * @brief Remove a surface node from the target display. + * + * @param displayId Target display. + * @param surfaceNode SurfaceNode object. + */ DMError RemoveSurfaceNodeFromDisplay(DisplayId displayId, std::shared_ptr& surfaceNode); constexpr static int32_t MAX_RESOLUTION_SIZE_SCREENSHOT = 3840; // max resolution, 4K diff --git a/interfaces/innerkits/dm/dm_common.h b/interfaces/innerkits/dm/dm_common.h index 3ad4c10492797abd7ffd26103c7631948313c8c5..0224771970b8a93abd22992204dfc3cd04b9cf75 100644 --- a/interfaces/innerkits/dm/dm_common.h +++ b/interfaces/innerkits/dm/dm_common.h @@ -34,10 +34,17 @@ namespace { constexpr uint32_t BASELINE_DENSITY = 160; } +/** + * @brief Power state change reason. + */ enum class PowerStateChangeReason : uint32_t { POWER_BUTTON, }; + +/** + * @brief Enumerates the state of the screen power. + */ enum class ScreenPowerState : uint32_t { POWER_ON, POWER_STAND_BY, @@ -47,17 +54,26 @@ enum class ScreenPowerState : uint32_t { INVALID_STATE, }; +/** + * @brief Enumerates the state of the display. + */ enum class DisplayState : uint32_t { ON, OFF, UNKNOWN, }; +/** + * @brief Enumerates display events. + */ enum class DisplayEvent : uint32_t { UNLOCK, KEYGUARD_DRAWN, }; +/** + * @brief Enumerates DMError. + */ enum class DMError : int32_t { DM_OK = 0, DM_ERROR_INIT_DMS_PROXY_LOCKED = 100, @@ -77,6 +93,10 @@ enum class DMError : int32_t { DM_ERROR_UNKNOWN = -1, }; +/** + * @brief Enumerates DM error codes. + * + */ enum class DmErrorCode : int32_t { DM_OK = 0, DM_ERROR_NO_PERMISSION = 201, @@ -88,6 +108,10 @@ enum class DmErrorCode : int32_t { DM_ERROR_SYSTEM_INNORMAL = 1400003, }; +/** + * @brief Constructs the mapping of the DM errors to the DM error codes. + * + */ const std::map DM_JS_TO_ERROR_CODE_MAP { {DMError::DM_OK, DmErrorCode::DM_OK }, {DMError::DM_ERROR_INVALID_PERMISSION, DmErrorCode::DM_ERROR_NO_PERMISSION }, @@ -109,6 +133,10 @@ const std::map DM_JS_TO_ERROR_CODE_MAP { using DisplayStateCallback = std::function; +/** + * @brief Enumerates display power events. + * + */ enum class DisplayPowerEvent : uint32_t { WAKE_UP, SLEEP, @@ -117,6 +145,10 @@ enum class DisplayPowerEvent : uint32_t { DESKTOP_READY, }; +/** + * @brief Enumerates event status. + * + */ enum class EventStatus : uint32_t { BEGIN, END, @@ -124,9 +156,16 @@ enum class EventStatus : uint32_t { class IDisplayPowerEventListener : public RefBase { public: + /** + * @brief Notify when display power event status changed. + */ virtual void OnDisplayPowerEvent(DisplayPowerEvent event, EventStatus status) = 0; }; +/** + * @brief Enumerates screen change events. + * + */ enum class ScreenChangeEvent : uint32_t { UPDATE_ORIENTATION, UPDATE_ROTATION, @@ -134,12 +173,20 @@ enum class ScreenChangeEvent : uint32_t { VIRTUAL_PIXEL_RATIO_CHANGED, }; +/** + * @brief Enumerates screen group change events. + * + */ enum class ScreenGroupChangeEvent : uint32_t { ADD_TO_GROUP, REMOVE_FROM_GROUP, CHANGE_GROUP, }; +/** + * @brief Enumerates rotations. + * + */ enum class Rotation : uint32_t { ROTATION_0, ROTATION_90, @@ -147,6 +194,10 @@ enum class Rotation : uint32_t { ROTATION_270, }; +/** + * @brief Enumerates orientations. + * + */ enum class Orientation : uint32_t { BEGIN = 0, UNSPECIFIED = BEGIN, @@ -164,6 +215,10 @@ enum class Orientation : uint32_t { END = LOCKED, }; +/** + * @brief Enumerates display orientations. + * + */ enum class DisplayOrientation : uint32_t { PORTRAIT = 0, LANDSCAPE, @@ -172,6 +227,10 @@ enum class DisplayOrientation : uint32_t { UNKNOWN, }; +/** + * @brief Enumerates display change events. + * + */ enum class DisplayChangeEvent : uint32_t { UPDATE_ORIENTATION, UPDATE_ROTATION, @@ -184,6 +243,10 @@ enum class DisplayChangeEvent : uint32_t { UNKNOWN, }; +/** + * @brief Enumerates screen source mode. + * + */ enum class ScreenSourceMode: uint32_t { SCREEN_MAIN = 0, SCREEN_MIRROR = 1, diff --git a/interfaces/innerkits/dm/screen.h b/interfaces/innerkits/dm/screen.h index e748e8a2727693ae308a995a18ebbdbea106cceb..a20de49a18fefe2549cfb0dd1756835aefafd609 100644 --- a/interfaces/innerkits/dm/screen.h +++ b/interfaces/innerkits/dm/screen.h @@ -66,29 +66,116 @@ public: Screen& operator=(Screen&&) = delete; bool IsGroup() const; std::string GetName() const; + + /** + * @brief Get screen id. + */ ScreenId GetId() const; + + /** + * @brief Get width of the screen. + */ uint32_t GetWidth() const; + + /** + * @brief Get height of the screen. + */ uint32_t GetHeight() const; + + /** + * @brief Get virtual width of the screen. + */ uint32_t GetVirtualWidth() const; + + /** + * @brief Get virtual height of the screen. + */ uint32_t GetVirtualHeight() const; + + /** + * @brief Get virtual pixel ratio of the screen. + */ float GetVirtualPixelRatio() const; + + /** + * @brief Get the Rotation of the screen. + */ Rotation GetRotation() const; + + /** + * @brief Get the orientation of the screen. + */ Orientation GetOrientation() const; + + /** + * @brief Is a real screen. + */ bool IsReal() const; + + /** + * @brief Get screen parent id. + */ ScreenId GetParentId() const; + + /** + * @brief Get screen mode id. + */ uint32_t GetModeId() const; + + /** + * @brief Get supported modes of the screen. + */ std::vector> GetSupportedModes() const; + + /** + * @brief Set screen active mode. + */ DMError SetScreenActiveMode(uint32_t modeId); + + /** + * @brief Set orientation for the screen. + */ DMError SetOrientation(Orientation orientation) const; + + /** + * @brief Set the density dpi of the screen. + */ DMError SetDensityDpi(uint32_t dpi) const; + + /** + * @brief Get the screen info. + */ sptr GetScreenInfo() const; // colorspace, gamut + /** + * @brief Get the supported color gamuts of the screen. + */ DMError GetScreenSupportedColorGamuts(std::vector& colorGamuts) const; + + /** + * @brief Get the color gamut of the screen. + */ DMError GetScreenColorGamut(ScreenColorGamut& colorGamut) const; + + /** + * @brief Set the color gamut of the screen. + */ DMError SetScreenColorGamut(int32_t colorGamutIdx); + + /** + * @brief Get the gamut map of the screen. + */ DMError GetScreenGamutMap(ScreenGamutMap& gamutMap) const; + + /** + * @brief Set the gamut map of the screen. + */ DMError SetScreenGamutMap(ScreenGamutMap gamutMap); + + /** + * @brief Set color transform for the screen. + */ DMError SetScreenColorTransform(); protected: // No more methods or variables can be defined here. diff --git a/interfaces/innerkits/dm/screen_group.h b/interfaces/innerkits/dm/screen_group.h index 0a1e37f6c99eb0a39d32a4216504201d840b2e1a..8b00e9b2c6bd9bc99472b68223b06161a45bb63d 100644 --- a/interfaces/innerkits/dm/screen_group.h +++ b/interfaces/innerkits/dm/screen_group.h @@ -36,8 +36,20 @@ public: ScreenGroup(ScreenGroup&&) = delete; ScreenGroup& operator=(const ScreenGroup&) = delete; ScreenGroup& operator=(ScreenGroup&&) = delete; + + /** + * @brief Get the screenCombination type of the screen group. + */ ScreenCombination GetCombination() const; + + /** + * @brief Get the child screen ids. + */ std::vector GetChildIds() const; + + /** + * @brief Get the child screen positions. + */ std::vector GetChildPositions() const; private: diff --git a/interfaces/innerkits/dm/screen_manager.h b/interfaces/innerkits/dm/screen_manager.h index 9f082779f57fdad7a01253f5b89977610c427088..2f0fbe02e722dcc6ae59e48d5590793894d5b5ea 100644 --- a/interfaces/innerkits/dm/screen_manager.h +++ b/interfaces/innerkits/dm/screen_manager.h @@ -30,13 +30,27 @@ friend class DMSDeathRecipient; public: class IScreenListener : public virtual RefBase { public: + /** + * @brief Notify when a new screen is connected. + */ virtual void OnConnect(ScreenId) = 0; + + /** + * @brief Notify when a screen is disconnected. + */ virtual void OnDisconnect(ScreenId) = 0; + + /** + * @brief Notify when state of the screen is changed. + */ virtual void OnChange(ScreenId) = 0; }; class IScreenGroupListener : public virtual RefBase { public: + /** + * @brief Notify when state of the screenGroup is changed. + */ virtual void OnChange(const std::vector&, ScreenGroupChangeEvent) = 0; }; @@ -47,29 +61,109 @@ public: std::string trigger; std::vector ids; }; + /** + * @brief Notify when an event related to screen mirror occurs. + */ virtual void OnMirrorChange(const ChangeInfo& info) {} }; + /** + * @brief Get the screen object by screen id. + */ sptr GetScreenById(ScreenId screenId); + + /** + * @brief Get the screen group object by groupId. + */ sptr GetScreenGroup(ScreenId groupId); + + /** + * @brief Get the All Screens object. + */ DMError GetAllScreens(std::vector>& screens); + /** + * @brief Make screens as expand-screen. + */ DMError MakeExpand(const std::vector& options, ScreenId& screenGroupId); + + /** + * @brief Make screens as mirror-screen + */ DMError MakeMirror(ScreenId mainScreenId, std::vector mirrorScreenId, ScreenId& screenGroupId); + + /** + * @brief Remove virtual screen from group. + */ DMError RemoveVirtualScreenFromGroup(std::vector screens); + + /** + * @brief Create virtual screen. + * + * @param option Indicates the options of the virtual screen. + */ ScreenId CreateVirtualScreen(VirtualScreenOption option); + + /** + * @brief Destroy virtual screen. + * + * @param screenId Indicates the screen id of the virtual screen. + */ DMError DestroyVirtualScreen(ScreenId screenId); + + /** + * @brief Set surface for the virtual screen. + */ DMError SetVirtualScreenSurface(ScreenId screenId, sptr surface); + + /** + * @brief Set the screen power states for all screens. + */ bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason); + + /** + * @brief Get screen power state. + */ ScreenPowerState GetScreenPower(ScreenId screenId); + + /** + * @brief Set screen rotation lock status. + */ DMError SetScreenRotationLocked(bool isLocked); + + /** + * @brief Get screen rotation lock status. + */ DMError IsScreenRotationLocked(bool& isLocked); + /** + * @brief Register screen listener. + */ DMError RegisterScreenListener(sptr listener); + + /** + * @brief Unregister screen listener. + */ DMError UnregisterScreenListener(sptr listener); + + /** + * @brief Register screen group listener. + */ DMError RegisterScreenGroupListener(sptr listener); + + /** + * @brief Unregister screen group listener. + */ DMError UnregisterScreenGroupListener(sptr listener); + + /** + * @brief Register virtual screen group listener. + */ DMError RegisterVirtualScreenGroupListener(sptr listener); + + /** + * @brief Unregister virtual screen group listener. + */ DMError UnregisterVirtualScreenGroupListener(sptr listener); private: ScreenManager();