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

Commit de347097 authored by Chen Chen's avatar Chen Chen Committed by Jack He
Browse files

BluetoothMetrics: Remove MetricIdAllocator reference from HalCrashReason

Calling MetricIdAllocator may break its singleton pattern when stack is
half gd and half legacy. Since we are not inputing metric id at this
point, the easiest way is to just delete the reference.

Bug: 181819141
Test: atest --host bluetooth_test_common
Tag: #stability
Change-Id: If4bf0a87a55ef4ee5460065c43577ed22d7b28eb
parent 800130a4
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -904,17 +904,15 @@ void LogManufacturerInfo(const RawAddress& address,
void LogBluetoothHalCrashReason(const RawAddress& address, uint32_t error_code,
                                uint32_t vendor_error_code) {
  std::string obfuscated_id;
  int metric_id = 0;
  if (!address.IsEmpty()) {
    obfuscated_id = AddressObfuscator::GetInstance()->Obfuscate(address);
    metric_id = MetricIdAllocator::GetInstance().AllocateId(address);
  }
  // nullptr and size 0 represent missing value for obfuscated_id
  android::util::BytesField obfuscated_id_field(
      address.IsEmpty() ? nullptr : obfuscated_id.c_str(),
      address.IsEmpty() ? 0 : obfuscated_id.size());
  int ret = android::util::stats_write(
      android::util::BLUETOOTH_HAL_CRASH_REASON_REPORTED, metric_id,
      android::util::BLUETOOTH_HAL_CRASH_REASON_REPORTED, 0,
      obfuscated_id_field, error_code, vendor_error_code);
  if (ret < 0) {
    LOG(WARNING) << __func__ << ": failed for " << address << ", error_code "