OH_DisplayManager

Overview

The OH_DisplayManager module provides the display management capability.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Summary

Files

Name Description
oh_display_capture.h Declares the capability to take screenshots.
oh_display_info.h Declares the common enums and definitions of the display.
oh_display_manager.h Declares the functions for basic display management. You can call the functions to obtain various information about the default display and listen for display status changes, such as rotation, folding, and unfolding.

Structs

Name Description
struct NativeDisplayManager_Rect Describes a rectangle.
struct NativeDisplayManager_WaterfallDisplayAreaRects Describes the curved area on a waterfall display.
struct NativeDisplayManager_CutoutInfo Describes the unusable area of a display, including punch hole, notch, and curved area of a waterfall display.
struct NativeDisplayManager_DisplayHdrFormat Describes all the HDR formats supported by a display.
struct NativeDisplayManager_DisplayColorSpace Describes all the color spaces supported by a display.
struct NativeDisplayManager_DisplayInfo Encapsulates the information about a display.
struct NativeDisplayManager_DisplaysInfo Encapsulates the information about displays of a device with multiple screens.

Types

Name Description
typedef enum NativeDisplayManager_Rotation NativeDisplayManager_Rotation Defines an enum for the clockwise rotation angles of a display.
typedef enum NativeDisplayManager_Orientation NativeDisplayManager_Orientation Defines an enum for the orientations of a display.
typedef enum NativeDisplayManager_ErrorCode NativeDisplayManager_ErrorCode Defines an enum for the status codes returned by the display manager interface.
typedef enum NativeDisplayManager_FoldDisplayMode NativeDisplayManager_FoldDisplayMode Defines an enum for the display modes of a foldable device.
typedef struct NativeDisplayManager_Rect NativeDisplayManager_Rect Defines a struct for a rectangle.
typedef struct NativeDisplayManager_WaterfallDisplayAreaRects NativeDisplayManager_WaterfallDisplayAreaRects Defines a struct for the curved area on a waterfall display.
typedef struct NativeDisplayManager_CutoutInfo NativeDisplayManager_CutoutInfo Defines a struct for the unusable area of a display, including punch hole, notch, and curved area of a waterfall display.
typedef enum NativeDisplayManager_DisplayState NativeDisplayManager_DisplayState Defines an enum for the states of a display.
typedef struct NativeDisplayManager_DisplayHdrFormat NativeDisplayManager_DisplayHdrFormat Defines a struct for all the HDR formats supported by a display.
typedef struct NativeDisplayManager_DisplayColorSpace NativeDisplayManager_DisplayColorSpace Defines a struct for all the color spaces supported by a display.
typedef struct NativeDisplayManager_DisplayInfo NativeDisplayManager_DisplayInfo Defines a struct that encapsulates the information about a display.
typedef struct NativeDisplayManager_DisplaysInfo NativeDisplayManager_DisplaysInfo Defines a struct that encapsulates the information about displays of a device with multiple screens.
typedef void(* OH_NativeDisplayManager_DisplayChangeCallback) (uint64_t displayId) Defines a callback function to listen for status changes of a display.
typedef void(* OH_NativeDisplayManager_FoldDisplayModeChangeCallback) (NativeDisplayManager_FoldDisplayMode displayMode) Defines a callback function to listen for folded/unfolded state changes of a display.

Enums

