Loading android/app/src/com/android/bluetooth/a2dp/A2dpStateMachine.java +4 −0 Original line number Diff line number Diff line Loading @@ -52,12 +52,14 @@ import android.bluetooth.BluetoothCodecConfig; import android.bluetooth.BluetoothCodecStatus; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothProfile; import android.bluetooth.BluetoothProtoEnums; import android.content.Intent; import android.os.Looper; import android.os.Message; import android.util.Log; import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.MetricsLogger; import com.android.bluetooth.btservice.ProfileService; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.State; Loading Loading @@ -298,6 +300,8 @@ final class A2dpStateMachine extends StateMachine { event.device = mDevice; event.valueInt = A2dpStackEvent.CONNECTION_STATE_DISCONNECTED; sendMessage(STACK_EVENT, event); MetricsLogger.getInstance().count( BluetoothProtoEnums.A2DP_CONNECTION_TIMEOUT, 1); break; } case DISCONNECT: Loading system/btif/include/btif_metrics_logging.h +3 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,9 @@ void log_read_tx_power_level_result(const RawAddress& address, uint16_t handle, uint32_t cmd_status, int32_t transmit_power_level); void log_counter_metrics_btif(android::bluetooth::CodePathCounterKeyEnum key, int64_t value); void log_socket_connection_state( const RawAddress& address, int port, int type, android::bluetooth::SocketConnectionstateEnum connection_state, Loading system/btif/src/btif_av.cc +32 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <base/logging.h> #include <base/strings/stringprintf.h> #include <frameworks/proto_logging/stats/enums/bluetooth/a2dp/enums.pb.h> #include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h> #include <cstdint> #include <future> Loading @@ -39,6 +40,7 @@ #include "btif/include/btif_a2dp_source.h" #include "btif/include/btif_av_co.h" #include "btif/include/btif_common.h" #include "btif/include/btif_metrics_logging.h" #include "btif/include/btif_profile_queue.h" #include "btif/include/btif_rc.h" #include "btif/include/btif_util.h" Loading Loading @@ -1676,6 +1678,9 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, "%s: Peer %s : event=%s: transitioning to Idle due to ACL Disconnect", __PRETTY_FUNCTION__, peer_.PeerAddress().ToString().c_str(), BtifAvEvent::EventName(event).c_str()); log_counter_metrics_btif(android::bluetooth::CodePathCounterKeyEnum:: A2DP_CONNECTION_ACL_DISCONNECTED, 1); btif_report_connection_state(peer_.PeerAddress(), BTAV_CONNECTION_STATE_DISCONNECTED); peer_.StateMachine().TransitionTo(BtifAvStateMachine::kStateIdle); Loading @@ -1688,6 +1693,9 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, peer_.PeerAddress().ToString().c_str(), BtifAvEvent::EventName(event).c_str(), peer_.FlagsToString().c_str()); log_counter_metrics_btif(android::bluetooth::CodePathCounterKeyEnum:: A2DP_CONNECTION_REJECT_EVT, 1); btif_report_connection_state(peer_.PeerAddress(), BTAV_CONNECTION_STATE_DISCONNECTED); peer_.StateMachine().TransitionTo(BtifAvStateMachine::kStateIdle); Loading @@ -1714,6 +1722,9 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, av_state = BtifAvStateMachine::kStateOpened; peer_.SetEdr(p_bta_data->open.edr); CHECK(peer_.PeerSep() == p_bta_data->open.sep); log_counter_metrics_btif( android::bluetooth::CodePathCounterKeyEnum::A2DP_CONNECTION_SUCCESS, 1); } else { if (btif_rc_is_connected_peer(peer_.PeerAddress())) { // Disconnect the AVRCP connection, in case the A2DP connectiton Loading @@ -1721,6 +1732,10 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, BTIF_TRACE_WARNING("%s: Peer %s : Disconnecting AVRCP", __PRETTY_FUNCTION__, peer_.PeerAddress().ToString().c_str()); log_counter_metrics_btif( android::bluetooth::CodePathCounterKeyEnum:: A2DP_CONNECTION_FAILURE, 1); uint8_t peer_handle = btif_rc_get_connected_peer_handle(peer_.PeerAddress()); if (peer_handle != BTRC_HANDLE_NONE) { Loading Loading @@ -1768,6 +1783,9 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, "ignore Connect request", __PRETTY_FUNCTION__, peer_.PeerAddress().ToString().c_str(), BtifAvEvent::EventName(event).c_str()); log_counter_metrics_btif( android::bluetooth::CodePathCounterKeyEnum::A2DP_ALREADY_CONNECTING, 1); btif_queue_advance(); } break; Loading @@ -1779,6 +1797,9 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, "ignore incoming request", __PRETTY_FUNCTION__, peer_.PeerAddress().ToString().c_str(), BtifAvEvent::EventName(event).c_str()); log_counter_metrics_btif( android::bluetooth::CodePathCounterKeyEnum::A2DP_ALREADY_CONNECTING, 1); } break; case BTIF_AV_OFFLOAD_START_REQ_EVT: Loading @@ -1787,6 +1808,9 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, peer_.PeerAddress().ToString().c_str(), BtifAvEvent::EventName(event).c_str()); btif_a2dp_on_offload_started(peer_.PeerAddress(), BTA_AV_FAIL); log_counter_metrics_btif(android::bluetooth::CodePathCounterKeyEnum:: A2DP_OFFLOAD_START_REQ_FAILURE, 1); break; case BTA_AV_CLOSE_EVT: Loading @@ -1794,6 +1818,8 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, btif_report_connection_state(peer_.PeerAddress(), BTAV_CONNECTION_STATE_DISCONNECTED); peer_.StateMachine().TransitionTo(BtifAvStateMachine::kStateIdle); log_counter_metrics_btif( android::bluetooth::CodePathCounterKeyEnum::A2DP_CONNECTION_CLOSE, 1); if (peer_.SelfInitiatedConnection()) { btif_queue_advance(); } Loading @@ -1804,6 +1830,9 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, btif_report_connection_state(peer_.PeerAddress(), BTAV_CONNECTION_STATE_DISCONNECTED); peer_.StateMachine().TransitionTo(BtifAvStateMachine::kStateIdle); log_counter_metrics_btif(android::bluetooth::CodePathCounterKeyEnum:: A2DP_CONNECTION_DISCONNECTED, 1); if (peer_.SelfInitiatedConnection()) { btif_queue_advance(); } Loading @@ -1812,6 +1841,9 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, CHECK_RC_EVENT(event, (tBTA_AV*)p_data); default: log_counter_metrics_btif(android::bluetooth::CodePathCounterKeyEnum:: A2DP_CONNECTION_UNKNOWN_EVENT, 1); BTIF_TRACE_WARNING("%s: Peer %s : Unhandled event=%s", __PRETTY_FUNCTION__, peer_.PeerAddress().ToString().c_str(), Loading system/btif/src/btif_metrics_logging.cc +5 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,11 @@ void log_socket_connection_state( server_port, socket_role); } void log_counter_metrics_btif(android::bluetooth::CodePathCounterKeyEnum key, int64_t value) { bluetooth::shim::CountCounterMetrics(key, value); } bool init_metric_id_allocator( const std::unordered_map<RawAddress, int>& paired_device_map, bluetooth::shim::CallbackLegacy save_device_callback, Loading Loading
android/app/src/com/android/bluetooth/a2dp/A2dpStateMachine.java +4 −0 Original line number Diff line number Diff line Loading @@ -52,12 +52,14 @@ import android.bluetooth.BluetoothCodecConfig; import android.bluetooth.BluetoothCodecStatus; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothProfile; import android.bluetooth.BluetoothProtoEnums; import android.content.Intent; import android.os.Looper; import android.os.Message; import android.util.Log; import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.MetricsLogger; import com.android.bluetooth.btservice.ProfileService; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.State; Loading Loading @@ -298,6 +300,8 @@ final class A2dpStateMachine extends StateMachine { event.device = mDevice; event.valueInt = A2dpStackEvent.CONNECTION_STATE_DISCONNECTED; sendMessage(STACK_EVENT, event); MetricsLogger.getInstance().count( BluetoothProtoEnums.A2DP_CONNECTION_TIMEOUT, 1); break; } case DISCONNECT: Loading
system/btif/include/btif_metrics_logging.h +3 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,9 @@ void log_read_tx_power_level_result(const RawAddress& address, uint16_t handle, uint32_t cmd_status, int32_t transmit_power_level); void log_counter_metrics_btif(android::bluetooth::CodePathCounterKeyEnum key, int64_t value); void log_socket_connection_state( const RawAddress& address, int port, int type, android::bluetooth::SocketConnectionstateEnum connection_state, Loading
system/btif/src/btif_av.cc +32 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include <base/logging.h> #include <base/strings/stringprintf.h> #include <frameworks/proto_logging/stats/enums/bluetooth/a2dp/enums.pb.h> #include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h> #include <cstdint> #include <future> Loading @@ -39,6 +40,7 @@ #include "btif/include/btif_a2dp_source.h" #include "btif/include/btif_av_co.h" #include "btif/include/btif_common.h" #include "btif/include/btif_metrics_logging.h" #include "btif/include/btif_profile_queue.h" #include "btif/include/btif_rc.h" #include "btif/include/btif_util.h" Loading Loading @@ -1676,6 +1678,9 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, "%s: Peer %s : event=%s: transitioning to Idle due to ACL Disconnect", __PRETTY_FUNCTION__, peer_.PeerAddress().ToString().c_str(), BtifAvEvent::EventName(event).c_str()); log_counter_metrics_btif(android::bluetooth::CodePathCounterKeyEnum:: A2DP_CONNECTION_ACL_DISCONNECTED, 1); btif_report_connection_state(peer_.PeerAddress(), BTAV_CONNECTION_STATE_DISCONNECTED); peer_.StateMachine().TransitionTo(BtifAvStateMachine::kStateIdle); Loading @@ -1688,6 +1693,9 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, peer_.PeerAddress().ToString().c_str(), BtifAvEvent::EventName(event).c_str(), peer_.FlagsToString().c_str()); log_counter_metrics_btif(android::bluetooth::CodePathCounterKeyEnum:: A2DP_CONNECTION_REJECT_EVT, 1); btif_report_connection_state(peer_.PeerAddress(), BTAV_CONNECTION_STATE_DISCONNECTED); peer_.StateMachine().TransitionTo(BtifAvStateMachine::kStateIdle); Loading @@ -1714,6 +1722,9 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, av_state = BtifAvStateMachine::kStateOpened; peer_.SetEdr(p_bta_data->open.edr); CHECK(peer_.PeerSep() == p_bta_data->open.sep); log_counter_metrics_btif( android::bluetooth::CodePathCounterKeyEnum::A2DP_CONNECTION_SUCCESS, 1); } else { if (btif_rc_is_connected_peer(peer_.PeerAddress())) { // Disconnect the AVRCP connection, in case the A2DP connectiton Loading @@ -1721,6 +1732,10 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, BTIF_TRACE_WARNING("%s: Peer %s : Disconnecting AVRCP", __PRETTY_FUNCTION__, peer_.PeerAddress().ToString().c_str()); log_counter_metrics_btif( android::bluetooth::CodePathCounterKeyEnum:: A2DP_CONNECTION_FAILURE, 1); uint8_t peer_handle = btif_rc_get_connected_peer_handle(peer_.PeerAddress()); if (peer_handle != BTRC_HANDLE_NONE) { Loading Loading @@ -1768,6 +1783,9 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, "ignore Connect request", __PRETTY_FUNCTION__, peer_.PeerAddress().ToString().c_str(), BtifAvEvent::EventName(event).c_str()); log_counter_metrics_btif( android::bluetooth::CodePathCounterKeyEnum::A2DP_ALREADY_CONNECTING, 1); btif_queue_advance(); } break; Loading @@ -1779,6 +1797,9 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, "ignore incoming request", __PRETTY_FUNCTION__, peer_.PeerAddress().ToString().c_str(), BtifAvEvent::EventName(event).c_str()); log_counter_metrics_btif( android::bluetooth::CodePathCounterKeyEnum::A2DP_ALREADY_CONNECTING, 1); } break; case BTIF_AV_OFFLOAD_START_REQ_EVT: Loading @@ -1787,6 +1808,9 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, peer_.PeerAddress().ToString().c_str(), BtifAvEvent::EventName(event).c_str()); btif_a2dp_on_offload_started(peer_.PeerAddress(), BTA_AV_FAIL); log_counter_metrics_btif(android::bluetooth::CodePathCounterKeyEnum:: A2DP_OFFLOAD_START_REQ_FAILURE, 1); break; case BTA_AV_CLOSE_EVT: Loading @@ -1794,6 +1818,8 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, btif_report_connection_state(peer_.PeerAddress(), BTAV_CONNECTION_STATE_DISCONNECTED); peer_.StateMachine().TransitionTo(BtifAvStateMachine::kStateIdle); log_counter_metrics_btif( android::bluetooth::CodePathCounterKeyEnum::A2DP_CONNECTION_CLOSE, 1); if (peer_.SelfInitiatedConnection()) { btif_queue_advance(); } Loading @@ -1804,6 +1830,9 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, btif_report_connection_state(peer_.PeerAddress(), BTAV_CONNECTION_STATE_DISCONNECTED); peer_.StateMachine().TransitionTo(BtifAvStateMachine::kStateIdle); log_counter_metrics_btif(android::bluetooth::CodePathCounterKeyEnum:: A2DP_CONNECTION_DISCONNECTED, 1); if (peer_.SelfInitiatedConnection()) { btif_queue_advance(); } Loading @@ -1812,6 +1841,9 @@ bool BtifAvStateMachine::StateOpening::ProcessEvent(uint32_t event, CHECK_RC_EVENT(event, (tBTA_AV*)p_data); default: log_counter_metrics_btif(android::bluetooth::CodePathCounterKeyEnum:: A2DP_CONNECTION_UNKNOWN_EVENT, 1); BTIF_TRACE_WARNING("%s: Peer %s : Unhandled event=%s", __PRETTY_FUNCTION__, peer_.PeerAddress().ToString().c_str(), Loading
system/btif/src/btif_metrics_logging.cc +5 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,11 @@ void log_socket_connection_state( server_port, socket_role); } void log_counter_metrics_btif(android::bluetooth::CodePathCounterKeyEnum key, int64_t value) { bluetooth::shim::CountCounterMetrics(key, value); } bool init_metric_id_allocator( const std::unordered_map<RawAddress, int>& paired_device_map, bluetooth::shim::CallbackLegacy save_device_callback, Loading