summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author floss-automerger <mdb.chromeos-bluetooth-floss-automerger@google.com> 2024-05-17 12:01:12 +0000
committer Sarvesh Kalwit <sarveshkalwit@google.com> 2024-06-13 14:55:22 +0000
commit86c11fd1dffa91496ad342102661c5f7ab79452c (patch)
tree7d87e3013a0afd6bb295c30678d8f2a2f1b77437
parentb7d0abce5529c025b43a822b7a77ec546b3a7f5a (diff)
libbluetooth: Add BT_STATUS_UNEXPECTED_STATE metric
Add granularity to BT_STATUS_FAIL error codes by introducing a new BT_STATUS_UNEXPECTED_STATE 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: I0b358f08821cb1904f828b1aa04b1855b41ec8df
-rw-r--r--floss/pandora/floss/floss_enums.py1
-rw-r--r--system/btif/src/bluetooth.cc2
-rw-r--r--system/btif/src/btif_hh.cc2
-rw-r--r--system/btif/src/btif_profile_queue.cc2
-rw-r--r--system/include/hardware/bluetooth.h5
5 files changed, 8 insertions, 4 deletions
diff --git a/floss/pandora/floss/floss_enums.py b/floss/pandora/floss/floss_enums.py
index c04dd4015d..5f5dc2cd87 100644
--- a/floss/pandora/floss/floss_enums.py
+++ b/floss/pandora/floss/floss_enums.py
@@ -135,6 +135,7 @@ class BtStatus(enum.IntEnum):
WAKE_LOCK_ERROR = 14
BT_STATUS_TIMEOUT = 15
DEVICE_NOT_FOUND = 16
+ UNEXPECTED_STATE = 17
class SocketType(enum.IntEnum):
diff --git a/system/btif/src/bluetooth.cc b/system/btif/src/bluetooth.cc
index 0a1c48d304..ffcc2f64ff 100644
--- a/system/btif/src/bluetooth.cc
+++ b/system/btif/src/bluetooth.cc
@@ -946,7 +946,7 @@ int dut_mode_configure(uint8_t enable) {
int dut_mode_send(uint16_t opcode, uint8_t* buf, uint8_t len) {
if (!interface_ready()) return BT_STATUS_NOT_READY;
- if (!btif_is_dut_mode()) return BT_STATUS_FAIL;
+ if (!btif_is_dut_mode()) return BT_STATUS_UNEXPECTED_STATE;
uint8_t* copy = (uint8_t*)osi_calloc(len);
memcpy(copy, buf, len);
diff --git a/system/btif/src/btif_hh.cc b/system/btif/src/btif_hh.cc
index bbc3a91735..af3a2779db 100644
--- a/system/btif/src/btif_hh.cc
+++ b/system/btif/src/btif_hh.cc
@@ -122,7 +122,7 @@ static tHID_KB_LIST hid_kb_numlock_on_list[] = {{LOGITECH_KB_MX5500_PRODUCT_ID,
do { \
if (btif_hh_cb.status == BTIF_HH_DISABLED) { \
log::error("HH status = {}", btif_hh_status_text(btif_hh_cb.status)); \
- return BT_STATUS_FAIL; \
+ return BT_STATUS_UNEXPECTED_STATE; \
} \
} while (0)
diff --git a/system/btif/src/btif_profile_queue.cc b/system/btif/src/btif_profile_queue.cc
index 91b1cf6064..95186a4390 100644
--- a/system/btif/src/btif_profile_queue.cc
+++ b/system/btif/src/btif_profile_queue.cc
@@ -191,7 +191,7 @@ bt_status_t btif_queue_connect_next(void) {
if (connect_queue.empty()) return BT_STATUS_FAIL;
if (!stack_manager_get_interface()->get_stack_is_running())
- return BT_STATUS_FAIL;
+ return BT_STATUS_UNEXPECTED_STATE;
ConnectNode& head = connect_queue.front();
diff --git a/system/include/hardware/bluetooth.h b/system/include/hardware/bluetooth.h
index 6e5ad22ac8..e4877d8cdb 100644
--- a/system/include/hardware/bluetooth.h
+++ b/system/include/hardware/bluetooth.h
@@ -108,7 +108,8 @@ typedef enum {
BT_STATUS_JNI_THREAD_ATTACH_ERROR,
BT_STATUS_WAKELOCK_ERROR,
BT_STATUS_TIMEOUT,
- BT_STATUS_DEVICE_NOT_FOUND
+ BT_STATUS_DEVICE_NOT_FOUND,
+ BT_STATUS_UNEXPECTED_STATE
} bt_status_t;
inline std::string bt_status_text(const bt_status_t& status) {
@@ -147,6 +148,8 @@ inline std::string bt_status_text(const bt_status_t& status) {
return std::string("timeout_error");
case BT_STATUS_DEVICE_NOT_FOUND:
return std::string("device_not_found");
+ case BT_STATUS_UNEXPECTED_STATE:
+ return std::string("unexpected_state");
default:
return std::string("UNKNOWN");
}