161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd. 361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 461847f8eSopenharmony_ci * you may not use this file except in compliance with the License. 561847f8eSopenharmony_ci * You may obtain a copy of the License at 661847f8eSopenharmony_ci * 761847f8eSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 861847f8eSopenharmony_ci * 961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and 1361847f8eSopenharmony_ci * limitations under the License. 1461847f8eSopenharmony_ci */ 1561847f8eSopenharmony_ci 1661847f8eSopenharmony_ci/** 1761847f8eSopenharmony_ci * @file 1861847f8eSopenharmony_ci * @kit ConnectivityKit 1961847f8eSopenharmony_ci */ 2061847f8eSopenharmony_ci 2161847f8eSopenharmony_ciimport type { AsyncCallback, Callback } from './@ohos.base'; 2261847f8eSopenharmony_ci 2361847f8eSopenharmony_ci/** 2461847f8eSopenharmony_ci * Provides methods to manage the wearing detection function. 2561847f8eSopenharmony_ci * 2661847f8eSopenharmony_ci * @namespace wearDetection 2761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 2861847f8eSopenharmony_ci * @since 11 2961847f8eSopenharmony_ci */ 3061847f8eSopenharmony_cideclare namespace wearDetection { 3161847f8eSopenharmony_ci /** 3261847f8eSopenharmony_ci * Turn on the wearing detection switch. 3361847f8eSopenharmony_ci * 3461847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 3561847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID.For example, "11:22:33:AA:BB:FF", 3661847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the Callback result. 3761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 3861847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 3961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 4061847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 4161847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 4261847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 4361847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 4461847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 4561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 4661847f8eSopenharmony_ci * @systemapi 4761847f8eSopenharmony_ci * @since 11 4861847f8eSopenharmony_ci */ 4961847f8eSopenharmony_ci function enableWearDetection(deviceId: string, callback: AsyncCallback<void>): void; 5061847f8eSopenharmony_ci 5161847f8eSopenharmony_ci /** 5261847f8eSopenharmony_ci * Turn on the wearing detection switch. 5361847f8eSopenharmony_ci * 5461847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 5561847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID.For example, "11:22:33:AA:BB:FF", 5661847f8eSopenharmony_ci * @returns { Promise<void> } Returns the promise object. 5761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 5861847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 5961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 6061847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 6161847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 6261847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 6361847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 6461847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 6561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 6661847f8eSopenharmony_ci * @systemapi 6761847f8eSopenharmony_ci * @since 11 6861847f8eSopenharmony_ci */ 6961847f8eSopenharmony_ci function enableWearDetection(deviceId: string): Promise<void>; 7061847f8eSopenharmony_ci 7161847f8eSopenharmony_ci /** 7261847f8eSopenharmony_ci * Turn off the wearing detection switch. 7361847f8eSopenharmony_ci * 7461847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 7561847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID.For example, "11:22:33:AA:BB:FF", 7661847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the Callback result. 7761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 7861847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 7961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 8061847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 8161847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 8261847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 8361847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 8461847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 8561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 8661847f8eSopenharmony_ci * @systemapi 8761847f8eSopenharmony_ci * @since 11 8861847f8eSopenharmony_ci */ 8961847f8eSopenharmony_ci function disableWearDetection(deviceId: string, callback: AsyncCallback<void>): void; 9061847f8eSopenharmony_ci 9161847f8eSopenharmony_ci /** 9261847f8eSopenharmony_ci * Turn off the wearing detection switch. 9361847f8eSopenharmony_ci * 9461847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 9561847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID.For example, "11:22:33:AA:BB:FF", 9661847f8eSopenharmony_ci * @returns { Promise<void> } Returns the promise object. 9761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 9861847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 9961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 10061847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 10161847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 10261847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 10361847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 10461847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 10561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 10661847f8eSopenharmony_ci * @systemapi 10761847f8eSopenharmony_ci * @since 11 10861847f8eSopenharmony_ci */ 10961847f8eSopenharmony_ci function disableWearDetection(deviceId: string): Promise<void>; 11061847f8eSopenharmony_ci 11161847f8eSopenharmony_ci /** 11261847f8eSopenharmony_ci * Checks whether the device supports wear detection. 11361847f8eSopenharmony_ci * 11461847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH 11561847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID.For example, "11:22:33:AA:BB:FF", 11661847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the Callback result. 11761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 11861847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 11961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 12061847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 12161847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 12261847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 12361847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 12461847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 12561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 12661847f8eSopenharmony_ci * @systemapi 12761847f8eSopenharmony_ci * @since 11 12861847f8eSopenharmony_ci */ 12961847f8eSopenharmony_ci function isWearDetectionSupported(deviceId: string, callback: AsyncCallback<boolean>): void; 13061847f8eSopenharmony_ci 13161847f8eSopenharmony_ci /** 13261847f8eSopenharmony_ci * Checks whether the device supports wear detection. 13361847f8eSopenharmony_ci * 13461847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH 13561847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID.For example, "11:22:33:AA:BB:FF", 13661847f8eSopenharmony_ci * @returns { Promise<boolean> } Returns the promise object. 13761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 13861847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 13961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 14061847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 14161847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 14261847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 14361847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 14461847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 14561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 14661847f8eSopenharmony_ci * @systemapi 14761847f8eSopenharmony_ci * @since 11 14861847f8eSopenharmony_ci */ 14961847f8eSopenharmony_ci function isWearDetectionSupported(deviceId: string): Promise<boolean>; 15061847f8eSopenharmony_ci 15161847f8eSopenharmony_ci /** 15261847f8eSopenharmony_ci * Check whether the wearing detection is enabled. 15361847f8eSopenharmony_ci * 15461847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH 15561847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID.For example, "11:22:33:AA:BB:FF", 15661847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the Callback result. 15761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 15861847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 15961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 16061847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 16161847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 16261847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 16361847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 16461847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 16561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 16661847f8eSopenharmony_ci * @systemapi 16761847f8eSopenharmony_ci * @since 11 16861847f8eSopenharmony_ci */ 16961847f8eSopenharmony_ci function isWearDetectionEnabled(deviceId: string, callback: AsyncCallback<boolean>): void; 17061847f8eSopenharmony_ci 17161847f8eSopenharmony_ci /** 17261847f8eSopenharmony_ci * Check whether the wearing detection is enabled. 17361847f8eSopenharmony_ci * 17461847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH 17561847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID.For example, "11:22:33:AA:BB:FF", 17661847f8eSopenharmony_ci * @returns { Promise<boolean> } Returns the promise object. 17761847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 17861847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 17961847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 18061847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 18161847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 18261847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 18361847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 18461847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 18561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 18661847f8eSopenharmony_ci * @systemapi 18761847f8eSopenharmony_ci * @since 11 18861847f8eSopenharmony_ci */ 18961847f8eSopenharmony_ci function isWearDetectionEnabled(deviceId: string): Promise<boolean>; 19061847f8eSopenharmony_ci} 19161847f8eSopenharmony_ci 19261847f8eSopenharmony_ciexport default wearDetection;