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

Commit 70520f55 authored by Stanley Tng's avatar Stanley Tng
Browse files

Increase LE connection interval with bonded Hearing Aids

When there are bonded Hearing Aids device, increase the minimum LE
Connection Interval to reduce the audio noises on the devices.

Bug: 80079923
Test: Manual test with RAT mouse and HA devices
Change-Id: I589bc574ef7ff3754a149e30fb3c0a685ce27823
(cherry picked from commit 111c7db93f613a09022d44639517a94be04ab300)
parent 7369f801
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -3958,6 +3958,9 @@ void bta_dm_ble_set_conn_params(const RawAddress& bd_addr,
                                uint16_t conn_int_min, uint16_t conn_int_max,
                                uint16_t slave_latency,
                                uint16_t supervision_tout) {
  L2CA_AdjustConnectionIntervals(&conn_int_min, &conn_int_max,
                                 BTM_BLE_CONN_INT_MIN);

  BTM_BleSetPrefConnParams(bd_addr, conn_int_min, conn_int_max, slave_latency,
                           supervision_tout);
}
@@ -3973,6 +3976,8 @@ void bta_dm_ble_update_conn_params(const RawAddress& bd_addr, uint16_t min_int,
                                   uint16_t max_int, uint16_t latency,
                                   uint16_t timeout, uint16_t min_ce_len,
                                   uint16_t max_ce_len) {
  L2CA_AdjustConnectionIntervals(&min_int, &max_int, BTM_BLE_CONN_INT_MIN);

  if (!L2CA_UpdateBleConnParams(bd_addr, min_int, max_int, latency, timeout,
                                min_ce_len, max_ce_len)) {
    APPL_TRACE_ERROR("Update connection parameters failed!");
+13 −0
Original line number Diff line number Diff line
@@ -235,6 +235,8 @@ class HearingDevices {
    return false;
  }

  size_t size() { return (devices.size()); }

  std::vector<HearingDevice> devices;
};

@@ -298,6 +300,8 @@ class HearingAidImpl : public HearingAid {
    callbacks->OnDeviceAvailable(capabilities, hiSyncId, address);
  }

  int GetDeviceCount() { return (hearingDevices.size()); }

  void OnGattConnected(tGATT_STATUS status, uint16_t conn_id,
                       tGATT_IF client_if, RawAddress address,
                       tBTA_TRANSPORT transport, uint16_t mtu) {
@@ -1189,6 +1193,15 @@ void HearingAid::AddFromStorage(const RawAddress& address, uint16_t psm,
                           render_delay, preparation_delay, is_white_listed);
};

int HearingAid::GetDeviceCount() {
  if (!instance) {
    LOG(INFO) << __func__ << ": Not initialized yet";
    return 0;
  }

  return (instance->GetDeviceCount());
}

void HearingAid::CleanUp() {
  // Must stop audio source to make sure it doesn't call any of callbacks on our
  // soon to be  null instance
+2 −10
Original line number Diff line number Diff line
@@ -1354,16 +1354,8 @@ void read_pref_conn_params_cb(uint16_t conn_id, tGATT_STATUS status,

  // Make sure both min, and max are bigger than 11.25ms, lower values can
  // introduce audio issues if A2DP is also active.
  if (min_interval < BTM_BLE_CONN_INT_MIN_LIMIT) {
    APPL_TRACE_DEBUG("%s: requested min_interval=%d too small. Set to %d",
                     __func__, min_interval, BTM_BLE_CONN_INT_MIN_LIMIT);
    min_interval = BTM_BLE_CONN_INT_MIN_LIMIT;
  }
  if (max_interval < BTM_BLE_CONN_INT_MIN_LIMIT) {
    APPL_TRACE_DEBUG("%s: requested max_interval=%d too small. Set to %d",
                     __func__, max_interval, BTM_BLE_CONN_INT_MIN_LIMIT);
    max_interval = BTM_BLE_CONN_INT_MIN_LIMIT;
  }
  L2CA_AdjustConnectionIntervals(&min_interval, &max_interval,
                                 BTM_BLE_CONN_INT_MIN_LIMIT);

  // If the device has no preferred connection timeout, use the default.
  if (timeout == BTM_BLE_CONN_PARAM_UNDEF) timeout = BTM_BLE_CONN_TIMEOUT_DEF;
+2 −0
Original line number Diff line number Diff line
@@ -49,6 +49,8 @@ class HearingAid {
                             uint16_t render_delay, uint16_t preparation_delay,
                             uint16_t is_white_listed);

  static int GetDeviceCount();

  virtual void Connect(const RawAddress& address) = 0;
  virtual void Disconnect(const RawAddress& address) = 0;
  virtual void SetVolume(int8_t volume) = 0;
+6 −0
Original line number Diff line number Diff line
@@ -197,6 +197,12 @@ typedef uint8_t tBTM_BLE_SFP;
#define BTM_BLE_CONN_INT_MIN_LIMIT 0x0009
#endif

/* minimum acceptable connection interval when there is bonded Hearing Aid
 * device */
#ifndef BTM_BLE_CONN_INT_MIN_HEARINGAID
#define BTM_BLE_CONN_INT_MIN_HEARINGAID 0x0010
#endif

#define BTM_BLE_DIR_CONN_FALLBACK_UNDIR 1
#define BTM_BLE_DIR_CONN_FALLBACK_NO_ADV 2

Loading