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

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

Use LE as default transport for GATT

When the application does not specify transport for the GATT connections, use LE transport if LE is supported.

Test: mmm packages/modules/Bluetooth
Flag: com.android.bluetooth.flags.default_gatt_transport
Bug: 372973407
Bug: 376276742

Change-Id: I99a7e18972a1389179f814ae52d083d565a1b3d3
parent b22e0087
Loading
Loading
Loading
Loading
+24 −18
Original line number Diff line number Diff line
@@ -332,6 +332,10 @@ void btif_gattc_open_impl(int client_if, RawAddress address, tBLE_ADDR_TYPE addr

  // Determine transport
  if (transport == BT_TRANSPORT_AUTO) {
    if (com::android::bluetooth::flags::default_gatt_transport()) {
      // Prefer LE transport when LE is supported
      transport = (device_type == BT_DEVICE_TYPE_BREDR) ? BT_TRANSPORT_BR_EDR : BT_TRANSPORT_LE;
    } else {
      switch (device_type) {
        case BT_DEVICE_TYPE_BREDR:
          transport = BT_TRANSPORT_BR_EDR;
@@ -347,11 +351,13 @@ void btif_gattc_open_impl(int client_if, RawAddress address, tBLE_ADDR_TYPE addr

        default:
          log::error("Unknown device type {}", DeviceTypeText(device_type));
        // transport must not be AUTO for finding control blocks. Use LE for backward compatibility.
          // transport must not be AUTO for finding control blocks. Use LE for backward
          // compatibility.
          transport = BT_TRANSPORT_LE;
          break;
      }
    }
  }

  // Connect!
  log::info("Transport={}, device type={}, address={}, address type={}, phy={}",