diff options
author | Ćukasz Rymanowski <lukasz.rymanowski@codecoup.pl> | 2020-05-11 16:30:33 +0200 |
---|---|---|
committer | Jakub Pawlowski <jpawlowski@google.com> | 2021-07-06 13:02:21 +0200 |
commit | ff36b218e981665605a5e8081461d1ffe1426326 (patch) | |
tree | 76e845cca03c3c7a53c3663425019ce22c5a1a16 | |
parent | 3dc8ae94b4be512527e3b287a63642844f38d840 (diff) | |
download | bt-ff36b218e981665605a5e8081461d1ffe1426326.tar.gz |
btif_storage: Add way to store GATT server supported features
This is needed for storing Enhanced ATT support.
Tag: #feature
Bug: 159786353
Sponsor: jpawlowski@
Test: compile & manual testing
Bug: 191313013
Merged-In: Ic37b668b91ab6c830d780f70db703a5d9be11677
Change-Id: Ic37b668b91ab6c830d780f70db703a5d9be11677
-rw-r--r-- | btif/include/btif_storage.h | 6 | ||||
-rw-r--r-- | btif/src/btif_storage.cc | 32 | ||||
-rw-r--r-- | test/mock/mock_btif_storage.cc | 7 |
3 files changed, 45 insertions, 0 deletions
diff --git a/btif/include/btif_storage.h b/btif/include/btif_storage.h index f19733e0d..7e970ec4d 100644 --- a/btif/include/btif_storage.h +++ b/btif/include/btif_storage.h @@ -242,6 +242,12 @@ uint8_t btif_storage_get_gatt_cl_supp_feat(const RawAddress& bd_addr); /** Remove client supported features */ void btif_storage_remove_gatt_cl_supp_feat(const RawAddress& bd_addr); +/** Stores information about GATT server supported features */ +void btif_storage_set_gatt_sr_supp_feat(const RawAddress& addr, uint8_t feat); + +/** Gets information about GATT server supported features */ +uint8_t btif_storage_get_sr_supp_feat(const RawAddress& bd_addr); + /** Store last server database hash for remote client */ void btif_storage_set_gatt_cl_db_hash(const RawAddress& bd_addr, Octet16 hash); diff --git a/btif/src/btif_storage.cc b/btif/src/btif_storage.cc index 90234bc20..8a20518b5 100644 --- a/btif/src/btif_storage.cc +++ b/btif/src/btif_storage.cc @@ -83,6 +83,7 @@ using bluetooth::Uuid; #define BTIF_STORAGE_KEY_ADAPTER_DISC_TIMEOUT "DiscoveryTimeout" #define BTIF_STORAGE_KEY_GATT_CLIENT_SUPPORTED "GattClientSupportedFeatures" #define BTIF_STORAGE_KEY_GATT_CLIENT_DB_HASH "GattClientDatabaseHash" +#define BTIF_STORAGE_KEY_GATT_SERVER_SUPPORTED "GattServerSupportedFeatures" /* This is a local property to add a device found */ #define BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP 0xFF @@ -855,6 +856,9 @@ bt_status_t btif_storage_remove_bonded_device( if (btif_config_exist(bdstr, BTIF_STORAGE_KEY_GATT_CLIENT_DB_HASH)) { ret &= btif_config_remove(bdstr, BTIF_STORAGE_KEY_GATT_CLIENT_DB_HASH); } + if (btif_config_exist(bdstr, BTIF_STORAGE_KEY_GATT_SERVER_SUPPORTED)) { + ret &= btif_config_remove(bdstr, BTIF_STORAGE_KEY_GATT_SERVER_SUPPORTED); + } /* write bonded info immediately */ btif_config_flush(); @@ -1660,6 +1664,34 @@ bool btif_storage_get_hearing_aid_prop( return true; } +/** Stores information about GATT server supported features */ +void btif_storage_set_gatt_sr_supp_feat(const RawAddress& addr, uint8_t feat) { + do_in_jni_thread( + FROM_HERE, Bind( + [](const RawAddress& addr, uint8_t feat) { + std::string bdstr = addr.ToString(); + VLOG(2) + << "GATT server supported features for: " << bdstr + << " features: " << +feat; + btif_config_set_int( + bdstr, BTIF_STORAGE_KEY_GATT_SERVER_SUPPORTED, feat); + btif_config_save(); + }, + addr, feat)); +} + +/** Gets information about GATT server supported features */ +uint8_t btif_storage_get_sr_supp_feat(const RawAddress& bd_addr) { + auto name = bd_addr.ToString(); + + int value = 0; + btif_config_get_int(name, BTIF_STORAGE_KEY_GATT_SERVER_SUPPORTED, &value); + BTIF_TRACE_DEBUG("Remote device: %s GATT server supported features 0x%02x", + name.c_str(), value); + + return value; +} + /******************************************************************************* * * Function btif_storage_is_restricted_device diff --git a/test/mock/mock_btif_storage.cc b/test/mock/mock_btif_storage.cc index 8c09ad9ac..4a700dbd1 100644 --- a/test/mock/mock_btif_storage.cc +++ b/test/mock/mock_btif_storage.cc @@ -215,3 +215,10 @@ void btif_storage_set_hearing_aid_acceptlist(const RawAddress& address, bool add_to_acceptlist) { mock_function_count_map[__func__]++; } +void btif_storage_set_gatt_sr_supp_feat(const RawAddress& addr, uint8_t feat) { + mock_function_count_map[__func__]++; +} +uint8_t btif_storage_get_sr_supp_feat(const RawAddress& bd_addr) { + mock_function_count_map[__func__]++; + return 0; +} |