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.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 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 /**
43  * @brief Indicates information of application
44  *
45  * @syscap SystemCapability.BundleManager.BundleFramework.Core
46  * @since 9
47  */
48 struct OH_NativeBundle_ApplicationInfo {
49     /**
50      * Indicates the name of application
51      * @syscap SystemCapability.BundleManager.BundleFramework.Core
52      * @since 9
53      */
54     char* bundleName;
55 
56     /**
57      * Indicates the fingerprint of application
58      * @syscap SystemCapability.BundleManager.BundleFramework.Core
59      * @since 9
60      */
61     char* fingerprint;
62 };
63 
64 /**
65  * @brief Indicates information of elementName.
66  *
67  * @syscap SystemCapability.BundleManager.BundleFramework.Core
68  * @since 13
69  */
70 struct OH_NativeBundle_ElementName {
71     /** Indicates the name of application. */
72     char* bundleName;
73     /** Indicates the name of module. */
74     char* moduleName;
75     /** Indicates the name of ability. */
76     char* abilityName;
77 };
78 
79 /**
80  * @brief Indicates information of application
81  *
82  * @since 11
83  * @version 1.0
84  */
85 typedef struct OH_NativeBundle_ApplicationInfo OH_NativeBundle_ApplicationInfo;
86 
87 /**
88  * @brief Indicates information of elementName
89  *
90  * @since 13
91  * @version 1.0
92  */
93 typedef struct OH_NativeBundle_ElementName OH_NativeBundle_ElementName;
94 
95 /**
96  * @brief Obtains the application info based on the The current bundle.
97  *
98  * @return Returns the newly created OH_NativeBundle_ApplicationInfo object, if the returned object is NULL,
99  * it indicates creation failure. The possible cause of failure could be that the application address space is full,
100  * leading to space allocation failure.
101  * @since 9
102  * @version 1.0
103  */
104 OH_NativeBundle_ApplicationInfo OH_NativeBundle_GetCurrentApplicationInfo();
105 
106 /**
107  * @brief Obtains the appId of application. AppId indicates the ID of the application to which this bundle belongs
108  * The application ID uniquely identifies an application. It is determined by the bundle name and signature.
109  * After utilizing this interface, to prevent memory leaks,
110  * it is necessary to manually release the pointer returned by the interface.
111  *
112  * @return Returns the newly created string that indicates appId information,
113  * if the returned object is NULL, it indicates creation failure.
114  * The possible cause of failure could be that the application address space is full,
115  * leading to space allocation failure.
116  * @since 11
117  * @version 1.0
118  */
119 char* OH_NativeBundle_GetAppId();
120 
121 /**
122  * @brief Obtains the appIdentifier of application. AppIdentifier does not change along the application lifecycle,
123  * including version updates, certificate changes, public and private key changes, and application transfer.
124  * After utilizing this interface, to prevent memory leaks,
125  * it is necessary to manually release the pointer returned by the interface.
126  *
127  * @return Returns the newly created string that indicates app identifier information,
128  * if the returned object is NULL, it indicates creation failure.
129  * The possible cause of failure could be that the application address space is full,
130  * leading to space allocation failure.
131  * @since 11
132  * @version 1.0
133  */
134 char* OH_NativeBundle_GetAppIdentifier();
135 
136 /**
137 * @brief Obtains information of the entry mainElement based on the current application, including bundle name,
138  * module name, and ability name.
139  * After utilizing this interface, to prevent memory leaks,
140  * it is necessary to manually release the pointer returned by the interface.
141  *
142  * @return Returns the newly created OH_NativeBundle_ElementName object, if the returned object is NULL,
143  * it indicates creation failure. The possible cause of failure could be that the application address space is full,
144  * leading to space allocation failure.
145  * @since 13
146  * @version 1.0
147  */
148 OH_NativeBundle_ElementName OH_NativeBundle_GetMainElementName();
149 
150 /**
151  * @brief Obtains the compatible device type of the current application.
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 the compatible device type,
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 14
160  * @version 1.0
161  */
162 char* OH_NativeBundle_GetCompatibleDeviceType();
163 #ifdef __cplusplus
164 };
165 #endif
166 /** @} */
167 #endif // FOUNDATION_APPEXECFWK_STANDARD_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_NATIVE_INTERFACE_BUNDLE_H
168