1 /* 2 * Copyright (c) 2021-2023 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 #ifndef OHOS_BUNDLE_INSTALL_MSG_H 17 #define OHOS_BUNDLE_INSTALL_MSG_H 18 19 #include <stdint.h> 20 21 #include "bundle_manager.h" 22 #include "los_list.h" 23 24 #ifdef __cplusplus 25 #if __cplusplus 26 extern "C" { 27 #endif 28 #endif /* __cplusplus */ 29 30 #define MAX_APP_FILE_PATH_LEN 100 31 typedef enum { 32 BUNDLE_INSTALL_DOING = 0, 33 BUNDLE_INSTALL_OK = 1, 34 BUNDLE_INSTALL_FAIL = 2, 35 BUNDLE_UNINSTALL_DOING = 3, 36 BUNDLE_UNINSTALL_OK = 4, 37 BUNDLE_UNINSTALL_FAIL = 5 38 } InstallState; 39 40 typedef struct { 41 char *bundleName; 42 char *label; 43 char *smallIconPath; 44 char *bigIconPath; 45 InstallState installState; 46 uint8_t installProcess; 47 uint8_t actionService; 48 } BundleInstallMsg; 49 50 typedef struct { 51 LOS_DL_LIST appDoubleList; 52 char filePath[MAX_APP_FILE_PATH_LEN]; 53 } PreAppList; 54 55 /** 56 * @brief Get the install state and install process of the bundle. 57 * 58 * @param bundleName Indicates the name of the bundle. 59 * @param installState Obtains install state. 60 * @param installProcess Obtains install process. 61 * @return Returns success or not. 62 * 63 * @since 4.0 64 * @version 4.0 65 */ 66 bool GetInstallState(const char *bundleName, InstallState *installState, uint8_t *installProcess); 67 68 /** 69 * @brief Get the bundle size. 70 * 71 * @param bundleName Indicates the name of the bundle. 72 * @return Returns bundle size or returns 0 if get bundle size failed. 73 * 74 */ 75 uint32_t GetBundleSize(const char *bundleName); 76 77 /** 78 * @brief Register installer callback. 79 * 80 * @param installerCallback Indicates the installer callback. 81 * @return Returns success or failure. 82 * 83 */ 84 bool RegisterInstallerCallback(InstallerCallback installerCallback); 85 86 /** 87 * @brief Update bundleInfo when system language has been changed. 88 * 89 */ 90 void UpdateBundleInfoList(void); 91 92 /** 93 * @brief Obtains the {@link BundleInfo} of all bundles with no replication in the system. 94 * 95 * @param flags Specifies whether each of the obtained {@link BundleInfo} objects can contain {@link AbilityInfo}. 96 * The value <b>1</b> indicates that it can contain {@link AbilityInfo}, and <b>0</b> indicates that 97 * it cannot. 98 * @param bundleInfos Indicates the double pointer to the obtained {@link BundleInfo} objects. 99 * @param len Indicates the pointer to the number of {@link BundleInfo} objects obtained. 100 * @return Returns {@link ERR_OK} if this function is successfully called; returns another error code defined in 101 * {@link AppexecfwkErrors} otherwise. 102 * 103 */ 104 uint8_t GetBundleInfosNoReplication(const int flags, BundleInfo **bundleInfos, int32_t *len); 105 106 /** 107 * @brief Query qualified abilityInfo according to want. 108 * 109 * @param want The want provided by ActivityManagerService contains the actions fiels you want to query. 110 * @param abilityInfo Qualified abilityInfo. 111 * @param len Indicates the pointer to the number of {@link abilityInfo} objects obtained. 112 * @return Returns {@link ERR_OK} if this function is successfully called; 113 */ 114 uint8_t QueryAbilityInfos(const Want *want, AbilityInfo **abilityInfo, int32_t *len); 115 116 /** 117 * @brief Register an event callback to return the specified HCE tag. 118 * 119 * @param installerCallback callback function. 120 * @return Returns result if this function is successfully called; 121 */ 122 bool RegisterEvent(InstallerCallback installerCallback); 123 124 /** 125 * @brief Unregister an event callback, which is used to cancel the RegisterEvent. 126 * 127 * @param installerCallback callback function. 128 * @return Returns result if this function is successfully called; 129 */ 130 bool UnregisterEvent(InstallerCallback installerCallback); 131 132 /** 133 * @brief Initializing preset application information. 134 * 135 * @return Returns an empty PreAppList. 136 * 137 */ 138 PreAppList *InitPreAppInfo(void); 139 140 /** 141 * @brief Insert preset application information to the list. 142 * 143 * @param filePath Indicates the file path of the preconfigured application. 144 * @param list Indicates the inserted list. 145 * 146 */ 147 void InsertPreAppInfo(const char *filePath, PreAppList *list); 148 149 /** 150 * @brief Setting the preset application list. 151 * 152 * @param list Indicates the preset application list. 153 * 154 */ 155 void SetPreAppInfo(PreAppList *list); 156 157 #ifdef __cplusplus 158 #if __cplusplus 159 } 160 #endif 161 #endif /* __cplusplus */ 162 #endif /* OHOS_BUNDLE_INSTALL_MSG_H */ 163 /** @} */