Name Description
NativeDisplayManager_Rotation { DISPLAY_MANAGER_ROTATION_0 = 0, DISPLAY_MANAGER_ROTATION_90 = 1, DISPLAY_MANAGER_ROTATION_180 = 2, DISPLAY_MANAGER_ROTATION_270 = 3 } Enumerates the clockwise rotation angles of a display.
NativeDisplayManager_Orientation {
DISPLAY_MANAGER_PORTRAIT = 0, DISPLAY_MANAGER_LANDSCAPE = 1, DISPLAY_MANAGER_PORTRAIT_INVERTED = 2, DISPLAY_MANAGER_LANDSCAPE_INVERTED = 3,
DISPLAY_MANAGER_UNKNOWN
}
Enumerates the orientations of a display.
NativeDisplayManager_ErrorCode {
DISPLAY_MANAGER_OK = 0, DISPLAY_MANAGER_ERROR_NO_PERMISSION = 201, DISPLAY_MANAGER_ERROR_NOT_SYSTEM_APP = 202, DISPLAY_MANAGER_ERROR_INVALID_PARAM = 401,
DISPLAY_MANAGER_ERROR_DEVICE_NOT_SUPPORTED = 801, DISPLAY_MANAGER_ERROR_INVALID_SCREEN = 1400001, DISPLAY_MANAGER_ERROR_INVALID_CALL = 1400002, DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL = 1400003
}
Enumerates the status codes returned by the display manager interface.
NativeDisplayManager_FoldDisplayMode {
DISPLAY_MANAGER_FOLD_DISPLAY_MODE_UNKNOWN = 0, DISPLAY_MANAGER_FOLD_DISPLAY_MODE_FULL = 1, DISPLAY_MANAGER_FOLD_DISPLAY_MODE_MAIN = 2, DISPLAY_MANAGER_FOLD_DISPLAY_MODE_SUB = 3,
DISPLAY_MANAGER_FOLD_DISPLAY_MODE_COORDINATION = 4
}
Enumerates the display modes of a foldable device.
NativeDisplayManager_DisplayState {
DISPLAY_MANAGER_DISPLAY_STATE_UNKNOWN = 0, DISPLAY_MANAGER_DISPLAY_STATE_OFF = 1, DISPLAY_MANAGER_DISPLAY_STATE_ON = 2, DISPLAY_MANAGER_DISPLAY_STATE_DOZE = 3,
DISPLAY_MANAGER_DISPLAY_STATE_DOZE_SUSPEND = 4, DISPLAY_MANAGER_DISPLAY_STATE_VR = 5, DISPLAY_MANAGER_DISPLAY_STATE_ON_SUSPEND = 6
}
Enumerates the states of a display.

Functions

Name Description
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CaptureScreenPixelmap (uint32_t displayId, OH_PixelmapNative **pixelMap) Takes a screenshot of the entire screen. This function can be used only on tablets and 2-in-1 devices. It can be used to capture a full-screen screenshot on the specified display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayId (uint64_t *displayId) Obtains the ID of the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayWidth (int32_t *displayWidth) Obtains the width of the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayHeight (int32_t *displayHeight) Obtains the height of the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayRotation (NativeDisplayManager_Rotation *displayRotation) Obtains the clockwise rotation angle of the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayOrientation (NativeDisplayManager_Orientation *displayOrientation) Obtains the orientation of the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayVirtualPixelRatio (float *virtualPixels) Obtains the virtual pixel ratio of the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayRefreshRate (uint32_t *refreshRate) Obtains the refresh rate of the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityDpi (int32_t *densityDpi) Obtains the physical pixel density of the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityPixels (float *densityPixels) Obtains the logical pixel density of the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayScaledDensity (float *scaledDensity) Obtains the scale factor of fonts displayed on the default display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityXdpi (float *xDpi) Obtains the number of physical pixels per inch on the default display in the X dimension.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityYdpi (float *yDpi) Obtains the number of physical pixels per inch on the default display in the Y dimension.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDefaultDisplayCutoutInfo (NativeDisplayManager_CutoutInfo **cutoutInfo) Obtains the unusable area of the default display, including punch hole, notch, and curved area of a waterfall display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_DestroyDefaultDisplayCutoutInfo (NativeDisplayManager_CutoutInfo *cutoutInfo) Destroys the unusable area of the default display, including punch hole, notch, and curved area of a waterfall display.
bool OH_NativeDisplayManager_IsFoldable () Checks whether the current device is foldable.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetFoldDisplayMode (NativeDisplayManager_FoldDisplayMode *displayMode) Obtains the display mode of the foldable device.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterDisplayChangeListener (OH_NativeDisplayManager_DisplayChangeCallback displayChangeCallback, uint32_t *listenerIndex) Registers a listener for status changes (such as rotation, refresh rate, DPI, and resolution changes) of the display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterDisplayChangeListener (uint32_t listenerIndex) Cancels the listening for status changes of the display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterFoldDisplayModeChangeListener (OH_NativeDisplayManager_FoldDisplayModeChangeCallback displayModeChangeCallback, uint32_t *listenerIndex) Registers a listener for folded/unfolded state changes of the display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterFoldDisplayModeChangeListener (uint32_t listenerIndex) Cancels the listening for folded/unfolded state changes of the display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateAllDisplays (NativeDisplayManager_DisplaysInfo **allDisplays) Obtains the object that contains the information about all displays.
void OH_NativeDisplayManager_DestroyAllDisplays (NativeDisplayManager_DisplaysInfo *allDisplays) Destroys the object that contains the information about all displays.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDisplayById (uint32_t displayId, NativeDisplayManager_DisplayInfo **displayInfo) Obtains the object that contains the information about a display.
void OH_NativeDisplayManager_DestroyDisplay (NativeDisplayManager_DisplayInfo *displayInfo) Destroys the object that contains the information about a display.
NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreatePrimaryDisplay (NativeDisplayManager_DisplayInfo **displayInfo) Obtains the object that contains the information about the primary display. For devices other than 2-in-1 devices, the displayInfo object obtained contains information about the built-in screen. For 2-in-1 devices with an external screen, the displayInfo object obtained contains information about the current primary screen. For 2-in-1 devices without an external screen, the displayInfo object obtained contains information about the built-in screen.

