• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   * Gets bluetooth information.
76   * This function can be called by a super administrator.
77   *
78   * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH
79   * @param { Want } admin - admin indicates the enterprise admin extension ability information.
80   *                         The admin must have the corresponding permission.
81   * @returns { BluetoothInfo } the bluetooth information.
82   * @throws { BusinessError } 9200001 - The application is not an administrator application of the device.
83   * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device.
84   * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
85   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
86   *                                 2. Incorrect parameter types; 3. Parameter verification failed.
87   * @syscap SystemCapability.Customization.EnterpriseDeviceManager
88   * @stagemodelonly
89   * @since 12
90   */
91  function getBluetoothInfo(admin: Want): BluetoothInfo;
92
93  /**
94   * Disables the bluetooth.
95   * This function can be called by a super administrator.
96   *
97   * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH
98   * @param { Want } admin - admin indicates the enterprise admin extension ability information.
99   *                         The admin must have the corresponding permission.
100   * @param { boolean } disabled - true if disable the bluetooth, otherwise false.
101   * @throws { BusinessError } 9200001 - The application is not an administrator application of the device.
102   * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device.
103   * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
104   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
105   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
106   *                                 2. Incorrect parameter types; 3. Parameter verification failed.
107   * @syscap SystemCapability.Customization.EnterpriseDeviceManager
108   * @systemapi
109   * @stagemodelonly
110   * @since 11
111   */
112  function setBluetoothDisabled(admin: Want, disabled: boolean): void;
113
114  /**
115   * Gets state of whether the bluetooth is disabled.
116   * This function can be called by a super administrator.
117   *
118   * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH
119   * @param { Want } admin - admin indicates the enterprise admin extension ability information.
120   *                         If the admin is not empty, it must have the corresponding permission.
121   * @returns { boolean } true if the bluetooth is disabled, otherwise false.
122   * @throws { BusinessError } 9200001 - The application is not an administrator application of the device.
123   * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device.
124   * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
125   * @throws { BusinessError } 202 - Permission verification failed. A non-system application calls a system API.
126   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
127   *                                 2. Incorrect parameter types; 3. Parameter verification failed.
128   * @syscap SystemCapability.Customization.EnterpriseDeviceManager
129   * @systemapi
130   * @stagemodelonly
131   * @since 11
132   */
133  function isBluetoothDisabled(admin: Want): boolean;
134
135  /**
136   * Adds devices to the list of bluetooth devices that are allowed to be connected.
137   * This function can be called by a super administrator.
138   *
139   * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH
140   * @param { Want } admin - admin indicates the enterprise admin extension ability information.
141   *                         The admin must have the corresponding permission.
142   * @param { Array<string> } deviceIds - IDs of the bluetooth devices to be added to the list.
143   *                                      The size of the array after setting cannot be greater than 1000.
144   * @throws { BusinessError } 9200001 - The application is not an administrator application of the device.
145   * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device.
146   * @throws { BusinessError } 9200010 - A conflict policy has been configured.
147   * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
148   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
149   *                                 2. Incorrect parameter types; 3. Parameter verification failed.
150   * @syscap SystemCapability.Customization.EnterpriseDeviceManager
151   * @stagemodelonly
152   * @since 12
153   */
154  function addAllowedBluetoothDevices(admin: Want, deviceIds: Array<string>): void;
155
156  /**
157   * Removes devices from the list of bluetooth devices that are allowed to be connected.
158   * This function can be called by a super administrator.
159   *
160   * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH
161   * @param { Want } admin - admin indicates the enterprise admin extension ability information.
162   *                         The admin must have the corresponding permission.
163   * @param { Array<string> } deviceIds - IDs of the bluetooth devices to be removed from the list.
164   *                                      The size of the array after setting cannot be greater than 1000.
165   * @throws { BusinessError } 9200001 - The application is not an administrator application of the device.
166   * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device.
167   * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
168   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
169   *                                 2. Incorrect parameter types; 3. Parameter verification failed.
170   * @syscap SystemCapability.Customization.EnterpriseDeviceManager
171   * @stagemodelonly
172   * @since 12
173   */
174  function removeAllowedBluetoothDevices(admin: Want, deviceIds: Array<string>): void;
175
176  /**
177   * Gets the devices in the list of bluetooth devices that are allowed to be connected.
178   * This function can be called by a super administrator.
179   *
180   * @permission ohos.permission.ENTERPRISE_MANAGE_BLUETOOTH
181   * @param { Want } admin - admin indicates the enterprise admin extension ability information.
182   *                         If the admin is not empty, it must have the corresponding permission.
183   * @returns { Array<string> } IDs of the bluetooth devices in the list.
184   * @throws { BusinessError } 9200001 - The application is not an administrator application of the device.
185   * @throws { BusinessError } 9200002 - The administrator application does not have permission to manage the device.
186   * @throws { BusinessError } 201 - Permission verification failed. The application does not have the permission required to call the API.
187   * @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
188   *                                 2. Incorrect parameter types; 3. Parameter verification failed.
189   * @syscap SystemCapability.Customization.EnterpriseDeviceManager
190   * @stagemodelonly
191   * @since 12
192   */
193  function getAllowedBluetoothDevices(admin: Want): Array<string>;
194}
195
196export default bluetoothManager;
197