summaryrefslogtreecommitdiff
path: root/system/test
diff options
context:
space:
mode:
author Pomai Ahlo <poahlo@google.com> 2025-02-21 12:18:23 -0800
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2025-02-21 12:18:23 -0800
commit10dfe15ea08bfa1efc76b369b65dfcf676dda446 (patch)
tree089125b0cfabda712f5f6bcea4cdb150e425817a /system/test
parent40a0132ce9f2ad26a361d10a3ef0d59de16a73f5 (diff)
parente101f6ae5a31b10133d7d6f43bac888a87713e97 (diff)
Merge changes Idccdb2ab,Ie109fab6,Ie2de6f03 into main
* changes: RFCOMM Metrics V2: Collect at port closure RFCOMM metrics V2: Collect metrics in bta RFCOMM metrics V2: Add metrics functions
Diffstat (limited to 'system/test')
-rw-r--r--system/test/Android.bp15
-rw-r--r--system/test/mock/mock_bta_rfc_metrics.cc34
-rw-r--r--system/test/mock/mock_main_shim_metrics_api.cc13
-rw-r--r--system/test/mock/mock_main_shim_metrics_api.h37
-rw-r--r--system/test/mock/mock_stack_rfcomm_metrics.cc21
5 files changed, 120 insertions, 0 deletions
diff --git a/system/test/Android.bp b/system/test/Android.bp
index c965355dcc..fabb5e9847 100644
--- a/system/test/Android.bp
+++ b/system/test/Android.bp
@@ -142,6 +142,13 @@ filegroup {
}
filegroup {
+ name: "TestMockBtaRfcMetrics",
+ srcs: [
+ "mock/mock_bta_rfc_metrics.cc",
+ ],
+}
+
+filegroup {
name: "TestMockBtaScn",
srcs: [
"mock/mock_bta_scn.cc",
@@ -189,6 +196,7 @@ filegroup {
":TestMockBtaLeAudioHalVerifier",
":TestMockBtaPan",
":TestMockBtaRas",
+ ":TestMockBtaRfcMetrics",
":TestMockBtaSdp",
":TestMockBtaSys",
":TestMockBtaVc",
@@ -290,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_bta_rfc_metrics.cc b/system/test/mock/mock_bta_rfc_metrics.cc
new file mode 100644
index 0000000000..9c1c0cced2
--- /dev/null
+++ b/system/test/mock/mock_bta_rfc_metrics.cc
@@ -0,0 +1,34 @@
+/*
+ * 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 "bta/include/bta_jv_api.h"
+#include "bta/include/bta_rfcomm_metrics.h"
+#include "test/common/mock_functions.h"
+#include "types/raw_address.h"
+
+void bta_collect_rfc_metrics_after_sdp_fail(tBTA_JV_STATUS /* sdp_status */, RawAddress /* addr */,
+ int /* app_uid */, int /* security */,
+ bool /* is_server */, uint64_t /* sdp_duration */) {
+ inc_func_call_count(__func__);
+}
+
+void bta_collect_rfc_metrics_after_port_fail(tPORT_RESULT /* port_result */,
+ bool /* sdp_initiated */,
+ tBTA_JV_STATUS /* sdp_status */, RawAddress /* addr */,
+ int /* app_uid */, int /* security */,
+ bool /* is_server */, uint64_t /* sdp_duration_ms */) {
+ inc_func_call_count(__func__);
+}
diff --git a/system/test/mock/mock_main_shim_metrics_api.cc b/system/test/mock/mock_main_shim_metrics_api.cc
index ac64150797..908f258205 100644
--- a/system/test/mock/mock_main_shim_metrics_api.cc
+++ b/system/test/mock/mock_main_shim_metrics_api.cc
@@ -59,6 +59,7 @@ struct LogMetricLeConnectionStatus LogMetricLeConnectionStatus;
struct LogMetricLeDeviceInAcceptList LogMetricLeDeviceInAcceptList;
struct LogMetricLeConnectionLifecycle LogMetricLeConnectionLifecycle;
struct LogMetricLeConnectionCompletion LogMetricLeConnectionCompletion;
+struct LogMetricRfcommConnectionAtClose LogMetricRfcommConnectionAtClose;
} // namespace main_shim_metrics_api
} // namespace mock
@@ -215,4 +216,16 @@ void bluetooth::shim::LogMetricLeConnectionCompletion(bluetooth::hci::Address ad
test::mock::main_shim_metrics_api::LogMetricLeConnectionCompletion(address, reason,
is_locally_initiated);
}
+void bluetooth::shim::LogMetricRfcommConnectionAtClose(
+ const RawAddress& raw_address, android::bluetooth::rfcomm::PortResult close_reason,
+ android::bluetooth::rfcomm::SocketConnectionSecurity security,
+ android::bluetooth::rfcomm::RfcommPortEvent last_event,
+ android::bluetooth::rfcomm::RfcommPortState previous_state, int32_t open_duration_ms,
+ int32_t uid, android::bluetooth::BtaStatus sdp_status, bool is_server, bool sdp_initiated,
+ int32_t sdp_duration_ms) {
+ inc_func_call_count(__func__);
+ test::mock::main_shim_metrics_api::LogMetricRfcommConnectionAtClose(
+ raw_address, close_reason, security, last_event, previous_state, open_duration_ms, uid,
+ sdp_status, is_server, sdp_initiated, sdp_duration_ms);
+}
// END mockcify generation
diff --git a/system/test/mock/mock_main_shim_metrics_api.h b/system/test/mock/mock_main_shim_metrics_api.h
index 6b8d8e5edf..7e8df3c3c8 100644
--- a/system/test/mock/mock_main_shim_metrics_api.h
+++ b/system/test/mock/mock_main_shim_metrics_api.h
@@ -367,6 +367,43 @@ struct LogMetricLeConnectionCompletion {
};
extern struct LogMetricLeConnectionCompletion LogMetricLeConnectionCompletion;
+// Name: LogMetricRfcommConnectionAtClose
+// Params: const RawAddress& raw_address, android::bluetooth::rfcomm::PortResult close_reason,
+// android::bluetooth::rfcomm::SocketConnectionSecurity security,
+// android::bluetooth::rfcomm::RfcommPortEvent last_event,
+// android::bluetooth::rfcomm::RfcommPortState previous_state, int32_t open_duration_ms,
+// int32_t uid, android::bluetooth::BtaStatus sdp_status, bool is_server,
+// bool sdp_initiated, int32_t sdp_duration_ms
+// Returns: void
+struct LogMetricRfcommConnectionAtClose {
+ std::function<void(
+ const RawAddress& raw_address, android::bluetooth::rfcomm::PortResult close_reason,
+ android::bluetooth::rfcomm::SocketConnectionSecurity security,
+ android::bluetooth::rfcomm::RfcommPortEvent last_event,
+ android::bluetooth::rfcomm::RfcommPortState previous_state, int32_t open_duration_ms,
+ int32_t uid, android::bluetooth::BtaStatus sdp_status, bool is_server, bool sdp_initiated,
+ int32_t sdp_duration_ms)>
+ body{[](const RawAddress& /* raw_address */,
+ android::bluetooth::rfcomm::PortResult /* close_reason */,
+ android::bluetooth::rfcomm::SocketConnectionSecurity /* security */,
+ android::bluetooth::rfcomm::RfcommPortEvent /* last_event */,
+ android::bluetooth::rfcomm::RfcommPortState /* previous_state */,
+ int32_t /* open_duration_ms */, int32_t /* uid */,
+ android::bluetooth::BtaStatus /* sdp_status */, bool /* is_server */,
+ bool /* sdp_initiated */, int32_t /* sdp_duration_ms */) {}};
+ void operator()(const RawAddress& raw_address,
+ android::bluetooth::rfcomm::PortResult close_reason,
+ android::bluetooth::rfcomm::SocketConnectionSecurity security,
+ android::bluetooth::rfcomm::RfcommPortEvent last_event,
+ android::bluetooth::rfcomm::RfcommPortState previous_state,
+ int32_t open_duration_ms, int32_t uid, android::bluetooth::BtaStatus sdp_status,
+ bool is_server, bool sdp_initiated, int32_t sdp_duration_ms) {
+ body(raw_address, close_reason, security, last_event, previous_state, open_duration_ms, uid,
+ sdp_status, is_server, sdp_initiated, sdp_duration_ms);
+ }
+};
+extern struct LogMetricRfcommConnectionAtClose LogMetricRfcommConnectionAtClose;
+
} // namespace main_shim_metrics_api
} // namespace mock
} // namespace test
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__); }