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

Commit 0cb7f2a4 authored by xiaoshun.xu's avatar xiaoshun.xu Committed by Dorin Drimus
Browse files

Fix reconnect RC, but RC key missing

[Description]
Fix is designed to fix reconnect with RC, but RC key missing
issue, if RC key missing, Host will remove bond RC

[Test Report]
RC press combo keys to forget device, device reconnect
with RC and remove bond if RC key missing, repair can use

Test: manual, the RC reconnects after forget device
Bug: 133389433

Change-Id: I5739a7537070c07d82fd5a0205610308f55ffcf2
parent 85e410c5
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -4048,3 +4048,15 @@ static void bta_dm_ctrl_features_rd_cmpl_cback(tHCI_STATUS result) {
  }
}
#endif /* BLE_VND_INCLUDED */

void bta_dm_process_delete_key_RC_to_unpair(const RawAddress& bd_addr)
{
    LOG_WARN("RC key missing");
    tBTA_DM_SEC param = {
        .delete_key_RC_to_unpair = {
            .bd_addr = bd_addr,
        },
    };
    bta_dm_cb.p_sec_cback(BTA_DM_REPORT_BONDING_EVT, &param);
}
+8 −1
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ static void bta_hh_le_add_dev_bg_conn(tBTA_HH_DEV_CB* p_cb, bool check_bond);
static void bta_hh_process_cache_rpt(tBTA_HH_DEV_CB* p_cb,
                                     tBTA_HH_RPT_CACHE_ENTRY* p_rpt_cache,
                                     uint8_t num_rpt);
extern void bta_dm_process_delete_key_RC_to_unpair(const RawAddress& bd_addr);

static const char* bta_hh_le_rpt_name[4] = {"UNKNOWN", "INPUT", "OUTPUT",
                                            "FEATURE"};
@@ -1002,6 +1003,12 @@ void bta_hh_security_cmpl(tBTA_HH_DEV_CB* p_cb,
      APPL_TRACE_DEBUG("%s: Starting service discovery", __func__);
      bta_hh_le_pri_service_discovery(p_cb);
    }
  }
  else if(p_cb->btm_status == BTM_ERR_KEY_MISSING) {
    LOG_ERROR("Received encryption failed status:%s btm_status:%s",
              bta_hh_status_text(p_cb->status).c_str(),
              btm_status_text(p_cb->btm_status).c_str());
    bta_dm_process_delete_key_RC_to_unpair(p_cb->addr);
  } else {
    LOG_ERROR("Encryption failed status:%s btm_status:%s",
              bta_hh_status_text(p_cb->status).c_str(),
+7 −0
Original line number Diff line number Diff line
@@ -222,6 +222,7 @@ typedef enum : uint8_t {
  BTA_DM_BLE_SC_OOB_REQ_EVT = 29,  /* SMP SC OOB request event */
  BTA_DM_BLE_CONSENT_REQ_EVT = 30, /* SMP consent request event */
  BTA_DM_BLE_SC_CR_LOC_OOB_EVT = 31, /* SMP SC Create Local OOB request event */
  BTA_DM_REPORT_BONDING_EVT = 32     /*handle for pin or key missing*/
} tBTA_DM_SEC_EVT;

/* Structure associated with BTA_DM_PIN_REQ_EVT */
@@ -371,6 +372,11 @@ typedef struct {
  tBTA_STATUS result; /* true of bond cancel succeeded, false if failed. */
} tBTA_DM_BOND_CANCEL_CMPL;

/* Add to remove bond of key missing RC */
typedef struct {
  RawAddress bd_addr;
} tBTA_DM_RC_UNPAIR;

typedef struct {
  Octet16 local_oob_c; /* Local OOB Data Confirmation/Commitment */
  Octet16 local_oob_r; /* Local OOB Data Randomizer */
@@ -392,6 +398,7 @@ typedef union {
  tBTA_BLE_LOCAL_ID_KEYS ble_id_keys; /* IR event */
  Octet16 ble_er;                     /* ER event data */
  tBTA_DM_LOC_OOB_DATA local_oob_data; /* Local OOB data generated by us */
  tBTA_DM_RC_UNPAIR delete_key_RC_to_unpair;
} tBTA_DM_SEC;

/* Security callback */
+8 −1
Original line number Diff line number Diff line
@@ -1793,7 +1793,14 @@ static void btif_dm_upstreams_evt(uint16_t event, char* p_param) {
    case BTA_DM_LE_FEATURES_READ:
      btif_get_adapter_property(BT_PROPERTY_LOCAL_LE_FEATURES);
      break;

    /* add case for HANDLE_KEY_MISSING */
    case BTA_DM_REPORT_BONDING_EVT:
      LOG_WARN("Received encryption failed: Report bonding firstly.");
      bd_addr = p_data->delete_key_RC_to_unpair.bd_addr;
      invoke_bond_state_changed_cb(BT_STATUS_SUCCESS, bd_addr, BT_BOND_STATE_BONDING,
                                   pairing_cb.fail_reason);
      btif_dm_remove_bond(bd_addr);
      break;
    default:
      BTIF_TRACE_WARNING("%s: unhandled event (%d)", __func__, event);
      break;
+1 −0
Original line number Diff line number Diff line
@@ -159,6 +159,7 @@ const char* dump_dm_event(uint16_t event) {
    CASE_RETURN_STR(BTA_DM_BLE_AUTH_CMPL_EVT)
    CASE_RETURN_STR(BTA_DM_DEV_UNPAIRED_EVT)
    CASE_RETURN_STR(BTA_DM_ENER_INFO_READ)
    CASE_RETURN_STR(BTA_DM_REPORT_BONDING_EVT)

    default:
      return "UNKNOWN DM EVENT";
Loading