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

Commit 1fb28ba1 authored by Jack He's avatar Jack He Committed by Android (Google) Code Review
Browse files

Merge changes I37f46b53,I742ba3f1,Ife2aa3ae into tm-dev

* changes:
  Only add btm_ble_enq_resolving_list_pending when privacy not enabled
  Do not create connection when filter accept list is empty
  Remove device from filter accept list before delete device record
parents c8b27571 4891931f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -585,6 +585,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
      return;
    }
    connect_list.erase(address_with_type);
    connecting_le_.erase(address_with_type);
    direct_connections_.erase(address_with_type);
    register_with_address_manager();
    le_address_manager_->RemoveDeviceFromFilterAcceptList(
@@ -643,6 +644,10 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
          connectability_state_machine_text(connectability_state_).c_str());
      return;
    }
    if (connect_list.empty()) {
      LOG_ERROR("Attempting to re-arm le connection state machine when filter accept list is empty");
      return;
    }
    AddressWithType empty(Address::kEmpty, AddressType::RANDOM_DEVICE_ADDRESS);
    connectability_state_ = ConnectabilityState::ARMING;
    connecting_le_ = connect_list;
+4 −0
Original line number Diff line number Diff line
@@ -1338,12 +1338,16 @@ void shim::legacy::Acl::CancelClassicConnection(const hci::Address& address) {
void shim::legacy::Acl::AcceptLeConnectionFrom(
    const hci::AddressWithType& address_with_type, bool is_direct,
    std::promise<bool> promise) {
  LOG_DEBUG("AcceptLeConnectionFrom %s",
            PRIVATE_ADDRESS(address_with_type.GetAddress()));
  handler_->CallOn(pimpl_.get(), &Acl::impl::accept_le_connection_from,
                   address_with_type, is_direct, std::move(promise));
}

void shim::legacy::Acl::IgnoreLeConnectionFrom(
    const hci::AddressWithType& address_with_type) {
  LOG_DEBUG("IgnoreLeConnectionFrom %s",
            PRIVATE_ADDRESS(address_with_type.GetAddress()));
  handler_->CallOn(pimpl_.get(), &Acl::impl::ignore_le_connection_from,
                   address_with_type);
}
+15 −2
Original line number Diff line number Diff line
@@ -205,8 +205,14 @@ bool BTM_AcceptlistAdd(const RawAddress& address) {
    LOG_WARN("Controller does not support Le");
    return false;
  }

  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address);
  if (p_dev_rec != NULL && p_dev_rec->device_type & BT_DEVICE_TYPE_BLE) {
    p_dev_rec->ble.in_controller_list |= BTM_ACCEPTLIST_BIT;
  }

  return bluetooth::shim::ACL_AcceptLeConnectionFrom(
      convert_to_address_with_type(address, btm_find_dev(address)),
      convert_to_address_with_type(address, p_dev_rec),
      /* is_direct */ false);
}

@@ -216,8 +222,15 @@ void BTM_AcceptlistRemove(const RawAddress& address) {
    LOG_WARN("Controller does not support Le");
    return;
  }

  tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(address);
  if (p_dev_rec != NULL && p_dev_rec->device_type & BT_DEVICE_TYPE_BLE) {
    p_dev_rec->ble.in_controller_list &= ~BTM_ACCEPTLIST_BIT;
  }

  bluetooth::shim::ACL_IgnoreLeConnectionFrom(
      convert_to_address_with_type(address, btm_find_dev(address)));
      convert_to_address_with_type(address, p_dev_rec));
  return;
}

/** Clear the acceptlist, end any pending acceptlist connections */
+5 −7
Original line number Diff line number Diff line
@@ -434,10 +434,9 @@ tBTM_STATUS btm_ble_remove_resolving_list_entry(tBTM_SEC_DEV_REC* p_dev_rec) {
    BTM_VendorSpecificCommand(HCI_VENDOR_BLE_RPA_VSC,
                              BTM_BLE_META_REMOVE_IRK_LEN, param,
                              btm_ble_resolving_list_vsc_op_cmpl);
  }

    btm_ble_enq_resolving_list_pending(p_dev_rec->bd_addr,
                                       BTM_BLE_META_REMOVE_IRK_ENTRY);
  }
  return BTM_CMD_STARTED;
}

@@ -495,11 +494,10 @@ bool btm_ble_read_resolving_list_entry(tBTM_SEC_DEV_REC* p_dev_rec) {

    BTM_VendorSpecificCommand(HCI_VENDOR_BLE_RPA_VSC, BTM_BLE_META_READ_IRK_LEN,
                              param, btm_ble_resolving_list_vsc_op_cmpl);
  }

    btm_ble_enq_resolving_list_pending(p_dev_rec->bd_addr,
                                       BTM_BLE_META_READ_IRK_ENTRY);

  }
  return true;
}

+9 −0
Original line number Diff line number Diff line
@@ -136,6 +136,9 @@ void wipe_secrets_and_remove(tBTM_SEC_DEV_REC* p_dev_rec) {
  list_remove(btm_cb.sec_dev_rec, p_dev_rec);
}

/** Removes the device from acceptlist */
extern void BTM_AcceptlistRemove(const RawAddress& address);

/** Free resources associated with the device associated with |bd_addr| address.
 *
 * *** WARNING ***
@@ -162,6 +165,12 @@ bool BTM_SecDeleteDevice(const RawAddress& bd_addr) {
  if (p_dev_rec != NULL) {
    RawAddress bda = p_dev_rec->bd_addr;

    if (p_dev_rec->ble.in_controller_list & BTM_ACCEPTLIST_BIT) {
      LOG_INFO("Remove device %s from filter accept list before delete record",
               PRIVATE_ADDRESS(bd_addr));
      BTM_AcceptlistRemove(p_dev_rec->bd_addr);
    }

    /* Clear out any saved BLE keys */
    btm_sec_clear_ble_keys(p_dev_rec);
    wipe_secrets_and_remove(p_dev_rec);