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

Commit 6975520f authored by Zhengping Jiang's avatar Zhengping Jiang
Browse files

floss: not do service discovery with HIDSDPDisable

If HIDSDPDisable is set, do not start service discovery after hid
profile is connected.

Bug: 272146455
Test: mma -j32

Change-Id: I3c05761b6eeb0525a48baa5fc97fc7a9c4f43b09
parent 0eb003a9
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -238,6 +238,7 @@ cc_test {
        ":TestMockStackBtm",
        ":TestMockStackGap",
        ":TestMockStackGatt",
        ":TestMockStackHid",
        ":TestMockStackL2cap",
        ":TestMockStackMetrics",
        ":TestMockStackPan",
+12 −2
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@
#include "stack/include/btm_log_history.h"
#include "stack/include/btm_sec_api.h"  // BTM_IsRemoteNameKnown
#include "stack/include/gap_api.h"      // GAP_BleReadPeerPrefConnParams
#include "stack/include/hidh_api.h"
#include "stack/include/sdp_status.h"
#include "stack/sdp/sdpint.h"  // is_sdp_pbap_pce_disabled
#include "types/raw_address.h"
@@ -1361,8 +1362,17 @@ static void bta_dm_discover_device(const RawAddress& remote_bd_addr) {
  /* Reset transport state for next discovery */
  bta_dm_search_cb.transport = BT_TRANSPORT_AUTO;

  /* if application wants to discover service */
  if (bta_dm_search_cb.services) {
  bool sdp_disable = HID_HostSDPDisable(remote_bd_addr);
  if (sdp_disable)
    LOG_DEBUG("peer:%s with HIDSDPDisable attribute.",
              ADDRESS_TO_LOGGABLE_CSTR(remote_bd_addr));

  /* if application wants to discover service and HIDSDPDisable attribute is
     false.
     Classic mouses with this attribute should not start SDP here, because the
     SDP has been done during bonding. SDP request here will interleave with
     connections to the Control or Interrupt channels */
  if (bta_dm_search_cb.services && !sdp_disable) {
    BTM_LogHistory(kBtmLogTag, remote_bd_addr, "Discovery started ",
                   base::StringPrintf("Transport:%s",
                                      bt_transport_text(transport).c_str()));
+20 −1
Original line number Diff line number Diff line
@@ -319,6 +319,25 @@ tHID_STATUS HID_HostDeregister(void) {
  return (HID_SUCCESS);
}

/*******************************************************************************
 *
 * Function         HID_HostSDPDisable
 *
 * Description      This is called to check if the device has the HIDSDPDisable
 *                  attribute.
 *
 * Returns          bool
 *
 ******************************************************************************/
bool HID_HostSDPDisable(const RawAddress& addr) {
  for (int i = 0; i < HID_HOST_MAX_DEVICES; i++) {
    if (hh_cb.devices[i].in_use && (hh_cb.devices[i].addr == addr)) {
      return (hh_cb.devices[i].attr_mask & HID_SDP_DISABLE);
    }
  }
  return false;
}

/*******************************************************************************
 *
 * Function         HID_HostAddDev
@@ -358,7 +377,7 @@ tHID_STATUS HID_HostAddDev(const RawAddress& addr, uint16_t attr_mask,
    hh_cb.devices[i].conn_tries = 0;
  }

  if (attr_mask != HID_ATTR_MASK_IGNORE) hh_cb.devices[i].attr_mask = attr_mask;
  hh_cb.devices[i].attr_mask = attr_mask;

  *handle = i;

+12 −0
Original line number Diff line number Diff line
@@ -124,6 +124,18 @@ tHID_STATUS HID_HostRegister(tHID_HOST_DEV_CALLBACK* dev_cback);
 ******************************************************************************/
tHID_STATUS HID_HostDeregister(void);

/*******************************************************************************
 *
 * Function         HID_HostSDPDisable
 *
 * Description      This is called to check if the device has the HIDSDPDisable
 *                  attribute.
 *
 * Returns          bool
 *
 ******************************************************************************/
bool HID_HostSDPDisable(const RawAddress& addr);

/*******************************************************************************
 *
 * Function         HID_HostAddDev
+4 −0
Original line number Diff line number Diff line
@@ -47,6 +47,10 @@ tHID_STATUS HID_HostGetSDPRecord(const RawAddress& /* addr */,
  inc_func_call_count(__func__);
  return HID_SUCCESS;
}
bool HID_HostSDPDisable(const RawAddress& /* addr */) {
  inc_func_call_count(__func__);
  return false;
}
tHID_STATUS HID_HostOpenDev(uint8_t /* dev_handle */) {
  inc_func_call_count(__func__);
  return HID_SUCCESS;