Loading system/gd/cert/gd_base_test.py +6 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ from acts.base_test import BaseTestClass import importlib import logging import os import signal import sys Loading Loading @@ -63,6 +64,9 @@ class GdBaseTestClass(BaseTestClass): def teardown_class(self): self.unregister_controllers() self.rootcanal_process.send_signal(signal.SIGINT) self.rootcanal_process.wait() rootcanal_return_code = self.rootcanal_process.wait() self.rootcanal_logs.close() if rootcanal_return_code != 0: logging.error("rootcanal stopped with code: %d" % rootcanal_return_code) return False system/gd/cert/gd_device.py +7 −1 Original line number Diff line number Diff line Loading @@ -103,6 +103,8 @@ class GdDevice: log_path_base, 'GdDevice_%s_backing_logs.txt' % label) self.backing_process_logs = open(backing_process_logpath, 'w') btsnoop_path = os.path.join(log_path_base, '%s_btsnoop_hci.log' % label) cmd.append("--btsnoop=" + btsnoop_path) self.backing_process = subprocess.Popen( cmd, cwd=ANDROID_BUILD_TOP, Loading @@ -116,8 +118,12 @@ class GdDevice: def clean_up(self): self.grpc_channel.close() self.backing_process.send_signal(signal.SIGINT) self.backing_process.wait() backing_process_return_code = self.backing_process.wait() self.backing_process_logs.close() if backing_process_return_code != 0: logging.error("backing process stopped with code: %d" % backing_process_return_code) return False class GdDeviceLoggerAdapter(logging.LoggerAdapter): def process(self, msg, kwargs): Loading system/gd/facade/stack_with_grpc_main.cc +8 −1 Original line number Diff line number Diff line Loading @@ -15,8 +15,9 @@ */ #include "grpc/grpc_module.h" #include "hal/hci_hal_host_rootcanal.h" #include "hal/facade.h" #include "hal/hci_hal_host_rootcanal.h" #include "hal/snoop_logger.h" #include <csignal> #include <string> Loading Loading @@ -45,6 +46,8 @@ int main(int argc, const char** argv) { const std::string arg_grpc_port = "--port="; const std::string arg_rootcanal_port = "--rootcanal-port="; const std::string arg_btsnoop_path = "--btsnoop="; std::string btsnoop_path; for (int i = 1; i < argc; i++) { std::string arg = argv[i]; if (arg.find(arg_grpc_port) == 0) { Loading @@ -55,6 +58,10 @@ int main(int argc, const char** argv) { auto port_number = arg.substr(arg_rootcanal_port.size()); HciHalHostRootcanalConfig::Get()->SetPort(std::stoi(port_number)); } if (arg.find(arg_btsnoop_path) == 0) { btsnoop_path = arg.substr(arg_btsnoop_path.size()); ::bluetooth::hal::SnoopLogger::SetFilePath(btsnoop_path); } } ModuleList modules; Loading system/gd/hal/hci_hal_android_hidl.cc +4 −5 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ using HidlStatus = ::android::hardware::bluetooth::V1_0::Status; namespace bluetooth { namespace hal { namespace { constexpr char kDefaultBtsnoopPath[] = "/data/misc/bluetooth/logs/btsnoop_hci.log"; class HciDeathRecipient : public ::android::hardware::hidl_death_recipient { public: Loading Loading @@ -113,6 +112,8 @@ class InternalHciCallbacks : public IBluetoothHciCallbacks { } // namespace const std::string SnoopLogger::DefaultFilePath = "/data/misc/bluetooth/logs/btsnoop_hci.log"; class HciHalHidl : public HciHal { public: void registerIncomingPacketCallback(HciHalCallbacks* callback) override { Loading @@ -136,11 +137,11 @@ class HciHalHidl : public HciHal { protected: void ListDependencies(ModuleList* list) override { // We have no dependencies list->add<SnoopLogger>(); } void Start() override { btsnoop_logger_ = new SnoopLogger(kDefaultBtsnoopPath); btsnoop_logger_ = GetDependency<SnoopLogger>(); bt_hci_ = IBluetoothHci::getService(); ASSERT(bt_hci_ != nullptr); auto death_link = bt_hci_->linkToDeath(hci_death_recipient_, 0); Loading @@ -163,8 +164,6 @@ class HciHalHidl : public HciHal { bt_hci_->close(); callbacks_->ResetCallback(); bt_hci_ = nullptr; delete btsnoop_logger_; btsnoop_logger_ = nullptr; } private: Loading system/gd/hal/hci_hal_host_rootcanal.cc +4 −6 Original line number Diff line number Diff line Loading @@ -44,8 +44,6 @@ constexpr uint8_t kHciScoHeaderSize = 3; constexpr uint8_t kHciEvtHeaderSize = 2; constexpr int kBufSize = 1024; constexpr char kDefaultBtsnoopPath[] = "/tmp/btsnoop_hci.log"; int ConnectToRootCanal(const std::string& server, int port) { int socket_fd = socket(AF_INET, SOCK_STREAM, 0); if (socket_fd < 1) { Loading Loading @@ -88,6 +86,8 @@ int ConnectToRootCanal(const std::string& server, int port) { namespace bluetooth { namespace hal { const std::string SnoopLogger::DefaultFilePath = "/tmp/btsnoop_hci.log"; class HciHalHostRootcanal : public HciHal { public: void registerIncomingPacketCallback(HciHalCallbacks* callback) override { Loading Loading @@ -125,7 +125,7 @@ class HciHalHostRootcanal : public HciHal { protected: void ListDependencies(ModuleList* list) override { // We have no dependencies list->add<SnoopLogger>(); } void Start() override { Loading @@ -135,14 +135,12 @@ class HciHalHostRootcanal : public HciHal { ASSERT(sock_fd_ != INVALID_FD); reactable_ = hci_incoming_thread_.GetReactor()->Register(sock_fd_, [this]() { this->incoming_packet_received(); }, nullptr); btsnoop_logger_ = new SnoopLogger(kDefaultBtsnoopPath); btsnoop_logger_ = GetDependency<SnoopLogger>(); LOG_INFO("Rootcanal HAL opened successfully"); } void Stop() override { std::lock_guard<std::mutex> lock(mutex_); delete btsnoop_logger_; btsnoop_logger_ = nullptr; if (reactable_ != nullptr) { hci_incoming_thread_.GetReactor()->Unregister(reactable_); ASSERT(sock_fd_ != INVALID_FD); Loading Loading
system/gd/cert/gd_base_test.py +6 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ from acts.base_test import BaseTestClass import importlib import logging import os import signal import sys Loading Loading @@ -63,6 +64,9 @@ class GdBaseTestClass(BaseTestClass): def teardown_class(self): self.unregister_controllers() self.rootcanal_process.send_signal(signal.SIGINT) self.rootcanal_process.wait() rootcanal_return_code = self.rootcanal_process.wait() self.rootcanal_logs.close() if rootcanal_return_code != 0: logging.error("rootcanal stopped with code: %d" % rootcanal_return_code) return False
system/gd/cert/gd_device.py +7 −1 Original line number Diff line number Diff line Loading @@ -103,6 +103,8 @@ class GdDevice: log_path_base, 'GdDevice_%s_backing_logs.txt' % label) self.backing_process_logs = open(backing_process_logpath, 'w') btsnoop_path = os.path.join(log_path_base, '%s_btsnoop_hci.log' % label) cmd.append("--btsnoop=" + btsnoop_path) self.backing_process = subprocess.Popen( cmd, cwd=ANDROID_BUILD_TOP, Loading @@ -116,8 +118,12 @@ class GdDevice: def clean_up(self): self.grpc_channel.close() self.backing_process.send_signal(signal.SIGINT) self.backing_process.wait() backing_process_return_code = self.backing_process.wait() self.backing_process_logs.close() if backing_process_return_code != 0: logging.error("backing process stopped with code: %d" % backing_process_return_code) return False class GdDeviceLoggerAdapter(logging.LoggerAdapter): def process(self, msg, kwargs): Loading
system/gd/facade/stack_with_grpc_main.cc +8 −1 Original line number Diff line number Diff line Loading @@ -15,8 +15,9 @@ */ #include "grpc/grpc_module.h" #include "hal/hci_hal_host_rootcanal.h" #include "hal/facade.h" #include "hal/hci_hal_host_rootcanal.h" #include "hal/snoop_logger.h" #include <csignal> #include <string> Loading Loading @@ -45,6 +46,8 @@ int main(int argc, const char** argv) { const std::string arg_grpc_port = "--port="; const std::string arg_rootcanal_port = "--rootcanal-port="; const std::string arg_btsnoop_path = "--btsnoop="; std::string btsnoop_path; for (int i = 1; i < argc; i++) { std::string arg = argv[i]; if (arg.find(arg_grpc_port) == 0) { Loading @@ -55,6 +58,10 @@ int main(int argc, const char** argv) { auto port_number = arg.substr(arg_rootcanal_port.size()); HciHalHostRootcanalConfig::Get()->SetPort(std::stoi(port_number)); } if (arg.find(arg_btsnoop_path) == 0) { btsnoop_path = arg.substr(arg_btsnoop_path.size()); ::bluetooth::hal::SnoopLogger::SetFilePath(btsnoop_path); } } ModuleList modules; Loading
system/gd/hal/hci_hal_android_hidl.cc +4 −5 Original line number Diff line number Diff line Loading @@ -37,7 +37,6 @@ using HidlStatus = ::android::hardware::bluetooth::V1_0::Status; namespace bluetooth { namespace hal { namespace { constexpr char kDefaultBtsnoopPath[] = "/data/misc/bluetooth/logs/btsnoop_hci.log"; class HciDeathRecipient : public ::android::hardware::hidl_death_recipient { public: Loading Loading @@ -113,6 +112,8 @@ class InternalHciCallbacks : public IBluetoothHciCallbacks { } // namespace const std::string SnoopLogger::DefaultFilePath = "/data/misc/bluetooth/logs/btsnoop_hci.log"; class HciHalHidl : public HciHal { public: void registerIncomingPacketCallback(HciHalCallbacks* callback) override { Loading @@ -136,11 +137,11 @@ class HciHalHidl : public HciHal { protected: void ListDependencies(ModuleList* list) override { // We have no dependencies list->add<SnoopLogger>(); } void Start() override { btsnoop_logger_ = new SnoopLogger(kDefaultBtsnoopPath); btsnoop_logger_ = GetDependency<SnoopLogger>(); bt_hci_ = IBluetoothHci::getService(); ASSERT(bt_hci_ != nullptr); auto death_link = bt_hci_->linkToDeath(hci_death_recipient_, 0); Loading @@ -163,8 +164,6 @@ class HciHalHidl : public HciHal { bt_hci_->close(); callbacks_->ResetCallback(); bt_hci_ = nullptr; delete btsnoop_logger_; btsnoop_logger_ = nullptr; } private: Loading
system/gd/hal/hci_hal_host_rootcanal.cc +4 −6 Original line number Diff line number Diff line Loading @@ -44,8 +44,6 @@ constexpr uint8_t kHciScoHeaderSize = 3; constexpr uint8_t kHciEvtHeaderSize = 2; constexpr int kBufSize = 1024; constexpr char kDefaultBtsnoopPath[] = "/tmp/btsnoop_hci.log"; int ConnectToRootCanal(const std::string& server, int port) { int socket_fd = socket(AF_INET, SOCK_STREAM, 0); if (socket_fd < 1) { Loading Loading @@ -88,6 +86,8 @@ int ConnectToRootCanal(const std::string& server, int port) { namespace bluetooth { namespace hal { const std::string SnoopLogger::DefaultFilePath = "/tmp/btsnoop_hci.log"; class HciHalHostRootcanal : public HciHal { public: void registerIncomingPacketCallback(HciHalCallbacks* callback) override { Loading Loading @@ -125,7 +125,7 @@ class HciHalHostRootcanal : public HciHal { protected: void ListDependencies(ModuleList* list) override { // We have no dependencies list->add<SnoopLogger>(); } void Start() override { Loading @@ -135,14 +135,12 @@ class HciHalHostRootcanal : public HciHal { ASSERT(sock_fd_ != INVALID_FD); reactable_ = hci_incoming_thread_.GetReactor()->Register(sock_fd_, [this]() { this->incoming_packet_received(); }, nullptr); btsnoop_logger_ = new SnoopLogger(kDefaultBtsnoopPath); btsnoop_logger_ = GetDependency<SnoopLogger>(); LOG_INFO("Rootcanal HAL opened successfully"); } void Stop() override { std::lock_guard<std::mutex> lock(mutex_); delete btsnoop_logger_; btsnoop_logger_ = nullptr; if (reactable_ != nullptr) { hci_incoming_thread_.GetReactor()->Unregister(reactable_); ASSERT(sock_fd_ != INVALID_FD); Loading