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

Commit 8cd176cb authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi
Browse files

Revert "topshim: Add btm_sec shim"

This reverts commit 976b3eb4.

Reason for revert: Breaks Linux build.
Test: ./build.py on gLinux
Change-Id: Ic72ebb72bab9b455b56044c8347624c059d8c991
parent 976b3eb4
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -52,7 +52,6 @@ cc_library_static {
        "gatt/gatt_shim.cc",
        "hfp/hfp_shim.cc",
        "controller/controller_shim.cc",
        "btm_sec/btm_sec_shim.cc",
    ],
    generated_headers: ["libbt_topshim_bridge_header", "cxx-bridge-header"],
    generated_sources: ["libbt_topshim_bridge_code"],
@@ -62,12 +61,9 @@ cc_library_static {
    include_dirs: [
        "packages/modules/Bluetooth/system",
        "packages/modules/Bluetooth/system/gd/rust/topshim",
        "packages/modules/Bluetooth/system/internal_include",
        "packages/modules/Bluetooth/system/include",
        "packages/modules/Bluetooth/system/types",
        "packages/modules/Bluetooth/system/stack/include",
    ],
    cflags: ["-DHAS_NO_BDROID_BUILDCFG"],
    host_supported: true,
}

@@ -81,7 +77,6 @@ gensrcs {
        "src/profiles/avrcp.rs",
        "src/profiles/gatt.rs",
        "src/controller.rs",
        "src/btm_sec.rs",
    ],
    output_extension: "rs.h",
    export_include_dirs: ["."],
@@ -97,7 +92,6 @@ gensrcs {
        "src/profiles/avrcp.rs",
        "src/profiles/gatt.rs",
        "src/controller.rs",
        "src/btm_sec.rs",
    ],
    output_extension: "cc",
    export_include_dirs: ["."],
+0 −1
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ source_set("btif_cxx_bridge_code") {
    "btav_sink/btav_sink_shim.cc",
    "gatt/gatt_shim.cc",
    "controller/controller_shim.cc",
    "btm_sec/btm_sec_shim.cc",
  ]

  deps = [":btif_bridge_header", "//bt/gd:BluetoothGeneratedPackets_h"]
+0 −57
Original line number Diff line number Diff line
/*
 * Copyright 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "gd/rust/topshim/btm_sec/btm_sec_shim.h"

#include <memory>

#include "main/shim/btm_api.h"
#include "src/btm_sec.rs.h"
#include "stack/btm/btm_sec.h"
#include "stack/include/hci_error_code.h"
#include "types/bt_transport.h"

namespace bluetooth {
namespace topshim {
namespace rust {
namespace internal {
static BtmSecIntf* g_btm_sec_intf;
static RawAddress from_rust_address(const RustRawAddress& raddr) {
  RawAddress addr;
  addr.FromOctets(raddr.address.data());
  return addr;
}
}  // namespace internal

BtmSecIntf::BtmSecIntf() {}
BtmSecIntf::~BtmSecIntf() {}

void BtmSecIntf::hci_disconnect(RustRawAddress bt_addr) const {
  uint16_t handle = shim::BTM_GetHCIConnHandle(internal::from_rust_address(bt_addr), BT_TRANSPORT_BR_EDR);
  btm_sec_disconnect(handle, tHCI_STATUS::HCI_ERR_UNDEFINED);
}

std::unique_ptr<BtmSecIntf> GetBtmSecInterface() {
  if (internal::g_btm_sec_intf) std::abort();
  auto btm_sec_intf = std::make_unique<BtmSecIntf>();
  internal::g_btm_sec_intf = btm_sec_intf.get();

  return btm_sec_intf;
}

}  // namespace rust
}  // namespace topshim
}  // namespace bluetooth
+0 −41
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef GD_RUST_TOPSHIM_BTM_SEC_SHIM
#define GD_RUST_TOPSHIM_BTM_SEC_SHIM

#include <memory>

namespace bluetooth {
namespace topshim {
namespace rust {

struct RustRawAddress;

class BtmSecIntf {
 public:
  BtmSecIntf();
  ~BtmSecIntf();

  void hci_disconnect(RustRawAddress bt_addr) const;
};

std::unique_ptr<BtmSecIntf> GetBtmSecInterface();

}  // namespace rust
}  // namespace topshim
}  // namespace bluetooth

#endif
 No newline at end of file
+0 −34
Original line number Diff line number Diff line
use crate::btif::RawAddress;

#[cxx::bridge(namespace = bluetooth::topshim::rust)]
mod ffi {
    pub struct RustRawAddress {
        address: [u8; 6],
    }

    unsafe extern "C++" {
        include!("btm_sec/btm_sec_shim.h");

        type BtmSecIntf;

        fn GetBtmSecInterface() -> UniquePtr<BtmSecIntf>;
        fn hci_disconnect(self: &BtmSecIntf, bt_addr: RustRawAddress);
    }
}

pub struct BtmSec {
    internal: cxx::UniquePtr<ffi::BtmSecIntf>,
}

unsafe impl Send for BtmSec {}

impl BtmSec {
    pub fn new() -> BtmSec {
        let btm_sec_intf = ffi::GetBtmSecInterface();
        BtmSec { internal: btm_sec_intf }
    }

    pub fn hci_disconnect(&mut self, address: [u8; 6]) {
        self.internal.hci_disconnect(ffi::RustRawAddress { address });
    }
}
Loading