• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  * @library libbundle_ndk.z.so
32  * @syscap SystemCapability.BundleManager.BundleFramework.Core
33  * @since 9
34  * @version 1.0
35  */
36 #ifndef FOUNDATION_APPEXECFWK_STANDARD_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_NATIVE_INTERFACE_BUNDLE_H
37 #define FOUNDATION_APPEXECFWK_STANDARD_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_NATIVE_INTERFACE_BUNDLE_H
38 
39 #include <stdbool.h>
40 #include <stddef.h>
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 /**
46  * @brief Indicates information of application
47  *
48  * @syscap SystemCapability.BundleManager.BundleFramework.Core
49  * @since 9
50  */
51 struct OH_NativeBundle_ApplicationInfo {
52     /**
53      * Indicates the name of application
54      * @syscap SystemCapability.BundleManager.BundleFramework.Core
55      * @since 9
56      */
57     char* bundleName;
58 
59     /**
60      * Indicates the fingerprint of application
61      * @syscap SystemCapability.BundleManager.BundleFramework.Core
62      * @since 9
63      */
64     char* fingerprint;
65 };
66 
67 /**
68  * @brief Indicates information of elementName.
69  *
70  * @syscap SystemCapability.BundleManager.BundleFramework.Core
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  * @version 1.0
190  */
191 OH_NativeBundle_ElementName OH_NativeBundle_GetMainElementName();
192 
193 /**
194  * @brief Obtains the compatible device type of the current application.
195  * After utilizing this interface, to prevent memory leaks,
196  * it is necessary to manually release the pointer returned by the interface.
197  *
198  * @return Returns the newly created string that indicates the compatible device type,
199  * if the returned object is NULL, it indicates creation failure.
200  * The possible cause of failure could be that the application address space is full,
201  * leading to space allocation failure.
202  * @since 14
203  * @version 1.0
204  */
205 char* OH_NativeBundle_GetCompatibleDeviceType();
206 
207 /**
208  * @brief Obtains the application debug mode.
209  *
210  * @param isDebugMode Indicates whether the application is in debug mode.
211  * @return Returns true if call successful, false otherwise.
212  * @since 20
213  */
214 bool OH_NativeBundle_IsDebugMode(bool* isDebugMode);
215 
216 /**
217  * @brief Obtains the module metadata array of the current application.
218  * After utilizing this interface, to prevent memory leaks,
219  * it is necessary to manually release the pointer returned by the interface.
220  *
221  * @param size Indicates the module metadata array size.
222  * @return Returns the newly created module metadata array, if the returned object is NULL,
223  * it indicates creation failure. The possible cause of failure could be that the application address space is full,
224  * leading to space allocation failure.
225  * @since 20
226  */
227 OH_NativeBundle_ModuleMetadata* OH_NativeBundle_GetModuleMetadata(size_t* size);
228 #ifdef __cplusplus
229 };
230 #endif
231 /** @} */
232 #endif // FOUNDATION_APPEXECFWK_STANDARD_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_NATIVE_INTERFACE_BUNDLE_H
233