Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a83ef451 authored by Chen Chen's avatar Chen Chen Committed by Automerger Merge Worker
Browse files

Merge "BluetoothMetrics: Upload A2DP connection failures using counter...

Merge "BluetoothMetrics: Upload A2DP connection failures using counter metrics" am: 5465174e am: 3753b672 am: fbeabcb5 am: caf328f5

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2043428



Change-Id: Id106a8fb67af0350de74c02582a30b8bcf46eca6
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 536d8bbc caf328f5
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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:
+3 −0
Original line number Diff line number Diff line
@@ -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,
+32 −0
Original line number Diff line number Diff line
@@ -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>
@@ -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"
@@ -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);
@@ -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);
@@ -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
@@ -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) {
@@ -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;

@@ -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:
@@ -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:
@@ -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();
      }
@@ -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();
      }
@@ -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(),
+5 −0
Original line number Diff line number Diff line
@@ -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,