1e41f4b71Sopenharmony_ci# @ohos.enterprise.bluetoothManager(蓝牙管理)(系统接口)
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci本模块提供设备蓝牙管理的能力,包括设置和查询蓝牙信息等。
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci> **说明:**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci> 本模块首批接口从API version 11开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8e41f4b71Sopenharmony_ci>
9e41f4b71Sopenharmony_ci> 本模块接口仅可在Stage模型下使用。
10e41f4b71Sopenharmony_ci>
11e41f4b71Sopenharmony_ci> 本模块接口仅对[设备管理应用](../../mdm/mdm-kit-guide.md#功能介绍)开放,需将[设备管理应用激活](js-apis-enterprise-adminManager-sys.md#adminmanagerenableadmin)后调用,实现相应功能。
12e41f4b71Sopenharmony_ci> 
13e41f4b71Sopenharmony_ci> 当前页面仅包含本模块的系统接口,其他公开接口参见。其他公开接口参见[@ohos.enterprise.bluetoothManager](js-apis-enterprise-bluetoothManager.md)。
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci## 导入模块
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci```ts
18e41f4b71Sopenharmony_ciimport { bluetoothManager } from '@kit.MDMKit';
19e41f4b71Sopenharmony_ci```
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci## bluetoothManager.isBluetoothDisabled
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ciisBluetoothDisabled(admin: Want): boolean
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci以同步方法查询蓝牙是否被禁用。
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci**参数:**
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci| 参数名   | 类型                                  | 必填   | 说明      |
36e41f4b71Sopenharmony_ci| ----- | ----------------------------------- | ---- | ------- |
37e41f4b71Sopenharmony_ci| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是    | 设备管理应用。 |
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci**返回值:**
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci| 类型                   | 说明                      |
42e41f4b71Sopenharmony_ci| :-------------------- | ------------------------- |
43e41f4b71Sopenharmony_ci| boolean | 返回蓝牙禁用状态,true表示蓝牙被禁用,false表示蓝牙未被禁用。 |
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci**错误码:**
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci以下的错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                                     |
50e41f4b71Sopenharmony_ci| ------- | ---------------------------------------------------------------------------- |
51e41f4b71Sopenharmony_ci| 9200001 | The application is not an administrator application of the device. |
52e41f4b71Sopenharmony_ci| 9200002 | The administrator application does not have permission to manage the device. |
53e41f4b71Sopenharmony_ci| 201 | Permission verification failed. The application does not have the permission required to call the API. |
54e41f4b71Sopenharmony_ci| 202 | Permission verification failed. A non-system application calls a system API. |
55e41f4b71Sopenharmony_ci| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci**示例:**
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci```ts
60e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit';
61e41f4b71Sopenharmony_ciimport { bluetoothManager } from '@kit.MDMKit';
62e41f4b71Sopenharmony_cilet wantTemp: Want = {
63e41f4b71Sopenharmony_ci  bundleName: 'com.example.myapplication',
64e41f4b71Sopenharmony_ci  abilityName: 'EntryAbility',
65e41f4b71Sopenharmony_ci};
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_citry {
68e41f4b71Sopenharmony_ci  let isDisabled: boolean = bluetoothManager.isBluetoothDisabled(wantTemp);
69e41f4b71Sopenharmony_ci  console.info(`Succeeded in query the bluetooth is disabled or not, isDisabled : ${isDisabled}`);
70e41f4b71Sopenharmony_ci} catch(err) {
71e41f4b71Sopenharmony_ci  console.error(`Failed to query the bluetooth is disabled or not. Code: ${err.code}, message: ${err.message}`);
72e41f4b71Sopenharmony_ci};
73e41f4b71Sopenharmony_ci```
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci## bluetoothManager.setBluetoothDisabled
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_cisetBluetoothDisabled(admin: Want, disabled: boolean): void
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci以同步方法设置禁用蓝牙策略。
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci**需要权限:** ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH
82e41f4b71Sopenharmony_ci
83e41f4b71Sopenharmony_ci**系统能力:** SystemCapability.Customization.EnterpriseDeviceManager
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_ci**参数:**
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ci| 参数名     | 类型                                | 必填 | 说明                                      |
90e41f4b71Sopenharmony_ci| ---------- | ----------------------------------- | ---- | ----------------------------------------- |
91e41f4b71Sopenharmony_ci| admin      | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | 是   | 设备管理应用。                            |
92e41f4b71Sopenharmony_ci| disabled   | boolean                             | 是   | true表示禁用蓝牙,false表示解除蓝牙禁用。 |
93e41f4b71Sopenharmony_ci
94e41f4b71Sopenharmony_ci**错误码:**
95e41f4b71Sopenharmony_ci
96e41f4b71Sopenharmony_ci以下的错误码的详细介绍请参见[企业设备管理错误码](errorcode-enterpriseDeviceManager.md)和[通用错误码](../errorcode-universal.md)。
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci| 错误码ID | 错误信息                                                     |
99e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------------------ |
100e41f4b71Sopenharmony_ci| 9200001  | The application is not an administrator application of the device. |
101e41f4b71Sopenharmony_ci| 9200002  | The administrator application does not have permission to manage the device. |
102e41f4b71Sopenharmony_ci| 201      | Permission verification failed. The application does not have the permission required to call the API. |
103e41f4b71Sopenharmony_ci| 202      | Permission verification failed. A non-system application calls a system API. |
104e41f4b71Sopenharmony_ci| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
105e41f4b71Sopenharmony_ci
106e41f4b71Sopenharmony_ci**示例:**
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci```ts
109e41f4b71Sopenharmony_ciimport { Want } from '@kit.AbilityKit';
110e41f4b71Sopenharmony_ciimport { bluetoothManager } from '@kit.MDMKit';
111e41f4b71Sopenharmony_cilet wantTemp: Want = {
112e41f4b71Sopenharmony_ci  bundleName: 'com.example.myapplication',
113e41f4b71Sopenharmony_ci  abilityName: 'EntryAbility',
114e41f4b71Sopenharmony_ci};
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_citry {
117e41f4b71Sopenharmony_ci  bluetoothManager.setBluetoothDisabled(wantTemp, true);
118e41f4b71Sopenharmony_ci  console.info('Succeeded in set the bluetooth disabled.');
119e41f4b71Sopenharmony_ci} catch(err) {
120e41f4b71Sopenharmony_ci  console.error(`Failed to set the bluetooth disabled. Code: ${err.code}, message: ${err.message}`);
121e41f4b71Sopenharmony_ci};
122e41f4b71Sopenharmony_ci```
123