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

Commit e15a3054 authored by Hsin-chen Chuang's avatar Hsin-chen Chuang
Browse files

RFCOMM: Always be the DISC initiator in the DISC_WAIT_UA state

Aggressively proceed DISC if we've already in the DISC_WAIT_UA state.
This avoids a meaningless timeout which all services based on RFCOMM
would be blocked during.

Bug: 343640447
Bug: 350839022
Test: mmm packages/modules/Bluetooth
Test: manual verify no timeout on RFCOMM disconnection,
      see b/343640447#comment7
Flag: com.android.bluetooth.flags.rfcomm_always_disc_initiator_in_disc_wait_ua
Change-Id: I52b46b758cbd588dd5731c81d6620d29a0095719
parent 46185607
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -473,6 +473,7 @@ cc_fuzz {
    ],
    static_libs: [
        "bluetooth_flags_c_lib",
        "libaconfig_storage_read_api_cc",
        "libbluetooth-types",
        "libbluetooth_crypto_toolbox",
        "libbluetooth_hci_pdl",
@@ -904,6 +905,7 @@ cc_test {
        "libcutils",
    ],
    static_libs: [
        "libaconfig_storage_read_api_cc",
        "libbase",
        "libbluetooth-types",
        "libbluetooth_crypto_toolbox",
@@ -924,6 +926,7 @@ cc_test {
        "libosi",
        "libprotobuf-cpp-lite",
        "libstatslog_bt",
        "server_configurable_flags",
    ],
    target: {
        android: {
+12 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
 ******************************************************************************/

#include <bluetooth/log.h>
#include <com_android_bluetooth_flags.h>

#include <cstdint>
#include <cstring>
@@ -560,6 +561,17 @@ void rfc_port_sm_disc_wait_ua(tPORT* p_port, tRFC_PORT_EVENT event, void* p_data

    case RFC_PORT_EVENT_DM:
      log::warn("RFC_EVENT_DM|RFC_EVENT_UA[{}], index={}", event, p_port->handle);
      if (com::android::bluetooth::flags::rfcomm_always_disc_initiator_in_disc_wait_ua()) {
        // If we got a DM in RFC_STATE_DISC_WAIT_UA, it's likely that both ends
        // attempt to DISC at the same time and both get a DM.
        // Without setting this flag the both ends would start the same timers,
        // wait, and still DISC the multiplexer at the same time eventually.
        // The wait is meaningless and would block all other services that rely
        // on RFCOMM such as HFP.
        // Thus, setting this flag here to save us a timeout and doesn't
        // introduce further RFCOMM event changes.
        p_port->rfc.p_mcb->is_disc_initiator = true;
      }
      rfc_port_closed(p_port);
      return;