js-apis-enterprise-device-manager.md 35.5 KB
Newer Older
E
add doc  
ester.zhou 已提交
1 2
# Enterprise Device Management

3
The **enterpriseDeviceManager** module provides enterprise device management capabilities so that devices have the customization capabilities required in enterprise scenarios.
E
add doc  
ester.zhou 已提交
4

5 6 7
> **NOTE**
>
> 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.
E
add doc  
ester.zhou 已提交
8 9 10

## Modules to Import

11
```js
E
add doc  
ester.zhou 已提交
12 13 14
import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager';
```

15
## enterpriseDeviceManager.enableAdmin
E
add doc  
ester.zhou 已提交
16

E
ester.zhou 已提交
17
enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback\<void>): void
E
add doc  
ester.zhou 已提交
18

19
Enables a device administrator application based on the specified bundle name and class name. This API uses an asynchronous callback to return the result.
E
add doc  
ester.zhou 已提交
20

E
ester.zhou 已提交
21
**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
22 23 24

**System capability**: SystemCapability.Customization.EnterpriseDeviceManager

E
ester.zhou 已提交
25 26
**System API**: This is a system API.

27 28 29 30 31
**Parameters**

| Name           | Type                                 | Mandatory  | Description                |
| -------------- | ----------------------------------- | ---- | ------------------ |
| admin          | [Want](js-apis-application-Want.md) | Yes   | Device administrator application.           |
E
ester.zhou 已提交
32 33
| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo)   | Yes   | Enterprise information of the device administrator application.      |
| type           | [AdminType](#admintype)             | Yes   | Type of the device administrator to enable.        |
E
ester.zhou 已提交
34 35 36 37 38 39 40 41 42
| callback       | AsyncCallback\<void>                | Yes   | Callback used to return the result.|

**Error codes**

| Type     | Description                                                          |
| ------- | --------------------------------------------------------------- |
| 9200003 | The administrator ability component is invalid.                 |
| 9200004 | Failed to activate the administrator application of the device. |
| 9200007 | The system ability work abnormally.                             |
43 44 45 46 47 48 49 50 51 52 53 54

**Example**

```js
let wantTemp = {
    bundleName: "com.example.myapplication",
    abilityName: "com.example.myapplication.MainAbility",
};
let enterpriseInfo = {
    name: "enterprise name",
    description: "enterprise description"
}
E
ester.zhou 已提交
55
enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, error => {
56 57 58 59
    if (error != null) {
        console.log("error occurs" + error);
        return;
    }
E
ester.zhou 已提交
60
    console.log("enableAdmin success");
61 62 63 64 65
});
```

## enterpriseDeviceManager.enableAdmin

E
ester.zhou 已提交
66
enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId: number, callback: AsyncCallback\<void>): void
E
ester.zhou 已提交
67

68
Enables a device administrator application based on the specified bundle name and class name. This API uses an asynchronous callback to return the result.
E
add doc  
ester.zhou 已提交
69

E
ester.zhou 已提交
70
**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
E
ester.zhou 已提交
71

72
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
E
add doc  
ester.zhou 已提交
73

E
ester.zhou 已提交
74 75
**System API**: This is a system API.

E
add doc  
ester.zhou 已提交
76 77
**Parameters**

78 79 80
| Name           | Type                                 | Mandatory  | Description                          |
| -------------- | ----------------------------------- | ---- | ---------------------------- |
| admin          | [Want](js-apis-application-Want.md) | Yes   | Device administrator application.                     |
E
ester.zhou 已提交
81 82
| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo)   | Yes   | Enterprise information of the device administrator application.                |
| type           | [AdminType](#admintype)             | Yes   | Type of the device administrator to enable.                  |
83
| 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.|
E
ester.zhou 已提交
84 85 86 87 88 89 90 91 92
| callback       | AsyncCallback\<void>                | Yes   | Callback used to return the result.          |

**Error codes**

| Type     | Description                                                          |
| ------- | --------------------------------------------------------------- |
| 9200003 | The administrator ability component is invalid.                 |
| 9200004 | Failed to activate the administrator application of the device. |
| 9200007 | The system ability work abnormally.                             |
E
add doc  
ester.zhou 已提交
93 94 95

**Example**

96
```js
E
add doc  
ester.zhou 已提交
97
let wantTemp = {
98 99
    bundleName: "com.example.myapplication",
    abilityName: "com.example.myapplication.MainAbility",
E
add doc  
ester.zhou 已提交
100 101
};
let enterpriseInfo = {
102 103
    name: "enterprise name",
    description: "enterprise description"
E
add doc  
ester.zhou 已提交
104
}
E
ester.zhou 已提交
105
enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, 100, error => {
E
add doc  
ester.zhou 已提交
106 107
    if (error != null) {
        console.log("error occurs" + error);
108
        return;
E
add doc  
ester.zhou 已提交
109
    }
E
ester.zhou 已提交
110
    console.log("enableAdmin success");
E
add doc  
ester.zhou 已提交
111 112 113
});
```

114
## enterpriseDeviceManager.enableAdmin
E
add doc  
ester.zhou 已提交
115

E
ester.zhou 已提交
116
enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number): Promise\<void>
E
add doc  
ester.zhou 已提交
117

