Loading system/gd/Android.bp +34 −0 Original line number Diff line number Diff line Loading @@ -89,10 +89,44 @@ cc_defaults { ], } soong_config_module_type { name: "mgmt_cc_defaults", module_type: "cc_defaults", config_namespace: "mgmt", variables: ["vertical"], properties: ["srcs"], } soong_config_string_variable { name: "vertical", values: [ "android_default", "android_desktop", ], } mgmt_cc_defaults { name: "mgmt_defaults", soong_config_variables: { vertical: { android_desktop: { srcs: [":BluetoothHalSources_mgmt"], }, android_default: { srcs: [":BluetoothHalSources_mgmt_stub"], }, conditions_default: { srcs: [":BluetoothHalSources_mgmt_stub"], }, }, }, } cc_defaults { name: "libbluetooth_gd_defaults", defaults: [ "gd_defaults", "mgmt_defaults", ], host_supported: true, target: { Loading system/gd/hal/Android.bp +14 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,20 @@ filegroup { ], } filegroup { name: "BluetoothHalSources_mgmt_stub", srcs: [ "mgmt_stub.cc", ], } filegroup { name: "BluetoothHalSources_mgmt", srcs: [ "mgmt.cc", ], } filegroup { name: "BluetoothHalSources_ranging_android", srcs: [ Loading system/gd/hal/hci_hal_android.cc +3 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include "hal/hci_backend.h" #include "hal/hci_hal.h" #include "hal/link_clocker.h" #include "hal/mgmt.h" #include "hal/snoop_logger.h" namespace bluetooth::hal { Loading Loading @@ -157,6 +158,8 @@ public: backend_->sendIsoData(packet); } uint16_t getMsftOpcode() override { return Mgmt().get_vs_opcode(MGMT_VS_OPCODE_MSFT); } protected: void ListDependencies(ModuleList* list) const override { list->add<LinkClocker>(); Loading system/gd/hal/mgmt.cc +3 −3 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ constexpr static uint8_t BTPROTO_HCI = 1; constexpr static uint16_t HCI_CHANNEL_CONTROL = 3; constexpr static uint16_t HCI_DEV_NONE = 0xffff; static int btsocket_open_mgmt(uint16_t hci) { static int btsocket_open_mgmt() { int fd = socket(PF_BLUETOOTH, SOCK_RAW | SOCK_NONBLOCK, BTPROTO_HCI); if (fd < 0) { log::error("Failed to open BT socket."); Loading Loading @@ -84,7 +84,7 @@ static int btsocket_open_mgmt(uint16_t hci) { */ uint16_t Mgmt::get_vs_opcode(uint16_t vendor_specification) { int hci = GetAdapterIndex(); int fd = btsocket_open_mgmt(hci); int fd = btsocket_open_mgmt(); uint16_t ret_opcode = HCI_OP_NOP; if (fd < 0) { Loading @@ -99,7 +99,7 @@ uint16_t Mgmt::get_vs_opcode(uint16_t vendor_specification) { struct mgmt_cp_get_vs_opcode* cp = reinterpret_cast<struct mgmt_cp_get_vs_opcode*>(ev.data); cp->hci_id = hci; cp->vendor_specification = MGMT_VS_OPCODE_MSFT; cp->vendor_specification = vendor_specification; int ret; struct pollfd writable[1]; Loading system/gd/hal/mgmt_stub.cc 0 → 100644 +36 −0 Original line number Diff line number Diff line /****************************************************************************** * * Copyright 2024 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. * ******************************************************************************/ /* * MGMT stub */ #include <bluetooth/log.h> #include "hal/mgmt.h" namespace bluetooth { namespace hal { uint16_t Mgmt::get_vs_opcode(uint16_t vendor_specification) { log::debug("Using stub for vendor opcode 0x{:04x}", vendor_specification); return 0; } } // namespace hal } // namespace bluetooth Loading
system/gd/Android.bp +34 −0 Original line number Diff line number Diff line Loading @@ -89,10 +89,44 @@ cc_defaults { ], } soong_config_module_type { name: "mgmt_cc_defaults", module_type: "cc_defaults", config_namespace: "mgmt", variables: ["vertical"], properties: ["srcs"], } soong_config_string_variable { name: "vertical", values: [ "android_default", "android_desktop", ], } mgmt_cc_defaults { name: "mgmt_defaults", soong_config_variables: { vertical: { android_desktop: { srcs: [":BluetoothHalSources_mgmt"], }, android_default: { srcs: [":BluetoothHalSources_mgmt_stub"], }, conditions_default: { srcs: [":BluetoothHalSources_mgmt_stub"], }, }, }, } cc_defaults { name: "libbluetooth_gd_defaults", defaults: [ "gd_defaults", "mgmt_defaults", ], host_supported: true, target: { Loading
system/gd/hal/Android.bp +14 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,20 @@ filegroup { ], } filegroup { name: "BluetoothHalSources_mgmt_stub", srcs: [ "mgmt_stub.cc", ], } filegroup { name: "BluetoothHalSources_mgmt", srcs: [ "mgmt.cc", ], } filegroup { name: "BluetoothHalSources_ranging_android", srcs: [ Loading
system/gd/hal/hci_hal_android.cc +3 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ #include "hal/hci_backend.h" #include "hal/hci_hal.h" #include "hal/link_clocker.h" #include "hal/mgmt.h" #include "hal/snoop_logger.h" namespace bluetooth::hal { Loading Loading @@ -157,6 +158,8 @@ public: backend_->sendIsoData(packet); } uint16_t getMsftOpcode() override { return Mgmt().get_vs_opcode(MGMT_VS_OPCODE_MSFT); } protected: void ListDependencies(ModuleList* list) const override { list->add<LinkClocker>(); Loading
system/gd/hal/mgmt.cc +3 −3 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ constexpr static uint8_t BTPROTO_HCI = 1; constexpr static uint16_t HCI_CHANNEL_CONTROL = 3; constexpr static uint16_t HCI_DEV_NONE = 0xffff; static int btsocket_open_mgmt(uint16_t hci) { static int btsocket_open_mgmt() { int fd = socket(PF_BLUETOOTH, SOCK_RAW | SOCK_NONBLOCK, BTPROTO_HCI); if (fd < 0) { log::error("Failed to open BT socket."); Loading Loading @@ -84,7 +84,7 @@ static int btsocket_open_mgmt(uint16_t hci) { */ uint16_t Mgmt::get_vs_opcode(uint16_t vendor_specification) { int hci = GetAdapterIndex(); int fd = btsocket_open_mgmt(hci); int fd = btsocket_open_mgmt(); uint16_t ret_opcode = HCI_OP_NOP; if (fd < 0) { Loading @@ -99,7 +99,7 @@ uint16_t Mgmt::get_vs_opcode(uint16_t vendor_specification) { struct mgmt_cp_get_vs_opcode* cp = reinterpret_cast<struct mgmt_cp_get_vs_opcode*>(ev.data); cp->hci_id = hci; cp->vendor_specification = MGMT_VS_OPCODE_MSFT; cp->vendor_specification = vendor_specification; int ret; struct pollfd writable[1]; Loading
system/gd/hal/mgmt_stub.cc 0 → 100644 +36 −0 Original line number Diff line number Diff line /****************************************************************************** * * Copyright 2024 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. * ******************************************************************************/ /* * MGMT stub */ #include <bluetooth/log.h> #include "hal/mgmt.h" namespace bluetooth { namespace hal { uint16_t Mgmt::get_vs_opcode(uint16_t vendor_specification) { log::debug("Using stub for vendor opcode 0x{:04x}", vendor_specification); return 0; } } // namespace hal } // namespace bluetooth