• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2022 The Android Open Source Project
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 #pragma once
20 
21 #include <hardware/bluetooth.h>
22 
23 #include <vector>
24 
25 #include "types/ble_address_with_type.h"
26 #include "types/bluetooth/uuid.h"
27 #include "types/raw_address.h"
28 
29 struct HearingDevice;
30 
31 void btif_storage_add_hearing_aid(const HearingDevice& dev_info);
32 
33 void btif_storage_add_leaudio_has_device(const RawAddress& address,
34                                          std::vector<uint8_t> presets_bin, uint8_t features,
35                                          uint8_t active_preset);
36 bool btif_storage_get_leaudio_has_presets(const RawAddress& address,
37                                           std::vector<uint8_t>& presets_bin,
38                                           uint8_t& active_preset);
39 void btif_storage_set_leaudio_has_presets(const RawAddress& address,
40                                           std::vector<uint8_t> presets_bin);
41 void btif_storage_set_leaudio_has_active_preset(const RawAddress& address, uint8_t active_preset);
42 bool btif_storage_get_leaudio_has_features(const RawAddress& address, uint8_t& features);
43 void btif_storage_set_leaudio_has_features(const RawAddress& address, uint8_t features);
44 
45 /*******************************************************************************
46  *
47  * Function         btif_storage_add_hid_device_info
48  *
49  * Description      BTIF storage API - Adds the hid information of bonded hid
50  *                  devices-to NVRAM
51  *
52  * Returns          BT_STATUS_SUCCESS if the store was successful,
53  *                  BT_STATUS_FAIL otherwise
54  *
55  ******************************************************************************/
56 
57 bt_status_t btif_storage_add_hid_device_info(const tAclLinkSpec& link_spec, uint16_t attr_mask,
58                                              uint8_t sub_class, uint8_t app_id, uint16_t vendor_id,
59                                              uint16_t product_id, uint16_t version,
60                                              uint8_t ctry_code, uint16_t ssr_max_latency,
61                                              uint16_t ssr_min_tout, uint16_t dl_len,
62                                              uint8_t* dsc_list);
63 
64 /*******************************************************************************
65  *
66  * Function         btif_storage_load_bonded_hid_info
67  *
68  * Description      BTIF storage API - Loads hid info for all the bonded devices
69  *                  from NVRAM and adds those devices  to the BTA_HH.
70  *
71  * Returns          BT_STATUS_SUCCESS if successful, BT_STATUS_FAIL otherwise
72  *
73  ******************************************************************************/
74 bt_status_t btif_storage_load_bonded_hid_info(void);
75 
76 /*******************************************************************************
77  *
78  * Function         btif_storage_remove_hid_info
79  *
80  * Description      BTIF storage API - Deletes the bonded hid device info from
81  *                  NVRAM
82  *
83  * Returns          BT_STATUS_SUCCESS if the deletion was successful,
84  *                  BT_STATUS_FAIL otherwise
85  *
86  ******************************************************************************/
87 bt_status_t btif_storage_remove_hid_info(const tAclLinkSpec& link_spec);
88 
89 /** Returns all bonded LE hid devices + their address types. */
90 std::vector<std::pair<RawAddress, uint8_t>> btif_storage_get_le_hid_devices(void);
91 
92 /** Returns all bonded Classic HID devices capable of waking the system from
93  * system suspend (i.e. Keyboards and Pointing devices).
94  */
95 std::vector<RawAddress> btif_storage_get_wake_capable_classic_hid_devices(void);
96 
97 /** Loads information about bonded hearing aid devices */
98 void btif_storage_load_bonded_hearing_aids();
99 
100 /** Deletes the bonded hearing aid device info from NVRAM */
101 void btif_storage_remove_hearing_aid(const RawAddress& address);
102 
103 /** Set/Unset the hearing aid device HEARING_AID_IS_ACCEPTLISTED flag. */
104 void btif_storage_set_hearing_aid_acceptlist(const RawAddress& address, bool add_to_acceptlist);
105 
106 /** Get the hearing aid device properties. */
107 bool btif_storage_get_hearing_aid_prop(const RawAddress& address, uint8_t* capabilities,
108                                        uint64_t* hi_sync_id, uint16_t* render_delay,
109                                        uint16_t* preparation_delay, uint16_t* codecs);
110 
111 /** Store Le Audio device autoconnect flag */
112 void btif_storage_set_leaudio_autoconnect(const RawAddress& addr, bool autoconnect);
113 
114 /** Store PACs information */
115 void btif_storage_leaudio_update_pacs_bin(const RawAddress& addr);
116 
117 /** Store GMAP information */
118 void btif_storage_leaudio_update_gmap_bin(const RawAddress& addr);
119 
120 /** Store ASEs information */
121 void btif_storage_leaudio_update_ase_bin(const RawAddress& addr);
122 
123 /** Store Handles information */
124 void btif_storage_leaudio_update_handles_bin(const RawAddress& addr);
125 
126 /** Store Le Audio device audio locations */
127 void btif_storage_set_leaudio_sink_audio_location(const RawAddress& addr, uint32_t sink_location);
128 
129 /** Store Le Audio device audio locations */
130 void btif_storage_set_leaudio_source_audio_location(const RawAddress& addr,
131                                                     uint32_t source_location);
132 
133 /** Store Le Audio device context types */
134 void btif_storage_set_leaudio_supported_context_types(const RawAddress& addr,
135                                                       uint16_t sink_supported_context_type,
136                                                       uint16_t source_supported_context_type);
137 
138 /** Remove Le Audio device service data */
139 void btif_storage_leaudio_clear_service_data(const RawAddress& address);
140 
141 /** Remove Le Audio device from the storage */
142 void btif_storage_remove_leaudio(const RawAddress& address);
143 
144 /** Load bonded Le Audio devices */
145 void btif_storage_load_bonded_leaudio(void);
146 
147 /** Loads information about bonded HAS devices */
148 void btif_storage_load_bonded_leaudio_has_devices(void);
149 
150 /** Deletes the bonded HAS device info from NVRAM */
151 void btif_storage_remove_leaudio_has(const RawAddress& address);
152 
153 /** Set/Unset the HAS device acceptlist flag. */
154 void btif_storage_set_leaudio_has_acceptlist(const RawAddress& address, bool add_to_acceptlist);
155 
156 void btif_storage_add_groups(const RawAddress& addr);
157 void btif_storage_load_bonded_groups(void);
158 void btif_storage_remove_groups(const RawAddress& address);
159 
160 void btif_storage_set_csis_autoconnect(const RawAddress& addr, bool autoconnect);
161 void btif_storage_update_csis_info(const RawAddress& addr);
162 void btif_storage_load_bonded_csis_devices();
163 void btif_storage_remove_csis_device(const RawAddress& address);
164 
165 void btif_storage_load_bonded_volume_control_devices(void);
166 /*******************************************************************************
167  * Function         btif_storage_load_hidd
168  *
169  * Description      Loads hidd bonded device and "plugs" it into hidd
170  *
171  * Returns          BT_STATUS_SUCCESS if successful, BT_STATUS_FAIL otherwise
172  *
173  ******************************************************************************/
174 bt_status_t btif_storage_load_hidd(void);
175 
176 /*******************************************************************************
177  *
178  * Function         btif_storage_set_hidd
179  *
180  * Description      Stores hidd bonded device info in nvram.
181  *
182  * Returns          BT_STATUS_SUCCESS
183  *
184  ******************************************************************************/
185 
186 bt_status_t btif_storage_set_hidd(const RawAddress& remote_bd_addr);
187 
188 /*******************************************************************************
189  *
190  * Function         btif_storage_remove_hidd
191  *
192  * Description      Removes hidd bonded device info from nvram
193  *
194  * Returns          BT_STATUS_SUCCESS
195  *
196  ******************************************************************************/
197 
198 bt_status_t btif_storage_remove_hidd(RawAddress* remote_bd_addr);
199 
200 /*******************************************************************************
201  *
202  *Function : btif_storage_set_pce_profile_version
203  *
204  * Description :
205  *    This function store remote PCE profile version in config file
206  *
207  ******************************************************************************/
208 
209 void btif_storage_set_pce_profile_version(const RawAddress& remote_bd_addr,
210                                           uint16_t peer_pce_version);
211 
212 /*******************************************************************************
213  *
214  * Function        btif_storage_is_pce_version_102
215  *
216  * Description     checks if remote supports PBAP 1.2
217  *
218  * Returns         true/false depending on remote PBAP version support found in
219  *file.
220  *
221  ******************************************************************************/
222 
223 bool btif_storage_is_pce_version_102(const RawAddress& remote_bd_addr);
224