118
Enables a device administrator application based on the specified bundle name and class name. This API uses a promise to return the result.
E
add doc  
ester.zhou 已提交
119

E
ester.zhou 已提交
120
**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
E
add doc  
ester.zhou 已提交
121

122
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
E
add doc  
ester.zhou 已提交
123

E
ester.zhou 已提交
124 125
**System API**: This is a system API.

E
add doc  
ester.zhou 已提交
126 127
**Parameters**

128 129 130
| Name           | Type                                 | Mandatory  | Description                          |
| -------------- | ----------------------------------- | ---- | ---------------------------- |
| admin          | [Want](js-apis-application-Want.md) | Yes   | Device administrator application.                     |
E
ester.zhou 已提交
131 132
| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo)   | Yes   | Enterprise information of the device administrator application.                |
| type           | [AdminType](#admintype)             | Yes   | Type of the device administrator to enable.                  |
133
| 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.|
E
add doc  
ester.zhou 已提交
134 135 136

**Return value**

137 138
| Type               | Description               |
| ----------------- | ----------------- |
E
ester.zhou 已提交
139 140 141 142 143 144 145 146 147
| Promise\<void>    | Promise used to return the result.|

**Error codes**

| Type     | Description                                                          |
| ------- | --------------------------------------------------------------- |
| 9200003 | The administrator ability component is invalid.                 |
| 9200004 | Failed to activate the administrator application of the device. |
| 9200007 | The system ability work abnormally.                             |
E
add doc  
ester.zhou 已提交
148 149 150

**Example**

151
```js
E
add doc  
ester.zhou 已提交
152
let wantTemp = {
153 154
    bundleName: "com.example.myapplication",
    abilityName: "com.example.myapplication.MainAbility",
E
add doc  
ester.zhou 已提交
155 156
};
let enterpriseInfo = {
157 158
    name: "enterprise name",
    description: "enterprise description"
E
add doc  
ester.zhou 已提交
159
}
160
enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, 100)
E
ester.zhou 已提交
161
.catch(error => {
162
    console.log("error occurs" + error);
E
add doc  
ester.zhou 已提交
163 164 165
});
```

166
## enterpriseDeviceManager.disableAdmin
E
add doc  
ester.zhou 已提交
167

E
ester.zhou 已提交
168
disableAdmin(admin: Want, callback: AsyncCallback\<void>): void
E
add doc  
ester.zhou 已提交
169

170
Disables a device common administrator application based on the specified bundle name and class name. This API uses an asynchronous callback to return the result.
E
add doc  
ester.zhou 已提交
171

E
ester.zhou 已提交
172
**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
173 174 175

**System capability**: SystemCapability.Customization.EnterpriseDeviceManager

E
ester.zhou 已提交
176 177
**System API**: This is a system API.

178 179 180 181 182
**Parameters**

| Name     | Type                                 | Mandatory  | Description                 |
| -------- | ----------------------------------- | ---- | ------------------- |
| admin    | [Want](js-apis-application-Want.md) | Yes   | Device common administrator application.          |
E
ester.zhou 已提交
183 184 185 186 187 188 189
| callback | AsyncCallback\<void>                | Yes   | Callback used to return the result.|

**Error codes**

| Type     | Description                                                             |
| ------- | ----------------------------------------------------------------- |
| 9200005 | Failed to deactivate the administrator application of the device. |
190 191 192 193 194 195 196 197

**Example**

```js
let wantTemp = {
    bundleName: "bundleName",
    abilityName: "abilityName",
};
E
ester.zhou 已提交
198
enterpriseDeviceManager.disableAdmin(wantTemp, error => {
199 200 201 202
    if (error != null) {
        console.log("error occurs" + error);
        return;
    }
E
ester.zhou 已提交
203
    console.log("disableAdmin success ");
204 205 206 207 208
});
```

## enterpriseDeviceManager.disableAdmin

E
ester.zhou 已提交
209
disableAdmin(admin: Want, userId: number, callback: AsyncCallback\<void>): void
E
ester.zhou 已提交
210

211
Disables a device common administrator application based on the specified bundle name and class name. This API uses an asynchronous callback to return the result.
E
add doc  
ester.zhou 已提交
212

E
ester.zhou 已提交
213
**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
E
ester.zhou 已提交
214

215
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
E
add doc  
ester.zhou 已提交
216

E
ester.zhou 已提交
217 218
**System API**: This is a system API.

E
add doc  
ester.zhou 已提交
219 220
**Parameters**

221 222 223 224
| Name     | Type                                 | Mandatory  | Description                          |
| -------- | ----------------------------------- | ---- | ---------------------------- |
| admin    | [Want](js-apis-application-Want.md) | Yes   | Device common administrator application.                   |
| 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.|
E
ester.zhou 已提交
225 226 227 228 229 230 231
| callback | AsyncCallback\<void>                | Yes   | Callback used to return the result.         |

**Error codes**

| Type     | Description                                                             |
| ------- | ----------------------------------------------------------------- |
| 9200005 | Failed to deactivate the administrator application of the device. |
E
add doc  
ester.zhou 已提交
232 233 234

**Example**

235
```js
E
add doc  
ester.zhou 已提交
236
let wantTemp = {
237 238
    bundleName: "bundleName",
    abilityName: "abilityName",
E
add doc  
ester.zhou 已提交
239
};
E
ester.zhou 已提交
240
enterpriseDeviceManager.disableAdmin(wantTemp, 100, error => {
E
add doc  
ester.zhou 已提交
241 242
    if (error != null) {
        console.log("error occurs" + error);
243
        return;
E
add doc  
ester.zhou 已提交
244
    }
E
ester.zhou 已提交
245
    console.log("disableAdmin success ");
E
add doc  
ester.zhou 已提交
246 247 248
});
```

249
## enterpriseDeviceManager.disableAdmin
E
add doc  
ester.zhou 已提交
250

E
ester.zhou 已提交
251
disableAdmin(admin: Want, userId?: number): Promise\<void>
E
add doc  
ester.zhou 已提交
252

253
Disables a device common administrator application based on the specified bundle name and class name. This API uses a promise to return the result.
E
add doc  
ester.zhou 已提交
254

E
ester.zhou 已提交
255
**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
E
ester.zhou 已提交
256

257
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
E
add doc  
ester.zhou 已提交
258

E
ester.zhou 已提交
259 260
**System API**: This is a system API.

E
add doc  
ester.zhou 已提交
261 262
**Parameters**

263 264 265 266
| Name   | Type                                 | Mandatory  | Description                          |
| ------ | ----------------------------------- | ---- | ---------------------------- |
| admin  | [Want](js-apis-application-Want.md) | Yes   | Device common administrator application.                   |
| 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.|
E
add doc  
ester.zhou 已提交
267 268 269

**Return value**

270 271
| Type               | Description               |
| ----------------- | ----------------- |
E
ester.zhou 已提交
272 273 274 275 276 277 278
| Promise\<void>    | Promise used to return the result.|

**Error codes**

| Type     | Description                                                             |
| ------- | ----------------------------------------------------------------- |
| 9200005 | Failed to deactivate the administrator application of the device. |
E
add doc  
ester.zhou 已提交
279 280 281

**Example**

282
```js
E
add doc  
ester.zhou 已提交
283
let wantTemp = {
284 285
    bundleName: "bundleName",
    abilityName: "abilityName",
E
add doc  
ester.zhou 已提交
286
};
E
ester.zhou 已提交
287
enterpriseDeviceManager.disableAdmin(wantTemp, 100).catch(error => {
288
    console.log("error occurs" + error);
E
add doc  
ester.zhou 已提交
289 290 291
});
```

292
## enterpriseDeviceManager.disableSuperAdmin
E
add doc  
ester.zhou 已提交
293

E
ester.zhou 已提交
294
disableSuperAdmin(bundleName: String, callback: AsyncCallback\<void>): void
E
add doc  
ester.zhou 已提交
295

296
Disables a device super administrator application based on the specified bundle name. This API uses an asynchronous callback to return the result.
E
add doc  
ester.zhou 已提交
297

E
ester.zhou 已提交
298 299
**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN

300
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
E
add doc  
ester.zhou 已提交
301

E
ester.zhou 已提交
302 303
**System API**: This is a system API.

E
add doc  
ester.zhou 已提交
304 305
**Parameters**

306 307 308
| Name       | Type                     | Mandatory  | Description                 |
| ---------- | ----------------------- | ---- | ------------------- |
| bundleName | String                  | Yes   | Bundle name of the device super administrator application.       |
E
ester.zhou 已提交
309 310 311 312 313 314 315
| callback   | AsyncCallback\<void>    | Yes   | Callback used to return the result.|

**Error codes**

| Type     | Description                                                             |
| ------- | ----------------------------------------------------------------- |
| 9200005 | Failed to deactivate the administrator application of the device. |
E
add doc  
ester.zhou 已提交
316 317 318

**Example**

319
```js
E
add doc  
ester.zhou 已提交
320
let bundleName = "com.example.myapplication";
E
ester.zhou 已提交
321
enterpriseDeviceManager.disableSuperAdmin(bundleName, error => {
E
add doc  
ester.zhou 已提交
322 323
    if (error != null) {
        console.log("error occurs" + error);
324
        return;
E
add doc  
ester.zhou 已提交
325
    }
E
ester.zhou 已提交
326
    console.log("disableSuperAdmin success");
E
add doc  
ester.zhou 已提交
327 328 329
});
```

330
## enterpriseDeviceManager.disableSuperAdmin
E
add doc  
ester.zhou 已提交
331

E
ester.zhou 已提交
332
disableSuperAdmin(bundleName: String): Promise\<void>
E
add doc  
ester.zhou 已提交
333

334
Disables a device super administrator application based on the specified bundle name. This API uses a promise to return the result.
E
add doc  
ester.zhou 已提交
335

E
ester.zhou 已提交
336 337
**Required permissions**: ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN

338
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
E
add doc  
ester.zhou 已提交
339

E
ester.zhou 已提交
340 341
**System API**: This is a system API.

E
add doc  
ester.zhou 已提交
342 343
**Parameters**

344 345 346
| Name       | Type    | Mandatory  | Description          |
| ---------- | ------ | ---- | ------------ |
| bundleName | String | Yes   | Bundle name of the device super administrator application.|
E
add doc  
ester.zhou 已提交
347 348 349

**Return value**

350 351
| Type               | Description               |
| ----------------- | ----------------- |
E
ester.zhou 已提交
352 353 354 355 356 357 358
| Promise\<void>    | Promise used to return the result.|

**Error codes**

| Type     | Description                                                             |
| ------- | ----------------------------------------------------------------- |
| 9200005 | Failed to deactivate the administrator application of the device. |
E
add doc  
ester.zhou 已提交
359 360 361

**Example**

362
```js
E
add doc  
ester.zhou 已提交
363
let bundleName = "com.example.myapplication";
E
ester.zhou 已提交
364
enterpriseDeviceManager.disableSuperAdmin(bundleName).catch(error => {
365
    console.log("error occurs" + error);
E
add doc  
ester.zhou 已提交
366 367 368
});
```

369
## enterpriseDeviceManager.isAdminEnabled
E
add doc  
ester.zhou 已提交
370

371
isAdminEnabled(admin: Want, callback: AsyncCallback\<boolean>): void
E
add doc  
ester.zhou 已提交
372

373
Checks 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.
E
add doc  
ester.zhou 已提交
374

375
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
E
add doc  
ester.zhou 已提交
376

E
ester.zhou 已提交
377 378
**System API**: This is a system API.

E
add doc  
ester.zhou 已提交
379 380
**Parameters**

381 382 383 384
| Name     | Type                                 | Mandatory  | Description                  |
| -------- | ----------------------------------- | ---- | -------------------- |
| admin    | [Want](js-apis-application-Want.md) | Yes   | Device administrator application.             |
| callback | AsyncCallback\<boolean>             | Yes   | Callback used to return the result.|
E
add doc  
ester.zhou 已提交
385

E
ester.zhou 已提交
386 387 388 389 390 391
**Error codes**

| Type     | Description                                                             |
| ------- | ----------------------------------------------------------------- |
| 9200005 | Failed to deactivate the administrator application of the device. |

E
add doc  
ester.zhou 已提交
392 393
**Example**

394
```js
E
add doc  
ester.zhou 已提交
395
let wantTemp = {
396 397
    bundleName: "bundleName",
    abilityName: "abilityName",
E
add doc  
ester.zhou 已提交
398
};
399
enterpriseDeviceManager.isAdminEnabled(wantTemp, (error, result) => {
E
add doc  
ester.zhou 已提交
400 401
    if (error != null) {
        console.log("error occurs" + error);
402
        return;
E
add doc  
ester.zhou 已提交
403
    }
404
    console.log("result is " + result);
E
add doc  
ester.zhou 已提交
405 406 407
});
```

408 409 410 411 412 413 414 415
## enterpriseDeviceManager.isAdminEnabled

isAdminEnabled(admin: Want, userId: number, callback: AsyncCallback\<boolean>): void

Checks 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.

**System capability**: SystemCapability.Customization.EnterpriseDeviceManager

E
ester.zhou 已提交
416 417
**System API**: This is a system API.

418 419 420 421 422 423 424
**Parameters**

| Name     | Type                                 | Mandatory  | Description                          |
| -------- | ----------------------------------- | ---- | ---------------------------- |
| admin    | [Want](js-apis-application-Want.md) | Yes   | Device administrator application.                     |
| 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.|
| callback | AsyncCallback\<boolean>             | Yes   | Callback used to return the result.        |
E
add doc  
ester.zhou 已提交
425

426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
**Example**

```js
let wantTemp = {
    bundleName: "bundleName",
    abilityName: "abilityName",
};
enterpriseDeviceManager.isAdminEnabled(wantTemp, 100, (error, result) => {
    if (error != null) {
        console.log("error occurs" + error);
        return;
    }
    console.log("result is " + result);
});
```
E
add doc  
ester.zhou 已提交
441

442
## enterpriseDeviceManager.isAdminEnabled
E
add doc  
ester.zhou 已提交
443

444
isAdminEnabled(admin: Want, userId?: number): Promise\<boolean>
E
add doc  
ester.zhou 已提交
445

446
Checks 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.
E
add doc  
ester.zhou 已提交
447

448
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
E
add doc  
ester.zhou 已提交
449

E
ester.zhou 已提交
450 451
**System API**: This is a system API.

E
add doc  
ester.zhou 已提交
452 453
**Parameters**

454 455 456 457
| Name   | Type                                 | Mandatory  | Description                          |
| ------ | ----------------------------------- | ---- | ---------------------------- |
| admin  | [Want](js-apis-application-Want.md) | Yes   | Device administrator application.                     |
| 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.|
E
add doc  
ester.zhou 已提交
458 459 460

**Return value**

461 462 463
| Type               | Description                 |
| ----------------- | ------------------- |
| Promise\<boolean> | Promise used to return the result.|
E
add doc  
ester.zhou 已提交
464 465 466

**Example**

467
```js
E
add doc  
ester.zhou 已提交
468
let wantTemp = {
469 470
    bundleName: "bundleName",
    abilityName: "abilityName",
E
add doc  
ester.zhou 已提交
471
};
472
enterpriseDeviceManager.isAdminEnabled(wantTemp, 100).then((result) => {
473
    console.log("result is " + result);
E
add doc  
ester.zhou 已提交
474
}).catch(error => {
475
    console.log("error occurs" + error);
E
add doc  
ester.zhou 已提交
476 477 478 479 480 481 482
});
```

## enterpriseDeviceManager.isSuperAdmin

isSuperAdmin(bundleName: String, callback: AsyncCallback\<boolean>): void

483
Checks whether a device super administrator application is enabled based on the specified bundle name. This API uses an asynchronous callback to return the result.
E
add doc  
ester.zhou 已提交
484

485
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
E
add doc  
ester.zhou 已提交
486

E
ester.zhou 已提交
487 488
**System API**: This is a system API.

E
add doc  
ester.zhou 已提交
489 490
**Parameters**

491 492 493 494
| Name       | Type                     | Mandatory  | Description                  |
| ---------- | ----------------------- | ---- | -------------------- |
| bundleName | String                  | Yes   | Device administrator application.             |
| callback   | AsyncCallback\<boolean> | Yes   | Callback used to return the result.|
E
add doc  
ester.zhou 已提交
495 496 497

**Example**

498
```js
E
add doc  
ester.zhou 已提交
499 500 501 502
let bundleName = "com.example.myapplication";
enterpriseDeviceManager.isSuperAdmin(bundleName, (error, result) => {
    if (error != null) {
        console.log("error occurs" + error);
503
        return;
E
add doc  
ester.zhou 已提交
504
    }
505
    console.log("result is " + result);
E
add doc  
ester.zhou 已提交
506 507 508 509 510 511 512
});
```

## enterpriseDeviceManager.isSuperAdmin

isSuperAdmin(bundleName: String): Promise\<boolean>

513
Checks whether a device super administrator application is enabled based on the specified bundle name. This API uses a promise to return the result.
E
add doc  
ester.zhou 已提交
514

515
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
E
add doc  
ester.zhou 已提交
516

E
ester.zhou 已提交
517 518
**System API**: This is a system API.

E
add doc  
ester.zhou 已提交
519 520
**Parameters**

521 522 523
| Name       | Type    | Mandatory  | Description       |
| ---------- | ------ | ---- | --------- |
| bundleName | String | Yes   | Device super administrator application.|
E
add doc  
ester.zhou 已提交
524 525 526

**Return value**

527 528 529
| Type               | Description                 |
| ----------------- | ------------------- |
| Promise\<boolean> | Promise used to return the result.|
E
add doc  
ester.zhou 已提交
530 531 532

**Example**

533
```js
E
add doc  
ester.zhou 已提交
534 535
let bundleName = "com.example.myapplication";
enterpriseDeviceManager.isSuperAdmin(bundleName).then((result) => {
536
    console.log("result is " + result);
E
add doc  
ester.zhou 已提交
537
}).catch(error => {
538
    console.log("error occurs" + error);
E
add doc  
ester.zhou 已提交
539 540 541 542 543 544 545 546 547
});
```

## enterpriseDeviceManager.getDeviceSettingsManager

getDeviceSettingsManager(callback: AsyncCallback&lt;DeviceSettingsManager&gt;): void

Obtains a **DeviceSettingsManager** object. This API uses an asynchronous callback to return the result.

548
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
E
add doc  
ester.zhou 已提交
549 550 551

**Parameters**

552 553
| Name     | Type                                     | Mandatory  | Description                                 |
| -------- | --------------------------------------- | ---- | ----------------------------------- |
E
ester.zhou 已提交
554
| callback | AsyncCallback<[DeviceSettingsManager](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md)&gt; | Yes   | Callback used to return the **DeviceSettingsManager** object obtained.|
E
add doc  
ester.zhou 已提交
555

E
ester.zhou 已提交
556 557 558 559 560 561 562
**Error codes**

| Type     | Description                                                                        |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | The application is not a administrator of the device.                        |
| 9200002 | The administrator application does not have permission to manage the device. |

E
add doc  
ester.zhou 已提交
563 564
**Example**

565
```js
E
add doc  
ester.zhou 已提交
566
let wantTemp = {
567 568
    bundleName: "bundleName",
    abilityName: "abilityName",
E
add doc  
ester.zhou 已提交
569 570 571
};
enterpriseDeviceManager.getDeviceSettingsManager((error, mgr) => {
    if (error != null) {
E
ester.zhou 已提交
572
        console.log("error code:" + error.code);
573
        return;
E
add doc  
ester.zhou 已提交
574
    }
E
ester.zhou 已提交
575
    mgr.setDateTime(wantTemp, 1526003846000, (error) => { 
E
add doc  
ester.zhou 已提交
576
        if (error != null) {
E
ester.zhou 已提交
577
            console.log("error code:" + error.code);
E
add doc  
ester.zhou 已提交
578 579 580 581 582 583 584 585 586 587 588
        }
    });
});
```

## enterpriseDeviceManager.getDeviceSettingsManager

getDeviceSettingsManager(): Promise&lt;DeviceSettingsManager&gt;

Obtains a **DeviceSettingsManager** object. This API uses a promise to return the result.

589
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
E
add doc  
ester.zhou 已提交
590 591 592

**Return value**

593 594
| Type                                  | Description                                |
| ------------------------------------ | ---------------------------------- |
E
ester.zhou 已提交
595
| Promise&lt;[DeviceSettingsManager](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md)&gt; | Promise used to return the **DeviceSettingsManager** object obtained.|
E
add doc  
ester.zhou 已提交
596

E
ester.zhou 已提交
597 598 599 600 601 602 603
**Error codes**

| Type     | Description                                                                        |
| ------- | ---------------------------------------------------------------------------- |
| 9200001 | The application is not a administrator of the device.                        |
| 9200002 | The administrator application does not have permission to manage the device. |

E
add doc  
ester.zhou 已提交
604 605
**Example**

606
```js
E
add doc  
ester.zhou 已提交
607
let wantTemp = {
608 609
    bundleName: "bundleName",
    abilityName: "abilityName",
E
add doc  
ester.zhou 已提交
610
};
611
enterpriseDeviceManager.getDeviceSettingsManager().then((mgr) => {
E
ester.zhou 已提交
612 613
    mgr.setDateTime(wantTemp, 1526003846000).catch((error) => {
        console.log("error code:" + error.code);
E
add doc  
ester.zhou 已提交
614 615
    })
}).catch((error) => {
E
ester.zhou 已提交
616
    console.log("error code:" + error.code);
E
add doc  
ester.zhou 已提交
617 618 619 620 621
})
```

## enterpriseDeviceManager.setEnterpriseInfo

E
ester.zhou 已提交
622
setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback\<void>;): void
E
add doc  
ester.zhou 已提交
623 624 625

