1# @ohos.bundle.installer (installer) (System API) 2 3The **bundle.installer** module provides APIs for you to install, uninstall, and recover bundles on devices. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> 9> The APIs provided by this module are system APIs. 10 11## Modules to Import 12 13```js 14import installer from '@ohos.bundle.installer'; 15``` 16 17## Required Permissions 18 19| Permission | APL | Description | 20| ------------------------------ | ----------- | ---------------- | 21| ohos.permission.INSTALL_BUNDLE | system_core | Permission to install or uninstall other applications except enterprise applications, including enterprise InHouse, mobile device management (MDM), and Normal applications.| 22| ohos.permission.INSTALL_ENTERPRISE_BUNDLE | system_core | Permission to install enterprise InHouse applications.| 23| ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE | system_core | Permission to install enterprise MDM applications.| 24| ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE | system_core | Permission to install enterprise Normal applications.| 25| ohos.permission.UNINSTALL_BUNDLE | system_core | Allows an application to uninstall applications.| 26| ohos.permission.RECOVER_BUNDLE | system_core | Allows an application to restore pre-installed applications.| 27| ohos.permission.INSTALL_SELF_BUNDLE | system_core | Allows automatic updates of the enterprise MDM applications on enterprise devices.| 28| ohos.permission.INSTALL_INTERNALTESTING_BUNDLE | system_core | Allows an application to install beta applications.| 29 30For details about the APL, see [Basic Concepts in the Permission Mechanism](../../security/AccessToken/app-permission-mgmt-overview.md#basic-concepts-in-the-permission-mechanism). 31 32## BundleInstaller.getBundleInstaller 33 34getBundleInstaller(callback: AsyncCallback\<BundleInstaller>): void 35 36Obtains a **BundleInstaller** object. This API uses an asynchronous callback to return the result. 37 38**System API**: This is a system API. 39 40**System capability**: SystemCapability.BundleManager.BundleFramework.Core 41 42**Parameters** 43 44| Name | Type | Mandatory| Description | 45| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 46| callback | AsyncCallback\<BundleInstaller> | Yes | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the **BundleInstaller** object obtained; otherwise, **err** is an error object.| 47 48**Error codes** 49 50For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). 51 52| ID| Error Message | 53| -------- | ------------------------------------------------------------ | 54| 202 | Permission verification failed. A non-system application calls a system API. | 55| 401 | Parameter error. Possible causes: 1. Incorrect parameter types. | 56 57**Example** 58 59```ts 60import installer from '@ohos.bundle.installer'; 61import { BusinessError } from '@ohos.base'; 62 63try { 64 installer.getBundleInstaller((err: BusinessError, data: installer.BundleInstaller) => { 65 if (err) { 66 console.error('getBundleInstaller failed:' + err.message); 67 } else { 68 console.info('getBundleInstaller successfully'); 69 } 70 }); 71} catch (error) { 72 let message = (error as BusinessError).message; 73 console.error('getBundleInstaller failed:' + message); 74} 75``` 76 77## BundleInstaller.getBundleInstaller 78 79getBundleInstaller(): Promise\<BundleInstaller> 80 81Obtains a **BundleInstaller** object. This API uses an asynchronous callback to return the result. 82 83**System API**: This is a system API. 84 85**System capability**: SystemCapability.BundleManager.BundleFramework.Core 86 87**Return value** 88| Type | Description | 89| ------------------------------------------------------------ | ------------------------------------ | 90| Promise\<BundleInstaller> | Promise used to return the **BundleInstaller** object obtained.| 91 92**Error codes** 93 94For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). 95 96| ID| Error Message | 97| -------- | ------------------------------------------------------------ | 98| 202 | Permission verification failed. A non-system application calls a system API. | 99 100**Example** 101 102```ts 103import installer from '@ohos.bundle.installer'; 104import { BusinessError } from '@ohos.base'; 105 106try { 107 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 108 console.info('getBundleInstaller successfully.'); 109 }).catch((error: BusinessError) => { 110 console.error('getBundleInstaller failed. Cause: ' + error.message); 111 }); 112} catch (error) { 113 let message = (error as BusinessError).message; 114 console.error('getBundleInstaller failed. Cause: ' + message); 115} 116``` 117 118## BundleInstaller.getBundleInstallerSync<sup>10+</sup> 119 120getBundleInstallerSync(): BundleInstaller 121 122Obtains a **BundleInstaller** object. This API is a synchronous API. 123 124**System API**: This is a system API. 125 126**System capability**: SystemCapability.BundleManager.BundleFramework.Core 127 128**Return value** 129| Type | Description | 130| ------------------------------------------------------------ | ------------------------------------ | 131| BundleInstaller | **BundleInstaller** object.| 132 133**Error codes** 134 135For details about the error codes, see [Bundle Error Codes](errorcode-bundle.md). 136 137| ID| Error Message | 138| -------- | ------------------------------------------------------------ | 139| 202 | Permission verification failed. A non-system application calls a system API. | 140 141**Example** 142 143```ts 144import installer from '@ohos.bundle.installer'; 145import { BusinessError } from '@ohos.base'; 146 147try { 148 installer.getBundleInstallerSync(); 149 console.info('getBundleInstallerSync successfully.'); 150} catch (error) { 151 let message = (error as BusinessError).message; 152 console.error('getBundleInstallerSync failed. Cause: ' + message); 153} 154``` 155 156## BundleInstaller.install 157install(hapFilePaths: Array<string>, installParam: InstallParam, callback: AsyncCallback<void>): void 158 159Installs a bundle. This API uses an asynchronous callback to return the result. 160 161**System API**: This is a system API. 162 163**Required permissions**: ohos.permission.INSTALL_BUNDLE, ohos.permission.INSTALL_ENTERPRISE_BUNDLE<sup>10+</sup>, ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE<sup>10+</sup>, or ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE<sup>10+</sup> 164> **NOTE** 165> 166> From API version 10, this API can be called with the permission **ohos.permission.INSTALL_ENTERPRISE_BUNDLE**, **ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE**, or **ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE**. 167> 168> To install an enterprise application, you must have the **ohos.permission.INSTALL_ENTERPRISE_BUNDLE** permission. 169> 170> To install an enterprise Normal application, you must have the **ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE** or **ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE** permission. 171> 172> To install an enterprise MDM application, you must have the **ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE** permission. 173> 174> To install a common application, you must have the **ohos.permission.INSTALL_BUNDLE** permission. 175> 176> To install a beta application, you must have the **ohos.permission.INSTALL_INTERNALTESTING_BUNDLE** permission. 177 178**System capability**: SystemCapability.BundleManager.BundleFramework.Core 179 180**Parameters** 181 182| Name | Type | Mandatory| Description | 183| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | 184| hapFilePaths | Array<string> | Yes | Paths where the HAP files of the bundle are stored, which are the data directories. If only one directory is passed, the HAP files in the directory must belong to the same bundle and have the same signature.| 185| installParam | [InstallParam](#installparam) | Yes | Parameters required for the installation. | 186| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **null**; otherwise, **err** is an error object.| 187 188**Error codes** 189 190For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 191 192| ID| Error Message | 193| -------- | ------------------------------------------------------------ | 194| 201 | Calling interface without permission 'ohos.permission.INSTALL_BUNDLE' or 'ohos.permission.INSTALL_ENTERPRISE_BUNDLE' or 'ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE' or 'ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE'. | 195| 202 | Permission verification failed. A non-system application calls a system API. | 196| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter hapFiles is needed for code signature; 4. The size of specifiedDistributionType is greater than 128; 5. The size of additionalInfo is greater than 3000. | 197| 17700004 | The specified user ID is not found. | 198| 17700010 | Failed to install the HAP because the HAP fails to be parsed. | 199| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. | 200| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. | 201| 17700015 | Failed to install the HAPs because they have different configuration information. | 202| 17700016 | Failed to install the HAP because of insufficient system disk space. | 203| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. | 204| 17700018 | Failed to install the HAP or HSP because the dependent module does not exist. | 205| 17700031 | Failed to install the HAP because the overlay check of the HAP failed. | 206| 17700036 | Failed to install the HSP due to the lack of required permission. | 207| 17700039 | Failed to install the HSP because installing a shared bundle specified by hapFilePaths is not allowed. | 208| 17700041 | Failed to install the HAP because the installation is forbidden by enterprise device management. | 209| 17700042 | Failed to install the HAP because of incorrect URI in the data proxy. | 210| 17700043 | Failed to install the HAP because of low APL in the non-system data proxy (required APL: system_basic or system_core). | 211| 17700044 | Failed to install the HAP because the isolationMode configured is not supported. | 212| 17700047 | Failed to install the HAP because the VersionCode to be updated is not greater than the current VersionCode. | 213| 17700048 | Failed to install the HAP because the code signature verification failed. | 214| 17700050 | Failed to install the HAP because an enterprise normal/MDM bundle cannot be installed on non-enterprise devices. | 215| 17700052 | Failed to install the HAP because a debug bundle can be installed only in developer mode. | 216| 17700054 | Failed to install the HAP because the HAP requests wrong permissions.| 217| 17700066 | Failed to install the HAP because installing the native package failed. | 218| 17700073 | Failed to install the HAP because an application with the same bundle name but different signature information exists on the device. | 219 220**Example** 221 222```ts 223import installer from '@ohos.bundle.installer'; 224import { BusinessError } from '@ohos.base'; 225 226let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; 227let installParam: installer.InstallParam = { 228 userId: 100, 229 isKeepData: false, 230 installFlag: 1, 231}; 232 233try { 234 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 235 data.install(hapFilePaths, installParam, (err: BusinessError) => { 236 if (err) { 237 console.error('install failed:' + err.message); 238 } else { 239 console.info('install successfully.'); 240 } 241 }); 242 }).catch((error: BusinessError) => { 243 console.error('getBundleInstaller failed. Cause: ' + error.message); 244 }); 245} catch (error) { 246 let message = (error as BusinessError).message; 247 console.error('getBundleInstaller failed. Cause: ' + message); 248} 249``` 250## BundleInstaller.install 251install(hapFilePaths: Array<string>, callback: AsyncCallback<void>): void 252 253Installs a bundle. This API uses an asynchronous callback to return the result. 254 255**System API**: This is a system API. 256 257**Required permissions**: ohos.permission.INSTALL_BUNDLE, ohos.permission.INSTALL_ENTERPRISE_BUNDLE<sup>10+</sup>, ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE<sup>10+</sup>, or ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE<sup>10+</sup> 258> **NOTE** 259> 260> From API version 10, this API can be called with the permission **ohos.permission.INSTALL_ENTERPRISE_BUNDLE**, **ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE**, or **ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE**. 261> 262> To install an enterprise application, you must have the **ohos.permission.INSTALL_ENTERPRISE_BUNDLE** permission. 263> 264> To install an enterprise Normal application, you must have the **ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE** or **ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE** permission. 265> 266> To install an enterprise MDM application, you must have the **ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE** permission. 267> 268> To install a common application, you must have the **ohos.permission.INSTALL_BUNDLE** permission. 269> 270> To install a beta application, you must have the **ohos.permission.INSTALL_INTERNALTESTING_BUNDLE** permission. 271 272**System capability**: SystemCapability.BundleManager.BundleFramework.Core 273 274**Parameters** 275 276| Name | Type | Mandatory| Description | 277| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | 278| hapFilePaths | Array<string> | Yes | Paths where the HAP files of the bundle are stored, which are the data directories. If only one directory is passed, the HAP files in the directory must belong to the same bundle and have the same signature.| 279| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **null**; otherwise, **err** is an error object.| 280 281**Error codes** 282 283For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 284 285| ID| Error Message | 286| -------- | ------------------------------------------------------------ | 287| 201 | Calling interface without permission 'ohos.permission.INSTALL_BUNDLE' or 'ohos.permission.INSTALL_ENTERPRISE_BUNDLE' or 'ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE' or 'ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE'. | 288| 202 | Permission verification failed. A non-system application calls a system API. | 289| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 290| 17700010 | Failed to install the HAP because the HAP fails to be parsed. | 291| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. | 292| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. | 293| 17700015 | Failed to install the HAPs because they have different configuration information. | 294| 17700016 | Failed to install the HAP because of insufficient system disk space. | 295| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. | 296| 17700018 | Failed to install the HAP or HSP because the dependent module does not exist. | 297| 17700031 | Failed to install the HAP because the overlay check of the HAP failed. | 298| 17700036 | Failed to install the HSP due to the lack of required permission. | 299| 17700039 | Failed to install the HSP because installing a shared bundle specified by hapFilePaths is not allowed. | 300| 17700041 | Failed to install the HAP because the installation is forbidden by enterprise device management. | 301| 17700042 | Failed to install the HAP because of incorrect URI in the data proxy. | 302| 17700043 | Failed to install the HAP because of low APL in the non-system data proxy (required APL: system_basic or system_core). | 303| 17700044 | Failed to install the HAP because the isolationMode configured is not supported. | 304| 17700047 | Failed to install the HAP because the VersionCode to be updated is not greater than the current VersionCode. | 305| 17700048 | Failed to install the HAP because the code signature verification failed. | 306| 17700050 | Failed to install the HAP because an enterprise normal/MDM bundle cannot be installed on non-enterprise devices. | 307| 17700052 | Failed to install the HAP because a debug bundle can be installed only in developer mode. | 308| 17700054 | Failed to install the HAP because the HAP requests wrong permissions.| 309| 17700066 | Failed to install the HAP because installing the native package failed. | 310| 17700073 | Failed to install the HAP because an application with the same bundle name but different signature information exists on the device. | 311 312**Example** 313 314```ts 315import installer from '@ohos.bundle.installer'; 316import { BusinessError } from '@ohos.base'; 317 318let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; 319 320try { 321 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 322 data.install(hapFilePaths, (err: BusinessError) => { 323 if (err) { 324 console.error('install failed:' + err.message); 325 } else { 326 console.info('install successfully.'); 327 } 328 }); 329 }).catch((error: BusinessError) => { 330 console.error('getBundleInstaller failed. Cause: ' + error.message); 331 }); 332} catch (error) { 333 let message = (error as BusinessError).message; 334 console.error('getBundleInstaller failed. Cause: ' + message); 335} 336``` 337 338## BundleInstaller.install 339 340install(hapFilePaths: Array\<string\>, installParam?: InstallParam) : Promise\<void\> 341 342Installs a bundle. This API uses a promise to return the result. 343 344**System API**: This is a system API. 345 346**Required permissions**: ohos.permission.INSTALL_BUNDLE, ohos.permission.INSTALL_ENTERPRISE_BUNDLE<sup>10+</sup>, ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE<sup>10+</sup>, or ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE<sup>10+</sup> 347> **NOTE** 348> 349> From API version 10, this API can be called with the permission **ohos.permission.INSTALL_ENTERPRISE_BUNDLE**, **ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE**, or **ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE**. 350> 351> To install an enterprise application, you must have the **ohos.permission.INSTALL_ENTERPRISE_BUNDLE** permission. 352> 353> To install an enterprise Normal application, you must have the **ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE** or **ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE** permission. 354> 355> To install an enterprise MDM application, you must have the **ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE** permission. 356> 357> To install a common application, you must have the **ohos.permission.INSTALL_BUNDLE** permission. 358> 359> To install a beta application, you must have the **ohos.permission.INSTALL_INTERNALTESTING_BUNDLE** permission. 360 361**System capability**: SystemCapability.BundleManager.BundleFramework.Core 362 363**Parameters** 364 365| Name | Type | Mandatory| Description | 366| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ | 367| hapFilePaths | Array\<string\> | Yes | Paths where the HAP files of the bundle are stored, which are the data directories. If only one directory is passed, the HAP files in the directory must belong to the same bundle and have the same signature.| 368| installParam | [InstallParam](#installparam) | No | Parameters required for the installation. For details about their default values, see [InstallParam](#installparam). | 369 370**Return value** 371 372| Type | Description | 373| --------------- | -------------------------------------- | 374| Promise\<void\> | Promise that returns no value.| 375 376**Error codes** 377 378For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 379 380| ID| Error Message | 381| -------- | ------------------------------------------------------------ | 382| 201 | Calling interface without permission 'ohos.permission.INSTALL_BUNDLE' or 'ohos.permission.INSTALL_ENTERPRISE_BUNDLE' or 'ohos.permission.INSTALL_ENTERPRISE_MDM_BUNDLE' or 'ohos.permission.INSTALL_ENTERPRISE_NORMAL_BUNDLE'. | 383| 202 | Permission verification failed. A non-system application calls a system API. | 384| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter hapFiles is needed for code signature; 4. The size of specifiedDistributionType is greater than 128; 5. The size of additionalInfo is greater than 3000. | 385| 17700004 | The specified user ID is not found. | 386| 17700010 | Failed to install the HAP because the HAP fails to be parsed. | 387| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. | 388| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. | 389| 17700015 | Failed to install the HAPs because they have different configuration information. | 390| 17700016 | Failed to install the HAP because of insufficient system disk space. | 391| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. | 392| 17700018 | Failed to install the HAP or HSP because the dependent module does not exist. | 393| 17700031 | Failed to install the HAP because the overlay check of the HAP failed. | 394| 17700036 | Failed to install the HSP due to the lack of required permission. | 395| 17700039 | Failed to install the HSP because installing a shared bundle specified by hapFilePaths is not allowed. | 396| 17700041 | Failed to install the HAP because the installation is forbidden by enterprise device management. | 397| 17700042 | Failed to install the HAP because of incorrect URI in the data proxy. | 398| 17700043 | Failed to install the HAP because of low APL in the non-system data proxy (required APL: system_basic or system_core). | 399| 17700044 | Failed to install the HAP because the isolationMode configured is not supported. | 400| 17700047 | Failed to install the HAP because the VersionCode to be updated is not greater than the current VersionCode. | 401| 17700048 | Failed to install the HAP because the code signature verification failed. | 402| 17700050 | Failed to install the HAP because an enterprise normal/MDM bundle cannot be installed on non-enterprise devices. | 403| 17700052 | Failed to install the HAP because a debug bundle can be installed only in developer mode. | 404| 17700054 | Failed to install the HAP because the HAP requests wrong permissions.| 405| 17700066 | Failed to install the HAP because installing the native package failed. | 406| 17700073 | Failed to install the HAP because an application with the same bundle name but different signature information exists on the device. | 407 408**Example** 409 410```ts 411import installer from '@ohos.bundle.installer'; 412import { BusinessError } from '@ohos.base'; 413 414let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; 415let installParam: installer.InstallParam = { 416 userId: 100, 417 isKeepData: false, 418 installFlag: 1, 419}; 420 421try { 422 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 423 data.install(hapFilePaths, installParam) 424 .then((data: void) => { 425 console.info('install successfully: ' + JSON.stringify(data)); 426 }).catch((error: BusinessError) => { 427 console.error('install failed:' + error.message); 428 }); 429 }).catch((error: BusinessError) => { 430 console.error('getBundleInstaller failed. Cause: ' + error.message); 431 }); 432} catch (error) { 433 let message = (error as BusinessError).message; 434 console.error('getBundleInstaller failed. Cause: ' + message); 435} 436``` 437 438## BundleInstaller.uninstall 439 440uninstall(bundleName: string, installParam: InstallParam, callback: AsyncCallback<void>): void 441 442Uninstalls a bundle. This API uses an asynchronous callback to return the result. 443 444**System API**: This is a system API. 445 446**Required permissions**: ohos.permission.INSTALL_BUNDLE or ohos.permission.UNINSTALL_BUNDLE 447 448**System capability**: SystemCapability.BundleManager.BundleFramework.Core 449 450**Parameters** 451 452| Name | Type | Mandatory| Description | 453| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | 454| bundleName | string | Yes | Name of the target bundle. | 455| installParam | [InstallParam](#installparam) | Yes | Parameters required for the installation. | 456| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **null**; otherwise, **err** is an error object.| 457 458**Error codes** 459 460For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 461 462| ID| Error Message | 463| -------- | ------------------------------------------------------------ | 464| 201 | Calling interface without permission 'ohos.permission.INSTALL_BUNDLE' or 'ohos.permission.UNINSTALL_BUNDLE'. | 465| 202 | Permission verification failed. A non-system application calls a system API. | 466| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 467| 17700001 | The specified bundle name is not found. | 468| 17700004 | The specified user ID is not found. | 469| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. | 470| 17700040 | The specified bundle is a shared bundle which cannot be uninstalled. | 471| 17700045 | Failed to uninstall the HAP because the uninstall is forbidden by enterprise device management. | 472| 17700060 | The specified application cannot be uninstalled. | 473| 17700067 | Failed to uninstall the HAP because uninstalling the native package failed. | 474 475**Example** 476 477```ts 478import installer from '@ohos.bundle.installer'; 479import { BusinessError } from '@ohos.base'; 480 481let bundleName = 'com.ohos.demo'; 482let installParam: installer.InstallParam = { 483 userId: 100, 484 isKeepData: false, 485 installFlag: 1 486}; 487 488try { 489 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 490 data.uninstall(bundleName, installParam, (err: BusinessError) => { 491 if (err) { 492 console.error('uninstall failed:' + err.message); 493 } else { 494 console.info('uninstall successfully.'); 495 } 496 }); 497 }).catch((error: BusinessError) => { 498 console.error('getBundleInstaller failed. Cause: ' + error.message); 499 }); 500} catch (error) { 501 let message = (error as BusinessError).message; 502 console.error('getBundleInstaller failed. Cause: ' + message); 503} 504``` 505 506## BundleInstaller.uninstall 507 508uninstall(bundleName: string, callback: AsyncCallback<void>): void 509 510Uninstalls a bundle. This API uses an asynchronous callback to return the result. 511 512**System API**: This is a system API. 513 514**Required permissions**: ohos.permission.INSTALL_BUNDLE or ohos.permission.UNINSTALL_BUNDLE 515 516**System capability**: SystemCapability.BundleManager.BundleFramework.Core 517 518**Parameters** 519 520| Name | Type | Mandatory| Description | 521| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | 522| bundleName | string | Yes | Name of the target bundle. | 523| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **null**; otherwise, **err** is an error object.| 524 525**Error codes** 526 527For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 528 529| ID| Error Message | 530| -------- | ------------------------------------------------------------ | 531| 201 | Calling interface without permission 'ohos.permission.INSTALL_BUNDLE' or 'ohos.permission.UNINSTALL_BUNDLE'. | 532| 202 | Permission verification failed. A non-system application calls a system API. | 533| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 534| 17700001 | The specified bundle name is not found. | 535| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. | 536| 17700040 | The specified bundle is a shared bundle which cannot be uninstalled. | 537| 17700045 | Failed to uninstall the HAP because the uninstall is forbidden by enterprise device management. | 538| 17700060 | The specified application cannot be uninstalled. | 539| 17700067 | Failed to uninstall the HAP because uninstalling the native package failed. | 540 541**Example** 542 543```ts 544import installer from '@ohos.bundle.installer'; 545import { BusinessError } from '@ohos.base'; 546 547let bundleName = 'com.ohos.demo'; 548 549try { 550 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 551 data.uninstall(bundleName, (err: BusinessError) => { 552 if (err) { 553 console.error('uninstall failed:' + err.message); 554 } else { 555 console.info('uninstall successfully.'); 556 } 557 }); 558 }).catch((error: BusinessError) => { 559 console.error('getBundleInstaller failed. Cause: ' + error.message); 560 }); 561} catch (error) { 562 let message = (error as BusinessError).message; 563 console.error('getBundleInstaller failed. Cause: ' + message); 564} 565``` 566## BundleInstaller.uninstall 567 568uninstall(bundleName: string, installParam?: InstallParam) : Promise\<void\> 569 570Uninstalls a bundle. This API uses a promise to return the result. 571 572**System API**: This is a system API. 573 574**Required permissions**: ohos.permission.INSTALL_BUNDLE or ohos.permission.UNINSTALL_BUNDLE 575 576**System capability**: SystemCapability.BundleManager.BundleFramework.Core 577 578**Parameters** 579 580| Name | Type | Mandatory| Description | 581| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ | 582| bundleName | string | Yes | Name of the target bundle. | 583| installParam | [InstallParam](#installparam) | No | Parameters required for the installation. For details about their default values, see [InstallParam](#installparam). | 584 585**Return value** 586 587| Type | Description | 588| --------------- | -------------------------------------- | 589| Promise\<void\> | Promise that returns no value.| 590 591**Error codes** 592 593For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 594 595| ID| Error Message | 596| -------- | ------------------------------------------------------------ | 597| 201 | Calling interface without permission 'ohos.permission.INSTALL_BUNDLE' or 'ohos.permission.UNINSTALL_BUNDLE'. | 598| 202 | Permission verification failed. A non-system application calls a system API. | 599| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 600| 17700001 | The specified bundle name is not found. | 601| 17700004 | The specified user ID is not found. | 602| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. | 603| 17700040 | The specified bundle is a shared bundle which cannot be uninstalled. | 604| 17700045 | Failed to uninstall the HAP because the uninstall is forbidden by enterprise device management. | 605| 17700060 | The specified application cannot be uninstalled. | 606| 17700067 | Failed to uninstall the HAP because uninstalling the native package failed. | 607 608**Example** 609 610```ts 611import installer from '@ohos.bundle.installer'; 612import { BusinessError } from '@ohos.base'; 613 614let bundleName = 'com.ohos.demo'; 615let installParam: installer.InstallParam = { 616 userId: 100, 617 isKeepData: false, 618 installFlag: 1, 619}; 620 621try { 622 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 623 data.uninstall(bundleName, installParam) 624 .then((data: void) => { 625 console.info('uninstall successfully: ' + JSON.stringify(data)); 626 }).catch((error: BusinessError) => { 627 console.error('uninstall failed:' + error.message); 628 }); 629 }).catch((error: BusinessError) => { 630 console.error('getBundleInstaller failed. Cause: ' + error.message); 631 }); 632} catch (error) { 633 let message = (error as BusinessError).message; 634 console.error('getBundleInstaller failed. Cause: ' + message); 635} 636``` 637 638## BundleInstaller.recover 639 640recover(bundleName: string, installParam: InstallParam, callback: AsyncCallback<void>): void 641 642Rolls back a bundle to the initial installation state. This API uses an asynchronous callback to return the result. 643 644**System API**: This is a system API. 645 646**Required permissions**: ohos.permission.INSTALL_BUNDLE or ohos.permission.RECOVER_BUNDLE 647 648**System capability**: SystemCapability.BundleManager.BundleFramework.Core 649 650**Parameters** 651 652| Name | Type | Mandatory| Description | 653| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | 654| bundleName | string | Yes | Name of the target bundle. | 655| installParam | [InstallParam](#installparam) | Yes | Parameters required for the installation. | 656| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **null**; otherwise, **err** is an error object.| 657 658**Error codes** 659 660For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 661 662| ID| Error Message | 663| -------- | ----------------------------------- | 664| 201 | Calling interface without permission 'ohos.permission.INSTALL_BUNDLE' or 'ohos.permission.RECOVER_BUNDLE'. | 665| 202 | Permission verification failed. A non-system application calls a system API. | 666| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 667| 17700001 | The specified bundle name is not found. | 668| 17700004 | The specified user ID is not found. | 669| 17700058 | Failed to install the HAP because this application is prohibited from being installed on this device or by specified users. | 670| 17700073 | Failed to install the HAP because an application with the same bundle name but different signature information exists on the device. | 671 672**Example** 673 674```ts 675import installer from '@ohos.bundle.installer'; 676import { BusinessError } from '@ohos.base'; 677 678let bundleName = 'com.ohos.demo'; 679let installParam: installer.InstallParam = { 680 userId: 100, 681 isKeepData: false, 682 installFlag: 1 683}; 684 685try { 686 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 687 data.recover(bundleName, installParam, (err: BusinessError) => { 688 if (err) { 689 console.error('recover failed:' + err.message); 690 } else { 691 console.info('recover successfully.'); 692 } 693 }); 694 }).catch((error: BusinessError) => { 695 console.error('getBundleInstaller failed. Cause: ' + error.message); 696 }); 697} catch (error) { 698 let message = (error as BusinessError).message; 699 console.error('getBundleInstaller failed. Cause: ' + message); 700} 701``` 702 703 704## BundleInstaller.recover 705 706recover(bundleName: string, callback: AsyncCallback<void>): void 707 708Rolls back a bundle to the initial installation state. This API uses an asynchronous callback to return the result. 709 710**System API**: This is a system API. 711 712**Required permissions**: ohos.permission.INSTALL_BUNDLE or ohos.permission.RECOVER_BUNDLE 713 714**System capability**: SystemCapability.BundleManager.BundleFramework.Core 715 716**Parameters** 717 718| Name | Type | Mandatory| Description | 719| ---------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | 720| bundleName | string | Yes | Name of the target bundle. | 721| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **null**; otherwise, **err** is an error object.| 722 723**Error codes** 724 725For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 726 727| ID| Error Message | 728| -------- | ----------------------------------- | 729| 201 | Calling interface without permission 'ohos.permission.INSTALL_BUNDLE' or 'ohos.permission.RECOVER_BUNDLE'. | 730| 202 | Permission verification failed. A non-system application calls a system API. | 731| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 732| 17700001 | The specified bundle name is not found. | 733| 17700058 | Failed to install the HAP because this application is prohibited from being installed on this device or by specified users. | 734| 17700073 | Failed to install the HAP because an application with the same bundle name but different signature information exists on the device. | 735 736**Example** 737 738```ts 739import installer from '@ohos.bundle.installer'; 740import { BusinessError } from '@ohos.base'; 741 742let bundleName = 'com.ohos.demo'; 743 744try { 745 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 746 data.recover(bundleName, (err: BusinessError) => { 747 if (err) { 748 console.error('recover failed:' + err.message); 749 } else { 750 console.info('recover successfully.'); 751 } 752 }); 753 }).catch((error: BusinessError) => { 754 console.error('getBundleInstaller failed. Cause: ' + error.message); 755 }); 756} catch (error) { 757 let message = (error as BusinessError).message; 758 console.error('getBundleInstaller failed. Cause: ' + message); 759} 760``` 761 762## BundleInstaller.recover 763 764recover(bundleName: string, installParam?: InstallParam) : Promise\<void\> 765 766Rolls back a bundle to the initial installation state. This API uses a promise to return the result. 767 768**System API**: This is a system API. 769 770**Required permissions**: ohos.permission.INSTALL_BUNDLE or ohos.permission.RECOVER_BUNDLE 771 772**System capability**: SystemCapability.BundleManager.BundleFramework.Core 773 774**Parameters** 775 776| Name | Type | Mandatory| Description | 777| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ | 778| bundleName | string | Yes | Name of the target bundle. | 779| installParam | [InstallParam](#installparam) | No | Parameters required for the installation. For details about their default values, see [InstallParam](#installparam). | 780 781**Return value** 782 783| Type | Description | 784| --------------- | -------------------------------------- | 785| Promise\<void\> | Promise that returns no value.| 786 787**Error codes** 788 789For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 790 791| ID| Error Message | 792| -------- | ----------------------------------- | 793| 201 | Calling interface without permission 'ohos.permission.INSTALL_BUNDLE' or 'ohos.permission.RECOVER_BUNDLE'. | 794| 202 | Permission verification failed. A non-system application calls a system API. | 795| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 796| 17700001 | The specified bundle name is not found. | 797| 17700004 | The specified user ID is not found. | 798| 17700058 | Failed to install the HAP because this application is prohibited from being installed on this device or by specified users. | 799| 17700073 | Failed to install the HAP because an application with the same bundle name but different signature information exists on the device. | 800 801**Example** 802```ts 803import installer from '@ohos.bundle.installer'; 804import { BusinessError } from '@ohos.base'; 805 806let bundleName = 'com.ohos.demo'; 807let installParam: installer.InstallParam = { 808 userId: 100, 809 isKeepData: false, 810 installFlag: 1, 811}; 812 813try { 814 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 815 data.recover(bundleName, installParam) 816 .then((data: void) => { 817 console.info('recover successfully: ' + JSON.stringify(data)); 818 }).catch((error: BusinessError) => { 819 console.error('recover failed:' + error.message); 820 }); 821 }).catch((error: BusinessError) => { 822 console.error('getBundleInstaller failed. Cause: ' + error.message); 823 }); 824} catch (error) { 825 let message = (error as BusinessError).message; 826 console.error('getBundleInstaller failed. Cause: ' + message); 827} 828``` 829 830## BundleInstaller.uninstall<sup>10+</sup> 831 832uninstall(uninstallParam: UninstallParam, callback : AsyncCallback\<void\>) : void 833 834Uninstalls a shared bundle. This API uses an asynchronous callback to return the result. 835 836**System API**: This is a system API. 837 838**Required permissions**: ohos.permission.INSTALL_BUNDLE or ohos.permission.UNINSTALL_BUNDLE 839 840**System capability**: SystemCapability.BundleManager.BundleFramework.Core 841 842**Parameters** 843 844| Name | Type | Mandatory| Description | 845| -------------- | ----------------------------------- | ---- | -------------------------------------------------------- | 846| uninstallParam | [UninstallParam](#uninstallparam10) | Yes | Parameters required for the uninstall. | 847| callback | AsyncCallback<void> | Yes | Callback used to return the result. If the operation is successful, **err** is **null**; otherwise, **err** is an error object.| 848 849**Error codes** 850 851For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 852 853| ID| Error Message | 854| -------- | ------------------------------------------------------------ | 855| 201 | Calling interface without permission 'ohos.permission.INSTALL_BUNDLE' or 'ohos.permission.UNINSTALL_BUNDLE'. | 856| 202 | Permission verification failed. A non-system application calls a system API. | 857| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 858| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. | 859| 17700037 | The version of the shared bundle is dependent on other applications. | 860| 17700038 | The specified shared bundle does not exist. | 861 862**Example** 863 864```ts 865import installer from '@ohos.bundle.installer'; 866import { BusinessError } from '@ohos.base'; 867 868let uninstallParam: installer.UninstallParam = { 869 bundleName: "com.ohos.demo", 870}; 871 872try { 873 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 874 data.uninstall(uninstallParam, (err: BusinessError) => { 875 if (err) { 876 console.error('uninstall failed:' + err.message); 877 } else { 878 console.info('uninstall successfully.'); 879 } 880 }); 881 }).catch((error: BusinessError) => { 882 console.error('getBundleInstaller failed. Cause: ' + error.message); 883 }); 884} catch (error) { 885 let message = (error as BusinessError).message; 886 console.error('getBundleInstaller failed. Cause: ' + message); 887} 888``` 889 890## BundleInstaller.uninstall<sup>10+</sup> 891 892uninstall(uninstallParam: UninstallParam) : Promise\<void> 893 894Uninstalls a shared bundle. This API uses a promise to return the result. 895 896**System API**: This is a system API. 897 898**Required permissions**: ohos.permission.INSTALL_BUNDLE or ohos.permission.UNINSTALL_BUNDLE 899 900**System capability**: SystemCapability.BundleManager.BundleFramework.Core 901 902**Parameters** 903 904| Name | Type | Mandatory| Description | 905| -------------- | ----------------------------------- | ---- | ---------------------------- | 906| uninstallParam | [UninstallParam](#uninstallparam10) | Yes | Parameters required for the uninstall.| 907 908**Return value** 909 910| Type | Description | 911| ------------- | -------------------------------------- | 912| Promise\<void\> | Promise that returns no value.| 913 914**Error codes** 915 916For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 917 918| ID| Error Message | 919| -------- | ------------------------------------------------------------ | 920| 201 | Calling interface without permission 'ohos.permission.INSTALL_BUNDLE' or 'ohos.permission.UNINSTALL_BUNDLE'. | 921| 202 | Permission verification failed. A non-system application calls a system API. | 922| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 923| 17700020 | The specified bundle is pre-installed bundle which cannot be uninstalled. | 924| 17700037 | The version of the shared bundle is dependent on other applications. | 925| 17700038 | The specified shared bundle does not exist. | 926 927**Example** 928 929```ts 930import installer from '@ohos.bundle.installer'; 931import { BusinessError } from '@ohos.base'; 932 933let uninstallParam: installer.UninstallParam = { 934 bundleName: "com.ohos.demo", 935}; 936 937try { 938 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 939 data.uninstall(uninstallParam, (err: BusinessError) => { 940 if (err) { 941 console.error('uninstall failed:' + err.message); 942 } else { 943 console.info('uninstall successfully.'); 944 } 945 }); 946 }).catch((error: BusinessError) => { 947 console.error('getBundleInstaller failed. Cause: ' + error.message); 948 }); 949} catch (error) { 950 let message = (error as BusinessError).message; 951 console.error('getBundleInstaller failed. Cause: ' + message); 952} 953``` 954 955## BundleInstaller.addExtResource<sup>12+</sup> 956 957addExtResource(bundleName: string, filePaths: Array\<string>): Promise\<void>; 958 959Adds extended resources based on the specified bundle name and HSP file path. This API uses a promise to return the result. 960 961**System API**: This is a system API. 962 963**Required permissions**: ohos.permission.INSTALL_BUNDLE 964 965**System capability**: SystemCapability.BundleManager.BundleFramework.Core 966 967**Parameters** 968 969| Name | Type | Mandatory| Description | 970| -------------- | ----------------------------------- | ---- | ---------------------------- | 971| bundleName | string | Yes | Bundle name of the application to which extended resources are to be added.| 972| filePaths | Array\<string> | Yes | Path of the extended resources to be added.| 973 974**Return value** 975 976| Type | Description | 977| ------------- | -------------------------------------- | 978| Promise\<void> | that returns no value.| 979 980**Error codes** 981 982For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 983 984| ID| Error Message | 985| -------- | ------------------------------------------------------------ | 986| 201 | Permission denied. | 987| 202 | Permission verification failed. A non-system application calls a system API. | 988| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 989| 17700001 | The specified bundleName is not found. | 990| 17700301 | Failed to add extended resources. | 991 992**Example** 993 994```ts 995import installer from '@ohos.bundle.installer'; 996import hilog from '@ohos.hilog'; 997import { BusinessError } from '@ohos.base'; 998 999let bundleName : string = 'com.ohos.demo'; 1000let filePaths : Array<string> = ['/data/storage/el2/base/a.hsp']; 1001try { 1002 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 1003 data.addExtResource(bundleName, filePaths).then((data) => { 1004 hilog.info(0x0000, 'testTag', 'addExtResource successfully'); 1005 }).catch((err: BusinessError) => { 1006 hilog.error(0x0000, 'testTag', 'addExtResource failed. Cause: %{public}s', err.message); 1007 }); 1008 }).catch((error: BusinessError) => { 1009 console.error('getBundleInstaller failed. Cause: ' + error.message); 1010 }); 1011} catch (error) { 1012 let message = (error as BusinessError).message; 1013 console.error('getBundleInstaller failed. Cause: ' + message); 1014} 1015``` 1016 1017## BundleInstaller.removeExtResource<sup>12+</sup> 1018 1019removeExtResource(bundleName: string, moduleNames: Array\<string>): Promise\<void>; 1020 1021Removes extended resources based on the specified bundle name and HSP file path. This API uses a promise to return the result. 1022 1023**System API**: This is a system API. 1024 1025**Required permissions**: ohos.permission.INSTALL_BUNDLE or ohos.permission.UNINSTALL_BUNDLE 1026 1027**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1028 1029**Parameters** 1030 1031| Name | Type | Mandatory| Description | 1032| -------------- | ----------------------------------- | ---- | ---------------------------- | 1033| bundleName | string | Yes | Bundle name of the application for which extended resources are to be removed.| 1034| moduleNames | Array\<string> | Yes | Names of the modules whose extended resources are to be removed.| 1035 1036**Return value** 1037 1038| Type | Description | 1039| ------------- | -------------------------------------- | 1040| Promise\<void> | that returns no value.| 1041 1042**Error codes** 1043 1044For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1045 1046| ID| Error Message | 1047| -------- | ------------------------------------------------------------ | 1048| 201 | Permission denied. | 1049| 202 | Permission verification failed. A non-system application calls a system API. | 1050| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 1051| 17700001 | The specified bundleName is not found. | 1052| 17700302 | Failed to remove extended resources. | 1053 1054**Example** 1055 1056```ts 1057import installer from '@ohos.bundle.installer'; 1058import hilog from '@ohos.hilog'; 1059import { BusinessError } from '@ohos.base'; 1060 1061let bundleName : string = 'com.ohos.demo'; 1062let moduleNames : Array<string> = ['moduleTest']; 1063try { 1064 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 1065 data.removeExtResource(bundleName, moduleNames).then((data) => { 1066 hilog.info(0x0000, 'testTag', 'removeExtResource successfully'); 1067 }).catch((err: BusinessError) => { 1068 hilog.error(0x0000, 'testTag', 'removeExtResource failed. Cause: %{public}s', err.message); 1069 }); 1070 }).catch((error: BusinessError) => { 1071 console.error('getBundleInstaller failed. Cause: ' + error.message); 1072 }); 1073} catch (error) { 1074 let message = (error as BusinessError).message; 1075 console.error('getBundleInstaller failed. Cause: ' + message); 1076} 1077``` 1078 1079## BundleInstaller.updateBundleForSelf<sup>10+</sup> 1080 1081updateBundleForSelf(hapFilePaths: Array\<string\>, installParam: InstallParam, callback: AsyncCallback\<void\>): void 1082 1083Updates the current bundle. This API uses an asynchronous callback to return the result. It can be called only by enterprise MDM applications on enterprise devices, and the HAPs in **hapFilePaths** must belong to the current application. 1084 1085**System API**: This is a system API. 1086 1087**Required permissions**: ohos.permission.INSTALL_SELF_BUNDLE 1088 1089**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1090 1091**Parameters** 1092 1093| Name | Type | Mandatory| Description | 1094| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | 1095| hapFilePaths | Array<string> | Yes | Paths where the HAP files of the bundle are stored, which are the data directories. If only one directory is passed, the HAP files in the directory must belong to the same bundle and have the same signature.| 1096| installParam | [InstallParam](#installparam) | Yes | Parameters required for the installation. | 1097| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **null**; otherwise, **err** is an error object.| 1098 1099**Error codes** 1100 1101For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1102 1103| ID| Error Message | 1104| -------- | ------------------------------------------------------------ | 1105| 201 | Calling interface without permission 'ohos.permission.INSTALL_SELF_BUNDLE'. | 1106| 202 | Permission verification failed. A non-system application calls a system API. | 1107| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter hapFiles is needed for code signature; 4. The size of specifiedDistributionType is greater than 128; 5. The size of additionalInfo is greater than 3000. | 1108| 17700004 | The specified user ID is not found. | 1109| 17700010 | Failed to install the HAP because the HAP fails to be parsed. | 1110| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. | 1111| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. | 1112| 17700015 | Failed to install the HAPs because they have different configuration information. | 1113| 17700016 | Failed to install the HAP because of insufficient system disk space. | 1114| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. | 1115| 17700018 | Failed to install the HAP or HSP because the dependent module does not exist. | 1116| 17700039 | Failed to install the HSP because installing a shared bundle specified by hapFilePaths is not allowed. | 1117| 17700041 | Failed to install the HAP because the installation is forbidden by enterprise device management. | 1118| 17700042 | Failed to install the HAP because of incorrect URI in the data proxy. | 1119| 17700043 | Failed to install the HAP because of low APL in the non-system data proxy (required APL: system_basic or system_core). | 1120| 17700044 | Failed to install the HAP because the isolationMode configured is not supported. | 1121| 17700047 | Failed to install the HAP because the VersionCode to be updated is not greater than the current VersionCode. | 1122| 17700048 | Failed to install the HAP because the code signature verification failed. | 1123| 17700049 | Failed to install the HAP because the bundleName is different from the bundleName of the caller application. | 1124| 17700050 | Failed to install the HAP because an enterprise normal/MDM bundle cannot be installed on non-enterprise devices. | 1125| 17700051 | Failed to install the HAP because the distribution type of the caller application is not enterprise_mdm. | 1126 1127**Example** 1128 1129```ts 1130import installer from '@ohos.bundle.installer'; 1131import { BusinessError } from '@ohos.base'; 1132 1133let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; 1134let installParam: installer.InstallParam = { 1135 userId: 100, 1136 isKeepData: false, 1137 installFlag: 1, 1138}; 1139 1140try { 1141 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 1142 data.updateBundleForSelf(hapFilePaths, installParam, (err: BusinessError) => { 1143 if (err) { 1144 console.error('updateBundleForSelf failed:' + err.message); 1145 } else { 1146 console.info('updateBundleForSelf successfully.'); 1147 } 1148 }); 1149 }).catch((error: BusinessError) => { 1150 console.error('getBundleInstaller failed. Cause: ' + error.message); 1151 }); 1152} catch (error) { 1153 let message = (error as BusinessError).message; 1154 console.error('getBundleInstaller failed. Cause: ' + message); 1155} 1156``` 1157 1158## BundleInstaller.updateBundleForSelf<sup>10+</sup> 1159 1160updateBundleForSelf(hapFilePaths: Array\<string\>, callback: AsyncCallback\<void\>): void 1161 1162Updates the current bundle. This API uses an asynchronous callback to return the result. It can be called only by enterprise MDM applications on enterprise devices, and the HAPs in **hapFilePaths** must belong to the current application. 1163 1164**System API**: This is a system API. 1165 1166**Required permissions**: ohos.permission.INSTALL_SELF_BUNDLE 1167 1168**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1169 1170**Parameters** 1171 1172| Name | Type | Mandatory| Description | 1173| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | 1174| hapFilePaths | Array<string> | Yes | Paths where the HAP files of the bundle are stored, which are the data directories. If only one directory is passed, the HAP files in the directory must belong to the same bundle and have the same signature.| 1175| callback | AsyncCallback<void> | Yes| Callback used to return the result. If the operation is successful, **err** is **null**; otherwise, **err** is an error object.| 1176 1177**Error codes** 1178 1179For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1180 1181| ID| Error Message | 1182| -------- | ------------------------------------------------------------ | 1183| 201 | Calling interface without permission 'ohos.permission.INSTALL_SELF_BUNDLE'. | 1184| 202 | Permission verification failed. A non-system application calls a system API. | 1185| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 1186| 17700010 | Failed to install the HAP because the HAP fails to be parsed. | 1187| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. | 1188| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. | 1189| 17700015 | Failed to install the HAPs because they have different configuration information. | 1190| 17700016 | Failed to install the HAP because of insufficient system disk space. | 1191| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. | 1192| 17700018 | Failed to install the HAP or HSP because the dependent module does not exist. | 1193| 17700039 | Failed to install the HSP because installing a shared bundle specified by hapFilePaths is not allowed. | 1194| 17700041 | Failed to install the HAP because the installation is forbidden by enterprise device management. | 1195| 17700042 | Failed to install the HAP because of incorrect URI in the data proxy. | 1196| 17700043 | Failed to install the HAP because of low APL in the non-system data proxy (required APL: system_basic or system_core). | 1197| 17700044 | Failed to install the HAP because the isolationMode configured is not supported. | 1198| 17700047 | Failed to install the HAP because the VersionCode to be updated is not greater than the current VersionCode. | 1199| 17700048 | Failed to install the HAP because the code signature verification failed. | 1200| 17700049 | Failed to install the HAP because the bundleName is different from the bundleName of the caller application. | 1201| 17700050 | Failed to install the HAP because an enterprise normal/MDM bundle cannot be installed on non-enterprise devices. | 1202| 17700051 | Failed to install the HAP because the distribution type of the caller application is not enterprise_mdm. | 1203 1204**Example** 1205 1206```ts 1207import installer from '@ohos.bundle.installer'; 1208import { BusinessError } from '@ohos.base'; 1209 1210let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; 1211 1212try { 1213 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 1214 data.updateBundleForSelf(hapFilePaths, (err: BusinessError) => { 1215 if (err) { 1216 console.error('updateBundleForSelf failed:' + err.message); 1217 } else { 1218 console.info('updateBundleForSelf successfully.'); 1219 } 1220 }); 1221 }).catch((error: BusinessError) => { 1222 console.error('getBundleInstaller failed. Cause: ' + error.message); 1223 }); 1224} catch (error) { 1225 let message = (error as BusinessError).message; 1226 console.error('getBundleInstaller failed. Cause: ' + message); 1227} 1228``` 1229 1230## BundleInstaller.updateBundleForSelf<sup>10+</sup> 1231 1232updateBundleForSelf(hapFilePaths: Array\<string\>, installParam?: InstallParam): Promise\<void\> 1233 1234Updates the current bundle. This API uses a promise to return the result. It can be called only by enterprise MDM applications on enterprise devices, and the HAPs in **hapFilePaths** must belong to the current application. 1235 1236**System API**: This is a system API. 1237 1238**Required permissions**: ohos.permission.INSTALL_SELF_BUNDLE 1239 1240**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1241 1242**Parameters** 1243 1244| Name | Type | Mandatory| Description | 1245| --------------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ | 1246| hapFilePaths | Array<string> | Yes | Paths where the HAP files of the bundle are stored, which are the data directories. If only one directory is passed, the HAP files in the directory must belong to the same bundle and have the same signature.| 1247| installParam | [InstallParam](#installparam) | No | Parameters required for the installation. For details about their default values, see [InstallParam](#installparam). | 1248 1249**Return value** 1250 1251| Type | Description | 1252| ------------- | -------------------------------------- | 1253| Promise\<void\> | Promise that returns no value.| 1254 1255**Error codes** 1256 1257For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1258 1259| ID| Error Message | 1260| -------- | ------------------------------------------------------------ | 1261| 201 | Calling interface without permission 'ohos.permission.INSTALL_SELF_BUNDLE'. | 1262| 202 | Permission verification failed. A non-system application calls a system API. | 1263| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter hapFiles is needed for code signature; 4. The size of specifiedDistributionType is greater than 128; 5. The size of additionalInfo is greater than 3000. | 1264| 17700004 | The specified user ID is not found. | 1265| 17700010 | Failed to install the HAP because the HAP fails to be parsed. | 1266| 17700011 | Failed to install the HAP because the HAP signature fails to be verified. | 1267| 17700012 | Failed to install the HAP because the HAP path is invalid or the HAP is too large. | 1268| 17700015 | Failed to install the HAPs because they have different configuration information. | 1269| 17700016 | Failed to install the HAP because of insufficient system disk space. | 1270| 17700017 | Failed to install the HAP since the version of the HAP to install is too early. | 1271| 17700018 | Failed to install the HAP or HSP because the dependent module does not exist. | 1272| 17700039 | Failed to install the HSP because installing a shared bundle specified by hapFilePaths is not allowed. | 1273| 17700041 | Failed to install the HAP because the installation is forbidden by enterprise device management. | 1274| 17700042 | Failed to install the HAP because of incorrect URI in the data proxy. | 1275| 17700043 | Failed to install the HAP because of low APL in the non-system data proxy (required APL: system_basic or system_core). | 1276| 17700044 | Failed to install the HAP because the isolationMode configured is not supported. | 1277| 17700047 | Failed to install the HAP because the VersionCode to be updated is not greater than the current VersionCode. | 1278| 17700048 | Failed to install the HAP because the code signature verification failed. | 1279| 17700049 | Failed to install the HAP because the bundleName is different from the bundleName of the caller application. | 1280| 17700050 | Failed to install the HAP because an enterprise normal/MDM bundle cannot be installed on non-enterprise devices. | 1281| 17700051 | Failed to install the HAP because the distribution type of the caller application is not enterprise_mdm. | 1282 1283**Example** 1284 1285```ts 1286import installer from '@ohos.bundle.installer'; 1287import { BusinessError } from '@ohos.base'; 1288 1289let hapFilePaths = ['/data/storage/el2/base/haps/entry/files/']; 1290let installParam: installer.InstallParam = { 1291 userId: 100, 1292 isKeepData: false, 1293 installFlag: 1, 1294}; 1295 1296try { 1297 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 1298 data.updateBundleForSelf(hapFilePaths, installParam) 1299 .then((data: void) => { 1300 console.info('updateBundleForSelf successfully: ' + JSON.stringify(data)); 1301 }).catch((error: BusinessError) => { 1302 console.error('updateBundleForSelf failed:' + error.message); 1303 }); 1304 }).catch((error: BusinessError) => { 1305 console.error('getBundleInstaller failed. Cause: ' + error.message); 1306 }); 1307} catch (error) { 1308 let message = (error as BusinessError).message; 1309 console.error('getBundleInstaller failed. Cause: ' + message); 1310} 1311``` 1312 1313## BundleInstaller.uninstallUpdates<sup>12+</sup> 1314 1315uninstallUpdates(bundleName: string, installParam?: InstallParam): Promise\<void\>; 1316 1317Uninstalls and updates a pre-installed application and restores it to the initial installation status. This API uses a promise to return the result. 1318 1319**System API**: This is a system API. 1320 1321**Required permissions**: ohos.permission.INSTALL_BUNDLE or ohos.permission.RECOVER_BUNDLE 1322 1323**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1324 1325**Parameters** 1326 1327| Name | Type | Mandatory| Description | 1328| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ | 1329| bundleName | string | Yes | Name of the target bundle. | 1330| installParam | [InstallParam](#installparam) | No | Parameters required for the uninstall and update. For details about their default values, see [InstallParam](#installparam). The **userId** parameter cannot be specified. Calling this API will uninstall and update the application for all users.| 1331 1332**Return value** 1333 1334| Type | Description | 1335| --------------- | -------------------------------------- | 1336| Promise\<void\> | Promise that returns no value.| 1337 1338**Error codes** 1339 1340For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1341 1342| ID| Error Message | 1343| -------- | ----------------------------------- | 1344| 201 | Calling interface without permission 'ohos.permission.INSTALL_BUNDLE' or 'ohos.permission.UNINSTALL_BUNDLE'. | 1345| 202 | Permission verification failed. A non-system application calls a system API. | 1346| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 1347| 17700001 | The specified bundle name is not found. | 1348| 17700045 | Failed to uninstall the HAP because the uninstall is forbidden by enterprise device management. | 1349| 17700057 | Failed to uninstall updates because the HAP is not pre-installed. | 1350| 17700060 | The specified application cannot be uninstalled. | 1351| 17700067 | Failed to uninstall the HAP because uninstalling the native package failed. | 1352| 17700073 | Failed to install the HAP because an application with the same bundle name but different signature information exists on the device. | 1353 1354**Example** 1355 1356```ts 1357import installer from '@ohos.bundle.installer'; 1358import { BusinessError } from '@ohos.base'; 1359 1360let bundleName = 'com.ohos.camera'; 1361let installParam: installer.InstallParam = { 1362 isKeepData: true, 1363 installFlag: 1, 1364}; 1365 1366try { 1367 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 1368 data.uninstallUpdates(bundleName, installParam) 1369 .then(() => { 1370 console.info('uninstallUpdates successfully.'); 1371 }).catch((error: BusinessError) => { 1372 console.error('uninstallUpdates failed:' + error.message); 1373 }); 1374 }).catch((error: BusinessError) => { 1375 console.error('getBundleInstaller failed. Cause: ' + error.message); 1376 }); 1377} catch (error) { 1378 let message = (error as BusinessError).message; 1379 console.error('getBundleInstaller failed. Cause: ' + message); 1380} 1381``` 1382 1383## BundleInstaller.createAppClone<sup>12+</sup> 1384 1385createAppClone(bundleName: string, createAppCloneParam?: CreateAppCloneParam): Promise\<number\>; 1386 1387Creates an application clone. This API uses a promise to return the result. 1388 1389**System API**: This is a system API. 1390 1391**Required permissions**: ohos.permission.INSTALL_CLONE_BUNDLE 1392 1393**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1394 1395**Parameters** 1396 1397| Name | Type | Mandatory| Description | 1398| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ | 1399| bundleName | string | Yes | Bundle name of the application for which a clone is to be created. | 1400| createAppCloneParam | [createAppCloneParam](#createappcloneparam12) | No | Other parameters required for creating the clone. For details about the default values of these parameters, see [createAppCloneParam](#createappcloneparam12). | 1401 1402**Return value** 1403 1404| Type | Description | 1405| --------------- | -------------------------------------- | 1406| Promise\<number\> | Promise used to return the index of the application clone.| 1407 1408**Error codes** 1409 1410For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1411 1412| ID| Error Message | 1413| -------- | ----------------------------------- | 1414| 201 | Calling interface without permission 'ohos.permission.INSTALL_CLONE_BUNDLE'. | 1415| 202 | Permission verification failed. A non-system application calls a system API. | 1416| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 1417| 17700001 | The specified bundleName cannot be found or the bundle is not installed by the specified user. | 1418| 17700004 | The userId is invalid. | 1419| 17700061 | The appIndex is not in valid range or already exists. | 1420| 17700069 | The app does not support the creation of an appClone instance. | 1421 1422**Example** 1423```ts 1424import installer from '@ohos.bundle.installer'; 1425import { BusinessError } from '@ohos.base'; 1426 1427let bundleName = 'com.ohos.camera'; 1428let createAppCloneParam: installer.CreateAppCloneParam = { 1429 userId: 100, 1430 appIndex: 1, 1431}; 1432 1433try { 1434 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 1435 data.createAppClone(bundleName, createAppCloneParam) 1436 .then(() => { 1437 console.info('createAppClone successfully.'); 1438 }).catch((error: BusinessError) => { 1439 console.error('createAppClone failed:' + error.message); 1440 }); 1441 }).catch((error: BusinessError) => { 1442 console.error('getBundleInstaller failed. Cause: ' + error.message); 1443 }); 1444} catch (error) { 1445 let message = (error as BusinessError).message; 1446 console.error('getBundleInstaller failed. Cause: ' + message); 1447} 1448``` 1449 1450## BundleInstaller.destroyAppClone<sup>12+</sup> 1451 1452destroyAppClone(bundleName: string, appIndex: number, userId?: number): Promise\<void\>; 1453 1454Destroys an application clone. This API uses a promise to return the result. 1455 1456**System API**: This is a system API. 1457 1458**Required permissions**: ohos.permission.UNINSTALL_CLONE_BUNDLE 1459 1460**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1461 1462**Parameters** 1463 1464| Name | Type | Mandatory| Description | 1465| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ | 1466| bundleName | string | Yes | Bundle name of the application for which a clone is to be destroyed. | 1467| appIndex | number | Yes | Index of the clone to destroy. | 1468| userId | number | No | ID of the user to whom the clone to destroy belongs. The default value is the user ID of the caller. | 1469 1470**Return value** 1471 1472| Type | Description | 1473| --------------- | -------------------------------------- | 1474| Promise\<void\> | Promise that returns no value.| 1475 1476**Error codes** 1477 1478For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1479 1480| ID| Error Message | 1481| -------- | ----------------------------------- | 1482| 201 | Calling interface without permission 'ohos.permission.UNINSTALL_CLONE_BUNDLE'. | 1483| 202 | Permission verification failed. A non-system application calls a system API. | 1484| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 1485| 17700001 | The specified bundleName cannot be found or the bundle is not installed by the specified user. | 1486| 17700004 | The userId is invalid. | 1487| 17700061 | The appIndex is invalid. | 1488 1489**Example** 1490```ts 1491import installer from '@ohos.bundle.installer'; 1492import { BusinessError } from '@ohos.base'; 1493 1494let bundleName = 'com.ohos.camera'; 1495let index = 1; 1496let userId = 100; 1497 1498try { 1499 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 1500 data.destroyAppClone(bundleName, index, userId) 1501 .then(() => { 1502 console.info('destroyAppClone successfully.'); 1503 }).catch((error: BusinessError) => { 1504 console.error('destroyAppClone failed:' + error.message); 1505 }); 1506 }).catch((error: BusinessError) => { 1507 console.error('getBundleInstaller failed. Cause: ' + error.message); 1508 }); 1509} catch (error) { 1510 let message = (error as BusinessError).message; 1511 console.error('getBundleInstaller failed. Cause: ' + message); 1512} 1513``` 1514 1515## BundleInstaller.installPreexistingApp<sup>12+</sup> 1516 1517installPreexistingApp(bundleName: string, userId?: number): Promise\<void\>; 1518 1519Installs a bundle. This API uses a promise to return the result. 1520 1521**System API**: This is a system API. 1522 1523**Required permissions**: ohos.permission.INSTALL_BUNDLE 1524 1525**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1526 1527**Parameters** 1528 1529| Name | Type | Mandatory| Description | 1530| ------------ | ----------------------------- | ---- | ------------------------------------------------------------ | 1531| bundleName | string | Yes | Bundle name of the application to install. | 1532| userId | number | No | ID of the user for whom the application is to be installed. The value must be greater than 0. The default value is the user ID of the caller. | 1533 1534**Return value** 1535 1536| Type | Description | 1537| --------------- | -------------------------------------- | 1538| Promise\<void\> | Promise that returns no value.| 1539 1540**Error codes** 1541 1542For details about the error codes, see [Universal Error Codes](../errorcode-universal.md) and [Bundle Error Codes](errorcode-bundle.md). 1543 1544| ID| Error Message | 1545| -------- | ----------------------------------- | 1546| 201 | Calling interface without permission 'ohos.permission.INSTALL_BUNDLE'. | 1547| 202 | Permission verification failed. A non-system application calls a system API. | 1548| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types.| 1549| 17700001 | The specified bundleName cannot be found. | 1550| 17700004 | The userId is invalid. | 1551| 17700071 | It is not allowed to install the enterprise bundle. | 1552| 17700058 | Failed to install the HAP because this application is prohibited from being installed on this device or by specified users. | 1553 1554**Example** 1555```ts 1556import installer from '@ohos.bundle.installer'; 1557import { BusinessError } from '@ohos.base'; 1558 1559let bundleName = 'com.ohos.camera'; 1560let userId = 100; 1561 1562try { 1563 installer.getBundleInstaller().then((data: installer.BundleInstaller) => { 1564 data.installPreexistingApp(bundleName, userId) 1565 .then(() => { 1566 console.info('installPreexistingApp successfully.'); 1567 }).catch((error: BusinessError) => { 1568 console.error('installPreexistingApp failed:' + error.message); 1569 }); 1570 }).catch((error: BusinessError) => { 1571 console.error('getBundleInstaller failed. Cause: ' + error.message); 1572 }); 1573} catch (error) { 1574 let message = (error as BusinessError).message; 1575 console.error('getBundleInstaller failed. Cause: ' + message); 1576} 1577``` 1578 1579## HashParam 1580 1581Defines the hash parameters for bundle installation and uninstall. 1582 1583 **System capability**: SystemCapability.BundleManager.BundleFramework.Core 1584 1585 **System API**: This is a system API. 1586 1587| Name | Type | Mandatory| Description | 1588| ---------- | ------ | ---------------- | ---------------- | 1589| moduleName | string | Yes| Module name of the bundle.| 1590| hashValue | string | Yes| Hash value. | 1591 1592## InstallParam 1593 1594Defines the parameters that need to be specified for bundle installation, uninstall, or recovering. 1595 1596 **System capability**: SystemCapability.BundleManager.BundleFramework.Core 1597 1598 **System API**: This is a system API. 1599 1600| Name | Type | Mandatory | Description | 1601| ------------------------------ | ------------------------------ | ------------------ | ------------------ | 1602| userId | number | No | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0. You can call [queryOsAccountLocalIdFromProcess](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9) to obtain the user ID of the current process. When a driver application is installed, uninstalled, or restored, this parameter is ignored and the operation is executed for all users.| 1603| installFlag | number | No | Installation flag. The value **0x00** means initial installation, **0x01** means overwrite installation, and **0x10** means installation-free. The default value is **0x00**.| 1604| isKeepData | boolean | No | Whether to retain the data directory during bundle uninstall. The default value is **false**.| 1605| hashParams | Array<[HashParam](#hashparam)> | No| Hash parameters. By default, no value is passed. | 1606| crowdtestDeadline| number | No | End date of crowdtesting. The default value is **-1**, indicating that no end date is specified for crowdtesting.| 1607| sharedBundleDirPaths<sup>10+</sup> | Array\<String> | No|Paths of the shared bundle files. By default, no value is passed.| 1608| specifiedDistributionType<sup>10+</sup> | string | No|Distribution type specified during application installation. By default, no value is passed. The maximum length is 128 bytes. This field is usually specified by the application market of the operating system operator.| 1609| additionalInfo<sup>10+</sup> | string | No|Additional information during application installation (usually an enterprise application). By default, no value is passed. The maximum length is 3,000 bytes. This field is usually specified by the application market of the operating system operator.| 1610| verifyCodeParams<sup>deprecated<sup> | Array<[VerifyCodeParam](#verifycodeparamdeprecated)> | No| Information about the code signature file. The default value is null. | 1611| pgoParams<sup>11+</sup> | Array<[PGOParam](#pgoparam11)> | No| Parameters of the Profile-guided Optimization (PGO) configuration file. The default value is null. | 1612 1613## UninstallParam<sup>10+</sup> 1614 1615Defines the parameters required for the uninstall of a shared bundle. 1616 1617 **System capability**: SystemCapability.BundleManager.BundleFramework.Core 1618 1619 **System API**: This is a system API. 1620 1621| Name | Type | Mandatory| Description | 1622| ----------- | ------ | ---- | ------------------------------------------------------------ | 1623| bundleName | string | Yes | Name of the shared bundle. | 1624| versionCode | number | No | Version number of the shared bundle. By default, no value is passed, and all shared bundles of the specified name are uninstalled.| 1625 1626## VerifyCodeParam<sup>deprecated<sup> 1627 1628> Since API version 11, the code signature file of an application is integrated into the installation package, rather than being specified by using this field. 1629 1630Defines the information about the code signature file. 1631 1632 **System capability**: SystemCapability.BundleManager.BundleFramework.Core 1633 1634 **System API**: This is a system API. 1635 1636| Name | Type | Mandatory| Description | 1637| ---------- | ------ | ---------------- | ---------------- | 1638| moduleName | string | Yes| Module name of the bundle.| 1639| signatureFilePath | string | Yes| Path of the code signature file. | 1640 1641## PGOParam<sup>11+</sup> 1642 1643Defines the parameters of the PGO configuration file. 1644 1645 **System capability**: SystemCapability.BundleManager.BundleFramework.Core 1646 1647 **System API**: This is a system API. 1648 1649| Name | Type | Mandatory| Description | 1650| ---------- | ------ | ---------------- | ---------------- | 1651| moduleName | string | Yes| Module name of the bundle.| 1652| pgoFilePath | string | Yes| Path of the PGO configuration file. | 1653 1654## CreateAppCloneParam<sup>12+</sup> 1655 1656Describes the parameters used for creating an application clone. 1657 1658**System capability**: SystemCapability.BundleManager.BundleFramework.Core 1659 1660**System API**: This is a system API. 1661 1662| Name | Type | Mandatory| Description | 1663| ----------- | ------ | ---- | ------------------------------------------------------------ | 1664| userId | number | No | ID of the user for whom the clone is created. The default value is the user ID of the caller. | 1665| appIndex | number | No | Index of the clone. The default value is the currently available minimum index. | 1666