From 53b12bf277248d845ec9b3d05a6cf72b1bfbdcff Mon Sep 17 00:00:00 2001 From: lanhaoyu Date: Thu, 8 May 2025 20:13:55 +0800 Subject: [PATCH 1/2] add interface Signed-off-by: lanhaoyu --- .../bundle/include/native_interface_bundle.h | 103 ++++++++++++++++++ .../bundle/libbundle.ndk.json | 8 ++ 2 files changed, 111 insertions(+) diff --git a/bundlemanager/bundle_framework/bundle/include/native_interface_bundle.h b/bundlemanager/bundle_framework/bundle/include/native_interface_bundle.h index 04bb5d331..e82033fb4 100644 --- a/bundlemanager/bundle_framework/bundle/include/native_interface_bundle.h +++ b/bundlemanager/bundle_framework/bundle/include/native_interface_bundle.h @@ -37,6 +37,9 @@ #ifndef FOUNDATION_APPEXECFWK_STANDARD_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_NATIVE_INTERFACE_BUNDLE_H #define FOUNDATION_APPEXECFWK_STANDARD_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_NATIVE_INTERFACE_BUNDLE_H +#include +#include + #ifdef __cplusplus extern "C" { #endif @@ -76,6 +79,74 @@ struct OH_NativeBundle_ElementName { char* abilityName; }; +/** + * @brief Indicates information of metadata + * + * @atomicservice + * @since 20 + */ +struct OH_NativeBundle_Metadata { + /** + * @brief Indicates the metadata name + * + * @atomicservice + * @since 20 + */ + char* name; + /** + * @brief Indicates the metadata value + * + * @atomicservice + * @since 20 + */ + char* value; + /** + * @brief Indicates the metadata resource + * + * @atomicservice + * @since 20 + */ + char* resource; +}; + +/** + * @brief Indicates information of metadata + * + * @atomicservice + * @since 20 + */ +typedef struct OH_NativeBundle_Metadata OH_NativeBundle_Metadata; + +/** + * @brief Indicates information of module metadata + * + * @atomicservice + * @since 20 + */ +struct OH_NativeBundle_ModuleMetadata { + /** + * @brief Indicates the moduleName of module + * + * @atomicservice + * @since 20 + */ + char* moduleName; + /** + * @brief Indicates the metadata array of module + * + * @atomicservice + * @since 20 + */ + OH_NativeBundle_Metadata* metadataArray; + /** + * @brief Indicates the metadata array size of module + * + * @atomicservice + * @since 20 + */ + size_t metadataArraySize; +}; + /** * @brief Indicates information of application * @@ -92,6 +163,14 @@ typedef struct OH_NativeBundle_ApplicationInfo OH_NativeBundle_ApplicationInfo; */ typedef struct OH_NativeBundle_ElementName OH_NativeBundle_ElementName; +/** + * @brief Indicates information of module metadata + * + * @atomicservice + * @since 20 + */ +typedef struct OH_NativeBundle_ModuleMetadata OH_NativeBundle_ModuleMetadata; + /** * @brief Obtains the application info based on the The current bundle. * @@ -159,6 +238,30 @@ OH_NativeBundle_ElementName OH_NativeBundle_GetMainElementName(); * @version 1.0 */ char* OH_NativeBundle_GetCompatibleDeviceType(); + +/** + * @brief Obtains the application debug mode. + * + * @param isDebugMode Indicates whether the application is in debug mode. + * @return Returns true if call successful, false otherwise. + * @atomicservice + * @since 20 + */ +bool OH_NativeBundle_IsDebugMode(bool* isDebugMode); + +/** + * @brief Obtains the module metadata array of the current application. + * After utilizing this interface, to prevent memory leaks, + * it is necessary to manually release the pointer returned by the interface. + * + * @param size Indicates the module metadata array size. + * @return Returns the newly created module metadata array, if the returned object is NULL, + * it indicates creation failure. The possible cause of failure could be that the application address space is full, + * leading to space allocation failure. + * @atomicservice + * @since 20 + */ +OH_NativeBundle_ModuleMetadata* OH_NativeBundle_GetModuleMetadata(size_t* size); #ifdef __cplusplus }; #endif diff --git a/bundlemanager/bundle_framework/bundle/libbundle.ndk.json b/bundlemanager/bundle_framework/bundle/libbundle.ndk.json index f61863508..7c05eef7b 100644 --- a/bundlemanager/bundle_framework/bundle/libbundle.ndk.json +++ b/bundlemanager/bundle_framework/bundle/libbundle.ndk.json @@ -18,5 +18,13 @@ { "first_introduced": "14", "name": "OH_NativeBundle_GetCompatibleDeviceType" + }, + { + "first_introduced": "20", + "name": "OH_NativeBundle_IsDebugMode" + }, + { + "first_introduced": "20", + "name": "OH_NativeBundle_GetModuleMetadata" } ] -- Gitee From 446d91e1885535c2edbd9417bfea42299c70bcd7 Mon Sep 17 00:00:00 2001 From: lanhaoyu Date: Thu, 8 May 2025 20:19:06 +0800 Subject: [PATCH 2/2] fix interface Signed-off-by: lanhaoyu --- .../bundle/include/native_interface_bundle.h | 46 ++----------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/bundlemanager/bundle_framework/bundle/include/native_interface_bundle.h b/bundlemanager/bundle_framework/bundle/include/native_interface_bundle.h index e82033fb4..9ffbb73b9 100644 --- a/bundlemanager/bundle_framework/bundle/include/native_interface_bundle.h +++ b/bundlemanager/bundle_framework/bundle/include/native_interface_bundle.h @@ -82,70 +82,42 @@ struct OH_NativeBundle_ElementName { /** * @brief Indicates information of metadata * - * @atomicservice * @since 20 */ -struct OH_NativeBundle_Metadata { +typedef struct OH_NativeBundle_Metadata { /** * @brief Indicates the metadata name - * - * @atomicservice - * @since 20 */ char* name; /** * @brief Indicates the metadata value - * - * @atomicservice - * @since 20 */ char* value; /** * @brief Indicates the metadata resource - * - * @atomicservice - * @since 20 */ char* resource; -}; - -/** - * @brief Indicates information of metadata - * - * @atomicservice - * @since 20 - */ -typedef struct OH_NativeBundle_Metadata OH_NativeBundle_Metadata; +} OH_NativeBundle_Metadata; /** * @brief Indicates information of module metadata * - * @atomicservice * @since 20 */ -struct OH_NativeBundle_ModuleMetadata { +typedef struct OH_NativeBundle_ModuleMetadata { /** * @brief Indicates the moduleName of module - * - * @atomicservice - * @since 20 */ char* moduleName; /** * @brief Indicates the metadata array of module - * - * @atomicservice - * @since 20 */ OH_NativeBundle_Metadata* metadataArray; /** * @brief Indicates the metadata array size of module - * - * @atomicservice - * @since 20 */ size_t metadataArraySize; -}; +} OH_NativeBundle_ModuleMetadata; /** * @brief Indicates information of application @@ -163,14 +135,6 @@ typedef struct OH_NativeBundle_ApplicationInfo OH_NativeBundle_ApplicationInfo; */ typedef struct OH_NativeBundle_ElementName OH_NativeBundle_ElementName; -/** - * @brief Indicates information of module metadata - * - * @atomicservice - * @since 20 - */ -typedef struct OH_NativeBundle_ModuleMetadata OH_NativeBundle_ModuleMetadata; - /** * @brief Obtains the application info based on the The current bundle. * @@ -244,7 +208,6 @@ char* OH_NativeBundle_GetCompatibleDeviceType(); * * @param isDebugMode Indicates whether the application is in debug mode. * @return Returns true if call successful, false otherwise. - * @atomicservice * @since 20 */ bool OH_NativeBundle_IsDebugMode(bool* isDebugMode); @@ -258,7 +221,6 @@ bool OH_NativeBundle_IsDebugMode(bool* isDebugMode); * @return Returns the newly created module metadata array, if the returned object is NULL, * it indicates creation failure. The possible cause of failure could be that the application address space is full, * leading to space allocation failure. - * @atomicservice * @since 20 */ OH_NativeBundle_ModuleMetadata* OH_NativeBundle_GetModuleMetadata(size_t* size); -- Gitee