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

Commit 93c842cf authored by En-Shuo Hsu's avatar En-Shuo Hsu Committed by Gerrit Code Review
Browse files

Merge "Init HFP interface with empty callbacks"

parents 35115a86 514452a5
Loading
Loading
Loading
Loading
+82 −3
Original line number Diff line number Diff line
@@ -14,21 +14,100 @@
 * limitations under the License.
 */

#include "hfp/hfp_shim.h"
#include "gd/rust/topshim/hfp/hfp_shim.h"

#include "btif/include/btif_hf.h"
#include "types/raw_address.h"

namespace bluetooth::headset {
class DBusHeadsetCallbacks : public Callbacks {
 public:
  static Callbacks* GetInstance() {
    static Callbacks* instance = new DBusHeadsetCallbacks();
    return instance;
  }

  void ConnectionStateCallback(
      [[maybe_unused]] bthf_connection_state_t state, [[maybe_unused]] RawAddress* bd_addr) override {}

  void AudioStateCallback([[maybe_unused]] bthf_audio_state_t state, [[maybe_unused]] RawAddress* bd_addr) override {}

  void VoiceRecognitionCallback([[maybe_unused]] bthf_vr_state_t state, [[maybe_unused]] RawAddress* bd_addr) override {
  }

  void AnswerCallCallback([[maybe_unused]] RawAddress* bd_addr) override {}

  void HangupCallCallback([[maybe_unused]] RawAddress* bd_addr) override {}

  void VolumeControlCallback(
      [[maybe_unused]] bthf_volume_type_t type,
      [[maybe_unused]] int volume,
      [[maybe_unused]] RawAddress* bd_addr) override {}

  void DialCallCallback([[maybe_unused]] char* number, [[maybe_unused]] RawAddress* bd_addr) override {}

  void DtmfCmdCallback([[maybe_unused]] char tone, [[maybe_unused]] RawAddress* bd_addr) override {}

  void NoiseReductionCallback([[maybe_unused]] bthf_nrec_t nrec, [[maybe_unused]] RawAddress* bd_addr) override {}

  void WbsCallback([[maybe_unused]] bthf_wbs_config_t wbs, [[maybe_unused]] RawAddress* bd_addr) override {}

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

  void AtCnumCallback([[maybe_unused]] RawAddress* bd_addr) override {}

  void AtCindCallback([[maybe_unused]] RawAddress* bd_addr) override {}

  void AtCopsCallback([[maybe_unused]] RawAddress* bd_addr) override {}

  void AtClccCallback([[maybe_unused]] RawAddress* bd_addr) override {}

  void UnknownAtCallback([[maybe_unused]] char* at_string, [[maybe_unused]] RawAddress* bd_addr) override {}

  void KeyPressedCallback([[maybe_unused]] RawAddress* bd_addr) override {}

  void AtBindCallback([[maybe_unused]] char* at_string, [[maybe_unused]] RawAddress* bd_addr) override {}

  void AtBievCallback(
      [[maybe_unused]] bthf_hf_ind_type_t ind_id,
      [[maybe_unused]] int ind_value,
      [[maybe_unused]] RawAddress* bd_addr) override {}

  void AtBiaCallback(
      [[maybe_unused]] bool service,
      [[maybe_unused]] bool roam,
      [[maybe_unused]] bool signal,
      [[maybe_unused]] bool battery,
      [[maybe_unused]] RawAddress* bd_addr) override {}
};
}  // namespace bluetooth::headset

namespace bluetooth {
namespace topshim {
namespace rust {
namespace internal {
static HfpIntf* g_hfpif;

}  // namespace internal

int HfpIntf::init() {
  intf_->Init(nullptr, 1, false);
  return 0;
  return intf_->Init(headset::DBusHeadsetCallbacks::GetInstance(), 1, false);
}

void HfpIntf::cleanup() {}

std::unique_ptr<HfpIntf> GetHfpProfile(const unsigned char* btif) {
  if (internal::g_hfpif) std::abort();

  const bt_interface_t* btif_ = reinterpret_cast<const bt_interface_t*>(btif);

  auto hfpif = std::make_unique<HfpIntf>(const_cast<headset::Interface*>(
      reinterpret_cast<const headset::Interface*>(btif_->get_profile_interface("handsfree"))));
  internal::g_hfpif = hfpif.get();

  return hfpif;
}

}  // namespace rust
}  // namespace topshim
}  // namespace bluetooth
+5 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#pragma once

#include "btif/include/btif_hf.h"
#include "include/hardware/bluetooth_headset_callbacks.h"

namespace bluetooth {
namespace topshim {
@@ -24,15 +25,16 @@ namespace rust {

class HfpIntf {
 public:
  // interface for Settings
  HfpIntf(headset::Interface* intf) : intf_(intf){};

  int init();
  void cleanup();

 private:
  bluetooth::headset::Interface* intf_ = nullptr;
  headset::Interface* intf_;
};

std::unique_ptr<HfpIntf> GetHfpProfile();
std::unique_ptr<HfpIntf> GetHfpProfile(const unsigned char* btif);

}  // namespace rust
}  // namespace topshim