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

Commit 7ead9c5d authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Fix CoC not being able to establish first connection

When establishing conenction, we must know address type of the device we
connect to. We learn it during scan. We store this information in BTIF
layer, and later copy it into BTM if someone tries to make connection.

CoC code was not copying address type information between layers. This
caused us to use bad address type, which resulted in no connection being
created.

This patch fixes the issue, by making sure address type is properly
copied from BTIF into BTM

Test: acts BleCocTest
Bug: 133444088
Change-Id: I08609d92df245649882ad0b186a6080bff61a96e
parent ad4eca7b
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@

#include "bta_api.h"
#include "btif_common.h"
#include "btif_config.h"
#include "btif_sock_l2cap.h"
#include "btif_sock_rfc.h"
#include "btif_sock_sco.h"
@@ -215,12 +216,24 @@ static bt_status_t btsock_connect(const RawAddress* bd_addr, btsock_type_t type,
      status = btsock_l2cap_connect(bd_addr, channel, sock_fd, flags, app_uid);
      break;

    case BTSOCK_L2CAP_LE:
    case BTSOCK_L2CAP_LE: {
      flags |= BTSOCK_FLAG_LE_COC;

      // Ensure device is in inquiry database
      int addr_type = 0;
      int device_type = 0;

      if (btif_get_address_type(*bd_addr, &addr_type) &&
          btif_get_device_type(*bd_addr, &device_type) &&
          device_type != BT_DEVICE_TYPE_BREDR) {
        BTA_DmAddBleDevice(*bd_addr, addr_type, device_type);
      }

      LOG_DEBUG(LOG_TAG, "%s: type=BTSOCK_L2CAP_LE, channel=0x%x, flags=0x%x",
                __func__, channel, flags);
      status = btsock_l2cap_connect(bd_addr, channel, sock_fd, flags, app_uid);
      break;
    }

    case BTSOCK_SCO:
      status = btsock_sco_connect(bd_addr, sock_fd, flags);