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

Commit 0ae9c06d authored by Jakub Pawlowski's avatar Jakub Pawlowski Committed by Jakub Pawłowski
Browse files

Improve key_missing_classic_device handling

Just like with btm_io_capabilities_rsp, in *_req handler we must check if device is already encrypted.

Bug: 333634398
Bug: 376765985
Test: mma -j32;
Test: OPP/SR/GOEP/BC/BV-01-I
Flag: com.android.bluetooth.flags.key_missing_classic_device
Change-Id: Ib572d92baedb8cad62e0482349a48d9dd310089b
parent 55843315
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -2441,15 +2441,17 @@ void btm_sec_rmt_host_support_feat_evt(const RawAddress bd_addr, uint8_t feature
 ******************************************************************************/
void btm_io_capabilities_req(RawAddress p) {
  if (btm_sec_is_a_bonded_dev(p)) {
    if (com::android::bluetooth::flags::key_missing_classic_device()) {
    auto p_dev_rec = btm_find_dev(p);
    ASSERT(p_dev_rec != NULL);

    /* If device is bonded, and encrypted it's upgrading security and it's ok.
     * If it's bonded and not encrypted, it's remote missing keys scenario */
    if (!p_dev_rec->sec_rec.is_device_encrypted() &&
        com::android::bluetooth::flags::key_missing_classic_device()) {
      log::warn("Incoming bond request, but {} is already bonded (notifying user)", p);
      bta_dm_remote_key_missing(p);

      auto p_dev_rec = btm_find_dev(p);
      if (p_dev_rec != NULL) {
      btm_sec_disconnect(p_dev_rec->hci_handle, HCI_ERR_AUTH_FAILURE,
                         "btm_io_capabilities_req for bonded device");
      }
      return;
    }