From 9b43246521474e33969f004b5e074a7cb3bdf968 Mon Sep 17 00:00:00 2001 From: guoxiadi Date: Tue, 10 Jun 2025 16:30:00 +0800 Subject: [PATCH] add access api Signed-off-by: guoxiadi --- api/@ohos.bluetooth.access.d.ts | 102 ++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/api/@ohos.bluetooth.access.d.ts b/api/@ohos.bluetooth.access.d.ts index 15547e3fbb..70336d2129 100644 --- a/api/@ohos.bluetooth.access.d.ts +++ b/api/@ohos.bluetooth.access.d.ts @@ -121,6 +121,59 @@ declare namespace access { */ function disableBluetooth(): void; + /** + * Asynchronous interface for enables Bluetooth on a device. + * + * @permission ohos.permission.ACCESS_BLUETOOTH + * @returns { Promise } Returns the promise object. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900007 - The user does not respond. + * @throws { BusinessError } 2900010 - User refuse the action. + * @throws { BusinessError } 2900099 - Operation failed. + * @syscap SystemCapability.Communication.Bluetooth.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + function enableBluetoothAsync(): Promise; + + /** + * Asynchronous interface for disables Bluetooth on a device. + * + * @permission ohos.permission.ACCESS_BLUETOOTH + * @returns { Promise } Returns the promise object. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900007 - The user does not respond. + * @throws { BusinessError } 2900010 - User refuse the action. + * @throws { BusinessError } 2900099 - Operation failed. + * @syscap SystemCapability.Communication.Bluetooth.Core + * @crossplatform + * @atomicservice + * @since 20 + */ + function disableBluetoothAsync(): Promise; + + /** + * Notify bluetooth the result of bluetooth dialog. + * + * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH + * @param { NotifyDialogResultParams } notifyDialogResultParams - Indicates the params for dialog result. + * @returns { Promise } Returns the promise object. + * @throws { BusinessError } 201 - Permission denied. + * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. + * @throws { BusinessError } 801 - Capability not supported. + * @throws { BusinessError } 2900001 - Service stopped. + * @throws { BusinessError } 2900099 - Operation failed. + * @syscap SystemCapability.Communication.Bluetooth.Core + * @systemapi + * @since 20 + */ + function notifyDialogResult(notifyDialogResultParams: NotifyDialogResultParams): Promise; + /** * Restrict Bluetooth BR/EDR ability on a device. * @@ -575,6 +628,55 @@ declare namespace access { */ STATE_BLE_TURNING_OFF = 6 } + + /** + * Describes the result of bluetooth dialog. + * + * @typedef NotifyDialogResultParams + * @syscap SystemCapability.Communication.Bluetooth.Core + * @systemapi + * @since 20 + */ + interface NotifyDialogResultParams { + /** + * The type of bluetooth dialog. + * + * @type { DialogType } + * @syscap SystemCapability.Communication.Bluetooth.Core + * @systemapi + * @since 20 + */ + dialogType: DialogType; + /** + * The result of bluetooth dialog. The value true indicates that the user approves the request, + * and the value false indicates that the user rejects the request. + * + * @type { boolean } + * @syscap SystemCapability.Communication.Bluetooth.Core + * @systemapi + * @since 20 + */ + dialogResult: boolean; + } + + /** + * The enum of bluetooth dialog type. + * + * @enum { number } + * @syscap SystemCapability.Communication.Bluetooth.Core + * @systemapi + * @since 20 + */ + enum DialogType { + /** + * The type of bluetooth switch dialog. + * + * @syscap SystemCapability.Communication.Bluetooth.Core + * @systemapi + * @since 20 + */ + BLUETOOTH_SWITCH = 0 + } } export default access; \ No newline at end of file -- Gitee