summaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2025-03-17 17:29:03 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2025-03-17 17:29:03 -0700
commitf671dfcc02924a7450b51df0fca23b0611b41219 (patch)
treebc8047a36ffe5c52e64c0bd18da35d5338125e97 /system
parentb41c374ba55755f5622edbeb39b9d4874f8bf349 (diff)
parent4e9002e82ba8cfa305399e72299d61935e8c79d4 (diff)
Merge "system/common: Move remaining metrics to os/metrics.h" into main
Diffstat (limited to 'system')
-rw-r--r--system/bta/le_audio/metrics_collector.cc6
-rw-r--r--system/bta/le_audio/metrics_collector_test.cc10
-rw-r--r--system/btif/src/btif_a2dp_source.cc8
-rw-r--r--system/common/Android.bp11
-rw-r--r--system/common/BUILD.gn2
-rw-r--r--system/common/metrics.cc94
-rw-r--r--system/common/metrics.h66
-rw-r--r--system/common/metrics_linux.cc47
-rw-r--r--system/gd/Android.bp2
-rw-r--r--system/gd/os/android/metrics.cc56
-rw-r--r--system/gd/os/chromeos/metrics.cc14
-rw-r--r--system/gd/os/host/metrics.cc14
-rw-r--r--system/gd/os/linux/metrics.cc15
-rw-r--r--system/gd/os/metrics.h17
-rw-r--r--system/stack/acl/btm_acl.cc8
-rw-r--r--system/stack/btm/btm_sec.cc7
-rw-r--r--system/stack/btm/security_event_parser.cc7
-rw-r--r--system/stack/btu/btu_hcif.cc38
18 files changed, 150 insertions, 272 deletions
diff --git a/system/bta/le_audio/metrics_collector.cc b/system/bta/le_audio/metrics_collector.cc
index a4fb4a353d..24da2e085c 100644
--- a/system/bta/le_audio/metrics_collector.cc
+++ b/system/bta/le_audio/metrics_collector.cc
@@ -25,9 +25,9 @@
#include <unordered_map>
#include <vector>
-#include "common/metrics.h"
#include "hardware/bt_le_audio.h"
#include "le_audio_types.h"
+#include "os/metrics.h"
#include "types/raw_address.h"
namespace bluetooth::le_audio {
@@ -199,7 +199,7 @@ public:
device_address[i] = device_metric->address_;
}
- bluetooth::common::LogLeAudioConnectionSessionReported(
+ bluetooth::os::LogMetricLeAudioConnectionSessionReported(
group_size_, group_id_, connection_duration_nanos, device_connecting_offset_nanos,
device_connected_offset_nanos, device_connection_duration_nanos,
device_connection_statuses, device_disconnection_statuses, device_address,
@@ -278,7 +278,7 @@ void MetricsCollector::OnBroadcastStateChanged(bool started) {
broadcast_beginning_timepoint_ = std::chrono::high_resolution_clock::now();
} else {
auto broadcast_ending_timepoint_ = std::chrono::high_resolution_clock::now();
- bluetooth::common::LogLeAudioBroadcastSessionReported(
+ bluetooth::os::LogMetricLeAudioBroadcastSessionReported(
get_timedelta_nanos(broadcast_beginning_timepoint_, broadcast_ending_timepoint_));
broadcast_beginning_timepoint_ = kInvalidTimePoint;
}
diff --git a/system/bta/le_audio/metrics_collector_test.cc b/system/bta/le_audio/metrics_collector_test.cc
index c94db90ad6..199199bf8a 100644
--- a/system/bta/le_audio/metrics_collector_test.cc
+++ b/system/bta/le_audio/metrics_collector_test.cc
@@ -23,7 +23,7 @@
#include <cstdint>
#include <vector>
-#include "common/metrics.h"
+#include "os/metrics.h"
#include "types/raw_address.h"
using testing::_;
@@ -57,9 +57,9 @@ std::vector<int64_t> last_streaming_duration_nanos;
std::vector<int32_t> last_streaming_context_type;
namespace bluetooth {
-namespace common {
+namespace os {
-void LogLeAudioConnectionSessionReported(
+void LogMetricLeAudioConnectionSessionReported(
int32_t group_size, int32_t group_metric_id, int64_t connection_duration_nanos,
const std::vector<int64_t>& device_connecting_offset_nanos,
const std::vector<int64_t>& device_connected_offset_nanos,
@@ -85,11 +85,11 @@ void LogLeAudioConnectionSessionReported(
last_streaming_context_type = streaming_context_type;
}
-void LogLeAudioBroadcastSessionReported(int64_t duration_nanos) {
+void LogMetricLeAudioBroadcastSessionReported(int64_t duration_nanos) {
last_broadcast_duration_nanos = duration_nanos;
}
-} // namespace common
+} // namespace os
} // namespace bluetooth
namespace bluetooth::le_audio {
diff --git a/system/btif/src/btif_a2dp_source.cc b/system/btif/src/btif_a2dp_source.cc
index 20805a92bd..5bf2ef0d87 100644
--- a/system/btif/src/btif_a2dp_source.cc
+++ b/system/btif/src/btif_a2dp_source.cc
@@ -48,7 +48,6 @@
#include "btif_hf.h"
#include "btm_iso_api.h"
#include "common/message_loop_thread.h"
-#include "common/metrics.h"
#include "common/repeating_timer.h"
#include "common/time_util.h"
#include "hardware/bt_av.h"
@@ -1302,8 +1301,7 @@ static void btm_read_rssi_cb(void* data) {
return;
}
- bluetooth::shim::LogMetricReadRssiResult(result->rem_bda,
- bluetooth::common::kUnknownConnectionHandle,
+ bluetooth::shim::LogMetricReadRssiResult(result->rem_bda, bluetooth::os::kUnknownConnectionHandle,
result->hci_status, result->rssi);
log::warn("device: {}, rssi: {}", result->rem_bda, result->rssi);
@@ -1321,7 +1319,7 @@ static void btm_read_failed_contact_counter_cb(void* data) {
return;
}
bluetooth::shim::LogMetricReadFailedContactCounterResult(
- result->rem_bda, bluetooth::common::kUnknownConnectionHandle, result->hci_status,
+ result->rem_bda, bluetooth::os::kUnknownConnectionHandle, result->hci_status,
result->failed_contact_counter);
log::warn("device: {}, Failed Contact Counter: {}", result->rem_bda,
@@ -1340,7 +1338,7 @@ static void btm_read_tx_power_cb(void* data) {
return;
}
bluetooth::shim::LogMetricReadTxPowerLevelResult(result->rem_bda,
- bluetooth::common::kUnknownConnectionHandle,
+ bluetooth::os::kUnknownConnectionHandle,
result->hci_status, result->tx_power);
log::warn("device: {}, Tx Power: {}", result->rem_bda, result->tx_power);
diff --git a/system/common/Android.bp b/system/common/Android.bp
index c192613dbc..a22a733e75 100644
--- a/system/common/Android.bp
+++ b/system/common/Android.bp
@@ -32,17 +32,6 @@ cc_library_static {
canonical_path_from_root: false,
export_proto_headers: true,
},
- target: {
- android: {
- srcs: [
- "metrics.cc",
- ],
- static_libs: ["libstatslog_bt"],
- },
- host: {
- srcs: ["metrics_linux.cc"],
- },
- },
shared_libs: [
"libcrypto",
"libcutils",
diff --git a/system/common/BUILD.gn b/system/common/BUILD.gn
index 50ec9c1dd0..5b0852bd36 100644
--- a/system/common/BUILD.gn
+++ b/system/common/BUILD.gn
@@ -19,8 +19,6 @@ static_library("common") {
"address_obfuscator.cc",
"le_conn_params.cc",
"message_loop_thread.cc",
- "metric_id_allocator.cc",
- "metrics_linux.cc",
"os_utils.cc",
"repeating_timer.cc",
"stop_watch_legacy.cc",
diff --git a/system/common/metrics.cc b/system/common/metrics.cc
deleted file mode 100644
index c6c0977115..0000000000
--- a/system/common/metrics.cc
+++ /dev/null
@@ -1,94 +0,0 @@
-/******************************************************************************
- *
- * Copyright 2016 Google, Inc.
- *
- * 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 "common/metrics.h"
-
-#include <bluetooth/log.h>
-#include <frameworks/proto_logging/stats/enums/bluetooth/le/enums.pb.h>
-#include <statslog_bt.h>
-
-#include <cstdint>
-#include <vector>
-
-#include "main/shim/metric_id_api.h"
-#include "types/raw_address.h"
-
-namespace bluetooth {
-namespace common {
-
-void LogRemoteVersionInfo(uint16_t handle, uint8_t status, uint8_t version,
- uint16_t manufacturer_name, uint16_t subversion) {
- int ret = stats_write(BLUETOOTH_REMOTE_VERSION_INFO_REPORTED, handle, status, version,
- manufacturer_name, subversion);
- if (ret < 0) {
- log::warn(
- "failed for handle {}, status 0x{:x}, version 0x{:x}, "
- "manufacturer_name 0x{:x}, subversion 0x{:x}, error {}",
- handle, status, version, manufacturer_name, subversion, ret);
- }
-}
-
-void LogLeAudioConnectionSessionReported(
- int32_t group_size, int32_t group_metric_id, int64_t connection_duration_nanos,
- const std::vector<int64_t>& device_connecting_offset_nanos,
- const std::vector<int64_t>& device_connected_offset_nanos,
- const std::vector<int64_t>& device_connection_duration_nanos,
- const std::vector<int32_t>& device_connection_status,
- const std::vector<int32_t>& device_disconnection_status,
- const std::vector<RawAddress>& device_address,
- const std::vector<int64_t>& streaming_offset_nanos,
- const std::vector<int64_t>& streaming_duration_nanos,
- const std::vector<int32_t>& streaming_context_type) {
- std::vector<int32_t> device_metric_id(device_address.size());
- for (uint64_t i = 0; i < device_address.size(); i++) {
- if (!device_address[i].IsEmpty()) {
- device_metric_id[i] = bluetooth::shim::AllocateIdFromMetricIdAllocator(device_address[i]);
- } else {
- device_metric_id[i] = 0;
- }
- }
- int ret = stats_write(LE_AUDIO_CONNECTION_SESSION_REPORTED, group_size, group_metric_id,
- connection_duration_nanos, device_connecting_offset_nanos,
- device_connected_offset_nanos, device_connection_duration_nanos,
- device_connection_status, device_disconnection_status, device_metric_id,
- streaming_offset_nanos, streaming_duration_nanos, streaming_context_type);
- if (ret < 0) {
- log::warn(
- "failed for group {}device_connecting_offset_nanos[{}], "
- "device_connected_offset_nanos[{}], "
- "device_connection_duration_nanos[{}], device_connection_status[{}], "
- "device_disconnection_status[{}], device_metric_id[{}], "
- "streaming_offset_nanos[{}], streaming_duration_nanos[{}], "
- "streaming_context_type[{}]",
- group_metric_id, device_connecting_offset_nanos.size(),
- device_connected_offset_nanos.size(), device_connection_duration_nanos.size(),
- device_connection_status.size(), device_disconnection_status.size(),
- device_metric_id.size(), streaming_offset_nanos.size(), streaming_duration_nanos.size(),
- streaming_context_type.size());
- }
-}
-
-void LogLeAudioBroadcastSessionReported(int64_t duration_nanos) {
- int ret = stats_write(LE_AUDIO_BROADCAST_SESSION_REPORTED, duration_nanos);
- if (ret < 0) {
- log::warn("failed for duration={}", duration_nanos);
- }
-}
-
-} // namespace common
-} // namespace bluetooth
diff --git a/system/common/metrics.h b/system/common/metrics.h
deleted file mode 100644
index 4d5a234ce5..0000000000
--- a/system/common/metrics.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/******************************************************************************
- *
- * Copyright 2016 Google, Inc.
- *
- * 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.
- *
- ******************************************************************************/
-
-#pragma once
-
-#include <cstdint>
-#include <vector>
-
-#include "types/raw_address.h"
-
-namespace bluetooth {
-namespace common {
-
-/**
- * Unknown connection handle for metrics purpose
- */
-static const uint32_t kUnknownConnectionHandle = 0xFFFF;
-
-/**
- * Logs when we receive Bluetooth Read Remote Version Information Complete
- * Event from the remote device, as documented by the Bluetooth Core HCI
- * specification
- *
- * Reference: 5.0 Core Specification, Vol 2, Part E, Page 1118
- *
- * @param handle handle of associated ACL connection
- * @param status HCI command status of this event
- * @param version version code from read remote version complete event
- * @param manufacturer_name manufacturer code from read remote version complete
- * event
- * @param subversion subversion code from read remote version complete event
- */
-void LogRemoteVersionInfo(uint16_t handle, uint8_t status, uint8_t version,
- uint16_t manufacturer_name, uint16_t subversion);
-
-void LogLeAudioConnectionSessionReported(
- int32_t group_size, int32_t group_metric_id, int64_t connection_duration_nanos,
- const std::vector<int64_t>& device_connecting_offset_nanos,
- const std::vector<int64_t>& device_connected_offset_nanos,
- const std::vector<int64_t>& device_connection_duration_nanos,
- const std::vector<int32_t>& device_connection_status,
- const std::vector<int32_t>& device_disconnection_status,
- const std::vector<RawAddress>& device_address,
- const std::vector<int64_t>& streaming_offset_nanos,
- const std::vector<int64_t>& streaming_duration_nanos,
- const std::vector<int32_t>& streaming_context_type);
-
-void LogLeAudioBroadcastSessionReported(int64_t duration_nanos);
-
-} // namespace common
-} // namespace bluetooth
diff --git a/system/common/metrics_linux.cc b/system/common/metrics_linux.cc
deleted file mode 100644
index e886c05bf3..0000000000
--- a/system/common/metrics_linux.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-/******************************************************************************
- *
- * Copyright 2018 Google, Inc.
- *
- * 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 <cstdint>
-#include <vector>
-
-#include "common/metrics.h"
-#include "types/raw_address.h"
-
-namespace bluetooth {
-namespace common {
-
-void LogRemoteVersionInfo(uint16_t /* handle */, uint8_t /* status */, uint8_t /* version */,
- uint16_t /* manufacturer_name */, uint16_t /* subversion */) {}
-
-void LogLeAudioConnectionSessionReported(
- int32_t /* group_size */, int32_t /* group_metric_id */,
- int64_t /* connection_duration_nanos */,
- const std::vector<int64_t>& /* device_connecting_offset_nanos */,
- const std::vector<int64_t>& /* device_connected_offset_nanos */,
- const std::vector<int64_t>& /* device_connection_duration_nanos */,
- const std::vector<int32_t>& /* device_connection_status */,
- const std::vector<int32_t>& /* device_disconnection_status */,
- const std::vector<RawAddress>& /* device_address */,
- const std::vector<int64_t>& /* streaming_offset_nanos */,
- const std::vector<int64_t>& /* streaming_duration_nanos */,
- const std::vector<int32_t>& /* streaming_context_type */) {}
-
-void LogLeAudioBroadcastSessionReported(int64_t /* duration_nanos */) {}
-
-} // namespace common
-} // namespace bluetooth
diff --git a/system/gd/Android.bp b/system/gd/Android.bp
index 9a6bd02551..45555f130a 100644
--- a/system/gd/Android.bp
+++ b/system/gd/Android.bp
@@ -194,7 +194,7 @@ cc_library_static {
"packages/modules/Bluetooth/system",
],
apex_available: ["com.android.bt"],
- min_sdk_version: "31",
+ min_sdk_version: "33",
static_libs: [
"bluetooth_flags_c_lib",
"libchrome",
diff --git a/system/gd/os/android/metrics.cc b/system/gd/os/android/metrics.cc
index 78b12c8d96..5f5b34ef2e 100644
--- a/system/gd/os/android/metrics.cc
+++ b/system/gd/os/android/metrics.cc
@@ -122,11 +122,9 @@ void LogMetricRemoteVersionInfo(uint16_t handle, uint8_t status, uint8_t version
manufacturer_name, subversion);
if (ret < 0) {
log::warn(
- "Failed for handle {}, status {}, version {}, manufacturer_name {}, subversion {}, "
- "error "
- "{}",
- handle, common::ToHexString(status), common::ToHexString(version),
- common::ToHexString(manufacturer_name), common::ToHexString(subversion), ret);
+ "failed for handle {}, status 0x{:x}, version 0x{:x}, "
+ "manufacturer_name 0x{:x}, subversion 0x{:x}, error {}",
+ handle, status, version, manufacturer_name, subversion, ret);
}
}
@@ -526,5 +524,53 @@ void LogMetricRfcommConnectionAtClose(const Address& address,
}
}
+void LogMetricLeAudioConnectionSessionReported(
+ int32_t group_size, int32_t group_metric_id, int64_t connection_duration_nanos,
+ const std::vector<int64_t>& device_connecting_offset_nanos,
+ const std::vector<int64_t>& device_connected_offset_nanos,
+ const std::vector<int64_t>& device_connection_duration_nanos,
+ const std::vector<int32_t>& device_connection_status,
+ const std::vector<int32_t>& device_disconnection_status,
+ const std::vector<RawAddress>& device_address,
+ const std::vector<int64_t>& streaming_offset_nanos,
+ const std::vector<int64_t>& streaming_duration_nanos,
+ const std::vector<int32_t>& streaming_context_type) {
+ std::vector<int32_t> device_metric_id(device_address.size());
+ for (uint64_t i = 0; i < device_address.size(); i++) {
+ if (!device_address[i].IsEmpty()) {
+ device_metric_id[i] =
+ MetricIdManager::GetInstance().AllocateId(ToGdAddress(device_address[i]));
+ } else {
+ device_metric_id[i] = 0;
+ }
+ }
+ int ret = stats_write(LE_AUDIO_CONNECTION_SESSION_REPORTED, group_size, group_metric_id,
+ connection_duration_nanos, device_connecting_offset_nanos,
+ device_connected_offset_nanos, device_connection_duration_nanos,
+ device_connection_status, device_disconnection_status, device_metric_id,
+ streaming_offset_nanos, streaming_duration_nanos, streaming_context_type);
+ if (ret < 0) {
+ log::warn(
+ "failed for group {}device_connecting_offset_nanos[{}], "
+ "device_connected_offset_nanos[{}], "
+ "device_connection_duration_nanos[{}], device_connection_status[{}], "
+ "device_disconnection_status[{}], device_metric_id[{}], "
+ "streaming_offset_nanos[{}], streaming_duration_nanos[{}], "
+ "streaming_context_type[{}]",
+ group_metric_id, device_connecting_offset_nanos.size(),
+ device_connected_offset_nanos.size(), device_connection_duration_nanos.size(),
+ device_connection_status.size(), device_disconnection_status.size(),
+ device_metric_id.size(), streaming_offset_nanos.size(), streaming_duration_nanos.size(),
+ streaming_context_type.size());
+ }
+}
+
+void LogMetricLeAudioBroadcastSessionReported(int64_t duration_nanos) {
+ int ret = stats_write(LE_AUDIO_BROADCAST_SESSION_REPORTED, duration_nanos);
+ if (ret < 0) {
+ log::warn("failed for duration={}", duration_nanos);
+ }
+}
+
} // namespace os
} // namespace bluetooth
diff --git a/system/gd/os/chromeos/metrics.cc b/system/gd/os/chromeos/metrics.cc
index b7921fe308..de36a98780 100644
--- a/system/gd/os/chromeos/metrics.cc
+++ b/system/gd/os/chromeos/metrics.cc
@@ -216,5 +216,19 @@ void LogMetricRfcommConnectionAtClose(
android::bluetooth::BtaStatus /* sdp_status */, bool /* is_server */,
bool /* sdp_initiated */, int32_t /* sdp_duration_ms */) {}
+void LogMetricLeAudioConnectionSessionReported(
+ int32_t /*group_size*/, int32_t /*group_metric_id*/, int64_t /*connection_duration_nanos*/,
+ const std::vector<int64_t>& /*device_connecting_offset_nanos*/,
+ const std::vector<int64_t>& /*device_connected_offset_nanos*/,
+ const std::vector<int64_t>& /*device_connection_duration_nanos*/,
+ const std::vector<int32_t>& /*device_connection_status*/,
+ const std::vector<int32_t>& /*device_disconnection_status*/,
+ const std::vector<RawAddress>& /*device_address*/,
+ const std::vector<int64_t>& /*streaming_offset_nanos*/,
+ const std::vector<int64_t>& /*streaming_duration_nanos*/,
+ const std::vector<int32_t>& /*streaming_context_type*/) {}
+
+void LogMetricLeAudioBroadcastSessionReported(int64_t /*duration_nanos*/) {}
+
} // namespace os
} // namespace bluetooth
diff --git a/system/gd/os/host/metrics.cc b/system/gd/os/host/metrics.cc
index a333113238..518a29ffee 100644
--- a/system/gd/os/host/metrics.cc
+++ b/system/gd/os/host/metrics.cc
@@ -135,5 +135,19 @@ void LogMetricRfcommConnectionAtClose(
android::bluetooth::BtaStatus /* sdp_status */, bool /* is_server */,
bool /* sdp_initiated */, int32_t /* sdp_duration_ms */) {}
+void LogMetricLeAudioConnectionSessionReported(
+ int32_t /*group_size*/, int32_t /*group_metric_id*/, int64_t /*connection_duration_nanos*/,
+ const std::vector<int64_t>& /*device_connecting_offset_nanos*/,
+ const std::vector<int64_t>& /*device_connected_offset_nanos*/,
+ const std::vector<int64_t>& /*device_connection_duration_nanos*/,
+ const std::vector<int32_t>& /*device_connection_status*/,
+ const std::vector<int32_t>& /*device_disconnection_status*/,
+ const std::vector<RawAddress>& /*device_address*/,
+ const std::vector<int64_t>& /*streaming_offset_nanos*/,
+ const std::vector<int64_t>& /*streaming_duration_nanos*/,
+ const std::vector<int32_t>& /*streaming_context_type*/) {}
+
+void LogMetricLeAudioBroadcastSessionReported(int64_t /*duration_nanos*/) {}
+
} // namespace os
} // namespace bluetooth
diff --git a/system/gd/os/linux/metrics.cc b/system/gd/os/linux/metrics.cc
index 7b727f38f2..f5d1555075 100644
--- a/system/gd/os/linux/metrics.cc
+++ b/system/gd/os/linux/metrics.cc
@@ -122,5 +122,20 @@ void LogMetricRfcommConnectionAtClose(const Address& raw_address,
void LogMetricBluetoothEvent(const Address& address, android::bluetooth::EventType event_type,
android::bluetooth::State state) {}
+
+void LogMetricLeAudioConnectionSessionReported(
+ int32_t /*group_size*/, int32_t /*group_metric_id*/, int64_t /*connection_duration_nanos*/,
+ const std::vector<int64_t>& /*device_connecting_offset_nanos*/,
+ const std::vector<int64_t>& /*device_connected_offset_nanos*/,
+ const std::vector<int64_t>& /*device_connection_duration_nanos*/,
+ const std::vector<int32_t>& /*device_connection_status*/,
+ const std::vector<int32_t>& /*device_disconnection_status*/,
+ const std::vector<RawAddress>& /*device_address*/,
+ const std::vector<int64_t>& /*streaming_offset_nanos*/,
+ const std::vector<int64_t>& /*streaming_duration_nanos*/,
+ const std::vector<int32_t>& /*streaming_context_type*/) {}
+
+void LogMetricLeAudioBroadcastSessionReported(int64_t /*duration_nanos*/) {}
+
} // namespace os
} // namespace bluetooth
diff --git a/system/gd/os/metrics.h b/system/gd/os/metrics.h
index aab82826e6..04b5c37e84 100644
--- a/system/gd/os/metrics.h
+++ b/system/gd/os/metrics.h
@@ -29,8 +29,8 @@
#include "types/raw_address.h"
namespace bluetooth {
-
namespace os {
+
/**
* Unknown connection handle for metrics purpose
*/
@@ -379,6 +379,19 @@ void LogMetricRfcommConnectionAtClose(const hci::Address& address,
android::bluetooth::BtaStatus sdp_status, bool is_server,
bool sdp_initiated, int32_t sdp_duration_ms);
+void LogMetricLeAudioConnectionSessionReported(
+ int32_t group_size, int32_t group_metric_id, int64_t connection_duration_nanos,
+ const std::vector<int64_t>& device_connecting_offset_nanos,
+ const std::vector<int64_t>& device_connected_offset_nanos,
+ const std::vector<int64_t>& device_connection_duration_nanos,
+ const std::vector<int32_t>& device_connection_status,
+ const std::vector<int32_t>& device_disconnection_status,
+ const std::vector<RawAddress>& device_address,
+ const std::vector<int64_t>& streaming_offset_nanos,
+ const std::vector<int64_t>& streaming_duration_nanos,
+ const std::vector<int32_t>& streaming_context_type);
+
+void LogMetricLeAudioBroadcastSessionReported(int64_t duration_nanos);
+
} // namespace os
- //
} // namespace bluetooth
diff --git a/system/stack/acl/btm_acl.cc b/system/stack/acl/btm_acl.cc
index 69afab3bfa..1a4c292d55 100644
--- a/system/stack/acl/btm_acl.cc
+++ b/system/stack/acl/btm_acl.cc
@@ -41,7 +41,6 @@
#include "bta/gatt/bta_gattc_int.h"
#include "bta/include/bta_dm_acl.h"
#include "bta/sys/bta_sys.h"
-#include "common/metrics.h"
#include "device/include/device_iot_config.h"
#include "device/include/interop.h"
#include "hci/controller_interface.h"
@@ -51,6 +50,7 @@
#include "main/shim/dumpsys.h"
#include "main/shim/entry.h"
#include "main/shim/helpers.h"
+#include "os/metrics.h"
#include "os/parameter_provider.h"
#include "osi/include/allocator.h"
#include "osi/include/properties.h"
@@ -785,10 +785,10 @@ static void btm_process_remote_version_complete(uint8_t status, uint16_t handle,
p_acl_cb->remote_version_info.valid = true;
BTM_update_version_info(p_acl_cb->RemoteAddress(), p_acl_cb->remote_version_info);
- bluetooth::common::LogRemoteVersionInfo(handle, status, lmp_version, manufacturer,
- lmp_subversion);
+ bluetooth::os::LogMetricRemoteVersionInfo(handle, status, lmp_version, manufacturer,
+ lmp_subversion);
} else {
- bluetooth::common::LogRemoteVersionInfo(handle, status, 0, 0, 0);
+ bluetooth::os::LogMetricRemoteVersionInfo(handle, status, 0, 0, 0);
}
}
diff --git a/system/stack/btm/btm_sec.cc b/system/stack/btm/btm_sec.cc
index 6244b951c6..4595794cab 100644
--- a/system/stack/btm/btm_sec.cc
+++ b/system/stack/btm/btm_sec.cc
@@ -38,7 +38,6 @@
#include "bta/dm/bta_dm_act.h"
#include "bta/dm/bta_dm_sec_int.h"
#include "btif/include/btif_storage.h"
-#include "common/metrics.h"
#include "common/time_util.h"
#include "device/include/device_iot_config.h"
#include "device/include/interop.h"
@@ -49,6 +48,7 @@
#include "main/shim/helpers.h"
#include "main/shim/metrics_api.h"
#include "metrics/bluetooth_event.h"
+#include "os/metrics.h"
#include "osi/include/allocator.h"
#include "osi/include/properties.h"
#include "stack/btm/btm_ble_int.h"
@@ -1924,9 +1924,8 @@ void btm_create_conn_cancel_complete(uint8_t status, const RawAddress bd_addr) {
log::verbose("btm_create_conn_cancel_complete(): in State: {} status:{}",
tBTM_SEC_CB::btm_pair_state_descr(btm_sec_cb.pairing_state), status);
bluetooth::shim::LogMetricLinkLayerConnectionEvent(
- &bd_addr, bluetooth::common::kUnknownConnectionHandle,
- android::bluetooth::DIRECTION_OUTGOING, android::bluetooth::LINK_TYPE_ACL,
- android::bluetooth::hci::CMD_CREATE_CONNECTION_CANCEL,
+ &bd_addr, bluetooth::os::kUnknownConnectionHandle, android::bluetooth::DIRECTION_OUTGOING,
+ android::bluetooth::LINK_TYPE_ACL, android::bluetooth::hci::CMD_CREATE_CONNECTION_CANCEL,
android::bluetooth::hci::EVT_COMMAND_COMPLETE, android::bluetooth::hci::BLE_EVT_UNKNOWN,
status, android::bluetooth::hci::STATUS_UNKNOWN);
diff --git a/system/stack/btm/security_event_parser.cc b/system/stack/btm/security_event_parser.cc
index deba84b67f..b107a69cb8 100644
--- a/system/stack/btm/security_event_parser.cc
+++ b/system/stack/btm/security_event_parser.cc
@@ -22,10 +22,10 @@
#include <string>
#include "btm_sec.h"
-#include "common/metrics.h"
#include "hci/hci_packets.h"
#include "main/shim/helpers.h"
#include "main/shim/metrics_api.h"
+#include "os/metrics.h"
#include "stack/include/btm_sec_api_types.h"
#include "stack/include/hci_error_code.h"
#include "stack/include/sec_hci_link_interface.h"
@@ -35,7 +35,6 @@ using namespace bluetooth;
using namespace bluetooth::hci;
using android::bluetooth::hci::CMD_UNKNOWN;
using android::bluetooth::hci::STATUS_UNKNOWN;
-using bluetooth::common::kUnknownConnectionHandle;
namespace bluetooth::stack::btm {
namespace {
@@ -44,7 +43,7 @@ static void log_address_and_status(const Address& bda, EventCode event_code,
uint32_t cmd = android::bluetooth::hci::CMD_UNKNOWN;
uint16_t status = static_cast<uint16_t>(event_status);
uint16_t reason = android::bluetooth::hci::STATUS_UNKNOWN;
- uint16_t handle = bluetooth::common::kUnknownConnectionHandle;
+ uint16_t handle = bluetooth::os::kUnknownConnectionHandle;
int64_t value = 0;
bluetooth::shim::LogMetricClassicPairingEvent(
ToRawAddress(bda), handle, cmd, static_cast<uint16_t>(event_code), status, reason, value);
@@ -53,7 +52,7 @@ static void log_address(const Address& bda, EventCode event_code) {
uint32_t cmd = android::bluetooth::hci::CMD_UNKNOWN;
uint16_t status = android::bluetooth::hci::STATUS_UNKNOWN;
uint16_t reason = android::bluetooth::hci::STATUS_UNKNOWN;
- uint16_t handle = bluetooth::common::kUnknownConnectionHandle;
+ uint16_t handle = bluetooth::os::kUnknownConnectionHandle;
int64_t value = 0;
bluetooth::shim::LogMetricClassicPairingEvent(
ToRawAddress(bda), handle, cmd, static_cast<uint16_t>(event_code), status, reason, value);
diff --git a/system/stack/btu/btu_hcif.cc b/system/stack/btu/btu_hcif.cc
index ee3c9757a5..367c8a89c8 100644
--- a/system/stack/btu/btu_hcif.cc
+++ b/system/stack/btu/btu_hcif.cc
@@ -37,10 +37,10 @@
#include <cstdint>
#include "btm_iso_api.h"
-#include "common/metrics.h"
#include "internal_include/bt_target.h"
#include "main/shim/hci_layer.h"
#include "main/shim/metrics_api.h"
+#include "os/metrics.h"
#include "osi/include/allocator.h"
#include "stack/include/acl_api.h"
#include "stack/include/acl_hci_link_interface.h"
@@ -110,7 +110,7 @@ static void btu_hcif_log_event_metrics(uint8_t evt_code, const uint8_t* p_event)
uint32_t cmd = android::bluetooth::hci::CMD_UNKNOWN;
uint16_t status = android::bluetooth::hci::STATUS_UNKNOWN;
uint16_t reason = android::bluetooth::hci::STATUS_UNKNOWN;
- uint16_t handle = bluetooth::common::kUnknownConnectionHandle;
+ uint16_t handle = bluetooth::os::kUnknownConnectionHandle;
int64_t value = 0;
RawAddress bda = RawAddress::kEmpty;
@@ -375,7 +375,7 @@ static void btu_hcif_log_command_metrics(uint16_t opcode, const uint8_t* p_cmd,
case HCI_CREATE_CONNECTION_CANCEL:
STREAM_TO_BDADDR(bd_addr, p_cmd);
bluetooth::shim::LogMetricLinkLayerConnectionEvent(
- &bd_addr, bluetooth::common::kUnknownConnectionHandle,
+ &bd_addr, bluetooth::os::kUnknownConnectionHandle,
android::bluetooth::DIRECTION_OUTGOING, android::bluetooth::LINK_TYPE_ACL, opcode,
hci_event, kUnknownBleEvt, cmd_status, android::bluetooth::hci::STATUS_UNKNOWN);
break;
@@ -400,7 +400,7 @@ static void btu_hcif_log_command_metrics(uint16_t opcode, const uint8_t* p_cmd,
case HCI_ENH_ACCEPT_ESCO_CONNECTION:
STREAM_TO_BDADDR(bd_addr, p_cmd);
bluetooth::shim::LogMetricLinkLayerConnectionEvent(
- &bd_addr, bluetooth::common::kUnknownConnectionHandle,
+ &bd_addr, bluetooth::os::kUnknownConnectionHandle,
android::bluetooth::DIRECTION_INCOMING, android::bluetooth::LINK_TYPE_UNKNOWN, opcode,
hci_event, kUnknownBleEvt, cmd_status, android::bluetooth::hci::STATUS_UNKNOWN);
break;
@@ -409,7 +409,7 @@ static void btu_hcif_log_command_metrics(uint16_t opcode, const uint8_t* p_cmd,
STREAM_TO_BDADDR(bd_addr, p_cmd);
STREAM_TO_UINT8(reason, p_cmd);
bluetooth::shim::LogMetricLinkLayerConnectionEvent(
- &bd_addr, bluetooth::common::kUnknownConnectionHandle,
+ &bd_addr, bluetooth::os::kUnknownConnectionHandle,
android::bluetooth::DIRECTION_INCOMING, android::bluetooth::LINK_TYPE_UNKNOWN, opcode,
hci_event, kUnknownBleEvt, cmd_status, reason);
break;
@@ -439,7 +439,7 @@ static void btu_hcif_log_command_metrics(uint16_t opcode, const uint8_t* p_cmd,
// - When doing non-acceptlist connection
// - When there is an error in command status
bluetooth::shim::LogMetricLinkLayerConnectionEvent(
- bd_addr_p, bluetooth::common::kUnknownConnectionHandle,
+ bd_addr_p, bluetooth::os::kUnknownConnectionHandle,
android::bluetooth::DIRECTION_OUTGOING, android::bluetooth::LINK_TYPE_ACL, opcode,
hci_event, kUnknownBleEvt, cmd_status, android::bluetooth::hci::STATUS_UNKNOWN);
}
@@ -464,7 +464,7 @@ static void btu_hcif_log_command_metrics(uint16_t opcode, const uint8_t* p_cmd,
// - When doing non-acceptlist connection
// - When there is an error in command status
bluetooth::shim::LogMetricLinkLayerConnectionEvent(
- bd_addr_p, bluetooth::common::kUnknownConnectionHandle,
+ bd_addr_p, bluetooth::os::kUnknownConnectionHandle,
android::bluetooth::DIRECTION_OUTGOING, android::bluetooth::LINK_TYPE_ACL, opcode,
hci_event, kUnknownBleEvt, cmd_status, android::bluetooth::hci::STATUS_UNKNOWN);
}
@@ -474,7 +474,7 @@ static void btu_hcif_log_command_metrics(uint16_t opcode, const uint8_t* p_cmd,
if (cmd_status != HCI_SUCCESS && !is_cmd_status) {
// Only log errors to prevent log spam due to acceptlist connections
bluetooth::shim::LogMetricLinkLayerConnectionEvent(
- nullptr, bluetooth::common::kUnknownConnectionHandle,
+ nullptr, bluetooth::os::kUnknownConnectionHandle,
android::bluetooth::DIRECTION_OUTGOING, android::bluetooth::LINK_TYPE_ACL, opcode,
hci_event, kUnknownBleEvt, cmd_status, android::bluetooth::hci::STATUS_UNKNOWN);
}
@@ -482,14 +482,14 @@ static void btu_hcif_log_command_metrics(uint16_t opcode, const uint8_t* p_cmd,
case HCI_READ_LOCAL_OOB_DATA:
case HCI_READ_LOCAL_OOB_EXTENDED_DATA:
bluetooth::shim::LogMetricClassicPairingEvent(
- RawAddress::kEmpty, bluetooth::common::kUnknownConnectionHandle, opcode, hci_event,
+ RawAddress::kEmpty, bluetooth::os::kUnknownConnectionHandle, opcode, hci_event,
cmd_status, android::bluetooth::hci::STATUS_UNKNOWN, 0);
break;
case HCI_WRITE_SIMPLE_PAIRING_MODE: {
uint8_t simple_pairing_mode;
STREAM_TO_UINT8(simple_pairing_mode, p_cmd);
bluetooth::shim::LogMetricClassicPairingEvent(
- RawAddress::kEmpty, bluetooth::common::kUnknownConnectionHandle, opcode, hci_event,
+ RawAddress::kEmpty, bluetooth::os::kUnknownConnectionHandle, opcode, hci_event,
cmd_status, android::bluetooth::hci::STATUS_UNKNOWN, simple_pairing_mode);
break;
}
@@ -497,7 +497,7 @@ static void btu_hcif_log_command_metrics(uint16_t opcode, const uint8_t* p_cmd,
uint8_t secure_conn_host_support;
STREAM_TO_UINT8(secure_conn_host_support, p_cmd);
bluetooth::shim::LogMetricClassicPairingEvent(
- RawAddress::kEmpty, bluetooth::common::kUnknownConnectionHandle, opcode, hci_event,
+ RawAddress::kEmpty, bluetooth::os::kUnknownConnectionHandle, opcode, hci_event,
cmd_status, android::bluetooth::hci::STATUS_UNKNOWN, secure_conn_host_support);
break;
}
@@ -521,7 +521,7 @@ static void btu_hcif_log_command_metrics(uint16_t opcode, const uint8_t* p_cmd,
STREAM_TO_BDADDR(bd_addr, p_cmd);
STREAM_TO_UINT8(delete_all_flag, p_cmd);
bluetooth::shim::LogMetricClassicPairingEvent(
- bd_addr, bluetooth::common::kUnknownConnectionHandle, opcode, hci_event, cmd_status,
+ bd_addr, bluetooth::os::kUnknownConnectionHandle, opcode, hci_event, cmd_status,
android::bluetooth::hci::STATUS_UNKNOWN, delete_all_flag);
break;
}
@@ -538,15 +538,15 @@ static void btu_hcif_log_command_metrics(uint16_t opcode, const uint8_t* p_cmd,
case HCI_REM_OOB_DATA_REQ_NEG_REPLY:
STREAM_TO_BDADDR(bd_addr, p_cmd);
bluetooth::shim::LogMetricClassicPairingEvent(
- bd_addr, bluetooth::common::kUnknownConnectionHandle, opcode, hci_event, cmd_status,
+ bd_addr, bluetooth::os::kUnknownConnectionHandle, opcode, hci_event, cmd_status,
android::bluetooth::hci::STATUS_UNKNOWN, 0);
break;
case HCI_IO_CAP_REQ_NEG_REPLY:
STREAM_TO_BDADDR(bd_addr, p_cmd);
STREAM_TO_UINT8(reason, p_cmd);
bluetooth::shim::LogMetricClassicPairingEvent(bd_addr,
- bluetooth::common::kUnknownConnectionHandle,
- opcode, hci_event, cmd_status, reason, 0);
+ bluetooth::os::kUnknownConnectionHandle, opcode,
+ hci_event, cmd_status, reason, 0);
break;
}
}
@@ -611,8 +611,8 @@ static void btu_hcif_log_command_complete_metrics(uint16_t opcode, const uint8_t
case HCI_WRITE_SECURE_CONNS_SUPPORT:
STREAM_TO_UINT8(status, p_return_params);
bluetooth::shim::LogMetricClassicPairingEvent(RawAddress::kEmpty,
- bluetooth::common::kUnknownConnectionHandle,
- opcode, hci_event, status, reason, 0);
+ bluetooth::os::kUnknownConnectionHandle, opcode,
+ hci_event, status, reason, 0);
break;
case HCI_READ_ENCR_KEY_SIZE: {
uint16_t handle;
@@ -637,8 +637,8 @@ static void btu_hcif_log_command_complete_metrics(uint16_t opcode, const uint8_t
STREAM_TO_UINT8(status, p_return_params);
STREAM_TO_BDADDR(bd_addr, p_return_params);
bluetooth::shim::LogMetricClassicPairingEvent(bd_addr,
- bluetooth::common::kUnknownConnectionHandle,
- opcode, hci_event, status, reason, 0);
+ bluetooth::os::kUnknownConnectionHandle, opcode,
+ hci_event, status, reason, 0);
break;
}
}