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.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 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 /**
44  * @brief Indicates information of application
45  *
46  * @syscap SystemCapability.BundleManager.BundleFramework.Core
47  * @since 9
48  */
49 struct OH_NativeBundle_ApplicationInfo {
50     /**
51      * Indicates the name of application
52      * @syscap SystemCapability.BundleManager.BundleFramework.Core
53      * @since 9
54      */
55     char* bundleName;
56 
57     /**
58      * Indicates the fingerprint of application
59      * @syscap SystemCapability.BundleManager.BundleFramework.Core
60      * @since 9
61      */
62     char* fingerprint;
63 };
64 
65 /**
66  * @brief Indicates information of elementName.
67  *
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  */
147 OH_NativeBundle_ElementName OH_NativeBundle_GetMainElementName();
148 #ifdef __cplusplus
149 };
150 #endif
151 /** @} */
152 #endif // FOUNDATION_APPEXECFWK_STANDARD_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_NATIVE_INTERFACE_BUNDLE_H
153