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 bundle_status_callback.h
32  *
33  * @brief Declares the callback invoked upon state changes of an application and the structure defining the callback
34  *        information.
35  *
36  * @since 1.0
37  * @version 1.0
38  */
39 
40 #ifndef OHOS_BUNDLE_STATUS_CALLBACK_H
41 #define OHOS_BUNDLE_STATUS_CALLBACK_H
42 
43 /**
44  * @brief Called when the installation, update, or uninstallation state of an application changes.
45  *
46  * This callback is used to listen for state change results of applications in the system.
47  * @param installType Indicates the installation, update, or uninstallation state. The value <b>0</b> indicates that
48  *                    the application is being installed or updated, and <b>1</b> indicates that the application is
49  *                    being uninstalled.
50  * @param resultCode Indicates the status code returned for the application installation, update, or uninstallation
51  *                   result. For details, see {@link AppexecfwkErrors}.
52  * @param resultMessage Indicates the pointer to the result message returned with the status code.
53  * @param bundleName Indicates the pointer to the name of the bundle whose state has changed.
54  * @param data Indicates the pointer to the data that will be used by the callback upon a state change. The data is
55  *             passed through {@link BundleStatusCallback} during callback registration.
56  *
57  * @since 1.0
58  * @version 1.0
59  */
60 typedef void (*BundleStateCallback)(const uint8_t installType, const uint8_t resultCode, const void *resultMessage,
61     const char *bundleName, void *data);
62 
63 /**
64  * @brief Defines the application state callback information.
65  */
66 typedef struct {
67     /**
68      * Pointer to the bundle name of the application that the callback listens to. If this parameter is set to
69      * <b>nullptr</b>, the callback listens to all applications in the system.
70      */
71     char *bundleName;
72 
73     /**
74      * Pointer to the registered data that will be used by {@link BundleStateCallback}.
75      */
76     void *data;
77 
78     /**
79      * Callback to be invoked upon application state changes.
80      */
81     BundleStateCallback callBack;
82 } BundleStatusCallback;
83 
84 #ifdef __cplusplus
85 #if __cplusplus
86 extern "C" {
87 #endif
88 #endif // __cplusplus
89 /**
90  * @brief Clears and releases the memory occupied by the {@link BundleStatusCallback} structure.
91  *
92  *
93  * @param bundleStatusCallback Indicates the pointer to the {@link BundleStatusCallback} structure to clear.
94  *
95  * @since 1.0
96  * @version 1.0
97  */
98 void ClearBundleStatusCallback(BundleStatusCallback *bundleStatusCallback);
99 #ifdef __cplusplus
100 #if __cplusplus
101 }
102 #endif
103 #endif // __cplusplus
104 #endif // OHOS_BUNDLE_STATUS_CALLBACK_H
105 /** @} */