Type Description

NativeDisplayManager_DisplayColorSpace

typedef struct NativeDisplayManager_DisplayColorSpace NativeDisplayManager_DisplayColorSpace

Description

Defines a struct for all the color spaces supported by a display.

Since: 14

NativeDisplayManager_DisplayHdrFormat

typedef struct NativeDisplayManager_DisplayHdrFormat NativeDisplayManager_DisplayHdrFormat

Description

Defines a struct for all the HDR formats supported by a display.

Since: 14

NativeDisplayManager_DisplayInfo

typedef struct NativeDisplayManager_DisplayInfo NativeDisplayManager_DisplayInfo

Description

Defines a struct that encapsulates the information about a display.

Since: 14

NativeDisplayManager_DisplaysInfo

typedef struct NativeDisplayManager_DisplaysInfo NativeDisplayManager_DisplaysInfo

Description

Defines a struct that encapsulates the information about displays of a device with multiple screens.

Since: 14

NativeDisplayManager_DisplayState

typedef enum NativeDisplayManager_DisplayState NativeDisplayManager_DisplayState

Description

Defines an enum for the states of a display.

Since: 14

NativeDisplayManager_CutoutInfo

typedef struct NativeDisplayManager_CutoutInfo NativeDisplayManager_CutoutInfo

Description

Defines a struct for the unusable area of a display, including punch hole, notch, and curved area of a waterfall display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

NativeDisplayManager_ErrorCode

typedef enum NativeDisplayManager_ErrorCode NativeDisplayManager_ErrorCode

Description

Defines an enum for the status codes returned by the display manager interface.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

NativeDisplayManager_FoldDisplayMode

typedef enum NativeDisplayManager_FoldDisplayMode NativeDisplayManager_FoldDisplayMode

Description

Defines an enum for the display modes of a foldable device.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

NativeDisplayManager_Orientation

typedef enum NativeDisplayManager_Orientation NativeDisplayManager_Orientation

Description

Defines an enum for the orientations of a display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

NativeDisplayManager_Rect

typedef struct NativeDisplayManager_Rect NativeDisplayManager_Rect

Description

Defines a struct for a rectangle.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

NativeDisplayManager_Rotation

typedef enum NativeDisplayManager_Rotation NativeDisplayManager_Rotation

Description

Defines an enum for the clockwise rotation angles of a display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

NativeDisplayManager_WaterfallDisplayAreaRects

typedef struct NativeDisplayManager_WaterfallDisplayAreaRects NativeDisplayManager_WaterfallDisplayAreaRects

Description

Defines a struct for the curved area on a waterfall display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

OH_NativeDisplayManager_DisplayChangeCallback

typedef void(* OH_NativeDisplayManager_DisplayChangeCallback) (uint64_t displayId)

Description

Defines a callback function to listen for status changes of a display.

System capability: SystemCapability.Window.SessionManager

Since: 12

Parameters

Name Description
displayId ID of the display.

OH_NativeDisplayManager_FoldDisplayModeChangeCallback

typedef void(* OH_NativeDisplayManager_FoldDisplayModeChangeCallback) (NativeDisplayManager_FoldDisplayMode displayMode)

Description

Defines a callback function to listen for folded/unfolded state changes of a display.

System capability: SystemCapability.Window.SessionManager

Since: 12

Parameters

Name Description
displayMode Folded or unfolded state of the display. For details about the available options, see NativeDisplayManager_FoldDisplayMode.

Enum Description

NativeDisplayManager_DisplayState

enum NativeDisplayManager_DisplayState

Description

Enumerates the states of a display.

Since: 14

