1# @ohos.enterprise.bundleManager (Bundle Management) 2 3The **bundleManager** module provides APIs for bundle management, including adding, obtaining, and removing a list of bundles that are allowed to install. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> 9> The APIs of this module can be used only in the stage model. 10> 11> The APIs of this module can be called only by a [device administrator application](../../mdm/mdm-kit-guide.md#introduction) that is enabled. 12 13## Modules to Import 14 15```ts 16import { bundleManager } from '@kit.MDMKit'; 17``` 18 19## bundleManager.addAllowedInstallBundlesSync 20 21addAllowedInstallBundlesSync(admin: Want, appIds: Array<string>, accountId?: number): void 22 23Adds the applications that can be installed by the current or specified user through the specified device administrator application. 24 25**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 26 27**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 28 29 30**Parameters** 31 32| Name | Type | Mandatory| Description | 33| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 34| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 35| appIds | Array<string> | Yes | IDs of the applications to add. | 36| accountId | number | No | User ID, which must be greater than or equal to 0.<br>- If **accountId** is passed in, this API applies to the specified user.<br>- If **accountId** is not passed in, this API applies to the current user.| 37 38**Error codes** 39 40For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 41 42| ID| Error Message | 43| -------- | ------------------------------------------------------------ | 44| 9200001 | The application is not an administrator application of the device. | 45| 9200002 | The administrator application does not have permission to manage the device. | 46| 201 | Permission verification failed. The application does not have the permission required to call the API. | 47| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 48 49**Example** 50 51```ts 52import { Want } from '@kit.AbilityKit'; 53import { BusinessError } from '@kit.BasicServicesKit'; 54let wantTemp: Want = { 55 bundleName: 'com.example.myapplication', 56 abilityName: 'EntryAbility', 57}; 58let appIds: Array<string> = ['com.example.myapplication']; 59 60try { 61 bundleManager.addAllowedInstallBundlesSync(wantTemp, appIds, 100); 62 console.info('Succeeded in adding allowed install bundles.'); 63} catch (err) { 64 console.error(`Failed to add allowed install bundles. Code is ${err.code}, message is ${err.message}`); 65} 66``` 67 68## bundleManager.removeAllowedInstallBundlesSync 69 70removeAllowedInstallBundlesSync(admin: Want, appIds: Array<string>, accountId?: number): void 71 72Removes the applications that can be installed by the current or specified user through the specified device administrator application. 73 74**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 75 76**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 77 78 79**Parameters** 80 81| Name | Type | Mandatory| Description | 82| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 83| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 84| appIds | Array<string> | Yes | IDs of the applications to remove. | 85| accountId | number | No | User ID, which must be greater than or equal to 0.<br>- If **accountId** is passed in, this API applies to the specified user.<br>- If **accountId** is not passed in, this API applies to the current user.| 86 87**Error codes** 88 89For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 90 91| ID| Error Message | 92| -------- | ------------------------------------------------------------ | 93| 9200001 | The application is not an administrator application of the device. | 94| 9200002 | The administrator application does not have permission to manage the device. | 95| 201 | Permission verification failed. The application does not have the permission required to call the API. | 96| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 97 98**Example** 99 100```ts 101import { Want } from '@kit.AbilityKit'; 102import { BusinessError } from '@kit.BasicServicesKit'; 103let wantTemp: Want = { 104 bundleName: 'com.example.myapplication', 105 abilityName: 'EntryAbility', 106}; 107let appIds: Array<string> = ['com.example.myapplication']; 108 109try { 110 bundleManager.removeAllowedInstallBundlesSync(wantTemp, appIds, 100); 111 console.info('Succeeded in removing allowed install bundles.'); 112} catch (err) { 113 console.error(`Failed to remove allowed install bundles. Code is ${err.code}, message is ${err.message}`); 114} 115``` 116 117## bundleManager.getAllowedInstallBundlesSync 118 119getAllowedInstallBundlesSync(admin: Want, accountId?: number): Array<string> 120 121Obtains the applications that can be installed by the current or specified user through the specified device administrator application. 122 123**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 124 125**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 126 127 128**Parameters** 129 130| Name | Type | Mandatory| Description | 131| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 132| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 133| accountId | number | No | User ID, which must be greater than or equal to 0.<br>- If **accountId** is passed in, this API applies to the specified user.<br>- If **accountId** is not passed in, this API applies to the current user.| 134 135**Return value** 136 137| Type | Description | 138| ------------------- | ------------------------------ | 139| Array<string> | Applications that can be installed by the user.| 140 141**Error codes** 142 143For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 144 145| ID| Error Message | 146| -------- | ------------------------------------------------------------ | 147| 9200001 | The application is not an administrator application of the device. | 148| 9200002 | The administrator application does not have permission to manage the device. | 149| 201 | Permission verification failed. The application does not have the permission required to call the API. | 150| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 151 152**Example** 153 154```ts 155import { Want } from '@kit.AbilityKit'; 156let wantTemp: Want = { 157 bundleName: 'com.example.myapplication', 158 abilityName: 'EntryAbility', 159}; 160 161try { 162 let result: Array<string> = bundleManager.getAllowedInstallBundlesSync(wantTemp, 100); 163 console.info(`Succeeded in getting allowed install bundles, result : ${JSON.stringify(result)}`); 164} catch (err) { 165 console.error(`Failed to get allowed install bundles. Code is ${err.code}, message is ${err.message}`); 166} 167``` 168 169## bundleManager.addDisallowedInstallBundlesSync 170 171addDisallowedInstallBundlesSync(admin: Want, appIds: Array<string>, accountId?: number): void 172 173Adds the applications that cannot be installed by the current or specified user through the specified device administrator application. 174 175**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 176 177**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 178 179**Parameters** 180 181| Name | Type | Mandatory| Description | 182| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 183| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 184| appIds | Array<string> | Yes | IDs of the applications to add. | 185| accountId | number | No | User ID, which must be greater than or equal to 0.<br>- If **accountId** is passed in, this API applies to the specified user.<br>- If **accountId** is not passed in, this API applies to the current user.| 186 187**Error codes** 188 189For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 190 191| ID| Error Message | 192| -------- | ------------------------------------------------------------ | 193| 9200001 | The application is not an administrator application of the device. | 194| 9200002 | The administrator application does not have permission to manage the device. | 195| 201 | Permission verification failed. The application does not have the permission required to call the API. | 196| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 197 198**Example** 199 200```ts 201import { Want } from '@kit.AbilityKit'; 202import { BusinessError } from '@kit.BasicServicesKit'; 203let wantTemp: Want = { 204 bundleName: 'com.example.myapplication', 205 abilityName: 'EntryAbility', 206}; 207let appIds: Array<string> = ['com.example.myapplication']; 208 209try { 210 bundleManager.addDisallowedInstallBundlesSync(wantTemp, appIds, 100); 211 console.info('Succeeded in adding disallowed install bundles.'); 212} catch (err) { 213 console.error(`Failed to add disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 214} 215``` 216 217## bundleManager.removeDisallowedInstallBundlesSync 218 219removeDisallowedInstallBundlesSync(admin: Want, appIds: Array<string>, accountId?: number): void 220 221Removes the applications that cannot be installed by the current or specified user through the specified device administrator application. 222 223**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 224 225**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 226 227**Parameters** 228 229| Name | Type | Mandatory| Description | 230| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 231| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 232| appIds | Array<string> | Yes | IDs of the applications to remove. | 233| accountId | number | No | User ID, which must be greater than or equal to 0.<br>- If **accountId** is passed in, this API applies to the specified user.<br>- If **accountId** is not passed in, this API applies to the current user.| 234 235**Error codes** 236 237For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 238 239| ID| Error Message | 240| -------- | ------------------------------------------------------------ | 241| 9200001 | The application is not an administrator application of the device. | 242| 9200002 | The administrator application does not have permission to manage the device. | 243| 201 | Permission verification failed. The application does not have the permission required to call the API. | 244| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 245 246**Example** 247 248```ts 249import { Want } from '@kit.AbilityKit'; 250import { BusinessError } from '@kit.BasicServicesKit'; 251let wantTemp: Want = { 252 bundleName: 'com.example.myapplication', 253 abilityName: 'EntryAbility', 254}; 255let appIds: Array<string> = ['com.example.myapplication']; 256 257try { 258 bundleManager.removeDisallowedInstallBundlesSync(wantTemp, appIds, 100) 259 console.info('Succeeded in removing disallowed install bundles.'); 260} catch (err) { 261 console.error(`Failed to remove disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 262} 263``` 264 265## bundleManager.getDisallowedInstallBundlesSync 266 267getDisallowedInstallBundlesSync(admin: Want, accountId?: number): Array<string> 268 269Obtains the applications that cannot be installed by the current or specified user through the specified device administrator application. 270 271**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 272 273**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 274 275 276**Parameters** 277 278| Name | Type | Mandatory| Description | 279| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 280| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 281| accountId | number | No | User ID, which must be greater than or equal to 0.<br>- If **accountId** is passed in, this API applies to the specified user.<br>- If **accountId** is not passed in, this API applies to the current user.| 282 283**Return value** 284 285| Type | Description | 286| ------------------- | ------------------------------ | 287| Array<string> | Applications that cannot be installed by the user.| 288 289**Error codes** 290 291For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 292 293| ID| Error Message | 294| -------- | ------------------------------------------------------------ | 295| 9200001 | The application is not an administrator application of the device. | 296| 9200002 | The administrator application does not have permission to manage the device. | 297| 201 | Permission verification failed. The application does not have the permission required to call the API. | 298| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 299 300**Example** 301 302```ts 303import { Want } from '@kit.AbilityKit'; 304let wantTemp: Want = { 305 bundleName: 'com.example.myapplication', 306 abilityName: 'EntryAbility', 307}; 308 309try { 310 let result: Array<string> = bundleManager.getDisallowedInstallBundlesSync(wantTemp, 100); 311 console.info(`Succeeded in getting disallowed install bundles, result : ${JSON.stringify(result)}`); 312} catch (err) { 313 console.error(`Failed to get disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 314} 315``` 316 317## bundleManager.addDisallowedUninstallBundlesSync 318 319addDisallowedUninstallBundlesSync(admin: Want, appIds: Array<string>, accountId?: number): void 320 321Adds the applications that cannot be uninstalled by the current or specified user through the specified device administrator application. 322 323**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 324 325**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 326 327 328**Parameters** 329 330| Name | Type | Mandatory| Description | 331| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 332| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 333| appIds | Array<string> | Yes | IDs of the applications to add. | 334| accountId | number | No | User ID, which must be greater than or equal to 0.<br>- If **accountId** is passed in, this API applies to the specified user.<br>- If **accountId** is not passed in, this API applies to the current user.| 335 336**Error codes** 337 338For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 339 340| ID| Error Message | 341| -------- | ------------------------------------------------------------ | 342| 9200001 | The application is not an administrator application of the device. | 343| 9200002 | The administrator application does not have permission to manage the device. | 344| 201 | Permission verification failed. The application does not have the permission required to call the API. | 345| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 346 347**Example** 348 349```ts 350import { Want } from '@kit.AbilityKit'; 351let wantTemp: Want = { 352 bundleName: 'com.example.myapplication', 353 abilityName: 'EntryAbility', 354}; 355let appIds: Array<string> = ['com.example.myapplication']; 356 357try { 358 bundleManager.addDisallowedUninstallBundlesSync(wantTemp, appIds, 100); 359 console.info('Succeeded in adding disallowed uninstall bundles.'); 360} catch (err) { 361 console.error(`Failed to add disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 362} 363``` 364 365## bundleManager.removeDisallowedUninstallBundlesSync 366 367removeDisallowedUninstallBundlesSync(admin: Want, appIds: Array<string>, accountId?: number): void 368 369Removes the applications that cannot be uninstalled by the current or specified user through the specified device administrator application. 370 371**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 372 373**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 374 375 376**Parameters** 377 378| Name | Type | Mandatory| Description | 379| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 380| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 381| appIds | Array<string> | Yes | IDs of the applications to remove. | 382| accountId | number | No | User ID, which must be greater than or equal to 0.<br>- If **accountId** is passed in, this API applies to the specified user.<br>- If **accountId** is not passed in, this API applies to the current user.| 383 384**Error codes** 385 386For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 387 388| ID| Error Message | 389| -------- | ------------------------------------------------------------ | 390| 9200001 | The application is not an administrator application of the device. | 391| 9200002 | The administrator application does not have permission to manage the device. | 392| 201 | Permission verification failed. The application does not have the permission required to call the API. | 393| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 394 395**Example** 396 397```ts 398import { Want } from '@kit.AbilityKit'; 399let wantTemp: Want = { 400 bundleName: 'com.example.myapplication', 401 abilityName: 'EntryAbility', 402}; 403let appIds: Array<string> = ['com.example.myapplication']; 404 405try { 406 bundleManager.removeDisallowedUninstallBundlesSync(wantTemp, appIds, 100); 407 console.info('Succeeded in removing disallowed uninstall bundles.'); 408} catch (err) { 409 console.error(`Failed to remove disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 410} 411``` 412 413## bundleManager.getDisallowedUninstallBundlesSync 414 415getDisallowedUninstallBundlesSync(admin: Want, accountId?: number): Array<string> 416 417Obtains the applications that cannot be uninstalled by the current or specified user through the specified device administrator application. 418 419**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 420 421**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 422 423 424**Parameters** 425 426| Name | Type | Mandatory| Description | 427| --------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 428| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 429| accountId | number | No | User ID, which must be greater than or equal to 0.<br>- If **accountId** is passed in, this API applies to the specified user.<br>- If **accountId** is not passed in, this API applies to the current user.| 430 431**Return value** 432 433| Type | Description | 434| ------------------- | ------------------------------ | 435| Array<string> | Applications that cannot be uninstalled by the user.| 436 437**Error codes** 438 439For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 440 441| ID| Error Message | 442| -------- | ------------------------------------------------------------ | 443| 9200001 | The application is not an administrator application of the device. | 444| 9200002 | The administrator application does not have permission to manage the device. | 445| 201 | Permission verification failed. The application does not have the permission required to call the API. | 446| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 447 448**Example** 449 450```ts 451import { Want } from '@kit.AbilityKit'; 452let wantTemp: Want = { 453 bundleName: 'com.example.myapplication', 454 abilityName: 'EntryAbility', 455}; 456 457try { 458 let result: Array<String> = bundleManager.getDisallowedUninstallBundlesSync(wantTemp, 100); 459 console.info(`Succeeded in getting disallowed uninstall bundles, result : ${JSON.stringify(result)}`); 460} catch (err) { 461 console.error(`Failed to get disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 462} 463``` 464 465## bundleManager.uninstall 466 467uninstall(admin: Want, bundleName: string, userId?: number, isKeepData?: boolean): Promise<void> 468 469Uninstalls an application of the current or specified user through the specified device administrator application. The **isKeepData** parameter specifies whether to retain the bundle data. This API uses a promise to return the result. 470 471**Required permissions**: ohos.permission.ENTERPRISE_INSTALL_BUNDLE 472 473**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 474 475 476**Parameters** 477 478| Name | Type | Mandatory| Description | 479| ---------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ | 480| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 481| bundleName | string | Yes | Name of the bundle to uninstall. | 482| userId | number | No | User ID, which must be greater than or equal to 0.<br>- If **userId** is passed in, this API applies to the specified user.<br>- If **userId** is not passed in, this API applies to the current user.| 483| isKeepData | boolean | No | Whether to retain the bundle data. The value **true** means to retain the bundle data; the value **false** means the opposite. | 484 485**Return value** 486 487| Type | Description | 488| ------------------- | ----------------------------------------------------- | 489| Promise<void> | Promise that returns no value. An error object will be thrown if the application fails to be uninstalled.| 490 491**Error codes** 492 493For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 494 495| ID| Error Message | 496| -------- | ------------------------------------------------------------ | 497| 9200001 | The application is not an administrator application of the device. | 498| 9200002 | The administrator application does not have permission to manage the device. | 499| 201 | Permission verification failed. The application does not have the permission required to call the API. | 500| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 501 502**Example** 503 504```ts 505import { Want } from '@kit.AbilityKit'; 506import { BusinessError } from '@kit.BasicServicesKit'; 507let wantTemp: Want = { 508 bundleName: 'com.example.myapplication', 509 abilityName: 'EntryAbility', 510}; 511 512bundleManager.uninstall(wantTemp, 'bundleName', 100, true).then(() => { 513 console.info('Succeeded in uninstalling bundles.'); 514}).catch((err: BusinessError) => { 515 console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`); 516}); 517``` 518 519## bundleManager.install 520 521install(admin: Want, hapFilePaths: Array\<string>, installParam?: InstallParam): Promise\<void> 522 523Installs applications through the specified device administrator application. This API uses a promise to return the result. 524 525**Required permissions**: ohos.permission.ENTERPRISE_INSTALL_BUNDLE 526 527**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 528 529 530**Parameters** 531 532| Name | Type | Mandatory| Description | 533| ------------ | ------------------------------------------------------- | ---- | ---------------------- | 534| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 535| hapFilePaths | Array\<string> | Yes | Applications to install.| 536| installParam | [InstallParam](#installparam) | No | Application installation parameters. | 537 538**Return value** 539 540| Type | Description | 541| ------------------- | ------------------------------------------------------- | 542| Promise<void> | Promise that returns no value. If the operation fails, an error object will be thrown.| 543 544**Error codes** 545 546For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 547 548| ID| Error Message | 549| -------- | ------------------------------------------------------------ | 550| 9200001 | The application is not an administrator application of the device. | 551| 9200002 | The administrator application does not have permission to manage the device. | 552| 9201002 | Failed to install the application. | 553| 201 | Permission verification failed. The application does not have the permission required to call the API. | 554| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 555 556**Example** 557 558```ts 559import { Want } from '@kit.AbilityKit'; 560import { BusinessError } from '@kit.BasicServicesKit'; 561let wantTemp: Want = { 562 bundleName: 'com.example.myapplication', 563 abilityName: 'EntryAbility', 564}; 565let hapFilePaths: Array<string> = ['/data/storage/el2/base/haps/entry/testinstall/ExtensionTest.hap']; 566 567bundleManager.install(wantTemp, hapFilePaths).then(() => { 568 console.info('Succeeded in installing bundles.'); 569}).catch((err: BusinessError) => { 570 console.error(`Failed to install bundles. Code is ${err.code}, message is ${err.message}`); 571}); 572``` 573 574## InstallParam 575 576Defines the parameters for application installation. 577 578**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 579 580| Name | Type | Mandatory| Description | 581| ----------- | ------ | ---- | ------------------------------------------------------------ | 582| userId | number | No | User ID, which must be greater than or equal to 0. The default value is the user ID of the caller. | 583| installFlag | number | No | Installation flag.<br>- **0**: initial installation.<br>- **1**: overwrite installation.<br>- **2**: installation-free.<br>Default value: **0**| 584