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 /******************************************************************************* 30 * Functions 31 ******************************************************************************/ 32 33 /******************************************************************************* 34 * 35 * Function btif_storage_add_hid_device_info 36 * 37 * Description BTIF storage API - Adds the hid information of bonded hid 38 * devices-to NVRAM 39 * 40 * Returns BT_STATUS_SUCCESS if the store was successful, 41 * BT_STATUS_FAIL otherwise 42 * 43 ******************************************************************************/ 44 45 bt_status_t btif_storage_add_hid_device_info(const tAclLinkSpec& link_spec, uint16_t attr_mask, 46 uint8_t sub_class, uint8_t app_id, uint16_t vendor_id, 47 uint16_t product_id, uint16_t version, 48 uint8_t ctry_code, uint16_t ssr_max_latency, 49 uint16_t ssr_min_tout, uint16_t dl_len, 50 uint8_t* dsc_list); 51 52 /******************************************************************************* 53 * 54 * Function btif_storage_load_bonded_hid_info 55 * 56 * Description BTIF storage API - Loads hid info for all the bonded devices 57 * from NVRAM and adds those devices to the BTA_HH. 58 * 59 * Returns BT_STATUS_SUCCESS if successful, BT_STATUS_FAIL otherwise 60 * 61 ******************************************************************************/ 62 bt_status_t btif_storage_load_bonded_hid_info(void); 63 64 /******************************************************************************* 65 * 66 * Function btif_storage_remove_hid_info 67 * 68 * Description BTIF storage API - Deletes the bonded hid device info from 69 * NVRAM 70 * 71 * Returns BT_STATUS_SUCCESS if the deletion was successful, 72 * BT_STATUS_FAIL otherwise 73 * 74 ******************************************************************************/ 75 bt_status_t btif_storage_remove_hid_info(const tAclLinkSpec& link_spec); 76 77 /** Returns all bonded LE hid devices + their address types. */ 78 std::vector<std::pair<RawAddress, uint8_t>> btif_storage_get_le_hid_devices(void); 79 80 /** Returns all bonded Classic HID devices capable of waking the system from 81 * system suspend (i.e. Keyboards and Pointing devices). 82 */ 83 std::vector<RawAddress> btif_storage_get_wake_capable_classic_hid_devices(void); 84 85 /** Loads information about bonded hearing aid devices */ 86 void btif_storage_load_bonded_hearing_aids(); 87 88 /** Deletes the bonded hearing aid device info from NVRAM */ 89 void btif_storage_remove_hearing_aid(const RawAddress& address); 90 91 /** Set/Unset the hearing aid device HEARING_AID_IS_ACCEPTLISTED flag. */ 92 void btif_storage_set_hearing_aid_acceptlist(const RawAddress& address, bool add_to_acceptlist); 93 94 /** Get the hearing aid device properties. */ 95 bool btif_storage_get_hearing_aid_prop(const RawAddress& address, uint8_t* capabilities, 96 uint64_t* hi_sync_id, uint16_t* render_delay, 97 uint16_t* preparation_delay, uint16_t* codecs); 98 99 /** Store Le Audio device autoconnect flag */ 100 void btif_storage_set_leaudio_autoconnect(const RawAddress& addr, bool autoconnect); 101 102 /** Store PACs information */ 103 void btif_storage_leaudio_update_pacs_bin(const RawAddress& addr); 104 105 /** Store ASEs information */ 106 void btif_storage_leaudio_update_ase_bin(const RawAddress& addr); 107 108 /** Store Handles information */ 109 void btif_storage_leaudio_update_handles_bin(const RawAddress& addr); 110 111 /** Store Le Audio device audio locations */ 112 void btif_storage_set_leaudio_audio_location(const RawAddress& addr, uint32_t sink_location, 113 uint32_t source_location); 114 115 /** Store Le Audio device context types */ 116 void btif_storage_set_leaudio_supported_context_types(const RawAddress& addr, 117 uint16_t sink_supported_context_type, 118 uint16_t source_supported_context_type); 119 120 /** Remove Le Audio device service data */ 121 void btif_storage_leaudio_clear_service_data(const RawAddress& address); 122 123 /** Remove Le Audio device from the storage */ 124 void btif_storage_remove_leaudio(const RawAddress& address); 125 126 /** Load bonded Le Audio devices */ 127 void btif_storage_load_bonded_leaudio(void); 128 129 /** Loads information about bonded HAS devices */ 130 void btif_storage_load_bonded_leaudio_has_devices(void); 131 132 /** Deletes the bonded HAS device info from NVRAM */ 133 void btif_storage_remove_leaudio_has(const RawAddress& address); 134 135 /** Set/Unset the HAS device acceptlist flag. */ 136 void btif_storage_set_leaudio_has_acceptlist(const RawAddress& address, bool add_to_acceptlist); 137 138 void btif_storage_add_groups(const RawAddress& addr); 139 void btif_storage_load_bonded_groups(void); 140 void btif_storage_remove_groups(const RawAddress& address); 141 142 void btif_storage_set_csis_autoconnect(const RawAddress& addr, bool autoconnect); 143 void btif_storage_update_csis_info(const RawAddress& addr); 144 void btif_storage_load_bonded_csis_devices(); 145 void btif_storage_remove_csis_device(const RawAddress& address); 146 147 void btif_storage_load_bonded_volume_control_devices(void); 148 /******************************************************************************* 149 * Function btif_storage_load_hidd 150 * 151 * Description Loads hidd bonded device and "plugs" it into hidd 152 * 153 * Returns BT_STATUS_SUCCESS if successful, BT_STATUS_FAIL otherwise 154 * 155 ******************************************************************************/ 156 bt_status_t btif_storage_load_hidd(void); 157 158 /******************************************************************************* 159 * 160 * Function btif_storage_set_hidd 161 * 162 * Description Stores hidd bonded device info in nvram. 163 * 164 * Returns BT_STATUS_SUCCESS 165 * 166 ******************************************************************************/ 167 168 bt_status_t btif_storage_set_hidd(const RawAddress& remote_bd_addr); 169 170 /******************************************************************************* 171 * 172 * Function btif_storage_remove_hidd 173 * 174 * Description Removes hidd bonded device info from nvram 175 * 176 * Returns BT_STATUS_SUCCESS 177 * 178 ******************************************************************************/ 179 180 bt_status_t btif_storage_remove_hidd(RawAddress* remote_bd_addr); 181 182 /******************************************************************************* 183 * 184 *Function : btif_storage_set_pce_profile_version 185 * 186 * Description : 187 * This function store remote PCE profile version in config file 188 * 189 ******************************************************************************/ 190 191 void btif_storage_set_pce_profile_version(const RawAddress& remote_bd_addr, 192 uint16_t peer_pce_version); 193 194 /******************************************************************************* 195 * 196 * Function btif_storage_is_pce_version_102 197 * 198 * Description checks if remote supports PBAP 1.2 199 * 200 * Returns true/false depending on remote PBAP version support found in 201 *file. 202 * 203 ******************************************************************************/ 204 205 bool btif_storage_is_pce_version_102(const RawAddress& remote_bd_addr); 206