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

Commit f26bebe5 authored by Michael Sun's avatar Michael Sun
Browse files

interop: add an interop rule to delay authentication

Instead of applying a system-wide authentication delay, which
introduced unnecessary latency to connection establishment, this patch
allows applying delay based on specific devices. The patch updates the
property fetch logic to allow the system property to remain untouched
if the system requires a universal delay, while also allowing systems
that require device-specific delays to be possible.

Bug: 301563951
Tag: #floss
Test: mma -j32
Test: emerge-brya floss
Test: Pixel Buds connected with Floss
FLAG: EXEMPT, floss-only: interop is no-op for android
Change-Id: I2b9cad82ce7d9e48ba6d8ac7b7b1d31fd3010da6
parent 4489c713
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -343,6 +343,10 @@ typedef enum {
  // It is required for some devices to provide sound.
  INTEROP_INSERT_CALL_WHEN_SCO_START,

  // Some device need the host to delay authentication process to avoid
  // collision.
  INTEROP_DELAY_AUTH,

  END_OF_INTEROP_LIST
} interop_feature_t;

+1 −0
Original line number Diff line number Diff line
@@ -394,6 +394,7 @@ static const char* interop_feature_string_(const interop_feature_t feature) {
    CASE_RETURN_STR(INTEROP_IGNORE_DISC_BEFORE_SIGNALLING_TIMEOUT);
    CASE_RETURN_STR(INTEROP_SUSPEND_ATT_TRAFFIC_DURING_PAIRING);
    CASE_RETURN_STR(INTEROP_INSERT_CALL_WHEN_SCO_START);
    CASE_RETURN_STR(INTEROP_DELAY_AUTH);
  }
  return UNKNOWN_INTEROP_FEATURE;
}
+9 −2
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@
#include "common/time_util.h"
#include "device/include/controller.h"
#include "device/include/device_iot_config.h"
#include "device/include/interop.h"
#include "internal_include/bt_target.h"
#include "l2c_api.h"
#include "osi/include/allocator.h"
@@ -80,6 +81,7 @@ constexpr char kBtmLogTag[] = "SEC";
extern tBTM_CB btm_cb;

#define BTM_SEC_MAX_COLLISION_DELAY (5000)
#define BTM_SEC_START_AUTH_DELAY (200)

#define BTM_SEC_IS_SM4(sm) ((bool)(BTM_SM4_TRUE == ((sm)&BTM_SM4_TRUE)))
#define BTM_SEC_IS_SM4_LEGACY(sm) ((bool)(BTM_SM4_KNOWN == ((sm)&BTM_SM4_TRUE)))
@@ -4487,10 +4489,15 @@ static bool btm_sec_start_get_name(tBTM_SEC_DEV_REC* p_dev_rec) {
 ******************************************************************************/
static void btm_sec_wait_and_start_authentication(tBTM_SEC_DEV_REC* p_dev_rec) {
  auto addr = new RawAddress(p_dev_rec->bd_addr);

  static const int32_t delay_auth =
  int32_t delay_auth =
      osi_property_get_int32("bluetooth.btm.sec.delay_auth_ms.value", 0);

  /* Overwrite the system-wide authentication delay if device-specific
   * interoperability delay is needed. */
  if (interop_match_addr(INTEROP_DELAY_AUTH, addr)) {
    delay_auth = BTM_SEC_START_AUTH_DELAY;
  }

  bt_status_t status = do_in_main_thread_delayed(
      FROM_HERE, base::Bind(&btm_sec_auth_timer_timeout, addr),
#if BASE_VER < 931007