From: Zach Johnson Date: Mon, 29 Apr 2019 19:07:23 +0000 (-0700) Subject: Remove redundant Bluetooth from internal class names X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=b45ecd2fd7;p=android-x86%2Fsystem-bt.git Remove redundant Bluetooth from internal class names Test: atest --host bluetooth_test_gd and ./cert/run_cert.sh Change-Id: I55b2c1ecc1ec254a197d6fde70968a9aa8c06c00 --- diff --git a/gd/hal/Android.bp b/gd/hal/Android.bp index 8dd4eaaa2..cb4ca82c9 100644 --- a/gd/hal/Android.bp +++ b/gd/hal/Android.bp @@ -1,7 +1,7 @@ filegroup { name: "BluetoothHalSources", srcs: [ - "bluetooth_snoop_logger.cc", + "snoop_logger.cc", ], } diff --git a/gd/hal/facade/facade.cc b/gd/hal/facade/facade.cc index 754293112..815ff8f9f 100644 --- a/gd/hal/facade/facade.cc +++ b/gd/hal/facade/facade.cc @@ -37,9 +37,9 @@ namespace facade { class HciTransportationService : public HciTransportation::Service, - public ::bluetooth::hal::BluetoothHciHalCallbacks { + public ::bluetooth::hal::HciHalCallbacks { public: - HciTransportationService(BluetoothHciHal* hal) : hal_(hal) { + HciTransportationService(HciHal* hal) : hal_(hal) { } ::grpc::Status SetLoopbackMode(::grpc::ServerContext* context, @@ -88,17 +88,17 @@ class HciTransportationService // TODO } private: - BluetoothHciHal* hal_; + HciHal* hal_; }; void HalFacadeModule::ListDependencies(ModuleList* list) { ::bluetooth::grpc::GrpcFacadeModule::ListDependencies(list); - list->add(); + list->add(); } void HalFacadeModule::Start(const ModuleRegistry* registry) { ::bluetooth::grpc::GrpcFacadeModule::Start(registry); - auto hal = registry->GetInstance(); + auto hal = registry->GetInstance(); service_ = new HciTransportationService(hal); hal->registerIncomingPacketCallback(service_); diff --git a/gd/hal/hci_hal.h b/gd/hal/hci_hal.h index b8d6849e5..88c0d9ecb 100644 --- a/gd/hal/hci_hal.h +++ b/gd/hal/hci_hal.h @@ -31,9 +31,9 @@ enum class Status : int32_t { SUCCESS, TRANSPORT_ERROR, INITIALIZATION_ERROR, UN // callback to BluetoothInitializationCompleteCallback // The interface from the Bluetooth Controller to the stack -class BluetoothHciHalCallbacks { +class HciHalCallbacks { public: - virtual ~BluetoothHciHalCallbacks() = default; + virtual ~HciHalCallbacks() = default; // This function is invoked when an HCI event is received from the // Bluetooth controller to be forwarded to the Bluetooth stack @@ -56,11 +56,11 @@ class BluetoothHciHalCallbacks { // Abstraction Layer (HAL). Dealing only in HCI packets and events simplifies // the stack and abstracts away power management, initialization, and other // implementation-specific details related to the hardware. -class BluetoothHciHal : public ::bluetooth::Module { +class HciHal : public ::bluetooth::Module { public: static const ModuleFactory Factory; - virtual ~BluetoothHciHal() = default; + virtual ~HciHal() = default; // Register the callback for incoming packets. All incoming packets are dropped before // this callback is registered. Callback can only be registered once, but will be reset @@ -71,7 +71,7 @@ class BluetoothHciHal : public ::bluetooth::Module { // @param callback implements BluetoothHciHalCallbacks which will // receive callbacks when incoming HCI packets are received // from the controller to be sent to the host. - virtual void registerIncomingPacketCallback(BluetoothHciHalCallbacks* callback) = 0; + virtual void registerIncomingPacketCallback(HciHalCallbacks* callback) = 0; // Send an HCI command (as specified in the Bluetooth Specification // V4.2, Vol 2, Part 5, Section 5.4.1) to the Bluetooth controller. diff --git a/gd/hal/hci_hal_android_hidl.cc b/gd/hal/hci_hal_android_hidl.cc index 0c2b56fb0..ca24746e4 100644 --- a/gd/hal/hci_hal_android_hidl.cc +++ b/gd/hal/hci_hal_android_hidl.cc @@ -24,7 +24,7 @@ #include #include -#include "hal/bluetooth_snoop_logger.h" +#include "hal/snoop_logger.h" #include "os/log.h" using ::android::hardware::hidl_vec; @@ -39,7 +39,7 @@ namespace hal { namespace { constexpr char kDefaultBtsnoopPath[] = "/data/misc/bluetooth/logs/btsnoop_hci.log"; -class BluetoothHciDeathRecipient : public ::android::hardware::hidl_death_recipient { +class HciDeathRecipient : public ::android::hardware::hidl_death_recipient { public: virtual void serviceDied(uint64_t /*cookie*/, const android::wp<::android::hidl::base::V1_0::IBase>& /*who*/) { LOG_ERROR("Bluetooth HAL service died!"); @@ -47,16 +47,16 @@ class BluetoothHciDeathRecipient : public ::android::hardware::hidl_death_recipi } }; -android::sp bluetooth_hci_death_recipient_ = new BluetoothHciDeathRecipient(); +android::sp hci_death_recipient_ = new HciDeathRecipient(); -class HciHalBluetoothHciCallbacks : public IBluetoothHciCallbacks { +class InternalHciCallbacks : public IBluetoothHciCallbacks { public: - HciHalBluetoothHciCallbacks(BluetoothSnoopLogger* btsnoop_logger) + InternalHciCallbacks(SnoopLogger* btsnoop_logger) : btsnoop_logger_(btsnoop_logger) { init_promise_ = new std::promise(); } - void SetCallback(BluetoothHciHalCallbacks* callback) { + void SetCallback(HciHalCallbacks* callback) { ASSERT(callback_ == nullptr && callback != nullptr); callback_ = callback; } @@ -77,8 +77,8 @@ class HciHalBluetoothHciCallbacks : public IBluetoothHciCallbacks { Return hciEventReceived(const hidl_vec& event) { std::vector received_hci_packet(event.begin(), event.end()); - btsnoop_logger_->capture(received_hci_packet, BluetoothSnoopLogger::Direction::INCOMING, - BluetoothSnoopLogger::PacketType::EVT); + btsnoop_logger_->capture(received_hci_packet, SnoopLogger::Direction::INCOMING, + SnoopLogger::PacketType::EVT); if (callback_ != nullptr) { callback_->hciEventReceived(std::move(received_hci_packet)); } @@ -87,8 +87,8 @@ class HciHalBluetoothHciCallbacks : public IBluetoothHciCallbacks { Return aclDataReceived(const hidl_vec& data) { std::vector received_hci_packet(data.begin(), data.end()); - btsnoop_logger_->capture(received_hci_packet, BluetoothSnoopLogger::Direction::INCOMING, - BluetoothSnoopLogger::PacketType::ACL); + btsnoop_logger_->capture(received_hci_packet, SnoopLogger::Direction::INCOMING, + SnoopLogger::PacketType::ACL); if (callback_ != nullptr) { callback_->aclDataReceived(std::move(received_hci_packet)); } @@ -97,8 +97,8 @@ class HciHalBluetoothHciCallbacks : public IBluetoothHciCallbacks { Return scoDataReceived(const hidl_vec& data) { std::vector received_hci_packet(data.begin(), data.end()); - btsnoop_logger_->capture(received_hci_packet, BluetoothSnoopLogger::Direction::INCOMING, - BluetoothSnoopLogger::PacketType::SCO); + btsnoop_logger_->capture(received_hci_packet, SnoopLogger::Direction::INCOMING, + SnoopLogger::PacketType::SCO); if (callback_ != nullptr) { callback_->scoDataReceived(std::move(received_hci_packet)); } @@ -107,30 +107,30 @@ class HciHalBluetoothHciCallbacks : public IBluetoothHciCallbacks { private: std::promise* init_promise_ = nullptr; - BluetoothHciHalCallbacks* callback_ = nullptr; - BluetoothSnoopLogger* btsnoop_logger_ = nullptr; + HciHalCallbacks* callback_ = nullptr; + SnoopLogger* btsnoop_logger_ = nullptr; }; } // namespace -class BluetoothHciHalHidl : public BluetoothHciHal { +class HciHalHidl : public HciHal { public: - void registerIncomingPacketCallback(BluetoothHciHalCallbacks* callback) override { + void registerIncomingPacketCallback(HciHalCallbacks* callback) override { callbacks_->SetCallback(callback); } void sendHciCommand(HciPacket command) override { - btsnoop_logger_->capture(command, BluetoothSnoopLogger::Direction::OUTGOING, BluetoothSnoopLogger::PacketType::CMD); + btsnoop_logger_->capture(command, SnoopLogger::Direction::OUTGOING, SnoopLogger::PacketType::CMD); bt_hci_->sendHciCommand(command); } void sendAclData(HciPacket packet) override { - btsnoop_logger_->capture(packet, BluetoothSnoopLogger::Direction::OUTGOING, BluetoothSnoopLogger::PacketType::ACL); + btsnoop_logger_->capture(packet, SnoopLogger::Direction::OUTGOING, SnoopLogger::PacketType::ACL); bt_hci_->sendAclData(packet); } void sendScoData(HciPacket packet) override { - btsnoop_logger_->capture(packet, BluetoothSnoopLogger::Direction::OUTGOING, BluetoothSnoopLogger::PacketType::SCO); + btsnoop_logger_->capture(packet, SnoopLogger::Direction::OUTGOING, SnoopLogger::PacketType::SCO); bt_hci_->sendScoData(packet); } @@ -140,14 +140,14 @@ class BluetoothHciHalHidl : public BluetoothHciHal { } void Start(const ModuleRegistry* registry) override { - btsnoop_logger_ = new BluetoothSnoopLogger(kDefaultBtsnoopPath); + btsnoop_logger_ = new SnoopLogger(kDefaultBtsnoopPath); bt_hci_ = IBluetoothHci::getService(); ASSERT(bt_hci_ != nullptr); - auto death_link = bt_hci_->linkToDeath(bluetooth_hci_death_recipient_, 0); + auto death_link = bt_hci_->linkToDeath(hci_death_recipient_, 0); ASSERT_LOG(death_link.isOk(), "Unable to set the death recipient for the Bluetooth HAL"); // Block allows allocation of a variable that might be bypassed by goto. { - callbacks_ = new HciHalBluetoothHciCallbacks(btsnoop_logger_); + callbacks_ = new InternalHciCallbacks(btsnoop_logger_); bt_hci_->initialize(callbacks_); // Don't timeout here, time out at a higher layer callbacks_->GetInitPromise()->get_future().wait(); @@ -156,7 +156,7 @@ class BluetoothHciHalHidl : public BluetoothHciHal { void Stop(const ModuleRegistry* registry) override { ASSERT(bt_hci_ != nullptr); - auto death_unlink = bt_hci_->unlinkToDeath(bluetooth_hci_death_recipient_); + auto death_unlink = bt_hci_->unlinkToDeath(hci_death_recipient_); if (!death_unlink.isOk()) { LOG_ERROR("Error unlinking death recipient from the Bluetooth HAL"); } @@ -168,13 +168,13 @@ class BluetoothHciHalHidl : public BluetoothHciHal { } private: - android::sp callbacks_; + android::sp callbacks_; android::sp bt_hci_; - BluetoothSnoopLogger* btsnoop_logger_; + SnoopLogger* btsnoop_logger_; }; -const ModuleFactory BluetoothHciHal::Factory = ModuleFactory([]() { - return new BluetoothHciHalHidl(); +const ModuleFactory HciHal::Factory = ModuleFactory([]() { + return new HciHalHidl(); }); } // namespace hal diff --git a/gd/hal/hci_hal_android_hidl_test.cc b/gd/hal/hci_hal_android_hidl_test.cc index 01eaa2d87..0a302ed67 100644 --- a/gd/hal/hci_hal_android_hidl_test.cc +++ b/gd/hal/hci_hal_android_hidl_test.cc @@ -37,7 +37,7 @@ class HciHalHidlTest : public ::testing::Test { }; TEST_F(HciHalHidlTest, init_and_close) { - fake_registry_.Start(); + fake_registry_.Start(); fake_registry_.StopAll(); } } // namespace diff --git a/gd/hal/hci_hal_host_rootcanal.cc b/gd/hal/hci_hal_host_rootcanal.cc index 94afad73e..b169447bd 100644 --- a/gd/hal/hci_hal_host_rootcanal.cc +++ b/gd/hal/hci_hal_host_rootcanal.cc @@ -24,7 +24,7 @@ #include #include -#include "hal/bluetooth_snoop_logger.h" +#include "hal/snoop_logger.h" #include "os/log.h" #include "os/reactor.h" #include "os/thread.h" @@ -84,9 +84,9 @@ int ConnectToRootCanal(const std::string& server, int port) { namespace bluetooth { namespace hal { -class BluetoothHciHalHostRootcanal : public BluetoothHciHal { +class HciHalHostRootcanal : public HciHal { public: - void registerIncomingPacketCallback(BluetoothHciHalCallbacks* callback) override { + void registerIncomingPacketCallback(HciHalCallbacks* callback) override { std::lock_guard lock(mutex_); ASSERT(incoming_packet_callback_ == nullptr && callback != nullptr); incoming_packet_callback_ = callback; @@ -96,7 +96,7 @@ class BluetoothHciHalHostRootcanal : public BluetoothHciHal { std::lock_guard lock(mutex_); ASSERT(sock_fd_ != INVALID_FD); std::vector packet = std::move(command); - btsnoop_logger_->capture(packet, BluetoothSnoopLogger::Direction::OUTGOING, BluetoothSnoopLogger::PacketType::CMD); + btsnoop_logger_->capture(packet, SnoopLogger::Direction::OUTGOING, SnoopLogger::PacketType::CMD); packet.insert(packet.cbegin(), kH4Command); write_to_rootcanal_fd(packet); } @@ -105,7 +105,7 @@ class BluetoothHciHalHostRootcanal : public BluetoothHciHal { std::lock_guard lock(mutex_); ASSERT(sock_fd_ != INVALID_FD); std::vector packet = std::move(data); - btsnoop_logger_->capture(packet, BluetoothSnoopLogger::Direction::OUTGOING, BluetoothSnoopLogger::PacketType::ACL); + btsnoop_logger_->capture(packet, SnoopLogger::Direction::OUTGOING, SnoopLogger::PacketType::ACL); packet.insert(packet.cbegin(), kH4Acl); write_to_rootcanal_fd(packet); } @@ -114,7 +114,7 @@ class BluetoothHciHalHostRootcanal : public BluetoothHciHal { std::lock_guard lock(mutex_); ASSERT(sock_fd_ != INVALID_FD); std::vector packet = std::move(data); - btsnoop_logger_->capture(packet, BluetoothSnoopLogger::Direction::OUTGOING, BluetoothSnoopLogger::PacketType::SCO); + btsnoop_logger_->capture(packet, SnoopLogger::Direction::OUTGOING, SnoopLogger::PacketType::SCO); packet.insert(packet.cbegin(), kH4Sco); write_to_rootcanal_fd(packet); } @@ -131,7 +131,7 @@ class BluetoothHciHalHostRootcanal : public BluetoothHciHal { ASSERT(sock_fd_ != INVALID_FD); reactable_ = hci_incoming_thread_.GetReactor()->Register(sock_fd_, [this]() { this->incoming_packet_received(); }, nullptr); - btsnoop_logger_ = new BluetoothSnoopLogger(kDefaultBtsnoopPath); + btsnoop_logger_ = new SnoopLogger(kDefaultBtsnoopPath); LOG_INFO("Rootcanal HAL opened successfully"); } @@ -153,13 +153,13 @@ class BluetoothHciHalHostRootcanal : public BluetoothHciHal { private: std::mutex mutex_; HciHalHostRootcanalConfig* config_ = HciHalHostRootcanalConfig::Get(); - BluetoothHciHalCallbacks* incoming_packet_callback_ = nullptr; + HciHalCallbacks* incoming_packet_callback_ = nullptr; int sock_fd_ = INVALID_FD; bluetooth::os::Thread hci_incoming_thread_ = bluetooth::os::Thread("hci_incoming_thread", bluetooth::os::Thread::Priority::NORMAL); bluetooth::os::Reactor::Reactable* reactable_ = nullptr; std::queue> hci_outgoing_queue_; - BluetoothSnoopLogger* btsnoop_logger_; + SnoopLogger* btsnoop_logger_; void write_to_rootcanal_fd(HciPacket packet) { // TODO: replace this with new queue when it's ready @@ -211,8 +211,8 @@ class BluetoothHciHalHostRootcanal : public BluetoothHciHal { HciPacket receivedHciPacket; receivedHciPacket.assign(buf + kH4HeaderSize, buf + kH4HeaderSize + kHciEvtHeaderSize + payload_size); - btsnoop_logger_->capture(receivedHciPacket, BluetoothSnoopLogger::Direction::INCOMING, - BluetoothSnoopLogger::PacketType::EVT); + btsnoop_logger_->capture(receivedHciPacket, SnoopLogger::Direction::INCOMING, + SnoopLogger::PacketType::EVT); incoming_packet_callback_->hciEventReceived(receivedHciPacket); } @@ -229,8 +229,8 @@ class BluetoothHciHalHostRootcanal : public BluetoothHciHal { HciPacket receivedHciPacket; receivedHciPacket.assign(buf + kH4HeaderSize, buf + kH4HeaderSize + kHciAclHeaderSize + payload_size); - btsnoop_logger_->capture(receivedHciPacket, BluetoothSnoopLogger::Direction::INCOMING, - BluetoothSnoopLogger::PacketType::ACL); + btsnoop_logger_->capture(receivedHciPacket, SnoopLogger::Direction::INCOMING, + SnoopLogger::PacketType::ACL); incoming_packet_callback_->aclDataReceived(receivedHciPacket); } @@ -244,16 +244,16 @@ class BluetoothHciHalHostRootcanal : public BluetoothHciHal { HciPacket receivedHciPacket; receivedHciPacket.assign(buf + kH4HeaderSize, buf + kH4HeaderSize + kHciScoHeaderSize + payload_size); - btsnoop_logger_->capture(receivedHciPacket, BluetoothSnoopLogger::Direction::INCOMING, - BluetoothSnoopLogger::PacketType::SCO); + btsnoop_logger_->capture(receivedHciPacket, SnoopLogger::Direction::INCOMING, + SnoopLogger::PacketType::SCO); incoming_packet_callback_->scoDataReceived(receivedHciPacket); } memset(buf, 0, kBufSize); } }; -const ModuleFactory BluetoothHciHal::Factory = ModuleFactory([]() { - return new BluetoothHciHalHostRootcanal(); +const ModuleFactory HciHal::Factory = ModuleFactory([]() { + return new HciHalHostRootcanal(); }); } // namespace hal diff --git a/gd/hal/hci_hal_host_rootcanal_test.cc b/gd/hal/hci_hal_host_rootcanal_test.cc index 33b62210b..bb4649ea6 100644 --- a/gd/hal/hci_hal_host_rootcanal_test.cc +++ b/gd/hal/hci_hal_host_rootcanal_test.cc @@ -50,7 +50,7 @@ using H4Packet = std::vector; std::queue> incoming_packets_queue_; -class TestBluetoothHciHalCallbacks : public BluetoothHciHalCallbacks { +class TestHciHalCallbacks : public HciHalCallbacks { public: void hciEventReceived(HciPacket packet) override { incoming_packets_queue_.emplace(kH4Event, packet); @@ -134,8 +134,8 @@ class HciHalRootcanalTest : public ::testing::Test { void SetUp() override { HciHalHostRootcanalConfig::Get()->SetPort(kTestPort); fake_server_ = new FakeRootcanalDesktopHciServer; - fake_registry_.Start(); - hal_ = fake_registry_.GetInstance(); + fake_registry_.Start(); + hal_ = fake_registry_.GetInstance(); hal_->registerIncomingPacketCallback(&callbacks_); fake_server_socket_ = fake_server_->Accept(); // accept() after client is connected to avoid blocking std::queue> empty; @@ -155,9 +155,9 @@ class HciHalRootcanalTest : public ::testing::Test { } FakeRootcanalDesktopHciServer* fake_server_ = nullptr; - BluetoothHciHal* hal_ = nullptr; + HciHal* hal_ = nullptr; ModuleRegistry fake_registry_; - TestBluetoothHciHalCallbacks callbacks_; + TestHciHalCallbacks callbacks_; int fake_server_socket_ = -1; }; diff --git a/gd/hal/bluetooth_snoop_logger.cc b/gd/hal/snoop_logger.cc similarity index 94% rename from gd/hal/bluetooth_snoop_logger.cc rename to gd/hal/snoop_logger.cc index 2fd719d97..37eacf635 100644 --- a/gd/hal/bluetooth_snoop_logger.cc +++ b/gd/hal/snoop_logger.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "hal/bluetooth_snoop_logger.h" +#include "hal/snoop_logger.h" #include #include @@ -67,7 +67,7 @@ constexpr btsnoop_file_header_t BTSNOOP_FILE_HEADER = { .datalink_type = BTSNOOP_DATALINK_TYPE}; } // namespace -BluetoothSnoopLogger::BluetoothSnoopLogger(const std::string& filename) { +SnoopLogger::SnoopLogger(const std::string& filename) { { std::ifstream btsnoop_istream(filename); file_exists_ = btsnoop_istream.is_open(); @@ -81,7 +81,7 @@ BluetoothSnoopLogger::BluetoothSnoopLogger(const std::string& filename) { } } -void BluetoothSnoopLogger::capture(const HciPacket& packet, Direction direction, PacketType type) { +void SnoopLogger::capture(const HciPacket& packet, Direction direction, PacketType type) { uint64_t timestamp_us = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()) .count(); diff --git a/gd/hal/bluetooth_snoop_logger.h b/gd/hal/snoop_logger.h similarity index 92% rename from gd/hal/bluetooth_snoop_logger.h rename to gd/hal/snoop_logger.h index 6c41f3a55..4447a8fb7 100644 --- a/gd/hal/bluetooth_snoop_logger.h +++ b/gd/hal/snoop_logger.h @@ -26,9 +26,9 @@ namespace bluetooth { namespace hal { -class BluetoothSnoopLogger { +class SnoopLogger { public: - explicit BluetoothSnoopLogger(const std::string& filename); + explicit SnoopLogger(const std::string& filename); enum class PacketType { CMD = 1,