js-apis-enterprise-device-manager.md 28.8 KB
Newer Older
C
caiminggang 已提交
1 2
# 企业设备管理

3 4
本模块提供企业设备管理能力,使设备具备企业场景下所需的定制能力。

H
HelloCrease 已提交
5
> **说明:**
H
HelloCrease 已提交
6
>
C
caiminggang 已提交
7 8 9 10
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。

## 导入模块

H
HelloCrease 已提交
11
```js
C
caiminggang 已提交
12 13 14
import enterpriseDeviceManager from '@ohos.enterpriseDeviceManager';
```

15
## enterpriseDeviceManager.enableAdmin
C
caiminggang 已提交
16

17
enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, callback: AsyncCallback\<boolean>): void
C
caiminggang 已提交
18 19 20

以异步方法根据给定的包名和类名激活设备管理员应用,使用Callback形式返回是否激活成功。

L
liwuli 已提交
21
**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
C
caiminggang 已提交
22

H
HelloCrease 已提交
23
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
C
caiminggang 已提交
24 25 26

**参数**

H
HelloCrease 已提交
27 28 29
| 参数名            | 类型                                  | 必填   | 说明                 |
| -------------- | ----------------------------------- | ---- | ------------------ |
| admin          | [Want](js-apis-application-Want.md) | 是    | 设备管理员应用            |
L
liwuli 已提交
30 31
| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo)   | 是    | 设备管理员应用的企业信息       |
| type           | [AdminType](#admintype)             | 是    | 激活的设备管理员类型         |
H
HelloCrease 已提交
32
| callback       | AsyncCallback\<boolean>             | 是    | callback方式返回是否激活成功 |
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59

**示例**

```js
let wantTemp = {
    bundleName: "com.example.myapplication",
    abilityName: "com.example.myapplication.MainAbility",
};
let enterpriseInfo = {
    name: "enterprise name",
    description: "enterprise description"
}
enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, (error, result) => {
    if (error != null) {
        console.log("error occurs" + error);
        return;
    }
    console.log("result is " + result);
});
```

## enterpriseDeviceManager.enableAdmin

enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId: number, callback: AsyncCallback\<boolean>): void

以异步方法根据给定的包名和类名激活设备管理员应用,使用Callback形式返回是否激活成功。

L
liwuli 已提交
60
**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
61

H
HelloCrease 已提交
62
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
63 64 65

**参数**

