• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# native_interface_bundle.h
2<!--Kit: Ability Kit-->
3<!--Subsystem: BundleManager-->
4<!--Owner: @wanghang904-->
5<!--Designer: @hanfeng6-->
6<!--Tester: @kongjing2-->
7<!--Adviser: @Brilliantry_Rui-->
8
9## Overview
10
11The module provides capabilities for querying the application's bundle information, such as the bundle name and fingerprint information.
12
13**File to include**: <bundle/native_interface_bundle.h>
14
15**Library**: libbundle_ndk.z.so
16
17**System capability**: SystemCapability.BundleManager.BundleFramework.Core
18
19**Since**: 9
20
21**Related module**: [Native_Bundle](capi-native-bundle.md)
22
23## Summary
24
25### Structs
26
27| Name| typedef Keyword| Description|
28| -- | -- | -- |
29| [OH_NativeBundle_ApplicationInfo](capi-native-bundle-oh-nativebundle-applicationinfo.md) | OH_NativeBundle_ApplicationInfo | Describes the application information, including the bundle name and fingerprint information.|
30| [OH_NativeBundle_ElementName](capi-native-bundle-oh-nativebundle-elementname.md) | OH_NativeBundle_ElementName | Describes the elementName information.|
31| [OH_NativeBundle_Metadata](capi-native-bundle-oh-nativebundle-metadata.md) | OH_NativeBundle_Metadata | Describes the metadata information.|
32| [OH_NativeBundle_ModuleMetadata](capi-native-bundle-oh-nativebundle-modulemetadata.md) | OH_NativeBundle_ModuleMetadata | Describes the metadata of a module.|
33
34### Functions
35
36| Name| Description|
37| -- | -- |
38| [OH_NativeBundle_ApplicationInfo OH_NativeBundle_GetCurrentApplicationInfo()](#oh_nativebundle_getcurrentapplicationinfo) | Obtains the current application information, including the bundle name and fingerprint information.|
39| [char* OH_NativeBundle_GetAppId()](#oh_nativebundle_getappid) | Obtains the appId of the current application. The appId is the unique identifier of an application and is determined by the bundle name and signature information of the application. After using this function, you must manually release the pointer returned to prevent memory leakage.|
40| [char* OH_NativeBundle_GetAppIdentifier()](#oh_nativebundle_getappidentifier)| Obtains the appIdentifier of the current application. The appIdentifier does not change throughout the application lifecycle, including version updates, certificate changes, public and private key changes, and application migration. After using this function, you must manually release the pointer returned to prevent memory leakage.|
41| [OH_NativeBundle_ElementName_OH_NativeBundle_GetMainElementName()](#oh_nativebundle_getmainelementname) | Obtains the mainElement information of the current application, including the bundle name, module name, and ability name. After using this function, you must manually release the pointer returned to prevent memory leakage.|
42| [char* OH_NativeBundle_GetCompatibleDeviceType()](#oh_nativebundle_getcompatibledevicetype) | Obtains the compatible device type of the current application. After using this function, you must manually release the pointer returned to prevent memory leakage.|
43| [bool OH_NativeBundle_IsDebugMode(bool* isDebugMode)](#oh_nativebundle_isdebugmode) | Checks whether the current application is in debug mode.|
44| [OH_NativeBundle_ModuleMetadata* OH_NativeBundle_GetModuleMetadata(size_t* size)](#oh_nativebundle_getmodulemetadata) | Obtains the module metadata array of the current application. After using this function, you must manually release the pointer returned to prevent memory leakage.|
45
46## Function Description
47
48### OH_NativeBundle_GetCurrentApplicationInfo()
49
50```
51OH_NativeBundle_ApplicationInfo OH_NativeBundle_GetCurrentApplicationInfo()
52```
53
54**Description**
55
56Obtains the current application information, including the bundle name and fingerprint information.
57
58**Since**: 9
59
60**Returns**
61
62| Type| Description|
63| -- | -- |
64| [OH_NativeBundle_ApplicationInfo](capi-native-bundle-oh-nativebundle-applicationinfo.md) | Pointer to the OH_NativeBundle_ApplicationInfo object. If the returned object is NULL, the creation fails.<br>The possible cause is that the application address space is full, causing space allocation to fail.|
65
66### OH_NativeBundle_GetAppId()
67
68```
69char* OH_NativeBundle_GetAppId()
70```
71
72**Description**
73
74Obtains the appId of the current application. The appId is the unique identifier of an application and is determined by the bundle name and signature information of the application. After using this function, you must manually release the pointer returned to prevent memory leakage.
75
76**Since**: 11
77
78**Returns**
79
80| Type| Description|
81| -- | -- |
82| char* | Pointer to a new string that indicates the appID. If the returned object is NULL, the creation fails.<br>The possible cause is that the application address space is full, causing space allocation to fail.|
83
84### OH_NativeBundle_GetAppIdentifier()
85
86```
87char* OH_NativeBundle_GetAppIdentifier()
88```
89
90**Description**
91
92Obtains the appIdentifier of the current application. The appIdentifier does not change throughout the application lifecycle, including version updates, certificate changes, public and private key changes, and application migration. After using this function, you must manually release the pointer returned to prevent memory leakage.
93
94**Since**: 11
95
96**Returns**
97| Type| Description|
98| -- | -- |
99| char* | Pointer to a new string that indicates the appIdentifier. If the returned object is NULL, the creation fails.<br>The possible cause is that the application address space is full, causing space allocation to fail.|
100
101### OH_NativeBundle_GetMainElementName()
102
103```
104OH_NativeBundle_ElementName OH_NativeBundle_GetMainElementName()
105```
106
107**Description**
108
109Obtains the mainElement information of the current application, including the bundle name, module name, and ability name. After using this function, you must manually release the pointer returned to prevent memory leakage.
110
111**Since**: 13
112
113**Returns**
114| Type| Description|
115| -- | -- |
116| [OH_NativeBundle_ElementName](capi-native-bundle-oh-nativebundle-elementname.md) | Pointer to the OH_NativeBundle_ElementName object. If the returned object is NULL, the creation fails.<br>The possible cause is that the application address space is full, causing space allocation to fail.|
117
118
119### OH_NativeBundle_GetCompatibleDeviceType()
120
121```
122char* OH_NativeBundle_GetCompatibleDeviceType()
123```
124
125**Description**
126
127Obtains the compatible device type of the current application. It helps you optimize the layout and font size when distributing mobile applications to tablets or 2-in-1 devices. After using this function, you must manually release the pointer returned to prevent memory leakage.
128
129**Since**: 14
130
131**Returns**
132
133| Type| Description|
134| -- | -- |
135| char* | Pointer to a new string that indicates the compatible device type. If the returned object is NULL, the creation fails.<br>The possible cause is that the application address space is full, causing space allocation to fail.|
136
137### OH_NativeBundle_IsDebugMode()
138
139```
140bool OH_NativeBundle_IsDebugMode(bool* isDebugMode)
141```
142
143**Description**
144
145Checks whether the current application is in debug mode.
146
147**Since**: 20
148
149**Parameters**
150
151| Name| Description|
152| -- | -- |
153| bool* isDebugMode | Pointer to the check result indicating whether the application is in debug mode. **true** if in debug mode, **false** otherwise.|
154
155**Returns**
156
157| Type| Description|
158| -- | -- |
159| bool | Operation result. **true** if the call is successful, **false** otherwise.|
160
161### OH_NativeBundle_GetModuleMetadata()
162
163```
164OH_NativeBundle_ModuleMetadata* OH_NativeBundle_GetModuleMetadata(size_t* size)
165```
166
167**Description**
168
169Obtains the module metadata array of the current application. After using this function, you must manually release the pointer returned to prevent memory leakage.
170
171**Since**: 20
172
173**Parameters**
174
175| Name| Description|
176| -- | -- |
177| size_t* size | Pointer to the size of the module metadata array.|
178
179**Returns**
180
181| Type| Description|
182| -- | -- |
183| [OH_NativeBundle_ModuleMetadata*](capi-native-bundle-oh-nativebundle-modulemetadata.md) | An array of module metadata. If the returned object is NULL, the retrieval fails.<br>The possible cause is that the application address space is full, causing space allocation to fail.|
184