1/* 2 * Copyright (C) 2023 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 ConnectivityKit 19 */ 20 21import type { AsyncCallback, Callback } from './@ohos.base'; 22 23/** 24 * Provides methods to manage the wearing detection function. 25 * 26 * @namespace wearDetection 27 * @syscap SystemCapability.Communication.Bluetooth.Core 28 * @since 11 29 */ 30declare namespace wearDetection { 31 /** 32 * Turn on the wearing detection switch. 33 * 34 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 35 * @param { string } deviceId - Indicates device ID.For example, "11:22:33:AA:BB:FF", 36 * @param { AsyncCallback<void> } callback - the Callback result. 37 * @throws { BusinessError } 201 - Permission denied. 38 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 39 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 40 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 41 * @throws { BusinessError } 801 - Capability not supported. 42 * @throws { BusinessError } 2900001 - Service stopped. 43 * @throws { BusinessError } 2900003 - Bluetooth switch is off. 44 * @throws { BusinessError } 2900099 - Operation failed. 45 * @syscap SystemCapability.Communication.Bluetooth.Core 46 * @systemapi 47 * @since 11 48 */ 49 function enableWearDetection(deviceId: string, callback: AsyncCallback<void>): void; 50 51 /** 52 * Turn on the wearing detection switch. 53 * 54 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 55 * @param { string } deviceId - Indicates device ID.For example, "11:22:33:AA:BB:FF", 56 * @returns { Promise<void> } Returns the promise object. 57 * @throws { BusinessError } 201 - Permission denied. 58 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 59 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 60 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 61 * @throws { BusinessError } 801 - Capability not supported. 62 * @throws { BusinessError } 2900001 - Service stopped. 63 * @throws { BusinessError } 2900003 - Bluetooth switch is off. 64 * @throws { BusinessError } 2900099 - Operation failed. 65 * @syscap SystemCapability.Communication.Bluetooth.Core 66 * @systemapi 67 * @since 11 68 */ 69 function enableWearDetection(deviceId: string): Promise<void>; 70 71 /** 72 * Turn off the wearing detection switch. 73 * 74 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 75 * @param { string } deviceId - Indicates device ID.For example, "11:22:33:AA:BB:FF", 76 * @param { AsyncCallback<void> } callback - the Callback result. 77 * @throws { BusinessError } 201 - Permission denied. 78 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 79 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 80 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 81 * @throws { BusinessError } 801 - Capability not supported. 82 * @throws { BusinessError } 2900001 - Service stopped. 83 * @throws { BusinessError } 2900003 - Bluetooth switch is off. 84 * @throws { BusinessError } 2900099 - Operation failed. 85 * @syscap SystemCapability.Communication.Bluetooth.Core 86 * @systemapi 87 * @since 11 88 */ 89 function disableWearDetection(deviceId: string, callback: AsyncCallback<void>): void; 90 91 /** 92 * Turn off the wearing detection switch. 93 * 94 * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 95 * @param { string } deviceId - Indicates device ID.For example, "11:22:33:AA:BB:FF", 96 * @returns { Promise<void> } Returns the promise object. 97 * @throws { BusinessError } 201 - Permission denied. 98 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 99 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 100 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 101 * @throws { BusinessError } 801 - Capability not supported. 102 * @throws { BusinessError } 2900001 - Service stopped. 103 * @throws { BusinessError } 2900003 - Bluetooth switch is off. 104 * @throws { BusinessError } 2900099 - Operation failed. 105 * @syscap SystemCapability.Communication.Bluetooth.Core 106 * @systemapi 107 * @since 11 108 */ 109 function disableWearDetection(deviceId: string): Promise<void>; 110 111 /** 112 * Checks whether the device supports wear detection. 113 * 114 * @permission ohos.permission.ACCESS_BLUETOOTH 115 * @param { string } deviceId - Indicates device ID.For example, "11:22:33:AA:BB:FF", 116 * @param { AsyncCallback<boolean> } callback - the Callback result. 117 * @throws { BusinessError } 201 - Permission denied. 118 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 119 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 120 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 121 * @throws { BusinessError } 801 - Capability not supported. 122 * @throws { BusinessError } 2900001 - Service stopped. 123 * @throws { BusinessError } 2900003 - Bluetooth switch is off. 124 * @throws { BusinessError } 2900099 - Operation failed. 125 * @syscap SystemCapability.Communication.Bluetooth.Core 126 * @systemapi 127 * @since 11 128 */ 129 function isWearDetectionSupported(deviceId: string, callback: AsyncCallback<boolean>): void; 130 131 /** 132 * Checks whether the device supports wear detection. 133 * 134 * @permission ohos.permission.ACCESS_BLUETOOTH 135 * @param { string } deviceId - Indicates device ID.For example, "11:22:33:AA:BB:FF", 136 * @returns { Promise<boolean> } Returns the promise object. 137 * @throws { BusinessError } 201 - Permission denied. 138 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 139 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 140 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 141 * @throws { BusinessError } 801 - Capability not supported. 142 * @throws { BusinessError } 2900001 - Service stopped. 143 * @throws { BusinessError } 2900003 - Bluetooth switch is off. 144 * @throws { BusinessError } 2900099 - Operation failed. 145 * @syscap SystemCapability.Communication.Bluetooth.Core 146 * @systemapi 147 * @since 11 148 */ 149 function isWearDetectionSupported(deviceId: string): Promise<boolean>; 150 151 /** 152 * Check whether the wearing detection is enabled. 153 * 154 * @permission ohos.permission.ACCESS_BLUETOOTH 155 * @param { string } deviceId - Indicates device ID.For example, "11:22:33:AA:BB:FF", 156 * @param { AsyncCallback<boolean> } callback - the Callback result. 157 * @throws { BusinessError } 201 - Permission denied. 158 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 159 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 160 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 161 * @throws { BusinessError } 801 - Capability not supported. 162 * @throws { BusinessError } 2900001 - Service stopped. 163 * @throws { BusinessError } 2900003 - Bluetooth switch is off. 164 * @throws { BusinessError } 2900099 - Operation failed. 165 * @syscap SystemCapability.Communication.Bluetooth.Core 166 * @systemapi 167 * @since 11 168 */ 169 function isWearDetectionEnabled(deviceId: string, callback: AsyncCallback<boolean>): void; 170 171 /** 172 * Check whether the wearing detection is enabled. 173 * 174 * @permission ohos.permission.ACCESS_BLUETOOTH 175 * @param { string } deviceId - Indicates device ID.For example, "11:22:33:AA:BB:FF", 176 * @returns { Promise<boolean> } Returns the promise object. 177 * @throws { BusinessError } 201 - Permission denied. 178 * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 179 * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 180 * <br>2. Incorrect parameter types. 3. Parameter verification failed. 181 * @throws { BusinessError } 801 - Capability not supported. 182 * @throws { BusinessError } 2900001 - Service stopped. 183 * @throws { BusinessError } 2900003 - Bluetooth switch is off. 184 * @throws { BusinessError } 2900099 - Operation failed. 185 * @syscap SystemCapability.Communication.Bluetooth.Core 186 * @systemapi 187 * @since 11 188 */ 189 function isWearDetectionEnabled(deviceId: string): Promise<boolean>; 190} 191 192export default wearDetection;