H
HelloCrease 已提交
66 67 68
| 参数名            | 类型                                  | 必填   | 说明                           |
| -------------- | ----------------------------------- | ---- | ---------------------------- |
| admin          | [Want](js-apis-application-Want.md) | 是    | 设备管理员应用                      |
L
liwuli 已提交
69 70
| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo)   | 是    | 设备管理员应用的企业信息                 |
| type           | [AdminType](#admintype)             | 是    | 激活的设备管理员类型                   |
H
HelloCrease 已提交
71 72
| userId         | number                              | 是    | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
| callback       | AsyncCallback\<boolean>             | 是    | callback方式返回是否激活成功           |
C
caiminggang 已提交
73 74 75

**示例**

H
HelloCrease 已提交
76
```js
C
caiminggang 已提交
77
let wantTemp = {
78 79
    bundleName: "com.example.myapplication",
    abilityName: "com.example.myapplication.MainAbility",
C
caiminggang 已提交
80 81
};
let enterpriseInfo = {
82 83
    name: "enterprise name",
    description: "enterprise description"
C
caiminggang 已提交
84
}
85
enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, 100, (error, result) => {
C
caiminggang 已提交
86 87
    if (error != null) {
        console.log("error occurs" + error);
88
        return;
C
caiminggang 已提交
89
    }
H
HelloCrease 已提交
90
    console.log("result is " + result);
C
caiminggang 已提交
91 92 93
});
```

94
## enterpriseDeviceManager.enableAdmin
C
caiminggang 已提交
95

96
enableAdmin(admin: Want, enterpriseInfo: EnterpriseInfo, type: AdminType, userId?: number): Promise\<boolean>
C
caiminggang 已提交
97 98 99

以异步方法根据给定的包名和类名激活设备管理员应用,使用Promise形式返回是否激活成功。

L
liwuli 已提交
100
**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
C
caiminggang 已提交
101

H
HelloCrease 已提交
102
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
C
caiminggang 已提交
103 104 105

**参数**

H
HelloCrease 已提交
106 107 108
| 参数名            | 类型                                  | 必填   | 说明                           |
| -------------- | ----------------------------------- | ---- | ---------------------------- |
| admin          | [Want](js-apis-application-Want.md) | 是    | 设备管理员应用                      |
L
liwuli 已提交
109 110
| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo)   | 是    | 设备管理员应用的企业信息                 |
| type           | [AdminType](#admintype)             | 是    | 激活的设备管理员类型                   |
H
HelloCrease 已提交
111
| userId         | number                              | 否    | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
C
caiminggang 已提交
112 113 114

**返回值:**

H
HelloCrease 已提交
115 116
| 类型                | 说明                |
| ----------------- | ----------------- |
C
caiminggang 已提交
117 118 119 120
| Promise\<boolean> | Promise形式返回是否激活成功 |

**示例**

H
HelloCrease 已提交
121
```js
C
caiminggang 已提交
122
let wantTemp = {
123 124
    bundleName: "com.example.myapplication",
    abilityName: "com.example.myapplication.MainAbility",
C
caiminggang 已提交
125 126
};
let enterpriseInfo = {
127 128
    name: "enterprise name",
    description: "enterprise description"
C
caiminggang 已提交
129
}
130
enterpriseDeviceManager.enableAdmin(wantTemp, enterpriseInfo, enterpriseDeviceManager.AdminType.ADMIN_TYPE_NORMAL, 100)
C
caiminggang 已提交
131
.then((result) => {
132
    console.log("result is " + result);
C
caiminggang 已提交
133
}).catch(error => {
134
    console.log("error occurs" + error);
C
caiminggang 已提交
135 136 137
});
```

138
## enterpriseDeviceManager.disableAdmin
C
caiminggang 已提交
139

140 141 142 143
disableAdmin(admin: Want, callback: AsyncCallback\<boolean>): void

以异步方法根据给定的包名和类名将设备普通管理员应用去激活,使用Callback形式返回是否去激活成功。

L
liwuli 已提交
144
**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
145

H
HelloCrease 已提交
146
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
147 148 149

**参数**

H
HelloCrease 已提交
150 151 152 153
| 参数名      | 类型                                  | 必填   | 说明                  |
| -------- | ----------------------------------- | ---- | ------------------- |
| admin    | [Want](js-apis-application-Want.md) | 是    | 普通设备管理员应用           |
| callback | AsyncCallback\<boolean>             | 是    | callback方式返回是否去激活成功 |
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173

**示例**

```js
let wantTemp = {
    bundleName: "bundleName",
    abilityName: "abilityName",
};
enterpriseDeviceManager.disableAdmin(wantTemp, (error, result) => {
    if (error != null) {
        console.log("error occurs" + error);
        return;
    }
    console.log("result is " + result);
});
```

## enterpriseDeviceManager.disableAdmin

disableAdmin(admin: Want, userId: number, callback: AsyncCallback\<boolean>): void
C
caiminggang 已提交
174 175 176

以异步方法根据给定的包名和类名将设备普通管理员应用去激活,使用Callback形式返回是否去激活成功。

L
liwuli 已提交
177
**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
C
caiminggang 已提交
178

H
HelloCrease 已提交
179
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
C
caiminggang 已提交
180 181 182

**参数**

H
HelloCrease 已提交
183 184 185 186 187
| 参数名      | 类型                                  | 必填   | 说明                           |
| -------- | ----------------------------------- | ---- | ---------------------------- |
| admin    | [Want](js-apis-application-Want.md) | 是    | 普通设备管理员应用                    |
| userId   | number                              | 是    | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
| callback | AsyncCallback\<boolean>             | 是    | callback方式返回是否去激活成功          |
C
caiminggang 已提交
188 189 190

**示例**

H
HelloCrease 已提交
191
```js
C
caiminggang 已提交
192
let wantTemp = {
193 194
    bundleName: "bundleName",
    abilityName: "abilityName",
C
caiminggang 已提交
195
};
196
enterpriseDeviceManager.disableAdmin(wantTemp, 100, (error, result) => {
C
caiminggang 已提交
197 198
    if (error != null) {
        console.log("error occurs" + error);
199
        return;
C
caiminggang 已提交
200
    }
H
HelloCrease 已提交
201
    console.log("result is " + result);
C
caiminggang 已提交
202 203 204
});
```

205
## enterpriseDeviceManager.disableAdmin
C
caiminggang 已提交
206

207
disableAdmin(admin: Want, userId?: number): Promise\<boolean>
C
caiminggang 已提交
208 209 210

以异步方法根据给定的包名和类名将设备普通管理员应用去激活,使用Promise形式返回是否去激活成功。

L
liwuli 已提交
211
**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN
C
caiminggang 已提交
212

H
HelloCrease 已提交
213
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
C
caiminggang 已提交
214 215 216

**参数**

H
HelloCrease 已提交
217 218 219 220
| 参数名    | 类型                                  | 必填   | 说明                           |
| ------ | ----------------------------------- | ---- | ---------------------------- |
| admin  | [Want](js-apis-application-Want.md) | 是    | 普通设备管理员应用                    |
| userId | number                              | 否    | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
C
caiminggang 已提交
221 222 223

**返回值:**

H
HelloCrease 已提交
224 225
| 类型                | 说明                |
| ----------------- | ----------------- |
C
caiminggang 已提交
226 227 228 229
| Promise\<boolean> | Promise形式返回是否激活成功 |

**示例**

H
HelloCrease 已提交
230
```js
C
caiminggang 已提交
231
let wantTemp = {
232 233
    bundleName: "bundleName",
    abilityName: "abilityName",
C
caiminggang 已提交
234
};
235
enterpriseDeviceManager.disableAdmin(wantTemp, 100).then((result) => {
236
    console.log("result is " + result);
C
caiminggang 已提交
237
}).catch(error => {
238
    console.log("error occurs" + error);
C
caiminggang 已提交
239 240 241
});
```

242
## enterpriseDeviceManager.disableSuperAdmin
C
caiminggang 已提交
243

244
disableSuperAdmin(bundleName: String, callback: AsyncCallback\<boolean>): void
C
caiminggang 已提交
245 246 247

以异步方法根据给定的包名将设备超级管理员应用去激活,使用Callback形式返回是否去激活成功。

H
HelloCrease 已提交
248
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
C
caiminggang 已提交
249 250 251

**参数**

H
HelloCrease 已提交
252 253 254 255
| 参数名        | 类型                      | 必填   | 说明                  |
| ---------- | ----------------------- | ---- | ------------------- |
| bundleName | String                  | 是    | 超级设备管理员应用的包名        |
| callback   | AsyncCallback\<boolean> | 是    | callback方式返回是否去激活成功 |
C
caiminggang 已提交
256 257 258

**示例**

H
HelloCrease 已提交
259
```js
C
caiminggang 已提交
260
let bundleName = "com.example.myapplication";
261
enterpriseDeviceManager.disableSuperAdmin(bundleName, (error, result) => {
C
caiminggang 已提交
262 263
    if (error != null) {
        console.log("error occurs" + error);
264
        return;
C
caiminggang 已提交
265
    }
H
HelloCrease 已提交
266
    console.log("result is " + result);
C
caiminggang 已提交
267 268 269
});
```

270
## enterpriseDeviceManager.disableSuperAdmin
C
caiminggang 已提交
271

272
disableSuperAdmin(bundleName: String): Promise\<boolean>
C
caiminggang 已提交
273 274 275

以异步方法根据给定的包名将设备超级管理员应用去激活,使用Promise形式返回是否去激活成功。

H
HelloCrease 已提交
276
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
C
caiminggang 已提交
277 278 279

**参数**

H
HelloCrease 已提交
280 281 282
| 参数名        | 类型     | 必填   | 说明           |
| ---------- | ------ | ---- | ------------ |
| bundleName | String | 是    | 超级设备管理员应用的包名 |
C
caiminggang 已提交
283 284 285

**返回值:**

H
HelloCrease 已提交
286 287
| 类型                | 说明                |
| ----------------- | ----------------- |
C
caiminggang 已提交
288 289 290 291
| Promise\<boolean> | Promise形式返回是否激活成功 |

**示例**

H
HelloCrease 已提交
292
```js
C
caiminggang 已提交
293
let bundleName = "com.example.myapplication";
294
enterpriseDeviceManager.disableSuperAdmin(bundleName).then((result) => {
295
    console.log("result is " + result);
C
caiminggang 已提交
296
}).catch(error => {
297
    console.log("error occurs" + error);
C
caiminggang 已提交
298 299 300
});
```

301
## enterpriseDeviceManager.isAdminEnabled
C
caiminggang 已提交
302

303
isAdminEnabled(admin: Want, callback: AsyncCallback\<boolean>): void
C
caiminggang 已提交
304 305 306

以异步方法根据给定的包名和类名判断设备管理员应用是否被激活,使用Callback形式返回是否处于激活状态。

H
HelloCrease 已提交
307
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
C
caiminggang 已提交
308 309 310

**参数**

H
HelloCrease 已提交
311 312 313 314
| 参数名      | 类型                                  | 必填   | 说明                   |
| -------- | ----------------------------------- | ---- | -------------------- |
| admin    | [Want](js-apis-application-Want.md) | 是    | 设备管理员应用              |
| callback | AsyncCallback\<boolean>             | 是    | callback方式返回是否处于激活状态 |
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337

**示例**

```js
let wantTemp = {
    bundleName: "bundleName",
    abilityName: "abilityName",
};
enterpriseDeviceManager.isAdminEnabled(wantTemp, (error, result) => {
    if (error != null) {
        console.log("error occurs" + error);
        return;
    }
    console.log("result is " + result);
});
```

## enterpriseDeviceManager.isAdminEnabled

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

以异步方法根据给定的包名和类名判断设备管理员应用是否被激活,使用Callback形式返回是否处于激活状态。

H
HelloCrease 已提交
338
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
339 340 341

**参数**

H
HelloCrease 已提交
342 343 344 345 346
| 参数名      | 类型                                  | 必填   | 说明                           |
| -------- | ----------------------------------- | ---- | ---------------------------- |
| admin    | [Want](js-apis-application-Want.md) | 是    | 设备管理员应用                      |
| userId   | number                              | 是    | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
| callback | AsyncCallback\<boolean>             | 是    | callback方式返回是否处于激活状态         |
C
caiminggang 已提交
347 348 349

**示例**

H
HelloCrease 已提交
350
```js
C
caiminggang 已提交
351
let wantTemp = {
352 353
    bundleName: "bundleName",
    abilityName: "abilityName",
C
caiminggang 已提交
354
};
355
enterpriseDeviceManager.isAdminEnabled(wantTemp, 100, (error, result) => {
C
caiminggang 已提交
356 357
    if (error != null) {
        console.log("error occurs" + error);
358
        return;
C
caiminggang 已提交
359
    }
H
HelloCrease 已提交
360
    console.log("result is " + result);
C
caiminggang 已提交
361 362 363
});
```

364
## enterpriseDeviceManager.isAdminEnabled
C
caiminggang 已提交
365

366
isAdminEnabled(admin: Want, userId?: number): Promise\<boolean>
C
caiminggang 已提交
367 368 369

以异步方法根据给定的包名和类名判断设备管理员应用是否被激活,使用Promise形式返回是否处于激活状态。

H
HelloCrease 已提交
370
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
C
caiminggang 已提交
371 372 373

**参数**

H
HelloCrease 已提交
374 375 376 377
| 参数名    | 类型                                  | 必填   | 说明                           |
| ------ | ----------------------------------- | ---- | ---------------------------- |
| admin  | [Want](js-apis-application-Want.md) | 是    | 设备管理员应用                      |
| userId | number                              | 否    | 用户ID。默认值:调用方所在用户,取值范围:大于等于0。 |
C
caiminggang 已提交
378 379 380

**返回值:**

H
HelloCrease 已提交
381 382
| 类型                | 说明                  |
| ----------------- | ------------------- |
C
caiminggang 已提交
383 384 385 386
| Promise\<boolean> | Promise形式返回是否处于激活状态 |

**示例**

H
HelloCrease 已提交
387
```js
C
caiminggang 已提交
388
let wantTemp = {
389 390
    bundleName: "bundleName",
    abilityName: "abilityName",
C
caiminggang 已提交
391
};
392
enterpriseDeviceManager.isAdminEnabled(wantTemp, 100).then((result) => {
393
    console.log("result is " + result);
C
caiminggang 已提交
394
}).catch(error => {
395
    console.log("error occurs" + error);
C
caiminggang 已提交
396 397 398 399 400 401 402 403 404
});
```

## enterpriseDeviceManager.isSuperAdmin

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

以异步方法根据给定的包名判断设备超级管理员应用是否被激活,使用Callback形式返回是否处于激活状态。

H
HelloCrease 已提交
405
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
C
caiminggang 已提交
406 407 408

**参数**

H
HelloCrease 已提交
409 410 411 412
| 参数名        | 类型                      | 必填   | 说明                   |
| ---------- | ----------------------- | ---- | -------------------- |
| bundleName | String                  | 是    | 设备管理员应用              |
| callback   | AsyncCallback\<boolean> | 是    | callback方式返回是否处于激活状态 |
C
caiminggang 已提交
413 414 415

**示例**

H
HelloCrease 已提交
416
```js
C
caiminggang 已提交
417 418 419 420
let bundleName = "com.example.myapplication";
enterpriseDeviceManager.isSuperAdmin(bundleName, (error, result) => {
    if (error != null) {
        console.log("error occurs" + error);
421
        return;
C
caiminggang 已提交
422
    }
H
HelloCrease 已提交
423
    console.log("result is " + result);
C
caiminggang 已提交
424 425 426 427 428 429 430 431 432
});
```

## enterpriseDeviceManager.isSuperAdmin

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

以异步方法根据给定的包名判断设备超级管理员应用是否被激活,使用Promise形式返回是否处于激活状态。

H
HelloCrease 已提交
433
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
C
caiminggang 已提交
434 435 436

**参数**

H
HelloCrease 已提交
437 438 439
| 参数名        | 类型     | 必填   | 说明        |
| ---------- | ------ | ---- | --------- |
| bundleName | String | 是    | 超级设备管理员应用 |
C
caiminggang 已提交
440 441 442

**返回值:**

H
HelloCrease 已提交
443 444
| 类型                | 说明                  |
| ----------------- | ------------------- |
C
caiminggang 已提交
445 446 447 448
| Promise\<boolean> | Promise形式返回是否处于激活状态 |

**示例**

H
HelloCrease 已提交
449
```js
C
caiminggang 已提交
450 451
let bundleName = "com.example.myapplication";
enterpriseDeviceManager.isSuperAdmin(bundleName).then((result) => {
452
    console.log("result is " + result);
C
caiminggang 已提交
453
}).catch(error => {
454
    console.log("error occurs" + error);
C
caiminggang 已提交
455 456 457 458 459 460 461 462 463
});
```

## enterpriseDeviceManager.getDeviceSettingsManager

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

获取DeviceSettingsManager对象,使用callback形式返回DeviceSettingsManager对象。

H
HelloCrease 已提交
464
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
C
caiminggang 已提交
465 466 467

**参数:**

H
HelloCrease 已提交
468 469
| 参数名      | 类型                                      | 必填   | 说明                                  |
| -------- | --------------------------------------- | ---- | ----------------------------------- |
F
fangyun 已提交
470
| callback | AsyncCallback<[DeviceSettingsManager](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md)&gt; | 是    | callback方式返回DeviceSettingsManager对象 |
C
caiminggang 已提交
471 472 473

**示例:**

H
HelloCrease 已提交
474
```js
C
caiminggang 已提交
475
let wantTemp = {
476 477
    bundleName: "bundleName",
    abilityName: "abilityName",
C
caiminggang 已提交
478 479 480 481
};
enterpriseDeviceManager.getDeviceSettingsManager((error, mgr) => {
    if (error != null) {
        console.log("error occurs" + error);
482
        return;
C
caiminggang 已提交
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
    }
    mgr.setDateTime(wantTemp, 1526003846000, (error, value) => { 
        if (error != null) {
            console.log(error);
        } else {
            console.log(value);
        }
    });
});
```

## enterpriseDeviceManager.getDeviceSettingsManager

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

获取DeviceSettingsManager对象,使用Promise形式返回DeviceSettingsManager对象。

H
HelloCrease 已提交
500
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
C
caiminggang 已提交
501 502 503

**返回值:**

H
HelloCrease 已提交
504 505
| 类型                                   | 说明                                 |
| ------------------------------------ | ---------------------------------- |
F
fangyun 已提交
506
| Promise&lt;[DeviceSettingsManager](js-apis-enterpriseDeviceManager-DeviceSettingsManager.md)&gt; | Promise方式返回DeviceSettingsManager对象 |
C
caiminggang 已提交
507 508 509

**示例:**

H
HelloCrease 已提交
510
```js
C
caiminggang 已提交
511
let wantTemp = {
512 513
    bundleName: "bundleName",
    abilityName: "abilityName",
C
caiminggang 已提交
514
};
515
enterpriseDeviceManager.getDeviceSettingsManager().then((mgr) => {
C
caiminggang 已提交
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531
    mgr.setDateTime(wantTemp, 1526003846000).then((value) => {
        console.log(value);
    }).catch((error) => {
        console.log(error);
    })
}).catch((error) => {
    console.log(error);
})
```

## enterpriseDeviceManager.setEnterpriseInfo

setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo, callback: AsyncCallback&lt;boolean&gt;): void