Sets the enterprise information of a device administrator application. This API uses an asynchronous callback to return the result.

E
ester.zhou 已提交
626 627
**Required permissions**: ohos.permission.SET_ENTERPRISE_INFO

628
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
E
add doc  
ester.zhou 已提交
629

E
ester.zhou 已提交
630 631
**System API**: This is a system API.

E
add doc  
ester.zhou 已提交
632 633
**Parameters**

634 635 636
| Name           | Type                                 | Mandatory  | Description                    |
| -------------- | ----------------------------------- | ---- | ---------------------- |
| admin          | [Want](js-apis-application-Want.md) | Yes   | Device administrator application.               |
E
ester.zhou 已提交
637
| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo)   | Yes   | Enterprise information of the device administrator application.          |
E
ester.zhou 已提交
638 639 640 641 642 643 644
| callback       | AsyncCallback\<void>;               | Yes   | Callback used to return the result.|

**Error codes**

| Type     | Description                                                 |
| ------- | ----------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |
E
add doc  
ester.zhou 已提交
645 646 647

**Example**

648
```js
E
add doc  
ester.zhou 已提交
649
let wantTemp = {
650 651
    bundleName: "com.example.myapplication",
    abilityName: "com.example.myapplication.MainAbility",
E
add doc  
ester.zhou 已提交
652 653
};
let enterpriseInfo = {
654 655
    name: "enterprise name",
    description: "enterprise description"
E
add doc  
ester.zhou 已提交
656
}
E
ester.zhou 已提交
657 658 659 660 661 662
enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo, error => {
    if (error != null) {
        console.log("error occurs" + error);
        return;
    }
    console.log("setEnterpriseInfo success");
E
add doc  
ester.zhou 已提交
663 664 665 666 667
});
```

