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

Commit 5336d57e authored by Chen Chen's avatar Chen Chen
Browse files

BluetoothMetrics: Add SDP DI manufacturers info to Bluetooth config;

Add SDP ID info and LMP info to Bluetooth log

Bug: 142563377
Test: manually check Bluetooth config file
Change-Id: I4a7c348ac570a730cccc31e51bdc9669847f96a5
parent 7df2da94
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -29,6 +29,18 @@

static const char BTIF_CONFIG_MODULE[] = "btif_config_module";

static const std::string BT_CONFIG_KEY_SDP_DI_MANUFACTURER =
    "SdpDiManufacturer";
static const std::string BT_CONFIG_KEY_SDP_DI_MODEL = "SdpDiModel";
static const std::string BT_CONFIG_KEY_SDP_DI_HW_VERSION =
    "SdpDiHardwareVersion";
static const std::string BT_CONFIG_KEY_SDP_DI_VENDOR_ID_SRC =
    "SdpDiVendorIdSource";

static const std::string BT_CONFIG_KEY_REMOTE_VER_MFCT = "Manufacturer";
static const std::string BT_CONFIG_KEY_REMOTE_VER_VER = "LmpVer";
static const std::string BT_CONFIG_KEY_REMOTE_VER_SUBVER = "LmpSubVer";

