summaryrefslogtreecommitdiff
path: root/osi
diff options
context:
space:
mode:
authorPavlin Radoslavov <pavlin@google.com>2016-02-17 15:42:38 -0800
committerAndre Eisenbach <eisenbach@google.com>2016-02-18 13:36:13 -0800
commit4e6b1c82b78aa17c887376c14cf323bed02e1fd4 (patch)
tree0a94bba3b8a347faecf7476389e7f1456514a5c2 /osi
parent0e888661a5dc23e516429b3e80f1f6a1aac12015 (diff)
downloadandroid-system-bt-4e6b1c82b78aa17c887376c14cf323bed02e1fd4.tar.gz
android-system-bt-4e6b1c82b78aa17c887376c14cf323bed02e1fd4.tar.xz
Add support for collecting A2DP Protobuf metrics
* Add new function metrics_a2dp_session() to connect A2DP metrics into Protobuf * Add new function btif_update_a2dp_metrics() that is called when the metrics should be callected * Add few more statistics to the BTIF media stats. Change-Id: I5862ac82e55b3546dc1fbde0c78cb4683e40d19e
Diffstat (limited to 'osi')
-rw-r--r--osi/include/metrics.h26
-rw-r--r--osi/src/metrics.cpp48
2 files changed, 69 insertions, 5 deletions
diff --git a/osi/include/metrics.h b/osi/include/metrics.h
index 85360f5..4855301 100644
--- a/osi/include/metrics.h
+++ b/osi/include/metrics.h
@@ -62,6 +62,32 @@ typedef enum {
void metrics_scan_event(bool start, const char *initator, scan_tech_t type,
uint32_t results, uint64_t timestamp_ms);
+// Record A2DP session information.
+// |session_duration_sec| is the session duration (in seconds).
+// |device_class| is the device class of the paired device.
+// |media_timer_min_ms| is the minimum scheduled time (in milliseconds)
+// of the media timer.
+// |media_timer_max_ms| is the maximum scheduled time (in milliseconds)
+// of the media timer.
+// |media_timer_avg_ms| is the average scheduled time (in milliseconds)
+// of the media timer.
+// |buffer_overruns_max_count| - TODO - not clear what this is.
+// |buffer_overruns_total| is the number of times the media buffer with
+// audio data has overrun.
+// |buffer_underruns_average| - TODO - not clear what this is.
+// |buffer_underruns_count| is the number of times there was no enough
+// audio data to add to the media buffer.
+void metrics_a2dp_session(int64_t session_duration_sec,
+ const char *disconnect_reason,
+ uint32_t device_class,
+ int32_t media_timer_min_ms,
+ int32_t media_timer_max_ms,
+ int32_t media_timer_avg_ms,
+ int32_t buffer_overruns_max_count,
+ int32_t buffer_overruns_total,
+ float buffer_underruns_average,
+ int32_t buffer_underruns_count);
+
// Writes the metrics, in packed protobuf format, into the descriptor |fd|.
// If |clear| is true, metrics events are cleared afterwards.
void metrics_write(int fd, bool clear);
diff --git a/osi/src/metrics.cpp b/osi/src/metrics.cpp
index c1ccfc4..63be98a 100644
--- a/osi/src/metrics.cpp
+++ b/osi/src/metrics.cpp
@@ -32,7 +32,9 @@ extern "C" {
#include <google/protobuf/text_format.h>
+using clearcut::connectivity::A2DPSession;
using clearcut::connectivity::BluetoothLog;
+using clearcut::connectivity::BluetoothSession;
using clearcut::connectivity::DeviceInfo;
using clearcut::connectivity::DeviceInfo_DeviceType;
using clearcut::connectivity::PairEvent;
@@ -74,11 +76,10 @@ void metrics_pair_event(uint32_t disconnect_reason, uint64_t timestamp_ms,
event->set_disconnect_reason(disconnect_reason);
event->set_event_time_millis(timestamp_ms);
-
}
void metrics_wake_event(wake_event_type_t type, const char *requestor,
- const char *name, uint64_t timestamp) {
+ const char *name, uint64_t timestamp_ms) {
lazy_initialize();
WakeEvent *event = pending->add_wake_event();
@@ -98,10 +99,9 @@ void metrics_wake_event(wake_event_type_t type, const char *requestor,
if (name)
event->set_name(name);
- event->set_event_time_millis(timestamp);
+ event->set_event_time_millis(timestamp_ms);
}
-
void metrics_scan_event(bool start, const char *initator, scan_tech_t type,
uint32_t results, uint64_t timestamp_ms) {
lazy_initialize();
@@ -116,7 +116,7 @@ void metrics_scan_event(bool start, const char *initator, scan_tech_t type,
if (initator)
event->set_initiator(initator);
- ScanEvent_ScanTechnologyType scantype = ScanEvent::SCAN_TYPE_UNKNOWN;
+ ScanEvent::ScanTechnologyType scantype = ScanEvent::SCAN_TYPE_UNKNOWN;
if (type == SCAN_TECH_TYPE_LE)
scantype = ScanEvent::SCAN_TECH_TYPE_LE;
@@ -132,6 +132,44 @@ void metrics_scan_event(bool start, const char *initator, scan_tech_t type,
event->set_event_time_millis(timestamp_ms);
}
+void metrics_a2dp_session(int64_t session_duration_sec,
+ const char *disconnect_reason,
+ uint32_t device_class,
+ int32_t media_timer_min_ms,
+ int32_t media_timer_max_ms,
+ int32_t media_timer_avg_ms,
+ int32_t buffer_overruns_max_count,
+ int32_t buffer_overruns_total,
+ float buffer_underruns_average,
+ int32_t buffer_underruns_count) {
+ lazy_initialize();
+
+ BluetoothSession *bt_session = pending->add_session();
+
+ // Set connection type: for A2DP it is always BR/EDR
+ BluetoothSession::ConnectionTechnologyType conn_type =
+ BluetoothSession::CONNECTION_TECHNOLOGY_TYPE_BREDR;
+ bt_session->set_connection_technology_type(conn_type);
+
+ bt_session->set_session_duration_sec(session_duration_sec);
+ if (disconnect_reason != NULL)
+ bt_session->set_disconnect_reason(disconnect_reason);
+
+ // Set device: class and type are pre-defined
+ DeviceInfo *info = bt_session->mutable_device_connected_to();
+ info->set_device_class(device_class);
+ info->set_device_type(DeviceInfo::DEVICE_TYPE_BREDR);
+
+ A2DPSession *a2dp_session = bt_session->mutable_a2dp_session();
+ a2dp_session->set_media_timer_min_millis(media_timer_min_ms);
+ a2dp_session->set_media_timer_max_millis(media_timer_max_ms);
+ a2dp_session->set_media_timer_avg_millis(media_timer_avg_ms);
+ a2dp_session->set_buffer_overruns_max_count(buffer_overruns_max_count);
+ a2dp_session->set_buffer_overruns_total(buffer_overruns_total);
+ a2dp_session->set_buffer_underruns_average(buffer_underruns_average);
+ a2dp_session->set_buffer_underruns_count(buffer_underruns_count);
+}
+
void metrics_write(int fd, bool clear) {
LOG_DEBUG(LOG_TAG, "%s serializing metrics", __func__);
lazy_initialize();