• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.enterprise.systemManager (系统管理)
2<!--Kit: MDM Kit-->
3<!--Subsystem: Customization-->
4<!--Owner: @huanleima-->
5<!--Designer: @liuzuming-->
6<!--Tester: @lpw_work-->
7<!--Adviser: @Brilliantry_Rui-->
8
9本模块提供系统管理能力。
10
11> **说明**:
12>
13> 本模块首批接口从API version 12开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
14>
15> 本模块接口仅可在Stage模型下使用。
16>
17> 本模块接口仅对设备管理应用开放,且调用接口前需激活设备管理应用,具体请参考[MDM Kit开发指南](../../mdm/mdm-kit-guide.md)。
18
19## 导入模块
20
21```ts
22import { systemManager } from '@kit.MDMKit';
23```
24
25## systemManager.setNTPServer
26
27setNTPServer(admin: Want, server: string): void
28
29设置NTP时间服务器。
30
31**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SYSTEM
32
33**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
34
35**模型约束:** 此接口仅可在Stage模型下使用。
36
37**参数:**
38
39| 参数名   | 类型                                  | 必填   | 说明      |
40| ----- | ----------------------------------- | ---- | ------- |
41| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是    | 企业设备管理扩展组件。 |
42| server | string | 是 | NTP服务器地址(以","分隔,如"ntpserver1.com,ntpserver2.com"。最大长度96字节,包括结束符)。 |
43
44**错误码**:
45
46以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
47
48| 错误码ID | 错误信息                                                                      |
49| ------- | ---------------------------------------------------------------------------- |
50| 9200001 | The application is not an administrator application of the device. |
51| 9200002 | The administrator application does not have permission to manage the device. |
52| 201 | Permission verification failed. The application does not have the permission required to call the API. |
53| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
54
55**示例:**
56
57```ts
58import { systemManager } from '@kit.MDMKit';
59import { Want } from '@kit.AbilityKit';
60
61let wantTemp: Want = {
62  // 需根据实际情况进行替换
63  bundleName: 'com.example.myapplication',
64  abilityName: 'EntryAbility'
65};
66// 需根据实际情况进行替换
67let server: string = "ntpserver.com";
68try {
69  systemManager.setNTPServer(wantTemp, server);
70  console.info('Succeeded in setting NTPserver.');
71} catch (err) {
72  console.error(`Failed to set ntp server. Code is ${err.code}, message is ${err.message}`);
73}
74```
75
76## systemManager.getNTPServer
77
78getNTPServer(admin: Want): string
79
80获取NTP时间服务器信息。
81
82**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SYSTEM
83
84**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
85
86**模型约束:** 此接口仅可在Stage模型下使用。
87
88**参数:**
89
90| 参数名 | 类型                                                    | 必填 | 说明                   |
91| ------ | ------------------------------------------------------- | ---- | ---------------------- |
92| admin  | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是   | 企业设备管理扩展组件。 |
93
94**返回值:**
95
96| 类型   | 说明                                |
97| ------ | ----------------------------------- |
98| string | string对象,返回NTP时间服务器信息。 |
99
100**错误码**:
101
102以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
103
104| 错误码ID | 错误信息                                                     |
105| -------- | ------------------------------------------------------------ |
106| 9200001  | The application is not an administrator application of the device. |
107| 9200002  | The administrator application does not have permission to manage the device. |
108| 201      | Permission verification failed. The application does not have the permission required to call the API. |
109| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
110
111**示例:**
112
113```ts
114import { systemManager } from '@kit.MDMKit';
115import { Want } from '@kit.AbilityKit';
116import { BusinessError } from '@ohos.base';
117
118let wantTemp: Want = {
119  // 需根据实际情况进行替换
120  bundleName: 'com.example.myapplication',
121  abilityName: 'EntryAbility'
122};
123try {
124  systemManager.getNTPServer(wantTemp);
125  console.info('Succeeded in getting NTP server.');
126} catch (err) {
127  console.error(`Failed to get ntp server. Code is ${err.code}, message is ${err.message}`);
128}
129```
130
131## systemManager.setOtaUpdatePolicy
132
133setOtaUpdatePolicy(admin: Want, policy: OtaUpdatePolicy): void
134
135设置升级策略。内网升级场景下,需要先调用[systemManager.notifyUpdatePackages](#systemmanagernotifyupdatepackages)接口通知系统更新包,再调用该接口设置升级策略。
136
137**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SYSTEM
138
139**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
140
141**模型约束:** 此接口仅可在Stage模型下使用。
142
143**参数:**
144
145| 参数名   | 类型                                  | 必填   | 说明      |
146| ----- | ----------------------------------- | ---- | ------- |
147| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是    | 企业设备管理扩展组件。 |
148| policy | [OtaUpdatePolicy](#otaupdatepolicy) | 是 | 升级策略。 |
149
150**错误码**:
151
152以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
153
154| 错误码ID | 错误信息                                                                      |
155| ------- | ---------------------------------------------------------------------------- |
156| 9200001 | The application is not an administrator application of the device.                       |
157| 9200002 | The administrator application does not have permission to manage the device. |
158| 201 | Permission verification failed. The application does not have the permission required to call the API. |
159| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
160
161**示例:**
162
163```ts
164import { systemManager } from '@kit.MDMKit';
165import { Want } from '@kit.AbilityKit';
166
167let wantTemp: Want = {
168  // 需根据实际情况进行替换
169  bundleName: 'com.example.myapplication',
170  abilityName: 'EntryAbility'
171};
172// 默认升级策略
173let otaUpdatePolicy1: systemManager.OtaUpdatePolicy = {
174  "policyType": systemManager.PolicyType.DEFAULT,
175  "version": "version_1.0.0.0",
176};
177try {
178  systemManager.setOtaUpdatePolicy(wantTemp, otaUpdatePolicy1);
179  console.info('Succeeded in setting ota update policy.');
180} catch (err) {
181  console.error(`Failed to set ota update policy. Code is ${err.code}, message is ${err.message}`);
182}
183// 禁止升级
184let otaUpdatePolicy2: systemManager.OtaUpdatePolicy = {
185  "policyType": systemManager.PolicyType.PROHIBIT,
186  "version": "version_1.0.0.1",
187};
188try {
189  systemManager.setOtaUpdatePolicy(wantTemp, otaUpdatePolicy2);
190  console.info('Succeeded in setting ota update policy.');
191} catch (err) {
192  console.error(`Failed to set ota update policy. Code is ${err.code}, message is ${err.message}`);
193}
194// 强制升级
195let otaUpdatePolicy3: systemManager.OtaUpdatePolicy = {
196  "policyType": systemManager.PolicyType.UPDATE_TO_SPECIFIC_VERSION,
197  "version": "version_1.0.0.2",
198  "latestUpdateTime": 1716343200, // 时间戳
199};
200try {
201  systemManager.setOtaUpdatePolicy(wantTemp, otaUpdatePolicy3);
202  console.info('Succeeded in setting ota update policy.');
203} catch (err) {
204  console.error(`Failed to set ota update policy. Code is ${err.code}, message is ${err.message}`);
205}
206// 指定时间窗口升级
207let otaUpdatePolicy4: systemManager.OtaUpdatePolicy = {
208  "policyType": systemManager.PolicyType.WINDOWS,
209  "version": "version_1.0.0.3",
210  "installStartTime": 1716281049, // // 时间戳
211  "installEndTime": 1716343200, // // 时间戳
212};
213try {
214  systemManager.setOtaUpdatePolicy(wantTemp, otaUpdatePolicy4);
215  console.info('Succeeded in setting ota update policy.');
216} catch (err) {
217  console.error(`Failed to set ota update policy. Code is ${err.code}, message is ${err.message}`);
218}
219// 延迟升级
220let otaUpdatePolicy5: systemManager.OtaUpdatePolicy = {
221  "policyType": systemManager.PolicyType.POSTPONE,
222  "version": "version_1.0.0.4",
223  "delayUpdateTime": 5, // 单位(小时)
224};
225try {
226  systemManager.setOtaUpdatePolicy(wantTemp, otaUpdatePolicy5);
227  console.info('Succeeded in setting ota update policy.');
228} catch (err) {
229  console.error(`Failed to set ota update policy. Code is ${err.code}, message is ${err.message}`);
230}
231// 禁用公网升级
232let otaUpdatePolicy6: systemManager.OtaUpdatePolicy = {
233  "policyType": systemManager.PolicyType.DEFAULT,
234  "version": "version_1.0.0.5",
235  "disableSystemOtaUpdate": true,
236};
237try {
238  systemManager.setOtaUpdatePolicy(wantTemp, otaUpdatePolicy6);
239  console.info('Succeeded in setting ota update policy.');
240} catch (err) {
241  console.error(`Failed to set ota update policy. Code is ${err.code}, message is ${err.message}`);
242}
243```
244
245## systemManager.getOtaUpdatePolicy
246
247getOtaUpdatePolicy(admin: Want): OtaUpdatePolicy
248
249查询升级策略。
250
251**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SYSTEM
252
253**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
254
255**模型约束:** 此接口仅可在Stage模型下使用。
256
257**参数:**
258
259| 参数名 | 类型                                                    | 必填 | 说明               |
260| ------ | ------------------------------------------------------- | ---- | ------------------ |
261| admin  | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是   | 企业设备管理扩展组件。 |
262
263**返回值:**
264
265| 类型   | 说明                            |
266| ------ | ------------------------------- |
267| [OtaUpdatePolicy](#otaupdatepolicy) | OtaUpdatePolicy对象,返回升级策略。 |
268
269**错误码**:
270
271以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
272
273| 错误码ID | 错误信息                                                     |
274| -------- | ------------------------------------------------------------ |
275| 9200001  | The application is not an administrator application of the device.       |
276| 9200002  | The administrator application does not have permission to manage the device. |
277| 201 | Permission verification failed. The application does not have the permission required to call the API. |
278| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
279
280**示例:**
281
282```ts
283import { systemManager } from '@kit.MDMKit';
284import { Want } from '@kit.AbilityKit';
285
286let wantTemp: Want = {
287  // 需根据实际情况进行替换
288  bundleName: 'com.example.myapplication',
289  abilityName: 'EntryAbility'
290};
291try {
292  let policy: systemManager.OtaUpdatePolicy= systemManager.getOtaUpdatePolicy(wantTemp);
293  console.info(`Succeeded in getting update policy: ${JSON.stringify(policy)}`);
294} catch (err) {
295  console.error(`Failed to get update policy. Code is ${err.code}, message is ${err.message}`);
296}
297```
298
299## systemManager.notifyUpdatePackages
300
301notifyUpdatePackages(admin: Want, packageInfo: UpdatePackageInfo): Promise&lt;void&gt;
302
303通知系统更新包信息。内网升级场景下,需要先调用该接口通知系统更新包,再调用[systemManager.setOtaUpdatePolicy](#systemmanagersetotaupdatepolicy)设置升级策略。
304
305**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SYSTEM
306
307**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
308
309**模型约束:** 此接口仅可在Stage模型下使用。
310
311**参数:**
312
313| 参数名 | 类型                                | 必填 | 说明           |
314| ------ | ----------------------------------- | ---- | -------------- |
315| admin  | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是   | 企业设备管理扩展组件。 |
316| packageInfo  | [UpdatePackageInfo](#updatepackageinfo) | 是   | 系统更新包信息。 |
317
318**返回值:**
319
320| 类型                   | 说明                      |
321| --------------------- | ------------------------- |
322| Promise&lt;void&gt; | 无返回结果的Promise对象。当通知系统更新包失败时会抛出错误对象。 |
323
324**错误码**:
325
326以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
327
328| 错误码ID | 错误信息                                                     |
329| -------- | ------------------------------------------------------------ |
330| 9200001  | The application is not an administrator application of the device.       |
331| 9200002  | The administrator application does not have permission to manage the device. |
332| 9201004  | The update packages do not exist or analyzing failed. |
333| 201 | Permission verification failed. The application does not have the permission required to call the API. |
334| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
335
336**示例:**
337
338```ts
339import { systemManager } from '@kit.MDMKit';
340import { BusinessError } from '@kit.BasicServicesKit';
341import { Want } from '@kit.AbilityKit';
342
343let wantTemp: Want = {
344  // 需根据实际情况进行替换
345  bundleName: 'com.example.myapplication',
346  abilityName: 'EntryAbility'
347};
348let notify: systemManager.NotifyDescription = {
349  // 需根据实际情况进行替换
350  "installTips": "installTips",
351  "installTipsDetail": "installTips detail"
352};
353let description: systemManager.PackageDescription = {
354  // 需根据实际情况进行替换
355  "notify": notify
356};
357let updatePackages: Array<systemManager.Package> = [{
358  // 需根据实际情况进行替换
359  "type": systemManager.PackageType.FIRMWARE,
360  "path": "path",
361  "fd": 60
362}];
363let updatePackageInfo: systemManager.UpdatePackageInfo = {
364  // 需根据实际情况进行替换
365  "version" : "1.0",
366  "packages" : updatePackages,
367  "description" : description
368};
369systemManager.notifyUpdatePackages(wantTemp, updatePackageInfo).then(() => {
370  console.info('Succeeded in notifying update packages.');
371}).catch ((error: BusinessError) => {
372  console.error(`Failed to notify update packages. Code is ${error.code},message is ${error.message}`);
373});
374```
375
376## systemManager.getUpdateResult
377
378getUpdateResult(admin: Want, version: string): Promise&lt;UpdateResult&gt;
379
380获取系统更新结果。
381
382**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SYSTEM
383
384**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
385
386**模型约束:** 此接口仅可在Stage模型下使用。
387
388**参数:**
389
390| 参数名 | 类型                                | 必填 | 说明           |
391| ------ | ----------------------------------- | ---- | -------------- |
392| admin  | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是   | 企业设备管理扩展组件。 |
393| version  | string | 是   | 更新包版本号。 |
394
395**返回值:**
396
397| 类型                   | 说明                      |
398| --------------------- | ------------------------- |
399| Promise&lt;[UpdateResult](#updateresult)&gt; | Promise对象,返回系统更新结果。 |
400
401**错误码**:
402
403以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
404
405| 错误码ID | 错误信息                                                     |
406| -------- | ------------------------------------------------------------ |
407| 9200001  | The application is not an administrator application of the device.       |
408| 9200002  | The administrator application does not have permission to manage the device. |
409| 201 | Permission verification failed. The application does not have the permission required to call the API. |
410| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed.|
411
412**示例:**
413
414```ts
415import { systemManager } from '@kit.MDMKit';
416import { BusinessError } from '@kit.BasicServicesKit';
417import { Want } from '@kit.AbilityKit';
418
419let wantTemp: Want = {
420  // 需根据实际情况进行替换
421  bundleName: 'com.example.myapplication',
422  abilityName: 'EntryAbility'
423};
424systemManager.getUpdateResult(wantTemp, "1.0").then((result:systemManager.UpdateResult) => {
425    console.info(`Succeeded in getting update result: ${JSON.stringify(result)}`);
426  }).catch((error: BusinessError) => {
427    console.error(`Get update result failed. Code is ${error.code},message is ${error.message}`);
428  });
429```
430## systemManager.getUpdateAuthData<sup>19+</sup>
431
432getUpdateAuthData(admin: Want): Promise&lt;string&gt;
433
434获取系统更新的鉴权数据,用于校验系统更新信息。使用Promise异步回调。
435
436**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SYSTEM
437
438**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
439
440**模型约束:** 此接口仅可在Stage模型下使用。
441
442**参数:**
443
444| 参数名 | 类型                                | 必填 | 说明           |
445| ------ | ----------------------------------- | ---- | -------------- |
446| admin  | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是   | 企业设备管理扩展组件。 |
447
448**返回值:**
449
450| 类型                   | 说明                      |
451| --------------------- | ------------------------- |
452| Promise&lt;string&gt; | Promise对象,返回系统更新的鉴权数据。 |
453
454**错误码**:
455
456以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
457
458| 错误码ID | 错误信息                                                     |
459| -------- | ------------------------------------------------------------ |
460| 9200001  | The application is not an administrator application of the device.       |
461| 9200002  | The administrator application does not have permission to manage the device. |
462| 201 | Permission verification failed. The application does not have the permission required to call the API. |
463
464**示例:**
465
466```ts
467import { systemManager } from '@kit.MDMKit';
468import { BusinessError } from '@kit.BasicServicesKit';
469import { Want } from '@kit.AbilityKit';
470
471let wantTemp: Want = {
472  // 需根据实际情况进行替换
473  bundleName: 'com.example.myapplication',
474  abilityName: 'EntryAbility'
475};
476systemManager.getUpdateAuthData(wantTemp).then((result: string) => {
477    console.info(`Succeeded in getting update auth data: ${JSON.stringify(result)}`);
478  }).catch((error: BusinessError) => {
479    console.error(`Get update auth data failed. Code is ${error.code},message is ${error.message}`);
480  });
481```
482
483## systemManager.addDisallowedNearLinkProtocols<sup>20+</sup>
484
485addDisallowedNearLinkProtocols(admin: Want, protocols: Array&lt;NearLinkProtocol&gt;, accountId: number): void
486
487为指定用户添加禁用的星闪协议名单。NearLink Kit(星闪服务)提供一种低功耗、高速率的短距离通信服务,支持星闪设备之间的连接、数据交互。<!--RP3--><!--RP3End-->本接口对键盘、手写笔等系统服务和系统应用不生效。
488
489**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SYSTEM
490
491**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
492
493**设备行为差异:** 该接口在PC/2in1设备中可正常调用,在其他设备中返回801错误码。
494
495**模型约束:** 此接口仅可在Stage模型下使用。
496
497**参数:**
498
499| 参数名   | 类型                                                    | 必填 | 说明                                                         |
500| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
501| admin    | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是   | 企业设备管理扩展组件。                                   |
502| protocols  | Array&lt;[NearLinkProtocol](#nearlinkprotocol20)&gt;               | 是   | 星闪协议列表。 |
503| accountId | number                                                 | 是   | 用户ID,取值范围:大于等于0。<br/>accountId可以通过[getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9)等接口来获取。 |
504
505
506**错误码**:
507
508以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
509
510
511| 错误码ID | 错误信息                                                     |
512| -------- | ------------------------------------------------------------ |
513| 9200001  | The application is not an administrator application of the device. |
514| 9200002  | The administrator application does not have permission to manage the device. |
515| 9200012  | Parameter verification failed. |
516| 201      | Permission verification failed. The application does not have the permission required to call the API. |
517| 801      | Capability not supported. Failed to call the API due to limited device capabilities. |
518
519
520**示例:**
521
522```ts
523import { systemManager } from '@kit.MDMKit';
524import { Want } from '@kit.AbilityKit';
525
526let wantTemp: Want = {
527  // 需根据实际情况进行替换
528  bundleName: 'com.example.myapplication',
529  abilityName: 'EntryAbility'
530};
531
532// 需根据实际情况进行替换
533let protocols: systemManager.NearLinkProtocol[] = [systemManager.NearLinkProtocol.SSAP,
534  systemManager.NearLinkProtocol.DATA_TRANSFER];
535
536// 需根据实际情况进行替换
537let accountId: number = 100;
538
539try {
540  systemManager.addDisallowedNearLinkProtocols(wantTemp, protocols, accountId);
541  console.info('Succeeded in adding the disabled Starlink protocol list for the specified user.');
542} catch (err) {
543  console.error(`Failed to add the disabled Starlink protocol list for the specified user. Code is ${err.code}, message is ${err.message}`);
544}
545```
546
547## systemManager.removeDisallowedNearLinkProtocols<sup>20+</sup>
548
549removeDisallowedNearLinkProtocols(admin: Want, protocols: Array&lt;NearLinkProtocol&gt;, accountId: number): void
550
551为指定用户移除禁用的星闪协议名单。
552
553
554**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SYSTEM
555
556**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
557
558**设备行为差异:** 该接口在PC/2in1设备中可正常调用,在其他设备中返回801错误码。
559
560**模型约束:** 此接口仅可在Stage模型下使用。
561
562**参数:**
563
564| 参数名   | 类型                                                    | 必填 | 说明                                                         |
565| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
566| admin    | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是   | 企业设备管理扩展组件。                                   |
567| protocols  | Array&lt;[NearLinkProtocol](#nearlinkprotocol20)&gt;               | 是   | 星闪协议列表。 |
568| accountId | number                                                 | 是   | 用户ID,取值范围:大于等于0。<br/>accountId可以通过[getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9)等接口来获取。 |
569
570**错误码**:
571
572以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
573
574| 错误码ID | 错误信息                                                     |
575| -------- | ------------------------------------------------------------ |
576| 9200001  | The application is not an administrator application of the device. |
577| 9200002  | The administrator application does not have permission to manage the device. |
578| 9200012  | Parameter verification failed. |
579| 201      | Permission verification failed. The application does not have the permission required to call the API. |
580| 801      | Capability not supported. Failed to call the API due to limited device capabilities. |
581
582**示例:**
583
584```ts
585import { systemManager } from '@kit.MDMKit';
586import { Want } from '@kit.AbilityKit';
587
588let wantTemp: Want = {
589  // 需根据实际情况进行替换
590  bundleName: 'com.example.myapplication',
591  abilityName: 'EntryAbility'
592};
593
594// 需根据实际情况进行替换
595let protocols: systemManager.NearLinkProtocol[] = [systemManager.NearLinkProtocol.SSAP,
596  systemManager.NearLinkProtocol.DATA_TRANSFER];
597
598// 需根据实际情况进行替换
599let accountId: number = 100;
600try {
601  systemManager.removeDisallowedNearLinkProtocols(wantTemp, protocols, accountId);
602  console.info('Succeeded in removing the disabled Starlink protocol list for the specified user.');
603} catch (err) {
604  console.error(`Failed to remove the disabled Starlink protocol list for the specified user. Code is ${err.code}, message is ${err.message}`);
605}
606```
607
608## systemManager.getDisallowedNearLinkProtocols<sup>20+</sup>
609
610getDisallowedNearLinkProtocols(admin: Want, accountId: number): Array&lt;NearLinkProtocol&gt;
611
612获取指定用户下禁用的星闪协议名单。
613
614**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SYSTEM
615
616**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
617
618**设备行为差异:** 该接口在PC/2in1设备中可正常调用,在其他设备中返回801错误码。
619
620**模型约束:** 此接口仅可在Stage模型下使用。
621
622**参数:**
623
624| 参数名  | 类型                                                    | 必填 | 说明                                                         |
625| ------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
626| admin   | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是   | 企业设备管理扩展组件。                                   |
627| accountId | number                                                 | 是   | 用户ID,取值范围:大于等于0。<br/>accountId可以通过[getOsAccountLocalId](../apis-basic-services-kit/js-apis-osAccount.md#getosaccountlocalid9)等接口来获取。 |
628
629**返回值:**
630
631| 类型    | 说明                                                         |
632| ------- | ------------------------------------------------------------ |
633| Array&lt;[NearLinkProtocol](#nearlinkprotocol20)&gt;          | 指定用户下禁用的星闪协议名单。 |
634
635**错误码**:
636
637以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
638
639| 错误码ID | 错误信息                                                     |
640| -------- | ------------------------------------------------------------ |
641| 9200001  | The application is not an administrator application of the device. |
642| 9200002  | The administrator application does not have permission to manage the device. |
643| 201      | Permission verification failed. The application does not have the permission required to call the API. |
644| 801      | Capability not supported. Failed to call the API due to limited device capabilities. |
645
646**示例:**
647
648```ts
649import { systemManager } from '@kit.MDMKit';
650import { Want } from '@kit.AbilityKit';
651
652let wantTemp: Want = {
653  // 需根据实际情况进行替换
654  bundleName: 'com.example.myapplication',
655  abilityName: 'EntryAbility'
656};
657
658// 需根据实际情况进行替换
659let accountId: number = 100;
660
661try {
662  let result: systemManager.NearLinkProtocol[] = systemManager.getDisallowedNearLinkProtocols(wantTemp, accountId);
663  console.info(`Succeeded in querying the disabled Starlink protocol list for the specified user: ${result}`);
664} catch (err) {
665  console.error(`Failed to query the disabled Starlink protocol list for the specified user. Code is ${err.code}, message is ${err.message}`);
666}
667```
668
669## systemManager.setInstallLocalEnterpriseAppEnabled<sup>20+</sup>
670
671setInstallLocalEnterpriseAppEnabled(admin: Want, isEnable: boolean): void
672
673设置是否支持本地安装企业应用。设置为支持安装后,具备本地安装能力的PC/2in1设备可本地双击应用安装包,安装签名证书分发类型为enterprise_normal的企业应用。
674
675**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SYSTEM
676
677**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
678
679**设备行为差异:** 该接口在PC/2in1设备中可正常调用,在其他设备中返回801错误码。
680
681**模型约束:** 此接口仅可在Stage模型下使用。
682
683**参数:**
684
685| 参数名   | 类型                                  | 必填  | 说明 |
686| ----- | ----------------------------------- | ---- | ------- |
687| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是 | 企业设备管理扩展组件。 |
688| isEnable | boolean | 是 | 是否支持本地安装企业应用。true表示支持,false表示不支持。 |
689
690**错误码**:
691
692以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
693
694| 错误码ID | 错误信息                                                                      |
695| ------- | ---------------------------------------------------------------------------- |
696| 9200001 | The application is not an administrator application of the device. |
697| 9200002 | The administrator application does not have permission to manage the device. |
698| 201 | Permission verification failed. The application does not have the permission required to call the API. |
699| 801      | Capability not supported. Failed to call the API due to limited device capabilities. |
700
701**示例:**
702
703```ts
704
705import { systemManager } from '@kit.MDMKit';
706import { Want } from '@kit.AbilityKit';
707
708let wantTemp: Want = {
709  // 需根据实际情况进行替换
710  bundleName: 'com.example.myapplication',
711  abilityName: 'EntryAbility'
712};
713// 需根据实际情况进行替换
714let isEnable: boolean = true;
715try {
716  systemManager.setInstallLocalEnterpriseAppEnabled(wantTemp, isEnable);
717  console.info('Succeeded in setting InstallLocalEnterpriseAppEnabled.');
718} catch (err) {
719  console.error(`Failed to set installLocalEnterpriseAppEnabled. Code is ${err.code}, message is ${err.message}`);
720}
721```
722
723## systemManager.getInstallLocalEnterpriseAppEnabled<sup>20+</sup>
724
725getInstallLocalEnterpriseAppEnabled(admin: Want): boolean
726
727查询是否支持本地安装企业应用。
728
729**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SYSTEM
730
731**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
732
733**设备行为差异:** 该接口在PC/2in1设备中可正常调用,在其他设备中返回801错误码。
734
735**模型约束:** 此接口仅可在Stage模型下使用。
736
737**参数:**
738
739| 参数名 | 类型                                                    | 必填 | 说明                   |
740| ------ | ------------------------------------------------------- | ---- | ---------------------- |
741| admin  | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是   | 企业设备管理扩展组件。 |
742
743**返回值:**
744
745| 类型   | 说明                                |
746| ------ | ----------------------------------- |
747| boolean | 是否支持本地安装企业应用,true为支持,false为不支持。 |
748
749**错误码**:
750
751以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
752
753| 错误码ID | 错误信息                                                     |
754| -------- | ------------------------------------------------------------ |
755| 9200001  | The application is not an administrator application of the device. |
756| 9200002  | The administrator application does not have permission to manage the device. |
757| 201      | Permission verification failed. The application does not have the permission required to call the API. |
758| 801      | Capability not supported. Failed to call the API due to limited device capabilities. |
759
760**示例:**
761
762```ts
763import { systemManager } from '@kit.MDMKit';
764import { Want } from '@kit.AbilityKit';
765
766let wantTemp: Want = {
767  // 需根据实际情况进行替换
768  bundleName: 'com.example.myapplication',
769  abilityName: 'EntryAbility'
770};
771try {
772  let isEnable: boolean = systemManager.getInstallLocalEnterpriseAppEnabled(wantTemp);
773  console.info('Succeeded in getting installLocalEnterpriseAppEnabled.');
774} catch (err) {
775  console.error(`Failed to get installLocalEnterpriseAppEnabled. Code is ${err.code}, message is ${err.message}`);
776}
777```
778
779
780## systemManager.setAutoUnlockAfterReboot<sup>20+</sup>
781
782setAutoUnlockAfterReboot(admin: Want, isAllowed: boolean): void
783
784设置设备重启自动解锁,仅针对无锁屏密码设备生效。
785
786**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SYSTEM
787
788**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
789
790**设备行为差异:** 该接口在PC/2in1设备中可正常调用,在其他设备中返回801错误码。
791
792**模型约束:** 此接口仅可在Stage模型下使用。
793
794**参数:**
795
796| 参数名   | 类型                                  | 必填   | 说明      |
797| ----- | ----------------------------------- | ---- | ------- |
798| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是    | 企业设备管理扩展组件。 |
799| isAllowed | boolean | 是 | true表示设备重启后自动解锁,false表示设备重启后不自动解锁。 |
800
801**错误码**:
802
803以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
804
805| 错误码ID | 错误信息                                                                      |
806| ------- | ---------------------------------------------------------------------------- |
807| 9200001 | The application is not an administrator application of the device. |
808| 9200002 | The administrator application does not have permission to manage the device. |
809| 201 | Permission verification failed. The application does not have the permission required to call the API. |
810| 801      | Capability not supported. Failed to call the API due to limited device capabilities. |
811
812**示例:**
813
814```ts
815import { Want } from '@kit.AbilityKit';
816import { systemManager } from '@kit.MDMKit';
817
818let wantTemp: Want = {
819  // 需根据实际情况进行替换
820  bundleName: 'com.example.myapplication',
821  abilityName: 'EntryAbility'
822};
823let isAllowed: boolean = true;
824try {
825  systemManager.setAutoUnlockAfterReboot(wantTemp, isAllowed);
826  console.info('Succeeded in setting setAutoUnlockAfterReboot.');
827} catch (err) {
828  console.error(`Failed to set auto unlock after reboot. Code is ${err.code}, message is ${err.message}`);
829}
830```
831
832## systemManager.getAutoUnlockAfterReboot<sup>20+</sup>
833
834getAutoUnlockAfterReboot(admin: Want): boolean
835
836获取设备是否重启自动解锁。
837
838**需要权限:** ohos.permission.ENTERPRISE_MANAGE_SYSTEM
839
840**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
841
842**设备行为差异:** 该接口在PC/2in1设备中可正常调用,在其他设备中返回801错误码。
843
844**模型约束:** 此接口仅可在Stage模型下使用。
845
846**参数:**
847
848| 参数名 | 类型                                                    | 必填 | 说明                   |
849| ------ | ------------------------------------------------------- | ---- | ---------------------- |
850| admin  | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是   | 企业设备管理扩展组件。 |
851
852**返回值:**
853
854| 类型   | 说明                                |
855| ------ | ----------------------------------- |
856| boolean | 返回true表示设备重启后自动解锁,返回false表示设备重启后不自动解锁。 |
857
858**错误码**:
859
860以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
861
862| 错误码ID | 错误信息                                                     |
863| -------- | ------------------------------------------------------------ |
864| 9200001  | The application is not an administrator application of the device. |
865| 9200002  | The administrator application does not have permission to manage the device. |
866| 201      | Permission verification failed. The application does not have the permission required to call the API. |
867| 801      | Capability not supported. Failed to call the API due to limited device capabilities. |
868
869**示例:**
870
871```ts
872import { Want } from '@kit.AbilityKit';
873import { systemManager } from '@kit.MDMKit';
874
875let wantTemp: Want = {
876  // 需根据实际情况进行替换
877  bundleName: 'com.example.myapplication',
878  abilityName: 'EntryAbility'
879};
880try {
881  systemManager.getAutoUnlockAfterReboot(wantTemp);
882  console.info('Succeeded in getting auto unlock after reboot.');
883} catch (err) {
884  console.error(`Failed to get auto unlock after reboot. Code is ${err.code}, message is ${err.message}`);
885}
886```
887
888## SystemUpdateInfo
889
890待更新的系统版本信息。
891
892**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
893
894| 名称                | 类型     | 只读  | 可选 | 说明            |
895| ----------------- | ------ | --- | --- |------------- |
896| versionName       | string | 否   | 否 |待更新的系统版本名称。   |
897| firstReceivedTime | number | 否   | 否 |第一次收到系统更新包的时间。 |
898| packageType       | string | 否   | 否 |待更新的系统更新包类型。  |
899
900## OtaUpdatePolicy
901
902升级策略。
903
904**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
905
906| 名称         | 类型     | 只读 | 可选 | 说明                            |
907| ----------- | --------| ---- | -----| -------------------------- |
908| policyType        | [PolicyType](#policytype)   | 否   | 否 | 表示升级策略类型。 |
909| version | string   | 否   | 否 |表示待升级软件版本号。 |
910| latestUpdateTime        | number   | 否   | 是 | 表示最晚升级时间(时间戳)。 |
911| delayUpdateTime | number   | 否   | 是 | 表示延迟升级时间(单位:小时)。 |
912| installStartTime        | number   | 否   | 是 | 表示指定安装窗口起始时间(时间戳)。 |
913| installEndTime | number   | 否   | 是 | 表示指定安装窗口结束时间(时间戳)。 |
914| disableSystemOtaUpdate<sup>20+</sup> | boolean   | 否   | 是 | 表示是否禁用在公网环境下升级。true表示禁用公网升级,false表示不禁用公网升级。如果作为[systemManager.setOtaUpdatePolicy](#systemmanagersetotaupdatepolicy)的入参,该字段可缺省,缺省时保持当前配置不变。当前配置可通过[systemManager.getOtaUpdatePolicy](#systemmanagergetotaupdatepolicy)接口获取。禁用公网升级后,可以采用内网升级。<!--RP4--><!--RP4End--> |
915
916## PolicyType
917
918升级策略类型枚举。
919
920**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
921
922| 名称                | 值  | 说明    |
923| ----------------- | ---- | ----- |
924| DEFAULT | 0 | 默认升级策略。周期提示用户,用户确认后升级。 |
925| PROHIBIT  | 1 | 禁止升级策略。 |
926| UPDATE_TO_SPECIFIC_VERSION | 2 | 强制升级策略。需指定最晚升级时间(latestUpdateTime)参数。 |
927| WINDOWS | 3 | 指定时间窗口升级策略。需指定时间窗口参数(installStartTime、installEndTime)。 |
928| POSTPONE | 4 | 延迟升级策略。延迟指定时间(delayUpdateTime)后进入DEFAULT模式,周期提示用户升级。 |
929
930## UpdatePackageInfo
931
932系统更新包信息。
933
934**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
935
936| 名称                | 类型     | 只读  | 可选 | 说明            |
937| ----------------- | ------ | --- | ---- |------------- |
938| version       | string | 否   | 否 | 系统更新包版本号。   |
939| packages | Array&lt;[Package](#package)&gt; | 否   | 否 | 系统更新包详情。 |
940| description       | [PackageDescription](#packagedescription) | 否   | 是 | 系统更新包描述信息。  |
941| authInfo<sup>19+</sup> | string | 否 | 是 | 系统更新包的鉴权信息。 |
942
943## Package
944
945系统更新包详情。
946
947**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
948
949| 名称                | 类型     | 只读  | 可选 | 说明            |
950| ----------------- | ------ | --- | --- | ------------- |
951| type       | [PackageType](#packagetype) | 否   | 否 |  系统更新包类型。   |
952| path | string | 否   | 否 | 系统更新包文件路径。若传入fd参数,该参数传入更新包文件名。 |
953| fd       | number | 否   | 是 | 系统更新包文件句柄。当前不支持只传入path参数,需要传入fd。  |
954
955## PackageDescription
956
957系统更新包描述信息。
958
959**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
960
961| 名称                | 类型     | 只读  | 可选 | 说明            |
962| ----------------- | ------ | --- | --- | ------------- |
963| notify       | [NotifyDescription](#notifydescription) | 否   | 是 | 企业自定义更新通知说明。   |
964
965## NotifyDescription
966
967企业自定义更新通知说明。
968
969**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
970
971| 名称                | 类型     | 只读  |  可选 | 说明            |
972| ----------------- | ------ | --- | ---- | ------------- |
973| installTips       | string | 否   | 是 | 企业自定义更新提示。   |
974| installTipsDetail       | string | 否   | 是 | 企业自定义更新提示详情。   |
975
976## UpdateResult
977
978系统更新结果信息。
979
980**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
981
982| 名称                | 类型   | 只读  | 可选   | 说明            |
983| ----------------- | ------ | ------ | ------ | ------------- |
984| version       | string |  否 | 否 |系统当前版本号。   |
985| status       | [UpdateStatus](#updatestatus) | 否 | 否 | 系统更新状态。   |
986| errorInfo       | [ErrorInfo](#errorinfo) | 否 | 否 | 系统更新错误信息。   |
987
988## ErrorInfo
989
990系统更新错误信息。
991
992**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
993
994| 名称                | 类型     | 只读  | 可选 | 说明            |
995| ----------------- | ------ | ------ | ------ | ------------- |
996| code       | number | 否 | 否 | 错误码。   |
997| message       | string | 否 | 否 | 错误描述信息。   |
998
999## PackageType
1000
1001系统更新包类型。
1002
1003**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
1004
1005| 名称                | 值  | 说明    |
1006| ----------------- | ---- | ----- |
1007| FIRMWARE | 1 | 固件。 |
1008
1009## UpdateStatus
1010
1011系统更新状态。
1012
1013**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
1014
1015| 名称               | 值  | 说明    |
1016| -----------------  | ---- | ----- |
1017| NO_UPDATE_PACKAGE  | -4 | 指定版本系统更新包不存在。 |
1018| UPDATE_WAITING     | -3 | 系统更新包等待安装中。 |
1019| UPDATING           | -2 | 正在更新。 |
1020| UPDATE_FAILURE     | -1 | 更新失败。 |
1021| UPDATE_SUCCESS     | 0 | 更新成功。 |
1022
1023## NearLinkProtocol<sup>20+</sup>
1024
1025星闪协议枚举。
1026
1027**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
1028
1029**模型约束:** 此接口仅可在Stage模型下使用。
1030
1031| 名称               | 值  | 说明    |
1032| -----------------  | ---- | ----- |
1033| SSAP   | 0 |  SSAP(SparkLink Service Access Protocol)协议。<!--RP1--><!--RP1End--> |
1034| DATA_TRANSFER      | 1 | 数据传输协议。<!--RP2--><!--RP2End--> |