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