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