1/* 2 * Copyright (c) 2023-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit MDMKit 19 */ 20 21import type Want from './@ohos.app.ability.Want'; 22import type constant from './@ohos.bluetooth.constant'; 23import type access from './@ohos.bluetooth.access'; 24 25/** 26 * This module provides the capability to manage the bluetooth of the enterprise devices. 27 * 28 * @namespace bluetoothManager 29 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 30 * @stagemodelonly 31 * @since 11 32 */ 33declare namespace bluetoothManager { 34 /** 35 * The information of device bluetooth. 36 * 37 * @typedef BluetoothInfo 38 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 39 * @stagemodelonly 40 * @since 12 41 */ 42 export interface BluetoothInfo { 43 /** 44 * The name of bluetooth. 45 * 46 * @type { string } 47 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 48 * @stagemodelonly 49 * @since 12 50 */ 51 name: string; 52 53 /** 54 * The state of bluetooth. 55 * 56 * @type { access.BluetoothState } 57 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 58 * @stagemodelonly 59 * @since 12 60 */ 61 state: access.BluetoothState; 62 63 /** 64 * The state of bluetooth connection 65 * 66 * @type { constant.ProfileConnectionState } 67 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 68 * @stagemodelonly 69 * @since 12 70 */ 71 connectionState: constant.ProfileConnectionState; 72 } 73 74 /** 75 * Bluetooth protocol 76 * 77 * @enum { number } 78 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 79 * @stagemodelonly 80 * @since 20 81 */ 82 export enum Protocol { 83 /** 84 * Gatt protocol. 85 * 86 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 87 * @stagemodelonly 88 * @since 20 89 */ 90 GATT = 0, 91 92 /** 93 * Spp protocol. 94 * 95 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 96 * @stagemodelonly 97 * @since 20 98 */ 99 SPP = 1, 100 101 /** 102 * Opp protocol. 103 * 104 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 105 * @stagemodelonly 106 * @since 20 107 */ 108 OPP = 2, 109 } 110 111 /** 112 * Gets bluetooth information. 113 * This function can be called by a super administrator. 114 * 115 * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH 116 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 117 * The admin must have the corresponding permission. 118 * @returns { BluetoothInfo } the bluetooth information. 119 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 120 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 121 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 122 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 123 * 2. Incorrect parameter types; 3. Parameter verification failed. 124 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 125 * @stagemodelonly 126 * @since 12 127 */ 128 function getBluetoothInfo(admin: Want): BluetoothInfo; 129 130 /** 131 * Disables the bluetooth. 132 * This function can be called by a super administrator. 133 * 134 * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH 135 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 136 * The admin must have the corresponding permission. 137 * @param { boolean } disabled - true if disable the bluetooth, otherwise false. 138 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 139 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 140 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 141 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 142 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 143 * 2. Incorrect parameter types; 3. Parameter verification failed. 144 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 145 * @systemapi 146 * @stagemodelonly 147 * @since 11 148 */ 149 function setBluetoothDisabled(admin: Want, disabled: boolean): void; 150 151 /** 152 * Gets state of whether the bluetooth is disabled. 153 * This function can be called by a super administrator. 154 * 155 * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH 156 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 157 * If the admin is not empty, it must have the corresponding permission. 158 * @returns { boolean } true if the bluetooth is disabled, otherwise false. 159 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 160 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 161 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 162 * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API. 163 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 164 * 2. Incorrect parameter types; 3. Parameter verification failed. 165 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 166 * @systemapi 167 * @stagemodelonly 168 * @since 11 169 */ 170 function isBluetoothDisabled(admin: Want): boolean; 171 172 /** 173 * Adds devices to the list of bluetooth devices that are allowed to be connected. 174 * This function can be called by a super administrator. 175 * 176 * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH 177 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 178 * The admin must have the corresponding permission. 179 * @param { Array<string> } deviceIds - IDs of the bluetooth devices to be added to the list. 180 * The size of the array after setting cannot be greater than 1000. 181 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 182 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 183 * @throws { BusinessError } 9200010 - A conflict policy has been configured. 184 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 185 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 186 * 2. Incorrect parameter types; 3. Parameter verification failed. 187 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 188 * @stagemodelonly 189 * @since 12 190 */ 191 function addAllowedBluetoothDevices(admin: Want, deviceIds: Array<string>): void; 192 193 /** 194 * Removes devices from the list of bluetooth devices that are allowed to be connected. 195 * This function can be called by a super administrator. 196 * 197 * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH 198 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 199 * The admin must have the corresponding permission. 200 * @param { Array<string> } deviceIds - IDs of the bluetooth devices to be removed from the list. 201 * The size of the array after setting cannot be greater than 1000. 202 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 203 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 204 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 205 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 206 * 2. Incorrect parameter types; 3. Parameter verification failed. 207 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 208 * @stagemodelonly 209 * @since 12 210 */ 211 function removeAllowedBluetoothDevices(admin: Want, deviceIds: Array<string>): void; 212 213 /** 214 * Gets the devices in the list of bluetooth devices that are allowed to be connected. 215 * This function can be called by a super administrator. 216 * 217 * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH 218 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 219 * If the admin is not empty, it must have the corresponding permission. 220 * @returns { Array<string> } IDs of the bluetooth devices in the list. 221 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 222 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 223 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 224 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 225 * 2. Incorrect parameter types; 3. Parameter verification failed. 226 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 227 * @stagemodelonly 228 * @since 12 229 */ 230 function getAllowedBluetoothDevices(admin: Want): Array<string>; 231 232 /** 233 * Turn on bluetooth. 234 * This function can be called by a super administrator. 235 * 236 * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH 237 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 238 * If the admin is not empty, it must have the corresponding permission. 239 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 240 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 241 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 242 * @throws { BusinessError } 203 - This function is prohibited by enterprise management policies. 243 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 244 * @stagemodelonly 245 * @since 20 246 */ 247 function turnOnBluetooth(admin: Want): void; 248 249 /** 250 * Turn off bluetooth. 251 * This function can be called by a super administrator. 252 * 253 * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH 254 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 255 * If the admin is not empty, it must have the corresponding permission. 256 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 257 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 258 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 259 * @throws { BusinessError } 203 - This function is prohibited by enterprise management policies. 260 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 261 * @stagemodelonly 262 * @since 20 263 */ 264 function turnOffBluetooth(admin: Want): void; 265 266 /** 267 * Adds devices to the list of bluetooth devices that are disallowed to be connected. 268 * This function can be called by a super administrator. 269 * 270 * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH 271 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 272 * The admin must have the corresponding permission. 273 * @param { Array<string> } deviceIds - IDs of the bluetooth devices to be added to the list. 274 * The size of the array after setting cannot be greater than 1000. 275 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 276 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 277 * @throws { BusinessError } 9200010 - A conflict policy has been configured. 278 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 279 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 280 * @stagemodelonly 281 * @since 20 282 */ 283 function addDisallowedBluetoothDevices(admin: Want, deviceIds: Array<string>): void; 284 285 /** 286 * Removes devices from the list of bluetooth devices that are disallowed to be connected. 287 * This function can be called by a super administrator. 288 * 289 * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH 290 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 291 * The admin must have the corresponding permission. 292 * @param { Array<string> } deviceIds - IDs of the bluetooth devices to be removed from the list. 293 * The size of the array after setting cannot be greater than 1000. 294 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 295 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 296 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 297 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 298 * @stagemodelonly 299 * @since 20 300 */ 301 function removeDisallowedBluetoothDevices(admin: Want, deviceIds: Array<string>): void; 302 303 /** 304 * Gets the devices in the list of bluetooth devices that are disallowed to be connected. 305 * This function can be called by a super administrator. 306 * 307 * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH 308 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 309 * If the admin is not empty, it must have the corresponding permission. 310 * @returns { Array<string> } IDs of the bluetooth devices in the list. 311 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 312 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 313 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 314 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 315 * @stagemodelonly 316 * @since 20 317 */ 318 function getDisallowedBluetoothDevices(admin: Want): Array<string>; 319 320 /** 321 * Adds protocols to the list of bluetooth server that are disallowed to use. 322 * This function can be called by a super administrator. 323 * 324 * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH 325 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 326 * The admin must have the corresponding permission. 327 * @param { number } accountId - accountId indicates the local ID of the OS account. 328 * @param { Array<Protocol> } protocols - protocol of the bluetooth to be added to the list. 329 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 330 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 331 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 332 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 333 * @stagemodelonly 334 * @since 20 335 */ 336 function addDisallowedBluetoothProtocols(admin: Want, accountId: number, protocols: Array<Protocol>): void; 337 338 /** 339 * Remove protocol from the list of bluetooth server that are disallowed to use. 340 * This function can be called by a super administrator. 341 * 342 * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH 343 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 344 * The admin must have the corresponding permission. 345 * @param { number } accountId - accountId indicates the local ID of the OS account. 346 * @param { Array<Protocol> } protocols - protocol of the bluetooth to be removed from the list. 347 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 348 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 349 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 350 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 351 * @stagemodelonly 352 * @since 20 353 */ 354 function removeDisallowedBluetoothProtocols(admin: Want, accountId: number, protocols: Array<Protocol>): void; 355 356 /** 357 * Gets protocols to the list of bluetooth server that are disallowed to use. 358 * This function can be called by a super administrator. 359 * 360 * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH 361 * @param { Want } admin - admin indicates the enterprise admin extension ability information. 362 * If the admin is not empty, it must have the corresponding permission. 363 * @param { number } accountId - accountId indicates the local ID of the OS account. 364 * @returns { Array<Protocol> } protocol of the bluetooth list. 365 * @throws { BusinessError } 9200001 - The application is not an administrator application of the device. 366 * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device. 367 * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API. 368 * @syscap SystemCapability.Customization.EnterpriseDeviceManager 369 * @stagemodelonly 370 * @since 20 371 */ 372 function getDisallowedBluetoothProtocols(admin: Want, accountId: number): Array<Protocol>; 373} 374 375export default bluetoothManager; 376