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

Commit 61743123 authored by Himanshu Rawat's avatar Himanshu Rawat
Browse files

Expose a btif storage function to read class of device

Test: mmm packages/modules/Bluetooth
Flag: EXEMPT refactor
Bug: 286334644
Change-Id: I95f3bd4fc59a5de105abc893e1daef4976154ed5
parent 135e9130
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -398,6 +398,17 @@ bt_status_t btif_storage_remove_hidd(RawAddress* remote_bd_addr);
// |BD_NAME_LEN|.
bool btif_storage_get_stored_remote_name(const RawAddress& bd_addr, char* name);

/*******************************************************************************
 *
 * Function         btif_storage_get_cod
 *
 * Description      Retrieves the stored class of device.
 *
 * Returns          true if successful, otherwise false
 *
 ******************************************************************************/
bool btif_storage_get_cod(const RawAddress& bd_addr, uint32_t* cod);

/*******************************************************************************
 *
 * Function         btif_storage_set_hid_connection_policy
+4 −10
Original line number Diff line number Diff line
@@ -484,18 +484,12 @@ static bool get_cached_remote_name(const RawAddress& bd_addr, uint8_t* p_remote_
}

static uint32_t get_cod(const RawAddress* remote_bdaddr) {
  uint32_t remote_cod;
  bt_property_t prop_name;

  /* check if we already have it in our btif_storage cache */
  BTIF_STORAGE_FILL_PROPERTY(&prop_name, BT_PROPERTY_CLASS_OF_DEVICE, sizeof(uint32_t),
                             &remote_cod);
  if (btif_storage_get_remote_device_property((RawAddress*)remote_bdaddr, &prop_name) ==
      BT_STATUS_SUCCESS) {
    return remote_cod;
  uint32_t remote_cod = 0;
  if (!btif_storage_get_cod(*remote_bdaddr, &remote_cod)) {
    remote_cod = 0;
  }

  return 0;
  return remote_cod;
}

bool check_cod(const RawAddress* remote_bdaddr, uint32_t cod) {
+10 −0
Original line number Diff line number Diff line
@@ -1303,6 +1303,16 @@ bool btif_storage_get_stored_remote_name(const RawAddress& bd_addr, char* name)
  return btif_storage_get_remote_device_property(&bd_addr, &property) == BT_STATUS_SUCCESS;
}

// Get the Class of Device.
bool btif_storage_get_cod(const RawAddress& bd_addr, uint32_t* cod) {
  bt_property_t property;
  property.type = BT_PROPERTY_CLASS_OF_DEVICE;
  property.len = sizeof(*cod);
  property.val = cod;

  return btif_storage_get_remote_device_property(&bd_addr, &property) == BT_STATUS_SUCCESS;
}

/** Stores information about GATT Client supported features support */
void btif_storage_set_gatt_cl_supp_feat(const RawAddress& bd_addr, uint8_t feat) {
  do_in_jni_thread(Bind(
+6 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@ struct btif_storage_get_remote_device_property btif_storage_get_remote_device_pr
struct btif_storage_get_remote_prop btif_storage_get_remote_prop;
struct btif_storage_get_sr_supp_feat btif_storage_get_sr_supp_feat;
struct btif_storage_get_stored_remote_name btif_storage_get_stored_remote_name;
struct btif_storage_get_cod btif_storage_get_cod;
struct btif_storage_invoke_addr_type_update btif_storage_invoke_addr_type_update;
struct btif_storage_is_restricted_device btif_storage_is_restricted_device;
struct btif_storage_load_bonded_devices btif_storage_load_bonded_devices;
@@ -100,6 +101,7 @@ bt_status_t btif_storage_get_remote_device_property::return_value = BT_STATUS_SU
bt_status_t btif_storage_get_remote_prop::return_value = BT_STATUS_SUCCESS;
uint8_t btif_storage_get_sr_supp_feat::return_value = 0;
bool btif_storage_get_stored_remote_name::return_value = false;
bool btif_storage_get_cod::return_value = false;
bool btif_storage_is_restricted_device::return_value = false;
bt_status_t btif_storage_load_bonded_devices::return_value = BT_STATUS_SUCCESS;
bt_status_t btif_storage_remove_ble_bonding_keys::return_value = BT_STATUS_SUCCESS;
@@ -208,6 +210,10 @@ bool btif_storage_get_stored_remote_name(const RawAddress& bd_addr, char* name)
  inc_func_call_count(__func__);
  return test::mock::btif_storage::btif_storage_get_stored_remote_name(bd_addr, name);
}
bool btif_storage_get_cod(const RawAddress& bd_addr, uint32_t* cod) {
  inc_func_call_count(__func__);
  return test::mock::btif_storage::btif_storage_get_cod(bd_addr, cod);
}
void btif_storage_invoke_addr_type_update(const RawAddress& remote_bd_addr,
                                          const tBLE_ADDR_TYPE& addr_type) {
  inc_func_call_count(__func__);
+11 −0
Original line number Diff line number Diff line
@@ -310,6 +310,17 @@ struct btif_storage_get_stored_remote_name {
};
extern struct btif_storage_get_stored_remote_name btif_storage_get_stored_remote_name;

// Name: btif_storage_get_cod
// Params: const RawAddress& bd_addr, uint32_t* cod
// Return: bool
struct btif_storage_get_cod {
  static bool return_value;
  std::function<bool(const RawAddress& bd_addr, uint32_t* cod)> body{
          [](const RawAddress& /* bd_addr */, uint32_t* /* cod */) { return return_value; }};
  bool operator()(const RawAddress& bd_addr, uint32_t* cod) { return body(bd_addr, cod); }
};
extern struct btif_storage_get_cod btif_storage_get_cod;

// Name: btif_storage_invoke_addr_type_update
// Params: const RawAddress& remote_bd_addr, const tBLE_ADDR_TYPE& addr_type
// Return: void