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

Commit a8e99ffd authored by Ying Hsu's avatar Ying Hsu Committed by Archie Pusaka
Browse files

floss: Avoid extra authentication for a secure RFCOMM connection

When a RFCOMM client initiates a secure connection with a temporary link
key,  it will trigger an additional authentication with MTIM protection.
The second connection not only takes extra time but also leads to RFCOMM
disconnection from the RFCOMM server running on some Android 11 devices.

This behavior was introduced in the commit 6fa9d175
(“Add RFCOMM_CreateConnectionWithSecurity”).
This patch addresses the issue by updating the security record during
RFCOMM connection setup, eliminating unnecessary authentication

Bug: 312840315
Bug: 316824288
Tag: #floss
Test: CTS verifier 11r8 Bluetooth tests, using Pixel 4 as server
Test: m -j

Change-Id: I5f0a71b474460efcc396ea5e0c053db72e5a5abe
parent 08f3bdb6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -380,6 +380,7 @@ cc_test {
        "liblog",
        "libprotobuf-cpp-lite",
        "libstatssocket",
        "server_configurable_flags",
    ],
    static_libs: [
        "libbluetooth-types",
@@ -434,8 +435,10 @@ cc_test {
        "libcrypto",
        "libcutils",
        "liblog",
        "server_configurable_flags",
    ],
    static_libs: [
        "bluetooth_flags_c_lib",
        "libbluetooth-types",
        "libbt-common",
        "libbt-platform-protos-lite",
+15 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include <cstdint>
#include <unordered_set>

#include "android_bluetooth_flags.h"
#include "bta/include/bta_jv_co.h"
#include "bta/include/bta_rfcomm_scn.h"
#include "bta/jv/bta_jv_int.h"
@@ -1372,6 +1373,20 @@ void bta_jv_rfcomm_connect(tBTA_SEC sec_mask, uint8_t remote_scn,
  tBTA_JV_RFCOMM_CL_INIT evt_data;
  memset(&evt_data, 0, sizeof(evt_data));
  evt_data.status = BTA_JV_SUCCESS;

#ifdef TARGET_FLOSS
  if (true)
#else
  if (IS_FLAG_ENABLED(rfcomm_always_use_mitm))
#endif
  {
    // Update security service record for RFCOMM client so that
    // secure RFCOMM connection will be authenticated with MTIM protection
    // while creating the L2CAP connection.
    BTM_SetSecurityLevel(true, "RFC_MUX", BTM_SEC_SERVICE_RFC_MUX, sec_mask,
                         BT_PSM_RFCOMM, BTM_SEC_PROTO_RFCOMM, 0);
  }

  if (evt_data.status == BTA_JV_SUCCESS &&
      RFCOMM_CreateConnectionWithSecurity(
          UUID_SERVCLASS_SERIAL_PORT, remote_scn, false, BTA_JV_DEF_RFC_MTU,