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

Commit 9f5aeb0d authored by Chris Manton's avatar Chris Manton
Browse files

profile::avrcp Use proper type tSDP_STATUS

Bug: 354043719
Test: m .
Flag: EXEMPT, Proper Data Type

Change-Id: I4ced5d169b453e6257ae221e7f9be911ba3ebb38
parent 59856e1a
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -46,6 +46,7 @@
#include "stack/include/btm_client_interface.h"
#include "stack/include/btm_client_interface.h"
#include "stack/include/l2c_api.h"
#include "stack/include/l2c_api.h"
#include "stack/include/sdp_api.h"
#include "stack/include/sdp_api.h"
#include "stack/include/sdp_status.h"
#include "types/raw_address.h"
#include "types/raw_address.h"


using namespace bluetooth::legacy::stack::sdp;
using namespace bluetooth::legacy::stack::sdp;
@@ -199,7 +200,7 @@ static void bta_av_del_sdp_rec(uint32_t* p_sdp_handle) {
 * Returns          void
 * Returns          void
 *
 *
 ******************************************************************************/
 ******************************************************************************/
static void bta_av_avrc_sdp_cback(uint16_t /* status */) {
static void bta_av_avrc_sdp_cback(tSDP_STATUS /* status */) {
  BT_HDR_RIGID* p_msg = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID));
  BT_HDR_RIGID* p_msg = (BT_HDR_RIGID*)osi_malloc(sizeof(BT_HDR_RIGID));


  p_msg->event = BTA_AV_SDP_AVRC_DISC_EVT;
  p_msg->event = BTA_AV_SDP_AVRC_DISC_EVT;
+1 −0
Original line number Original line Diff line number Diff line
@@ -22,6 +22,7 @@
#include "stack/include/avrc_api.h"
#include "stack/include/avrc_api.h"
#include "stack/include/bt_types.h"
#include "stack/include/bt_types.h"
#include "stack/include/bt_uuid16.h"
#include "stack/include/bt_uuid16.h"
#include "stack/include/sdp_api.h"


using namespace bluetooth::legacy::stack::sdp;
using namespace bluetooth::legacy::stack::sdp;


+5 −4
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@
#include "packet/avrcp/avrcp_packet.h"
#include "packet/avrcp/avrcp_packet.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_uuid16.h"
#include "stack/include/bt_uuid16.h"
#include "stack/include/sdp_status.h"
#include "types/raw_address.h"
#include "types/raw_address.h"


extern bool btif_av_peer_is_connected_sink(const RawAddress& peer_address);
extern bool btif_av_peer_is_connected_sink(const RawAddress& peer_address);
@@ -134,9 +135,9 @@ bool ConnectionHandler::ConnectDevice(const RawAddress& bdaddr) {
  }
  }


  auto connection_lambda = [](ConnectionHandler* instance_, const RawAddress& bdaddr,
  auto connection_lambda = [](ConnectionHandler* instance_, const RawAddress& bdaddr,
                              uint16_t status, uint16_t version, uint16_t features) {
                              tSDP_STATUS status, uint16_t version, uint16_t features) {
    log::info("SDP Completed features=0x{:x}", features);
    log::info("SDP Completed features=0x{:x}", features);
    if (status != AVRC_SUCCESS || !(features & BTA_AV_FEAT_RCCT)) {
    if (status != SDP_SUCCESS || !(features & BTA_AV_FEAT_RCCT)) {
      log::error(
      log::error(
              "Failed to do SDP: status=0x{:x} features=0x{:x} supports "
              "Failed to do SDP: status=0x{:x} features=0x{:x} supports "
              "controller: {}",
              "controller: {}",
@@ -367,7 +368,7 @@ void ConnectionHandler::AcceptorControlCb(uint8_t handle, uint8_t event, uint16_
      connection_cb_.Run(newDevice);
      connection_cb_.Run(newDevice);


      log::info("Performing SDP on connected device. address={}", *peer_addr);
      log::info("Performing SDP on connected device. address={}", *peer_addr);
      auto sdp_lambda = [](ConnectionHandler* instance_, uint8_t handle, uint16_t status,
      auto sdp_lambda = [](ConnectionHandler* instance_, uint8_t handle, tSDP_STATUS status,
                           uint16_t version, uint16_t features) {
                           uint16_t version, uint16_t features) {
        if (instance_->device_map_.find(handle) == instance_->device_map_.end()) {
        if (instance_->device_map_.find(handle) == instance_->device_map_.end()) {
          log::warn("No device found for handle: 0x{:x}", handle);
          log::warn("No device found for handle: 0x{:x}", handle);
@@ -473,7 +474,7 @@ void ConnectionHandler::MessageCb(uint8_t handle, uint8_t label, uint8_t opcode,
}
}


void ConnectionHandler::SdpCb(RawAddress bdaddr, SdpCallback cb, tSDP_DISCOVERY_DB* disc_db,
void ConnectionHandler::SdpCb(RawAddress bdaddr, SdpCallback cb, tSDP_DISCOVERY_DB* disc_db,
                              bool retry, uint16_t status) {
                              bool retry, tSDP_STATUS status) {
  log::verbose("SDP lookup callback received");
  log::verbose("SDP lookup callback received");


  if (status == SDP_CONN_FAILED && !retry) {
  if (status == SDP_CONN_FAILED && !retry) {
+3 −3
Original line number Original line Diff line number Diff line
@@ -24,10 +24,10 @@
#include <vector>
#include <vector>


#include "avrcp_internal.h"
#include "avrcp_internal.h"
#include "packet/avrcp/avrcp_packet.h"
#include "packet/base/packet.h"
#include "packet/base/packet.h"
#include "profile/avrcp/device.h"
#include "profile/avrcp/device.h"
#include "raw_address.h"
#include "raw_address.h"
#include "stack/include/sdp_status.h"


namespace bluetooth {
namespace bluetooth {
namespace avrcp {
namespace avrcp {
@@ -144,10 +144,10 @@ private:


  static ConnectionHandler* instance_;
  static ConnectionHandler* instance_;


  using SdpCallback = base::Callback<void(uint16_t status, uint16_t version, uint16_t features)>;
  using SdpCallback = base::Callback<void(tSDP_STATUS status, uint16_t version, uint16_t features)>;
  virtual bool SdpLookup(const RawAddress& bdaddr, SdpCallback cb, bool retry);
  virtual bool SdpLookup(const RawAddress& bdaddr, SdpCallback cb, bool retry);
  void SdpCb(RawAddress bdaddr, SdpCallback cb, tSDP_DISCOVERY_DB* disc_db, bool retry,
  void SdpCb(RawAddress bdaddr, SdpCallback cb, tSDP_DISCOVERY_DB* disc_db, bool retry,
             uint16_t status);
             tSDP_STATUS status);


  virtual bool AvrcpConnect(bool initiator, const RawAddress& bdaddr);
  virtual bool AvrcpConnect(bool initiator, const RawAddress& bdaddr);


+10 −9
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@
#include "avrcp_test_helper.h"
#include "avrcp_test_helper.h"
#include "connection_handler.h"
#include "connection_handler.h"
#include "sdpdefs.h"
#include "sdpdefs.h"
#include "stack/include/sdp_status.h"
#include "types/raw_address.h"
#include "types/raw_address.h"


using ::testing::_;
using ::testing::_;
@@ -213,7 +214,7 @@ TEST_F(AvrcpConnectionHandlerTest, remoteDeviceConnectionTest) {
  conn_cb.ctrl_cback.Run(1, AVRC_OPEN_IND_EVT, 0, &RawAddress::kAny);
  conn_cb.ctrl_cback.Run(1, AVRC_OPEN_IND_EVT, 0, &RawAddress::kAny);


  // Run the SDP callback with status success
  // Run the SDP callback with status success
  sdp_cb.Run(0);
  sdp_cb.Run(SDP_SUCCESS);


  // Check that a device was created
  // Check that a device was created
  ASSERT_TRUE(current_device_ != nullptr);
  ASSERT_TRUE(current_device_ != nullptr);
@@ -255,7 +256,7 @@ TEST_F(AvrcpConnectionHandlerTest, noAbsoluteVolumeTest) {
  conn_cb.ctrl_cback.Run(1, AVRC_OPEN_IND_EVT, 0, &RawAddress::kAny);
  conn_cb.ctrl_cback.Run(1, AVRC_OPEN_IND_EVT, 0, &RawAddress::kAny);


  // Run the SDP callback with status success
  // Run the SDP callback with status success
  sdp_cb.Run(0);
  sdp_cb.Run(SDP_SUCCESS);


  // Check that a device was created
  // Check that a device was created
  ASSERT_TRUE(current_device_ != nullptr);
  ASSERT_TRUE(current_device_ != nullptr);
@@ -297,7 +298,7 @@ TEST_F(AvrcpConnectionHandlerTest, absoluteVolumeTest) {
  conn_cb.ctrl_cback.Run(1, AVRC_OPEN_IND_EVT, 0, &RawAddress::kAny);
  conn_cb.ctrl_cback.Run(1, AVRC_OPEN_IND_EVT, 0, &RawAddress::kAny);


  // Run the SDP callback with status success
  // Run the SDP callback with status success
  sdp_cb.Run(0);
  sdp_cb.Run(SDP_SUCCESS);


  // Check that a device was created
  // Check that a device was created
  ASSERT_TRUE(current_device_ != nullptr);
  ASSERT_TRUE(current_device_ != nullptr);
@@ -380,7 +381,7 @@ TEST_F(AvrcpConnectionHandlerTest, multipleRemoteDeviceConnectionTest) {
  current_device_.reset();
  current_device_.reset();


  // Run the SDP callback with status success
  // Run the SDP callback with status success
  sdp_cb.Run(0);
  sdp_cb.Run(SDP_SUCCESS);


  // Set an Expectations that SDP will be performed again
  // Set an Expectations that SDP will be performed again
  SetUpSdp(&sdp_cb, false, false);
  SetUpSdp(&sdp_cb, false, false);
@@ -397,7 +398,7 @@ TEST_F(AvrcpConnectionHandlerTest, multipleRemoteDeviceConnectionTest) {
  ASSERT_TRUE(current_device_ != nullptr);
  ASSERT_TRUE(current_device_ != nullptr);


  // Run the SDP callback with status success
  // Run the SDP callback with status success
  sdp_cb.Run(0);
  sdp_cb.Run(SDP_SUCCESS);


  connection_handler_ = nullptr;
  connection_handler_ = nullptr;
  ConnectionHandler::CleanUp();
  ConnectionHandler::CleanUp();
@@ -451,7 +452,7 @@ TEST_F(AvrcpConnectionHandlerTest, connectToRemoteDeviceTest) {
          .WillOnce(DoAll(SetArgPointee<0>(1), SaveArgPointee<1>(&conn_cb), Return(0)));
          .WillOnce(DoAll(SetArgPointee<0>(1), SaveArgPointee<1>(&conn_cb), Return(0)));


  // Complete SDP
  // Complete SDP
  sdp_cb.Run(0);
  sdp_cb.Run(SDP_SUCCESS);


  // Check that the callback was sent with us as the initiator
  // Check that the callback was sent with us as the initiator
  ASSERT_EQ(conn_cb.conn, 0);
  ASSERT_EQ(conn_cb.conn, 0);
@@ -493,7 +494,7 @@ TEST_F(AvrcpConnectionHandlerTest, connectToBrowsableRemoteDeviceTest) {
          .WillOnce(DoAll(SetArgPointee<0>(1), SaveArgPointee<1>(&conn_cb), Return(0)));
          .WillOnce(DoAll(SetArgPointee<0>(1), SaveArgPointee<1>(&conn_cb), Return(0)));


  // Complete SDP
  // Complete SDP
  sdp_cb.Run(0);
  sdp_cb.Run(SDP_SUCCESS);


  // Check that the callback was sent with us as the initiator
  // Check that the callback was sent with us as the initiator
  ASSERT_EQ(conn_cb.conn, 0);
  ASSERT_EQ(conn_cb.conn, 0);
@@ -543,7 +544,7 @@ TEST_F(AvrcpConnectionHandlerTest, disconnectWhileDoingSdpTest) {
  conn_cb.ctrl_cback.Run(1, AVRC_CLOSE_IND_EVT, 0, &RawAddress::kAny);
  conn_cb.ctrl_cback.Run(1, AVRC_CLOSE_IND_EVT, 0, &RawAddress::kAny);


  // Signal that SDP has completed
  // Signal that SDP has completed
  sdp_cb.Run(0);
  sdp_cb.Run(SDP_SUCCESS);


  connection_handler_ = nullptr;
  connection_handler_ = nullptr;
  ConnectionHandler::CleanUp();
  ConnectionHandler::CleanUp();
@@ -592,7 +593,7 @@ TEST_F(AvrcpConnectionHandlerTest, connectionCollisionTest) {
  EXPECT_CALL(mock_avrcp_, Close(_));
  EXPECT_CALL(mock_avrcp_, Close(_));


  // Run the SDP callback with status success
  // Run the SDP callback with status success
  sdp_cb.Run(0);
  sdp_cb.Run(SDP_SUCCESS);


  connection_handler_ = nullptr;
  connection_handler_ = nullptr;
  ConnectionHandler::CleanUp();
  ConnectionHandler::CleanUp();
Loading