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