1# @ohos.enterprise.bluetoothManager (Bluetooth Management) (System API)
2
3The **bluetoothManager** module provides Bluetooth management capabilities, including setting and obtaining Bluetooth information.
4
5> **NOTE**
6>
7> - The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8>
9> - The APIs of this module can be used only in the stage model.
10>
11> - 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).
12>
13> - This topic describes only the system APIs provided by the module. For details about its public APIs, see [@ohos.enterprise.bluetoothManager](js-apis-enterprise-bluetoothManager.md).
14
15## Modules to Import
16
17```ts
18import { bluetoothManager } from '@kit.MDMKit';
19```
20
21## bluetoothManager.isBluetoothDisabled
22
23isBluetoothDisabled(admin: Want): boolean
24
25Checks whether Bluetooth is disabled. This API returns the result synchronously.
26
27**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH
28
29**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
30
31
32
33**Parameters**
34
35| Name  | Type                                 | Mandatory  | Description     |
36| ----- | ----------------------------------- | ---- | ------- |
37| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes   | Device administrator application.|
38
39**Return value**
40
41| Type                  | Description                     |
42| :-------------------- | ------------------------- |
43| boolean | Returns **true** if Bluetooth is disabled; returns **false** otherwise.|
44
45**Error codes**
46
47For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
48
49| ID| Error Message                                                                    |
50| ------- | ---------------------------------------------------------------------------- |
51| 9200001 | The application is not an administrator application of the device. |
52| 9200002 | The administrator application does not have permission to manage the device. |
53| 201 | Permission verification failed. The application does not have the permission required to call the API. |
54| 202 | Permission verification failed. A non-system application calls a system API. |
55| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
56
57**Example**
58
59```ts
60import { Want } from '@kit.AbilityKit';
61import { bluetoothManager } from '@kit.MDMKit';
62let wantTemp: Want = {
63  bundleName: 'com.example.myapplication',
64  abilityName: 'EntryAbility',
65};
66
67try {
68  let isDisabled: boolean = bluetoothManager.isBluetoothDisabled(wantTemp);
69  console.info(`Succeeded in query the bluetooth is disabled or not, isDisabled : ${isDisabled}`);
70} catch(err) {
71  console.error(`Failed to query the bluetooth is disabled or not. Code: ${err.code}, message: ${err.message}`);
72};
73```
74
75## bluetoothManager.setBluetoothDisabled
76
77setBluetoothDisabled(admin: Want, disabled: boolean): void
78
79Disables Bluetooth. This API returns the result synchronously.
80
81**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH
82
83**System capability**: SystemCapability.Customization.EnterpriseDeviceManager
84
85
86
87**Parameters**
88
89| Name    | Type                               | Mandatory| Description                                     |
90| ---------- | ----------------------------------- | ---- | ----------------------------------------- |
91| admin      | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes  | Device administrator application.                           |
92| disabled   | boolean                             | Yes  | Whether to disable Bluetooth. The value **true** means to disable Bluetooth; **false** means the opposite.|
93
94**Error codes**
95
96For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md).
97
98| ID| Error Message                                                    |
99| -------- | ------------------------------------------------------------ |
100| 9200001  | The application is not an administrator application of the device. |
101| 9200002  | The administrator application does not have permission to manage the device. |
102| 201      | Permission verification failed. The application does not have the permission required to call the API. |
103| 202      | Permission verification failed. A non-system application calls a system API. |
104| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. |
105
106**Example**
107
108```ts
109import { Want } from '@kit.AbilityKit';
110import { bluetoothManager } from '@kit.MDMKit';
111let wantTemp: Want = {
112  bundleName: 'com.example.myapplication',
113  abilityName: 'EntryAbility',
114};
115
116try {
117  bluetoothManager.setBluetoothDisabled(wantTemp, true);
118  console.info('Succeeded in set the bluetooth disabled.');
119} catch(err) {
120  console.error(`Failed to set the bluetooth disabled. Code: ${err.code}, message: ${err.message}`);
121};
122```
123