summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Pomai Ahlo <poahlo@google.com> 2025-02-03 15:43:16 -0800
committer Pomai Ahlo <poahlo@google.com> 2025-02-20 13:27:55 -0800
commite101f6ae5a31b10133d7d6f43bac888a87713e97 (patch)
tree951cc05d72c88b9ff9fc97eb90ca20cbfed2ddca
parent86d90eee9dd37eccdd19449b9d72b883df060f9b (diff)
RFCOMM Metrics V2: Collect at port closure
Collect metrics in system/stack/rfcomm after tPORT structure closes Bug: 374989690 Test: m com.android.bt && manual with Atom Tester Flag: EXEMPT metrics Change-Id: Idccdb2ab660e62a998d46293cea8495a761fa916
-rw-r--r--system/stack/Android.bp2
-rw-r--r--system/stack/BUILD.gn1
-rw-r--r--system/stack/rfcomm/port_rfc.cc2
-rw-r--r--system/test/Android.bp7
-rw-r--r--system/test/mock/mock_stack_rfcomm_metrics.cc21
5 files changed, 33 insertions, 0 deletions
diff --git a/system/stack/Android.bp b/system/stack/Android.bp
index d01c892197..e70eb30f96 100644
--- a/system/stack/Android.bp
+++ b/system/stack/Android.bp
@@ -294,6 +294,7 @@ cc_library_static {
"rfcomm/port_rfc.cc",
"rfcomm/port_utils.cc",
"rfcomm/rfc_l2cap_if.cc",
+ "rfcomm/rfc_metrics.cc",
"rfcomm/rfc_mx_fsm.cc",
"rfcomm/rfc_port_fsm.cc",
"rfcomm/rfc_port_if.cc",
@@ -869,6 +870,7 @@ cc_test {
":TestMockStackBtm",
":TestMockStackL2capInterface",
":TestMockStackMetrics",
+ ":TestMockStackRfcommMetrics",
"rfcomm/port_api.cc",
"rfcomm/port_rfc.cc",
"rfcomm/port_utils.cc",
diff --git a/system/stack/BUILD.gn b/system/stack/BUILD.gn
index ab902f7b5e..d078d1bc14 100644
--- a/system/stack/BUILD.gn
+++ b/system/stack/BUILD.gn
@@ -157,6 +157,7 @@ source_set("stack") {
"rfcomm/port_rfc.cc",
"rfcomm/port_utils.cc",
"rfcomm/rfc_l2cap_if.cc",
+ "rfcomm/rfc_metrics.cc",
"rfcomm/rfc_mx_fsm.cc",
"rfcomm/rfc_port_fsm.cc",
"rfcomm/rfc_port_if.cc",
diff --git a/system/stack/rfcomm/port_rfc.cc b/system/stack/rfcomm/port_rfc.cc
index 4dc7590d96..ac206257bf 100644
--- a/system/stack/rfcomm/port_rfc.cc
+++ b/system/stack/rfcomm/port_rfc.cc
@@ -40,6 +40,7 @@
#include "osi/include/mutex.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_uuid16.h"
+#include "stack/include/rfc_metrics.h"
#include "stack/include/stack_metrics_logging.h"
#include "stack/l2cap/l2c_int.h"
#include "stack/rfcomm/port_int.h"
@@ -1051,6 +1052,7 @@ void port_rfc_closed(tPORT* p_port, uint8_t res) {
rfc_set_state(RFC_STATE_CLOSED, p_port);
p_port->rfc.sm_cb.close_reason = static_cast<tPORT_RESULT>(res);
+ port_collect_attempt_metrics(p_port);
log::info(
"RFCOMM connection closed, port_handle={}, state={}, reason={}[{}], "
"UUID=0x{:x}, bd_addr={}, is_server={}",
diff --git a/system/test/Android.bp b/system/test/Android.bp
index 9ed0a083b5..fabb5e9847 100644
--- a/system/test/Android.bp
+++ b/system/test/Android.bp
@@ -298,6 +298,13 @@ filegroup {
}
filegroup {
+ name: "TestMockStackRfcommMetrics",
+ srcs: [
+ "mock/mock_stack_rfcomm_metrics.cc",
+ ],
+}
+
+filegroup {
name: "TestMockStackRnr",
srcs: [
"mock/mock_stack_rnr_interface.cc",
diff --git a/system/test/mock/mock_stack_rfcomm_metrics.cc b/system/test/mock/mock_stack_rfcomm_metrics.cc
new file mode 100644
index 0000000000..f44af222b1
--- /dev/null
+++ b/system/test/mock/mock_stack_rfcomm_metrics.cc
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2025 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "rfc_metrics.h"
+#include "stack/rfcomm/port_int.h"
+#include "test/common/mock_functions.h"
+
+void port_collect_attempt_metrics(tPORT* /* p_port */) { inc_func_call_count(__func__); }