## enterpriseDeviceManager.setEnterpriseInfo

E
ester.zhou 已提交
668
setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise\<void>;
E
add doc  
ester.zhou 已提交
669 670 671

Sets the enterprise information of a device administrator application. This API uses a promise to return the result.

E
ester.zhou 已提交
672 673
**Required permissions**: ohos.permission.SET_ENTERPRISE_INFO

674
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
E
add doc  
ester.zhou 已提交
675

E
ester.zhou 已提交
676 677
**System API**: This is a system API.

E
add doc  
ester.zhou 已提交
678 679
**Parameters**

680 681 682
| Name           | Type                                 | Mandatory  | Description          |
| -------------- | ----------------------------------- | ---- | ------------ |
| admin          | [Want](js-apis-application-Want.md) | Yes   | Device administrator application.     |
E
ester.zhou 已提交
683
| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo)   | Yes   | Enterprise information of the device administrator application.|
E
add doc  
ester.zhou 已提交
684 685 686

**Return value**

687 688
| Type               | Description                   |
| ----------------- | --------------------- |
E
ester.zhou 已提交
689 690 691 692 693 694 695
| Promise\<void>    | Promise used to return the result.|

**Error codes**

| Type     | Description                                                 |
| ------- | ----------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |
E
add doc  
ester.zhou 已提交
696 697 698