bool btif_config_has_section(const char* section);
bool btif_config_exist(const std::string& section, const std::string& key);
bool btif_config_get_int(const std::string& section, const std::string& key,
+6 −10
Original line number Diff line number Diff line
@@ -72,9 +72,6 @@ using bluetooth::Uuid;
#define BTIF_STORAGE_PATH_REMOTE_DEVCLASS "DevClass"
#define BTIF_STORAGE_PATH_REMOTE_DEVTYPE "DevType"
#define BTIF_STORAGE_PATH_REMOTE_NAME "Name"
#define BTIF_STORAGE_PATH_REMOTE_VER_MFCT "Manufacturer"
#define BTIF_STORAGE_PATH_REMOTE_VER_VER "LmpVer"
#define BTIF_STORAGE_PATH_REMOTE_VER_SUBVER "LmpSubVer"

//#define BTIF_STORAGE_PATH_REMOTE_LINKKEYS "remote_linkkeys"
#define BTIF_STORAGE_PATH_REMOTE_ALIASE "Aliase"
@@ -260,11 +257,10 @@ static int prop2cfg(const RawAddress* remote_bd_addr, bt_property_t* prop) {

      if (!info) return false;

      btif_config_set_int(bdstr, BTIF_STORAGE_PATH_REMOTE_VER_MFCT,
      btif_config_set_int(bdstr, BT_CONFIG_KEY_REMOTE_VER_MFCT,
                          info->manufacturer);
      btif_config_set_int(bdstr, BTIF_STORAGE_PATH_REMOTE_VER_VER,
                          info->version);
      btif_config_set_int(bdstr, BTIF_STORAGE_PATH_REMOTE_VER_SUBVER,
      btif_config_set_int(bdstr, BT_CONFIG_KEY_REMOTE_VER_VER, info->version);
      btif_config_set_int(bdstr, BT_CONFIG_KEY_REMOTE_VER_SUBVER,
                          info->sub_ver);
    } break;

@@ -382,15 +378,15 @@ static int cfg2prop(const RawAddress* remote_bd_addr, bt_property_t* prop) {
      bt_remote_version_t* info = (bt_remote_version_t*)prop->val;

      if (prop->len >= (int)sizeof(bt_remote_version_t)) {
        ret = btif_config_get_int(bdstr, BTIF_STORAGE_PATH_REMOTE_VER_MFCT,
        ret = btif_config_get_int(bdstr, BT_CONFIG_KEY_REMOTE_VER_MFCT,
                                  &info->manufacturer);

        if (ret)
          ret = btif_config_get_int(bdstr, BTIF_STORAGE_PATH_REMOTE_VER_VER,
          ret = btif_config_get_int(bdstr, BT_CONFIG_KEY_REMOTE_VER_VER,
                                    &info->version);

        if (ret)
          ret = btif_config_get_int(bdstr, BTIF_STORAGE_PATH_REMOTE_VER_SUBVER,
          ret = btif_config_get_int(bdstr, BT_CONFIG_KEY_REMOTE_VER_SUBVER,
                                    &info->sub_ver);
      }
    } break;
+39 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@
#include "bt_common.h"
#include "bt_types.h"
#include "bt_utils.h"
#include "btif_config.h"
#include "btm_api.h"
#include "btm_int.h"
#include "btu.h"
@@ -192,6 +193,44 @@ void btu_hcif_log_event_metrics(uint8_t evt_code, uint8_t* p_event) {
      bluetooth::common::LogLinkLayerConnectionEvent(
          &bda, handle, android::bluetooth::DIRECTION_UNKNOWN, link_type, cmd,
          evt_code, android::bluetooth::hci::BLE_EVT_UNKNOWN, status, reason);

      // Read SDP_DI manufacturer, model, HW version from config,
      // and log them
      int sdp_di_manufacturer_id = 0;
      int sdp_di_model_id = 0;
      int sdp_di_hw_version = 0;
      int sdp_di_vendor_id_source = 0;
      std::string bda_string = bda.ToString();
      btif_config_get_int(bda_string, BT_CONFIG_KEY_SDP_DI_MANUFACTURER,
                          &sdp_di_manufacturer_id);
      btif_config_get_int(bda_string, BT_CONFIG_KEY_SDP_DI_MODEL,
                          &sdp_di_model_id);
      btif_config_get_int(bda_string, BT_CONFIG_KEY_SDP_DI_HW_VERSION,
                          &sdp_di_hw_version);
      btif_config_get_int(bda_string, BT_CONFIG_KEY_SDP_DI_VENDOR_ID_SRC,
                          &sdp_di_vendor_id_source);

      std::stringstream ss;
      // [N - native]::SDP::[DIP - Device ID Profile]
      ss << "N:SDP::DIP::" << loghex(sdp_di_vendor_id_source);
      bluetooth::common::LogManufacturerInfo(
          bda, android::bluetooth::DeviceInfoSrcEnum::DEVICE_INFO_INTERNAL,
          ss.str(), loghex(sdp_di_manufacturer_id), loghex(sdp_di_model_id),
          loghex(sdp_di_hw_version), "");

      // Read LMP version, subversion and  manufacturer from config,
      // and log them
      int lmp_version = -1;
      int lmp_subversion = -1;
      int lmp_manufacturer_id = -1;
      btif_config_get_int(bda_string, BT_CONFIG_KEY_REMOTE_VER_VER,
                          &lmp_version);
      btif_config_get_int(bda_string, BT_CONFIG_KEY_REMOTE_VER_SUBVER,
                          &lmp_subversion);
      btif_config_get_int(bda_string, BT_CONFIG_KEY_REMOTE_VER_MFCT,
                          &lmp_manufacturer_id);
      bluetooth::common::LogRemoteVersionInfo(
          handle, status, lmp_version, lmp_manufacturer_id, lmp_subversion);
      break;
    }
    case HCI_CONNECTION_REQUEST_EVT: {
+12 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@

#include "bt_common.h"
#include "bt_types.h"
#include "btif_config.h"

#include "sdp_api.h"
#include "sdpint.h"
@@ -274,6 +275,17 @@ void sdpu_log_attribute_metrics(const RawAddress& bda,
          bda, android::bluetooth::DeviceInfoSrcEnum::DEVICE_INFO_INTERNAL,
          ss.str(), loghex(di_record.rec.vendor), loghex(di_record.rec.product),
          loghex(di_record.rec.version), "");

      std::string bda_string = bda.ToString();
      // write manufacturer, model, HW version to config
      btif_config_set_int(bda_string, BT_CONFIG_KEY_SDP_DI_MANUFACTURER,
                          di_record.rec.vendor);
      btif_config_set_int(bda_string, BT_CONFIG_KEY_SDP_DI_MODEL,
                          di_record.rec.product);
      btif_config_set_int(bda_string, BT_CONFIG_KEY_SDP_DI_HW_VERSION,
                          di_record.rec.version);
      btif_config_set_int(bda_string, BT_CONFIG_KEY_SDP_DI_VENDOR_ID_SRC,
                          di_record.rec.vendor_id_source);
    }
  }
}