• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.enterprise.adminManager (Enterprise Device Management)
2
3The **adminManager** module provides enterprise device management capabilities so that devices have the custom capabilities required in enterprise settings.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9## Modules to Import
10
11```js
12import adminManager from '@ohos.enterprise.adminManager';
13```
14
15## adminManager.enableAdmin
16
17enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback\<void>): void
18
19Enables a device administrator application based on the specified bundle name and class name. This API uses an asynchronous callback to return the result.
20
21**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
22
23**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
24
25**System API**: This is a system API.
26
27**Parameters**
28
29| Name           | Type                                 | Mandatory  | Description                |
30| -------------- | ----------------------------------- | ---- | ------------------ |
31| admin          | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.           |
32| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo)   | Yes   | Enterprise information of the device administrator application.      |
33| type           | [AdminType](#admintype)             | Yes   | Type of the device administrator to enable.        |
34| callback       | AsyncCallback\<void>                | Yes   | Callback used to return the result.|
35
36**Error codes**
37
38For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
39
40| ID| Error Message                                                        |
41| ------- | --------------------------------------------------------------- |
42| 9200003 | the administrator ability component is invalid.                 |
43| 9200004 | failed to enable the administrator application of the device.   |
44| 9200007 | the system ability work abnormally.                             |
45
46**Example**
47
48```js
49let wantTemp = {
50    bundleName: "com.example.myapplication",
51    abilityName: "EntryAbility",
52};
53let enterpriseInfo = {
54    name: "enterprise name",
55    description: "enterprise description"
56}
57adminManager.enableAdmin(wantTemp, enterpriseInfo, adminManager.AdminType.ADMIN_TYPE_NORMAL, error => {
58    if (error != null) {
59        console.log("error occurs" + error);
60        return;
61    }
62    console.log("enableAdmin success");
63});
64```
65
66## adminManager.enableAdmin
67
68enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId: number, callback: AsyncCallback\<void>): void
69
70Enables a device administrator application for the specified user based on the specified bundle name and class name. This API uses an asynchronous callback to return the result.
71
72**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
73
74**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
75
76**System API**: This is a system API.
77
78**Parameters**
79
80| Name           | Type                                 | Mandatory  | Description                          |
81| -------------- | ----------------------------------- | ---- | ---------------------------- |
82| admin          | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.                     |
83| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo)   | Yes   | Enterprise information of the device administrator application.                |
84| type           | [AdminType](#admintype)             | Yes   | Type of the device administrator to enable.                  |
85| userId         | number                              | Yes   | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
86| callback       | AsyncCallback\<void>                | Yes   | Callback used to return the result.          |
87
88**Error codes**
89
90For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
91
92| ID| Error Message                                                        |
93| ------- | --------------------------------------------------------------- |
94| 9200003 | the administrator ability component is invalid.                 |
95| 9200004 | failed to enable the administrator application of the device.   |
96| 9200007 | the system ability work abnormally.                             |
97
98**Example**
99
100```js
101let wantTemp = {
102    bundleName: "com.example.myapplication",
103    abilityName: "EntryAbility",
104};
105let enterpriseInfo = {
106    name: "enterprise name",
107    description: "enterprise description"
108}
109adminManager.enableAdmin(wantTemp, enterpriseInfo, adminManager.AdminType.ADMIN_TYPE_NORMAL, 100, error => {
110    if (error != null) {
111        console.log("error occurs" + error);
112        return;
113    }
114    console.log("enableAdmin success");
115});
116```
117
118## adminManager.enableAdmin
119
120enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number): Promise\<void>
121
122Enables a device administrator application based on the specified bundle name and class name. This API uses a promise to return the result.
123
124**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
125
126**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
127
128**System API**: This is a system API.
129
130**Parameters**
131
132| Name           | Type                                 | Mandatory  | Description                          |
133| -------------- | ----------------------------------- | ---- | ---------------------------- |
134| admin          | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.                     |
135| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo)   | Yes   | Enterprise information of the device administrator application.                |
136| type           | [AdminType](#admintype)             | Yes   | Type of the device administrator to enable.                  |
137| userId         | number                              | No   | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
138
139**Return value**
140
141| Type               | Description               |
142| ----------------- | ----------------- |
143| Promise\<void>    | Promise used to return the result.|
144
145**Error codes**
146
147For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
148
149| ID| Error Message                                                        |
150| ------- | --------------------------------------------------------------- |
151| 9200003 | the administrator ability component is invalid.                 |
152| 9200004 | failed to enable the administrator application of the device.   |
153| 9200007 | the system ability work abnormally.                             |
154
155**Example**
156
157```js
158let wantTemp = {
159    bundleName: "com.example.myapplication",
160    abilityName: "EntryAbility",
161};
162let enterpriseInfo = {
163    name: "enterprise name",
164    description: "enterprise description"
165}
166adminManager.enableAdmin(wantTemp, enterpriseInfo, adminManager.AdminType.ADMIN_TYPE_NORMAL, 100)
167.catch(error => {
168    console.log("error occurs" + error);
169});
170```
171
172## adminManager.disableAdmin
173
174disableAdmin(admin: Want, callback: AsyncCallback\<void>): void
175
176Disables a device common administrator application based on the specified bundle name and class name. This API uses an asynchronous callback to return the result.
177
178**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
179
180**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
181
182**System API**: This is a system API.
183
184**Parameters**
185
186| Name     | Type                                 | Mandatory  | Description                 |
187| -------- | ----------------------------------- | ---- | ------------------- |
188| admin    | [Want](js-apis-app-ability-want.md) | Yes   | Device common administrator application.          |
189| callback | AsyncCallback\<void>                | Yes   | Callback used to return the result.|
190
191**Error codes**
192
193For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
194
195| ID| Error Message                                                          |
196| ------- | ----------------------------------------------------------------- |
197| 9200005 | failed to disable the administrator application of the device.    |
198
199**Example**
200
201```js
202let wantTemp = {
203    bundleName: "bundleName",
204    abilityName: "abilityName",
205};
206adminManager.disableAdmin(wantTemp, error => {
207    if (error != null) {
208        console.log("error occurs" + error);
209        return;
210    }
211    console.log("disableAdmin success ");
212});
213```
214
215## adminManager.disableAdmin
216
217disableAdmin(admin: Want, userId: number, callback: AsyncCallback\<void>): void
218
219Disables a device common administrator application for the specified user based on the specified bundle name and class name. This API uses an asynchronous callback to return the result.
220
221**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
222
223**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
224
225**System API**: This is a system API.
226
227**Parameters**
228
229| Name     | Type                                 | Mandatory  | Description                          |
230| -------- | ----------------------------------- | ---- | ---------------------------- |
231| admin    | [Want](js-apis-app-ability-want.md) | Yes   | Device common administrator application.                   |
232| userId   | number                              | Yes   | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
233| callback | AsyncCallback\<void>                | Yes   | Callback used to return the result.         |
234
235**Error codes**
236
237For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
238
239| ID| Error Message                                                          |
240| ------- | ----------------------------------------------------------------- |
241| 9200005 | failed to disable the administrator application of the device.    |
242
243**Example**
244
245```js
246let wantTemp = {
247    bundleName: "bundleName",
248    abilityName: "abilityName",
249};
250adminManager.disableAdmin(wantTemp, 100, error => {
251    if (error != null) {
252        console.log("error occurs" + error);
253        return;
254    }
255    console.log("disableAdmin success ");
256});
257```
258
259## adminManager.disableAdmin
260
261disableAdmin(admin: Want, userId?: number): Promise\<void>
262
263Disables a device common administrator application based on the specified bundle name and class name. This API uses a promise to return the result.
264
265**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
266
267**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
268
269**System API**: This is a system API.
270
271**Parameters**
272
273| Name   | Type                                 | Mandatory  | Description                          |
274| ------ | ----------------------------------- | ---- | ---------------------------- |
275| admin  | [Want](js-apis-app-ability-want.md) | Yes   | Device common administrator application.                   |
276| userId | number                              | No   | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
277
278**Return value**
279
280| Type               | Description               |
281| ----------------- | ----------------- |
282| Promise\<void>    | Promise used to return the result.|
283
284**Error codes**
285
286For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
287
288| ID| Error Message                                                          |
289| ------- | ----------------------------------------------------------------- |
290| 9200005 | failed to disable the administrator application of the device.    |
291
292**Example**
293
294```js
295let wantTemp = {
296    bundleName: "bundleName",
297    abilityName: "abilityName",
298};
299adminManager.disableAdmin(wantTemp, 100).catch(error => {
300    console.log("error occurs" + error);
301});
302```
303
304## adminManager.disableSuperAdmin
305
306disableSuperAdmin(bundleName: String, callback: AsyncCallback\<void>): void
307
308Disables a device super administrator application based on the specified bundle name. This API uses an asynchronous callback to return the result.
309
310**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
311
312**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
313
314**System API**: This is a system API.
315
316**Parameters**
317
318| Name       | Type                     | Mandatory  | Description                 |
319| ---------- | ----------------------- | ---- | ------------------- |
320| bundleName | String                  | Yes   | Bundle name of the device super administrator application.       |
321| callback   | AsyncCallback\<void>    | Yes   | Callback used to return the result.|
322
323**Error codes**
324
325For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
326
327| ID| Error Message                                                          |
328| ------- | ----------------------------------------------------------------- |
329| 9200005 | failed to disable the administrator application of the device.    |
330
331**Example**
332
333```js
334let bundleName = "com.example.myapplication";
335adminManager.disableSuperAdmin(bundleName, error => {
336    if (error != null) {
337        console.log("error occurs" + error);
338        return;
339    }
340    console.log("disableSuperAdmin success");
341});
342```
343
344## adminManager.disableSuperAdmin
345
346disableSuperAdmin(bundleName: String): Promise\<void>
347
348Disables a device super administrator application based on the specified bundle name. This API uses a promise to return the result.
349
350**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
351
352**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
353
354**System API**: This is a system API.
355
356**Parameters**
357
358| Name       | Type    | Mandatory  | Description          |
359| ---------- | ------ | ---- | ------------ |
360| bundleName | String | Yes   | Bundle name of the device super administrator application.|
361
362**Return value**
363
364| Type               | Description               |
365| ----------------- | ----------------- |
366| Promise\<void>    | Promise used to return the result.|
367
368**Error codes**
369
370For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
371
372| ID| Error Message                                                          |
373| ------- | ----------------------------------------------------------------- |
374| 9200005 | failed to disable the administrator application of the device.    |
375
376**Example**
377
378```js
379let bundleName = "com.example.myapplication";
380adminManager.disableSuperAdmin(bundleName).catch(error => {
381    console.log("error occurs" + error);
382});
383```
384
385## adminManager.isAdminEnabled
386
387isAdminEnabled(admin: Want, callback: AsyncCallback\<boolean>): void
388
389Checks whether a device administrator application is enabled based on the specified bundle name and class name. This API uses an asynchronous callback to return the result.
390
391**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
392
393**System API**: This is a system API.
394
395**Parameters**
396
397| Name     | Type                                 | Mandatory  | Description                  |
398| -------- | ----------------------------------- | ---- | -------------------- |
399| admin    | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.             |
400| callback | AsyncCallback\<boolean>             | Yes   | Callback used to return the result.|
401
402**Example**
403
404```js
405let wantTemp = {
406    bundleName: "bundleName",
407    abilityName: "abilityName",
408};
409adminManager.isAdminEnabled(wantTemp, (error, result) => {
410    if (error != null) {
411        console.log("error occurs" + error);
412        return;
413    }
414    console.log("result is " + result);
415});
416```
417
418## adminManager.isAdminEnabled
419
420isAdminEnabled(admin: Want, userId: number, callback: AsyncCallback\<boolean>): void
421
422Checks whether a device administrator application is enabled for the specified user based on the specified bundle name and class name. This API uses an asynchronous callback to return the result.
423
424**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
425
426**System API**: This is a system API.
427
428**Parameters**
429
430| Name     | Type                                 | Mandatory  | Description                          |
431| -------- | ----------------------------------- | ---- | ---------------------------- |
432| admin    | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.                     |
433| userId   | number                              | Yes   | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
434| callback | AsyncCallback\<boolean>             | Yes   | Callback used to return the result.        |
435
436**Example**
437
438```js
439let wantTemp = {
440    bundleName: "bundleName",
441    abilityName: "abilityName",
442};
443adminManager.isAdminEnabled(wantTemp, 100, (error, result) => {
444    if (error != null) {
445        console.log("error occurs" + error);
446        return;
447    }
448    console.log("result is " + result);
449});
450```
451
452## adminManager.isAdminEnabled
453
454isAdminEnabled(admin: Want, userId?: number): Promise\<boolean>
455
456Checks whether a device administrator application is enabled based on the specified bundle name and class name. This API uses a promise to return the result.
457
458**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
459
460**System API**: This is a system API.
461
462**Parameters**
463
464| Name   | Type                                 | Mandatory  | Description                          |
465| ------ | ----------------------------------- | ---- | ---------------------------- |
466| admin  | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.                     |
467| userId | number                              | No   | User ID. The default value is the user ID of the caller. The value must be greater than or equal to 0.|
468
469**Return value**
470
471| Type              | Description               |
472| ----------------- | ------------------- |
473| Promise\<boolean> | Promise used to return the result.|
474
475**Example**
476
477```js
478let wantTemp = {
479    bundleName: "bundleName",
480    abilityName: "abilityName",
481};
482adminManager.isAdminEnabled(wantTemp, 100).then((result) => {
483    console.log("result is " + result);
484}).catch(error => {
485    console.log("error occurs" + error);
486});
487```
488
489## adminManager.isSuperAdmin
490
491isSuperAdmin(bundleName: String, callback: AsyncCallback\<boolean>): void
492
493Checks whether a device super administrator application is enabled based on the specified bundle name. This API uses an asynchronous callback to return the result.
494
495**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
496
497**System API**: This is a system API.
498
499**Parameters**
500
501| Name       | Type                     | Mandatory  | Description                  |
502| ---------- | ----------------------- | ---- | -------------------- |
503| bundleName | String                  | Yes   | Device administrator application.             |
504| callback   | AsyncCallback\<boolean> | Yes   | Callback used to return the result.|
505
506**Example**
507
508```js
509let bundleName = "com.example.myapplication";
510adminManager.isSuperAdmin(bundleName, (error, result) => {
511    if (error != null) {
512        console.log("error occurs" + error);
513        return;
514    }
515    console.log("result is " + result);
516});
517```
518
519## adminManager.isSuperAdmin
520
521isSuperAdmin(bundleName: String): Promise\<boolean>
522
523Checks whether a device super administrator application is enabled based on the specified bundle name. This API uses a promise to return the result.
524
525**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
526
527**System API**: This is a system API.
528
529**Parameters**
530
531| Name       | Type    | Mandatory  | Description       |
532| ---------- | ------ | ---- | --------- |
533| bundleName | String | Yes   | Device super administrator application.|
534
535**Return value**
536
537| ID          | Error Message              |
538| ----------------- | ------------------- |
539| Promise\<boolean> | Promise used to return the result.|
540
541**Example**
542
543```js
544let bundleName = "com.example.myapplication";
545adminManager.isSuperAdmin(bundleName).then((result) => {
546    console.log("result is " + result);
547}).catch(error => {
548    console.log("error occurs" + error);
549});
550```
551
552## adminManager.setEnterpriseInfo
553
554setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback\<void>;): void
555
556Sets the enterprise information of a device administrator application. This API uses an asynchronous callback to return the result.
557
558**Required permissions**: ohos.permission.SET_ENTERPRISE_INFO
559
560**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
561
562**System API**: This is a system API.
563
564**Parameters**
565
566| Name           | Type                                 | Mandatory  | Description                    |
567| -------------- | ----------------------------------- | ---- | ---------------------- |
568| admin          | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.               |
569| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo)   | Yes   | Enterprise information of the device administrator application.          |
570| callback       | AsyncCallback\<void>;               | Yes   | Callback used to return the result.|
571
572**Error codes**
573
574For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
575
576| ID| Error Message                                              |
577| ------- | ----------------------------------------------------- |
578| 9200001 | the application is not an administrator of the device. |
579
580**Example**
581
582```js
583let wantTemp = {
584    bundleName: "com.example.myapplication",
585    abilityName: "EntryAbility",
586};
587let enterpriseInfo = {
588    name: "enterprise name",
589    description: "enterprise description"
590}
591adminManager.setEnterpriseInfo(wantTemp, enterpriseInfo, error => {
592    if (error != null) {
593        console.log("error occurs" + error);
594        return;
595    }
596    console.log("setEnterpriseInfo success");
597});
598```
599
600## adminManager.setEnterpriseInfo
601
602setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise\<void>;
603
604Sets the enterprise information of a device administrator application. This API uses a promise to return the result.
605
606**Required permissions**: ohos.permission.SET_ENTERPRISE_INFO
607
608**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
609
610**System API**: This is a system API.
611
612**Parameters**
613
614| Name           | Type                                 | Mandatory  | Description          |
615| -------------- | ----------------------------------- | ---- | ------------ |
616| admin          | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.     |
617| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo)   | Yes   | Enterprise information of the device administrator application.|
618
619**Return value**
620
621| Type               | Description                   |
622| ----------------- | --------------------- |
623| Promise\<void>    | Promise used to return the result.|
624
625**Error codes**
626
627For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
628
629| ID| Error Message                                              |
630| ------- | ----------------------------------------------------- |
631| 9200001 | the application is not an administrator of the device. |
632
633**Example**
634
635```js
636let wantTemp = {
637    bundleName: "com.example.myapplication",
638    abilityName: "EntryAbility",
639};
640let enterpriseInfo = {
641    name: "enterprise name",
642    description: "enterprise description"
643}
644adminManager.setEnterpriseInfo(wantTemp, enterpriseInfo).catch(error => {
645    console.log("error occurs" + error);
646});
647```
648
649## adminManager.getEnterpriseInfo
650
651getEnterpriseInfo(admin: Want, callback: AsyncCallback&lt;EnterpriseInfo&gt;): void
652
653Obtains the enterprise information of a device administrator application. This API uses an asynchronous callback to return the result.
654
655**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
656
657**System API**: This is a system API.
658
659**Parameters**
660
661| Name     | Type                                      | Mandatory  | Description                      |
662| -------- | ---------------------------------------- | ---- | ------------------------ |
663| admin    | [Want](js-apis-app-ability-want.md)      | Yes   | Device administrator application.                 |
664| callback | AsyncCallback&lt;[EnterpriseInfo](#enterpriseinfo)&gt; | Yes   | Callback used to return the enterprise information of the device administrator application.|
665
666**Error codes**
667
668For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
669
670| ID| Error Message                                              |
671| ------- | ----------------------------------------------------- |
672| 9200001 | the application is not an administrator of the device. |
673
674**Example**
675
676```js
677let wantTemp = {
678    bundleName: "com.example.myapplication",
679    abilityName: "EntryAbility",
680};
681adminManager.getEnterpriseInfo(wantTemp, (error, result) => {
682    if (error != null) {
683        console.log("error occurs" + error);
684        return;
685    }
686    console.log(result.name);
687    console.log(result.description);
688});
689```
690
691## adminManager.getEnterpriseInfo
692
693getEnterpriseInfo(admin: Want): Promise&lt;EnterpriseInfo&gt;
694
695Obtains the enterprise information of a device administrator application. This API uses a promise to return the result.
696
697**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
698
699**System API**: This is a system API.
700
701**Parameters**
702
703| Name  | Type                                 | Mandatory  | Description     |
704| ----- | ----------------------------------- | ---- | ------- |
705| admin | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.|
706
707**Return value**
708
709| Type                                      | Description                       |
710| ---------------------------------------- | ------------------------- |
711| Promise&lt;[EnterpriseInfo](#enterpriseinfo)&gt; | Promise used to return the enterprise information of the device administrator application.|
712
713**Error codes**
714
715For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
716
717| ID| Error Message                                              |
718| ------- | ----------------------------------------------------- |
719| 9200001 | the application is not an administrator of the device. |
720
721**Example**
722
723```js
724let wantTemp = {
725    bundleName: "com.example.myapplication",
726    abilityName: "EntryAbility",
727};
728adminManager.getEnterpriseInfo(wantTemp).then((result) => {
729    console.log(result.name);
730    console.log(result.description);
731}).catch(error => {
732    console.log("error occurs" + error);
733});
734```
735
736## adminManager.subscribeManagedEvent
737
738subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callback: AsyncCallback\<void>): void
739
740Subscribes to system management events. This API uses an asynchronous callback to return the result.
741
742**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT
743
744**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
745
746**System API**: This is a system API.
747
748**Parameters**
749
750| Name  | Type                                 | Mandatory  | Description     |
751| ----- | ----------------------------------- | ---- | ------- |
752| admin | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.|
753| managedEvents  | Array\<[ManagedEvent](#managedevent)> | Yes| Array of events to subscribe to.|
754| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the subscription is successful, **err** is **null**. Otherwise, **err** is an error object.|
755
756**Error codes**
757
758For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
759
760|ID| Error Message                                               |
761| ------- | ----------------------------------------------------- |
762| 9200001 | the application is not an administrator of the device. |
763| 9200008 | the specified system events enum is invalid.          |
764
765**Example**
766
767```js
768let wantTemp = {
769    bundleName: "bundleName",
770    abilityName: "abilityName",
771};
772let events = [0, 1];
773adminManager.subscribeManagedEvent(wantTemp, events, (error) => {
774    if (error) {
775        console.log("error code:" + error.code + " error message:" + error.message);
776    }
777});
778```
779
780## adminManager.subscribeManagedEvent
781
782subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promise\<void>
783
784Subscribes to system management events. This API uses a promise to return the result.
785
786**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT
787
788**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
789
790**System API**: This is a system API.
791
792**Parameters**
793
794| Name  | Type                                 | Mandatory  | Description     |
795| ----- | ----------------------------------- | ---- | ------- |
796| admin | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.|
797| managedEvents  | Array\<[ManagedEvent](#managedevent)> | Yes| Array of events to subscribe to.|
798
799**Return value**
800
801| Type  | Description                                 |
802| ----- | ----------------------------------- |
803| Promise\<void> | Promise that returns no value.|
804
805**Error codes**
806
807For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
808
809| ID| Error Message                                              |
810| ------- | ----------------------------------------------------- |
811| 9200001 | the application is not an administrator of the device. |
812| 9200008 | the specified system events enum is invalid.          |
813
814**Example**
815
816```js
817let wantTemp = {
818    bundleName: "bundleName",
819    abilityName: "abilityName",
820};
821let events = [0, 1];
822adminManager.subscribeManagedEvent(wantTemp, events).then(() => {
823}).catch((error) => {
824    console.log("error code:" + error.code + " error message:" + error.message);
825})
826```
827
828## adminManager.unsubscribeManagedEvent
829
830unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callback: AsyncCallback\<void>): void
831
832Unsubscribes from system management events. This API uses an asynchronous callback to return the result.
833
834**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT
835
836**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
837
838**System API**: This is a system API.
839
840**Parameters**
841
842| Name  | Type                                 | Mandatory  | Description     |
843| ----- | ----------------------------------- | ---- | ------- |
844| admin | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.|
845| managedEvents  | Array\<[ManagedEvent](#managedevent)> | Yes| Array of events to unsubscribe from.|
846| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the unsubscription is successful, **err** is **null**. Otherwise, **err** is an error object.|
847
848**Error codes**
849
850For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
851
852| ID| Error Message                                              |
853| ------- | ----------------------------------------------------- |
854| 9200001 | the application is not an administrator of the device. |
855| 9200008 | the specified system events enum is invalid.          |
856
857**Example**
858
859```js
860let wantTemp = {
861    bundleName: "bundleName",
862    abilityName: "abilityName",
863};
864let events = [0, 1];
865adminManager.unsubscribeManagedEvent(wantTemp, events, (error) => {
866    if (error) {
867        console.log("error code:" + error.code + " error message:" + error.message);
868    }
869});
870```
871
872## adminManager.unsubscribeManagedEvent
873
874unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promise\<void>
875
876Unsubscribes from system management events. This API uses an asynchronous callback to return the result.
877
878**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT
879
880**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
881
882**System API**: This is a system API.
883
884**Parameters**
885
886| Name  | Type                                 | Mandatory  | Description     |
887| ----- | ----------------------------------- | ---- | ------- |
888| admin | [Want](js-apis-app-ability-want.md) | Yes   | Device administrator application.|
889| managedEvents  | Array\<[ManagedEvent](#managedevent)> | Yes| Array of events to unsubscribe from.|
890
891**Return value**
892
893| Type  | Description                                 |
894| ----- | ----------------------------------- |
895| Promise\<void> | Promise that returns no value.|
896
897**Error codes**
898
899For details about the following error codes, see [Enterprise Device Management Error Codes](../errorcodes/errorcode-enterpriseDeviceManager.md).
900
901| ID| Error Message                                              |
902| ------- | ----------------------------------------------------- |
903| 9200001 | the application is not an administrator of the device. |
904| 9200008 | the specified system events enum is invalid.          |
905
906**Example**
907
908```js
909let wantTemp = {
910    bundleName: "bundleName",
911    abilityName: "abilityName",
912};
913let events = [0, 1];
914adminManager.unsubscribeManagedEvent(wantTemp, events).then(() => {
915}).catch((error) => {
916    console.log("error code:" + error.code + " error message:" + error.message);
917})
918```
919
920## EnterpriseInfo
921
922Describes the enterprise information of a device administrator application.
923
924**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
925
926**System API**: This is a system API.
927
928| Name        | Type    | Readable| Writable  | Description                           |
929| ----------- | --------| ---- | ----- | ------------------------------- |
930| name        | string   | Yes  | No   | Name of the enterprise to which the device administrator application belongs.|
931| description | string   | Yes  | No   | Description of the enterprise to which the device administrator application belongs.|
932
933## AdminType
934
935Enumerates the administrator types of the device administrator application.
936
937**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
938
939**System API**: This is a system API.
940
941| Name               | Value | Description   |
942| ----------------- | ---- | ----- |
943| ADMIN_TYPE_NORMAL | 0x00 | Common administrator.|
944| ADMIN_TYPE_SUPER  | 0x01 | Super administrator.|
945
946## ManagedEvent
947
948Enumerates the system management events that can be subscribed to.
949
950**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
951
952**System API**: This is a system API.
953
954| Name                       | Value | Description          |
955| -------------------------- | ---- | ------------- |
956| MANAGED_EVENT_BUNDLE_ADDED | 0    | Application installation event.|
957| MANAGED_EVENT_BUNDLE_REMOVED | 1  | Application uninstallation event.|
958