**Example**

699
```js
E
add doc  
ester.zhou 已提交
700
let wantTemp = {
701 702
    bundleName: "com.example.myapplication",
    abilityName: "com.example.myapplication.MainAbility",
E
add doc  
ester.zhou 已提交
703 704
};
let enterpriseInfo = {
705 706
    name: "enterprise name",
    description: "enterprise description"
E
add doc  
ester.zhou 已提交
707
}
E
ester.zhou 已提交
708
enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo).catch(error => {
709
    console.log("error occurs" + error);
E
add doc  
ester.zhou 已提交
710 711 712 713 714 715 716 717 718
});
```

## enterpriseDeviceManager.getEnterpriseInfo

getEnterpriseInfo(admin: Want, callback: AsyncCallback&lt;EnterpriseInfo&gt;): void

Obtains the enterprise information of a device administrator application. This API uses an asynchronous callback to return the result.

719
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
E
add doc  
ester.zhou 已提交
720

E
ester.zhou 已提交
721 722
**System API**: This is a system API.

E
add doc  
ester.zhou 已提交
723 724
**Parameters**

725 726 727
| Name     | Type                                      | Mandatory  | Description                      |
| -------- | ---------------------------------------- | ---- | ------------------------ |
| admin    | [Want](js-apis-application-Want.md)      | Yes   | Device administrator application.                 |
E
ester.zhou 已提交
728
| callback | AsyncCallback&lt;[EnterpriseInfo](#enterpriseinfo)&gt; | Yes   | Callback used to return the enterprise information of the device administrator application.|
E
add doc  
ester.zhou 已提交
729

E
ester.zhou 已提交
730 731 732 733 734 735
**Error codes**

| Type     | Description                                                 |
| ------- | ----------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |

E
add doc  
ester.zhou 已提交
736 737
**Example**

738
```js
E
add doc  
ester.zhou 已提交
739
let wantTemp = {
740 741
    bundleName: "com.example.myapplication",
    abilityName: "com.example.myapplication.MainAbility",
E
add doc  
ester.zhou 已提交
742 743 744 745
};
enterpriseDeviceManager.getEnterpriseInfo(wantTemp, (error, result) => {
    if (error != null) {
        console.log("error occurs" + error);
746
        return;
E
add doc  
ester.zhou 已提交
747 748
    }
    console.log(result.name);
749
    console.log(result.description);
E
add doc  
ester.zhou 已提交
750 751 752 753 754
});
```

## enterpriseDeviceManager.getEnterpriseInfo

755
getEnterpriseInfo(admin: Want): Promise&lt;EnterpriseInfo&gt;
E
add doc  
ester.zhou 已提交
756 757 758

Obtains the enterprise information of a device administrator application. This API uses a promise to return the result.

759
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
E
add doc  
ester.zhou 已提交
760

E
ester.zhou 已提交
761 762
**System API**: This is a system API.

E
add doc  
ester.zhou 已提交
763 764
**Parameters**

765 766 767
| Name  | Type                                 | Mandatory  | Description     |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | Yes   | Device administrator application.|
E
add doc  
ester.zhou 已提交
768 769 770

**Return value**

771 772
| Type                                      | Description                       |
| ---------------------------------------- | ------------------------- |
E
ester.zhou 已提交
773
| Promise&lt;[EnterpriseInfo](#enterpriseinfo)&gt; | Promise used to return the enterprise information of the device administrator application.|
E
add doc  
ester.zhou 已提交
774

E
ester.zhou 已提交
775 776 777 778 779 780
**Error codes**

| Type     | Description                                                 |
| ------- | ----------------------------------------------------- |
| 9200001 | The application is not a administrator of the device. |

E
add doc  
ester.zhou 已提交
781 782
**Example**

783
```js
E
add doc  
ester.zhou 已提交
784
let wantTemp = {
785 786
    bundleName: "com.example.myapplication",
    abilityName: "com.example.myapplication.MainAbility",
E
add doc  
ester.zhou 已提交
787 788
};
enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => {
789 790
    console.log(result.name);
    console.log(result.description);
E
add doc  
ester.zhou 已提交
791
}).catch(error => {
792
    console.log("error occurs" + error);
E
add doc  
ester.zhou 已提交
793 794 795
});
```

E
ester.zhou 已提交
796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943
## enterpriseDeviceManager.subscribeManagedEvent

subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callback: AsyncCallback\<void>): void

Subscribes to system management events. This API uses an asynchronous callback to return the result.

**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT

**System capability**: SystemCapability.Customization.EnterpriseDeviceManager

**System API**: This is a system API.

**Parameters**

| Name  | Type                                 | Mandatory  | Description     |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | Yes   | Device administrator application.|
| managedEvents  | Array\<[ManagedEvent](#managedevent)> | Yes| Array of events to subscribe to.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the subscription is successful, **err** is **null**. Otherwise, **err** is an error object.|

**Example**

```js
let wantTemp = {
    bundleName: "bundleName",
    abilityName: "abilityName",
};
let events = [0, 1];
enterpriseDeviceManager.subscribeManagedEvent(wantTemp, events, (error) => {
    if (error) {
        console.log("error code:" + error.code + " error message:" + error.message);
    }
});
```

## enterpriseDeviceManager.subscribeManagedEvent

subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promise\<void>

Subscribes to system management events. This API uses a promise to return the result.

**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT

**System capability**: SystemCapability.Customization.EnterpriseDeviceManager

**System API**: This is a system API.

**Parameters**

| Name  | Type                                 | Mandatory  | Description     |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | Yes   | Device administrator application.|
| managedEvents  | Array\<[ManagedEvent](#managedevent)> | Yes| Array of events to subscribe to.|

**Return value**

| Type  | Description                                 |
| ----- | ----------------------------------- |
| Promise\<void> | Promise used to return the result. Promise that returns no value.|

**Example**

```js
let wantTemp = {
    bundleName: "bundleName",
    abilityName: "abilityName",
};
let events = [0, 1];
enterpriseDeviceManager.subscribeManagedEvent(wantTemp, events).then(() => {
}).catch((error) => {
    console.log("error code:" + error.code + " error message:" + error.message);
})
```

## enterpriseDeviceManager.unsubscribeManagedEvent

unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callback: AsyncCallback\<void>): void

Unsubscribes from system management events. This API uses an asynchronous callback to return the result.

**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT

**System capability**: SystemCapability.Customization.EnterpriseDeviceManager

**System API**: This is a system API.

**Parameters**

| Name  | Type                                 | Mandatory  | Description     |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | Yes   | Device administrator application.|
| managedEvents  | Array\<[ManagedEvent](#managedevent)> | Yes| Array of events to unsubscribe from.|
| callback | AsyncCallback\<void> | Yes| Callback used to return the result. If the unsubscription is successful, **err** is **null**. Otherwise, **err** is an error object.|

**Example**

```js
let wantTemp = {
    bundleName: "bundleName",
    abilityName: "abilityName",
};
let events = [0, 1];
enterpriseDeviceManager.unsubscribeManagedEvent(wantTemp, events, (error) => {
    if (error) {
        console.log("error code:" + error.code + " error message:" + error.message);
    }
});
```

## enterpriseDeviceManager.unsubscribeManagedEvent

unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promise\<void>

Unsubscribes from system management events. This API uses an asynchronous callback to return the result.

**Required permissions**: ohos.permission.ENTERPRISE_SUBSCRIBE_MANAGED_EVENT

**System capability**: SystemCapability.Customization.EnterpriseDeviceManager

**System API**: This is a system API.

**Parameters**

| Name  | Type                                 | Mandatory  | Description     |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | Yes   | Device administrator application.|
| managedEvents  | Array\<[ManagedEvent](#managedevent)> | Yes| Array of events to unsubscribe from.|

**Return value**

| Type  | Description                                 |
| ----- | ----------------------------------- |
| Promise\<void> | Promise used to return the result. Promise that returns no value.|

**Example**

```js
let wantTemp = {
    bundleName: "bundleName",
    abilityName: "abilityName",
};
let events = [0, 1];
enterpriseDeviceManager.unsubscribeManagedEvent(wantTemp, events).then(() => {
}).catch((error) => {
    console.log("error code:" + error.code + " error message:" + error.message);
})
```

E
add doc  
ester.zhou 已提交
944 945 946 947
## EnterpriseInfo

Describes the enterprise information of a device administrator application.

948
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
E
add doc  
ester.zhou 已提交
949

950 951 952 953
| Name         | Readable/Writable| Type    | Mandatory  | Description               |
| ----------- | ---- | ------ | ---- | ----------------- |
| name        | Read only  | string | Yes   | Name of the enterprise to which the device administrator application belongs.|
| description | Read only  | string | Yes   | Description of the enterprise to which the device administrator application belongs.|
E
add doc  
ester.zhou 已提交
954 955 956 957 958

## AdminType

Enumerates the administrator types of the device administrator application.

959
**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
E
ester.zhou 已提交
960

961 962 963 964
| Name               | Default Value | Description   |
| ----------------- | ---- | ----- |
| ADMIN_TYPE_NORMAL | 0x00 | Common administrator.|
| ADMIN_TYPE_SUPER  | 0x01 | Super administrator.|
E
ester.zhou 已提交
965 966 967 968 969 970 971 972 973 974 975

## ManagedEvent

Enumerates the system management events that can be subscribed to.

**System capability**: SystemCapability.Customization.EnterpriseDeviceManager

| Name               | Default Value | Description   |
| ----------------- | ---- | ----- |
| MANAGED_EVENT_BUNDLE_ADDED | 0 | Application installation event.|
| MANAGED_EVENT_BUNDLE_REMOVED  | 1 | Application uninstallation event.|