Value Description
DISPLAY_MANAGER_DISPLAY_STATE_UNKNOWN Unknown.
DISPLAY_MANAGER_DISPLAY_STATE_OFF The display is shut down.
DISPLAY_MANAGER_DISPLAY_STATE_ON The display is powered on.
DISPLAY_MANAGER_DISPLAY_STATE_DOZE The display is in sleep mode.
DISPLAY_MANAGER_DISPLAY_STATE_DOZE_SUSPEND The display is in sleep mode, and the CPU is suspended.
DISPLAY_MANAGER_DISPLAY_STATE_VR The display is in VR mode.
DISPLAY_MANAGER_DISPLAY_STATE_ON_SUSPEND The display is powered on, and the CPU is suspended.

NativeDisplayManager_ErrorCode

enum NativeDisplayManager_ErrorCode

Description

Enumerates the status codes returned by the display manager interface.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Value Description
DISPLAY_MANAGER_OK The operation is successful.
DISPLAY_MANAGER_ERROR_NO_PERMISSION Permission verification failed. The application does not have the permission to use the API.
DISPLAY_MANAGER_ERROR_NOT_SYSTEM_APP Permission verification failed. A non-system application attempts to call a system API.
DISPLAY_MANAGER_ERROR_INVALID_PARAM Parameter check fails.
DISPLAY_MANAGER_ERROR_DEVICE_NOT_SUPPORTED The device does not support the API.
DISPLAY_MANAGER_ERROR_INVALID_SCREEN The display is invalid.
DISPLAY_MANAGER_ERROR_INVALID_CALL The current operation object does not have the operation permission.
DISPLAY_MANAGER_ERROR_SYSTEM_ABNORMAL The system service is abnormal.

NativeDisplayManager_FoldDisplayMode

enum NativeDisplayManager_FoldDisplayMode

Description

Enumerates the display modes of a foldable device.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Value Description
DISPLAY_MANAGER_FOLD_DISPLAY_MODE_UNKNOWN The display mode of the device is unknown.
DISPLAY_MANAGER_FOLD_DISPLAY_MODE_FULL The device is displayed in full screen.
DISPLAY_MANAGER_FOLD_DISPLAY_MODE_MAIN The main screen of the device is displayed.
DISPLAY_MANAGER_FOLD_DISPLAY_MODE_SUB The subscreen of the device is displayed.
DISPLAY_MANAGER_FOLD_DISPLAY_MODE_COORDINATION Both screens of the device are displayed in collaborative mode.

NativeDisplayManager_Orientation

enum NativeDisplayManager_Orientation

Description

Enumerates the orientations of a display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Value Description
DISPLAY_MANAGER_PORTRAIT The display is in portrait mode.
DISPLAY_MANAGER_LANDSCAPE The display is in landscape mode.
DISPLAY_MANAGER_PORTRAIT_INVERTED The display is in reverse portrait mode.
DISPLAY_MANAGER_LANDSCAPE_INVERTED The display is in reverse landscape mode.
DISPLAY_MANAGER_UNKNOWN The screen orientation is unknown.

NativeDisplayManager_Rotation

enum NativeDisplayManager_Rotation

Description

Enumerates the clockwise rotation angles of a display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Value Description
DISPLAY_MANAGER_ROTATION_0 The display is rotated clockwise by 0 degrees.
DISPLAY_MANAGER_ROTATION_90 The display is rotated clockwise by 90 degrees.
DISPLAY_MANAGER_ROTATION_180 The display is rotated clockwise by 180 degrees.
DISPLAY_MANAGER_ROTATION_270 The display is rotated clockwise by 270 degrees.

Function Description

OH_NativeDisplayManager_CaptureScreenPixelmap()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CaptureScreenPixelmap (uint32_t displayId, OH_PixelmapNative **pixelMap )

Description

Takes a screenshot of the entire screen. This function can be used only on tablets and 2-in-1 devices. It can be used to capture a full-screen screenshot on the specified display.

Required permissions

ohos.permission.CUSTOM_SCREEN_CAPTURE

System capability: SystemCapability.Window.SessionManager.Core

Since: 14

Parameters

Name Description
displayId ID of the display. The value must be a non-negative integer.
pixelMap Double pointer to an OH_PixelmapNative object, which is the screenshot taken.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_CreateAllDisplays()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateAllDisplays (NativeDisplayManager_DisplaysInfo **allDisplays)

Description

Obtains the object that contains the information about all displays.

System capability: SystemCapability.Window.SessionManager.Core

Since: 14

Parameters

