• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.enterprise.restrictions (限制类策略)(系统接口)
2<!--Kit: MDM Kit-->
3<!--Subsystem: Customization-->
4<!--Owner: @huanleima-->
5<!--Designer: @liuzuming-->
6<!--Tester: @lpw_work-->
7<!--Adviser: @Brilliantry_Rui-->
8
9本模块提供设置通用限制类策略能力,包括禁用或启用设备打印、HDC等能力。
10
11> **说明**:
12>
13> 本模块首批接口从API version 10 开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
14>
15> 本模块接口仅可在Stage模型下使用。
16>
17> 本模块接口仅对[设备管理应用](../../mdm/mdm-kit-term.md#mdm应用设备管理应用)开放,需将[设备管理应用激活](js-apis-enterprise-adminManager-sys.md#adminmanagerenableadmin-2)后调用。
18>
19> 当前页面仅包含本模块的系统接口,其他公开接口参见。其他公开接口参见[@ohos.enterprise.restrictions](js-apis-enterprise-restrictions.md)。
20
21## 导入模块
22
23```ts
24import { restrictions } from '@kit.MDMKit';
25```
26
27## restrictions.setPrinterDisabled
28
29setPrinterDisabled(admin: Want, disabled: boolean, callback: AsyncCallback\<void>): void
30
31使设备禁用或启用打印能力。使用callback异步回调。
32
33**需要权限:** ohos.permission.ENTERPRISE_RESTRICT_POLICY
34
35**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
36
37**模型约束:** 此接口仅可在Stage模型下使用。
38
39**系统接口:** 此接口为系统接口。
40
41**参数:**
42
43| 参数名   | 类型                                  | 必填   | 说明      |
44| ----- | ----------------------------------- | ---- | ------- |
45| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是    | 企业设备管理扩展组件。 |
46| disabled  | boolean | 是 | true表示禁止使用打印能力,false表示允许使用打印能力。 |
47| callback | AsyncCallback\<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
48
49**错误码**:
50
51以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
52
53| 错误码ID | 错误信息                                                                      |
54| ------- | ---------------------------------------------------------------------------- |
55| 9200001 | The application is not an administrator application of the device.           |
56| 9200002 | The administrator application does not have permission to manage the device. |
57| 201 | Permission verification failed. The application does not have the permission required to call the API. |
58| 202 | Permission verification failed. A non-system application calls a system API. |
59| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
60
61**示例:**
62
63```ts
64import { restrictions } from '@kit.MDMKit';
65import { Want } from '@kit.AbilityKit';
66
67let wantTemp: Want = {
68  // 需根据实际情况进行替换
69  bundleName: 'com.example.myapplication',
70  abilityName: 'EntryAbility'
71};
72
73restrictions.setPrinterDisabled(wantTemp, true, (err) => {
74  if (err) {
75    console.error(`Failed to set printer disabled. Code is ${err.code}, message is ${err.message}`);
76    return;
77  }
78  console.info('Succeeded in setting printer disabled');
79})
80```
81
82## restrictions.setPrinterDisabled
83
84setPrinterDisabled(admin: Want, disabled: boolean): Promise\<void>
85
86使设备禁用或启用打印能力。使用Promise异步回调。
87
88**需要权限:** ohos.permission.ENTERPRISE_RESTRICT_POLICY
89
90**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
91
92**模型约束:** 此接口仅可在Stage模型下使用。
93
94**系统接口:** 此接口为系统接口。
95
96**参数:**
97
98| 参数名   | 类型                                  | 必填   | 说明      |
99| ----- | ----------------------------------- | ---- | ------- |
100| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是    | 企业设备管理扩展组件。 |
101| disabled  | boolean | 是 | true表示禁止使用打印能力,false表示允许使用打印能力。 |
102
103**返回值:**
104
105| 类型   | 说明                                  |
106| ----- | ----------------------------------- |
107| Promise\<void> | 无返回结果的Promise对象。当禁止或允许使用打印能力失败时抛出错误对象。 |
108
109**错误码**:
110
111以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
112
113| 错误码ID | 错误信息                                                                      |
114| ------- | ---------------------------------------------------------------------------- |
115| 9200001 | The application is not an administrator application of the device.            |
116| 9200002 | The administrator application does not have permission to manage the device. |
117| 201 | Permission verification failed. The application does not have the permission required to call the API. |
118| 202 | Permission verification failed. A non-system application calls a system API. |
119| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
120
121**示例:**
122
123```ts
124import { restrictions } from '@kit.MDMKit';
125import { Want } from '@kit.AbilityKit';
126import { BusinessError } from '@kit.BasicServicesKit';
127
128let wantTemp: Want = {
129  // 需根据实际情况进行替换
130  bundleName: 'com.example.myapplication',
131  abilityName: 'EntryAbility'
132};
133
134restrictions.setPrinterDisabled(wantTemp, true).then(() => {
135  console.info('Succeeded in setting printer disabled');
136}).catch((err: BusinessError) => {
137  console.error(`Failed to set printer disabled. Code is ${err.code}, message is ${err.message}`);
138})
139```
140
141## restrictions.isPrinterDisabled
142
143isPrinterDisabled(admin: Want, callback: AsyncCallback\<boolean>): void
144
145查询设备打印能力是否被禁用。使用callback异步回调。
146
147**需要权限:** ohos.permission.ENTERPRISE_RESTRICT_POLICY
148
149**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
150
151**模型约束:** 此接口仅可在Stage模型下使用。
152
153**系统接口:** 此接口为系统接口。
154
155**参数:**
156
157| 参数名   | 类型                                  | 必填   | 说明      |
158| ----- | ----------------------------------- | ---- | ------- |
159| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是    | 企业设备管理扩展组件。 |
160| callback | AsyncCallback\<boolean> | 是 | 回调函数,callback方式返回设备打印能力是否被禁用,true表示设备打印能力被禁用,false表示设备打印能力未被禁用。 |
161
162**错误码**:
163
164以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
165
166| 错误码ID | 错误信息                                                                      |
167| ------- | ---------------------------------------------------------------------------- |
168| 9200001 | The application is not an administrator application of the device.           |
169| 9200002 | The administrator application does not have permission to manage the device. |
170| 201 | Permission verification failed. The application does not have the permission required to call the API. |
171| 202 | Permission verification failed. A non-system application calls a system API. |
172| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
173
174**示例:**
175
176```ts
177import { restrictions } from '@kit.MDMKit';
178import { Want } from '@kit.AbilityKit';
179
180let wantTemp: Want = {
181  // 需根据实际情况进行替换
182  bundleName: 'com.example.myapplication',
183  abilityName: 'EntryAbility'
184};
185
186restrictions.isPrinterDisabled(wantTemp, (err, result) => {
187  if (err) {
188    console.error(`Failed to query is the printing function disabled or not. Code is ${err.code}, message is ${err.message}`);
189    return;
190  }
191  console.info(`Succeeded in querying is the printing function disabled : ${result}`);
192})
193```
194
195## restrictions.isPrinterDisabled
196
197isPrinterDisabled(admin: Want): Promise\<boolean>
198
199查询设备打印能力是否被禁用。使用Promise异步回调。
200
201**需要权限:** ohos.permission.ENTERPRISE_RESTRICT_POLICY
202
203**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
204
205**模型约束:** 此接口仅可在Stage模型下使用。
206
207**系统接口:** 此接口为系统接口。
208
209**参数:**
210
211| 参数名 | 类型                                                    | 必填 | 说明                                   |
212| ------ | ------------------------------------------------------- | ---- | -------------------------------------- |
213| admin  | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是   | 企业设备管理扩展组件。 |
214
215**返回值:**
216
217| 类型   | 说明                                  |
218| ----- | ----------------------------------- |
219| Promise\<boolean> | Promise对象。promise方式返回设备打印能力是否被禁用,true表示设备打印能力被禁用,false表示设备打印能力未被禁用。 |
220
221**错误码**:
222
223以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
224
225| 错误码ID | 错误信息                                                                      |
226| ------- | ---------------------------------------------------------------------------- |
227| 9200001 | The application is not an administrator application of the device.            |
228| 9200002 | The administrator application does not have permission to manage the device. |
229| 201 | Permission verification failed. The application does not have the permission required to call the API. |
230| 202 | Permission verification failed. A non-system application calls a system API. |
231| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
232
233**示例:**
234
235```ts
236import { restrictions } from '@kit.MDMKit';
237import { Want } from '@kit.AbilityKit';
238import { BusinessError } from '@kit.BasicServicesKit';
239
240let wantTemp: Want = {
241  // 需根据实际情况进行替换
242  bundleName: 'com.example.myapplication',
243  abilityName: 'EntryAbility'
244};
245
246restrictions.isPrinterDisabled(wantTemp).then((result) => {
247  console.info(`Succeeded in querying is the printing function disabled : ${result}`);
248}).catch((err: BusinessError) => {
249  console.error(`Failed to query is the printing function disabled or not. Code is ${err.code}, message is ${err.message}`);
250})
251```
252
253## restrictions.setHdcDisabled
254
255setHdcDisabled(admin: Want, disabled: boolean, callback: AsyncCallback\<void>): void
256
257使设备禁用或启用[HDC](../../../device-dev/subsystems/subsys-toolchain-hdc-guide.md)。使用callback异步回调。
258
259**需要权限:** ohos.permission.ENTERPRISE_RESTRICT_POLICY
260
261**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
262
263**模型约束:** 此接口仅可在Stage模型下使用。
264
265**系统接口:** 此接口为系统接口。
266
267**参数:**
268
269| 参数名   | 类型                                  | 必填   | 说明      |
270| ----- | ----------------------------------- | ---- | ------- |
271| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是    | 企业设备管理扩展组件。 |
272| disabled  | boolean | 是 | true表示禁止使用HDC,false表示允许使用HDC。 |
273| callback | AsyncCallback\<void> | 是 | 回调函数。当接口调用成功,err为null,否则为错误对象。 |
274
275**错误码**:
276
277以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
278
279| 错误码ID | 错误信息                                                                      |
280| ------- | ---------------------------------------------------------------------------- |
281| 9200001 | The application is not an administrator application of the device.           |
282| 9200002 | The administrator application does not have permission to manage the device. |
283| 201 | Permission verification failed. The application does not have the permission required to call the API. |
284| 202 | Permission verification failed. A non-system application calls a system API. |
285| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
286
287**示例:**
288
289```ts
290import { restrictions } from '@kit.MDMKit';
291import { Want } from '@kit.AbilityKit';
292
293let wantTemp: Want = {
294  // 需根据实际情况进行替换
295  bundleName: 'com.example.myapplication',
296  abilityName: 'EntryAbility'
297};
298
299restrictions.setHdcDisabled(wantTemp, true, (err) => {
300  if (err) {
301    console.error(`Failed to set hdc disabled. Code is ${err.code}, message is ${err.message}`);
302    return;
303  }
304  console.info('Succeeded in setting hdc disabled');
305})
306```
307
308## restrictions.setHdcDisabled
309
310setHdcDisabled(admin: Want, disabled: boolean): Promise\<void>
311
312使设备禁用或启用HDC。使用Promise异步回调。
313
314**需要权限:** ohos.permission.ENTERPRISE_RESTRICT_POLICY
315
316**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
317
318**模型约束:** 此接口仅可在Stage模型下使用。
319
320**系统接口:** 此接口为系统接口。
321
322**参数:**
323
324| 参数名   | 类型                                  | 必填   | 说明      |
325| ----- | ----------------------------------- | ---- | ------- |
326| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是    | 企业设备管理扩展组件。 |
327| disabled  | boolean | 是 | true表示禁止使用HDC,false表示允许使用HDC。 |
328
329**返回值:**
330
331| 类型   | 说明                                  |
332| ----- | ----------------------------------- |
333| Promise\<void> | 无返回结果的Promise对象。当禁止或允许使用HDC失败时,抛出错误对象。 |
334
335**错误码**:
336
337以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
338
339| 错误码ID | 错误信息                                                                      |
340| ------- | ---------------------------------------------------------------------------- |
341| 9200001 | The application is not an administrator application of the device.            |
342| 9200002 | The administrator application does not have permission to manage the device. |
343| 201 | Permission verification failed. The application does not have the permission required to call the API. |
344| 202 | Permission verification failed. A non-system application calls a system API. |
345| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
346
347**示例:**
348
349```ts
350import { restrictions } from '@kit.MDMKit';
351import { Want } from '@kit.AbilityKit';
352import { BusinessError } from '@kit.BasicServicesKit';
353
354let wantTemp: Want = {
355  // 需根据实际情况进行替换
356  bundleName: 'com.example.myapplication',
357  abilityName: 'EntryAbility'
358};
359
360restrictions.setHdcDisabled(wantTemp, true).then(() => {
361  console.info('Succeeded in setting hdc disabled');
362}).catch((err: BusinessError) => {
363  console.error(`Failed to set hdc disabled. Code is ${err.code}, message is ${err.message}`);
364})
365```
366
367## restrictions.isHdcDisabled
368
369isHdcDisabled(admin: Want, callback: AsyncCallback\<boolean>): void
370
371查询HDC是否被禁用。使用callback异步回调。
372
373**需要权限:** ohos.permission.ENTERPRISE_RESTRICT_POLICY
374
375**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
376
377**模型约束:** 此接口仅可在Stage模型下使用。
378
379**系统接口:** 此接口为系统接口。
380
381**参数:**
382
383| 参数名   | 类型                                  | 必填   | 说明      |
384| ----- | ----------------------------------- | ---- | ------- |
385| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是    | 企业设备管理扩展组件。 |
386| callback | AsyncCallback\<boolean> | 是 | 回调函数,callback方式返回HDC是否被禁用,true表示HDC被禁用,false表示HDC未被禁用。 |
387
388**错误码**:
389
390以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
391
392| 错误码ID | 错误信息                                                                      |
393| ------- | ---------------------------------------------------------------------------- |
394| 9200001 | The application is not an administrator application of the device.           |
395| 9200002 | The administrator application does not have permission to manage the device. |
396| 201 | Permission verification failed. The application does not have the permission required to call the API. |
397| 202 | Permission verification failed. A non-system application calls a system API. |
398| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
399
400**示例:**
401
402```ts
403import { restrictions } from '@kit.MDMKit';
404import { Want } from '@kit.AbilityKit';
405
406let wantTemp: Want = {
407  // 需根据实际情况进行替换
408  bundleName: 'com.example.myapplication',
409  abilityName: 'EntryAbility'
410};
411
412restrictions.isHdcDisabled(wantTemp, (err, result) => {
413  if (err) {
414    console.error(`Failed to query is hdc disabled or not. Code is ${err.code}, message is ${err.message}`);
415    return;
416  }
417  console.info(`Succeeded in querying is hdc disabled : ${result}`);
418})
419```
420
421## restrictions.isHdcDisabled
422
423isHdcDisabled(admin: Want): Promise\<boolean>
424
425查询HDC是否被禁用。使用Promise异步回调。
426
427**需要权限:** ohos.permission.ENTERPRISE_RESTRICT_POLICY
428
429**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
430
431**模型约束:** 此接口仅可在Stage模型下使用。
432
433**系统接口:** 此接口为系统接口。
434
435**参数:**
436
437| 参数名 | 类型                                                    | 必填 | 说明                                   |
438| ------ | ------------------------------------------------------- | ---- | -------------------------------------- |
439| admin  | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是   | 企业设备管理扩展组件。 |
440
441**返回值:**
442
443| 类型   | 说明                                  |
444| ----- | ----------------------------------- |
445| Promise\<boolean> | Promise对象。promise方式返回HDC是否被禁用,true表示HDC被禁用,false表示HDC未被禁用。 |
446
447**错误码**:
448
449以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
450
451| 错误码ID | 错误信息                                                                      |
452| ------- | ---------------------------------------------------------------------------- |
453| 9200001 | The application is not an administrator application of the device.            |
454| 9200002 | The administrator application does not have permission to manage the device. |
455| 201 | Permission verification failed. The application does not have the permission required to call the API. |
456| 202 | Permission verification failed. A non-system application calls a system API. |
457| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
458
459**示例:**
460
461```ts
462import { restrictions } from '@kit.MDMKit';
463import { Want } from '@kit.AbilityKit';
464import { BusinessError } from '@kit.BasicServicesKit';
465
466let wantTemp: Want = {
467  // 需根据实际情况进行替换
468  bundleName: 'com.example.myapplication',
469  abilityName: 'EntryAbility'
470};
471
472restrictions.isHdcDisabled(wantTemp).then((result) => {
473  console.info(`Succeeded in querying is hdc disabled : ${result}`);
474}).catch((err: BusinessError) => {
475  console.error(`Failed to query is hdc disabled or not. Code is ${err.code}, message is ${err.message}`);
476})
477```
478
479## restrictions.isMicrophoneDisabled<sup>11+</sup>
480
481isMicrophoneDisabled(admin: Want): boolean
482
483查询麦克风是否被禁用。
484
485**需要权限:** ohos.permission.ENTERPRISE_MANAGE_RESTRICTIONS
486
487**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
488
489**模型约束:** 此接口仅可在Stage模型下使用。
490
491**系统接口:** 此接口为系统接口。
492
493**参数:**
494
495| 参数名 | 类型                                                    | 必填 | 说明                                   |
496| ------ | ------------------------------------------------------- | ---- | -------------------------------------- |
497| admin  | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是   | 企业设备管理扩展组件。 |
498
499**返回值:**
500
501| 类型   | 说明                                  |
502| ----- | ----------------------------------- |
503| boolean | boolean方式返回麦克风是否被禁用,true表示麦克风被禁用,false表示麦克风未被禁用。 |
504
505**错误码**:
506
507以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
508
509| 错误码ID | 错误信息                                                                      |
510| ------- | ---------------------------------------------------------------------------- |
511| 9200001 | The application is not an administrator application of the device.           |
512| 9200002 | The administrator application does not have permission to manage the device. |
513| 201 | Permission verification failed. The application does not have the permission required to call the API. |
514| 202 | Permission verification failed. A non-system application calls a system API. |
515| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
516
517**示例:**
518
519```ts
520import { restrictions } from '@kit.MDMKit';
521import { Want } from '@kit.AbilityKit';
522
523let wantTemp: Want = {
524  // 需根据实际情况进行替换
525  bundleName: 'com.example.myapplication',
526  abilityName: 'EntryAbility'
527};
528
529try {
530  let result = restrictions.isMicrophoneDisabled(wantTemp);
531  console.info(`Succeeded in querying is microphone disabled : ${result}`);
532} catch (err) {
533  console.error(`Failed to query is microphone disabled or not. Code is ${err.code}, message is ${err.message}`);
534}
535```
536
537## restrictions.disableMicrophone<sup>11+</sup>
538
539disableMicrophone(admin: Want, disable: boolean): void
540
541使设备禁用或启用麦克风。
542
543**需要权限:** ohos.permission.ENTERPRISE_MANAGE_RESTRICTIONS
544
545**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
546
547**模型约束:** 此接口仅可在Stage模型下使用。
548
549**系统接口:** 此接口为系统接口。
550
551**参数:**
552
553| 参数名   | 类型                                  | 必填   | 说明      |
554| ----- | ----------------------------------- | ---- | ------- |
555| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是    | 企业设备管理扩展组件。 |
556| disable  | boolean | 是 | true表示禁止使用麦克风,false表示允许使用麦克风。 |
557
558**错误码**:
559
560以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
561
562| 错误码ID | 错误信息                                                                      |
563| ------- | ---------------------------------------------------------------------------- |
564| 9200001 | The application is not an administrator application of the device.            |
565| 9200002 | The administrator application does not have permission to manage the device. |
566| 201 | Permission verification failed. The application does not have the permission required to call the API. |
567| 202 | Permission verification failed. A non-system application calls a system API. |
568| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
569
570**示例:**
571
572```ts
573import { restrictions } from '@kit.MDMKit';
574import { Want } from '@kit.AbilityKit';
575import { BusinessError } from '@kit.BasicServicesKit';
576
577let wantTemp: Want = {
578  // 需根据实际情况进行替换
579  bundleName: 'com.example.myapplication',
580  abilityName: 'EntryAbility'
581};
582
583try {
584  restrictions.disableMicrophone(wantTemp, true);
585  console.info('Succeeded in setting microphone disabled');
586} catch (err) {
587  console.error(`Failed to disable microphone. Code is ${err.code}, message is ${err.message}`);
588}
589```
590
591## restrictions.setFingerprintAuthDisabled<sup>11+</sup>
592
593setFingerprintAuthDisabled(admin: Want, disabled: boolean): void
594
595禁用或启用指纹认证。
596
597**需要权限:** ohos.permission.ENTERPRISE_MANAGE_RESTRICTIONS
598
599**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
600
601**模型约束:** 此接口仅可在Stage模型下使用。
602
603**系统接口:** 此接口为系统接口。
604
605**参数:**
606
607| 参数名   | 类型                                  | 必填   | 说明      |
608| ----- | ----------------------------------- | ---- | ------- |
609| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是    | 企业设备管理扩展组件。 |
610| disabled  | boolean | 是 | true表示禁止指纹认证,false表示允许指纹认证。 |
611
612**错误码**:
613
614以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
615
616| 错误码ID | 错误信息                                                                      |
617| ------- | ---------------------------------------------------------------------------- |
618| 9200001 | The application is not an administrator application of the device.            |
619| 9200002 | The administrator application does not have permission to manage the device. |
620| 201 | Permission verification failed. The application does not have the permission required to call the API. |
621| 202 | Permission verification failed. A non-system application calls a system API. |
622| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
623
624**示例:**
625
626```ts
627import { restrictions } from '@kit.MDMKit';
628import { Want } from '@kit.AbilityKit';
629
630let wantTemp: Want = {
631  // 需根据实际情况进行替换
632  bundleName: 'com.example.myapplication',
633  abilityName: 'EntryAbility'
634};
635
636try {
637  restrictions.setFingerprintAuthDisabled(wantTemp, true);
638  console.info('Succeeded in disabling the fingerprint auth');
639} catch (err) {
640  console.error(`Failed to disable fingerprint auth. Code: ${err.code}, message: ${err.message}`);
641};
642
643```
644
645## restrictions.isFingerprintAuthDisabled<sup>11+</sup>
646
647isFingerprintAuthDisabled(admin: Want): boolean
648
649查询指纹认证是否被禁用。
650
651**需要权限:** ohos.permission.ENTERPRISE_MANAGE_RESTRICTIONS
652
653**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
654
655**模型约束:** 此接口仅可在Stage模型下使用。
656
657**系统接口:** 此接口为系统接口。
658
659**参数:**
660
661| 参数名 | 类型                                                    | 必填 | 说明                                   |
662| ------ | ------------------------------------------------------- | ---- | -------------------------------------- |
663| admin  | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是   | 企业设备管理扩展组件。 |
664
665**返回值:**
666
667| 类型   | 说明                                  |
668| ----- | ----------------------------------- |
669| boolean | 返回指纹认证是否被禁用,true表示指纹认证被禁用,false表示指纹认证未被禁用。 |
670
671**错误码**:
672
673以下错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
674
675| 错误码ID | 错误信息                                                                      |
676| ------- | ---------------------------------------------------------------------------- |
677| 9200001 | The application is not an administrator application of the device.            |
678| 9200002 | The administrator application does not have permission to manage the device. |
679| 201 | Permission verification failed. The application does not have the permission required to call the API. |
680| 202 | Permission verification failed. A non-system application calls a system API. |
681| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
682
683**示例:**
684
685```ts
686import { restrictions } from '@kit.MDMKit';
687import { Want } from '@kit.AbilityKit';
688
689let wantTemp: Want = {
690  // 需根据实际情况进行替换
691  bundleName: 'com.example.myapplication',
692  abilityName: 'EntryAbility'
693};
694
695try {
696  let result: boolean = restrictions.isFingerprintAuthDisabled(wantTemp);
697  console.info(`Succeeded in getting the state of fingerprint auth. result : ${result}`);
698} catch (err) {
699  console.error(`Failed to get the state of fingerprint auth. Code: ${err.code}, message: ${err.message}`);
700};
701```