1# @ohos.enterprise.bundleManager (Bundle Management) (System API) 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 10. 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](js-apis-enterprise-adminManager-sys.md#adminmanagerenableadmin-2). 12> 13> - This topic describes only the system APIs provided by the module. For details about its public APIs, see [@ohos.enterprise.bundleManager](js-apis-enterprise-bundleManager.md). 14 15## Modules to Import 16 17```ts 18import { bundleManager } from '@kit.MDMKit'; 19``` 20 21## bundleManager.addAllowedInstallBundles 22 23addAllowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback<void>): void 24 25Adds the applications that can be installed by the current user. This API uses an asynchronous callback to return the result. 26 27**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 28 29**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 30 31 32**Parameters** 33 34| Name | Type | Mandatory | Description | 35| -------- | ---------------------------------------- | ---- | ------------------------------- | 36| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 37| appIds | Array<string> | Yes | IDs of the applications to add. | 38| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 39 40**Error codes** 41 42For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 43 44| ID| Error Message | 45| ------- | ---------------------------------------------------------------------------- | 46| 9200001 | The application is not an administrator application of the device. | 47| 9200002 | The administrator application does not have permission to manage the device. | 48| 201 | Permission verification failed. The application does not have the permission required to call the API. | 49| 202 | Permission verification failed. A non-system application calls a system API. | 50| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 51 52**Example** 53 54```ts 55import { Want } from '@kit.AbilityKit'; 56 57let wantTemp: Want = { 58 bundleName: 'com.example.myapplication', 59 abilityName: 'EntryAbility', 60}; 61let appIds: Array<string> = ['com.example.******_******/******5t5CoBM=']; 62 63bundleManager.addAllowedInstallBundles(wantTemp, appIds, (err) => { 64 if (err) { 65 console.error(`Failed to add allowed install bundles. Code is ${err.code}, message is ${err.message}`); 66 return; 67 } 68 console.info('Succeeded in adding allowed install bundles'); 69}); 70``` 71 72## bundleManager.addAllowedInstallBundles 73 74addAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback<void>): void 75 76Adds the applications that can be installed by the specified user. This API uses an asynchronous callback to return the result. 77 78**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 79 80**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 81 82 83**Parameters** 84 85| Name | Type | Mandatory | Description | 86| ----- | ----------------------------------- | ---- | ------- | 87| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 88| appIds | Array<string> | Yes | IDs of the applications to add. | 89| userId | number | Yes | User ID, which must be greater than or equal to 0.| 90| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 91 92**Error codes** 93 94For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 95 96| ID| Error Message | 97| ------- | ---------------------------------------------------------------------------- | 98| 9200001 | The application is not an administrator application of the device. | 99| 9200002 | The administrator application does not have permission to manage the device. | 100| 201 | Permission verification failed. The application does not have the permission required to call the API. | 101| 202 | Permission verification failed. A non-system application calls a system API. | 102| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 103 104**Example** 105 106```ts 107import { Want } from '@kit.AbilityKit'; 108 109let wantTemp: Want = { 110 bundleName: 'com.example.myapplication', 111 abilityName: 'EntryAbility', 112}; 113let appIds: Array<string> = ['com.example.******_******/******5t5CoBM=']; 114 115bundleManager.addAllowedInstallBundles(wantTemp, appIds, 100, (err) => { 116 if (err) { 117 console.error(`Failed to add allowed install bundles. Code is ${err.code}, message is ${err.message}`); 118 return; 119 } 120 console.info('Succeeded in adding allowed install bundles'); 121}); 122``` 123 124## bundleManager.addAllowedInstallBundles 125 126addAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise<void> 127 128Adds the applications that can be installed by the current or specified user. This API uses a promise to return the result. 129 130**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 131 132**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 133 134 135**Parameters** 136 137| Name | Type | Mandatory | Description | 138| ----- | ----------------------------------- | ---- | ------- | 139| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 140| appIds | Array<string> | Yes | IDs of the applications to add. | 141| 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.| 142 143**Return value** 144 145| Type | Description | 146| --------------------- | ------------------------- | 147| Promise<void> | Promise that returns no value. If the operation fails, an error object will be thrown. | 148 149**Error codes** 150 151For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 152 153| ID| Error Message | 154| ------- | ---------------------------------------------------------------------------- | 155| 9200001 | The application is not an administrator application of the device. | 156| 9200002 | The administrator application does not have permission to manage the device. | 157| 201 | Permission verification failed. The application does not have the permission required to call the API. | 158| 202 | Permission verification failed. A non-system application calls a system API. | 159| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 160 161**Example** 162 163```ts 164import { Want } from '@kit.AbilityKit'; 165import { BusinessError } from '@kit.BasicServicesKit'; 166 167let wantTemp: Want = { 168 bundleName: 'com.example.myapplication', 169 abilityName: 'EntryAbility', 170}; 171let appIds: Array<string> = ['com.example.******_******/******5t5CoBM=']; 172 173bundleManager.addAllowedInstallBundles(wantTemp, appIds, 100).then(() => { 174 console.info('Succeeded in adding allowed install bundles'); 175}).catch((err: BusinessError) => { 176 console.error(`Failed to add allowed install bundles. Code is ${err.code}, message is ${err.message}`); 177}); 178``` 179 180## bundleManager.removeAllowedInstallBundles 181 182removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback<void>): void 183 184Removes the applications that can be installed by the current user. This API uses an asynchronous callback to return the result. 185 186**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 187 188**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 189 190 191**Parameters** 192 193| Name | Type | Mandatory | Description | 194| -------- | ---------------------------------------- | ---- | ------------------------------- | 195| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 196| appIds | Array<string> | Yes | IDs of the applications to add. | 197| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 198 199**Error codes** 200 201For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 202 203| ID| Error Message | 204| ------- | ---------------------------------------------------------------------------- | 205| 9200001 | The application is not an administrator application of the device. | 206| 9200002 | The administrator application does not have permission to manage the device. | 207| 201 | Permission verification failed. The application does not have the permission required to call the API. | 208| 202 | Permission verification failed. A non-system application calls a system API. | 209| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 210 211**Example** 212 213```ts 214import { Want } from '@kit.AbilityKit'; 215 216let wantTemp: Want = { 217 bundleName: 'com.example.myapplication', 218 abilityName: 'EntryAbility', 219}; 220let appIds: Array<string> = ['com.example.******_******/******5t5CoBM=']; 221 222bundleManager.removeAllowedInstallBundles(wantTemp, appIds, (err) => { 223 if (err) { 224 console.error(`Failed to remove allowed install bundles. Code is ${err.code}, message is ${err.message}`); 225 return; 226 } 227 console.info('Succeeded in removing allowed install bundles'); 228}); 229``` 230 231## bundleManager.removeAllowedInstallBundles 232 233removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback<void>): void 234 235Removes the applications that can be installed by the specified user. This API uses an asynchronous callback to return the result. 236 237**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 238 239**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 240 241 242**Parameters** 243 244| Name | Type | Mandatory | Description | 245| ----- | ----------------------------------- | ---- | ------- | 246| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 247| appIds | Array<string> | Yes | IDs of the applications to add. | 248| userId | number | Yes | User ID, which must be greater than or equal to 0.| 249| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 250 251**Error codes** 252 253For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 254 255| ID| Error Message | 256| ------- | ---------------------------------------------------------------------------- | 257| 9200001 | The application is not an administrator application of the device. | 258| 9200002 | The administrator application does not have permission to manage the device. | 259| 201 | Permission verification failed. The application does not have the permission required to call the API. | 260| 202 | Permission verification failed. A non-system application calls a system API. | 261| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 262 263**Example** 264 265```ts 266import { Want } from '@kit.AbilityKit'; 267 268let wantTemp: Want = { 269 bundleName: 'com.example.myapplication', 270 abilityName: 'EntryAbility', 271}; 272let appIds: Array<string> = ['com.example.******_******/******5t5CoBM=']; 273 274bundleManager.removeAllowedInstallBundles(wantTemp, appIds, 100, (err) => { 275 if (err) { 276 console.error(`Failed to remove allowed install bundles. Code is ${err.code}, message is ${err.message}`); 277 return; 278 } 279 console.info('Succeeded in removing allowed install bundles'); 280}); 281``` 282 283## bundleManager.removeAllowedInstallBundles 284 285removeAllowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise<void> 286 287Removes the applications that can be installed by the current or specified user. This API uses a promise to return the result. 288 289**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 290 291**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 292 293 294**Parameters** 295 296| Name | Type | Mandatory | Description | 297| ----- | ----------------------------------- | ---- | ------- | 298| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 299| appIds | Array<string> | Yes | IDs of the applications to add. | 300| 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.| 301 302**Return value** 303 304| Type | Description | 305| --------------------- | ------------------------- | 306| Promise<void> | Promise that returns no value. If the operation fails, an error object will be thrown. | 307 308**Error codes** 309 310For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 311 312| ID| Error Message | 313| ------- | ---------------------------------------------------------------------------- | 314| 9200001 | The application is not an administrator application of the device. | 315| 9200002 | The administrator application does not have permission to manage the device. | 316| 201 | Permission verification failed. The application does not have the permission required to call the API. | 317| 202 | Permission verification failed. A non-system application calls a system API. | 318| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 319 320**Example** 321 322```ts 323import { Want } from '@kit.AbilityKit'; 324import { BusinessError } from '@kit.BasicServicesKit'; 325 326let wantTemp: Want = { 327 bundleName: 'com.example.myapplication', 328 abilityName: 'EntryAbility', 329}; 330let appIds: Array<string> = ['com.example.******_******/******5t5CoBM=']; 331 332bundleManager.removeAllowedInstallBundles(wantTemp, appIds, 100).then(() => { 333 console.info('Succeeded in removing allowed install bundles'); 334}).catch((err: BusinessError) => { 335 console.error(`Failed to remove allowed install bundles. Code is ${err.code}, message is ${err.message}`); 336}); 337``` 338 339## bundleManager.getAllowedInstallBundles 340 341getAllowedInstallBundles(admin: Want, callback: AsyncCallback<Array<string>>): void 342 343Obtains the applications that can be installed by the current user. This API uses an asynchronous callback to return the result. 344 345**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 346 347**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 348 349 350**Parameters** 351 352| Name | Type | Mandatory | Description | 353| -------- | ---------------------------------------- | ---- | ------------------------------- | 354| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 355| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | 356 357**Error codes** 358 359For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 360 361| ID| Error Message | 362| ------- | ---------------------------------------------------------------------------- | 363| 9200001 | The application is not an administrator application of the device. | 364| 9200002 | The administrator application does not have permission to manage the device. | 365| 201 | Permission verification failed. The application does not have the permission required to call the API. | 366| 202 | Permission verification failed. A non-system application calls a system API. | 367| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 368 369**Example** 370 371```ts 372import { Want } from '@kit.AbilityKit'; 373 374let wantTemp: Want = { 375 bundleName: 'com.example.myapplication', 376 abilityName: 'EntryAbility', 377}; 378 379bundleManager.getAllowedInstallBundles(wantTemp, (err, result) => { 380 if (err) { 381 console.error(`Failed to get allowed install bundles. Code is ${err.code}, message is ${err.message}`); 382 return; 383 } 384 console.info(`Succeeded in getting allowed install bundles, result : ${JSON.stringify(result)}`); 385}); 386``` 387 388## bundleManager.getAllowedInstallBundles 389 390getAllowedInstallBundles(admin: Want, userId: number, callback: AsyncCallback<Array<string>>): void 391 392Obtains the applications that can be installed by the specified user. This API uses an asynchronous callback to return the result. 393 394**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 395 396**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 397 398 399**Parameters** 400 401| Name | Type | Mandatory | Description | 402| -------- | ---------------------------------------- | ---- | ------------------------------- | 403| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 404| userId | number | Yes | User ID, which must be greater than or equal to 0.| 405| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | 406 407**Error codes** 408 409For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 410 411| ID| Error Message | 412| ------- | ---------------------------------------------------------------------------- | 413| 9200001 | The application is not an administrator application of the device. | 414| 9200002 | The administrator application does not have permission to manage the device. | 415| 201 | Permission verification failed. The application does not have the permission required to call the API. | 416| 202 | Permission verification failed. A non-system application calls a system API. | 417| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 418 419**Example** 420 421```ts 422import { Want } from '@kit.AbilityKit'; 423 424let wantTemp: Want = { 425 bundleName: 'com.example.myapplication', 426 abilityName: 'EntryAbility', 427}; 428 429bundleManager.getAllowedInstallBundles(wantTemp, 100, (err, result) => { 430 if (err) { 431 console.error(`Failed to get allowed install bundles. Code is ${err.code}, message is ${err.message}`); 432 return; 433 } 434 console.info(`Succeeded in getting allowed install bundles, result : ${JSON.stringify(result)}`); 435}); 436``` 437 438## bundleManager.getAllowedInstallBundles 439 440getAllowedInstallBundles(admin: Want, userId?: number): Promise<Array<string>> 441 442Obtains the applications that can be installed by the current or specified user. This API uses a promise to return the result. 443 444**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 445 446**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 447 448 449**Parameters** 450 451| Name | Type | Mandatory | Description | 452| ----- | ----------------------------------- | ---- | ------- | 453| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility.| 454| 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.| 455 456**Return value** 457 458| Type | Description | 459| --------------------- | ------------------------- | 460| Promise<Array<string>> | Promise used to return the applications that can be installed by the current or specified user.| 461 462**Error codes** 463 464For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 465 466| ID| Error Message | 467| ------- | ---------------------------------------------------------------------------- | 468| 9200001 | The application is not an administrator application of the device. | 469| 9200002 | The administrator application does not have permission to manage the device. | 470| 201 | Permission verification failed. The application does not have the permission required to call the API. | 471| 202 | Permission verification failed. A non-system application calls a system API. | 472| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 473 474**Example** 475 476```ts 477import { Want } from '@kit.AbilityKit'; 478import { BusinessError } from '@kit.BasicServicesKit'; 479 480let wantTemp: Want = { 481 bundleName: 'com.example.myapplication', 482 abilityName: 'EntryAbility', 483}; 484 485bundleManager.getAllowedInstallBundles(wantTemp, 100).then((result) => { 486 console.info(`Succeeded in getting allowed install bundles, result : ${JSON.stringify(result)}`); 487}).catch((err: BusinessError) => { 488 console.error(`Failed to get allowed install bundles. Code is ${err.code}, message is ${err.message}`); 489}); 490``` 491 492## bundleManager.addDisallowedInstallBundles 493 494addDisallowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback<void>): void 495 496Adds the applications that cannot be installed by the current user. This API uses an asynchronous callback to return the result. 497 498**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 499 500**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 501 502 503**Parameters** 504 505| Name | Type | Mandatory | Description | 506| -------- | ---------------------------------------- | ---- | ------------------------------- | 507| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 508| appIds | Array<string> | Yes | IDs of the applications to add. | 509| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 510 511**Error codes** 512 513For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 514 515| ID| Error Message | 516| ------- | ---------------------------------------------------------------------------- | 517| 9200001 | The application is not an administrator application of the device. | 518| 9200002 | The administrator application does not have permission to manage the device. | 519| 201 | Permission verification failed. The application does not have the permission required to call the API. | 520| 202 | Permission verification failed. A non-system application calls a system API. | 521| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 522 523**Example** 524 525```ts 526import { Want } from '@kit.AbilityKit'; 527 528let wantTemp: Want = { 529 bundleName: 'com.example.myapplication', 530 abilityName: 'EntryAbility', 531}; 532let appIds: Array<string> = ['com.example.******_******/******5t5CoBM=']; 533 534bundleManager.addDisallowedInstallBundles(wantTemp, appIds, (err) => { 535 if (err) { 536 console.error(`Failed to add disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 537 return; 538 } 539 console.info('Succeeded in adding disallowed install bundles'); 540}); 541``` 542 543## bundleManager.addDisallowedInstallBundles 544 545addDisallowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback<void>): void 546 547Adds the applications that cannot be installed by the specified user. This API uses an asynchronous callback to return the result. 548 549**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 550 551**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 552 553 554**Parameters** 555 556| Name | Type | Mandatory | Description | 557| ----- | ----------------------------------- | ---- | ------- | 558| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 559| appIds | Array<string> | Yes | IDs of the applications to add. | 560| userId | number | Yes | User ID, which must be greater than or equal to 0.| 561| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 562 563**Error codes** 564 565For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 566 567| ID| Error Message | 568| ------- | ---------------------------------------------------------------------------- | 569| 9200001 | The application is not an administrator application of the device. | 570| 9200002 | The administrator application does not have permission to manage the device. | 571| 201 | Permission verification failed. The application does not have the permission required to call the API. | 572| 202 | Permission verification failed. A non-system application calls a system API. | 573| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 574 575**Example** 576 577```ts 578import { Want } from '@kit.AbilityKit'; 579 580let wantTemp: Want = { 581 bundleName: 'com.example.myapplication', 582 abilityName: 'EntryAbility', 583}; 584let appIds: Array<string> = ['com.example.******_******/******5t5CoBM=']; 585 586bundleManager.addDisallowedInstallBundles(wantTemp, appIds, 100, (err) => { 587 if (err) { 588 console.error(`Failed to add disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 589 return; 590 } 591 console.info('Succeeded in adding disallowed install bundles'); 592}); 593``` 594 595## bundleManager.addDisallowedInstallBundles 596 597addDisallowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise<void> 598 599Adds the applications that cannot be installed by the current or specified user. This API uses a promise to return the result. 600 601**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 602 603**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 604 605 606**Parameters** 607 608| Name | Type | Mandatory | Description | 609| ----- | ----------------------------------- | ---- | ------- | 610| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 611| appIds | Array<string> | Yes | IDs of the applications to add. | 612| 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.| 613 614**Return value** 615 616| Type | Description | 617| --------------------- | ------------------------- | 618| Promise<void> | Promise that returns no value. If the operation fails, an error object will be thrown. | 619 620**Error codes** 621 622For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 623 624| ID| Error Message | 625| ------- | ---------------------------------------------------------------------------- | 626| 9200001 | The application is not an administrator application of the device. | 627| 9200002 | The administrator application does not have permission to manage the device. | 628| 201 | Permission verification failed. The application does not have the permission required to call the API. | 629| 202 | Permission verification failed. A non-system application calls a system API. | 630| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 631 632**Example** 633 634```ts 635import { Want } from '@kit.AbilityKit'; 636import { BusinessError } from '@kit.BasicServicesKit'; 637 638let wantTemp: Want = { 639 bundleName: 'com.example.myapplication', 640 abilityName: 'EntryAbility', 641}; 642let appIds: Array<string> = ['com.example.******_******/******5t5CoBM=']; 643 644bundleManager.addDisallowedInstallBundles(wantTemp, appIds, 100).then(() => { 645 console.info('Succeeded in adding disallowed install bundles'); 646}).catch((err: BusinessError) => { 647 console.error(`Failed to add disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 648}); 649``` 650 651## bundleManager.removeDisallowedInstallBundles 652 653removeDisallowedInstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback<void>): void 654 655Removes the applications that cannot be installed by the current user. This API uses an asynchronous callback to return the result. 656 657**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 658 659**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 660 661 662**Parameters** 663 664| Name | Type | Mandatory | Description | 665| -------- | ---------------------------------------- | ---- | ------------------------------- | 666| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 667| appIds | Array<string> | Yes | IDs of the applications to add. | 668| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 669 670**Error codes** 671 672For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 673 674| ID| Error Message | 675| ------- | ---------------------------------------------------------------------------- | 676| 9200001 | The application is not an administrator application of the device. | 677| 9200002 | The administrator application does not have permission to manage the device. | 678| 201 | Permission verification failed. The application does not have the permission required to call the API. | 679| 202 | Permission verification failed. A non-system application calls a system API. | 680| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 681 682**Example** 683 684```ts 685import { Want } from '@kit.AbilityKit'; 686 687let wantTemp: Want = { 688 bundleName: 'com.example.myapplication', 689 abilityName: 'EntryAbility', 690}; 691let appIds: Array<string> = ['com.example.******_******/******5t5CoBM=']; 692 693bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, (err) => { 694 if (err) { 695 console.error(`Failed to remove disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 696 return; 697 } 698 console.info('Succeeded in removing disallowed install bundles'); 699}); 700``` 701 702## bundleManager.removeDisallowedInstallBundles 703 704removeDisallowedInstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback<void>): void 705 706Removes the applications that cannot be installed by the specified user. This API uses an asynchronous callback to return the result. 707 708**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 709 710**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 711 712 713**Parameters** 714 715| Name | Type | Mandatory | Description | 716| ----- | ----------------------------------- | ---- | ------- | 717| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 718| appIds | Array<string> | Yes | IDs of the applications to add. | 719| userId | number | Yes | User ID, which must be greater than or equal to 0.| 720| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 721 722**Error codes** 723 724For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 725 726| ID| Error Message | 727| ------- | ---------------------------------------------------------------------------- | 728| 9200001 | The application is not an administrator application of the device. | 729| 9200002 | The administrator application does not have permission to manage the device. | 730| 201 | Permission verification failed. The application does not have the permission required to call the API. | 731| 202 | Permission verification failed. A non-system application calls a system API. | 732| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 733 734**Example** 735 736```ts 737import { Want } from '@kit.AbilityKit'; 738 739let wantTemp: Want = { 740 bundleName: 'com.example.myapplication', 741 abilityName: 'EntryAbility', 742}; 743let appIds: Array<string> = ['com.example.******_******/******5t5CoBM=']; 744 745bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, 100, (err) => { 746 if (err) { 747 console.error(`Failed to remove disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 748 return; 749 } 750 console.info('Succeeded in removing disallowed install bundles'); 751}); 752``` 753 754## bundleManager.removeDisallowedInstallBundles 755 756removeDisallowedInstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise<void> 757 758Removes the applications that cannot be installed by the current or specified user. This API uses a promise to return the result. 759 760**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 761 762**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 763 764 765**Parameters** 766 767| Name | Type | Mandatory | Description | 768| ----- | ----------------------------------- | ---- | ------- | 769| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 770| appIds | Array<string> | Yes | IDs of the applications to add. | 771| 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.| 772 773**Return value** 774 775| Type | Description | 776| --------------------- | ------------------------- | 777| Promise<void> | Promise that returns no value. If the operation fails, an error object will be thrown. | 778 779**Error codes** 780 781For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 782 783| ID| Error Message | 784| ------- | ---------------------------------------------------------------------------- | 785| 9200001 | The application is not an administrator application of the device. | 786| 9200002 | The administrator application does not have permission to manage the device. | 787| 201 | Permission verification failed. The application does not have the permission required to call the API. | 788| 202 | Permission verification failed. A non-system application calls a system API. | 789| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 790 791**Example** 792 793```ts 794import { Want } from '@kit.AbilityKit'; 795import { BusinessError } from '@kit.BasicServicesKit'; 796 797let wantTemp: Want = { 798 bundleName: 'com.example.myapplication', 799 abilityName: 'EntryAbility', 800}; 801let appIds: Array<string> = ['com.example.******_******/******5t5CoBM=']; 802 803bundleManager.removeDisallowedInstallBundles(wantTemp, appIds, 100).then(() => { 804 console.info('Succeeded in removing disallowed install bundles'); 805}).catch((err: BusinessError) => { 806 console.error(`Failed to remove disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 807}); 808``` 809 810## bundleManager.getDisallowedInstallBundles 811 812getDisallowedInstallBundles(admin: Want, callback: AsyncCallback<Array<string>>): void 813 814Obtains the applications that cannot be installed by the current user. This API uses an asynchronous callback to return the result. 815 816**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 817 818**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 819 820 821**Parameters** 822 823| Name | Type | Mandatory | Description | 824| -------- | ---------------------------------------- | ---- | ------------------------------- | 825| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 826| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | 827 828**Error codes** 829 830For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 831 832| ID| Error Message | 833| ------- | ---------------------------------------------------------------------------- | 834| 9200001 | The application is not an administrator application of the device. | 835| 9200002 | The administrator application does not have permission to manage the device. | 836| 201 | Permission verification failed. The application does not have the permission required to call the API. | 837| 202 | Permission verification failed. A non-system application calls a system API. | 838| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 839 840**Example** 841 842```ts 843import { Want } from '@kit.AbilityKit'; 844 845let wantTemp: Want = { 846 bundleName: 'com.example.myapplication', 847 abilityName: 'EntryAbility', 848}; 849 850bundleManager.getDisallowedInstallBundles(wantTemp, (err, result) => { 851 if (err) { 852 console.error(`Failed to get disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 853 return; 854 } 855 console.info(`Succeeded in getting disallowed install bundles, result : ${JSON.stringify(result)}`); 856}); 857``` 858 859## bundleManager.getDisallowedInstallBundles 860 861getDisallowedInstallBundles(admin: Want, userId: number, callback: AsyncCallback<Array<string>>): void 862 863Obtains the applications that cannot be installed by the specified user. This API uses an asynchronous callback to return the result. 864 865**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 866 867**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 868 869 870**Parameters** 871 872| Name | Type | Mandatory | Description | 873| -------- | ---------------------------------------- | ---- | ------------------------------- | 874| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 875| userId | number | Yes | User ID, which must be greater than or equal to 0.| 876| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | 877 878**Error codes** 879 880For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 881 882| ID| Error Message | 883| ------- | ---------------------------------------------------------------------------- | 884| 9200001 | The application is not an administrator application of the device. | 885| 9200002 | The administrator application does not have permission to manage the device. | 886| 201 | Permission verification failed. The application does not have the permission required to call the API. | 887| 202 | Permission verification failed. A non-system application calls a system API. | 888| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 889 890**Example** 891 892```ts 893import { Want } from '@kit.AbilityKit'; 894 895let wantTemp: Want = { 896 bundleName: 'com.example.myapplication', 897 abilityName: 'EntryAbility', 898}; 899 900bundleManager.getDisallowedInstallBundles(wantTemp, 100, (err, result) => { 901 if (err) { 902 console.error(`Failed to get disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 903 return; 904 } 905 console.info(`Succeeded in getting disallowed install bundles, result : ${JSON.stringify(result)}`); 906}); 907``` 908 909## bundleManager.getDisallowedInstallBundles 910 911getDisallowedInstallBundles(admin: Want, userId?: number): Promise<Array<string>> 912 913Obtains the applications that cannot be installed by the current or specified user. This API uses a promise to return the result. 914 915**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 916 917**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 918 919 920**Parameters** 921 922| Name | Type | Mandatory | Description | 923| ----- | ----------------------------------- | ---- | ------- | 924| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility.| 925| 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.| 926 927**Return value** 928 929| Type | Description | 930| --------------------- | ------------------------- | 931| Promise<Array<string>> | Promise used to return the applications that cannot be installed by the current or specified user.| 932 933**Error codes** 934 935For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 936 937| ID| Error Message | 938| ------- | ---------------------------------------------------------------------------- | 939| 9200001 | The application is not an administrator application of the device. | 940| 9200002 | The administrator application does not have permission to manage the device. | 941| 201 | Permission verification failed. The application does not have the permission required to call the API. | 942| 202 | Permission verification failed. A non-system application calls a system API. | 943| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 944 945**Example** 946 947```ts 948import { Want } from '@kit.AbilityKit'; 949import { BusinessError } from '@kit.BasicServicesKit'; 950 951let wantTemp: Want = { 952 bundleName: 'com.example.myapplication', 953 abilityName: 'EntryAbility', 954}; 955 956bundleManager.getDisallowedInstallBundles(wantTemp, 100).then((result) => { 957 console.info(`Succeeded in getting disallowed install bundles, result : ${JSON.stringify(result)}`); 958}).catch((err: BusinessError) => { 959 console.error(`Failed to get disallowed install bundles. Code is ${err.code}, message is ${err.message}`); 960}); 961``` 962 963## bundleManager.addDisallowedUninstallBundles 964 965addDisallowedUninstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback<void>): void 966 967Adds the applications that cannot be uninstalled by the current user. This API uses an asynchronous callback to return the result. 968 969**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 970 971**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 972 973 974**Parameters** 975 976| Name | Type | Mandatory | Description | 977| -------- | ---------------------------------------- | ---- | ------------------------------- | 978| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 979| appIds | Array<string> | Yes | IDs of the applications to add. | 980| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 981 982**Error codes** 983 984For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 985 986| ID| Error Message | 987| ------- | ---------------------------------------------------------------------------- | 988| 9200001 | The application is not an administrator application of the device. | 989| 9200002 | The administrator application does not have permission to manage the device. | 990| 201 | Permission verification failed. The application does not have the permission required to call the API. | 991| 202 | Permission verification failed. A non-system application calls a system API. | 992| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 993 994**Example** 995 996```ts 997import { Want } from '@kit.AbilityKit'; 998 999let wantTemp: Want = { 1000 bundleName: 'com.example.myapplication', 1001 abilityName: 'EntryAbility', 1002}; 1003let appIds: Array<string> = ['com.example.******_******/******5t5CoBM=']; 1004 1005bundleManager.addDisallowedUninstallBundles(wantTemp, appIds, (err) => { 1006 if (err) { 1007 console.error(`Failed to add disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1008 return; 1009 } 1010 console.info('Succeeded in adding disallowed uninstall bundles'); 1011}); 1012``` 1013 1014## bundleManager.addDisallowedUninstallBundles 1015 1016addDisallowedUninstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback<void>): void 1017 1018Adds the applications that cannot be uninstalled by the specified user. This API uses an asynchronous callback to return the result. 1019 1020**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 1021 1022**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1023 1024 1025**Parameters** 1026 1027| Name | Type | Mandatory | Description | 1028| ----- | ----------------------------------- | ---- | ------- | 1029| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 1030| appIds | Array<string> | Yes | IDs of the applications to add. | 1031| userId | number | Yes | User ID, which must be greater than or equal to 0.| 1032| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 1033 1034**Error codes** 1035 1036For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 1037 1038| ID| Error Message | 1039| ------- | ---------------------------------------------------------------------------- | 1040| 9200001 | The application is not an administrator application of the device. | 1041| 9200002 | The administrator application does not have permission to manage the device. | 1042| 201 | Permission verification failed. The application does not have the permission required to call the API. | 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; 3. Parameter verification failed. | 1045 1046**Example** 1047 1048```ts 1049import { Want } from '@kit.AbilityKit'; 1050 1051let wantTemp: Want = { 1052 bundleName: 'com.example.myapplication', 1053 abilityName: 'EntryAbility', 1054}; 1055let appIds: Array<string> = ['com.example.******_******/******5t5CoBM=']; 1056 1057bundleManager.addDisallowedUninstallBundles(wantTemp, appIds, 100, (err) => { 1058 if (err) { 1059 console.error(`Failed to add disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1060 return; 1061 } 1062 console.info('Succeeded in adding disallowed uninstall bundles'); 1063}); 1064``` 1065 1066## bundleManager.addDisallowedUninstallBundles 1067 1068addDisallowedUninstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise<void> 1069 1070Adds the applications that cannot be uninstalled by the current or specified user. This API uses a promise to return the result. 1071 1072**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 1073 1074**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1075 1076 1077**Parameters** 1078 1079| Name | Type | Mandatory | Description | 1080| ----- | ----------------------------------- | ---- | ------- | 1081| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 1082| appIds | Array<string> | Yes | IDs of the applications to add. | 1083| 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.| 1084 1085**Return value** 1086 1087| Type | Description | 1088| --------------------- | ------------------------- | 1089| Promise<void> | Promise that returns no value. If the operation fails, an error object will be thrown. | 1090 1091**Error codes** 1092 1093For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 1094 1095| ID| Error Message | 1096| ------- | ---------------------------------------------------------------------------- | 1097| 9200001 | The application is not an administrator application of the device. | 1098| 9200002 | The administrator application does not have permission to manage the device. | 1099| 201 | Permission verification failed. The application does not have the permission required to call the API. | 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 verification failed. | 1102 1103**Example** 1104 1105```ts 1106import { Want } from '@kit.AbilityKit'; 1107import { BusinessError } from '@kit.BasicServicesKit'; 1108 1109let wantTemp: Want = { 1110 bundleName: 'com.example.myapplication', 1111 abilityName: 'EntryAbility', 1112}; 1113let appIds: Array<string> = ['com.example.******_******/******5t5CoBM=']; 1114 1115bundleManager.addDisallowedUninstallBundles(wantTemp, appIds, 100).then(() => { 1116 console.info('Succeeded in adding disallowed uninstall bundles'); 1117}).catch((err: BusinessError) => { 1118 console.error(`Failed to add disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1119}); 1120``` 1121 1122## bundleManager.removeDisallowedUninstallBundles 1123 1124removeDisallowedUninstallBundles(admin: Want, appIds: Array\<string>, callback: AsyncCallback<void>): void 1125 1126Removes the applications that cannot be uninstalled by the current user. This API uses an asynchronous callback to return the result. 1127 1128**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 1129 1130**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1131 1132 1133**Parameters** 1134 1135| Name | Type | Mandatory | Description | 1136| -------- | ---------------------------------------- | ---- | ------------------------------- | 1137| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 1138| appIds | Array<string> | Yes | IDs of the applications to add. | 1139| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 1140 1141**Error codes** 1142 1143For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 1144 1145| ID| Error Message | 1146| ------- | ---------------------------------------------------------------------------- | 1147| 9200001 | The application is not an administrator application of the device. | 1148| 9200002 | The administrator application does not have permission to manage the device. | 1149| 201 | Permission verification failed. The application does not have the permission required to call the API. | 1150| 202 | Permission verification failed. A non-system application calls a system API. | 1151| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1152 1153**Example** 1154 1155```ts 1156import { Want } from '@kit.AbilityKit'; 1157 1158let wantTemp: Want = { 1159 bundleName: 'com.example.myapplication', 1160 abilityName: 'EntryAbility', 1161}; 1162let appIds: Array<string> = ['com.example.******_******/******5t5CoBM=']; 1163 1164bundleManager.removeDisallowedUninstallBundles(wantTemp, appIds, (err) => { 1165 if (err) { 1166 console.error(`Failed to remove disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1167 return; 1168 } 1169 console.info('Succeeded in removing disallowed uninstall bundles'); 1170}); 1171``` 1172 1173## bundleManager.removeDisallowedUninstallBundles 1174 1175removeDisallowedUninstallBundles(admin: Want, appIds: Array\<string>, userId: number, callback: AsyncCallback<void>): void 1176 1177Removes the applications that cannot be uninstalled by the specified user. This API uses an asynchronous callback to return the result. 1178 1179**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 1180 1181**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1182 1183 1184**Parameters** 1185 1186| Name | Type | Mandatory | Description | 1187| ----- | ----------------------------------- | ---- | ------- | 1188| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 1189| appIds | Array<string> | Yes | IDs of the applications to add. | 1190| userId | number | Yes | User ID, which must be greater than or equal to 0.| 1191| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 1192 1193**Error codes** 1194 1195For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 1196 1197| ID| Error Message | 1198| ------- | ---------------------------------------------------------------------------- | 1199| 9200001 | The application is not an administrator application of the device. | 1200| 9200002 | The administrator application does not have permission to manage the device. | 1201| 201 | Permission verification failed. The application does not have the permission required to call the API. | 1202| 202 | Permission verification failed. A non-system application calls a system API. | 1203| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1204 1205**Example** 1206 1207```ts 1208import { Want } from '@kit.AbilityKit'; 1209 1210let wantTemp: Want = { 1211 bundleName: 'com.example.myapplication', 1212 abilityName: 'EntryAbility', 1213}; 1214let appIds: Array<string> = ['com.example.******_******/******5t5CoBM=']; 1215 1216bundleManager.removeDisallowedUninstallBundles(wantTemp, appIds, 100, (err) => { 1217 if (err) { 1218 console.error(`Failed to remove disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1219 return; 1220 } 1221 console.info('Succeeded in removing disallowed uninstall bundles'); 1222}); 1223``` 1224 1225## bundleManager.removeDisallowedUninstallBundles 1226 1227removeDisallowedUninstallBundles(admin: Want, appIds: Array\<string>, userId?: number): Promise<void> 1228 1229Removes the applications that cannot be uninstalled by the current or specified user. This API uses a promise to return the result. 1230 1231**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 1232 1233**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1234 1235 1236**Parameters** 1237 1238| Name | Type | Mandatory | Description | 1239| ----- | ----------------------------------- | ---- | ------- | 1240| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 1241| appIds | Array<string> | Yes | IDs of the applications to add. | 1242| 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.| 1243 1244**Return value** 1245 1246| Type | Description | 1247| --------------------- | ------------------------- | 1248| Promise<void> | Promise that returns no value. If the operation fails, an error object will be thrown. | 1249 1250**Error codes** 1251 1252For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 1253 1254| ID| Error Message | 1255| ------- | ---------------------------------------------------------------------------- | 1256| 9200001 | The application is not an administrator application of the device. | 1257| 9200002 | The administrator application does not have permission to manage the device. | 1258| 201 | Permission verification failed. The application does not have the permission required to call the API. | 1259| 202 | Permission verification failed. A non-system application calls a system API. | 1260| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1261 1262**Example** 1263 1264```ts 1265import { Want } from '@kit.AbilityKit'; 1266import { BusinessError } from '@kit.BasicServicesKit'; 1267 1268let wantTemp: Want = { 1269 bundleName: 'com.example.myapplication', 1270 abilityName: 'EntryAbility', 1271}; 1272let appIds: Array<string> = ['com.example.******_******/******5t5CoBM=']; 1273 1274bundleManager.removeDisallowedUninstallBundles(wantTemp, appIds, 100).then(() => { 1275 console.info('Succeeded in removing disallowed uninstall bundles'); 1276}).catch((err: BusinessError) => { 1277 console.error(`Failed to remove disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1278}); 1279``` 1280 1281## bundleManager.getDisallowedUninstallBundles 1282 1283getDisallowedUninstallBundles(admin: Want, callback: AsyncCallback<Array<string>>): void 1284 1285Obtains the applications that cannot be uninstalled by the current user. This API uses an asynchronous callback to return the result. 1286 1287**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 1288 1289**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1290 1291 1292**Parameters** 1293 1294| Name | Type | Mandatory | Description | 1295| -------- | ---------------------------------------- | ---- | ------------------------------- | 1296| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 1297| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | 1298 1299**Error codes** 1300 1301For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 1302 1303| ID| Error Message | 1304| ------- | ---------------------------------------------------------------------------- | 1305| 9200001 | The application is not an administrator application of the device. | 1306| 9200002 | The administrator application does not have permission to manage the device. | 1307| 201 | Permission verification failed. The application does not have the permission required to call the API. | 1308| 202 | Permission verification failed. A non-system application calls a system API. | 1309| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1310 1311**Example** 1312 1313```ts 1314import { Want } from '@kit.AbilityKit'; 1315 1316let wantTemp: Want = { 1317 bundleName: 'com.example.myapplication', 1318 abilityName: 'EntryAbility', 1319}; 1320 1321bundleManager.getDisallowedUninstallBundles(wantTemp, (err, result) => { 1322 if (err) { 1323 console.error(`Failed to get disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1324 return; 1325 } 1326 console.info(`Succeeded in getting disallowed uninstall bundles, result : ${JSON.stringify(result)}`); 1327}); 1328``` 1329 1330## bundleManager.getDisallowedUninstallBundles 1331 1332getDisallowedUninstallBundles(admin: Want, userId: number, callback: AsyncCallback<Array<string>>): void 1333 1334Obtains the applications that cannot be uninstalled by the specified user. This API uses an asynchronous callback to return the result. 1335 1336**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 1337 1338**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1339 1340 1341**Parameters** 1342 1343| Name | Type | Mandatory | Description | 1344| -------- | ---------------------------------------- | ---- | ------------------------------- | 1345| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 1346| userId | number | Yes | User ID, which must be greater than or equal to 0.| 1347| callback | AsyncCallback<Array<string>> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | 1348 1349**Error codes** 1350 1351For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 1352 1353| ID| Error Message | 1354| ------- | ---------------------------------------------------------------------------- | 1355| 9200001 | The application is not an administrator application of the device. | 1356| 9200002 | The administrator application does not have permission to manage the device. | 1357| 201 | Permission verification failed. The application does not have the permission required to call the API. | 1358| 202 | Permission verification failed. A non-system application calls a system API. | 1359| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1360 1361**Example** 1362 1363```ts 1364import { Want } from '@kit.AbilityKit'; 1365 1366let wantTemp: Want = { 1367 bundleName: 'com.example.myapplication', 1368 abilityName: 'EntryAbility', 1369}; 1370 1371bundleManager.getDisallowedUninstallBundles(wantTemp, 100, (err, result) => { 1372 if (err) { 1373 console.error(`Failed to get disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1374 return; 1375 } 1376 console.info(`Succeeded in getting disallowed uninstall bundles, result : ${JSON.stringify(result)}`); 1377}); 1378``` 1379 1380## bundleManager.getDisallowedUninstallBundles 1381 1382getDisallowedUninstallBundles(admin: Want, userId?: number): Promise<Array<string>> 1383 1384Obtains the applications that cannot be uninstalled by the current or specified user. This API uses a promise to return the result. 1385 1386**Required permissions**: ohos.permission.ENTERPRISE_SET_BUNDLE_INSTALL_POLICY 1387 1388**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1389 1390 1391**Parameters** 1392 1393| Name | Type | Mandatory | Description | 1394| ----- | ----------------------------------- | ---- | ------- | 1395| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility.| 1396| 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.| 1397 1398**Return value** 1399 1400| Type | Description | 1401| --------------------- | ------------------------- | 1402| Promise<Array<string>> | Promise used to return the applications that cannot be uninstalled by the current or specified user.| 1403 1404**Error codes** 1405 1406For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 1407 1408| ID| Error Message | 1409| ------- | ---------------------------------------------------------------------------- | 1410| 9200001 | The application is not an administrator application of the device. | 1411| 9200002 | The administrator application does not have permission to manage the device. | 1412| 201 | Permission verification failed. The application does not have the permission required to call the API. | 1413| 202 | Permission verification failed. A non-system application calls a system API. | 1414| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1415 1416**Example** 1417 1418```ts 1419import { Want } from '@kit.AbilityKit'; 1420import { BusinessError } from '@kit.BasicServicesKit'; 1421 1422let wantTemp: Want = { 1423 bundleName: 'com.example.myapplication', 1424 abilityName: 'EntryAbility', 1425}; 1426 1427bundleManager.getDisallowedUninstallBundles(wantTemp, 100).then((result) => { 1428 console.info(`Succeeded in getting disallowed uninstall bundles, result : ${JSON.stringify(result)}`); 1429}).catch((err: BusinessError) => { 1430 console.error(`Failed to get disallowed uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1431}); 1432``` 1433 1434## bundleManager.uninstall 1435 1436uninstall(admin: Want, bundleName: string, callback: AsyncCallback<void>): void 1437 1438Uninstalls an application of the current user without retaining the bundle data. This API uses an asynchronous callback to return the result. 1439 1440**Required permissions**: ohos.permission.ENTERPRISE_INSTALL_BUNDLE 1441 1442**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1443 1444 1445**Parameters** 1446 1447| Name | Type | Mandatory | Description | 1448| -------- | ---------------------------------------- | ---- | ------------------------------- | 1449| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 1450| bundleName | string | Yes | Name of the bundle to uninstall.| 1451| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | 1452 1453**Error codes** 1454 1455For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 1456 1457| ID| Error Message | 1458| ------- | ---------------------------------------------------------------------------- | 1459| 9200001 | The application is not an administrator application of the device. | 1460| 9200002 | The administrator application does not have permission to manage the device. | 1461| 201 | Permission verification failed. The application does not have the permission required to call the API. | 1462| 202 | Permission verification failed. A non-system application calls a system API. | 1463| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1464 1465**Example** 1466 1467```ts 1468import { Want } from '@kit.AbilityKit'; 1469 1470let wantTemp: Want = { 1471 bundleName: 'com.example.myapplication', 1472 abilityName: 'EntryAbility', 1473}; 1474 1475bundleManager.uninstall(wantTemp, 'bundleName', (err) => { 1476 if (err) { 1477 console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1478 return; 1479 } 1480 console.info('Succeeded in uninstalling bundles'); 1481}); 1482``` 1483 1484## bundleManager.uninstall 1485 1486uninstall(admin: Want, bundleName: string, userId: number, callback: AsyncCallback<void>): void 1487 1488Uninstalls an application of the specified user without retaining the bundle data This API uses an asynchronous callback to return the result. 1489 1490**Required permissions**: ohos.permission.ENTERPRISE_INSTALL_BUNDLE 1491 1492**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1493 1494 1495**Parameters** 1496 1497| Name | Type | Mandatory | Description | 1498| -------- | ---------------------------------------- | ---- | ------------------------------- | 1499| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 1500| bundleName | string | Yes | Name of the bundle to uninstall.| 1501| userId | number | Yes | User ID, which must be greater than or equal to 0.| 1502| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | 1503 1504**Error codes** 1505 1506For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 1507 1508| ID| Error Message | 1509| ------- | ---------------------------------------------------------------------------- | 1510| 9200001 | The application is not an administrator application of the device. | 1511| 9200002 | The administrator application does not have permission to manage the device. | 1512| 201 | Permission verification failed. The application does not have the permission required to call the API. | 1513| 202 | Permission verification failed. A non-system application calls a system API. | 1514| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1515 1516**Example** 1517 1518```ts 1519import { Want } from '@kit.AbilityKit'; 1520 1521let wantTemp: Want = { 1522 bundleName: 'com.example.myapplication', 1523 abilityName: 'EntryAbility', 1524}; 1525 1526bundleManager.uninstall(wantTemp, 'bundleName', 100, (err) => { 1527 if (err) { 1528 console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1529 return; 1530 } 1531 console.info('Succeeded in uninstalling bundles'); 1532}); 1533``` 1534 1535## bundleManager.uninstall 1536 1537uninstall(admin: Want, bundleName: string, isKeepData: boolean, callback: AsyncCallback<void>): void 1538 1539Uninstalls an application of the current user. The **isKeepData** parameter specifies whether to retain the bundle data. This API uses an asynchronous callback to return the result. 1540 1541**Required permissions**: ohos.permission.ENTERPRISE_INSTALL_BUNDLE 1542 1543**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1544 1545 1546**Parameters** 1547 1548| Name | Type | Mandatory | Description | 1549| -------- | ---------------------------------------- | ---- | ------------------------------- | 1550| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 1551| bundleName | string | Yes | Name of the bundle to uninstall.| 1552| isKeepData | boolean | Yes | Whether to retain the bundle data. The value **true** means to retain the bundle data; the value **false** means the opposite.| 1553| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | 1554 1555**Error codes** 1556 1557For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 1558 1559| ID| Error Message | 1560| ------- | ---------------------------------------------------------------------------- | 1561| 9200001 | The application is not an administrator application of the device. | 1562| 9200002 | The administrator application does not have permission to manage the device. | 1563| 201 | Permission verification failed. The application does not have the permission required to call the API. | 1564| 202 | Permission verification failed. A non-system application calls a system API. | 1565| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1566 1567**Example** 1568 1569```ts 1570import { Want } from '@kit.AbilityKit'; 1571 1572let wantTemp: Want = { 1573 bundleName: 'com.example.myapplication', 1574 abilityName: 'EntryAbility', 1575}; 1576 1577bundleManager.uninstall(wantTemp, 'bundleName', true, (err) => { 1578 if (err) { 1579 console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1580 return; 1581 } 1582 console.info('Succeeded in uninstalling bundles'); 1583}); 1584``` 1585 1586## bundleManager.uninstall 1587 1588uninstall(admin: Want, bundleName: string, userId: number, isKeepData: boolean, callback: AsyncCallback<void>): void 1589 1590Uninstalls an application of the specified user. The **isKeepData** parameter specifies whether to retain the bundle data. This API uses an asynchronous callback to return the result. 1591 1592**Required permissions**: ohos.permission.ENTERPRISE_INSTALL_BUNDLE 1593 1594**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1595 1596 1597**Parameters** 1598 1599| Name | Type | Mandatory | Description | 1600| -------- | ---------------------------------------- | ---- | ------------------------------- | 1601| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 1602| bundleName | string | Yes | Name of the bundle to uninstall.| 1603| userId | number | Yes | User ID, which must be greater than or equal to 0.| 1604| isKeepData | boolean | Yes | Whether to retain the bundle data. The value **true** means to retain the bundle data; the value **false** means the opposite.| 1605| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | 1606 1607**Error codes** 1608 1609For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 1610 1611| ID| Error Message | 1612| ------- | ---------------------------------------------------------------------------- | 1613| 9200001 | The application is not an administrator application of the device. | 1614| 9200002 | The administrator application does not have permission to manage the device. | 1615| 201 | Permission verification failed. The application does not have the permission required to call the API. | 1616| 202 | Permission verification failed. A non-system application calls a system API. | 1617| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1618 1619**Example** 1620 1621```ts 1622import { Want } from '@kit.AbilityKit'; 1623 1624let wantTemp: Want = { 1625 bundleName: 'com.example.myapplication', 1626 abilityName: 'EntryAbility', 1627}; 1628 1629bundleManager.uninstall(wantTemp, 'bundleName', 100, true, (err) => { 1630 if (err) { 1631 console.error(`Failed to uninstall bundles. Code is ${err.code}, message is ${err.message}`); 1632 return; 1633 } 1634 console.info('Succeeded in uninstalling bundles'); 1635}); 1636``` 1637 1638## bundleManager.install 1639 1640install(admin: Want, hapFilePaths: Array\<string>, callback: AsyncCallback\<void>): void 1641 1642Installs specified applications. This API uses an asynchronous callback to return the result. 1643 1644**Required permissions**: ohos.permission.ENTERPRISE_INSTALL_BUNDLE 1645 1646**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1647 1648 1649**Parameters** 1650 1651| Name | Type | Mandatory | Description | 1652| -------- | ---------------------------------------- | ---- | ------------------------------- | 1653| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 1654| hapFilePaths | Array\<string> | Yes | Applications to install.| 1655| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | 1656 1657**Error codes** 1658 1659For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 1660 1661| ID| Error Message | 1662| ------- | ---------------------------------------------------------------------------- | 1663| 9200001 | The application is not an administrator application of the device. | 1664| 9200002 | The administrator application does not have permission to manage the device. | 1665| 9201002 | Failed to install the application. | 1666| 201 | Permission verification failed. The application does not have the permission required to call the API. | 1667| 202 | Permission verification failed. A non-system application calls a system API. | 1668| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1669 1670**Example** 1671 1672```ts 1673import { Want } from '@kit.AbilityKit'; 1674 1675let wantTemp: Want = { 1676 bundleName: 'com.example.myapplication', 1677 abilityName: 'EntryAbility', 1678}; 1679let hapFilePaths: Array<string> = ['/data/storage/el2/base/haps/entry/testinstall/ExtensionTest.hap']; 1680 1681bundleManager.install(wantTemp, hapFilePaths, (err) => { 1682 if (err) { 1683 console.error(`Failed to install bundles. Code is ${err.code}, message is ${err.message}`); 1684 return; 1685 } 1686 console.info('Succeeded in installing bundles'); 1687}); 1688``` 1689 1690## bundleManager.install 1691 1692install(admin: Want, hapFilePaths: Array\<string>, installParam: InstallParam, callback: AsyncCallback\<void>): void 1693 1694Installs applications with specified parameters. This API uses an asynchronous callback to return the result. 1695 1696**Required permissions**: ohos.permission.ENTERPRISE_INSTALL_BUNDLE 1697 1698**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 1699 1700 1701**Parameters** 1702 1703| Name | Type | Mandatory | Description | 1704| -------- | ---------------------------------------- | ---- | ------------------------------- | 1705| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | EnterpriseAdminExtensionAbility. | 1706| hapFilePaths | Array\<string> | Yes | Applications to install.| 1707| installParam | [InstallParam](js-apis-enterprise-bundleManager.md#installparam) | Yes | Application installation parameters.| 1708| callback | AsyncCallback<void> | Yes | Callback invoked to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. | 1709 1710**Error codes** 1711 1712For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 1713 1714| ID| Error Message | 1715| ------- | ---------------------------------------------------------------------------- | 1716| 9200001 | The application is not an administrator application of the device. | 1717| 9200002 | The administrator application does not have permission to manage the device. | 1718| 9201002 | Failed to install the application. | 1719| 201 | Permission verification failed. The application does not have the permission required to call the API. | 1720| 202 | Permission verification failed. A non-system application calls a system API. | 1721| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 1722 1723**Example** 1724 1725```ts 1726import { Want } from '@kit.AbilityKit'; 1727 1728let wantTemp: Want = { 1729 bundleName: 'com.example.myapplication', 1730 abilityName: 'EntryAbility', 1731}; 1732let hapFilePaths: Array<string> = ['/data/storage/el2/base/haps/entry/testinstall/ExtensionTest.hap']; 1733let installParam: bundleManager.InstallParam = { 1734 userId: 100, 1735 installFlag: 1, 1736}; 1737 1738bundleManager.install(wantTemp, hapFilePaths, installParam, (err) => { 1739 if (err) { 1740 console.error(`Failed to install bundles. Code is ${err.code}, message is ${err.message}`); 1741 return; 1742 } 1743 console.info('Succeeded in installing bundles'); 1744}); 1745``` 1746