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

Commit 6cfcc24f authored by Zhengping Jiang's avatar Zhengping Jiang Committed by Gerrit Code Review
Browse files

Merge "floss: add a metrics to log LL privacy state" into main

parents 481b69d9 b2a593f4
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -309,5 +309,30 @@ void LogMetricsSuspendIdState(uint32_t state) {
          .Record();
}

void LogMetricsLLPrivacyState(uint32_t llp_state, uint32_t rpa_state) {
  int64_t ll_privacy_state = 0;
  int64_t addr_privacy_state = 0;
  int64_t boot_time;
  std::string boot_id;

  if (!GetBootId(&boot_id)) {
    return;
  }

  boot_time = bluetooth::common::time_get_os_boottime_us();

  ll_privacy_state = (int64_t)ToLLPrivacyState(llp_state);
  addr_privacy_state = (int64_t)ToAddressPrivacyState(rpa_state);
  log::debug("LLPrivacyState: {}, {}, {}, {}", boot_id, boot_time, ll_privacy_state,
             addr_privacy_state);

  ::metrics::structured::events::bluetooth::BluetoothLLPrivacyState()
          .SetBootId(boot_id)
          .SetSystemTime(boot_time)
          .SetLLPrivacyState(ll_privacy_state)
          .SetAddressPrivacyState(addr_privacy_state)
          .Record();
}

}  // namespace metrics
}  // namespace bluetooth
+8 −0
Original line number Diff line number Diff line
@@ -243,6 +243,14 @@ SuspendIdState ToSuspendIdState(uint32_t state) {
  return state == 1 ? SuspendIdState::Recorded : SuspendIdState::NoRecord;
}

LLPrivacyState ToLLPrivacyState(uint32_t state) {
  return state == 1 ? LLPrivacyState::Enabled : LLPrivacyState::Disabled;
}

AddressPrivacyState ToAddressPrivacyState(uint32_t state) {
  return state == 1 ? AddressPrivacyState::Enabled : AddressPrivacyState::Disabled;
}

ConnectionType ToPairingDeviceType(std::string addr, uint32_t device_type) {
  // A map stores the pending ConnectionType used to match a pairing event with unknown type.
  // map<address, type>
+14 −0
Original line number Diff line number Diff line
@@ -202,6 +202,14 @@ enum class MetricTransportType {
// BluetoothSuspendIdStateChanged/SuspendIdState.
enum class SuspendIdState : int64_t { NoRecord = 0, Recorded = 1 };

// ENUM definition for LL Privacy that in sync with ChromeOS structured metrics
// BluetoothLLPrivacyState/LLPrivacyState.
enum class LLPrivacyState : int64_t { Disabled = 0, Enabled = 1 };

// ENUM definition for Host RPA that in sync with ChromeOS structured metrics
// BluetoothLLPrivacyState/AddressPrivacyState.
enum class AddressPrivacyState : int64_t { Disabled = 0, Enabled = 1 };

// A struct holds the parsed profile connection event.
struct ProfileConnectionEvent {
  int64_t type;
@@ -215,6 +223,12 @@ AdapterState ToAdapterState(uint32_t state);
// Convert to SuspendIdState.
SuspendIdState ToSuspendIdState(uint32_t state);

// Convert to LLPrivacyState.
LLPrivacyState ToLLPrivacyState(uint32_t state);

// Convert to AddressPrivacyState.
AddressPrivacyState ToAddressPrivacyState(uint32_t state);

// Convert topshim::btif::BtDeviceType to ConnectionType
ConnectionType ToPairingDeviceType(std::string addr, uint32_t device_type);

+2 −0
Original line number Diff line number Diff line
@@ -44,5 +44,7 @@ void LogMetricsChipsetInfoReport() {}

void LogMetricsSuspendIdState(uint32_t state) {}

void LogMetricsLLPrivacyState(uint32_t llp_state, uint32_t rpa_state) {}

}  // namespace metrics
}  // namespace bluetooth
+2 −0
Original line number Diff line number Diff line
@@ -39,5 +39,7 @@ void LogMetricsChipsetInfoReport();

void LogMetricsSuspendIdState(uint32_t state);

void LogMetricsLLPrivacyState(uint32_t llp_state, uint32_t rpa_state);

}  // namespace metrics
}  // namespace bluetooth
Loading