1 /*
2  * Copyright (c) 2020 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 BundleManager
18  * @{
19  *
20  * @brief Provides structures and functions for managing application bundles and obtaining application information.
21  *
22  * You can use functions provided by this module to install, update, or uninstall an application, obtain
23  * {@link AbilityInfo} and {@link BundleInfo} about an application, and obtain the bundle name of an application
24  * based on the application's user ID (UID).
25  *
26  * @since 1.0
27  * @version 1.0
28  */
29 
30 /**
31  * @file element_name.h
32  *
33  * @brief Declares the structure that defines the required information for querying {@link AbilityInfo}, including
34  *        the device ID, bundle name, and class name, and functions for setting such information.
35  *
36  * You can use functions provided in this file to specify the information for querying {@link AbilityInfo}.
37  *
38  * @since 1.0
39  * @version 1.0
40  */
41 
42 #ifndef OHOS_ELEMENT_NAME_H
43 #define OHOS_ELEMENT_NAME_H
44 
45 #ifndef __LITEOS_M__
46 #ifdef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER
47 #include <serializer.h>
48 #endif
49 #endif
50 #include <stdbool.h>
51 
52 /**
53  * @brief Defines the ability information.
54  */
55 typedef struct {
56     /**
57      * Pointer to the ID of the device running the application
58      */
59     char *deviceId;
60 
61     /**
62      * Pointer to the bundle name of the application
63      */
64     char *bundleName;
65 
66     /**
67      * Pointer to the class name of the ability
68      */
69     char *abilityName;
70 } ElementName;
71 
72 #ifdef __cplusplus
73 #if __cplusplus
74 extern "C" {
75 #endif
76 #endif // __cplusplus
77 /**
78  * @brief Clears the internal data of a specified <b>ElementName</b>.
79  *
80  * After {@link AbilityInfo} is queried, clear the internal data of an <b>ElementName</b> if it is no longer required.
81  * @param element Indicates the pointer to the <b>ElementName</b> to clear.
82  */
83 void ClearElement(ElementName *element);
84 
85 /**
86  * @brief Delete <b>ElementName</b>.
87  *
88  * After {@link AbilityInfo} is queried, clear the internal data of an <b>ElementName</b> if it is no longer required.
89  * @param element Indicates the pointer to the <b>ElementName</b> to clear.
90  */
91 void DeleteElement(ElementName *element);
92 
93 /**
94  * @brief Sets the device ID used to query {@link AbilityInfo}.
95  *
96  * @param element Indicates the pointer to the <b>ElementName</b> to set.
97  * @param deviceId Indicates the pointer to the device ID to set.
98  *
99  * @return Returns <b>true</b> if the setting is successful; returns <b>false</b> otherwise.
100  */
101 bool SetElementDeviceID(ElementName *element, const char *deviceId);
102 
103 /**
104  * @brief Sets the bundle name used to query {@link AbilityInfo}.
105  *
106  * @param element Indicates the pointer to the <b>ElementName</b> to set.
107  * @param bundleName Indicates the pointer to the bundle name to set.
108  *
109  * @return Returns <b>true</b> if the setting is successful; returns <b>false</b> otherwise.
110  */
111 bool SetElementBundleName(ElementName *element, const char *bundleName);
112 
113 /**
114  * @brief Sets the class name of the ability used to query {@link AbilityInfo}.
115  *
116  * @param element Indicates the pointer to the <b>ElementName</b> to set.
117  * @param abilityName Indicates the pointer to the class name to set.
118  *
119  * @return Returns <b>true</b> if the setting is successful; returns <b>false</b> otherwise.
120  */
121 bool SetElementAbilityName(ElementName *element, const char *abilityName);
122 
123 #ifndef __LITEOS_M__
124 #ifdef OHOS_APPEXECFWK_BMS_BUNDLEMANAGER
125 bool SerializeElement(IpcIo *io, const ElementName *element);
126 bool DeserializeElement(ElementName *element, IpcIo *io);
127 #endif
128 #endif
129 #ifdef __cplusplus
130 #if __cplusplus
131 }
132 #endif
133 #endif // __cplusplus
134 
135 #endif // OHOS_ELEMENT_NAME_H
136 /** @} */
137