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

Commit bc10268c authored by Chris Manton's avatar Chris Manton
Browse files

Skip on_common_connection after disarm le connection state machine

On common connection complete does two things:
1. Disables timer for the new connection if direct connection
2. Removes device from connections awaiting adverts

When the le connection state machine is disarmed by OnPause(),
neither of these conditions are true and may be skipped.

Bug: 213937853
Tag: #refactor
Test: gd/cert/run
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines

Change-Id: I5be0784d0cb5d541fd3e794d541b05693a5c1999
parent c99fca95
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -148,14 +148,15 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
    auto status = connection_complete.GetStatus();
    auto address = connection_complete.GetPeerAddress();
    auto peer_address_type = connection_complete.GetPeerAddressType();
    if (status == ErrorCode::UNKNOWN_CONNECTION && pause_connection) {
      // connection canceled by LeAddressManager.OnPause(), will auto reconnect by LeAddressManager.OnResume()
      return;
    }
    // TODO: find out which address and type was used to initiate the connection
    AddressWithType remote_address(address, peer_address_type);
    AddressWithType local_address = le_address_manager_->GetCurrentAddress();
    on_common_le_connection_complete(remote_address);
    if (status == ErrorCode::UNKNOWN_CONNECTION && pause_connection) {
      // connection canceled by LeAddressManager.OnPause(), will auto reconnect by LeAddressManager.OnResume()
      return;
    } else if (status == ErrorCode::UNKNOWN_CONNECTION && remote_address.GetAddress() == Address::kEmpty) {
    if (status == ErrorCode::UNKNOWN_CONNECTION && remote_address.GetAddress() == Address::kEmpty) {
      // direct connect canceled due to connection timeout, start background connect
      create_le_connection(remote_address, false, false);
      return;
@@ -210,15 +211,16 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
    auto address = connection_complete.GetPeerAddress();
    auto peer_address_type = connection_complete.GetPeerAddressType();
    auto peer_resolvable_address = connection_complete.GetPeerResolvablePrivateAddress();
    if (status == ErrorCode::UNKNOWN_CONNECTION && pause_connection) {
      // connection canceled by LeAddressManager.OnPause(), will auto reconnect by LeAddressManager.OnResume()
      return;
    }
    AddressWithType remote_address(address, peer_address_type);
    if (!peer_resolvable_address.IsEmpty()) {
      remote_address = AddressWithType(peer_resolvable_address, AddressType::RANDOM_DEVICE_ADDRESS);
    }
    on_common_le_connection_complete(remote_address);
    if (status == ErrorCode::UNKNOWN_CONNECTION && pause_connection) {
      // connection canceled by LeAddressManager.OnPause(), will auto reconnect by LeAddressManager.OnResume()
      return;
    } else if (status == ErrorCode::UNKNOWN_CONNECTION && remote_address.GetAddress() == Address::kEmpty) {
    if (status == ErrorCode::UNKNOWN_CONNECTION && remote_address.GetAddress() == Address::kEmpty) {
      // direct connect canceled due to connection timeout, start background connect
      create_le_connection(remote_address, false, false);
      return;