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

Commit 9513e41f authored by Chris Manton's avatar Chris Manton Committed by Automerger Merge Worker
Browse files

btm_history: Indicate pairing result am: d19f051d

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/1948947

Change-Id: I7b9dee167f70c17dbcc22fecd7f7c82f0bed8e25
parents 9808ca2e d19f051d
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include "stack/btm/btm_sec.h"
#include "stack/include/acl_api.h"
#include "stack/include/bt_octets.h"
#include "stack/include/btm_log_history.h"
#include "stack/include/l2c_api.h"
#include "stack/include/smp_api_types.h"
#include "stack/smp/p_256_ecc_pp.h"
@@ -39,6 +40,10 @@

extern tBTM_CB btm_cb;

namespace {
constexpr char kBtmLogTag[] = "SMP";
}

#define SMP_KEY_DIST_TYPE_MAX 4

const tSMP_ACT smp_distribute_act[] = {
@@ -229,11 +234,13 @@ void smp_send_pair_fail(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
  p_cb->status = p_data->status;
  p_cb->failure = p_data->status;

  SMP_TRACE_DEBUG("%s: status=%d failure=%d ", __func__, p_cb->status,
                  p_cb->failure);

  if (p_cb->status <= SMP_MAX_FAIL_RSN_PER_SPEC &&
      p_cb->status != SMP_SUCCESS) {
    LOG_ERROR("Pairing failed smp_status:%s",
              smp_status_text(p_cb->status).c_str());
    BTM_LogHistory(kBtmLogTag, p_cb->pairing_bda, "Pairing failed",
                   base::StringPrintf("smp_status:%s",
                                      smp_status_text(p_cb->status).c_str()));
    smp_send_cmd(SMP_OPCODE_PAIRING_FAILED, p_cb);
    p_cb->wait_for_authorization_complete = true;
  }
+33 −17
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
 *  This file contains functions for the SMP L2CAP utility functions
 *
 ******************************************************************************/
#include <base/logging.h>
#include <ctype.h>
#include <string.h>

@@ -36,11 +37,10 @@
#include "stack/include/acl_api.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_octets.h"
#include "stack/include/btm_log_history.h"
#include "stack/include/stack_metrics_logging.h"
#include "types/raw_address.h"

#include <base/logging.h>

#define SMP_PAIRING_REQ_SIZE 7
#define SMP_CONFIRM_CMD_SIZE (OCTET16_LEN + 1)
#define SMP_RAND_CMD_SIZE (OCTET16_LEN + 1)
@@ -59,6 +59,10 @@
                                                                   Check*/)
#define SMP_PAIR_KEYPR_NOTIF_SIZE (1 /* opcode */ + 1 /*Notif Type*/)

namespace {
constexpr char kBtmLogTag[] = "SMP";
}

/* SMP command sizes per spec */
static const uint8_t smp_cmd_size_per_spec[] = {
    0,
@@ -943,24 +947,36 @@ void smp_reset_control_value(tSMP_CB* p_cb) {
 *
 ******************************************************************************/
void smp_proc_pairing_cmpl(tSMP_CB* p_cb) {
  tSMP_EVT_DATA evt_data = {0};
  tSMP_CALLBACK* p_callback = p_cb->p_callback;
  const RawAddress pairing_bda = p_cb->pairing_bda;

  evt_data.cmplt.reason = p_cb->status;
  evt_data.cmplt.smp_over_br = p_cb->smp_over_br;
  const tSMP_EVT_DATA evt_data = {
      .cmplt =
          {
              .reason = p_cb->status,
              .sec_level = (p_cb->status == SMP_SUCCESS) ? p_cb->sec_level
                                                         : SMP_SEC_NONE,
              .is_pair_cancel = p_cb->is_pair_cancel,
              .smp_over_br = p_cb->smp_over_br,
          },
  };

  if (p_cb->status == SMP_SUCCESS) {
    LOG_DEBUG(
      "Pairing process has completed to remote:%s reason:0x%0x sec_level=0x%0x",
      PRIVATE_ADDRESS(p_cb->pairing_bda), evt_data.cmplt.reason,
        "Pairing process has completed successfully remote:%s sec_level:0x%0x",
        PRIVATE_ADDRESS(p_cb->pairing_bda), evt_data.cmplt.sec_level);
    BTM_LogHistory(kBtmLogTag, pairing_bda, "Pairing success");
  } else {
    LOG_WARN(
        "Pairing process has failed to remote:%s smp_reason:%s sec_level:0x%0x",
        PRIVATE_ADDRESS(p_cb->pairing_bda),
        smp_status_text(evt_data.cmplt.reason).c_str(),
        evt_data.cmplt.sec_level);

  if (p_cb->status == SMP_SUCCESS) evt_data.cmplt.sec_level = p_cb->sec_level;

  evt_data.cmplt.is_pair_cancel = false;

  if (p_cb->is_pair_cancel) evt_data.cmplt.is_pair_cancel = true;

  RawAddress pairing_bda = p_cb->pairing_bda;
    BTM_LogHistory(
        kBtmLogTag, pairing_bda, "Pairing failed",
        base::StringPrintf("reason:%s",
                           smp_status_text(evt_data.cmplt.reason).c_str()));
  }

  smp_reset_control_value(p_cb);