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

Commit 78c4fabf authored by En-Shuo Hsu's avatar En-Shuo Hsu
Browse files

floss: Set the HFP capability if wbs supported

Bug: 235171669
Tag: #floss
Test: Build and check the dbus-monitor
Change-Id: Ifa095608bd8f74b707653f34821ad5108b379a4b
parent ea210717
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -214,8 +214,11 @@ impl BluetoothMedia {
                    }
                    BthfConnectionState::SlcConnected => {
                        info!("[{}]: hfp slc connected.", addr.to_string());
                        // TODO(b/214148074): Support WBS
                        self.hfp_caps.insert(addr, HfpCodecCapability::CVSD);
                        let mut hfp_caps = HfpCodecCapability::CVSD;
                        if self.hfp.as_mut().unwrap().get_wbs_supported() {
                            hfp_caps = hfp_caps | HfpCodecCapability::MSBC;
                        }
                        self.hfp_caps.insert(addr, hfp_caps);
                        self.notify_media_capability_added(addr);
                    }
                    BthfConnectionState::Disconnected => {
+9 −1
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ namespace topshim {
namespace rust {
namespace internal {
static HfpIntf* g_hfpif;
static bool wbs_supported;

static void connection_state_cb(bluetooth::headset::bthf_connection_state_t state, RawAddress* addr) {
  RustRawAddress raddr = rusty::CopyToRustAddress(*addr);
@@ -100,7 +101,10 @@ class DBusHeadsetCallbacks : public headset::Callbacks {
  void NoiseReductionCallback(
      [[maybe_unused]] headset::bthf_nrec_t nrec, [[maybe_unused]] RawAddress* bd_addr) override {}

  void WbsCallback([[maybe_unused]] headset::bthf_wbs_config_t wbs, [[maybe_unused]] RawAddress* bd_addr) override {}
  void WbsCallback(headset::bthf_wbs_config_t wbs, RawAddress* bd_addr) override {
    LOG_INFO("WbsCallback %d from %s", wbs, bd_addr->ToString().c_str());
    internal::wbs_supported = (wbs == headset::BTHF_WBS_YES);
  }

  void AtChldCallback([[maybe_unused]] headset::bthf_chld_type_t chld, [[maybe_unused]] RawAddress* bd_addr) override {}

@@ -225,6 +229,10 @@ int HfpIntf::disconnect_audio(RustRawAddress bt_addr) {
  return intf_->DisconnectAudio(&addr);
}

bool HfpIntf::get_wbs_supported() {
  return internal::wbs_supported;
}

void HfpIntf::cleanup() {}

std::unique_ptr<HfpIntf> GetHfpProfile(const unsigned char* btif) {
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ class HfpIntf {
  int connect_audio(RustRawAddress bt_addr);
  int disconnect(RustRawAddress bt_addr);
  int disconnect_audio(RustRawAddress bt_addr);
  bool get_wbs_supported();
  void cleanup();

 private:
+5 −0
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ pub mod ffi {
        fn connect_audio(self: Pin<&mut HfpIntf>, bt_addr: RustRawAddress) -> i32;
        fn disconnect(self: Pin<&mut HfpIntf>, bt_addr: RustRawAddress) -> i32;
        fn disconnect_audio(self: Pin<&mut HfpIntf>, bt_addr: RustRawAddress) -> i32;
        fn get_wbs_supported(self: Pin<&mut HfpIntf>) -> bool;
        fn cleanup(self: Pin<&mut HfpIntf>);

    }
@@ -170,6 +171,10 @@ impl Hfp {
        self.internal.pin_mut().disconnect_audio(addr.into())
    }

    pub fn get_wbs_supported(&mut self) -> bool {
        self.internal.pin_mut().get_wbs_supported()
    }

    pub fn cleanup(&mut self) -> bool {
        self.internal.pin_mut().cleanup();
        true