设置设备管理员应用的企业信息,使用callback形式返回是否设置成功。

H
HelloCrease 已提交
532
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
C
caiminggang 已提交
533 534 535

**参数:**

H
HelloCrease 已提交
536 537 538
| 参数名            | 类型                                  | 必填   | 说明                     |
| -------------- | ----------------------------------- | ---- | ---------------------- |
| admin          | [Want](js-apis-application-Want.md) | 是    | 设备管理员应用                |
L
liwuli 已提交
539
| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo)   | 是    | 设备管理员应用的企业信息           |
H
HelloCrease 已提交
540
| callback       | AsyncCallback\<boolean&gt;          | 是    | callback方式返回是否设置企业信息成功 |
C
caiminggang 已提交
541 542 543

**示例:**

H
HelloCrease 已提交
544
```js
C
caiminggang 已提交
545
let wantTemp = {
546 547
    bundleName: "com.example.myapplication",
    abilityName: "com.example.myapplication.MainAbility",
C
caiminggang 已提交
548 549
};
let enterpriseInfo = {
550 551
    name: "enterprise name",
    description: "enterprise description"
C
caiminggang 已提交
552 553 554
}
enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo)
.then((result) => {
555
    console.log("result is " + result);
C
caiminggang 已提交
556
}).catch(error => {
557
    console.log("error occurs" + error);
C
caiminggang 已提交
558 559 560 561 562 563 564
});
```

