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

Commit a708965e authored by Sarvesh Kalwit's avatar Sarvesh Kalwit
Browse files

libbluetooth: Add BT_STATUS_SOCKET_ERROR metric

Add granularity to BT_STATUS_FAIL error codes by introducing a new
BT_STATUS_SOCKET_ERROR metric, to be used when an effort to find a
device by address or other identifier fails.

Bug: 340296381
Test: m -j
Flag: Exempt, metrics-only change

Change-Id: I030ea3e1545d6979f3634d89d3d6aefbdca619b2
parent 86c11fd1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@ class BtStatus(enum.IntEnum):
    BT_STATUS_TIMEOUT = 15
    DEVICE_NOT_FOUND = 16
    UNEXPECTED_STATE = 17
    SOCKET_ERROR = 18


class SocketType(enum.IntEnum):
+3 −3
Original line number Diff line number Diff line
@@ -127,7 +127,7 @@ error:;
  if (thread_handle != -1) btsock_thread_exit(thread_handle);
  thread_handle = -1;
  uid_set = NULL;
  return BT_STATUS_FAIL;
  return BT_STATUS_SOCKET_ERROR;
}

void btif_sock_cleanup(void) {
@@ -159,7 +159,7 @@ static bt_status_t btsock_listen(btsock_type_t type, const char* service_name,
  }

  *sock_fd = INVALID_FD;
  bt_status_t status = BT_STATUS_FAIL;
  bt_status_t status = BT_STATUS_SOCKET_ERROR;

  log::info(
      "Attempting listen for socket connections for device: {}, type: {}, "
@@ -214,7 +214,7 @@ static bt_status_t btsock_connect(const RawAddress* bd_addr, btsock_type_t type,
      *bd_addr, type, channel, app_uid);

  *sock_fd = INVALID_FD;
  bt_status_t status = BT_STATUS_FAIL;
  bt_status_t status = BT_STATUS_SOCKET_ERROR;

  btif_sock_connection_logger(*bd_addr, 0, type,
                              SOCKET_CONNECTION_STATE_CONNECTING,
+3 −3
Original line number Diff line number Diff line
@@ -840,7 +840,7 @@ static bt_status_t btsock_l2cap_listen_or_connect(const char* name,
        channel = 0;
      } else if (channel <= 0) {
        log::error("type BTSOCK_L2CAP_LE: invalid channel={}", channel);
        return BT_STATUS_FAIL;
        return BT_STATUS_SOCKET_ERROR;
      }
    } else {
      // Ensure device is in inquiry database during L2CAP CoC connection
@@ -1043,7 +1043,7 @@ bt_status_t btsock_l2cap_get_l2cap_local_cid(Uuid& conn_uuid, uint16_t* cid) {
  if (!sock) {
    log::error("Unable to find l2cap socket with conn_uuid:{}",
               conn_uuid.ToString());
    return BT_STATUS_FAIL;
    return BT_STATUS_SOCKET_ERROR;
  }
  *cid = sock->local_cid;
  return BT_STATUS_SUCCESS;
@@ -1057,7 +1057,7 @@ bt_status_t btsock_l2cap_get_l2cap_remote_cid(Uuid& conn_uuid, uint16_t* cid) {
  if (!sock) {
    log::error("Unable to find l2cap socket with conn_uuid:{}",
               conn_uuid.ToString());
    return BT_STATUS_FAIL;
    return BT_STATUS_SOCKET_ERROR;
  }
  *cid = sock->remote_cid;
  return BT_STATUS_SUCCESS;
+2 −2
Original line number Diff line number Diff line
@@ -390,13 +390,13 @@ bt_status_t btsock_rfc_connect(const RawAddress* bd_addr,
          "unable to initiate RFCOMM connection. status:{}, scn:{}, bd_addr:{}",
          bta_jv_status_text(ret), slot->scn, slot->addr);
      cleanup_rfc_slot(slot);
      return BT_STATUS_FAIL;
      return BT_STATUS_SOCKET_ERROR;
    }

    if (!send_app_scn(slot)) {
      log::error("send_app_scn() failed, closing slot->id:{}", slot->id);
      cleanup_rfc_slot(slot);
      return BT_STATUS_FAIL;
      return BT_STATUS_SOCKET_ERROR;
    }
  } else {
    log::info("service_uuid:{}, bd_addr:{}, slot_id:{}",
+3 −3
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ bt_status_t btsock_sco_init(thread_t* thread_) {
  log::assert_that(thread_ != NULL, "assert failed: thread_ != NULL");

  sco_sockets = list_new((list_free_cb)sco_socket_free_locked);
  if (!sco_sockets) return BT_STATUS_FAIL;
  if (!sco_sockets) return BT_STATUS_SOCKET_ERROR;

  thread = thread_;
  enh_esco_params_t params = esco_parameters_for_codec(SCO_CODEC_CVSD_D1, true);
@@ -108,7 +108,7 @@ bt_status_t btsock_sco_listen(int* sock_fd, int /* flags */) {
  std::unique_lock<std::mutex> lock(sco_lock);

  sco_socket_t* sco_socket = sco_socket_establish_locked(true, NULL, sock_fd);
  if (!sco_socket) return BT_STATUS_FAIL;
  if (!sco_socket) return BT_STATUS_SOCKET_ERROR;

  if (get_btm_client_interface().sco.BTM_RegForEScoEvts(
          sco_socket->sco_handle, connection_request_cb) != BTM_SUCCESS) {
@@ -128,7 +128,7 @@ bt_status_t btsock_sco_connect(const RawAddress* bd_addr, int* sock_fd,
  sco_socket_t* sco_socket =
      sco_socket_establish_locked(false, bd_addr, sock_fd);

  return (sco_socket != NULL) ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
  return (sco_socket != NULL) ? BT_STATUS_SUCCESS : BT_STATUS_SOCKET_ERROR;
}

// Must be called with |lock| held.
Loading