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

Commit 64f93e4a authored by Chris Manton's avatar Chris Manton
Browse files

stack::rnr Introduce RNR interface

Also prioritize RNR data structure

Bug: 359912830
Test: m .
Flag: EXEMPT, Mechanical Refactor

Change-Id: Ib571f4ac740d8c9944e201ec004001264e32877c
parent da9897ab
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -270,6 +270,7 @@ cc_test {
        ":TestMockStackMetrics",
        ":TestMockStackMetrics",
        ":TestMockStackPan",
        ":TestMockStackPan",
        ":TestMockStackRfcomm",
        ":TestMockStackRfcomm",
        ":TestMockStackRnr",
        "test/bta_ag_sco_test.cc",
        "test/bta_ag_sco_test.cc",
        "test/bta_ag_test.cc",
        "test/bta_ag_test.cc",
        "test/bta_api_test.cc",
        "test/bta_api_test.cc",
+5 −5
Original line number Original line Diff line number Diff line
@@ -45,6 +45,7 @@
#include "stack/include/btm_log_history.h"
#include "stack/include/btm_log_history.h"
#include "stack/include/btm_status.h"
#include "stack/include/btm_status.h"
#include "stack/include/main_thread.h"
#include "stack/include/main_thread.h"
#include "stack/include/rnr_interface.h"
#include "stack/rnr/remote_name_request.h"
#include "stack/rnr/remote_name_request.h"
#include "types/raw_address.h"
#include "types/raw_address.h"


@@ -148,8 +149,7 @@ static void bta_dm_search_cancel() {
  /* If no Service Search going on then issue cancel remote name in case it is
  /* If no Service Search going on then issue cancel remote name in case it is
     active */
     active */
  else if (!bta_dm_search_cb.name_discover_done) {
  else if (!bta_dm_search_cb.name_discover_done) {
    if (get_btm_client_interface().peer.BTM_CancelRemoteDeviceName() !=
    if (get_stack_rnr_interface().BTM_CancelRemoteDeviceName() != tBTM_STATUS::BTM_CMD_STARTED) {
        tBTM_STATUS::BTM_CMD_STARTED) {
      log::warn("Unable to cancel RNR");
      log::warn("Unable to cancel RNR");
    }
    }
    /* bta_dm_search_cmpl is called when receiving the remote name cancel evt */
    /* bta_dm_search_cmpl is called when receiving the remote name cancel evt */
@@ -297,8 +297,8 @@ static bool bta_dm_read_remote_device_name(const RawAddress& bd_addr, tBT_TRANSP
  bta_dm_search_cb.peer_bdaddr = bd_addr;
  bta_dm_search_cb.peer_bdaddr = bd_addr;
  bta_dm_search_cb.peer_name[0] = 0;
  bta_dm_search_cb.peer_name[0] = 0;


  btm_status = get_btm_client_interface().peer.BTM_ReadRemoteDeviceName(
  btm_status = get_stack_rnr_interface().BTM_ReadRemoteDeviceName(bta_dm_search_cb.peer_bdaddr,
          bta_dm_search_cb.peer_bdaddr, bta_dm_remname_cback, transport);
                                                                  bta_dm_remname_cback, transport);


  if (btm_status == tBTM_STATUS::BTM_CMD_STARTED) {
  if (btm_status == tBTM_STATUS::BTM_CMD_STARTED) {
    log::verbose("BTM_ReadRemoteDeviceName is started");
    log::verbose("BTM_ReadRemoteDeviceName is started");
@@ -435,7 +435,7 @@ static void bta_dm_search_cancel_notify() {
    case BTA_DM_SEARCH_ACTIVE:
    case BTA_DM_SEARCH_ACTIVE:
    case BTA_DM_SEARCH_CANCELLING:
    case BTA_DM_SEARCH_CANCELLING:
      if (!bta_dm_search_cb.name_discover_done) {
      if (!bta_dm_search_cb.name_discover_done) {
        if (get_btm_client_interface().peer.BTM_CancelRemoteDeviceName() !=
        if (get_stack_rnr_interface().BTM_CancelRemoteDeviceName() !=
            tBTM_STATUS::BTM_CMD_STARTED) {
            tBTM_STATUS::BTM_CMD_STARTED) {
          log::warn("Unable to cancel RNR");
          log::warn("Unable to cancel RNR");
        }
        }
+6 −7
Original line number Original line Diff line number Diff line
@@ -45,7 +45,6 @@
#include "stack/include/bt_dev_class.h"
#include "stack/include/bt_dev_class.h"
#include "stack/include/bt_name.h"
#include "stack/include/bt_name.h"
#include "stack/include/bt_uuid16.h"
#include "stack/include/bt_uuid16.h"
#include "stack/include/btm_ble_api.h"
#include "stack/include/btm_client_interface.h"
#include "stack/include/btm_client_interface.h"
#include "stack/include/btm_inq.h"
#include "stack/include/btm_inq.h"
#include "stack/include/btm_log_history.h"
#include "stack/include/btm_log_history.h"
@@ -53,6 +52,7 @@
#include "stack/include/gap_api.h"  // GAP_BleReadPeerPrefConnParams
#include "stack/include/gap_api.h"  // GAP_BleReadPeerPrefConnParams
#include "stack/include/hidh_api.h"
#include "stack/include/hidh_api.h"
#include "stack/include/main_thread.h"
#include "stack/include/main_thread.h"
#include "stack/include/rnr_interface.h"
#include "stack/include/sdp_status.h"
#include "stack/include/sdp_status.h"
#include "stack/rnr/remote_name_request.h"
#include "stack/rnr/remote_name_request.h"
#include "stack/sdp/sdpint.h"  // is_sdp_pbap_pce_disabled
#include "stack/sdp/sdpint.h"  // is_sdp_pbap_pce_disabled
@@ -309,8 +309,7 @@ static void bta_dm_search_cancel() {
  /* If no Service Search going on then issue cancel remote name in case it is
  /* If no Service Search going on then issue cancel remote name in case it is
     active */
     active */
  else if (!bta_dm_search_cb.name_discover_done) {
  else if (!bta_dm_search_cb.name_discover_done) {
    if (get_btm_client_interface().peer.BTM_CancelRemoteDeviceName() !=
    if (get_stack_rnr_interface().BTM_CancelRemoteDeviceName() != tBTM_STATUS::BTM_CMD_STARTED) {
        tBTM_STATUS::BTM_CMD_STARTED) {
      log::warn("Unable to cancel RNR");
      log::warn("Unable to cancel RNR");
    }
    }
    /* bta_dm_search_cmpl is called when receiving the remote name cancel evt */
    /* bta_dm_search_cmpl is called when receiving the remote name cancel evt */
@@ -392,8 +391,8 @@ static bool bta_dm_read_remote_device_name(const RawAddress& bd_addr, tBT_TRANSP
  bta_dm_search_cb.peer_bdaddr = bd_addr;
  bta_dm_search_cb.peer_bdaddr = bd_addr;
  bta_dm_search_cb.peer_name[0] = 0;
  bta_dm_search_cb.peer_name[0] = 0;


  btm_status = get_btm_client_interface().peer.BTM_ReadRemoteDeviceName(
  btm_status = get_stack_rnr_interface().BTM_ReadRemoteDeviceName(bta_dm_search_cb.peer_bdaddr,
          bta_dm_search_cb.peer_bdaddr, bta_dm_remname_cback, transport);
                                                                  bta_dm_remname_cback, transport);


  if (btm_status == tBTM_STATUS::BTM_CMD_STARTED) {
  if (btm_status == tBTM_STATUS::BTM_CMD_STARTED) {
    log::verbose("BTM_ReadRemoteDeviceName is started");
    log::verbose("BTM_ReadRemoteDeviceName is started");
@@ -995,7 +994,7 @@ static void bta_dm_search_cancel_notify() {
    case BTA_DM_SEARCH_ACTIVE:
    case BTA_DM_SEARCH_ACTIVE:
    case BTA_DM_SEARCH_CANCELLING:
    case BTA_DM_SEARCH_CANCELLING:
      if (!bta_dm_search_cb.name_discover_done) {
      if (!bta_dm_search_cb.name_discover_done) {
        if (get_btm_client_interface().peer.BTM_CancelRemoteDeviceName() !=
        if (get_stack_rnr_interface().BTM_CancelRemoteDeviceName() !=
            tBTM_STATUS::BTM_CMD_STARTED) {
            tBTM_STATUS::BTM_CMD_STARTED) {
          log::warn("Unable to cancel RNR");
          log::warn("Unable to cancel RNR");
        }
        }
@@ -1391,7 +1390,7 @@ static void bta_dm_service_search_remname_cback(const RawAddress& bd_addr, DEV_C
    bta_dm_remname_cback(&rem_name);
    bta_dm_remname_cback(&rem_name);
  } else {
  } else {
    /* get name of device */
    /* get name of device */
    btm_status = get_btm_client_interface().peer.BTM_ReadRemoteDeviceName(
    btm_status = get_stack_rnr_interface().BTM_ReadRemoteDeviceName(
            bta_dm_search_cb.peer_bdaddr, bta_dm_remname_cback, BT_TRANSPORT_BR_EDR);
            bta_dm_search_cb.peer_bdaddr, bta_dm_remname_cback, BT_TRANSPORT_BR_EDR);
    if (btm_status == tBTM_STATUS::BTM_BUSY) {
    if (btm_status == tBTM_STATUS::BTM_BUSY) {
      /* wait for next chance(notification of remote name discovery done) */
      /* wait for next chance(notification of remote name discovery done) */
+5 −4
Original line number Original line Diff line number Diff line
@@ -32,6 +32,7 @@
#include "stack/include/btm_sec_api.h"
#include "stack/include/btm_sec_api.h"
#include "stack/include/btm_status.h"
#include "stack/include/btm_status.h"
#include "stack/include/gatt_api.h"
#include "stack/include/gatt_api.h"
#include "stack/include/rnr_interface.h"
#include "stack/include/security_client_callbacks.h"
#include "stack/include/security_client_callbacks.h"
#include "types/bt_transport.h"
#include "types/bt_transport.h"
#include "types/raw_address.h"
#include "types/raw_address.h"
@@ -265,7 +266,7 @@ static tBTM_STATUS bta_dm_pin_cback(const RawAddress& bd_addr, DEV_CLASS dev_cla
    bta_dm_sec_cb.pin_evt = BTA_DM_PIN_REQ_EVT;
    bta_dm_sec_cb.pin_evt = BTA_DM_PIN_REQ_EVT;
    bta_dm_sec_cb.pin_bd_addr = bd_addr;
    bta_dm_sec_cb.pin_bd_addr = bd_addr;
    bta_dm_sec_cb.pin_dev_class = dev_class;
    bta_dm_sec_cb.pin_dev_class = dev_class;
    if ((get_btm_client_interface().peer.BTM_ReadRemoteDeviceName(bd_addr, bta_dm_pinname_cback,
    if ((get_stack_rnr_interface().BTM_ReadRemoteDeviceName(bd_addr, bta_dm_pinname_cback,
                                                            BT_TRANSPORT_BR_EDR)) ==
                                                            BT_TRANSPORT_BR_EDR)) ==
        tBTM_STATUS::BTM_CMD_STARTED) {
        tBTM_STATUS::BTM_CMD_STARTED) {
      return tBTM_STATUS::BTM_CMD_STARTED;
      return tBTM_STATUS::BTM_CMD_STARTED;
@@ -454,7 +455,7 @@ static tBTM_STATUS bta_dm_sp_cback(tBTM_SP_EVT event, tBTM_SP_EVT_DATA* p_data)
          log::info("CoD: bta_dm_sec_cb.pin_dev_class = {}",
          log::info("CoD: bta_dm_sec_cb.pin_dev_class = {}",
                    dev_class_text(bta_dm_sec_cb.pin_dev_class));
                    dev_class_text(bta_dm_sec_cb.pin_dev_class));
          {
          {
            const tBTM_STATUS btm_status = get_btm_client_interface().peer.BTM_ReadRemoteDeviceName(
            const tBTM_STATUS btm_status = get_stack_rnr_interface().BTM_ReadRemoteDeviceName(
                    p_data->cfm_req.bd_addr, bta_dm_pinname_cback, BT_TRANSPORT_BR_EDR);
                    p_data->cfm_req.bd_addr, bta_dm_pinname_cback, BT_TRANSPORT_BR_EDR);
            switch (btm_status) {
            switch (btm_status) {
              case tBTM_STATUS::BTM_CMD_STARTED:
              case tBTM_STATUS::BTM_CMD_STARTED:
@@ -475,7 +476,7 @@ static tBTM_STATUS bta_dm_sp_cback(tBTM_SP_EVT event, tBTM_SP_EVT_DATA* p_data)
          bta_dm_sec_cb.pin_evt = pin_evt;
          bta_dm_sec_cb.pin_evt = pin_evt;
          bta_dm_sec_cb.pin_bd_addr = p_data->key_notif.bd_addr;
          bta_dm_sec_cb.pin_bd_addr = p_data->key_notif.bd_addr;
          bta_dm_sec_cb.pin_dev_class = p_data->key_notif.dev_class;
          bta_dm_sec_cb.pin_dev_class = p_data->key_notif.dev_class;
          if ((get_btm_client_interface().peer.BTM_ReadRemoteDeviceName(
          if ((get_stack_rnr_interface().BTM_ReadRemoteDeviceName(
                      p_data->key_notif.bd_addr, bta_dm_pinname_cback, BT_TRANSPORT_BR_EDR)) ==
                      p_data->key_notif.bd_addr, bta_dm_pinname_cback, BT_TRANSPORT_BR_EDR)) ==
              tBTM_STATUS::BTM_CMD_STARTED) {
              tBTM_STATUS::BTM_CMD_STARTED) {
            return tBTM_STATUS::BTM_CMD_STARTED;
            return tBTM_STATUS::BTM_CMD_STARTED;
+6 −2
Original line number Original line Diff line number Diff line
@@ -32,14 +32,15 @@
#include "bta/test/bta_test_fixtures.h"
#include "bta/test/bta_test_fixtures.h"
#include "bta_api_data_types.h"
#include "bta_api_data_types.h"
#include "stack/btm/neighbor_inquiry.h"
#include "stack/btm/neighbor_inquiry.h"
#include "stack/include/gatt_api.h"
#include "test/common/main_handler.h"
#include "types/bt_transport.h"
#include "types/bt_transport.h"


#define TEST_BT com::android::bluetooth::flags
#define TEST_BT com::android::bluetooth::flags


using namespace bluetooth;
using namespace bluetooth;


using ::testing::_;
using ::testing::Return;

namespace {
namespace {
const RawAddress kRawAddress({0x11, 0x22, 0x33, 0x44, 0x55, 0x66});
const RawAddress kRawAddress({0x11, 0x22, 0x33, 0x44, 0x55, 0x66});
}
}
@@ -153,6 +154,9 @@ TEST_F(BtaInitializedTest, bta_dm_queue_search) {
}
}


TEST_F(BtaInitializedTest, bta_dm_read_remote_device_name) {
TEST_F(BtaInitializedTest, bta_dm_read_remote_device_name) {
  EXPECT_CALL(mock_stack_rnr_interface_, BTM_ReadRemoteDeviceName(_, _, _))
          .WillOnce(Return(tBTM_STATUS::BTM_CMD_STARTED));

  bluetooth::legacy::testing::bta_dm_read_remote_device_name(kRawAddress, BT_TRANSPORT_BR_EDR);
  bluetooth::legacy::testing::bta_dm_read_remote_device_name(kRawAddress, BT_TRANSPORT_BR_EDR);
}
}


Loading