1 /* 2 * Copyright (c) 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 /** 17 * @addtogroup Native_Bundle 18 * @{ 19 * 20 * @brief Describes the Native Bundle. 21 * 22 * @since 9 23 * @version 1.0 24 */ 25 26 /** 27 * @file native_interface_bundle.h 28 * 29 * @brief Declares the <b>Bundle</b>-specific function, including function for obtaining application info. 30 * 31 * @kit AbilityKit 32 * @library libbundle_ndk.z.so 33 * @syscap SystemCapability.BundleManager.BundleFramework.Core 34 * @since 9 35 * @version 1.0 36 */ 37 #ifndef FOUNDATION_APPEXECFWK_STANDARD_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_NATIVE_INTERFACE_BUNDLE_H 38 #define FOUNDATION_APPEXECFWK_STANDARD_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_NATIVE_INTERFACE_BUNDLE_H 39 40 #include <stdbool.h> 41 #include <stddef.h> 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 /** 47 * @brief Indicates information of application 48 * 49 * @syscap SystemCapability.BundleManager.BundleFramework.Core 50 * @since 9 51 */ 52 struct OH_NativeBundle_ApplicationInfo { 53 /** 54 * Indicates the name of application 55 * @syscap SystemCapability.BundleManager.BundleFramework.Core 56 * @since 9 57 */ 58 char* bundleName; 59 60 /** 61 * Indicates the fingerprint of application 62 * @syscap SystemCapability.BundleManager.BundleFramework.Core 63 * @since 9 64 */ 65 char* fingerprint; 66 }; 67 68 /** 69 * @brief Indicates information of elementName. 70 * 71 * @since 13 72 */ 73 struct OH_NativeBundle_ElementName { 74 /** Indicates the name of application. */ 75 char* bundleName; 76 /** Indicates the name of module. */ 77 char* moduleName; 78 /** Indicates the name of ability. */ 79 char* abilityName; 80 }; 81 82 /** 83 * @brief Indicates information of metadata. 84 * 85 * @since 20 86 */ 87 typedef struct OH_NativeBundle_Metadata { 88 /** 89 * @brief Indicates the metadata name. 90 */ 91 char* name; 92 /** 93 * @brief Indicates the metadata value. 94 */ 95 char* value; 96 /** 97 * @brief Indicates the metadata resource. 98 */ 99 char* resource; 100 } OH_NativeBundle_Metadata; 101 102 /** 103 * @brief Indicates information of module metadata. 104 * 105 * @since 20 106 */ 107 typedef struct OH_NativeBundle_ModuleMetadata { 108 /** 109 * @brief Indicates the moduleName of module. 110 */ 111 char* moduleName; 112 /** 113 * @brief Indicates the metadata array of module. 114 */ 115 OH_NativeBundle_Metadata* metadataArray; 116 /** 117 * @brief Indicates the metadata array size of module. 118 */ 119 size_t metadataArraySize; 120 } OH_NativeBundle_ModuleMetadata; 121 122 /** 123 * @brief Indicates information of application 124 * 125 * @since 11 126 * @version 1.0 127 */ 128 typedef struct OH_NativeBundle_ApplicationInfo OH_NativeBundle_ApplicationInfo; 129 130 /** 131 * @brief Indicates information of elementName 132 * 133 * @since 13 134 * @version 1.0 135 */ 136 typedef struct OH_NativeBundle_ElementName OH_NativeBundle_ElementName; 137 138 /** 139 * @brief Obtains the application info based on the The current bundle. 140 * 141 * @return Returns the newly created OH_NativeBundle_ApplicationInfo object, if the returned object is NULL, 142 * it indicates creation failure. The possible cause of failure could be that the application address space is full, 143 * leading to space allocation failure. 144 * @since 9 145 * @version 1.0 146 */ 147 OH_NativeBundle_ApplicationInfo OH_NativeBundle_GetCurrentApplicationInfo(); 148 149 /** 150 * @brief Obtains the appId of application. AppId indicates the ID of the application to which this bundle belongs 151 * The application ID uniquely identifies an application. It is determined by the bundle name and signature. 152 * After utilizing this interface, to prevent memory leaks, 153 * it is necessary to manually release the pointer returned by the interface. 154 * 155 * @return Returns the newly created string that indicates appId information, 156 * if the returned object is NULL, it indicates creation failure. 157 * The possible cause of failure could be that the application address space is full, 158 * leading to space allocation failure. 159 * @since 11 160 * @version 1.0 161 */ 162 char* OH_NativeBundle_GetAppId(); 163 164 /** 165 * @brief Obtains the appIdentifier of application. AppIdentifier does not change along the application lifecycle, 166 * including version updates, certificate changes, public and private key changes, and application transfer. 167 * After utilizing this interface, to prevent memory leaks, 168 * it is necessary to manually release the pointer returned by the interface. 169 * 170 * @return Returns the newly created string that indicates app identifier information, 171 * if the returned object is NULL, it indicates creation failure. 172 * The possible cause of failure could be that the application address space is full, 173 * leading to space allocation failure. 174 * @since 11 175 * @version 1.0 176 */ 177 char* OH_NativeBundle_GetAppIdentifier(); 178 179 /** 180 * @brief Obtains information of the entry mainElement based on the current application, including bundle name, 181 * module name, and ability name. 182 * After utilizing this interface, to prevent memory leaks, 183 * it is necessary to manually release the pointer returned by the interface. 184 * 185 * @return Returns the newly created OH_NativeBundle_ElementName object, if the returned object is NULL, 186 * it indicates creation failure. The possible cause of failure could be that the application address space is full, 187 * leading to space allocation failure. 188 * @since 13 189 */ 190 OH_NativeBundle_ElementName OH_NativeBundle_GetMainElementName(); 191 192 /** 193 * @brief Obtains the compatible device type of the current application. 194 * After utilizing this interface, to prevent memory leaks, 195 * it is necessary to manually release the pointer returned by the interface. 196 * 197 * @return Returns the newly created string that indicates the compatible device type, 198 * if the returned object is NULL, it indicates creation failure. 199 * The possible cause of failure could be that the application address space is full, 200 * leading to space allocation failure. 201 * @since 14 202 * @version 1.0 203 */ 204 char* OH_NativeBundle_GetCompatibleDeviceType(); 205 206 /** 207 * @brief Obtains the application debug mode. 208 * 209 * @param isDebugMode Indicates whether the application is in debug mode. 210 * @return Returns true if call successful, false otherwise. 211 * @since 20 212 */ 213 bool OH_NativeBundle_IsDebugMode(bool* isDebugMode); 214 215 /** 216 * @brief Obtains the module metadata array of the current application. 217 * After utilizing this interface, to prevent memory leaks, 218 * it is necessary to manually release the pointer returned by the interface. 219 * 220 * @param size Indicates the module metadata array size. 221 * @return Returns the newly created module metadata array, if the returned object is NULL, 222 * it indicates creation failure. The possible cause of failure could be that the application address space is full, 223 * leading to space allocation failure. 224 * @since 20 225 */ 226 OH_NativeBundle_ModuleMetadata* OH_NativeBundle_GetModuleMetadata(size_t* size); 227 #ifdef __cplusplus 228 }; 229 #endif 230 /** @} */ 231 #endif // FOUNDATION_APPEXECFWK_STANDARD_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_NATIVE_INTERFACE_BUNDLE_H 232