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 #ifndef BLUETOOTH_AUDIO_MANAGER_H
17 #define BLUETOOTH_AUDIO_MANAGER_H
18 
19 #include <cstdint>
20 #include <string>
21 
22 #include "iremote_broker.h"
23 #include "refbase.h"
24 #include "bluetooth_def.h"
25 #include "bluetooth_types.h"
26 #include "bluetooth_remote_device.h"
27 #include "bluetooth_no_destructor.h"
28 
29 namespace OHOS {
30 namespace Bluetooth {
31 
32 class BLUETOOTH_API BluetoothAudioManager {
33 public:
34     /**
35      * @brief Get audio manager.
36      *
37      * @return Returns the singleton instance.
38      * @since 6
39      */
40     static BluetoothAudioManager &GetInstance();
41 
42     int EnableWearDetection(const std::string &deviceId);
43     int DisableWearDetection(const std::string &deviceId);
44     int GetWearDetectionState(const std::string &deviceId, int32_t &ability);
45 
46     /**
47      * @brief Headset is wearing.
48      *
49      * @param device Remote device.
50      * @return Returns {@link BtErrCode} if the operation fails.
51      *         returns {wear 1 or unwear 0} otherwise.
52      * @since 11
53      */
54     int IsDeviceWearing(const BluetoothRemoteDevice &device);
55 
56     /**
57      * @brief Whether wear detection is supported
58      *
59      * @param device Remote device.
60      * @param isSupported Headset wearing detection capability.
61      * @return Returns {@link BT_NO_ERROR} if the operation fails.
62      *         returns an error code defined in {@link BtErrCode} otherwise.
63      * @since 11
64      */
65     int IsWearDetectionSupported(const BluetoothRemoteDevice &device, bool &isSupported);
66 
67     /**
68     * @brief Report to the remote device that the user has selected the device.
69     * @param device Remote device.
70     * @param useA2dp whether use A2dp of this device.
71     * @param useHfp whether use Hfp of this device.
72     * @param userSelection whether this send command by user selection.
73     * @return Returns {@link BT_NO_ERROR} if send selection success;
74     * returns an error code defined in {@link BtErrCode} otherwise.
75     */
76     int SendDeviceSelection(const BluetoothRemoteDevice &device, int useA2dp, int useHfp, int userSelection) const;
77 
78 private:
79     /**
80      * @brief A constructor used to create a <b>BluetoothHost</b> instance.
81      *
82      * @since 6
83      */
84     BluetoothAudioManager();
85 
86     BLUETOOTH_DISALLOW_COPY_AND_ASSIGN(BluetoothAudioManager);
87     BLUETOOTH_DECLARE_IMPL();
88 
89 #ifdef DTFUZZ_TEST
90     friend class BluetoothNoDestructor<BluetoothAudioManager>;
91 #endif
92 };
93 }  // namespace Bluetooth
94 }  // namespace OHOS
95 #endif
96