Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ab5c8c5 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski Committed by Automerger Merge Worker
Browse files

btif_storage: Add way to store GATT server supported features am: 0b10b7db

Original change: https://googleplex-android-review.googlesource.com/c/platform/system/bt/+/15215190

Change-Id: Ia6fdbbb92a9aed73c72d2281e1a06e033342b63c
parents b1f40bc1 0b10b7db
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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);

+32 −0
Original line number Diff line number Diff line
@@ -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
+7 −0
Original line number Diff line number Diff line
@@ -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;
}