Loading system/gd/rust/topshim/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ cc_library_static { "btif/btif_shim.cc", "gatt/gatt_shim.cc", "hfp/hfp_shim.cc", "controller/controller_shim.cc", ], generated_headers: ["libbt_topshim_bridge_header", "cxx-bridge-header"], generated_sources: ["libbt_topshim_bridge_code"], Loading @@ -75,6 +76,7 @@ gensrcs { "src/profiles/a2dp.rs", "src/profiles/avrcp.rs", "src/profiles/gatt.rs", "src/controller.rs", ], output_extension: "rs.h", export_include_dirs: ["."], Loading @@ -89,6 +91,7 @@ gensrcs { "src/profiles/a2dp.rs", "src/profiles/avrcp.rs", "src/profiles/gatt.rs", "src/controller.rs", ], output_extension: "cc", export_include_dirs: ["."], Loading system/gd/rust/topshim/BUILD.gn +5 −2 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ cxxbridge_header("btif_bridge_header") { "src/profiles/a2dp.rs", "src/profiles/avrcp.rs", "src/profiles/gatt.rs", "src/controller.rs", ] all_dependent_configs = [ ":rust_topshim_config" ] deps = [":cxxlibheader"] Loading @@ -39,8 +40,9 @@ cxxbridge_cc("btif_bridge_code") { "src/profiles/a2dp.rs", "src/profiles/avrcp.rs", "src/profiles/gatt.rs", "src/controller.rs", ] deps = [":btif_bridge_header"] deps = [":btif_bridge_header", "//bt/gd:BluetoothGeneratedPackets_h"] configs = [ "//bt/gd:gd_defaults" ] } Loading @@ -50,9 +52,10 @@ source_set("btif_cxx_bridge_code") { "btav/btav_shim.cc", "btav_sink/btav_sink_shim.cc", "gatt/gatt_shim.cc", "controller/controller_shim.cc", ] deps = [":btif_bridge_header"] deps = [":btif_bridge_header", "//bt/gd:BluetoothGeneratedPackets_h"] configs += ["//bt/gd:gd_defaults"] } Loading system/gd/rust/topshim/controller/controller_shim.cc 0 → 100644 +54 −0 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/controller/controller_shim.h" #include <memory> #include "rust/cxx.h" #include "src/controller.rs.h" #include "types/raw_address.h" namespace bluetooth { namespace topshim { namespace rust { namespace internal { static ControllerIntf* g_controller_intf; 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; } } // namespace internal ControllerIntf::~ControllerIntf() {} std::unique_ptr<ControllerIntf> GetControllerInterface() { if (internal::g_controller_intf) std::abort(); auto controller_intf = std::make_unique<ControllerIntf>(); internal::g_controller_intf = controller_intf.get(); return controller_intf; } RustRawAddress ControllerIntf::read_local_addr() const { if (!controller_) std::abort(); return internal::to_rust_address(*controller_->get_address()); } } // namespace rust } // namespace topshim } // namespace bluetooth system/gd/rust/topshim/controller/controller_shim.h 0 → 100644 +49 −0 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_CONTROLLER_SHIM #define GD_RUST_TOPSHIM_CONTROLLER_SHIM #include <memory> #include "main/shim/controller.h" #include "rust/cxx.h" #include "types/raw_address.h" namespace bluetooth { namespace topshim { namespace rust { struct RustRawAddress; class ControllerIntf { public: ControllerIntf() : controller_(controller_get_interface()) {} ~ControllerIntf(); RustRawAddress read_local_addr() const; private: const controller_t* controller_; }; // ControllerIntf* GetControllerInterface(); std::unique_ptr<ControllerIntf> GetControllerInterface(); } // namespace rust } // namespace topshim } // namespace bluetooth #endif // GD_RUST_TOPSHIM_CONTROLLER_SHIM No newline at end of file system/gd/rust/topshim/facade/utils.proto 0 → 100644 +13 −0 Original line number Diff line number Diff line syntax = "proto3"; package blueberry; message Empty {} message BluetoothAddress { bytes address = 1; } service ReadOnlyProperty { rpc ReadLocalAddress(Empty) returns (BluetoothAddress) {} } No newline at end of file Loading
system/gd/rust/topshim/Android.bp +3 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,7 @@ cc_library_static { "btif/btif_shim.cc", "gatt/gatt_shim.cc", "hfp/hfp_shim.cc", "controller/controller_shim.cc", ], generated_headers: ["libbt_topshim_bridge_header", "cxx-bridge-header"], generated_sources: ["libbt_topshim_bridge_code"], Loading @@ -75,6 +76,7 @@ gensrcs { "src/profiles/a2dp.rs", "src/profiles/avrcp.rs", "src/profiles/gatt.rs", "src/controller.rs", ], output_extension: "rs.h", export_include_dirs: ["."], Loading @@ -89,6 +91,7 @@ gensrcs { "src/profiles/a2dp.rs", "src/profiles/avrcp.rs", "src/profiles/gatt.rs", "src/controller.rs", ], output_extension: "cc", export_include_dirs: ["."], Loading
system/gd/rust/topshim/BUILD.gn +5 −2 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ cxxbridge_header("btif_bridge_header") { "src/profiles/a2dp.rs", "src/profiles/avrcp.rs", "src/profiles/gatt.rs", "src/controller.rs", ] all_dependent_configs = [ ":rust_topshim_config" ] deps = [":cxxlibheader"] Loading @@ -39,8 +40,9 @@ cxxbridge_cc("btif_bridge_code") { "src/profiles/a2dp.rs", "src/profiles/avrcp.rs", "src/profiles/gatt.rs", "src/controller.rs", ] deps = [":btif_bridge_header"] deps = [":btif_bridge_header", "//bt/gd:BluetoothGeneratedPackets_h"] configs = [ "//bt/gd:gd_defaults" ] } Loading @@ -50,9 +52,10 @@ source_set("btif_cxx_bridge_code") { "btav/btav_shim.cc", "btav_sink/btav_sink_shim.cc", "gatt/gatt_shim.cc", "controller/controller_shim.cc", ] deps = [":btif_bridge_header"] deps = [":btif_bridge_header", "//bt/gd:BluetoothGeneratedPackets_h"] configs += ["//bt/gd:gd_defaults"] } Loading
system/gd/rust/topshim/controller/controller_shim.cc 0 → 100644 +54 −0 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/controller/controller_shim.h" #include <memory> #include "rust/cxx.h" #include "src/controller.rs.h" #include "types/raw_address.h" namespace bluetooth { namespace topshim { namespace rust { namespace internal { static ControllerIntf* g_controller_intf; 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; } } // namespace internal ControllerIntf::~ControllerIntf() {} std::unique_ptr<ControllerIntf> GetControllerInterface() { if (internal::g_controller_intf) std::abort(); auto controller_intf = std::make_unique<ControllerIntf>(); internal::g_controller_intf = controller_intf.get(); return controller_intf; } RustRawAddress ControllerIntf::read_local_addr() const { if (!controller_) std::abort(); return internal::to_rust_address(*controller_->get_address()); } } // namespace rust } // namespace topshim } // namespace bluetooth
system/gd/rust/topshim/controller/controller_shim.h 0 → 100644 +49 −0 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_CONTROLLER_SHIM #define GD_RUST_TOPSHIM_CONTROLLER_SHIM #include <memory> #include "main/shim/controller.h" #include "rust/cxx.h" #include "types/raw_address.h" namespace bluetooth { namespace topshim { namespace rust { struct RustRawAddress; class ControllerIntf { public: ControllerIntf() : controller_(controller_get_interface()) {} ~ControllerIntf(); RustRawAddress read_local_addr() const; private: const controller_t* controller_; }; // ControllerIntf* GetControllerInterface(); std::unique_ptr<ControllerIntf> GetControllerInterface(); } // namespace rust } // namespace topshim } // namespace bluetooth #endif // GD_RUST_TOPSHIM_CONTROLLER_SHIM No newline at end of file
system/gd/rust/topshim/facade/utils.proto 0 → 100644 +13 −0 Original line number Diff line number Diff line syntax = "proto3"; package blueberry; message Empty {} message BluetoothAddress { bytes address = 1; } service ReadOnlyProperty { rpc ReadLocalAddress(Empty) returns (BluetoothAddress) {} } No newline at end of file