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

Commit 1bea83c1 authored by Henri Chataing's avatar Henri Chataing
Browse files

Add expresslog metrics for a2dp codec usage

This is pending the addition of a more exhaustive atom
tracking more information about a2dp audio sessions in general.

Bug: 346590002
Test: m com.android.btservices
Flag: EXEMPT, metric change
Change-Id: Ia671c9596698932ac5604f1a75d3bfce3bca7f31
parent 365a0ed8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -134,6 +134,7 @@ cc_library_shared {
        "libchrome",
        "libcutils",
        "libevent",
        "libexpresslog",
        "libflatbuffers-cpp",
        "libfmq",
        "libg722codec",
@@ -144,6 +145,8 @@ cc_library_shared {
        "libosi",
        "libprotobuf-cpp-lite",
        "libstatslog_bt",
        "libstatslog_express",
        "libtextclassifier_hash_static",
        "libudrv-uipc",
        "libutils",
        "server_configurable_flags",
+3 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ cc_defaults {
        "libchrome",
        "libcutils",
        "libevent",
        "libexpresslog",
        "libg722codec",
        "libhidlbase",
        "libjsoncpp",
@@ -99,6 +100,8 @@ cc_defaults {
        "libosi",
        "libprotobuf-cpp-lite",
        "libstatslog_bt",
        "libstatslog_express",
        "libtextclassifier_hash_static",
        "libudrv-uipc",
        "libutils",
        "libvndksupport",
+6 −0
Original line number Diff line number Diff line
@@ -125,8 +125,14 @@ cc_defaults {
                "libcutils",
                "libhidlbase",
                "libstatslog_bt",
                "libstatssocket",
                "libutils",
            ],
            static_libs: [
                "libexpresslog",
                "libstatslog_express",
                "libtextclassifier_hash_static",
            ],
            whole_static_libs: [
                "android.hardware.bluetooth-V1-ndk",
                "android.hardware.bluetooth.ranging-V1-ndk",
+30 −2
Original line number Diff line number Diff line
@@ -20,12 +20,14 @@

#include "os/metrics.h"

#include <Counter.h>
#include <bluetooth/log.h>
#include <statslog_bt.h>

#include "common/audit_log.h"
#include "common/metric_id_manager.h"
#include "common/strings.h"
#include "hardware/bt_av.h"
#include "hci/hci_packets.h"
#include "metrics/metrics_state.h"
#include "os/log.h"
@@ -206,8 +208,34 @@ void LogMetricA2dpSessionMetricsEvent(
    int /* buffer_overruns_total */,
    float /* buffer_underruns_average */,
    int /* buffer_underruns_count */,
    int64_t /* codec_index */,
    bool /* is_a2dp_offload */) {}
    int64_t codec_index,
    bool /* is_a2dp_offload */) {
  char const* metric_id = nullptr;
  switch (codec_index) {
    case BTAV_A2DP_CODEC_INDEX_SOURCE_SBC:
      metric_id = "bluetooth.value_sbc_codec_usage_over_a2dp";
      break;
    case BTAV_A2DP_CODEC_INDEX_SOURCE_AAC:
      metric_id = "bluetooth.value_aac_codec_usage_over_a2dp";
      break;
    case BTAV_A2DP_CODEC_INDEX_SOURCE_APTX:
      metric_id = "bluetooth.value_aptx_codec_usage_over_a2dp";
      break;
    case BTAV_A2DP_CODEC_INDEX_SOURCE_APTX_HD:
      metric_id = "bluetooth.value_aptx_hd_codec_usage_over_a2dp";
      break;
    case BTAV_A2DP_CODEC_INDEX_SOURCE_LDAC:
      metric_id = "bluetooth.value_ldac_codec_usage_over_a2dp";
      break;
    case BTAV_A2DP_CODEC_INDEX_SOURCE_OPUS:
      metric_id = "bluetooth.value_opus_codec_usage_over_a2dp";
      break;
    default:
      return;
  }

  android::expresslog::Counter::logIncrement(metric_id);
}

void LogMetricHfpPacketLossStats(
    const Address& /* address */,
+3 −0
Original line number Diff line number Diff line
@@ -772,6 +772,9 @@ cc_test {
            static_libs: [
                "android.hardware.bluetooth@1.0",
                "android.hardware.bluetooth@1.1",
                "libexpresslog",
                "libstatslog_express",
                "libtextclassifier_hash_static",
            ],
        },
        host: {
Loading