• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2009-2012 Broadcom Corporation
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 #ifndef BTIF_STORAGE_H
20 #define BTIF_STORAGE_H
21 
22 #include "data_types.h"
23 #include "bt_types.h"
24 
25 #include <utils/Log.h>
26 
27 /*******************************************************************************
28 **  Constants & Macros
29 ********************************************************************************/
30 #define BTIF_STORAGE_FILL_PROPERTY(p_prop, t, l, p_v) \
31          (p_prop)->type = t;(p_prop)->len = l; (p_prop)->val = (p_v);
32 
33 
34 /*******************************************************************************
35 **  Functions
36 ********************************************************************************/
37 
38 /*******************************************************************************
39 **
40 ** Function         btif_storage_get_adapter_property
41 **
42 ** Description      BTIF storage API - Fetches the adapter property->type
43 **                  from NVRAM and fills property->val.
44 **                  Caller should provide memory for property->val and
45 **                  set the property->val
46 **
47 ** Returns          BT_STATUS_SUCCESS if the fetch was successful,
48 **                  BT_STATUS_FAIL otherwise
49 **
50 *******************************************************************************/
51 bt_status_t btif_storage_get_adapter_property(bt_property_t *property);
52 
53 /*******************************************************************************
54 **
55 ** Function         btif_storage_set_adapter_property
56 **
57 ** Description      BTIF storage API - Stores the adapter property
58 **                  to NVRAM
59 **
60 ** Returns          BT_STATUS_SUCCESS if the store was successful,
61 **                  BT_STATUS_FAIL otherwise
62 **
63 *******************************************************************************/
64 bt_status_t btif_storage_set_adapter_property(bt_property_t *property);
65 
66 /*******************************************************************************
67 **
68 ** Function         btif_storage_get_remote_device_property
69 **
70 ** Description      BTIF storage API - Fetches the remote device property->type
71 **                  from NVRAM and fills property->val.
72 **                  Caller should provide memory for property->val and
73 **                  set the property->val
74 **
75 ** Returns          BT_STATUS_SUCCESS if the fetch was successful,
76 **                  BT_STATUS_FAIL otherwise
77 **
78 *******************************************************************************/
79 bt_status_t btif_storage_get_remote_device_property(bt_bdaddr_t *remote_bd_addr,
80                                                     bt_property_t *property);
81 
82 /*******************************************************************************
83 **
84 ** Function         btif_storage_set_remote_device_property
85 **
86 ** Description      BTIF storage API - Stores the remote device property
87 **                  to NVRAM
88 **
89 ** Returns          BT_STATUS_SUCCESS if the store was successful,
90 **                  BT_STATUS_FAIL otherwise
91 **
92 *******************************************************************************/
93 bt_status_t btif_storage_set_remote_device_property(bt_bdaddr_t *remote_bd_addr,
94                                                     bt_property_t *property);
95 
96 /*******************************************************************************
97 **
98 ** Function         btif_storage_add_remote_device
99 **
100 ** Description      BTIF storage API - Adds a newly discovered device to NVRAM
101 **                  along with the timestamp. Also, stores the various
102 **                  properties - RSSI, BDADDR, NAME (if found in EIR)
103 **
104 ** Returns          BT_STATUS_SUCCESS if the store was successful,
105 **                  BT_STATUS_FAIL otherwise
106 **
107 *******************************************************************************/
108 bt_status_t btif_storage_add_remote_device(bt_bdaddr_t *remote_bdaddr,
109                                            uint32_t num_properties,
110                                            bt_property_t *properties);
111 
112 /*******************************************************************************
113 **
114 ** Function         btif_storage_add_bonded_device
115 **
116 ** Description      BTIF storage API - Adds the newly bonded device to NVRAM
117 **                  along with the link-key, Key type and Pin key length
118 **
119 ** Returns          BT_STATUS_SUCCESS if the store was successful,
120 **                  BT_STATUS_FAIL otherwise
121 **
122 *******************************************************************************/
123 bt_status_t btif_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr,
124                                            LINK_KEY link_key,
125                                            uint8_t key_type,
126                                            uint8_t pin_length);
127 
128 /*******************************************************************************
129 **
130 ** Function         btif_storage_remove_bonded_device
131 **
132 ** Description      BTIF storage API - Deletes the bonded device from NVRAM
133 **
134 ** Returns          BT_STATUS_SUCCESS if the deletion was successful,
135 **                  BT_STATUS_FAIL otherwise
136 **
137 *******************************************************************************/
138 bt_status_t btif_storage_remove_bonded_device(bt_bdaddr_t *remote_bd_addr);
139 
140 /*******************************************************************************
141 **
142 ** Function         btif_storage_remove_bonded_device
143 **
144 ** Description      BTIF storage API - Deletes the bonded device from NVRAM
145 **
146 ** Returns          BT_STATUS_SUCCESS if the deletion was successful,
147 **                  BT_STATUS_FAIL otherwise
148 **
149 *******************************************************************************/
150 bt_status_t btif_storage_load_bonded_devices(void);
151 
152 /*******************************************************************************
153 **
154 ** Function         btif_storage_read_hl_apps_cb
155 **
156 ** Description      BTIF storage API - Read HL application control block from NVRAM
157 **
158 ** Returns          BT_STATUS_SUCCESS if the operation was successful,
159 **                  BT_STATUS_FAIL otherwise
160 **
161 *******************************************************************************/
162 bt_status_t btif_storage_read_hl_apps_cb(char *value, int value_size);
163 
164 /*******************************************************************************
165 **
166 ** Function         btif_storage_write_hl_apps_cb
167 **
168 ** Description      BTIF storage API - Write HL application control block to NVRAM
169 **
170 ** Returns          BT_STATUS_SUCCESS if the operation was successful,
171 **                  BT_STATUS_FAIL otherwise
172 **
173 *******************************************************************************/
174 bt_status_t btif_storage_write_hl_apps_cb(char *value, int value_size);
175 
176 /*******************************************************************************
177 **
178 ** Function         btif_storage_read_hl_apps_cb
179 **
180 ** Description      BTIF storage API - Read HL application configuration from NVRAM
181 **
182 ** Returns          BT_STATUS_SUCCESS if the operation was successful,
183 **                  BT_STATUS_FAIL otherwise
184 **
185 *******************************************************************************/
186 bt_status_t btif_storage_read_hl_app_data(UINT8 app_idx, char *value, int value_size);
187 
188 /*******************************************************************************
189 **
190 ** Function         btif_storage_write_hl_app_data
191 **
192 ** Description      BTIF storage API - Write HL application configuration to NVRAM
193 **
194 ** Returns          BT_STATUS_SUCCESS if the operation was successful,
195 **                  BT_STATUS_FAIL otherwise
196 **
197 *******************************************************************************/
198 bt_status_t btif_storage_write_hl_app_data(UINT8 app_idx, char *value, int value_size);
199 
200 /*******************************************************************************
201 **
202 ** Function         btif_storage_read_hl_mdl_data
203 **
204 ** Description      BTIF storage API - Read HL application MDL configuration from NVRAM
205 **
206 ** Returns          BT_STATUS_SUCCESS if the operation was successful,
207 **                  BT_STATUS_FAIL otherwise
208 **
209 *******************************************************************************/
210 bt_status_t btif_storage_read_hl_mdl_data(UINT8 app_idx, char *value, int value_size);
211 
212 /*******************************************************************************
213 **
214 ** Function         btif_storage_write_hl_mdl_data
215 **
216 ** Description      BTIF storage API - Write HL application MDL configuration from NVRAM
217 **
218 ** Returns          BT_STATUS_SUCCESS if the operation was successful,
219 **                  BT_STATUS_FAIL otherwise
220 **
221 *******************************************************************************/
222 bt_status_t btif_storage_write_hl_mdl_data(UINT8 app_idx, char *value, int value_size);
223 
224 /*******************************************************************************
225 **
226 ** Function         btif_storage_add_hid_device_info
227 **
228 ** Description      BTIF storage API - Adds the hid information of bonded hid devices-to NVRAM
229 **
230 ** Returns          BT_STATUS_SUCCESS if the store was successful,
231 **                  BT_STATUS_FAIL otherwise
232 **
233 *******************************************************************************/
234 bt_status_t btif_storage_add_hid_device_info(bt_bdaddr_t *remote_bd_addr,
235                                                     UINT16 attr_mask, UINT8 sub_class,
236                                                     UINT8 app_id, UINT16 vendor_id,
237                                                     UINT16 product_id, UINT16 version,
238                                                     UINT8 ctry_code, UINT16 dl_len,
239                                                     UINT8 *dsc_list);
240 
241 /*******************************************************************************
242 **
243 ** Function         btif_storage_load_bonded_hid_info
244 **
245 ** Description      BTIF storage API - Loads hid info for all the bonded devices
246 **                  from NVRAM and adds those devices  to the BTA_HH.
247 **
248 ** Returns          BT_STATUS_SUCCESS if successful, BT_STATUS_FAIL otherwise
249 **
250 *******************************************************************************/
251 bt_status_t btif_storage_load_bonded_hid_info(void);
252 
253 /*******************************************************************************
254 **
255 ** Function         btif_storage_remove_hid_info
256 **
257 ** Description      BTIF storage API - Deletes the bonded hid device info from NVRAM
258 **
259 ** Returns          BT_STATUS_SUCCESS if the deletion was successful,
260 **                  BT_STATUS_FAIL otherwise
261 **
262 *******************************************************************************/
263 bt_status_t btif_storage_remove_hid_info(bt_bdaddr_t *remote_bd_addr);
264 
265 /*******************************************************************************
266 **
267 ** Function         btif_storage_load_autopair_device_list
268 **
269 ** Description      BTIF storage API - Populates auto pair device list
270 **
271 ** Returns          BT_STATUS_SUCCESS if the auto pair blacklist is successfully populated
272 **                  BT_STATUS_FAIL otherwise
273 **
274 *******************************************************************************/
275 bt_status_t btif_storage_load_autopair_device_list();
276 
277 /*******************************************************************************
278 **
279 ** Function         btif_storage_is_device_autopair_blacklisted
280 **
281 ** Description      BTIF storage API  Checks if the given device is blacklisted for auto pairing
282 **
283 ** Returns          TRUE if the device is found in the auto pair blacklist
284 **                  FALSE otherwise
285 **
286 *******************************************************************************/
287 BOOLEAN  btif_storage_is_device_autopair_blacklisted(bt_bdaddr_t *remote_dev_addr);
288 
289 /*******************************************************************************
290 **
291 ** Function         btif_storage_add_device_to_autopair_blacklist
292 **
293 ** Description      BTIF storage API - Add a remote device to the auto pairing blacklist
294 **
295 ** Returns          BT_STATUS_SUCCESS if the device is successfully added to the auto pair blacklist
296 **                  BT_STATUS_FAIL otherwise
297 **
298 *******************************************************************************/
299 bt_status_t btif_storage_add_device_to_autopair_blacklist(bt_bdaddr_t *remote_dev_addr);
300 
301 /*******************************************************************************
302 **
303 ** Function         btif_storage_is_fixed_pin_zeros_keyboard
304 **
305 ** Description      BTIF storage API - checks if this device has fixed PIN key device list
306 **
307 ** Returns          TRUE   if the device is found in the fixed pin keyboard device list
308 **                  FALSE otherwise
309 **
310 *******************************************************************************/
311 BOOLEAN btif_storage_is_fixed_pin_zeros_keyboard(bt_bdaddr_t *remote_dev_addr);
312 
313 #endif /* BTIF_STORAGE_H */
314