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

Commit b2baba8b authored by howardchung's avatar howardchung
Browse files

Floss: Don't emit metric event when remove a bond

Don't emit metrics event when remove a bond otherwise it could pollute
our metrics.

Bug: 287157143
Test: manually remove the bond and check the logs

Change-Id: Id09299db0fb7096cd008df476dec9bad98efdfb5
parent e83cfa05
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -102,6 +102,9 @@ void LogMetricsBondStateChanged(
  // Ignore the start of pairing event as its logged separated above.
  if (pairing_state == PairingState::PAIR_STARTING) return;

  // Ignore absurd state.
  if (pairing_state == PairingState::PAIR_FAIL_END) return;

  LOG_DEBUG(
      "PairingStateChanged: %s, %d, %s, %d, %d",
      boot_id.c_str(),
+7 −2
Original line number Diff line number Diff line
@@ -265,11 +265,16 @@ PairingState ToPairingState(uint32_t status, uint32_t bond_state, int32_t fail_r
  if ((BtStatus)status == BtStatus::BT_STATUS_SUCCESS && (hci::ErrorCode)fail_reason == hci::ErrorCode::SUCCESS) {
    if ((BtBondState)bond_state == BtBondState::BT_BOND_STATE_BONDED) {
      return PairingState::PAIR_SUCCEED;
    } else {
      return PairingState::PAIR_FAIL_CANCELLED;
    } else {  // must be BtBondState::BT_BOND_STATE_NONE as BT_BOND_STATE_BONDING case has been
              // checked early
      // This implies the event is from forgetting a device. Return an absurd value to let caller
      // know.
      return PairingState::PAIR_FAIL_END;
    }
  }

  // TODO(b/287392029): Translate cases of bond cancelled into PairingState:PAIR_FAIL_CANCELLED

  // When both status and fail reason are provided and disagree with each other, overwrite status with the fail reason
  // as fail reason is generated closer to the HCI and provides a more accurate description.
  if (status) pairing_state = StatusToPairingState(status);