161847f8eSopenharmony_ci/* 261847f8eSopenharmony_ci * Copyright (C) 2023-2024 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 } from './@ohos.base'; 2261847f8eSopenharmony_ciimport type baseProfile from './@ohos.bluetooth.baseProfile'; 2361847f8eSopenharmony_ci 2461847f8eSopenharmony_ci/** 2561847f8eSopenharmony_ci * Provides methods to accessing bluetooth audio related capabilities. 2661847f8eSopenharmony_ci * 2761847f8eSopenharmony_ci * @namespace a2dp 2861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 2961847f8eSopenharmony_ci * @since 10 3061847f8eSopenharmony_ci */ 3161847f8eSopenharmony_ci/** 3261847f8eSopenharmony_ci * Provides methods to accessing bluetooth audio related capabilities. 3361847f8eSopenharmony_ci * 3461847f8eSopenharmony_ci * @namespace a2dp 3561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 3661847f8eSopenharmony_ci * @crossplatform 3761847f8eSopenharmony_ci * @since 13 3861847f8eSopenharmony_ci */ 3961847f8eSopenharmony_cideclare namespace a2dp { 4061847f8eSopenharmony_ci /** 4161847f8eSopenharmony_ci * Base interface of profile. 4261847f8eSopenharmony_ci * 4361847f8eSopenharmony_ci * @typedef { baseProfile.BaseProfile } BaseProfile 4461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 4561847f8eSopenharmony_ci * @since 10 4661847f8eSopenharmony_ci */ 4761847f8eSopenharmony_ci type BaseProfile = baseProfile.BaseProfile; 4861847f8eSopenharmony_ci 4961847f8eSopenharmony_ci /** 5061847f8eSopenharmony_ci * create the instance of a2dp profile. 5161847f8eSopenharmony_ci * 5261847f8eSopenharmony_ci * @returns { A2dpSourceProfile } Returns the instance of profile. 5361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter.Possible causes: 1. Mandatory parameters are left unspecified. 5461847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 5561847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 5661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 5761847f8eSopenharmony_ci * @since 10 5861847f8eSopenharmony_ci */ 5961847f8eSopenharmony_ci /** 6061847f8eSopenharmony_ci * create the instance of a2dp profile. 6161847f8eSopenharmony_ci * 6261847f8eSopenharmony_ci * @returns { A2dpSourceProfile } Returns the instance of profile. 6361847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter.Possible causes: 1. Mandatory parameters are left unspecified. 6461847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 6561847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 6661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 6761847f8eSopenharmony_ci * @crossplatform 6861847f8eSopenharmony_ci * @since 13 6961847f8eSopenharmony_ci */ 7061847f8eSopenharmony_ci function createA2dpSrcProfile(): A2dpSourceProfile; 7161847f8eSopenharmony_ci 7261847f8eSopenharmony_ci /** 7361847f8eSopenharmony_ci * Manager a2dp source profile. 7461847f8eSopenharmony_ci * 7561847f8eSopenharmony_ci * @typedef A2dpSourceProfile 7661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 7761847f8eSopenharmony_ci * @since 10 7861847f8eSopenharmony_ci */ 7961847f8eSopenharmony_ci /** 8061847f8eSopenharmony_ci * Manager a2dp source profile. 8161847f8eSopenharmony_ci * 8261847f8eSopenharmony_ci * @typedef A2dpSourceProfile 8361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 8461847f8eSopenharmony_ci * @crossplatform 8561847f8eSopenharmony_ci * @since 13 8661847f8eSopenharmony_ci */ 8761847f8eSopenharmony_ci interface A2dpSourceProfile extends BaseProfile { 8861847f8eSopenharmony_ci /** 8961847f8eSopenharmony_ci * Initiate an A2DP connection to a remote device. 9061847f8eSopenharmony_ci * 9161847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH 9261847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 9361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 9461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 9561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 9661847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 9761847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 9861847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 9961847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 10061847f8eSopenharmony_ci * @throws { BusinessError } 2900004 - Profile not supported. 10161847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 10261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 10361847f8eSopenharmony_ci * @systemapi 10461847f8eSopenharmony_ci * @since 10 10561847f8eSopenharmony_ci */ 10661847f8eSopenharmony_ci connect(deviceId: string): void; 10761847f8eSopenharmony_ci 10861847f8eSopenharmony_ci /** 10961847f8eSopenharmony_ci * Disconnect the A2DP connection with the remote device. 11061847f8eSopenharmony_ci * 11161847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH 11261847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 11361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 11461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 11561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 11661847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 11761847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 11861847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 11961847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 12061847f8eSopenharmony_ci * @throws { BusinessError } 2900004 - Profile not supported. 12161847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 12261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 12361847f8eSopenharmony_ci * @systemapi 12461847f8eSopenharmony_ci * @since 10 12561847f8eSopenharmony_ci */ 12661847f8eSopenharmony_ci disconnect(deviceId: string): void; 12761847f8eSopenharmony_ci 12861847f8eSopenharmony_ci /** 12961847f8eSopenharmony_ci * Obtains the playing state of device. 13061847f8eSopenharmony_ci * 13161847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH 13261847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 13361847f8eSopenharmony_ci * @returns { PlayingState } Returns the playing state. 13461847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 13561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 13661847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 13761847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 13861847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 13961847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 14061847f8eSopenharmony_ci * @throws { BusinessError } 2900004 - Profile not supported. 14161847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 14261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 14361847f8eSopenharmony_ci * @since 10 14461847f8eSopenharmony_ci */ 14561847f8eSopenharmony_ci getPlayingState(deviceId: string): PlayingState; 14661847f8eSopenharmony_ci 14761847f8eSopenharmony_ci /** 14861847f8eSopenharmony_ci * Checks whether the device supports absolute volume. 14961847f8eSopenharmony_ci * 15061847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH 15161847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 15261847f8eSopenharmony_ci * @returns { Promise<boolean> } Returns the promise object. 15361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 15461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 15561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 15661847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 15761847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 15861847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 15961847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 16061847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 16161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 16261847f8eSopenharmony_ci * @systemapi 16361847f8eSopenharmony_ci * @since 11 16461847f8eSopenharmony_ci */ 16561847f8eSopenharmony_ci isAbsoluteVolumeSupported(deviceId: string): Promise<boolean>; 16661847f8eSopenharmony_ci 16761847f8eSopenharmony_ci /** 16861847f8eSopenharmony_ci * Checks whether the device supports absolute volume. 16961847f8eSopenharmony_ci * 17061847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH 17161847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 17261847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - Callback used to listen for the pairing request event. 17361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 17461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 17561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 17661847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 17761847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 17861847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 17961847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 18061847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 18161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 18261847f8eSopenharmony_ci * @systemapi 18361847f8eSopenharmony_ci * @since 11 18461847f8eSopenharmony_ci */ 18561847f8eSopenharmony_ci isAbsoluteVolumeSupported(deviceId: string, callback: AsyncCallback<boolean>): void; 18661847f8eSopenharmony_ci 18761847f8eSopenharmony_ci /** 18861847f8eSopenharmony_ci * Checks whether the absolute volume is enabled. 18961847f8eSopenharmony_ci * 19061847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH 19161847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 19261847f8eSopenharmony_ci * @returns { Promise<boolean> } Returns the promise object. 19361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 19461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 19561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 19661847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 19761847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 19861847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 19961847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 20061847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 20161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 20261847f8eSopenharmony_ci * @systemapi 20361847f8eSopenharmony_ci * @since 11 20461847f8eSopenharmony_ci */ 20561847f8eSopenharmony_ci isAbsoluteVolumeEnabled(deviceId: string): Promise<boolean>; 20661847f8eSopenharmony_ci 20761847f8eSopenharmony_ci /** 20861847f8eSopenharmony_ci * Checks whether the absolute volume is enabled. 20961847f8eSopenharmony_ci * 21061847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH 21161847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 21261847f8eSopenharmony_ci * @param { AsyncCallback<boolean> } callback - the callback result. 21361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 21461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 21561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 21661847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 21761847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 21861847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 21961847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 22061847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 22161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 22261847f8eSopenharmony_ci * @systemapi 22361847f8eSopenharmony_ci * @since 11 22461847f8eSopenharmony_ci */ 22561847f8eSopenharmony_ci isAbsoluteVolumeEnabled(deviceId: string, callback: AsyncCallback<boolean>): void; 22661847f8eSopenharmony_ci 22761847f8eSopenharmony_ci /** 22861847f8eSopenharmony_ci * Turn on the absolute volume switch. 22961847f8eSopenharmony_ci * 23061847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 23161847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 23261847f8eSopenharmony_ci * @returns { Promise<void> } Returns the promise object. 23361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 23461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 23561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 23661847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 23761847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 23861847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 23961847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 24061847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 24161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 24261847f8eSopenharmony_ci * @systemapi 24361847f8eSopenharmony_ci * @since 11 24461847f8eSopenharmony_ci */ 24561847f8eSopenharmony_ci enableAbsoluteVolume(deviceId: string): Promise<void>; 24661847f8eSopenharmony_ci 24761847f8eSopenharmony_ci /** 24861847f8eSopenharmony_ci * Turn on the absolute volume switch.. 24961847f8eSopenharmony_ci * 25061847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 25161847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 25261847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback result. 25361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 25461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 25561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 25661847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 25761847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 25861847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 25961847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 26061847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 26161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 26261847f8eSopenharmony_ci * @systemapi 26361847f8eSopenharmony_ci * @since 11 26461847f8eSopenharmony_ci */ 26561847f8eSopenharmony_ci enableAbsoluteVolume(deviceId: string, callback: AsyncCallback<void>): void; 26661847f8eSopenharmony_ci 26761847f8eSopenharmony_ci /** 26861847f8eSopenharmony_ci * Turn off the absolute volume switch. 26961847f8eSopenharmony_ci * 27061847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 27161847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 27261847f8eSopenharmony_ci * @returns { Promise<void> } Returns the promise object. 27361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 27461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 27561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 27661847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 27761847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 27861847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 27961847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 28061847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 28161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 28261847f8eSopenharmony_ci * @systemapi 28361847f8eSopenharmony_ci * @since 11 28461847f8eSopenharmony_ci */ 28561847f8eSopenharmony_ci disableAbsoluteVolume(deviceId: string): Promise<void>; 28661847f8eSopenharmony_ci 28761847f8eSopenharmony_ci /** 28861847f8eSopenharmony_ci * Turn off the absolute volume switch.. 28961847f8eSopenharmony_ci * 29061847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 29161847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 29261847f8eSopenharmony_ci * @param { AsyncCallback<void> } callback - the callback result. 29361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 29461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 29561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 29661847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 29761847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 29861847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 29961847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 30061847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 30161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 30261847f8eSopenharmony_ci * @systemapi 30361847f8eSopenharmony_ci * @since 11 30461847f8eSopenharmony_ci */ 30561847f8eSopenharmony_ci disableAbsoluteVolume(deviceId: string, callback: AsyncCallback<void>): void; 30661847f8eSopenharmony_ci 30761847f8eSopenharmony_ci /** 30861847f8eSopenharmony_ci * Get codec information. 30961847f8eSopenharmony_ci * 31061847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH 31161847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 31261847f8eSopenharmony_ci * @returns { CodecInfo } Returns the CodecInfo. 31361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 31461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 31561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 31661847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 31761847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 31861847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 31961847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 32061847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 32161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 32261847f8eSopenharmony_ci * @systemapi 32361847f8eSopenharmony_ci * @since 11 32461847f8eSopenharmony_ci */ 32561847f8eSopenharmony_ci getCurrentCodecInfo(deviceId: string): CodecInfo; 32661847f8eSopenharmony_ci 32761847f8eSopenharmony_ci /** 32861847f8eSopenharmony_ci * Set codec information. 32961847f8eSopenharmony_ci * 33061847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 33161847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 33261847f8eSopenharmony_ci * @param { CodecInfo } codecInfo - Indicates the CodecInfo. 33361847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 33461847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 33561847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 33661847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 33761847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 33861847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 33961847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 34061847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 34161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 34261847f8eSopenharmony_ci * @systemapi 34361847f8eSopenharmony_ci * @since 11 34461847f8eSopenharmony_ci */ 34561847f8eSopenharmony_ci setCurrentCodecInfo(deviceId: string, codecInfo: CodecInfo): void; 34661847f8eSopenharmony_ci 34761847f8eSopenharmony_ci /** 34861847f8eSopenharmony_ci * Restriction devices to play music within {@code duration} milliseconds of connection. 34961847f8eSopenharmony_ci * 35061847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 35161847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 35261847f8eSopenharmony_ci * @param { number } duration - Restricted duration <milliseconds>. Valid range is from 3000ms to 20000ms. 35361847f8eSopenharmony_ci * @returns { Promise<void> } Returns the promise object. 35461847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 35561847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 35661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 35761847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 35861847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 35961847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 36061847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 36161847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 36261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 36361847f8eSopenharmony_ci * @systemapi 36461847f8eSopenharmony_ci * @since 12 36561847f8eSopenharmony_ci */ 36661847f8eSopenharmony_ci disableAutoPlay(deviceId: string, duration: number): Promise<void>; 36761847f8eSopenharmony_ci 36861847f8eSopenharmony_ci /** 36961847f8eSopenharmony_ci * Allow devices to automatically play music when connected. 37061847f8eSopenharmony_ci * 37161847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 37261847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 37361847f8eSopenharmony_ci * @returns { Promise<void> } Returns the promise object. 37461847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 37561847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 37661847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 37761847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 37861847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 37961847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 38061847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 38161847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 38261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 38361847f8eSopenharmony_ci * @systemapi 38461847f8eSopenharmony_ci * @since 12 38561847f8eSopenharmony_ci */ 38661847f8eSopenharmony_ci enableAutoPlay(deviceId: string): Promise<void>; 38761847f8eSopenharmony_ci 38861847f8eSopenharmony_ci /** 38961847f8eSopenharmony_ci * Obtains the duration for which automatic playback is disabled. 39061847f8eSopenharmony_ci * 39161847f8eSopenharmony_ci * @permission ohos.permission.ACCESS_BLUETOOTH and ohos.permission.MANAGE_BLUETOOTH 39261847f8eSopenharmony_ci * @param { string } deviceId - Indicates device ID. For example, "11:22:33:AA:BB:FF". 39361847f8eSopenharmony_ci * @returns { Promise<number> } Returns the duration <milliseconds>; 39461847f8eSopenharmony_ci * If returns { @code -1 } means allow devices automatic play music when connected. 39561847f8eSopenharmony_ci * @throws { BusinessError } 201 - Permission denied. 39661847f8eSopenharmony_ci * @throws { BusinessError } 202 - Non-system applications are not allowed to use system APIs. 39761847f8eSopenharmony_ci * @throws { BusinessError } 401 - Invalid parameter. Possible causes: 1. Mandatory parameters are left unspecified. 39861847f8eSopenharmony_ci * <br>2. Incorrect parameter types. 3. Parameter verification failed. 39961847f8eSopenharmony_ci * @throws { BusinessError } 801 - Capability not supported. 40061847f8eSopenharmony_ci * @throws { BusinessError } 2900001 - Service stopped. 40161847f8eSopenharmony_ci * @throws { BusinessError } 2900003 - Bluetooth disabled. 40261847f8eSopenharmony_ci * @throws { BusinessError } 2900099 - Operation failed. 40361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 40461847f8eSopenharmony_ci * @systemapi 40561847f8eSopenharmony_ci * @since 12 40661847f8eSopenharmony_ci */ 40761847f8eSopenharmony_ci getAutoPlayDisabledDuration(deviceId: string): Promise<number>; 40861847f8eSopenharmony_ci } 40961847f8eSopenharmony_ci 41061847f8eSopenharmony_ci /** 41161847f8eSopenharmony_ci * Describes the codec information. 41261847f8eSopenharmony_ci * 41361847f8eSopenharmony_ci * @typedef CodecInfo 41461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 41561847f8eSopenharmony_ci * @since 11 41661847f8eSopenharmony_ci */ 41761847f8eSopenharmony_ci interface CodecInfo { 41861847f8eSopenharmony_ci /** 41961847f8eSopenharmony_ci * codec type 42061847f8eSopenharmony_ci * 42161847f8eSopenharmony_ci * @type { CodecType } 42261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 42361847f8eSopenharmony_ci * @since 11 42461847f8eSopenharmony_ci */ 42561847f8eSopenharmony_ci codecType: CodecType; 42661847f8eSopenharmony_ci /** 42761847f8eSopenharmony_ci * codec bits per sample. 42861847f8eSopenharmony_ci * 42961847f8eSopenharmony_ci * @type { CodecBitsPerSample } 43061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 43161847f8eSopenharmony_ci * @since 11 43261847f8eSopenharmony_ci */ 43361847f8eSopenharmony_ci codecBitsPerSample: CodecBitsPerSample; 43461847f8eSopenharmony_ci /** 43561847f8eSopenharmony_ci * codec channel mode. 43661847f8eSopenharmony_ci * 43761847f8eSopenharmony_ci * @type { CodecChannelMode } 43861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 43961847f8eSopenharmony_ci * @since 11 44061847f8eSopenharmony_ci */ 44161847f8eSopenharmony_ci codecChannelMode: CodecChannelMode; 44261847f8eSopenharmony_ci /** 44361847f8eSopenharmony_ci * codec sample rate. 44461847f8eSopenharmony_ci * 44561847f8eSopenharmony_ci * @type { CodecSampleRate } 44661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 44761847f8eSopenharmony_ci * @since 11 44861847f8eSopenharmony_ci */ 44961847f8eSopenharmony_ci codecSampleRate: CodecSampleRate; 45061847f8eSopenharmony_ci } 45161847f8eSopenharmony_ci 45261847f8eSopenharmony_ci /** 45361847f8eSopenharmony_ci * The enum of a2dp playing state. 45461847f8eSopenharmony_ci * 45561847f8eSopenharmony_ci * @enum { number } 45661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 45761847f8eSopenharmony_ci * @since 10 45861847f8eSopenharmony_ci */ 45961847f8eSopenharmony_ci enum PlayingState { 46061847f8eSopenharmony_ci /** 46161847f8eSopenharmony_ci * Not playing. 46261847f8eSopenharmony_ci * 46361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 46461847f8eSopenharmony_ci * @since 10 46561847f8eSopenharmony_ci */ 46661847f8eSopenharmony_ci STATE_NOT_PLAYING, 46761847f8eSopenharmony_ci /** 46861847f8eSopenharmony_ci * Playing. 46961847f8eSopenharmony_ci * 47061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 47161847f8eSopenharmony_ci * @since 10 47261847f8eSopenharmony_ci */ 47361847f8eSopenharmony_ci STATE_PLAYING 47461847f8eSopenharmony_ci } 47561847f8eSopenharmony_ci 47661847f8eSopenharmony_ci /** 47761847f8eSopenharmony_ci * Describes the codec type. 47861847f8eSopenharmony_ci * 47961847f8eSopenharmony_ci * @enum { number } 48061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 48161847f8eSopenharmony_ci * @since 11 48261847f8eSopenharmony_ci */ 48361847f8eSopenharmony_ci enum CodecType { 48461847f8eSopenharmony_ci /** 48561847f8eSopenharmony_ci * invalid codec type. 48661847f8eSopenharmony_ci * 48761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 48861847f8eSopenharmony_ci * @since 11 48961847f8eSopenharmony_ci */ 49061847f8eSopenharmony_ci CODEC_TYPE_INVALID = -1, 49161847f8eSopenharmony_ci /** 49261847f8eSopenharmony_ci * SBC - Sub-band coding. 49361847f8eSopenharmony_ci * 49461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 49561847f8eSopenharmony_ci * @since 11 49661847f8eSopenharmony_ci */ 49761847f8eSopenharmony_ci CODEC_TYPE_SBC = 0, 49861847f8eSopenharmony_ci /** 49961847f8eSopenharmony_ci * AAC -Advanced Audio Coding. 50061847f8eSopenharmony_ci * 50161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 50261847f8eSopenharmony_ci * @since 11 50361847f8eSopenharmony_ci */ 50461847f8eSopenharmony_ci CODEC_TYPE_AAC = 1, 50561847f8eSopenharmony_ci /** 50661847f8eSopenharmony_ci * L2HC. 50761847f8eSopenharmony_ci * 50861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 50961847f8eSopenharmony_ci * @since 11 51061847f8eSopenharmony_ci */ 51161847f8eSopenharmony_ci CODEC_TYPE_L2HC = 2, 51261847f8eSopenharmony_ci /** 51361847f8eSopenharmony_ci * L2HCST. 51461847f8eSopenharmony_ci * 51561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 51661847f8eSopenharmony_ci * @since 13 51761847f8eSopenharmony_ci */ 51861847f8eSopenharmony_ci CODEC_TYPE_L2HCST = 3, 51961847f8eSopenharmony_ci /** 52061847f8eSopenharmony_ci * LDAC. 52161847f8eSopenharmony_ci * 52261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 52361847f8eSopenharmony_ci * @since 13 52461847f8eSopenharmony_ci */ 52561847f8eSopenharmony_ci CODEC_TYPE_LDAC = 4 52661847f8eSopenharmony_ci } 52761847f8eSopenharmony_ci 52861847f8eSopenharmony_ci /** 52961847f8eSopenharmony_ci * Describes the codec channel mode. 53061847f8eSopenharmony_ci * 53161847f8eSopenharmony_ci * @enum { number } 53261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 53361847f8eSopenharmony_ci * @since 11 53461847f8eSopenharmony_ci */ 53561847f8eSopenharmony_ci enum CodecChannelMode { 53661847f8eSopenharmony_ci /** 53761847f8eSopenharmony_ci * Codec channel mode none. 53861847f8eSopenharmony_ci * 53961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 54061847f8eSopenharmony_ci * @since 11 54161847f8eSopenharmony_ci */ 54261847f8eSopenharmony_ci CODEC_CHANNEL_MODE_NONE = 0, 54361847f8eSopenharmony_ci /** 54461847f8eSopenharmony_ci * Codec channel mode MONO. 54561847f8eSopenharmony_ci * 54661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 54761847f8eSopenharmony_ci * @since 11 54861847f8eSopenharmony_ci */ 54961847f8eSopenharmony_ci CODEC_CHANNEL_MODE_MONO = 1, 55061847f8eSopenharmony_ci /** 55161847f8eSopenharmony_ci * Codec channel mode STEREO. 55261847f8eSopenharmony_ci * 55361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 55461847f8eSopenharmony_ci * @since 11 55561847f8eSopenharmony_ci */ 55661847f8eSopenharmony_ci CODEC_CHANNEL_MODE_STEREO = 2 55761847f8eSopenharmony_ci } 55861847f8eSopenharmony_ci 55961847f8eSopenharmony_ci /** 56061847f8eSopenharmony_ci * Describes the codec bits per sample. 56161847f8eSopenharmony_ci * 56261847f8eSopenharmony_ci * @enum { number } 56361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 56461847f8eSopenharmony_ci * @since 11 56561847f8eSopenharmony_ci */ 56661847f8eSopenharmony_ci enum CodecBitsPerSample { 56761847f8eSopenharmony_ci /** 56861847f8eSopenharmony_ci * Codec bits per sample none. 56961847f8eSopenharmony_ci * 57061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 57161847f8eSopenharmony_ci * @since 11 57261847f8eSopenharmony_ci */ 57361847f8eSopenharmony_ci CODEC_BITS_PER_SAMPLE_NONE = 0, 57461847f8eSopenharmony_ci /** 57561847f8eSopenharmony_ci * Codec 16 bits per sample. 57661847f8eSopenharmony_ci * 57761847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 57861847f8eSopenharmony_ci * @since 11 57961847f8eSopenharmony_ci */ 58061847f8eSopenharmony_ci CODEC_BITS_PER_SAMPLE_16 = 1, 58161847f8eSopenharmony_ci /** 58261847f8eSopenharmony_ci * Codec 24 bits per sample. 58361847f8eSopenharmony_ci * 58461847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 58561847f8eSopenharmony_ci * @since 11 58661847f8eSopenharmony_ci */ 58761847f8eSopenharmony_ci CODEC_BITS_PER_SAMPLE_24 = 2, 58861847f8eSopenharmony_ci /** 58961847f8eSopenharmony_ci * Codec 32 bits per sample. 59061847f8eSopenharmony_ci * 59161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 59261847f8eSopenharmony_ci * @since 11 59361847f8eSopenharmony_ci */ 59461847f8eSopenharmony_ci CODEC_BITS_PER_SAMPLE_32 = 3 59561847f8eSopenharmony_ci } 59661847f8eSopenharmony_ci 59761847f8eSopenharmony_ci /** 59861847f8eSopenharmony_ci * Describes the codec sample rate. 59961847f8eSopenharmony_ci * 60061847f8eSopenharmony_ci * @enum { number } 60161847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 60261847f8eSopenharmony_ci * @since 11 60361847f8eSopenharmony_ci */ 60461847f8eSopenharmony_ci enum CodecSampleRate { 60561847f8eSopenharmony_ci /** 60661847f8eSopenharmony_ci * Codec sample rate none. 60761847f8eSopenharmony_ci * 60861847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 60961847f8eSopenharmony_ci * @since 11 61061847f8eSopenharmony_ci */ 61161847f8eSopenharmony_ci CODEC_SAMPLE_RATE_NONE = 0, 61261847f8eSopenharmony_ci /** 61361847f8eSopenharmony_ci * Codec sample rate 44.1k. 61461847f8eSopenharmony_ci * 61561847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 61661847f8eSopenharmony_ci * @since 11 61761847f8eSopenharmony_ci */ 61861847f8eSopenharmony_ci CODEC_SAMPLE_RATE_44100 = 1, 61961847f8eSopenharmony_ci /** 62061847f8eSopenharmony_ci * Codec sample rate 48k. 62161847f8eSopenharmony_ci * 62261847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 62361847f8eSopenharmony_ci * @since 11 62461847f8eSopenharmony_ci */ 62561847f8eSopenharmony_ci CODEC_SAMPLE_RATE_48000 = 2, 62661847f8eSopenharmony_ci /** 62761847f8eSopenharmony_ci * Codec sample rate 88.2k. 62861847f8eSopenharmony_ci * 62961847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 63061847f8eSopenharmony_ci * @since 11 63161847f8eSopenharmony_ci */ 63261847f8eSopenharmony_ci CODEC_SAMPLE_RATE_88200 = 3, 63361847f8eSopenharmony_ci /** 63461847f8eSopenharmony_ci * Codec sample rate 96k. 63561847f8eSopenharmony_ci * 63661847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 63761847f8eSopenharmony_ci * @since 11 63861847f8eSopenharmony_ci */ 63961847f8eSopenharmony_ci CODEC_SAMPLE_RATE_96000 = 4, 64061847f8eSopenharmony_ci /** 64161847f8eSopenharmony_ci * Codec sample rate 176.4k. 64261847f8eSopenharmony_ci * 64361847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 64461847f8eSopenharmony_ci * @since 11 64561847f8eSopenharmony_ci */ 64661847f8eSopenharmony_ci CODEC_SAMPLE_RATE_176400 = 5, 64761847f8eSopenharmony_ci /** 64861847f8eSopenharmony_ci * Codec sample rate 192k. 64961847f8eSopenharmony_ci * 65061847f8eSopenharmony_ci * @syscap SystemCapability.Communication.Bluetooth.Core 65161847f8eSopenharmony_ci * @since 11 65261847f8eSopenharmony_ci */ 65361847f8eSopenharmony_ci CODEC_SAMPLE_RATE_192000 = 6 65461847f8eSopenharmony_ci } 65561847f8eSopenharmony_ci} 65661847f8eSopenharmony_ci 65761847f8eSopenharmony_ciexport default a2dp;