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

Commit 28f4e21b authored by Ted Wang's avatar Ted Wang
Browse files

Retry service discovery for Avrcp if due to sdp connection failed

Some remote devices are not allow multiple l2cap connection with same
psm, so service discovery for Avrcp might failed due to this reason,
causing absolute volume not enable on this device.
Retry one time if the reason of service discovery fail reason is sdp
connection failed.

Bug: 150354122
Test: Manually Test
Merged-In: I3bb511434788211950884f72ff0a1256533aaa05
Change-Id: I3bb511434788211950884f72ff0a1256533aaa05
parent 921bcc3c
Loading
Loading
Loading
Loading
+16 −10
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ bool ConnectionHandler::ConnectDevice(const RawAddress& bdaddr) {
    return;
  };

  return SdpLookup(bdaddr, base::Bind(connection_lambda, this, bdaddr));
  return SdpLookup(bdaddr, base::Bind(connection_lambda, this, bdaddr), false);
}

bool ConnectionHandler::DisconnectDevice(const RawAddress& bdaddr) {
@@ -155,7 +155,8 @@ std::vector<std::shared_ptr<Device>> ConnectionHandler::GetListOfDevices()
  return list;
}

bool ConnectionHandler::SdpLookup(const RawAddress& bdaddr, SdpCallback cb) {
bool ConnectionHandler::SdpLookup(const RawAddress& bdaddr, SdpCallback cb,
                                  bool retry) {
  LOG(INFO) << __PRETTY_FUNCTION__;

  tAVRC_SDP_DB_PARAMS db_params;
@@ -172,11 +173,11 @@ bool ConnectionHandler::SdpLookup(const RawAddress& bdaddr, SdpCallback cb) {
  db_params.p_db = disc_db;
  db_params.p_attrs = attr_list;

  return avrc_->FindService(
             UUID_SERVCLASS_AV_REMOTE_CONTROL, bdaddr, &db_params,
  return avrc_->FindService(UUID_SERVCLASS_AV_REMOTE_CONTROL, bdaddr,
                            &db_params,
                            base::Bind(&ConnectionHandler::SdpCb,
                        weak_ptr_factory_.GetWeakPtr(), bdaddr, cb, disc_db)) ==
         AVRC_SUCCESS;
                                       weak_ptr_factory_.GetWeakPtr(), bdaddr,
                                       cb, disc_db, retry)) == AVRC_SUCCESS;
}

bool ConnectionHandler::AvrcpConnect(bool initiator, const RawAddress& bdaddr) {
@@ -342,7 +343,7 @@ void ConnectionHandler::AcceptorControlCb(uint8_t handle, uint8_t event,
        }
      };

      SdpLookup(*peer_addr, base::Bind(sdp_lambda, this, handle));
      SdpLookup(*peer_addr, base::Bind(sdp_lambda, this, handle), false);

      avrc_->OpenBrowse(handle, AVCT_ACP);
      AvrcpConnect(false, RawAddress::kAny);
@@ -406,10 +407,15 @@ void ConnectionHandler::MessageCb(uint8_t handle, uint8_t label, uint8_t opcode,
}

void ConnectionHandler::SdpCb(const RawAddress& bdaddr, SdpCallback cb,
                              tSDP_DISCOVERY_DB* disc_db, uint16_t status) {
                              tSDP_DISCOVERY_DB* disc_db, bool retry,
                              uint16_t status) {
  LOG(INFO) << __PRETTY_FUNCTION__ << ": SDP lookup callback received";

  if (status != AVRC_SUCCESS) {
  if (status == SDP_CONN_FAILED and !retry) {
    LOG(WARNING) << __PRETTY_FUNCTION__ << ": SDP Failure retry again";
    SdpLookup(bdaddr, cb, true);
    return;
  } else if (status != AVRC_SUCCESS) {
    LOG(ERROR) << __PRETTY_FUNCTION__
               << ": SDP Failure: status = " << (unsigned int)status;
    cb.Run(status, 0, 0);
+2 −2
Original line number Diff line number Diff line
@@ -135,9 +135,9 @@ class ConnectionHandler {

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

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