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

Commit 84457c93 authored by Sandeep Samdaria's avatar Sandeep Samdaria
Browse files

Cap total no. of max connected devices

Problem: Bluetooth stack can support upto total 5(configurable)
audio devices. This includes both A2DP source and sink devices.
Currently, each profile accounts for the devices connected with
its profile and doesn't account for the no. of devices connected
in other profiles.

Solution: While checking if a device is allowed to connect or not,
it will also account for the other profile's no. of devices
connected.

Bug: 312533591
Bug: 321806163
Test: atest net_*
Change-Id: I59666577f615dda3c8b0fa2a9b1246cf645c0c6d
parent b8b202cf
Loading
Loading
Loading
Loading
+14 −0
Original line number Original line Diff line number Diff line
@@ -1365,6 +1365,13 @@ bool BtifAvSource::AllowedToConnect(const RawAddress& peer_address) const {
      return true;
      return true;
    }
    }
  }
  }
  if (IS_FLAG_ENABLED(a2dp_concurrent_source_sink)) {
    const int sink_connected_peers_size = (int)btif_av_sink.Peers().size();
    log::info(
        "connected={}, max_connected_peers_={}, sink_connected_peers_size={}",
        connected, max_connected_peers_, (int)btif_av_sink.Peers().size());
    return ((connected + sink_connected_peers_size) < max_connected_peers_);
  }
  return (connected < max_connected_peers_);
  return (connected < max_connected_peers_);
}
}


@@ -1629,6 +1636,13 @@ bool BtifAvSink::AllowedToConnect(const RawAddress& peer_address) const {
    return (connected < max_connected_peers_) && btif_av_source.Peers().empty();
    return (connected < max_connected_peers_) && btif_av_source.Peers().empty();
  }
  }


  if (IS_FLAG_ENABLED(a2dp_concurrent_source_sink)) {
    const int source_connected_peers_size = (int)btif_av_source.Peers().size();
    log::info(
        "connected={}, max_connected_peers_={}, source_connected_peers_size={}",
        connected, max_connected_peers_, source_connected_peers_size);
    return ((connected + source_connected_peers_size) < max_connected_peers_);
  }
  return (connected < max_connected_peers_);
  return (connected < max_connected_peers_);
}
}