From 9bebcc0605038ea590b720c3722d89ee833817c5 Mon Sep 17 00:00:00 2001 From: Jack He <siyuanh@google.com> Date: Tue, 17 Jan 2017 15:41:30 -0800 Subject: [PATCH] Fix A2DP Metrics Logging Capacity * Set the maximum number of wake events logged to 1000 * Stop logging wake log name as it takes too much memory * Add counters for each of the repeated values in BluetoothLog so that the true number of events can be determined while oldest event get dropped * Log Bluetooth session disconnect reasons using enum instead of string in order to save memory usage * Apply other branch changes to bluetooth.proto on system/bt Bug: 33694310 Test: Code compilation and unit tests Change-Id: I2cc6f9304725938b63b211d615eb1941eac60edf (cherry picked from commit 7ab4b59672013eddcb706e288962ab7309a75628) --- system/btif/src/btif_a2dp_source.cc | 4 +- system/osi/include/metrics.h | 16 ++++- system/osi/src/metrics.cc | 62 ++++++++++++----- system/osi/src/protos/bluetooth.proto | 31 ++++++++- system/osi/src/wakelock.cc | 4 +- system/osi/test/metrics_test.cc | 97 +++++++++++++++++++++------ 6 files changed, 168 insertions(+), 46 deletions(-) diff --git a/system/btif/src/btif_a2dp_source.cc b/system/btif/src/btif_a2dp_source.cc index 443d62dd50d..0d4bb421578 100644 --- a/system/btif/src/btif_a2dp_source.cc +++ b/system/btif/src/btif_a2dp_source.cc @@ -324,8 +324,8 @@ static void btif_a2dp_source_shutdown_delayed(UNUSED_ATTR void* context) { btif_a2dp_source_cb.tx_audio_queue = NULL; btif_a2dp_source_state = BTIF_A2DP_SOURCE_STATE_OFF; - BluetoothMetricsLogger::GetInstance()->LogBluetoothSessionEnd("A2DP_SHUTDOWN", - 0); + BluetoothMetricsLogger::GetInstance()->LogBluetoothSessionEnd( + system_bt_osi::DISCONNECT_REASON_UNKNOWN, 0); } bool btif_a2dp_source_media_task_is_running(void) { diff --git a/system/osi/include/metrics.h b/system/osi/include/metrics.h index e2bc6cbc4a1..dcd1a2065d7 100644 --- a/system/osi/include/metrics.h +++ b/system/osi/include/metrics.h @@ -52,6 +52,12 @@ typedef enum { CONNECTION_TECHNOLOGY_TYPE_BREDR, } connection_tech_t; +typedef enum { + DISCONNECT_REASON_UNKNOWN, + DISCONNECT_REASON_METRICS_DUMP, + DISCONNECT_REASON_NEXT_START_WITHOUT_END_PREVIOUS, +} disconnect_reason_t; + /* Values of A2DP metrics that we care about * * audio_duration_ms : sum of audio duration (in milliseconds). @@ -173,7 +179,7 @@ class BluetoothMetricsLogger { * timestamp_ms : the timestamp of session end, 0 means now * */ - void LogBluetoothSessionEnd(const std::string& disconnect_reason, + void LogBluetoothSessionEnd(disconnect_reason_t disconnect_reason, uint64_t timestamp_ms); /* @@ -217,6 +223,14 @@ class BluetoothMetricsLogger { */ void Reset(); + /* + * Maximum number of log entries for each session or event + */ + static const size_t kMaxNumBluetoothSession = 50; + static const size_t kMaxNumPairEvent = 50; + static const size_t kMaxNumWakeEvent = 1000; + static const size_t kMaxNumScanEvent = 50; + private: BluetoothMetricsLogger(); diff --git a/system/osi/src/metrics.cc b/system/osi/src/metrics.cc index 2cce3d39afe..fec994b7973 100644 --- a/system/osi/src/metrics.cc +++ b/system/osi/src/metrics.cc @@ -45,6 +45,7 @@ using clearcut::connectivity::A2DPSession; using clearcut::connectivity::BluetoothLog; using clearcut::connectivity::BluetoothSession; using clearcut::connectivity::BluetoothSession_ConnectionTechnologyType; +using clearcut::connectivity::BluetoothSession_DisconnectReasonType; using clearcut::connectivity::DeviceInfo; using clearcut::connectivity::DeviceInfo_DeviceType; using clearcut::connectivity::PairEvent; @@ -54,17 +55,6 @@ using clearcut::connectivity::ScanEvent_ScanEventType; using clearcut::connectivity::WakeEvent; using clearcut::connectivity::WakeEvent_WakeEventType; -namespace { -// Maximum number of log entries for each repeated field -const size_t global_max_num_bluetooth_session = 50; -const size_t global_max_num_pair_event = 50; -const size_t global_max_num_wake_event = 50; -const size_t global_max_num_scan_event = 50; -const std::string global_next_session_start_without_ending_previous = - "NEXT_SESSION_START_WITHOUT_ENDING_PREVIOUS"; -const std::string global_metrics_dump = "METRICS_DUMP"; -} - /* * Get current OS boot time in millisecond */ @@ -217,6 +207,22 @@ static WakeEvent_WakeEventType get_wake_event_type(wake_event_type_t type) { } } +static BluetoothSession_DisconnectReasonType get_disconnect_reason_type( + disconnect_reason_t type) { + switch (type) { + case DISCONNECT_REASON_METRICS_DUMP: + return BluetoothSession_DisconnectReasonType:: + BluetoothSession_DisconnectReasonType_METRICS_DUMP; + case DISCONNECT_REASON_NEXT_START_WITHOUT_END_PREVIOUS: + return BluetoothSession_DisconnectReasonType:: + BluetoothSession_DisconnectReasonType_NEXT_START_WITHOUT_END_PREVIOUS; + case DISCONNECT_REASON_UNKNOWN: + default: + return BluetoothSession_DisconnectReasonType:: + BluetoothSession_DisconnectReasonType_UNKNOWN; + } +} + struct BluetoothMetricsLogger::impl { impl(size_t max_bluetooth_session, size_t max_pair_event, size_t max_wake_event, size_t max_scan_event) @@ -248,9 +254,8 @@ struct BluetoothMetricsLogger::impl { }; BluetoothMetricsLogger::BluetoothMetricsLogger() - : pimpl_(new impl(global_max_num_bluetooth_session, - global_max_num_pair_event, global_max_num_wake_event, - global_max_num_scan_event)) {} + : pimpl_(new impl(kMaxNumBluetoothSession, kMaxNumPairEvent, + kMaxNumWakeEvent, kMaxNumScanEvent)) {} void BluetoothMetricsLogger::LogPairEvent(uint32_t disconnect_reason, uint64_t timestamp_ms, @@ -263,6 +268,11 @@ void BluetoothMetricsLogger::LogPairEvent(uint32_t disconnect_reason, event->set_disconnect_reason(disconnect_reason); event->set_event_time_millis(timestamp_ms); pimpl_->pair_event_queue_->Enqueue(event); + { + std::lock_guard<std::recursive_mutex> lock(pimpl_->bluetooth_log_lock_); + pimpl_->bluetooth_log_->set_num_pair_event( + pimpl_->bluetooth_log_->num_pair_event() + 1); + } } void BluetoothMetricsLogger::LogWakeEvent(wake_event_type_t type, @@ -275,6 +285,11 @@ void BluetoothMetricsLogger::LogWakeEvent(wake_event_type_t type, event->set_name(name); event->set_event_time_millis(timestamp_ms); pimpl_->wake_event_queue_->Enqueue(event); + { + std::lock_guard<std::recursive_mutex> lock(pimpl_->bluetooth_log_lock_); + pimpl_->bluetooth_log_->set_num_wake_event( + pimpl_->bluetooth_log_->num_wake_event() + 1); + } } void BluetoothMetricsLogger::LogScanEvent(bool start, @@ -292,13 +307,18 @@ void BluetoothMetricsLogger::LogScanEvent(bool start, event->set_number_results(results); event->set_event_time_millis(timestamp_ms); pimpl_->scan_event_queue_->Enqueue(event); + { + std::lock_guard<std::recursive_mutex> lock(pimpl_->bluetooth_log_lock_); + pimpl_->bluetooth_log_->set_num_scan_event( + pimpl_->bluetooth_log_->num_scan_event() + 1); + } } void BluetoothMetricsLogger::LogBluetoothSessionStart( connection_tech_t connection_tech_type, uint64_t timestamp_ms) { std::lock_guard<std::recursive_mutex> lock(pimpl_->bluetooth_session_lock_); if (pimpl_->bluetooth_session_ != nullptr) { - LogBluetoothSessionEnd(global_next_session_start_without_ending_previous, + LogBluetoothSessionEnd(DISCONNECT_REASON_NEXT_START_WITHOUT_END_PREVIOUS, 0); } if (timestamp_ms == 0) { @@ -311,7 +331,7 @@ void BluetoothMetricsLogger::LogBluetoothSessionStart( } void BluetoothMetricsLogger::LogBluetoothSessionEnd( - const std::string& disconnect_reason, uint64_t timestamp_ms) { + disconnect_reason_t disconnect_reason, uint64_t timestamp_ms) { std::lock_guard<std::recursive_mutex> lock(pimpl_->bluetooth_session_lock_); if (pimpl_->bluetooth_session_ == nullptr) { return; @@ -322,9 +342,15 @@ void BluetoothMetricsLogger::LogBluetoothSessionEnd( int64_t session_duration_sec = (timestamp_ms - pimpl_->bluetooth_session_start_time_ms_) / 1000; pimpl_->bluetooth_session_->set_session_duration_sec(session_duration_sec); - pimpl_->bluetooth_session_->set_disconnect_reason(disconnect_reason); + pimpl_->bluetooth_session_->set_disconnect_reason_type( + get_disconnect_reason_type(disconnect_reason)); pimpl_->bt_session_queue_->Enqueue(pimpl_->bluetooth_session_); pimpl_->bluetooth_session_ = nullptr; + { + std::lock_guard<std::recursive_mutex> log_lock(pimpl_->bluetooth_log_lock_); + pimpl_->bluetooth_log_->set_num_bluetooth_session( + pimpl_->bluetooth_log_->num_bluetooth_session() + 1); + } } void BluetoothMetricsLogger::LogBluetoothSessionDeviceInfo( @@ -408,7 +434,7 @@ void BluetoothMetricsLogger::CutoffSession() { new BluetoothSession(*pimpl_->bluetooth_session_); new_bt_session->clear_a2dp_session(); new_bt_session->clear_rfcomm_session(); - LogBluetoothSessionEnd(global_metrics_dump, 0); + LogBluetoothSessionEnd(DISCONNECT_REASON_METRICS_DUMP, 0); pimpl_->bluetooth_session_ = new_bt_session; pimpl_->bluetooth_session_start_time_ms_ = time_get_os_boottime_ms(); pimpl_->a2dp_session_metrics_ = A2dpSessionMetrics(); diff --git a/system/osi/src/protos/bluetooth.proto b/system/osi/src/protos/bluetooth.proto index 23f83fdaf79..037fce1690c 100644 --- a/system/osi/src/protos/bluetooth.proto +++ b/system/osi/src/protos/bluetooth.proto @@ -24,6 +24,21 @@ message BluetoothLog { // Scan event information. repeated ScanEvent scan_event = 4; + + // Number of bonded devices. + optional int32 num_bonded_devices = 5; + + // Number of BluetoothSession including discarded ones beyond capacity + optional int64 num_bluetooth_session = 6; + + // Number of PairEvent including discarded ones beyond capacity + optional int64 num_pair_event = 7; + + // Number of WakeEvent including discarded ones beyond capacity + optional int64 num_wake_event = 8; + + // Number of ScanEvent including discarded ones beyond capacity + optional int64 num_scan_event = 9; } // The information about the device. @@ -59,6 +74,17 @@ message BluetoothSession { CONNECTION_TECHNOLOGY_TYPE_BREDR = 2; } + enum DisconnectReasonType { + UNKNOWN = 0; + + // A metrics dump takes a snapshot of current Bluetooth session and thus + // is not a real disconnect, but a discontinuation in metrics logging. + // This enum indicates this situation. + METRICS_DUMP = 1; + + NEXT_START_WITHOUT_END_PREVIOUS = 2; + } + // Duration of the session. optional int64 session_duration_sec = 2; @@ -66,7 +92,7 @@ message BluetoothSession { optional ConnectionTechnologyType connection_technology_type = 3; // Reason for disconnecting. - optional string disconnect_reason = 4; + optional string disconnect_reason = 4 [deprecated = true]; // The information about the device which it is connected to. optional DeviceInfo device_connected_to = 5; @@ -76,6 +102,9 @@ message BluetoothSession { // The information about the A2DP audio session. optional A2DPSession a2dp_session = 7; + + // Numeric reason for disconnecting as defined in metrics.h + optional DisconnectReasonType disconnect_reason_type = 8; } message RFCommSession { diff --git a/system/osi/src/wakelock.cc b/system/osi/src/wakelock.cc index 7aa7004003d..b7e5037ed68 100644 --- a/system/osi/src/wakelock.cc +++ b/system/osi/src/wakelock.cc @@ -278,7 +278,7 @@ static void update_wakelock_acquired_stats(bt_status_t acquired_status) { wakelock_stats.last_acquired_timestamp_ms = now_ms; BluetoothMetricsLogger::GetInstance()->LogWakeEvent( - system_bt_osi::WAKE_EVENT_ACQUIRED, "", WAKE_LOCK_ID, now_ms); + system_bt_osi::WAKE_EVENT_ACQUIRED, "", "", now_ms); } // @@ -320,7 +320,7 @@ static void update_wakelock_released_stats(bt_status_t released_status) { wakelock_stats.total_acquired_interval_ms += delta_ms; BluetoothMetricsLogger::GetInstance()->LogWakeEvent( - system_bt_osi::WAKE_EVENT_RELEASED, "", WAKE_LOCK_ID, now_ms); + system_bt_osi::WAKE_EVENT_RELEASED, "", "", now_ms); } void wakelock_debug_dump(int fd) { diff --git a/system/osi/test/metrics_test.cc b/system/osi/test/metrics_test.cc index 8bcf6732e8f..a8de2fc85f1 100644 --- a/system/osi/test/metrics_test.cc +++ b/system/osi/test/metrics_test.cc @@ -38,6 +38,7 @@ using clearcut::connectivity::A2DPSession; using clearcut::connectivity::BluetoothLog; using clearcut::connectivity::BluetoothSession; using clearcut::connectivity::BluetoothSession_ConnectionTechnologyType; +using clearcut::connectivity::BluetoothSession_DisconnectReasonType; using clearcut::connectivity::DeviceInfo; using clearcut::connectivity::DeviceInfo_DeviceType; using clearcut::connectivity::PairEvent; @@ -50,6 +51,10 @@ using clearcut::connectivity::WakeEvent_WakeEventType; using system_bt_osi::BluetoothMetricsLogger; using system_bt_osi::A2dpSessionMetrics; +namespace { +const size_t kMaxEventGenerationLimit = 5000; +} + /* * Get current OS boot time in ms */ @@ -118,15 +123,16 @@ A2DPSession* MakeA2DPSession(const A2dpSessionMetrics& metrics) { BluetoothSession* MakeBluetoothSession( int64_t session_duration_sec, BluetoothSession_ConnectionTechnologyType conn_type, - const std::string& disconnect_reason, DeviceInfo* device_info, - RFCommSession* rfcomm_session, A2DPSession* a2dp_session) { + BluetoothSession_DisconnectReasonType disconnect_reason, + DeviceInfo* device_info, RFCommSession* rfcomm_session, + A2DPSession* a2dp_session) { BluetoothSession* session = new BluetoothSession(); if (a2dp_session) session->set_allocated_a2dp_session(a2dp_session); if (rfcomm_session) session->set_allocated_rfcomm_session(rfcomm_session); if (device_info) session->set_allocated_device_connected_to(device_info); session->set_session_duration_sec(session_duration_sec); session->set_connection_technology_type(conn_type); - session->set_disconnect_reason(disconnect_reason); + session->set_disconnect_reason_type(disconnect_reason); return session; } @@ -154,9 +160,9 @@ BluetoothLog* MakeBluetoothLog(std::vector<BluetoothSession*> bt_sessions, return bt_log; } -void GenerateWakeEvents(int start, int end, +void GenerateWakeEvents(size_t start, size_t end, std::vector<WakeEvent*>* wake_events) { - for (int i = start; i < end; ++i) { + for (size_t i = start; i < end; ++i) { wake_events->push_back(MakeWakeEvent( i % 2 == 0 ? WakeEvent_WakeEventType::WakeEvent_WakeEventType_ACQUIRED : WakeEvent_WakeEventType::WakeEvent_WakeEventType_RELEASED, @@ -304,6 +310,10 @@ class BluetoothMetricsLoggerTest : public Test { std::vector<WakeEvent*> wake_events_; std::vector<ScanEvent*> scan_events_; std::vector<BluetoothSession*> bt_sessions_; + int64_t num_pair_event_ = 0; + int64_t num_wake_event_ = 0; + int64_t num_scan_event_ = 0; + int64_t num_bt_session_ = 0; BluetoothLog* bt_log_; std::string bt_log_str_; std::string bt_log_ascii_str_; @@ -312,18 +322,38 @@ class BluetoothMetricsLoggerTest : public Test { for (BluetoothSession* session : bt_sessions_) { bt_log_->mutable_session()->AddAllocated(session); } + if (num_bt_session_ > 0) { + bt_log_->set_num_bluetooth_session(num_bt_session_); + } else if (bt_sessions_.size() > 0) { + bt_log_->set_num_bluetooth_session(bt_sessions_.size()); + } bt_sessions_.clear(); for (PairEvent* event : pair_events_) { bt_log_->mutable_pair_event()->AddAllocated(event); } + if (num_pair_event_ > 0) { + bt_log_->set_num_pair_event(num_pair_event_); + } else if (pair_events_.size() > 0) { + bt_log_->set_num_pair_event(pair_events_.size()); + } pair_events_.clear(); for (WakeEvent* event : wake_events_) { bt_log_->mutable_wake_event()->AddAllocated(event); } + if (num_wake_event_ > 0) { + bt_log_->set_num_wake_event(num_wake_event_); + } else if (wake_events_.size() > 0) { + bt_log_->set_num_wake_event(wake_events_.size()); + } wake_events_.clear(); for (ScanEvent* event : scan_events_) { bt_log_->mutable_scan_event()->AddAllocated(event); } + if (num_scan_event_ > 0) { + bt_log_->set_num_scan_event(num_scan_event_); + } else if (scan_events_.size() > 0) { + bt_log_->set_num_scan_event(scan_events_.size()); + } scan_events_.clear(); bt_log_->SerializeToString(&bt_log_str_); } @@ -392,10 +422,13 @@ TEST_F(BluetoothMetricsLoggerTest, WakeEventTest) { EXPECT_THAT(msg_str, StrEq(bt_log_str_)); } -TEST_F(BluetoothMetricsLoggerTest, WakeEvent500Test) { - GenerateWakeEvents(450, 500, &wake_events_); +TEST_F(BluetoothMetricsLoggerTest, WakeEventOverrunTest) { + GenerateWakeEvents( + kMaxEventGenerationLimit - BluetoothMetricsLogger::kMaxNumWakeEvent, + kMaxEventGenerationLimit, &wake_events_); + num_wake_event_ = kMaxEventGenerationLimit; UpdateLog(); - for (int i = 0; i < 500; ++i) { + for (size_t i = 0; i < kMaxEventGenerationLimit; ++i) { BluetoothMetricsLogger::GetInstance()->LogWakeEvent( i % 2 == 0 ? system_bt_osi::WAKE_EVENT_ACQUIRED : system_bt_osi::WAKE_EVENT_RELEASED, @@ -425,12 +458,14 @@ TEST_F(BluetoothMetricsLoggerTest, BluetoothSessionTest) { 10, BluetoothSession_ConnectionTechnologyType:: BluetoothSession_ConnectionTechnologyType_CONNECTION_TECHNOLOGY_TYPE_LE, - "TEST_DISCONNECT", nullptr, nullptr, nullptr)); + BluetoothSession_DisconnectReasonType:: + BluetoothSession_DisconnectReasonType_UNKNOWN, + nullptr, nullptr, nullptr)); UpdateLog(); BluetoothMetricsLogger::GetInstance()->LogBluetoothSessionStart( system_bt_osi::CONNECTION_TECHNOLOGY_TYPE_LE, 123456); BluetoothMetricsLogger::GetInstance()->LogBluetoothSessionEnd( - "TEST_DISCONNECT", 133456); + system_bt_osi::DISCONNECT_REASON_UNKNOWN, 133456); std::string msg_str; BluetoothMetricsLogger::GetInstance()->WriteString(&msg_str, true); EXPECT_THAT(msg_str, StrEq(bt_log_str_)); @@ -441,7 +476,9 @@ TEST_F(BluetoothMetricsLoggerTest, BluetoothSessionDumpBeforeEndTest) { 1, BluetoothSession_ConnectionTechnologyType:: BluetoothSession_ConnectionTechnologyType_CONNECTION_TECHNOLOGY_TYPE_LE, - "METRICS_DUMP", nullptr, nullptr, nullptr)); + BluetoothSession_DisconnectReasonType:: + BluetoothSession_DisconnectReasonType_METRICS_DUMP, + nullptr, nullptr, nullptr)); UpdateLog(); BluetoothMetricsLogger::GetInstance()->LogBluetoothSessionStart( system_bt_osi::CONNECTION_TECHNOLOGY_TYPE_LE, time_get_os_boottime_ms()); @@ -456,12 +493,16 @@ TEST_F(BluetoothMetricsLoggerTest, BluetoothSessionStartBeforeEndTest) { 1, BluetoothSession_ConnectionTechnologyType:: BluetoothSession_ConnectionTechnologyType_CONNECTION_TECHNOLOGY_TYPE_UNKNOWN, - "NEXT_SESSION_START_WITHOUT_ENDING_PREVIOUS", nullptr, nullptr, nullptr)); + BluetoothSession_DisconnectReasonType:: + BluetoothSession_DisconnectReasonType_NEXT_START_WITHOUT_END_PREVIOUS, + nullptr, nullptr, nullptr)); bt_sessions_.push_back(MakeBluetoothSession( 2, BluetoothSession_ConnectionTechnologyType:: BluetoothSession_ConnectionTechnologyType_CONNECTION_TECHNOLOGY_TYPE_LE, - "METRICS_DUMP", nullptr, nullptr, nullptr)); + BluetoothSession_DisconnectReasonType:: + BluetoothSession_DisconnectReasonType_METRICS_DUMP, + nullptr, nullptr, nullptr)); UpdateLog(); BluetoothMetricsLogger::GetInstance()->LogBluetoothSessionStart( system_bt_osi::CONNECTION_TECHNOLOGY_TYPE_UNKNOWN, 0); @@ -523,7 +564,9 @@ TEST_F(BluetoothMetricsLoggerTest, A2DPSessionTwoUpdatesTest) { 10, BluetoothSession_ConnectionTechnologyType:: BluetoothSession_ConnectionTechnologyType_CONNECTION_TECHNOLOGY_TYPE_BREDR, - "TEST_DISCONNECT", info, nullptr, session)); + BluetoothSession_DisconnectReasonType:: + BluetoothSession_DisconnectReasonType_UNKNOWN, + info, nullptr, session)); UpdateLog(); BluetoothMetricsLogger::GetInstance()->LogBluetoothSessionStart( system_bt_osi::CONNECTION_TECHNOLOGY_TYPE_BREDR, 123456); @@ -532,7 +575,7 @@ TEST_F(BluetoothMetricsLoggerTest, A2DPSessionTwoUpdatesTest) { BluetoothMetricsLogger::GetInstance()->LogA2dpSession(metrics1); BluetoothMetricsLogger::GetInstance()->LogA2dpSession(metrics2); BluetoothMetricsLogger::GetInstance()->LogBluetoothSessionEnd( - "TEST_DISCONNECT", 133456); + system_bt_osi::DISCONNECT_REASON_UNKNOWN, 133456); std::string msg_str; BluetoothMetricsLogger::GetInstance()->WriteString(&msg_str, true); EXPECT_THAT(msg_str, StrEq(bt_log_str_)); @@ -579,7 +622,9 @@ TEST_F(BluetoothMetricsLoggerTest, A2DPSessionTwoUpdatesSeparatedbyDumpTest) { 1, BluetoothSession_ConnectionTechnologyType:: BluetoothSession_ConnectionTechnologyType_CONNECTION_TECHNOLOGY_TYPE_BREDR, - "METRICS_DUMP", info, nullptr, session)); + BluetoothSession_DisconnectReasonType:: + BluetoothSession_DisconnectReasonType_METRICS_DUMP, + info, nullptr, session)); UpdateLog(); BluetoothMetricsLogger::GetInstance()->LogBluetoothSessionStart( system_bt_osi::CONNECTION_TECHNOLOGY_TYPE_BREDR, 0); @@ -599,12 +644,14 @@ TEST_F(BluetoothMetricsLoggerTest, A2DPSessionTwoUpdatesSeparatedbyDumpTest) { 1, BluetoothSession_ConnectionTechnologyType:: BluetoothSession_ConnectionTechnologyType_CONNECTION_TECHNOLOGY_TYPE_BREDR, - "TEST_DISCONNECT", info, nullptr, session)); + BluetoothSession_DisconnectReasonType:: + BluetoothSession_DisconnectReasonType_UNKNOWN, + info, nullptr, session)); UpdateLog(); sleep_ms(1000); BluetoothMetricsLogger::GetInstance()->LogA2dpSession(metrics2); BluetoothMetricsLogger::GetInstance()->LogBluetoothSessionEnd( - "TEST_DISCONNECT", 0); + system_bt_osi::DISCONNECT_REASON_UNKNOWN, 0); msg_str.clear(); BluetoothMetricsLogger::GetInstance()->WriteString(&msg_str, true); EXPECT_THAT(msg_str, StrEq(bt_log_str_)); @@ -657,7 +704,9 @@ TEST_F(BluetoothMetricsLoggerTest, A2DPSessionOnlyTest) { 1, BluetoothSession_ConnectionTechnologyType:: BluetoothSession_ConnectionTechnologyType_CONNECTION_TECHNOLOGY_TYPE_BREDR, - "METRICS_DUMP", info, nullptr, session)); + BluetoothSession_DisconnectReasonType:: + BluetoothSession_DisconnectReasonType_METRICS_DUMP, + info, nullptr, session)); UpdateLog(); BluetoothMetricsLogger::GetInstance()->LogA2dpSession(metrics1); BluetoothMetricsLogger::GetInstance()->LogA2dpSession(metrics2); @@ -716,7 +765,9 @@ TEST_F(BluetoothMetricsLoggerTest, A2DPSessionDumpBeforeTwoUpdatesTest) { 1, BluetoothSession_ConnectionTechnologyType:: BluetoothSession_ConnectionTechnologyType_CONNECTION_TECHNOLOGY_TYPE_BREDR, - "METRICS_DUMP", info, nullptr, nullptr)); + BluetoothSession_DisconnectReasonType:: + BluetoothSession_DisconnectReasonType_METRICS_DUMP, + info, nullptr, nullptr)); UpdateLog(); BluetoothMetricsLogger::GetInstance()->LogBluetoothSessionStart( system_bt_osi::CONNECTION_TECHNOLOGY_TYPE_BREDR, 0); @@ -735,13 +786,15 @@ TEST_F(BluetoothMetricsLoggerTest, A2DPSessionDumpBeforeTwoUpdatesTest) { 1, BluetoothSession_ConnectionTechnologyType:: BluetoothSession_ConnectionTechnologyType_CONNECTION_TECHNOLOGY_TYPE_BREDR, - "TEST_DISCONNECT", info, nullptr, session)); + BluetoothSession_DisconnectReasonType:: + BluetoothSession_DisconnectReasonType_UNKNOWN, + info, nullptr, session)); UpdateLog(); BluetoothMetricsLogger::GetInstance()->LogA2dpSession(metrics1); BluetoothMetricsLogger::GetInstance()->LogA2dpSession(metrics2); sleep_ms(1000); BluetoothMetricsLogger::GetInstance()->LogBluetoothSessionEnd( - "TEST_DISCONNECT", 0); + system_bt_osi::DISCONNECT_REASON_UNKNOWN, 0); msg_str.clear(); BluetoothMetricsLogger::GetInstance()->WriteString(&msg_str, true); EXPECT_THAT(msg_str, StrEq(bt_log_str_)); -- GitLab