Name Description
allDisplays Double pointer to the display information, which is encapsulated in NativeDisplayManager_DisplaysInfo.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_CreateDisplayById()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDisplayById (uint32_t displayId, NativeDisplayManager_DisplayInfo **displayInfo )

Description

Obtains the object that contains the information about a display.

System capability: SystemCapability.Window.SessionManager.Core

Since: 14

Parameters

Name Description
displayId ID of the display. The value must be a non-negative integer.
displayInfo Double pointer to the display information, which is encapsulated in NativeDisplayManager_DisplayInfo.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_CreatePrimaryDisplay()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreatePrimaryDisplay (NativeDisplayManager_DisplayInfo **displayInfo)

Description

Obtains the object that contains the information about the primary display. For devices other than 2-in-1 devices, the displayInfo object obtained contains information about the built-in screen. For 2-in-1 devices with an external screen, the displayInfo object obtained contains information about the current primary screen. For 2-in-1 devices without an external screen, the displayInfo object obtained contains information about the built-in screen.

System capability: SystemCapability.Window.SessionManager.Core

Since: 14

Parameters

Name Description
displayInfo Double pointer to the display information, which is encapsulated in NativeDisplayManager_DisplayInfo.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_DestroyAllDisplays()

void OH_NativeDisplayManager_DestroyAllDisplays (NativeDisplayManager_DisplaysInfo *allDisplays)

Description

Destroys the object that contains the information about all displays.

System capability: SystemCapability.Window.SessionManager.Core

Since: 14

Parameters

Name Description
allDisplays Pointer to the display information object, which is obtained by calling OH_NativeDisplayManager_CreateAllDisplays. For details, see NativeDisplayManager_DisplaysInfo.

OH_NativeDisplayManager_DestroyDisplay()

void OH_NativeDisplayManager_DestroyDisplay (NativeDisplayManager_DisplayInfo *displayInfo)

Description

Destroys the object that contains the information about a display.

System capability: SystemCapability.Window.SessionManager.Core

Since: 14

Parameters

Name Description
displayInfo Pointer to the display information object, which is obtained by calling OH_NativeDisplayManager_CreateDisplayById or OH_NativeDisplayManager_CreatePrimaryDisplay. For details, see NativeDisplayManager_DisplayInfo.

OH_NativeDisplayManager_CreateDefaultDisplayCutoutInfo()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDefaultDisplayCutoutInfo (NativeDisplayManager_CutoutInfo **cutoutInfo)

Description

Obtains the unusable area of the default display, including punch hole, notch, and curved area of a waterfall display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

Name Description
cutoutInfo Double pointer to the unusable area information, which is encapsulated in NativeDisplayManager_CutoutInfo.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_DestroyDefaultDisplayCutoutInfo()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_DestroyDefaultDisplayCutoutInfo (NativeDisplayManager_CutoutInfo *cutoutInfo)

Description

Destroys the unusable area of the default display, including punch hole, notch, and curved area of a waterfall display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

Name Description
cutoutInfo Pointer to the unusable area information object, which is obtained by calling OH_NativeDisplayManager_CreateDefaultDisplayCutoutInfo. For details, see NativeDisplayManager_CutoutInfo.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayDensityDpi()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityDpi (int32_t *densityDpi)

Description

Obtains the physical pixel density of the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

Name Description
densityDpi Pointer to the physical pixel density, that is, the number of pixels per inch. The value is an integer, in px. The actual value depends on the options provided in device settings.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayDensityPixels()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityPixels (float *densityPixels)

Description

Obtains the logical pixel density of the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

Name Description
densityPixels Pointer to the logical pixel density, which indicates the scaling coefficient of the physical pixels and logical pixels. The value is a floating point number in the range [0.5, 4.0]. Generally, the value is 1.0 or 3.0. The actual value depends on the density DPI provided by the device in use.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayDensityXdpi()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityXdpi (float *xDpi)

Description

Obtains the number of physical pixels per inch on the default display in the X dimension.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

Name Description
xDpi Pointer to the number of physical pixels per inch in the X dimension. The value is a floating point number.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayDensityYdpi()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityYdpi (float *yDpi)

Description

Obtains the number of physical pixels per inch on the default display in the Y dimension.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

Name Description
yDpi Pointer to the number of physical pixels per inch in the Y dimension. The value is a floating point number.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayHeight()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayHeight (int32_t *displayHeight)

Description

Obtains the height of the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