## enterpriseDeviceManager.setEnterpriseInfo

setEnterpriseInfo(admin: Want, enterpriseInfo: EnterpriseInfo): Promise&lt;boolean&gt;

565
设置设备管理员应用的企业信息,使用Promise形式返回是否设置成功。
C
caiminggang 已提交
566

H
HelloCrease 已提交
567
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
C
caiminggang 已提交
568 569 570

**参数:**

H
HelloCrease 已提交
571 572 573
| 参数名            | 类型                                  | 必填   | 说明           |
| -------------- | ----------------------------------- | ---- | ------------ |
| admin          | [Want](js-apis-application-Want.md) | 是    | 设备管理员应用      |
L
liwuli 已提交
574
| enterpriseInfo | [EnterpriseInfo](#enterpriseinfo)   | 是    | 设备管理员应用的企业信息 |
C
caiminggang 已提交
575 576 577

**返回值:**

C
caiminggang 已提交
578 579
| 类型                | 说明                    |
| ----------------- | --------------------- |
580
| Promise\<boolean> | Promise方式返回是否设置企业信息成功 |
C
caiminggang 已提交
581 582 583

**示例:**

H
HelloCrease 已提交
584
```js
C
caiminggang 已提交
585
let wantTemp = {
586 587
    bundleName: "com.example.myapplication",
    abilityName: "com.example.myapplication.MainAbility",
C
caiminggang 已提交
588 589
};
let enterpriseInfo = {
590 591
    name: "enterprise name",
    description: "enterprise description"
C
caiminggang 已提交
592 593 594
}
enterpriseDeviceManager.setEnterpriseInfo(wantTemp, enterpriseInfo)
.then((result) => {
595
    console.log("result is " + result);
C
caiminggang 已提交
596
}).catch(error => {
597
    console.log("error occurs" + error);
C
caiminggang 已提交
598 599 600 601 602 603 604 605 606
});
```

## enterpriseDeviceManager.getEnterpriseInfo

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

获取设备管理员应用的企业信息,使用callback形式返回设备管理员应用的企业信息。

H
HelloCrease 已提交
607
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
C
caiminggang 已提交
608 609 610

**参数:**

H
HelloCrease 已提交
611 612 613
| 参数名      | 类型                                       | 必填   | 说明                       |
| -------- | ---------------------------------------- | ---- | ------------------------ |
| admin    | [Want](js-apis-application-Want.md)      | 是    | 设备管理员应用                  |
L
liwuli 已提交
614
| callback | AsyncCallback&lt;[EnterpriseInfo](#enterpriseinfo)&gt; | 是    | callback方式返回设备管理员应用的企业信息 |
C
caiminggang 已提交
615 616 617

**示例:**

H
HelloCrease 已提交
618
```js
C
caiminggang 已提交
619
let wantTemp = {
620 621
    bundleName: "com.example.myapplication",
    abilityName: "com.example.myapplication.MainAbility",
C
caiminggang 已提交
622 623 624 625
};
enterpriseDeviceManager.getEnterpriseInfo(wantTemp, (error, result) => {
    if (error != null) {
        console.log("error occurs" + error);
626
        return;
C
caiminggang 已提交
627 628
    }
    console.log(result.name);
629
    console.log(result.description);
C
caiminggang 已提交
630 631 632 633 634
});
```

## enterpriseDeviceManager.getEnterpriseInfo

635
getEnterpriseInfo(admin: Want): Promise&lt;EnterpriseInfo&gt;
C
caiminggang 已提交
636 637 638

获取设备管理员应用的企业信息,使用Promise形式返回设备管理员应用的企业信息。

H
HelloCrease 已提交
639
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
C
caiminggang 已提交
640 641 642

**参数:**

H
HelloCrease 已提交
643 644 645
| 参数名   | 类型                                  | 必填   | 说明      |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | 是    | 设备管理员应用 |
C
caiminggang 已提交
646 647 648

**返回值:**

H
HelloCrease 已提交
649 650
| 类型                                       | 说明                        |
| ---------------------------------------- | ------------------------- |
L
liwuli 已提交
651
| Promise&lt;[EnterpriseInfo](#enterpriseinfo)&gt; | Promise方式返回设备管理员应用的企业信息对象 |
C
caiminggang 已提交
652 653 654

**示例:**

H
HelloCrease 已提交
655
```js
C
caiminggang 已提交
656
let wantTemp = {
657 658
    bundleName: "com.example.myapplication",
    abilityName: "com.example.myapplication.MainAbility",
C
caiminggang 已提交
659 660
};
enterpriseDeviceManager.getEnterpriseInfo(wantTemp).then((result) => {
661 662
    console.log(result.name);
    console.log(result.description);
C
caiminggang 已提交
663
}).catch(error => {
664
    console.log("error occurs" + error);
C
caiminggang 已提交
665 666 667
});
```

F
fangyun 已提交
668 669
## enterpriseDeviceManager.subscribeManagedEvent

F
fangyun 已提交
670
subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callback: AsyncCallback\<void>): void
F
fangyun 已提交
671 672 673 674 675 676 677 678 679 680 681 682

订阅系统事件。使用callback异步回调。

**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN

**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager

**参数:**

| 参数名   | 类型                                  | 必填   | 说明      |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | 是    | 设备管理员应用。 |
F
fangyun 已提交
683
| managedEvents  | Array\<[ManagedEvent](#managedevent)> | 是 | 订阅事件数组。 |
F
fangyun 已提交
684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702
| callback | AsyncCallback\<void> | 是 | 回调函数。当系统事件订阅成功err为null,否则为错误对象。 |

**示例:**

```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

F
fangyun 已提交
703
subscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promise\<void>
F
fangyun 已提交
704 705 706 707 708 709 710 711 712 713 714 715

订阅系统事件。使用Promise异步回调。

**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN

**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager

**参数:**

| 参数名   | 类型                                  | 必填   | 说明      |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | 是    | 设备管理员应用。 |
F
fangyun 已提交
716
| managedEvents  | Array\<[ManagedEvent](#managedevent)> | 是 | 订阅事件数组。 |
F
fangyun 已提交
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739

**返回值:**

| 类型   | 说明                                  |
| ----- | ----------------------------------- |
| Promise\<void> | Promise对象。无返回结果的Promise对象。 |

**示例:**

```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

F
fangyun 已提交
740
unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>, callback: AsyncCallback\<void>): void
F
fangyun 已提交
741 742 743 744 745 746 747 748 749 750 751 752

取消订阅系统事件。使用callback异步回调。

**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN

**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager

**参数:**

| 参数名   | 类型                                  | 必填   | 说明      |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | 是    | 设备管理员应用。 |
F
fangyun 已提交
753
| managedEvents  | Array\<[ManagedEvent](#managedevent)> | 是 | 取消订阅事件数组。 |
F
fangyun 已提交
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772
| callback | AsyncCallback\<void> | 是 | 回调函数。当系统事件取消订阅成功err为null,否则为错误对象。 |

**示例:**

```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

F
fangyun 已提交
773
unsubscribeManagedEvent(admin: Want, managedEvents: Array\<ManagedEvent>): Promise\<void>
F
fangyun 已提交
774 775 776 777 778 779 780 781 782 783 784 785

取消订阅系统事件。使用callback异步回调。

**需要权限:** ohos.permission.MANAGE_ENTERPRISE_DEVICE_ADMIN

**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager

**参数:**

| 参数名   | 类型                                  | 必填   | 说明      |
| ----- | ----------------------------------- | ---- | ------- |
| admin | [Want](js-apis-application-Want.md) | 是    | 设备管理员应用。 |
F
fangyun 已提交
786
| managedEvents  | Array\<[ManagedEvent](#managedevent)> | 是 | 取消订阅事件数组。 |
F
fangyun 已提交
787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807

**返回值:**

| 类型   | 说明                                  |
| ----- | ----------------------------------- |
| Promise\<void> | Promise对象。无返回结果的Promise对象。 |

**示例:**

```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);
})
```

C
caiminggang 已提交
808 809 810 811
## EnterpriseInfo

设备管理员应用的企业信息

H
HelloCrease 已提交
812
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
C
caiminggang 已提交
813

H
HelloCrease 已提交
814 815 816 817
| 名称          | 读写属性 | 类型     | 必填   | 描述                |
| ----------- | ---- | ------ | ---- | ----------------- |
| name        | 只读   | string | 是    | 表示设备管理员应用所属企业的名称。 |
| description | 只读   | string | 是    | 表示设备管理员应用所属企业的描述。 |
C
caiminggang 已提交
818 819 820 821 822

## AdminType

设备管理员应用的管理员类型。

H
HelloCrease 已提交
823
**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 
C
caiminggang 已提交
824

H
HelloCrease 已提交
825 826
| 名称                | 默认值  | 说明    |
| ----------------- | ---- | ----- |
C
caiminggang 已提交
827
| ADMIN_TYPE_NORMAL | 0x00 | 普通管理员 |
H
HelloCrease 已提交
828
| ADMIN_TYPE_SUPER  | 0x01 | 超级管理员 |
F
fangyun 已提交
829 830 831 832 833 834 835 836 837 838

## ManagedEvent

可订阅系统事件。

**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager 

| 名称                | 默认值  | 说明    |
| ----------------- | ---- | ----- |
| MANAGED_EVENT_BUNDLE_ADDED | 0 | 应用安装事件。 |
F
fangyun 已提交
839
| MANAGED_EVENT_BUNDLE_REMOVED  | 1 | 应用卸载事件。 |
F
fangyun 已提交
840