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

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

Populate remote device name from properties if available

BTM creates device records from bonded devices at the time of
initiatlization. The remote device name is kept empty in these records
even though they are available in properties.

Test: mmm packages/modules/Bluetooth
Test: Manual | Bond with a remote device, restart Bluetooth, forget bond
from the remote device, initiate reconnection, pairing dialog box must
show correct name
Flag: com.android.bluetooth.flags.name_discovery_for_le_pairing
Bug: 346365430
Bug: 355095011

Change-Id: Ia47a912c3ccd36527349ec71d78d7d41fe570ea0
parent f0e97ea8
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -100,9 +100,17 @@ void BTM_SecAddBleDevice(const RawAddress& bd_addr, tBT_DEVICE_TYPE dev_type,

    log::debug("Device added, handle=0x{:x}, p_dev_rec={}, bd_addr={}", p_dev_rec->ble_hci_handle,
               fmt::ptr(p_dev_rec), bd_addr);

    if (com::android::bluetooth::flags::name_discovery_for_le_pairing() &&
        btif_storage_get_stored_remote_name(bd_addr,
                                            reinterpret_cast<char*>(&p_dev_rec->sec_bd_name))) {
      p_dev_rec->sec_rec.sec_flags |= BTM_SEC_NAME_KNOWN;
    }
  }

  memset(p_dev_rec->sec_bd_name, 0, sizeof(BD_NAME));
  if (!com::android::bluetooth::flags::name_discovery_for_le_pairing()) {
    bd_name_clear(p_dev_rec->sec_bd_name);
  }

  p_dev_rec->device_type |= dev_type;
  if (is_ble_addr_type_known(addr_type)) {
+11 −1
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@

#include <string>

#include "btif/include/btif_storage.h"
#include "btm_api.h"
#include "btm_int_types.h"
#include "btm_sec_api.h"
@@ -83,6 +84,7 @@ static void wipe_secrets_and_remove(tBTM_SEC_DEV_REC* p_dev_rec) {
void BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, LinkKey link_key,
                      uint8_t key_type, uint8_t pin_length) {
  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(bd_addr);

  if (!p_dev_rec) {
    p_dev_rec = btm_sec_allocate_dev_rec();
    log::info(
@@ -97,6 +99,12 @@ void BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, LinkKey li
    /* use default value for background connection params */
    /* update conn params, use default value for background connection params */
    memset(&p_dev_rec->conn_params, 0xff, sizeof(tBTM_LE_CONN_PRAMS));

    if (com::android::bluetooth::flags::name_discovery_for_le_pairing() &&
        btif_storage_get_stored_remote_name(bd_addr,
                                            reinterpret_cast<char*>(&p_dev_rec->sec_bd_name))) {
      p_dev_rec->sec_rec.sec_flags |= BTM_SEC_NAME_KNOWN;
    }
  } else {
    log::info(
            "Caching existing record from config file device: {}, dev_class: "
@@ -119,7 +127,9 @@ void BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, LinkKey li
    p_dev_rec->dev_class = dev_class;
  }

  memset(p_dev_rec->sec_bd_name, 0, sizeof(BD_NAME));
  if (!com::android::bluetooth::flags::name_discovery_for_le_pairing()) {
    bd_name_clear(p_dev_rec->sec_bd_name);
  }

  p_dev_rec->sec_rec.sec_flags |= BTM_SEC_LINK_KEY_KNOWN;
  p_dev_rec->sec_rec.link_key = link_key;