Name Description
displayHeight Pointer to the height, in px. The value is an integer.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayId()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayId (uint64_t *displayId)

Description

Obtains the ID of the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

Name Description
displayId Pointer to the display ID. The value is a non-negative integer.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayOrientation()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayOrientation (NativeDisplayManager_Orientation *displayOrientation)

Description

Obtains the orientation of the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

Name Description
displayOrientation Pointer to the orientation. For details about the available options, see NativeDisplayManager_Orientation.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayRefreshRate()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayRefreshRate (uint32_t *refreshRate)

Description

Obtains the refresh rate of the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

Name Description
refreshRate Pointer to the refresh rate. The value is an integer, in Hz.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayRotation()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayRotation (NativeDisplayManager_Rotation *displayRotation)

Description

Obtains the clockwise rotation angle of the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

Name Description
displayRotation Pointer to the clockwise rotation angle. For details about the available options, see NativeDisplayManager_Rotation.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayScaledDensity()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayScaledDensity (float *scaledDensity)

Description

Obtains the scale factor of fonts displayed on the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

Name Description
scaledDensity Pointer to the scale factor. The value is a floating-point number, and it is usually the same as that of densityPixels.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayVirtualPixelRatio()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayVirtualPixelRatio (float *virtualPixels)

Description

Obtains the virtual pixel ratio of the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

Name Description
virtualPixels Pointer to the virtual pixel ratio. The value is a floating-point number, and it is usually the same as that of densityPixels.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetDefaultDisplayWidth()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayWidth (int32_t *displayWidth)

Description

Obtains the width of the default display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

Name Description
displayWidth Pointer to the width, in px. The value is an integer.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_GetFoldDisplayMode()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetFoldDisplayMode (NativeDisplayManager_FoldDisplayMode *displayMode)

Description

Obtains the display mode of the foldable device.

System capability: SystemCapability.Window.SessionManager

Since: 12

Parameters

Name Description
displayMode Pointer to the display mode. For details about the available options, see NativeDisplayManager_FoldDisplayMode.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_IsFoldable()

bool OH_NativeDisplayManager_IsFoldable ()

Description

Checks whether the current device is foldable.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Returns

Returns the check result. The value true means that the device is foldable, and false means the opposite.

OH_NativeDisplayManager_RegisterDisplayChangeListener()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterDisplayChangeListener (OH_NativeDisplayManager_DisplayChangeCallback displayChangeCallback, uint32_t *listenerIndex )

Description

Registers a listener for status changes (such as rotation, refresh rate, DPI, and resolution changes) of the display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

Name Description
displayChangeCallback Callback function triggered when the display status is changed. For details, see OH_NativeDisplayManager_DisplayChangeCallback.
listenerIndex Pointer to the index of the listener registered. It can be used as an input parameter of OH_NativeDisplayManager_UnregisterDisplayChangeListener.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_RegisterFoldDisplayModeChangeListener()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterFoldDisplayModeChangeListener (OH_NativeDisplayManager_FoldDisplayModeChangeCallback displayModeChangeCallback, uint32_t *listenerIndex )

Description

Registers a listener for folded/unfolded state changes of the display.

System capability: SystemCapability.Window.SessionManager

Since: 12

Parameters

Name Description
displayModeChangeCallback Callback function triggered when the folded/unfolded state of the display is changed. For details, see OH_NativeDisplayManager_FoldDisplayModeChangeCallback.
listenerIndex Pointer to the index of the listener registered. It can be used as an input parameter of OH_NativeDisplayManager_UnregisterFoldDisplayModeChangeListener.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_UnregisterDisplayChangeListener()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterDisplayChangeListener (uint32_t listenerIndex)

Description

Cancels the listening for status changes of the display.

System capability: SystemCapability.WindowManager.WindowManager.Core

Since: 12

Parameters

Name Description
listenerIndex Index of the listener returned when OH_NativeDisplayManager_RegisterDisplayChangeListener is called.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.

OH_NativeDisplayManager_UnregisterFoldDisplayModeChangeListener()

NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnregisterFoldDisplayModeChangeListener (uint32_t listenerIndex)

Description

Cancels the listening for folded/unfolded state changes of the display.

System capability: SystemCapability.Window.SessionManager

Since: 12

Parameters

Name Description
listenerIndex Index of the listener returned when OH_NativeDisplayManager_RegisterFoldDisplayModeChangeListener is called.

Returns

Returns a status code defined in NativeDisplayManager_ErrorCode.