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