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 16import { AsyncCallback } from './basic'; 17import { DispatchInfo as _DispatchInfo } from './bundleManager/DispatchInfo'; 18import * as _PackInfo from './bundleManager/BundlePackInfo' 19 20/** 21 * Free install bundle manager. 22 * @namespace freeInstall 23 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 24 * @systemapi 25 * @since 9 26 */ 27declare namespace freeInstall { 28 /** 29 * Used to set the enumeration value of upgrading for free installation. 30 * @enum {number} 31 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 32 * @systemapi 33 * @since 9 34 */ 35 export enum UpgradeFlag { 36 /** 37 * Indicates module not need to be upgraded 38 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 39 * @since 9 40 */ 41 NOT_UPGRADE = 0, 42 /** 43 * Indicates single module need to be upgraded 44 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 45 * @since 9 46 */ 47 SINGLE_UPGRADE = 1, 48 /** 49 * Indicates relation module need to be upgraded 50 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 51 * @since 9 52 */ 53 RELATION_UPGRADE = 2, 54 } 55 56 /** 57 * Used to query the enumeration value of bundlePackInfo. 58 * @enum {number} 59 * @syscap SystemCapability.BundleManager.BundleFramework 60 * @systemapi 61 * @since 9 62 */ 63 export enum BundlePackFlag { 64 /** 65 * Query all package information. 66 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 67 * @since 9 68 */ 69 GET_PACK_INFO_ALL = 0x00000000, 70 /** 71 * Query package information 72 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 73 * @since 9 74 */ 75 GET_PACKAGES = 0x00000001, 76 /** 77 * Query the brief information of the package 78 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 79 * @since 9 80 */ 81 GET_BUNDLE_SUMMARY = 0x00000002, 82 /** 83 * Query the brief information of the module. 84 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 85 * @since 9 86 */ 87 GET_MODULE_SUMMARY = 0x00000004, 88 } 89 90 /** 91 * Sets whether to upgrade the module. 92 * @permission ohos.permission.INSTALL_BUNDLE 93 * @param { string } bundleName - Indicates the bundle name of the application. 94 * @param { string } moduleName - Indicates the module name of the application. 95 * @param { UpgradeFlag } upgradeFlag - Indicates upgradeFlag of the application. 96 * @param { AsyncCallback<void> } callback - The callback of setting module upgrade flag result. 97 * @throws { BusinessError } 201 - Permission denied. 98 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 99 * @throws { BusinessError } 401 - The parameter check failed. 100 * @throws { BusinessError } 801 - Capability not supported. 101 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 102 * @throws { BusinessError } 17700002 - The specified module name is not found. 103 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 104 * @systemapi 105 * @since 9 106 */ 107 function setHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag, callback: AsyncCallback<void>) : void; 108 109 /** 110 * Sets whether to upgrade the module. 111 * @permission ohos.permission.INSTALL_BUNDLE 112 * @param { string } bundleName - Indicates the bundle name of the application. 113 * @param { string } moduleName - Indicates the module name of the application. 114 * @param { UpgradeFlag } upgradeFlag - Indicates upgradeFlag of the application. 115 * @returns { Promise<void> } - Return the result of setting module upgrade flag. 116 * @throws { BusinessError } 201 - Permission denied. 117 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 118 * @throws { BusinessError } 401 - The parameter check failed. 119 * @throws { BusinessError } 801 - Capability not supported. 120 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 121 * @throws { BusinessError } 17700002 - The specified module name is not found. 122 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 123 * @systemapi 124 * @since 9 125 */ 126 function setHapModuleUpgradeFlag(bundleName: string, moduleName: string, upgradeFlag: UpgradeFlag): Promise<void>; 127 128 /** 129 * Checks whether a specified module is removable. 130 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 131 * @param { string } bundleName - Indicates the bundle name of the application. 132 * @param { string } moduleName - Indicates the module name of the application. 133 * @param { AsyncCallback<boolean> } callback - The callback of checking module removable result.The result is true if the module is removable, false otherwise. 134 * @throws { BusinessError } 201 - Permission denied. 135 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 136 * @throws { BusinessError } 401 - The parameter check failed. 137 * @throws { BusinessError } 801 - Capability not supported. 138 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 139 * @throws { BusinessError } 17700002 - The specified module name is not found. 140 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 141 * @systemapi 142 * @since 9 143 */ 144 function isHapModuleRemovable(bundleName: string, moduleName: string, callback: AsyncCallback<boolean>): void; 145 146 /** 147 * Checks whether a specified module is removable. 148 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 149 * @param { string } bundleName - Indicates the bundle name of the application. 150 * @param { string } moduleName - Indicates the module name of the application. 151 * @returns {Promise<void>} Returns true if the module is removable; returns false otherwise. 152 * @throws { BusinessError } 201 - Permission denied. 153 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 154 * @throws { BusinessError } 401 - The parameter check failed. 155 * @throws { BusinessError } 801 - Capability not supported. 156 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 157 * @throws { BusinessError } 17700002 - The specified module name is not found. 158 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 159 * @systemapi 160 * @since 9 161 */ 162 function isHapModuleRemovable(bundleName: string, moduleName: string): Promise<boolean>; 163 164 /** 165 * Obtains bundlePackInfo based on bundleName and bundlePackFlags. 166 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 167 * @param { string } bundleName - Indicates the application bundle name to be queried. 168 * @param { BundlePackFlag } bundlePackFlag - Indicates the application bundle pack flag to be queried. 169 * @param { AsyncCallback<BundlePackInfo> } callback - The callback of getting the BundlePackInfo object result. 170 * @throws { BusinessError } 201 - Permission denied. 171 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 172 * @throws { BusinessError } 401 - The parameter check failed. 173 * @throws { BusinessError } 801 - Capability not supported. 174 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 175 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 176 * @systemapi 177 * @since 9 178 */ 179 function getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag, callback: AsyncCallback<BundlePackInfo>): void; 180 181 /** 182 * Obtains bundlePackInfo based on bundleName and bundlePackFlags. 183 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 184 * @param { string } bundleName - Indicates the application bundle name to be queried. 185 * @param { BundlePackFlag } bundlePackFlag - Indicates the application bundle pack flag to be queried. 186 * @returns {Promise<BundlePackInfo>} Returns the BundlePackInfo object. 187 * @throws { BusinessError } 201 - Permission denied. 188 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 189 * @throws { BusinessError } 401 - The parameter check failed. 190 * @throws { BusinessError } 801 - Capability not supported. 191 * @throws { BusinessError } 17700001 - The specified bundle name is not found. 192 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 193 * @systemapi 194 * @since 9 195 */ 196 function getBundlePackInfo(bundleName: string, bundlePackFlag : BundlePackFlag): Promise<BundlePackInfo>; 197 198 /** 199 * Obtains information about the dispatcher version. 200 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 201 * @param { AsyncCallback<DispatchInfo> } callback - The callback of getting the dispatchInfo object for the current ability result. 202 * @throws { BusinessError } 201 - Permission denied. 203 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 204 * @throws { BusinessError } 801 - Capability not supported. 205 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 206 * @systemapi 207 * @since 9 208 */ 209 function getDispatchInfo(callback: AsyncCallback<DispatchInfo>): void; 210 211 /** 212 * Obtains information about the dispatcher version. 213 * @permission ohos.permission.GET_BUNDLE_INFO_PRIVILEGED 214 * @returns { Promise<DispatchInfo> } Returns the DispatchInfo object for the current ability. 215 * @throws { BusinessError } 201 - Permission denied. 216 * @throws { BusinessError } 202 - Permission denied, non-system app called system api. 217 * @throws { BusinessError } 801 - Capability not supported. 218 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 219 * @systemapi 220 * @since 9 221 */ 222 function getDispatchInfo(): Promise<DispatchInfo>; 223 224 /** 225 * The dispatch info class. 226 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 227 * @systemapi 228 * @since 9 229 */ 230 export type DispatchInfo = _DispatchInfo; 231 232 /** 233 * The bundle pack info class. 234 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 235 * @systemapi 236 * @since 9 237 */ 238 export type BundlePackInfo = _PackInfo.BundlePackInfo; 239 240 /** 241 * The package info class. 242 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 243 * @systemapi 244 * @since 9 245 */ 246 export type PackageConfig = _PackInfo.PackageConfig; 247 248 /** 249 * The package summary class. 250 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 251 * @systemapi 252 * @since 9 253 */ 254 export type PackageSummary = _PackInfo.PackageSummary; 255 256 /** 257 * The bundle summary class. 258 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 259 * @systemapi 260 * @since 9 261 */ 262 export type BundleConfigInfo = _PackInfo.BundleConfigInfo; 263 264 /** 265 * The extension ability forms class. 266 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 267 * @systemapi 268 * @since 9 269 */ 270 export type ExtensionAbility = _PackInfo.ExtensionAbility; 271 272 /** 273 * The module summary of a bundle. 274 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 275 * @systemapi 276 * @since 9 277 */ 278 export type ModuleConfigInfo = _PackInfo.ModuleConfigInfo; 279 280 /** 281 * The bundle info summary class. 282 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 283 * @systemapi 284 * @since 9 285 */ 286 export type ModuleDistroInfo = _PackInfo.ModuleDistroInfo; 287 288 /** 289 * The ability info of a module. 290 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 291 * @systemapi 292 * @since 9 293 */ 294 export type ModuleAbilityInfo = _PackInfo.ModuleAbilityInfo; 295 296 /** 297 * The form info of an ability. 298 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 299 * @systemapi 300 * @since 9 301 */ 302 export type AbilityFormInfo = _PackInfo.AbilityFormInfo; 303 304 /** 305 * The bundle version class. 306 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 307 * @systemapi 308 * @since 9 309 */ 310 export type Version = _PackInfo.Version; 311 312 /** 313 * The bundle Api version class. 314 * @syscap SystemCapability.BundleManager.BundleFramework.FreeInstall 315 * @systemapi 316 * @since 9 317 */ 318 export type ApiVersion = _PackInfo.ApiVersion; 319} 320 321export default freeInstall; 322