blob: 2bdc96f737e43f4a42520337d53eece7addfd5c6 [file] [log] [blame]
The Android Open Source Project5738f832012-12-12 16:00:35 -08001/******************************************************************************
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
Marie Janssen49a86702015-07-08 11:48:57 -070022#include <hardware/bluetooth.h>
23
24#include "bt_target.h"
The Android Open Source Project5738f832012-12-12 16:00:35 -080025#include "bt_types.h"
26
The Android Open Source Project5738f832012-12-12 16:00:35 -080027/*******************************************************************************
Myles Watson6bd442f2016-10-19 09:50:22 -070028 * Constants & Macros
29 *******************************************************************************/
The Android Open Source Project5738f832012-12-12 16:00:35 -080030#define BTIF_STORAGE_FILL_PROPERTY(p_prop, t, l, p_v) \
Myles Watson40cde562016-10-21 09:39:13 -070031 do { \
32 (p_prop)->type = (t); \
33 (p_prop)->len = (l); \
34 (p_prop)->val = (p_v); \
35 } while (0)
The Android Open Source Project5738f832012-12-12 16:00:35 -080036
The Android Open Source Project5738f832012-12-12 16:00:35 -080037/*******************************************************************************
Myles Watson6bd442f2016-10-19 09:50:22 -070038 * Functions
39 *******************************************************************************/
The Android Open Source Project5738f832012-12-12 16:00:35 -080040
41/*******************************************************************************
Myles Watson6bd442f2016-10-19 09:50:22 -070042 *
43 * Function btif_storage_get_adapter_property
44 *
45 * Description BTIF storage API - Fetches the adapter property->type
46 * from NVRAM and fills property->val.
47 * Caller should provide memory for property->val and
48 * set the property->val
49 *
50 * Returns BT_STATUS_SUCCESS if the fetch was successful,
51 * BT_STATUS_FAIL otherwise
52 *
53 ******************************************************************************/
54bt_status_t btif_storage_get_adapter_property(bt_property_t* property);
The Android Open Source Project5738f832012-12-12 16:00:35 -080055
56/*******************************************************************************
Myles Watson6bd442f2016-10-19 09:50:22 -070057 *
58 * Function btif_storage_set_adapter_property
59 *
60 * Description BTIF storage API - Stores the adapter property
61 * to NVRAM
62 *
63 * Returns BT_STATUS_SUCCESS if the store was successful,
64 * BT_STATUS_FAIL otherwise
65 *
66 ******************************************************************************/
67bt_status_t btif_storage_set_adapter_property(bt_property_t* property);
The Android Open Source Project5738f832012-12-12 16:00:35 -080068
69/*******************************************************************************
Myles Watson6bd442f2016-10-19 09:50:22 -070070 *
71 * Function btif_storage_get_remote_device_property
72 *
73 * Description BTIF storage API - Fetches the remote device property->type
74 * from NVRAM and fills property->val.
75 * Caller should provide memory for property->val and
76 * set the property->val
77 *
78 * Returns BT_STATUS_SUCCESS if the fetch was successful,
79 * BT_STATUS_FAIL otherwise
80 *
81 ******************************************************************************/
82bt_status_t btif_storage_get_remote_device_property(bt_bdaddr_t* remote_bd_addr,
83 bt_property_t* property);
The Android Open Source Project5738f832012-12-12 16:00:35 -080084
85/*******************************************************************************
Myles Watson6bd442f2016-10-19 09:50:22 -070086 *
87 * Function btif_storage_set_remote_device_property
88 *
89 * Description BTIF storage API - Stores the remote device property
90 * to NVRAM
91 *
92 * Returns BT_STATUS_SUCCESS if the store was successful,
93 * BT_STATUS_FAIL otherwise
94 *
95 ******************************************************************************/
96bt_status_t btif_storage_set_remote_device_property(bt_bdaddr_t* remote_bd_addr,
97 bt_property_t* property);
The Android Open Source Project5738f832012-12-12 16:00:35 -080098
99/*******************************************************************************
Myles Watson6bd442f2016-10-19 09:50:22 -0700100 *
101 * Function btif_storage_add_remote_device
102 *
103 * Description BTIF storage API - Adds a newly discovered device to
104 * track along with the timestamp. Also, stores the various
105 * properties - RSSI, BDADDR, NAME (if found in EIR)
106 *
107 * Returns BT_STATUS_SUCCESS if successful,
108 * BT_STATUS_FAIL otherwise
109 *
110 ******************************************************************************/
111bt_status_t btif_storage_add_remote_device(bt_bdaddr_t* remote_bd_addr,
The Android Open Source Project5738f832012-12-12 16:00:35 -0800112 uint32_t num_properties,
Myles Watson6bd442f2016-10-19 09:50:22 -0700113 bt_property_t* properties);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800114
115/*******************************************************************************
Myles Watson6bd442f2016-10-19 09:50:22 -0700116 *
117 * Function btif_storage_add_bonded_device
118 *
119 * Description BTIF storage API - Adds the newly bonded device to NVRAM
120 * along with the link-key, Key type and Pin key length
121 *
122 * Returns BT_STATUS_SUCCESS if the store was successful,
123 * BT_STATUS_FAIL otherwise
124 *
125 ******************************************************************************/
126bt_status_t btif_storage_add_bonded_device(bt_bdaddr_t* remote_bd_addr,
127 LINK_KEY link_key, uint8_t key_type,
The Android Open Source Project5738f832012-12-12 16:00:35 -0800128 uint8_t pin_length);
129
130/*******************************************************************************
Myles Watson6bd442f2016-10-19 09:50:22 -0700131 *
132 * Function btif_storage_remove_bonded_device
133 *
134 * Description BTIF storage API - Deletes the bonded device from NVRAM
135 *
136 * Returns BT_STATUS_SUCCESS if the deletion was successful,
137 * BT_STATUS_FAIL otherwise
138 *
139 ******************************************************************************/
140bt_status_t btif_storage_remove_bonded_device(bt_bdaddr_t* remote_bd_addr);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800141
142/*******************************************************************************
Myles Watson6bd442f2016-10-19 09:50:22 -0700143 *
144 * Function btif_storage_remove_bonded_device
145 *
146 * Description BTIF storage API - Deletes the bonded device from NVRAM
147 *
148 * Returns BT_STATUS_SUCCESS if the deletion was successful,
149 * BT_STATUS_FAIL otherwise
150 *
151 ******************************************************************************/
The Android Open Source Project5738f832012-12-12 16:00:35 -0800152bt_status_t btif_storage_load_bonded_devices(void);
153
154/*******************************************************************************
Myles Watson6bd442f2016-10-19 09:50:22 -0700155 *
156 * Function btif_storage_add_hid_device_info
157 *
158 * Description BTIF storage API - Adds the hid information of bonded hid
Myles Watsonf4548162016-10-19 09:53:56 -0700159 * devices-to NVRAM
Myles Watson6bd442f2016-10-19 09:50:22 -0700160 *
161 * Returns BT_STATUS_SUCCESS if the store was successful,
162 * BT_STATUS_FAIL otherwise
163 *
164 ******************************************************************************/
Ganesh Ganapathi Battaead3cde2013-02-05 15:22:31 -0800165
Myles Watson6bd442f2016-10-19 09:50:22 -0700166bt_status_t btif_storage_add_hid_device_info(
167 bt_bdaddr_t* remote_bd_addr, uint16_t attr_mask, uint8_t sub_class,
168 uint8_t app_id, uint16_t vendor_id, uint16_t product_id, uint16_t version,
169 uint8_t ctry_code, uint16_t ssr_max_latency, uint16_t ssr_min_tout,
170 uint16_t dl_len, uint8_t* dsc_list);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800171
172/*******************************************************************************
Myles Watson6bd442f2016-10-19 09:50:22 -0700173 *
174 * Function btif_storage_load_bonded_hid_info
175 *
176 * Description BTIF storage API - Loads hid info for all the bonded devices
Myles Watsonf4548162016-10-19 09:53:56 -0700177 * from NVRAM and adds those devices to the BTA_HH.
Myles Watson6bd442f2016-10-19 09:50:22 -0700178 *
179 * Returns BT_STATUS_SUCCESS if successful, BT_STATUS_FAIL otherwise
180 *
181 ******************************************************************************/
The Android Open Source Project5738f832012-12-12 16:00:35 -0800182bt_status_t btif_storage_load_bonded_hid_info(void);
183
184/*******************************************************************************
Myles Watson6bd442f2016-10-19 09:50:22 -0700185 *
186 * Function btif_storage_remove_hid_info
187 *
188 * Description BTIF storage API - Deletes the bonded hid device info from
Myles Watsonf4548162016-10-19 09:53:56 -0700189 * NVRAM
Myles Watson6bd442f2016-10-19 09:50:22 -0700190 *
191 * Returns BT_STATUS_SUCCESS if the deletion was successful,
192 * BT_STATUS_FAIL otherwise
193 *
194 ******************************************************************************/
195bt_status_t btif_storage_remove_hid_info(bt_bdaddr_t* remote_bd_addr);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800196
Ajay Panicker7b266be2016-03-17 17:09:24 -0700197/*******************************************************************************
Myles Watson6bd442f2016-10-19 09:50:22 -0700198 *
199 * Function btif_storage_is_retricted_device
200 *
201 * Description BTIF storage API - checks if this device is a restricted
Myles Watsonf4548162016-10-19 09:53:56 -0700202 * device
Myles Watson6bd442f2016-10-19 09:50:22 -0700203 *
204 * Returns true if the device is labled as restricted
205 * false otherwise
206 *
207 ******************************************************************************/
208bool btif_storage_is_restricted_device(const bt_bdaddr_t* remote_bd_addr);
Ajay Panicker7b266be2016-03-17 17:09:24 -0700209
Myles Watson6bd442f2016-10-19 09:50:22 -0700210bt_status_t btif_storage_add_ble_bonding_key(bt_bdaddr_t* remote_bd_addr,
211 char* key, uint8_t key_type,
212 uint8_t key_length);
213bt_status_t btif_storage_get_ble_bonding_key(bt_bdaddr_t* remote_bd_addr,
214 uint8_t key_type, char* key_value,
Ganesh Ganapathi Battaead3cde2013-02-05 15:22:31 -0800215 int key_length);
216
Myles Watson6bd442f2016-10-19 09:50:22 -0700217bt_status_t btif_storage_add_ble_local_key(char* key, uint8_t key_type,
Ganesh Ganapathi Battaead3cde2013-02-05 15:22:31 -0800218 uint8_t key_length);
Myles Watson6bd442f2016-10-19 09:50:22 -0700219bt_status_t btif_storage_remove_ble_bonding_keys(bt_bdaddr_t* remote_bd_addr);
Ganesh Ganapathi Battaead3cde2013-02-05 15:22:31 -0800220bt_status_t btif_storage_remove_ble_local_keys(void);
Myles Watson6bd442f2016-10-19 09:50:22 -0700221bt_status_t btif_storage_get_ble_local_key(uint8_t key_type, char* key_value,
Ganesh Ganapathi Battaead3cde2013-02-05 15:22:31 -0800222 int key_len);
223
Myles Watson6bd442f2016-10-19 09:50:22 -0700224bt_status_t btif_storage_get_remote_addr_type(bt_bdaddr_t* remote_bd_addr,
225 int* addr_type);
Ganesh Ganapathi Battaead3cde2013-02-05 15:22:31 -0800226
Myles Watson6bd442f2016-10-19 09:50:22 -0700227bt_status_t btif_storage_set_remote_addr_type(bt_bdaddr_t* remote_bd_addr,
Marie Janssenb7f64bc2016-06-22 12:52:19 -0700228 uint8_t addr_type);
Ganesh Ganapathi Battaead3cde2013-02-05 15:22:31 -0800229
Andre Eisenbach16856642016-01-29 16:11:13 -0800230/******************************************************************************
231 * Exported for unit tests
232 *****************************************************************************/
Myles Watson6bd442f2016-10-19 09:50:22 -0700233size_t btif_split_uuids_string(const char* str, bt_uuid_t* p_uuid,
234 size_t max_uuids);
Andre Eisenbach16856642016-01-29 16:11:13 -0800235
The Android Open Source Project5738f832012-12-12 16:00:35 -0800236#endif /* BTIF_STORAGE_H */