1e41f4b71Sopenharmony_ci# @ohos.enterprise.restrictions (Restrictions) (System API) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThis **restrictions** module provides APIs for setting general restriction policies, including disabling or enabling the printer and OpenHarmony Device Connector (hdc) for devices. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> The APIs of this module can be used only in the stage model. 10e41f4b71Sopenharmony_ci> 11e41f4b71Sopenharmony_ci> The APIs of this module can be called only by a [device administrator application](../../mdm/mdm-kit-guide.md#introduction) that is [enabled](js-apis-enterprise-adminManager-sys.md#adminmanagerenableadmin). 12e41f4b71Sopenharmony_ci> 13e41f4b71Sopenharmony_ci> This topic describes only the system APIs provided by the module. For details about its public APIs, see [@ohos.enterprise.restrictions](js-apis-enterprise-restrictions.md). 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci## Modules to Import 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci```ts 18e41f4b71Sopenharmony_ciimport { restrictions } from '@kit.MDMKit'; 19e41f4b71Sopenharmony_ci``` 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci## restrictions.setPrinterDisabled 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_cisetPrinterDisabled(admin: Want, disabled: boolean, callback: AsyncCallback\<void>): void 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ciEnables or disables the printer through the specified device administrator application. This API uses an asynchronous callback to return the result. 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_RESTRICT_POLICY 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci**Parameters** 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 34e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | ---- | ------- | 35e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 36e41f4b71Sopenharmony_ci| disabled | boolean | Yes| Operation to perform. The value **true** means to disable the printer; the value **false** means the opposite. | 37e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void> | Yes| Callback used to return the result.<br>If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci**Error codes** 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci| ID| Error Message | 44e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------------------------------------- | 45e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 46e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 47e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 48e41f4b71Sopenharmony_ci| 202 | Permission verification failed. A non-system application calls a system API. | 49e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci**Example** 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci```ts 54e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 55e41f4b71Sopenharmony_cilet wantTemp: Want = { 56e41f4b71Sopenharmony_ci bundleName: 'bundleName', 57e41f4b71Sopenharmony_ci abilityName: 'abilityName', 58e41f4b71Sopenharmony_ci}; 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_cirestrictions.setPrinterDisabled(wantTemp, true, (err) => { 61e41f4b71Sopenharmony_ci if (err) { 62e41f4b71Sopenharmony_ci console.error(`Failed to set printer disabled. Code is ${err.code}, message is ${err.message}`); 63e41f4b71Sopenharmony_ci return; 64e41f4b71Sopenharmony_ci } 65e41f4b71Sopenharmony_ci console.info('Succeeded in setting printer disabled'); 66e41f4b71Sopenharmony_ci}) 67e41f4b71Sopenharmony_ci``` 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ci## restrictions.setPrinterDisabled 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_cisetPrinterDisabled(admin: Want, disabled: boolean): Promise\<void> 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_ciEnables or disables the printer through the specified device administrator application. This API uses a promise to return the result. 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_RESTRICT_POLICY 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci**Parameters** 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 82e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | ---- | ------- | 83e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 84e41f4b71Sopenharmony_ci| disabled | boolean | Yes| Operation to perform. The value **true** means to disable the printer; the value **false** means the opposite. | 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci**Return value** 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ci| Type | Description | 89e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | 90e41f4b71Sopenharmony_ci| Promise\<void> | Promise that returns no value. If the operation fails, an error object will be thrown. | 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci**Error codes** 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 95e41f4b71Sopenharmony_ci 96e41f4b71Sopenharmony_ci| ID| Error Message | 97e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------------------------------------- | 98e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 99e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 100e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 101e41f4b71Sopenharmony_ci| 202 | Permission verification failed. A non-system application calls a system API. | 102e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 103e41f4b71Sopenharmony_ci 104e41f4b71Sopenharmony_ci**Example** 105e41f4b71Sopenharmony_ci 106e41f4b71Sopenharmony_ci```ts 107e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 108e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 109e41f4b71Sopenharmony_cilet wantTemp: Want = { 110e41f4b71Sopenharmony_ci bundleName: 'bundleName', 111e41f4b71Sopenharmony_ci abilityName: 'abilityName', 112e41f4b71Sopenharmony_ci}; 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_cirestrictions.setPrinterDisabled(wantTemp, true).then(() => { 115e41f4b71Sopenharmony_ci console.info('Succeeded in setting printer disabled'); 116e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 117e41f4b71Sopenharmony_ci console.error(`Failed to set printer disabled. Code is ${err.code}, message is ${err.message}`); 118e41f4b71Sopenharmony_ci}) 119e41f4b71Sopenharmony_ci``` 120e41f4b71Sopenharmony_ci 121e41f4b71Sopenharmony_ci## restrictions.isPrinterDisabled 122e41f4b71Sopenharmony_ci 123e41f4b71Sopenharmony_ciisPrinterDisabled(admin: Want, callback: AsyncCallback\<boolean>): void 124e41f4b71Sopenharmony_ci 125e41f4b71Sopenharmony_ciChecks whether the printer is disabled for devices through the specified device administrator application. This API uses an asynchronous callback to return the result. 126e41f4b71Sopenharmony_ci 127e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_RESTRICT_POLICY 128e41f4b71Sopenharmony_ci 129e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ci**Parameters** 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 134e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | ---- | ------- | 135e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 136e41f4b71Sopenharmony_ci| callback | AsyncCallback\<boolean> | Yes| Callback used to return the result. The value **true** means that the printer is disabled; the value **false** means the opposite. | 137e41f4b71Sopenharmony_ci 138e41f4b71Sopenharmony_ci**Error codes** 139e41f4b71Sopenharmony_ci 140e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 141e41f4b71Sopenharmony_ci 142e41f4b71Sopenharmony_ci| ID| Error Message | 143e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------------------------------------- | 144e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 145e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 146e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 147e41f4b71Sopenharmony_ci| 202 | Permission verification failed. A non-system application calls a system API. | 148e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci**Example** 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ci```ts 153e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 154e41f4b71Sopenharmony_cilet wantTemp: Want = { 155e41f4b71Sopenharmony_ci bundleName: 'bundleName', 156e41f4b71Sopenharmony_ci abilityName: 'abilityName', 157e41f4b71Sopenharmony_ci}; 158e41f4b71Sopenharmony_ci 159e41f4b71Sopenharmony_cirestrictions.isPrinterDisabled(wantTemp, (err, result) => { 160e41f4b71Sopenharmony_ci if (err) { 161e41f4b71Sopenharmony_ci console.error(`Failed to query is the printing function disabled or not. Code is ${err.code}, message is ${err.message}`); 162e41f4b71Sopenharmony_ci return; 163e41f4b71Sopenharmony_ci } 164e41f4b71Sopenharmony_ci console.info(`Succeeded in querying is the printing function disabled : ${result}`); 165e41f4b71Sopenharmony_ci}) 166e41f4b71Sopenharmony_ci``` 167e41f4b71Sopenharmony_ci 168e41f4b71Sopenharmony_ci## restrictions.isPrinterDisabled 169e41f4b71Sopenharmony_ci 170e41f4b71Sopenharmony_ciisPrinterDisabled(admin: Want): Promise\<boolean> 171e41f4b71Sopenharmony_ci 172e41f4b71Sopenharmony_ciChecks whether the printer is disabled for devices through the specified device administrator application. This API uses a promise to return the result. 173e41f4b71Sopenharmony_ci 174e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_RESTRICT_POLICY 175e41f4b71Sopenharmony_ci 176e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 177e41f4b71Sopenharmony_ci 178e41f4b71Sopenharmony_ci**Parameters** 179e41f4b71Sopenharmony_ci 180e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 181e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | ---- | ------- | 182e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 183e41f4b71Sopenharmony_ci 184e41f4b71Sopenharmony_ci**Return value** 185e41f4b71Sopenharmony_ci 186e41f4b71Sopenharmony_ci| Type | Description | 187e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | 188e41f4b71Sopenharmony_ci| Promise\<boolean> | Promise used to return the result. The value **true** means that the printer is disabled; the value **false** means the opposite. | 189e41f4b71Sopenharmony_ci 190e41f4b71Sopenharmony_ci**Error codes** 191e41f4b71Sopenharmony_ci 192e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 193e41f4b71Sopenharmony_ci 194e41f4b71Sopenharmony_ci| ID| Error Message | 195e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------------------------------------- | 196e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 197e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 198e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 199e41f4b71Sopenharmony_ci| 202 | Permission verification failed. A non-system application calls a system API. | 200e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci**Example** 203e41f4b71Sopenharmony_ci 204e41f4b71Sopenharmony_ci```ts 205e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 206e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 207e41f4b71Sopenharmony_cilet wantTemp: Want = { 208e41f4b71Sopenharmony_ci bundleName: 'bundleName', 209e41f4b71Sopenharmony_ci abilityName: 'abilityName', 210e41f4b71Sopenharmony_ci}; 211e41f4b71Sopenharmony_ci 212e41f4b71Sopenharmony_cirestrictions.isPrinterDisabled(wantTemp).then((result) => { 213e41f4b71Sopenharmony_ci console.info(`Succeeded in querying is the printing function disabled : ${result}`); 214e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 215e41f4b71Sopenharmony_ci console.error(`Failed to query is the printing function disabled or not. Code is ${err.code}, message is ${err.message}`); 216e41f4b71Sopenharmony_ci}) 217e41f4b71Sopenharmony_ci``` 218e41f4b71Sopenharmony_ci 219e41f4b71Sopenharmony_ci## restrictions.setHdcDisabled 220e41f4b71Sopenharmony_ci 221e41f4b71Sopenharmony_cisetHdcDisabled(admin: Want, disabled: boolean, callback: AsyncCallback\<void>): void 222e41f4b71Sopenharmony_ci 223e41f4b71Sopenharmony_ciEnables or disables hdc through the specified device administrator application. This API uses an asynchronous callback to return the result. 224e41f4b71Sopenharmony_ci 225e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_RESTRICT_POLICY 226e41f4b71Sopenharmony_ci 227e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 228e41f4b71Sopenharmony_ci 229e41f4b71Sopenharmony_ci**Parameters** 230e41f4b71Sopenharmony_ci 231e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 232e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | ---- | ------- | 233e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 234e41f4b71Sopenharmony_ci| disabled | boolean | Yes| Operation to perform. The value **true** means to disable hdc; the value **false** means the opposite.| 235e41f4b71Sopenharmony_ci| callback | AsyncCallback\<void> | Yes| Callback used to return the result.<br>If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.| 236e41f4b71Sopenharmony_ci 237e41f4b71Sopenharmony_ci**Error codes** 238e41f4b71Sopenharmony_ci 239e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 240e41f4b71Sopenharmony_ci 241e41f4b71Sopenharmony_ci| ID| Error Message | 242e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------------------------------------- | 243e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 244e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 245e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 246e41f4b71Sopenharmony_ci| 202 | Permission verification failed. A non-system application calls a system API. | 247e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 248e41f4b71Sopenharmony_ci 249e41f4b71Sopenharmony_ci**Example** 250e41f4b71Sopenharmony_ci 251e41f4b71Sopenharmony_ci```ts 252e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 253e41f4b71Sopenharmony_cilet wantTemp: Want = { 254e41f4b71Sopenharmony_ci bundleName: 'bundleName', 255e41f4b71Sopenharmony_ci abilityName: 'abilityName', 256e41f4b71Sopenharmony_ci}; 257e41f4b71Sopenharmony_ci 258e41f4b71Sopenharmony_cirestrictions.setHdcDisabled(wantTemp, true, (err) => { 259e41f4b71Sopenharmony_ci if (err) { 260e41f4b71Sopenharmony_ci console.error(`Failed to set hdc disabled. Code is ${err.code}, message is ${err.message}`); 261e41f4b71Sopenharmony_ci return; 262e41f4b71Sopenharmony_ci } 263e41f4b71Sopenharmony_ci console.info('Succeeded in setting hdc disabled'); 264e41f4b71Sopenharmony_ci}) 265e41f4b71Sopenharmony_ci``` 266e41f4b71Sopenharmony_ci 267e41f4b71Sopenharmony_ci## restrictions.setHdcDisabled 268e41f4b71Sopenharmony_ci 269e41f4b71Sopenharmony_cisetHdcDisabled(admin: Want, disabled: boolean): Promise\<void> 270e41f4b71Sopenharmony_ci 271e41f4b71Sopenharmony_ciEnables or disables hdc through the specified device administrator application. This API uses a promise to return the result. 272e41f4b71Sopenharmony_ci 273e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_RESTRICT_POLICY 274e41f4b71Sopenharmony_ci 275e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 276e41f4b71Sopenharmony_ci 277e41f4b71Sopenharmony_ci**Parameters** 278e41f4b71Sopenharmony_ci 279e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 280e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | ---- | ------- | 281e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 282e41f4b71Sopenharmony_ci| disabled | boolean | Yes| Operation to perform. The value **true** means to disable hdc; the value **false** means the opposite.| 283e41f4b71Sopenharmony_ci 284e41f4b71Sopenharmony_ci**Return value** 285e41f4b71Sopenharmony_ci 286e41f4b71Sopenharmony_ci| Type | Description | 287e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | 288e41f4b71Sopenharmony_ci| Promise\<void> | Promise that returns no value. If the operation fails, an error object will be thrown. | 289e41f4b71Sopenharmony_ci 290e41f4b71Sopenharmony_ci**Error codes** 291e41f4b71Sopenharmony_ci 292e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 293e41f4b71Sopenharmony_ci 294e41f4b71Sopenharmony_ci| ID| Error Message | 295e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------------------------------------- | 296e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 297e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 298e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 299e41f4b71Sopenharmony_ci| 202 | Permission verification failed. A non-system application calls a system API. | 300e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 301e41f4b71Sopenharmony_ci 302e41f4b71Sopenharmony_ci**Example** 303e41f4b71Sopenharmony_ci 304e41f4b71Sopenharmony_ci```ts 305e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 306e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 307e41f4b71Sopenharmony_cilet wantTemp: Want = { 308e41f4b71Sopenharmony_ci bundleName: 'bundleName', 309e41f4b71Sopenharmony_ci abilityName: 'abilityName', 310e41f4b71Sopenharmony_ci}; 311e41f4b71Sopenharmony_ci 312e41f4b71Sopenharmony_cirestrictions.setHdcDisabled(wantTemp, true).then(() => { 313e41f4b71Sopenharmony_ci console.info('Succeeded in setting hdc disabled'); 314e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 315e41f4b71Sopenharmony_ci console.error(`Failed to set hdc disabled. Code is ${err.code}, message is ${err.message}`); 316e41f4b71Sopenharmony_ci}) 317e41f4b71Sopenharmony_ci``` 318e41f4b71Sopenharmony_ci 319e41f4b71Sopenharmony_ci## restrictions.isHdcDisabled 320e41f4b71Sopenharmony_ci 321e41f4b71Sopenharmony_ciisHdcDisabled(admin: Want, callback: AsyncCallback\<boolean>): void 322e41f4b71Sopenharmony_ci 323e41f4b71Sopenharmony_ciChecks whether hdc is disabled through the specified device administrator application. This API uses an asynchronous callback to return the result. 324e41f4b71Sopenharmony_ci 325e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_RESTRICT_POLICY 326e41f4b71Sopenharmony_ci 327e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 328e41f4b71Sopenharmony_ci 329e41f4b71Sopenharmony_ci**Parameters** 330e41f4b71Sopenharmony_ci 331e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 332e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | ---- | ------- | 333e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 334e41f4b71Sopenharmony_ci| callback | AsyncCallback\<boolean> | Yes| Callback used to return the result. The value **true** means hdc is disabled; the value **false** means the opposite.| 335e41f4b71Sopenharmony_ci 336e41f4b71Sopenharmony_ci**Error codes** 337e41f4b71Sopenharmony_ci 338e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 339e41f4b71Sopenharmony_ci 340e41f4b71Sopenharmony_ci| ID| Error Message | 341e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------------------------------------- | 342e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 343e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 344e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 345e41f4b71Sopenharmony_ci| 202 | Permission verification failed. A non-system application calls a system API. | 346e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 347e41f4b71Sopenharmony_ci 348e41f4b71Sopenharmony_ci**Example** 349e41f4b71Sopenharmony_ci 350e41f4b71Sopenharmony_ci```ts 351e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 352e41f4b71Sopenharmony_cilet wantTemp: Want = { 353e41f4b71Sopenharmony_ci bundleName: 'bundleName', 354e41f4b71Sopenharmony_ci abilityName: 'abilityName', 355e41f4b71Sopenharmony_ci}; 356e41f4b71Sopenharmony_ci 357e41f4b71Sopenharmony_cirestrictions.isHdcDisabled(wantTemp, (err, result) => { 358e41f4b71Sopenharmony_ci if (err) { 359e41f4b71Sopenharmony_ci console.error(`Failed to query is hdc disabled or not. Code is ${err.code}, message is ${err.message}`); 360e41f4b71Sopenharmony_ci return; 361e41f4b71Sopenharmony_ci } 362e41f4b71Sopenharmony_ci console.info(`Succeeded in querying is hdc disabled : ${result}`); 363e41f4b71Sopenharmony_ci}) 364e41f4b71Sopenharmony_ci``` 365e41f4b71Sopenharmony_ci 366e41f4b71Sopenharmony_ci## restrictions.isHdcDisabled 367e41f4b71Sopenharmony_ci 368e41f4b71Sopenharmony_ciisHdcDisabled(admin: Want): Promise\<boolean> 369e41f4b71Sopenharmony_ci 370e41f4b71Sopenharmony_ciChecks whether hdc is disabled through the specified device administrator application. This API uses a promise to return the result. 371e41f4b71Sopenharmony_ci 372e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_RESTRICT_POLICY 373e41f4b71Sopenharmony_ci 374e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 375e41f4b71Sopenharmony_ci 376e41f4b71Sopenharmony_ci**Parameters** 377e41f4b71Sopenharmony_ci 378e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 379e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | ---- | ------- | 380e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 381e41f4b71Sopenharmony_ci 382e41f4b71Sopenharmony_ci**Return value** 383e41f4b71Sopenharmony_ci 384e41f4b71Sopenharmony_ci| Type | Description | 385e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | 386e41f4b71Sopenharmony_ci| Promise\<boolean> | Promise used to return the result. The value **true** means hdc is disabled; the value **false** means the opposite.| 387e41f4b71Sopenharmony_ci 388e41f4b71Sopenharmony_ci**Error codes** 389e41f4b71Sopenharmony_ci 390e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 391e41f4b71Sopenharmony_ci 392e41f4b71Sopenharmony_ci| ID| Error Message | 393e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------------------------------------- | 394e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 395e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 396e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 397e41f4b71Sopenharmony_ci| 202 | Permission verification failed. A non-system application calls a system API. | 398e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 399e41f4b71Sopenharmony_ci 400e41f4b71Sopenharmony_ci**Example** 401e41f4b71Sopenharmony_ci 402e41f4b71Sopenharmony_ci```ts 403e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 404e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 405e41f4b71Sopenharmony_cilet wantTemp: Want = { 406e41f4b71Sopenharmony_ci bundleName: 'bundleName', 407e41f4b71Sopenharmony_ci abilityName: 'abilityName', 408e41f4b71Sopenharmony_ci}; 409e41f4b71Sopenharmony_ci 410e41f4b71Sopenharmony_cirestrictions.isHdcDisabled(wantTemp).then((result) => { 411e41f4b71Sopenharmony_ci console.info(`Succeeded in querying is hdc disabled : ${result}`); 412e41f4b71Sopenharmony_ci}).catch((err: BusinessError) => { 413e41f4b71Sopenharmony_ci console.error(`Failed to query is hdc disabled or not. Code is ${err.code}, message is ${err.message}`); 414e41f4b71Sopenharmony_ci}) 415e41f4b71Sopenharmony_ci``` 416e41f4b71Sopenharmony_ci 417e41f4b71Sopenharmony_ci## restrictions.isMicrophoneDisabled<sup>11+</sup> 418e41f4b71Sopenharmony_ci 419e41f4b71Sopenharmony_ciisMicrophoneDisabled(admin: Want): boolean 420e41f4b71Sopenharmony_ci 421e41f4b71Sopenharmony_ciChecks whether the microphone is disabled through the specified device administrator application. 422e41f4b71Sopenharmony_ci 423e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_RESTRICTIONS 424e41f4b71Sopenharmony_ci 425e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 426e41f4b71Sopenharmony_ci 427e41f4b71Sopenharmony_ci**Parameters** 428e41f4b71Sopenharmony_ci 429e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 430e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | ---- | ------- | 431e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 432e41f4b71Sopenharmony_ci 433e41f4b71Sopenharmony_ci**Return value** 434e41f4b71Sopenharmony_ci 435e41f4b71Sopenharmony_ci| Type | Description | 436e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | 437e41f4b71Sopenharmony_ci| boolean | Returns **true** if the microphone is disabled; returns **false** otherwise.| 438e41f4b71Sopenharmony_ci 439e41f4b71Sopenharmony_ci**Error codes** 440e41f4b71Sopenharmony_ci 441e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 442e41f4b71Sopenharmony_ci 443e41f4b71Sopenharmony_ci| ID| Error Message | 444e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------------------------------------- | 445e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 446e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 447e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 448e41f4b71Sopenharmony_ci| 202 | Permission verification failed. A non-system application calls a system API. | 449e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 450e41f4b71Sopenharmony_ci 451e41f4b71Sopenharmony_ci**Example** 452e41f4b71Sopenharmony_ci 453e41f4b71Sopenharmony_ci```ts 454e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 455e41f4b71Sopenharmony_cilet wantTemp: Want = { 456e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 457e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 458e41f4b71Sopenharmony_ci}; 459e41f4b71Sopenharmony_ci 460e41f4b71Sopenharmony_citry { 461e41f4b71Sopenharmony_ci let result = restrictions.isMicrophoneDisabled(wantTemp); 462e41f4b71Sopenharmony_ci console.info(`Succeeded in querying is microphone disabled : ${result}`); 463e41f4b71Sopenharmony_ci} catch (err) { 464e41f4b71Sopenharmony_ci console.error(`Failed to query is microphone disabled or not. Code is ${err.code}, message is ${err.message}`); 465e41f4b71Sopenharmony_ci} 466e41f4b71Sopenharmony_ci``` 467e41f4b71Sopenharmony_ci 468e41f4b71Sopenharmony_ci## restrictions.disableMicrophone<sup>11+</sup> 469e41f4b71Sopenharmony_ci 470e41f4b71Sopenharmony_cidisableMicrophone(admin: Want, disable: boolean): void 471e41f4b71Sopenharmony_ci 472e41f4b71Sopenharmony_ciDisables or enables the device microphone through the specified device administrator application. 473e41f4b71Sopenharmony_ci 474e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_RESTRICTIONS 475e41f4b71Sopenharmony_ci 476e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 477e41f4b71Sopenharmony_ci 478e41f4b71Sopenharmony_ci**Parameters** 479e41f4b71Sopenharmony_ci 480e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 481e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | ---- | ------- | 482e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 483e41f4b71Sopenharmony_ci| disable | boolean | Yes| Operation to perform. The value **true** means to disable the microphone; the value **false** means the opposite.| 484e41f4b71Sopenharmony_ci 485e41f4b71Sopenharmony_ci**Error codes** 486e41f4b71Sopenharmony_ci 487e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 488e41f4b71Sopenharmony_ci 489e41f4b71Sopenharmony_ci| ID| Error Message | 490e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------------------------------------- | 491e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 492e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 493e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 494e41f4b71Sopenharmony_ci| 202 | Permission verification failed. A non-system application calls a system API. | 495e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 496e41f4b71Sopenharmony_ci 497e41f4b71Sopenharmony_ci**Example** 498e41f4b71Sopenharmony_ci 499e41f4b71Sopenharmony_ci```ts 500e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 501e41f4b71Sopenharmony_ciimport { BusinessError } from '@kit.BasicServicesKit'; 502e41f4b71Sopenharmony_cilet wantTemp: Want = { 503e41f4b71Sopenharmony_ci bundleName: 'com.example.myapplication', 504e41f4b71Sopenharmony_ci abilityName: 'EntryAbility', 505e41f4b71Sopenharmony_ci}; 506e41f4b71Sopenharmony_ci 507e41f4b71Sopenharmony_citry { 508e41f4b71Sopenharmony_ci restrictions.disableMicrophone(wantTemp, true); 509e41f4b71Sopenharmony_ci console.info('Succeeded in setting microphone disabled'); 510e41f4b71Sopenharmony_ci} catch (err) { 511e41f4b71Sopenharmony_ci console.error(`Failed to disable microphone. Code is ${err.code}, message is ${err.message}`); 512e41f4b71Sopenharmony_ci} 513e41f4b71Sopenharmony_ci``` 514e41f4b71Sopenharmony_ci 515e41f4b71Sopenharmony_ci## restrictions.setFingerprintAuthDisabled<sup>11+</sup> 516e41f4b71Sopenharmony_ci 517e41f4b71Sopenharmony_cisetFingerprintAuthDisabled(admin: Want, disabled: boolean): void 518e41f4b71Sopenharmony_ci 519e41f4b71Sopenharmony_ciDisables or enables fingerprint authentication through the specified device administrator application. This API returns the result synchronously. 520e41f4b71Sopenharmony_ci 521e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_RESTRICTIONS 522e41f4b71Sopenharmony_ci 523e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 524e41f4b71Sopenharmony_ci 525e41f4b71Sopenharmony_ci**Parameters** 526e41f4b71Sopenharmony_ci 527e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 528e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | ---- | ------- | 529e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 530e41f4b71Sopenharmony_ci| disabled | boolean | Yes| Operation to perform. The value **true** means to disable fingerprint authentication; the value **false** the opposite.| 531e41f4b71Sopenharmony_ci 532e41f4b71Sopenharmony_ci**Error codes** 533e41f4b71Sopenharmony_ci 534e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 535e41f4b71Sopenharmony_ci 536e41f4b71Sopenharmony_ci| ID| Error Message | 537e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------------------------------------- | 538e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 539e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 540e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 541e41f4b71Sopenharmony_ci| 202 | Permission verification failed. A non-system application calls a system API. | 542e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 543e41f4b71Sopenharmony_ci 544e41f4b71Sopenharmony_ci**Example** 545e41f4b71Sopenharmony_ci 546e41f4b71Sopenharmony_ci```ts 547e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 548e41f4b71Sopenharmony_ci 549e41f4b71Sopenharmony_cilet wantTemp: Want = { 550e41f4b71Sopenharmony_ci bundleName: 'bundleName', 551e41f4b71Sopenharmony_ci abilityName: 'abilityName', 552e41f4b71Sopenharmony_ci}; 553e41f4b71Sopenharmony_ci 554e41f4b71Sopenharmony_citry { 555e41f4b71Sopenharmony_ci restrictions.setFingerprintAuthDisabled(wantTemp, true); 556e41f4b71Sopenharmony_ci console.info('Succeeded in disabling the fingerprint auth'); 557e41f4b71Sopenharmony_ci} catch (err) { 558e41f4b71Sopenharmony_ci console.error(`Failed to disable fingerprint auth. Code: ${err.code}, message: ${err.message}`); 559e41f4b71Sopenharmony_ci}; 560e41f4b71Sopenharmony_ci 561e41f4b71Sopenharmony_ci``` 562e41f4b71Sopenharmony_ci 563e41f4b71Sopenharmony_ci## restrictions.isFingerprintAuthDisabled<sup>11+</sup> 564e41f4b71Sopenharmony_ci 565e41f4b71Sopenharmony_ciisFingerprintAuthDisabled(admin: Want): boolean 566e41f4b71Sopenharmony_ci 567e41f4b71Sopenharmony_ciChecks whether fingerprint authentication is disabled through the specified device administrator application. This API returns the result synchronously. 568e41f4b71Sopenharmony_ci 569e41f4b71Sopenharmony_ci**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_RESTRICTIONS 570e41f4b71Sopenharmony_ci 571e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 572e41f4b71Sopenharmony_ci 573e41f4b71Sopenharmony_ci**Parameters** 574e41f4b71Sopenharmony_ci 575e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 576e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | ---- | ------- | 577e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 578e41f4b71Sopenharmony_ci 579e41f4b71Sopenharmony_ci**Return value** 580e41f4b71Sopenharmony_ci 581e41f4b71Sopenharmony_ci| Type | Description | 582e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | 583e41f4b71Sopenharmony_ci| boolean | Returns **true** if fingerprint authentication is disabled; returns **false** otherwise.| 584e41f4b71Sopenharmony_ci 585e41f4b71Sopenharmony_ci**Error codes** 586e41f4b71Sopenharmony_ci 587e41f4b71Sopenharmony_ciFor details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 588e41f4b71Sopenharmony_ci 589e41f4b71Sopenharmony_ci| ID| Error Message | 590e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------------------------------------- | 591e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. | 592e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. | 593e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. | 594e41f4b71Sopenharmony_ci| 202 | Permission verification failed. A non-system application calls a system API. | 595e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 596e41f4b71Sopenharmony_ci 597e41f4b71Sopenharmony_ci**Example** 598e41f4b71Sopenharmony_ci 599e41f4b71Sopenharmony_ci```ts 600e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit'; 601e41f4b71Sopenharmony_ci 602e41f4b71Sopenharmony_cilet wantTemp: Want = { 603e41f4b71Sopenharmony_ci bundleName: 'bundleName', 604e41f4b71Sopenharmony_ci abilityName: 'abilityName', 605e41f4b71Sopenharmony_ci}; 606e41f4b71Sopenharmony_ci 607e41f4b71Sopenharmony_citry { 608e41f4b71Sopenharmony_ci let result: boolean = restrictions.isFingerprintAuthDisabled(wantTemp); 609e41f4b71Sopenharmony_ci console.info(`Succeeded in getting the state of fingerprint auth. result : ${result}`); 610e41f4b71Sopenharmony_ci} catch (err) { 611e41f4b71Sopenharmony_ci console.error(`Failed to get the state of fingerprint auth. Code: ${err.code}, message: ${err.message}`); 612e41f4b71Sopenharmony_ci}; 613e41f4b71Sopenharmony_ci``` 614