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

Commit a9e9437e authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi Committed by Automerger Merge Worker
Browse files

Merge changes If843996a,I37774e37,I3c110bba,Ic5aeec3e am: f6a5bc13

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/1964606

Change-Id: I738a8143897c51888728d9658ab37bab53b458b5
parents fa9568b1 f6a5bc13
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -6,7 +6,8 @@ use bt_topshim::bindings::root::bluetooth::Uuid;
use bt_topshim::btif::{BluetoothInterface, RawAddress, Uuid128Bit};
use bt_topshim::profiles::gatt::{
    BtGattDbElement, BtGattNotifyParams, BtGattReadParams, Gatt, GattClientCallbacks,
    GattClientCallbacksDispatcher, GattServerCallbacksDispatcher, GattStatus,
    GattClientCallbacksDispatcher, GattScannerCallbacksDispatcher, GattServerCallbacksDispatcher,
    GattStatus,
};
use bt_topshim::topstack;

@@ -514,6 +515,11 @@ impl BluetoothGatt {
                    debug!("received Gatt server callback: {:?}", cb);
                }),
            },
            GattScannerCallbacksDispatcher {
                dispatch: Box::new(move |cb| {
                    debug!("received Gatt scanner callback: {:?}", cb);
                }),
            },
        );
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -50,8 +50,10 @@ cc_library_static {
        "btav_sink/btav_sink_shim.cc",
        "btif/btif_shim.cc",
        "gatt/gatt_shim.cc",
        "gatt/gatt_ble_scanner_shim.cc",
        "hfp/hfp_shim.cc",
        "controller/controller_shim.cc",
        "common/utils.cc",
    ],
    generated_headers: [
        "libbt_init_flags_bridge_header",
+2 −0
Original line number Diff line number Diff line
@@ -55,7 +55,9 @@ source_set("btif_cxx_bridge_code") {
    "btav_sink/btav_sink_shim.cc",
    "hfp/hfp_shim.cc",
    "gatt/gatt_shim.cc",
    "gatt/gatt_ble_scanner_shim.cc",
    "controller/controller_shim.cc",
    "common/utils.cc",
  ]

  deps = [":btif_bridge_header", "//bt/system/gd:BluetoothGeneratedPackets_h"]
+12 −23
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include <memory>

#include "base/callback.h"
#include "gd/rust/topshim/common/utils.h"
#include "include/hardware/avrcp/avrcp.h"
#include "include/hardware/bluetooth.h"
#include "rust/cxx.h"
@@ -103,18 +104,6 @@ namespace internal {
static A2dpIntf* g_a2dpif;
static AvrcpIntf* g_avrcpif;

static RustRawAddress to_rust_address(const RawAddress& address) {
  RustRawAddress raddr;
  std::copy(std::begin(address.address), std::end(address.address), std::begin(raddr.address));
  return raddr;
}

static RawAddress from_rust_address(const RustRawAddress& raddr) {
  RawAddress addr;
  addr.FromOctets(raddr.address.data());
  return addr;
}

static A2dpCodecConfig to_rust_codec_config(const btav_a2dp_codec_config_t& config) {
  A2dpCodecConfig rconfig = {.codec_type = static_cast<uint8_t>(config.codec_type),
                             .codec_priority = config.codec_priority,
@@ -153,11 +142,11 @@ static ::rust::Vec<A2dpCodecConfig> to_rust_codec_config_vec(const std::vector<b
}

static void connection_state_cb(const RawAddress& bd_addr, btav_connection_state_t state) {
  RustRawAddress addr = to_rust_address(bd_addr);
  RustRawAddress addr = rusty::CopyToRustAddress(bd_addr);
  rusty::connection_state_callback(addr, state);
}
static void audio_state_cb(const RawAddress& bd_addr, btav_audio_state_t state) {
  RustRawAddress addr = to_rust_address(bd_addr);
  RustRawAddress addr = rusty::CopyToRustAddress(bd_addr);
  rusty::audio_state_callback(addr, state);
}
static void audio_config_cb(
@@ -165,14 +154,14 @@ static void audio_config_cb(
    btav_a2dp_codec_config_t codec_config,
    std::vector<btav_a2dp_codec_config_t> codecs_local_capabilities,
    std::vector<btav_a2dp_codec_config_t> codecs_selectable_capabilities) {
  RustRawAddress addr = to_rust_address(bd_addr);
  RustRawAddress addr = rusty::CopyToRustAddress(bd_addr);
  A2dpCodecConfig cfg = to_rust_codec_config(codec_config);
  ::rust::Vec<A2dpCodecConfig> lcaps = to_rust_codec_config_vec(codecs_local_capabilities);
  ::rust::Vec<A2dpCodecConfig> scaps = to_rust_codec_config_vec(codecs_selectable_capabilities);
  rusty::audio_config_callback(addr, cfg, lcaps, scaps);
}
static bool mandatory_codec_preferred_cb(const RawAddress& bd_addr) {
  RustRawAddress addr = to_rust_address(bd_addr);
  RustRawAddress addr = rusty::CopyToRustAddress(bd_addr);
  rusty::mandatory_codec_preferred_callback(addr);
  return true;
}
@@ -208,23 +197,23 @@ int A2dpIntf::init() const {
}

int A2dpIntf::connect(RustRawAddress bt_addr) const {
  RawAddress addr = internal::from_rust_address(bt_addr);
  RawAddress addr = rusty::CopyFromRustAddress(bt_addr);
  return intf_->connect(addr);
}
int A2dpIntf::disconnect(RustRawAddress bt_addr) const {
  RawAddress addr = internal::from_rust_address(bt_addr);
  RawAddress addr = rusty::CopyFromRustAddress(bt_addr);
  return intf_->disconnect(addr);
}
int A2dpIntf::set_silence_device(RustRawAddress bt_addr, bool silent) const {
  RawAddress addr = internal::from_rust_address(bt_addr);
  RawAddress addr = rusty::CopyFromRustAddress(bt_addr);
  return intf_->set_silence_device(addr, silent);
}
int A2dpIntf::set_active_device(RustRawAddress bt_addr) const {
  RawAddress addr = internal::from_rust_address(bt_addr);
  RawAddress addr = rusty::CopyFromRustAddress(bt_addr);
  return intf_->set_active_device(addr);
}
int A2dpIntf::config_codec(RustRawAddress bt_addr, ::rust::Vec<A2dpCodecConfig> codec_preferences) const {
  RawAddress addr = internal::from_rust_address(bt_addr);
  RawAddress addr = rusty::CopyFromRustAddress(bt_addr);
  std::vector<btav_a2dp_codec_config_t> prefs;
  for (int i = 0; i < codec_preferences.size(); ++i) {
    prefs.push_back(internal::from_rust_codec_config(codec_preferences[i]));
@@ -286,11 +275,11 @@ void AvrcpIntf::cleanup() {
}

int AvrcpIntf::connect(RustRawAddress bt_addr) {
  RawAddress addr = internal::from_rust_address(bt_addr);
  RawAddress addr = rusty::CopyFromRustAddress(bt_addr);
  return intf_->ConnectDevice(addr);
}
int AvrcpIntf::disconnect(RustRawAddress bt_addr) {
  RawAddress addr = internal::from_rust_address(bt_addr);
  RawAddress addr = rusty::CopyFromRustAddress(bt_addr);
  return intf_->DisconnectDevice(addr);
}

+6 −9
Original line number Diff line number Diff line
@@ -18,11 +18,14 @@

#include <memory>

#include "gd/rust/topshim/common/utils.h"
#include "include/hardware/bluetooth.h"
#include "rust/cxx.h"
#include "src/profiles/a2dp.rs.h"
#include "types/raw_address.h"

namespace rusty = ::bluetooth::topshim::rust;

namespace bluetooth {
namespace topshim {
namespace rust {
@@ -39,12 +42,6 @@ btav_sink_callbacks_t g_a2dp_sink_callbacks = {
    audio_state_cb,
    audio_config_cb,
};

static RawAddress from_rust_address(const RustRawAddress& raddr) {
  RawAddress addr;
  addr.FromOctets(raddr.address.data());
  return addr;
}
}  // namespace internal

A2dpSinkIntf::~A2dpSinkIntf() {
@@ -67,15 +64,15 @@ int A2dpSinkIntf::init() const {
}

int A2dpSinkIntf::connect(RustRawAddress bt_addr) const {
  return intf_->connect(internal::from_rust_address(bt_addr));
  return intf_->connect(rusty::CopyFromRustAddress(bt_addr));
}

int A2dpSinkIntf::disconnect(RustRawAddress bt_addr) const {
  return intf_->disconnect(internal::from_rust_address(bt_addr));
  return intf_->disconnect(rusty::CopyFromRustAddress(bt_addr));
}

int A2dpSinkIntf::set_active_device(RustRawAddress bt_addr) const {
  return intf_->set_active_device(internal::from_rust_address(bt_addr));
  return intf_->set_active_device(rusty::CopyFromRustAddress(bt_addr));
}

void A2dpSinkIntf::cleanup() const {
Loading