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

Commit 64e96d8a authored by Palash Ahuja's avatar Palash Ahuja
Browse files

BluetoothMetrics: Log ACL Completion after Remote Name Request

Test: m com.android.btservices and statsd_testdrive
Bug: 345564021
Flag: EXEMPT, metrics related changes
Change-Id: I71eddb272d28d8e18a127cf1dd09b776cbc725d7
parent f5bab398
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

#include <frameworks/proto_logging/stats/enums/bluetooth/enums.pb.h>

#include "main/shim/helpers.h"
#include "os/metrics.h"

namespace bluetooth {
@@ -48,6 +49,8 @@ State MapErrorCodeToState(ErrorCode reason) {
      return State::KEY_MISSING;
    case ErrorCode::PAIRING_NOT_ALLOWED:
      return State::PAIRING_NOT_ALLOWED;
    case ErrorCode::CONNECTION_REJECTED_LIMITED_RESOURCES:
      return State::RESOURCES_EXCEEDED;
    default:
      return State::STATE_UNKNOWN;
  }
@@ -60,5 +63,24 @@ void LogAclCompletionEvent(const hci::Address& address, ErrorCode reason,
                                                              : EventType::ACL_CONNECTION_RESPONDER,
                                         MapErrorCodeToState(reason));
}

void LogAclAfterRemoteNameRequest(const RawAddress& raw_address, tBTM_STATUS status) {
  hci::Address address = bluetooth::ToGdAddress(raw_address);

  switch (status) {
    case BTM_SUCCESS:
      bluetooth::os::LogMetricBluetoothEvent(address, EventType::ACL_CONNECTION_INITIATOR,
                                             State::ALREADY_CONNECTED);
      break;
    case BTM_NO_RESOURCES:
      bluetooth::os::LogMetricBluetoothEvent(
              address, EventType::ACL_CONNECTION_INITIATOR,
              MapErrorCodeToState(ErrorCode::CONNECTION_REJECTED_LIMITED_RESOURCES));
      break;
    default:
      break;
  }
}

}  // namespace metrics
}  // namespace bluetooth
+5 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@

#include "hci/address.h"
#include "hci/hci_packets.h"
#include "stack/include/btm_status.h"
#include "types/raw_address.h"

namespace bluetooth {
namespace metrics {
@@ -25,5 +27,8 @@ namespace metrics {
void LogAclCompletionEvent(const hci::Address& address, hci::ErrorCode reason,
                           bool is_locally_initiated);


void LogAclAfterRemoteNameRequest(const RawAddress& raw_address, tBTM_STATUS status);

}  // namespace metrics
}  // namespace bluetooth
+2 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
#include "main/shim/acl_api.h"
#include "main/shim/entry.h"
#include "main/shim/helpers.h"
#include "metrics/bluetooth_event.h"
#include "osi/include/allocator.h"
#include "osi/include/properties.h"
#include "stack/btm/btm_ble_int.h"
@@ -2318,6 +2319,7 @@ void btm_sec_rmt_name_request_complete(const RawAddress* p_bd_addr, const uint8_
        /* Both we and the peer are 2.1 - continue to create connection */
        else {
          tBTM_STATUS req_status = btm_sec_dd_create_conn(p_dev_rec);
          bluetooth::metrics::LogAclAfterRemoteNameRequest(bd_addr, req_status);
          if (req_status == tBTM_STATUS::BTM_SUCCESS) {
            await_connection = false;
          } else if (req_status != BTM_CMD_STARTED) {