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

Commit ff8ef521 authored by David Duarte's avatar David Duarte
Browse files

hearing_aid: Add a flag to augment l2cap flush threshold

Bug: 308684052
Bug: 315500864
Test: m com.android.btservices
Change-Id: I02ad13b4804399652f2a105a3dc34f7e3e86d4d6
parent 16336062
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ aconfig_declarations {
    package: "com.android.bluetooth.flags",
    srcs: [
        "a2dp.aconfig",
        "asha.aconfig",
        "audio_routing.aconfig",
        "bta_dm.aconfig",
        "framework.aconfig",

flags/asha.aconfig

0 → 100644
+8 −0
Original line number Diff line number Diff line
package: "com.android.bluetooth.flags"

flag {
    name: "higher_l2cap_flush_threshold"
    namespace: "bluetooth"
    description: "Use a higher threshold for flushing L2CAP packets"
    bug: "315500864"
}
+8 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@

#define LOG_TAG "bluetooth"

#include <android_bluetooth_flags.h>
#include <base/functional/bind.h>
#include <base/functional/callback.h>
#include <base/logging.h>
@@ -1410,6 +1411,11 @@ class HearingAidImpl : public HearingAid {
      }
    }

    uint16_t l2cap_flush_threshold = 0;
    if (IS_FLAG_ENABLED(higher_l2cap_flush_threshold)) {
      l2cap_flush_threshold = 1;
    }

    // TODO: monural, binarual check

    // divide encoded data into packets, add header, send.
@@ -1430,7 +1436,7 @@ class HearingAidImpl : public HearingAid {

      uint16_t cid = GAP_ConnGetL2CAPCid(left->gap_handle);
      uint16_t packets_in_chans = L2CA_FlushChannel(cid, L2CAP_FLUSH_CHANS_GET);
      if (packets_in_chans) {
      if (packets_in_chans > l2cap_flush_threshold) {
        // Compare the two sides LE CoC credit value to confirm need to drop or
        // skip audio packet.
        if (NeedToDropPacket(left, right) && IsBelowDropFrequency(time_point)) {
@@ -1464,7 +1470,7 @@ class HearingAidImpl : public HearingAid {

      uint16_t cid = GAP_ConnGetL2CAPCid(right->gap_handle);
      uint16_t packets_in_chans = L2CA_FlushChannel(cid, L2CAP_FLUSH_CHANS_GET);
      if (packets_in_chans) {
      if (packets_in_chans > l2cap_flush_threshold) {
        // Compare the two sides LE CoC credit value to confirm need to drop or
        // skip audio packet.
        if (NeedToDropPacket(right, left) && IsBelowDropFrequency(time_point)) {