From 9b56e97b0c65991cc6500d4d603b59bae0bf1c40 Mon Sep 17 00:00:00 2001 From: huangji731 Date: Wed, 21 Aug 2024 19:52:53 +0800 Subject: [PATCH] https://gitee.com/openharmony/window_window_manager/issues/IALLDV Signed-off-by: huangji731 --- arkui/display_manager/BUILD.gn | 35 +++ arkui/display_manager/libdm.ndk.json | 82 +++++ arkui/display_manager/oh_display_info.h | 159 ++++++++++ arkui/display_manager/oh_display_manager.h | 337 +++++++++++++++++++++ 4 files changed, 613 insertions(+) create mode 100644 arkui/display_manager/BUILD.gn create mode 100644 arkui/display_manager/libdm.ndk.json create mode 100644 arkui/display_manager/oh_display_info.h create mode 100644 arkui/display_manager/oh_display_manager.h diff --git a/arkui/display_manager/BUILD.gn b/arkui/display_manager/BUILD.gn new file mode 100644 index 000000000..bfdc284ac --- /dev/null +++ b/arkui/display_manager/BUILD.gn @@ -0,0 +1,35 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("display_manager_header") { + dest_dir = "$ndk_headers_out_dir/window_manager" + sources = [ + "oh_display_info.h", + "oh_display_manager.h", + ] +} + +ohos_ndk_library("native_display_manager") { + output_name = "native_display_manager" + output_extension = "so" + ndk_description_file = "./libdm.ndk.json" + system_capability = "SystemCapability.Window.SessionManager" + system_capability_headers = [ + "oh_display_info.h", + "oh_display_manager.h", + ] + min_compact_version = "12" +} diff --git a/arkui/display_manager/libdm.ndk.json b/arkui/display_manager/libdm.ndk.json new file mode 100644 index 000000000..0d640ee16 --- /dev/null +++ b/arkui/display_manager/libdm.ndk.json @@ -0,0 +1,82 @@ +[ + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayId" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayWidth" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayHeight" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayRotation" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayOrientation" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayVirtualPixelRatio" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayRefreshRate" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayDensityDPI" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayDensityPixels" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayScaledDensity" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayDensityXDPI" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetDefaultDisplayDensityYDPI" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_CreateDefaultDisplayCutoutInfo" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_DestroyDefaultDisplayCutoutInfo" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_IsFoldable" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_GetFoldDisplayMode" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_RegisterFoldDisplayModeChangeListener" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_UnRegisterFoldDisplayModeChangeListener" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_RegisterDisplayChangeListener" + }, + { + "first_instroduced":"12", + "name":"OH_NativeDisplayManager_UnRegisterDisplayChangeListener" + } +] \ No newline at end of file diff --git a/arkui/display_manager/oh_display_info.h b/arkui/display_manager/oh_display_info.h new file mode 100644 index 000000000..884b1ff25 --- /dev/null +++ b/arkui/display_manager/oh_display_info.h @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OH_NATIVE_DISPLAY_INFO_H +#define OH_NATIVE_DISPLAY_INFO_H + +/** + * @addtogroup OH_DisplayInfo + * @{ + * + * @brief Defines the data structures for the C APIs of the display module. + * + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + * @version 1.0 + */ + +/** + * @file oh_display_info.h + * + * @brief Defines the data structures for the C APIs of the display module. + * + * @kit ArkUI + * @library libnative_display_manager.so + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + * @version 1.0 + */ + +#include "stdint.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates rotations. + * + * @since 12 + * @version 1.0 + */ +typedef enum { + DISPLAY_MANAGER_ROTATION_0, + DISPLAY_MANAGER_ROTATION_90, + DISPLAY_MANAGER_ROTATION_180, + DISPLAY_MANAGER_ROTATION_270, +} NativeDisplayManager_Rotation; + +/** + * @brief Enumerates orientations. + * + * @since 12 + * @version 1.0 + */ +typedef enum { + DISPLAY_MANAGER_PORTRAIT = 0, + DISPLAY_MANAGER_LANDSCAPE = 1, + DISPLAY_MANAGER_PORTRAIT_INVERTED = 2, + DISPLAY_MANAGER_LANDSCAPE_INVERTED = 3, + DISPLAY_MANAGER_UNKNOWN, +} NativeDisplayManager_Orientation; + +/** + * @brief Enumerates the result types of the display manager interface. + * + * @since 12 + * @version 1.0 + */ +typedef enum { + 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_SUPPORT = 801, + DISPLAY_MANAGER_ERROR_INVALID_SCREEN = 1400001, + DISPLAY_MANAGER_ERROR_INVALID_CALLING = 1400002, + DISPLAY_MANAGER_ERROR_SYSTEM_INNORMAL = 1400003, +} NativeDisplayManager_ErrorCode; + +/** + * @brief Enumerates the fold display mode. + * + * @since 12 + * @version 1.0 + */ +typedef enum { + 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, +} NativeDisplayManager_FoldDisplayMode; + +/** + * @brief Defines the display rect data structure. + * + * @since 12 + * @version 1.0 + */ +typedef struct { + /* rect left */ + int32_t left; + /* rect top */ + int32_t top; + /* rect width */ + uint32_t width; + /* rect height */ + uint32_t height; +} NativeDisplayManager_Rect; + +/** + * @brief Defines the display waterfallDisplayAreaRects data structure. + * + * @since 12 + * @version 1.0 + */ +typedef struct { + /* waterfall left rect */ + NativeDisplayManager_Rect left; + /* waterfall top rect */ + NativeDisplayManager_Rect top; + /* waterfall right rect */ + NativeDisplayManager_Rect right; + /* waterfall bottom rect */ + NativeDisplayManager_Rect bottom; +} NativeDisplayManager_WaterfallDisplayAreaRects; + +/** + * @brief Defines the display cutout info data structure. + * + * @since 12 + * @version 1.0 + */ +typedef struct { + /* boundingRects length */ + int32_t boundingRectsLength; + /* boundingRects info pointer */ + NativeDisplayManager_Rect *boundingRects; + /* waterfallDisplayAreaRects info */ + NativeDisplayManager_WaterfallDisplayAreaRects waterfallDisplayAreaRects; +} NativeDisplayManager_CutoutInfo; + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif // OH_NATIVE_DISPLAY_INFO_H \ No newline at end of file diff --git a/arkui/display_manager/oh_display_manager.h b/arkui/display_manager/oh_display_manager.h new file mode 100644 index 000000000..32610daf2 --- /dev/null +++ b/arkui/display_manager/oh_display_manager.h @@ -0,0 +1,337 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OH_NATIVE_DISPLAY_MANAGER_H +#define OH_NATIVE_DISPLAY_MANAGER_H + +/** + * @addtogroup OH_DisplayManager + * @{ + * + * @brief Defines the data structures for the C APIs of the display module. + * + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + * @version 1.0 + */ + +/** + * @file oh_display_manager.h + * + * @brief Defines the data structures for the C APIs of the display module. + * + * @kit ArkUI + * @library libnative_display_manager.so. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + * @version 1.0 + */ + +#include "oh_display_info.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Obtain the default display Id. + * + * @param { *displayId } Indicates the pointer to an uint64_t object. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 140003 - this display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayId(uint64_t *displayId); + +/** + * @brief Obtain the default display width. + * + * @param { *displayWidth } Indicates the pointer to an int32_t object. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 140003 - this display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayWidth(int32_t *displayWidth); + +/** + * @brief Obtain the default display height. + * + * @param { *displayHeight } Indicates the pointer to an int32_t object. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 140003 - this display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayHeight(int32_t *displayHeight); + +/** + * @brief Obtain the default display rotation. + * + * @param { *displayRotation } Indicates the pointer to an NativeDisplayManager_Rotation object. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 140003 - this display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayRotation( + NativeDisplayManager_Rotation *displayRotation); + +/** + * @brief Obtain the default display orientation. + * + * @param { *displayOrientation } Indicates the pointer to an NativeDisplayManager_Orientation object. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 140003 - this display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayOrientation( + NativeDisplayManager_Orientation *displayOrientation); + +/** + * @brief Obtain the default display virtualPixels. + * + * @param { *virtualPixels } Indicates the pointer to an float object. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 140003 - this display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayVirtualPixelRatio(float *virtualPixels); + +/** + * @brief Obtain the default display refreshRate. + * + * @param { *refreshRate } Indicates the pointer to an uint32_t object. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 140003 - this display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayRefreshRate(uint32_t *refreshRate); + +/** + * @brief Obtain the default display densityDPI. + * + * @param { *densityDPI } Indicates the pointer to an int32_t object. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 140003 - this display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityDPI(int32_t *densityDPI); + +/** + * @brief Obtain the default display densityPixels. + * + * @param { *densityPixels } Indicates the pointer to an float object. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 140003 - this display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityPixels(float *densityPixels); + +/** + * @brief Obtain the default display scaledDensity. + * + * @param { *scaledDensity } Indicates the pointer to an float object. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 140003 - this display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayScaledDensity(float *scaledDensity); + +/** + * @brief Obtain the default display xDPI. + * + * @param { *xDPI } Indicates the pointer to an float object. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 140003 - this display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityXDPI(float *xDPI); + +/** + * @brief Obtain the default display yDPI. + * + * @param { *yDPI } Indicates the pointer to an float object. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 140003 - this display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetDefaultDisplayDensityYDPI(float *yDPI); + +/** + * @brief Create the cutout info of the device. + * + * @param { **cutoutInfo } Indicates the pointer to an NativeDisplayManager_CutoutInfo object. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 140003 - this display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_CreateDefaultDisplayCutoutInfo( + NativeDisplayManager_CutoutInfo **cutoutInfo); + +/** + * @brief Destroy an NativeDisplayManager_CutoutInfo object and reclaims the memory occupied by the object. + * + * @param { **cutoutInfo } Indicates the pointer to an NativeDisplayManager_CutoutInfo object. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_DestroyDefaultDisplayCutoutInfo( + NativeDisplayManager_CutoutInfo *cutoutInfo); + +/** + * @brief Check whether the device is foldable. + * + * @return { bool } true means the device is foldable. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +bool OH_NativeDisplayManager_IsFoldable(); + +/** + * @brief Get the display mode of the foldable device. + * + * @param { *displayMode } Indicates the pointer to an NativeDisplayManager_FoldDisplayMode object. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 801 - device not support. + * @syscap SystemCapability.Window.SessionManager + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_GetFoldDisplayMode( + NativeDisplayManager_FoldDisplayMode *displayMode); + +/** + * @brief the callback function type when display change. + * + * @param { *displayId } change display id. + * @syscap SystemCapability.Window.SessionManager + * @since 12 + */ +typedef void (*OH_NativeDisplayManager_DisplayChangeCallback)(uint64_t displayId); + +/** + * @brief Register the callback for display change listener. + * + * @param { displayChangeCallback } display change callback. + * @param { *listenerIndex } Indicates the pointer to an uint32_t object. used in unregister call. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 140003 - this display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterDisplayChangeListener( + OH_NativeDisplayManager_DisplayChangeCallback displayChangeCallback, uint32_t *listenerIndex); + +/** + * @brief Unregister the callback for display changes listener. + * + * @param { listenerIndex } display changed listener index. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 140003 - this display manager service works abnormally. + * @syscap SystemCapability.WindowManager.WindowManager.Core + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnRegisterDisplayChangeListener(uint32_t listenerIndex); + +/** + * @brief the callback function type when display fold change. + * + * @param { displayMode } current fold display mode. + * @syscap SystemCapability.Window.SessionManager + * @since 12 + */ +typedef void (*OH_NativeDisplayManager_FoldDisplayModeChangeCallback)( + NativeDisplayManager_FoldDisplayMode displayMode); + +/** + * @brief Register the callback for display mode change listener. + * + * @param { displayModeChangeCallback } display mode change callback. + * @param { *listenerIndex } Indicates the pointer to an uint32_t object. used in unregister call. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 801 - device not support. + * 140003 - this display manager service works abnormally. + * @syscap SystemCapability.Window.SessionManager + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_RegisterFoldDisplayModeChangeListener( + OH_NativeDisplayManager_FoldDisplayModeChangeCallback displayModeChangeCallback, uint32_t *listenerIndex); + +/** + * @brief Unregister the callback for display mode change listener. + * + * @param { listenerIndex } display mode change listener index. + * @return { NativeDisplayManager_ErrorCode } 401- Parameter error. + * Possible causes: 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 801 - device not support. + * 140003 - this display manager service works abnormally. + * @syscap SystemCapability.Window.SessionManager + * @since 12 + */ +NativeDisplayManager_ErrorCode OH_NativeDisplayManager_UnRegisterFoldDisplayModeChangeListener(uint32_t listenerIndex); + +#ifdef __cplusplus +} +#endif +/** @} */ +#endif // OH_NATIVE_DISPLAY_MANAGER_H -- Gitee