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

Commit bcafe9c0 authored by Himanshu Rawat's avatar Himanshu Rawat
Browse files

Allow multiple outgoing HID connections

After successful pairing and service discovery, profile connections are
initiated. Default transport for HID host is BR/EDR, so it initiates
BR/EDR HID connection. The settings app decides to use LE transport and
calls BluetoothHidHost.setPreferredTransport() with LE transport. This
triggers the HID host service into requesting disconnection over BR/EDR
and connection over LE.
Since BTA HH does not offer any interface for cancelling the connection,
the disconnection request gets ignored. And since BTIF HH is in
connection state, the connection request also gets ignored.

Test: mmm packags/modules/Bluetooth
Test: Pair with earbuds supporting both DSA 1.0 and DSA 2.0
Flag: com.android.bluetooth.flags.initiate_multiple_hid_connections
Bug: 347241319
Bug: 356141637
Change-Id: I5d2d054e64704c4ee4a6d7c9dd16a0fdb8138d19
parent b93367df
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -1559,7 +1559,8 @@ static bt_status_t connect(RawAddress* bd_addr, tBLE_ADDR_TYPE addr_type, tBT_TR

  BTHH_LOG_LINK(link_spec);

  if (!btif_hh_cb.pending_connections.empty()) {
  if (!com::android::bluetooth::flags::initiate_multiple_hid_connections() &&
      !btif_hh_cb.pending_connections.empty()) {
    log::warn("HH status = {}", btif_hh_status_text(btif_hh_cb.status));
    return BT_STATUS_BUSY;
  } else if (btif_hh_cb.status == BTIF_HH_DISABLED || btif_hh_cb.status == BTIF_HH_DISABLING) {
@@ -1625,6 +1626,13 @@ static bt_status_t disconnect(RawAddress* bd_addr, tBLE_ADDR_TYPE addr_type,
                  bthh_connection_state_text(p_dev->dev_status));
        p_dev->dev_status = BTHH_CONN_STATE_DISCONNECTED;
        return BT_STATUS_DONE;
      } else if (com::android::bluetooth::flags::initiate_multiple_hid_connections() &&
                 std::find(btif_hh_cb.pending_connections.begin(),
                           btif_hh_cb.pending_connections.end(),
                           link_spec) != btif_hh_cb.pending_connections.end()) {
        btif_hh_cb.pending_connections.remove(link_spec);
        log::info("Pending connection cancelled {}", link_spec);
        return BT_STATUS_SUCCESS;
      }
    }