1 /*
2  * Copyright 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_INCLUDE_BT_HEARING_AID_H
18 #define ANDROID_INCLUDE_BT_HEARING_AID_H
19 
20 #include <hardware/bluetooth.h>
21 
22 #include "types/raw_address.h"
23 
24 namespace bluetooth {
25 namespace hearing_aid {
26 
27 // Must be kept in sync with BluetoothProfile.java
28 enum class ConnectionState { DISCONNECTED = 0, CONNECTING, CONNECTED, DISCONNECTING };
29 
30 class HearingAidCallbacks {
31 public:
32   virtual ~HearingAidCallbacks() = default;
33 
34   /** Callback for profile connection state change */
35   virtual void OnConnectionState(ConnectionState state, const RawAddress& address) = 0;
36 
37   /** Callback for device being available. Is executed when devices are loaded
38    * from storage on stack bringup, and when new device is connected to profile.
39    * Main purpose of this callback is to keep its users informed of device
40    * capabilities and hiSyncId.
41    */
42   virtual void OnDeviceAvailable(uint8_t capabilities, uint64_t hiSyncId,
43                                  const RawAddress& address) = 0;
44 };
45 
46 class HearingAidInterface {
47 public:
48   virtual ~HearingAidInterface() = default;
49 
50   /** Register the Hearing Aid callbacks */
51   virtual void Init(HearingAidCallbacks* callbacks) = 0;
52 
53   /** Connect to Hearing Aid */
54   virtual void Connect(const RawAddress& address) = 0;
55 
56   /** Disconnect from Hearing Aid */
57   virtual void Disconnect(const RawAddress& address) = 0;
58 
59   /** Add a hearing aid device to acceptlist */
60   virtual void AddToAcceptlist(const RawAddress& address) = 0;
61 
62   /** Set the volume */
63   virtual void SetVolume(int8_t volume) = 0;
64 
65   /** Closes the interface. */
66   virtual void Cleanup(void) = 0;
67 
68   /* Called when Hearing Aid is unbonded. */
69   virtual void RemoveDevice(const RawAddress& address) = 0;
70 };
71 
72 }  // namespace hearing_aid
73 }  // namespace bluetooth
74 
75 #endif /* ANDROID_INCLUDE_BT_HEARING_AID_H */
76