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

Commit 63b09961 authored by Stanley Tng's avatar Stanley Tng
Browse files

Remove L2CAP_MASK_LE_COC_CHANNEL flag in channel number

Cleanup the code by removing the use of L2CAP_MASK_LE_COC_CHANNEL flag
in the channel number. This flag will be passed in the proper "flags"
parameter.

Test: Ran the new ACTS Tests for LE CoC
Bug: 70683224
Change-Id: I6ed77b46e5434bca5f2501d853ae8181c7197b4c
parent aec2c6f7
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -10,7 +10,6 @@
#include <hardware/bluetooth.h>

#define L2CAP_MASK_FIXED_CHANNEL 0x10000
#define L2CAP_MASK_LE_COC_CHANNEL 0x20000

bt_status_t btsock_l2cap_init(int handle, uid_set_t* set);
bt_status_t btsock_l2cap_cleanup();
+11 −10
Original line number Diff line number Diff line
@@ -143,17 +143,18 @@ static bt_status_t btsock_listen(btsock_type_t type, const char* service_name,
      break;
    case BTSOCK_L2CAP_LE:
      if (flags & BTSOCK_FLAG_NO_SDP) {
        channel = L2CAP_MASK_LE_COC_CHANNEL;
      } else if (channel > 0) {
        channel |= L2CAP_MASK_LE_COC_CHANNEL;
      } else {
        /* Set channel to zero so that it will be assigned */
        channel = 0;
      } else if (channel <= 0) {
        LOG_ERROR(LOG_TAG, "%s: type BTSOCK_L2CAP_LE: invalid channel=%d",
                  __func__, channel);
        break;
      }
      LOG_DEBUG(LOG_TAG,
                "%s: type=BTSOCK_L2CAP_LE, channel=0x%x, original=0x%x",
                __func__, channel, original_channel);
      flags |= BTSOCK_FLAG_LE_COC;
      LOG_DEBUG(
          LOG_TAG,
          "%s: type=BTSOCK_L2CAP_LE, channel=0x%x, original=0x%x, flags=0x%x",
          __func__, channel, original_channel, flags);
      status =
          btsock_l2cap_listen(service_name, channel, sock_fd, flags, app_uid);
      break;
@@ -190,9 +191,9 @@ static bt_status_t btsock_connect(const RawAddress* bd_addr, btsock_type_t type,
      break;

    case BTSOCK_L2CAP_LE:
      channel |= L2CAP_MASK_LE_COC_CHANNEL;
      LOG_DEBUG(LOG_TAG, "%s: type=BTSOCK_L2CAP_LE, channel=0x%x", __func__,
                channel);
      flags |= BTSOCK_FLAG_LE_COC;
      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;

+2 −2
Original line number Diff line number Diff line
@@ -857,9 +857,9 @@ static bt_status_t btsock_l2cap_listen_or_connect(const char* name,
    // We need to auto assign a PSM
    fixed_chan = 0;
  } else {
    is_le_coc = (flags & BTSOCK_FLAG_LE_COC) != 0;
    fixed_chan = (channel & L2CAP_MASK_FIXED_CHANNEL) != 0;
    is_le_coc = (channel & L2CAP_MASK_LE_COC_CHANNEL) != 0;
    channel &= ~(L2CAP_MASK_FIXED_CHANNEL | L2CAP_MASK_LE_COC_CHANNEL);
    channel &= ~L2CAP_MASK_FIXED_CHANNEL;
  }

  if (!is_inited()) return BT_STATUS_NOT_READY;
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ __BEGIN_DECLS
#define BTSOCK_FLAG_NO_SDP (1 << 2)
#define BTSOCK_FLAG_AUTH_MITM (1 << 3)
#define BTSOCK_FLAG_AUTH_16_DIGIT (1 << 4)
#define BTSOCK_FLAG_LE_COC (1 << 5)

typedef enum {
  BTSOCK_RFCOMM = 1,