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

Commit d5b50521 authored by Zhengping Jiang's avatar Zhengping Jiang
Browse files

floss: skip resume flow if no suspend id is recorded

If there is no suspend id recorded during resume, it means nothing is
done during suspend. Log the metrics and return.

Bug: 310077261
Test: mma -j32
Flag: EXEMPT Floss only changes and chromeos metrics.
Cq-Depend: chromium:5179124

Change-Id: I65f88b70b028865000ef3d9f9a6491687ee4844c
parent cae7c96d
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -318,5 +318,24 @@ void LogMetricsChipsetInfoReport() {
  }
}

void LogMetricsSuspendIdState(uint32_t state) {
  int64_t suspend_id_state = 0;
  int64_t boot_time;
  std::string boot_id;

  if (!GetBootId(&boot_id)) return;

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

  suspend_id_state = (int64_t)ToSuspendIdState(state);
  LOG_DEBUG("SuspendIdState: %s, %d, %d", boot_id.c_str(), boot_time, suspend_id_state);

  ::metrics::structured::events::bluetooth::BluetoothSuspendIdStateChanged()
      .SetBootId(boot_id)
      .SetSystemTime(boot_time)
      .SetSuspendIdState(suspend_id_state)
      .Record();
}

}  // namespace metrics
}  // namespace bluetooth
+4 −0
Original line number Diff line number Diff line
@@ -234,6 +234,10 @@ AdapterState ToAdapterState(uint32_t state) {
  return state == 1 ? AdapterState::ON : AdapterState::OFF;
}

SuspendIdState ToSuspendIdState(uint32_t state) {
  return state == 1 ? SuspendIdState::Recorded : SuspendIdState::NoRecord;
}

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>
+7 −0
Original line number Diff line number Diff line
@@ -195,6 +195,10 @@ enum class MetricTransportType {
  TRANSPORT_TYPE_SDIO = 3,
};

// ENUM definition for suspend id state that in sync with ChromeOS structured metrics
// BluetoothSuspendIdStateChanged/SuspendIdState.
enum class SuspendIdState : int64_t { NoRecord = 0, Recorded = 1 };

// A struct holds the parsed profile connection event.
struct ProfileConnectionEvent {
  int64_t type;
@@ -205,6 +209,9 @@ struct ProfileConnectionEvent {
// Convert topshim::btif::BtState to AdapterState.
AdapterState ToAdapterState(uint32_t state);

// Convert to SuspendIdState.
SuspendIdState ToSuspendIdState(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
@@ -51,5 +51,7 @@ void LogMetricsAclConnectionStateChanged(

void LogMetricsChipsetInfoReport() {}

void LogMetricsSuspendIdState(uint32_t state){};

}  // namespace metrics
}  // namespace bluetooth
+2 −0
Original line number Diff line number Diff line
@@ -40,5 +40,7 @@ void LogMetricsAclConnectionStateChanged(
    RawAddress* addr, uint32_t transport, uint32_t status, uint32_t acl_state, uint32_t direction, uint32_t hci_reason);
void LogMetricsChipsetInfoReport();

void LogMetricsSuspendIdState(uint32_t state);

}  // namespace metrics
}  // namespace bluetooth
Loading