OSDN Git Service

HCI: Make Controller getters virtual and const
authorMyles Watson <mylesgw@google.com>
Thu, 7 Nov 2019 18:26:54 +0000 (10:26 -0800)
committerMyles Watson <mylesgw@google.com>
Thu, 7 Nov 2019 18:38:25 +0000 (10:38 -0800)
Getters that are virtual and const make testing easier for
modules that depend on the controller.

Bug: 139080884
Test: bluetooth_test_gd
Change-Id: Icde03e69f1ebd19c819a6b443665a6de0721505e

gd/hci/acl_manager_test.cc
gd/hci/controller.cc
gd/hci/controller.h

index 5ba14b2..8b2cb32 100644 (file)
@@ -73,11 +73,11 @@ class TestController : public Controller {
     acl_cb_handler_ = handler;
   }
 
-  uint16_t GetControllerAclPacketLength() override {
+  uint16_t GetControllerAclPacketLength() const override {
     return acl_buffer_length_;
   }
 
-  uint16_t GetControllerNumAclPacketBuffers() override {
+  uint16_t GetControllerNumAclPacketBuffers() const override {
     return total_acl_buffers_;
   }
 
index 6ebe895..d961064 100644 (file)
@@ -696,50 +696,50 @@ void Controller::RegisterCompletedAclPacketsCallback(Callback<void(uint16_t /* h
   impl_->RegisterCompletedAclPacketsCallback(cb, handler);  // TODO hsz: why here?
 }
 
-std::string Controller::GetControllerLocalName() {
+std::string Controller::GetControllerLocalName() const {
   return impl_->local_name_;
 }
 
-LocalVersionInformation Controller::GetControllerLocalVersionInformation() {
+LocalVersionInformation Controller::GetControllerLocalVersionInformation() const {
   return impl_->local_version_information_;
 }
 
-std::array<uint8_t, 64> Controller::GetControllerLocalSupportedCommands() {
+std::array<uint8_t, 64> Controller::GetControllerLocalSupportedCommands() const {
   return impl_->local_supported_commands_;
 }
 
-uint8_t Controller::GetControllerLocalExtendedFeaturesMaxPageNumber() {
+uint8_t Controller::GetControllerLocalExtendedFeaturesMaxPageNumber() const {
   return impl_->maximum_page_number_;
 }
 
-uint64_t Controller::GetControllerLocalSupportedFeatures() {
+uint64_t Controller::GetControllerLocalSupportedFeatures() const {
   return impl_->local_supported_features_;
 }
 
-uint64_t Controller::GetControllerLocalExtendedFeatures(uint8_t page_number) {
+uint64_t Controller::GetControllerLocalExtendedFeatures(uint8_t page_number) const {
   if (page_number <= impl_->maximum_page_number_) {
     return impl_->extended_lmp_features_array_[page_number];
   }
   return 0x00;
 }
 
-uint16_t Controller::GetControllerAclPacketLength() {
+uint16_t Controller::GetControllerAclPacketLength() const {
   return impl_->acl_buffer_length_;
 }
 
-uint16_t Controller::GetControllerNumAclPacketBuffers() {
+uint16_t Controller::GetControllerNumAclPacketBuffers() const {
   return impl_->acl_buffers_;
 }
 
-uint8_t Controller::GetControllerScoPacketLength() {
+uint8_t Controller::GetControllerScoPacketLength() const {
   return impl_->sco_buffer_length_;
 }
 
-uint16_t Controller::GetControllerNumScoPacketBuffers() {
+uint16_t Controller::GetControllerNumScoPacketBuffers() const {
   return impl_->sco_buffers_;
 }
 
-Address Controller::GetControllerMacAddress() {
+Address Controller::GetControllerMacAddress() const {
   return impl_->mac_address_;
 }
 
@@ -813,35 +813,35 @@ void Controller::LeSetEventMask(uint64_t le_event_mask) {
   GetHandler()->Post(common::BindOnce(&impl::le_set_event_mask, common::Unretained(impl_.get()), le_event_mask));
 }
 
-LeBufferSize Controller::GetControllerLeBufferSize() {
+LeBufferSize Controller::GetControllerLeBufferSize() const {
   return impl_->le_buffer_size_;
 }
 
-uint64_t Controller::GetControllerLeLocalSupportedFeatures() {
+uint64_t Controller::GetControllerLeLocalSupportedFeatures() const {
   return impl_->le_local_supported_features_;
 }
 
-uint64_t Controller::GetControllerLeSupportedStates() {
+uint64_t Controller::GetControllerLeSupportedStates() const {
   return impl_->le_supported_states_;
 }
 
-LeMaximumDataLength Controller::GetControllerLeMaximumDataLength() {
+LeMaximumDataLength Controller::GetControllerLeMaximumDataLength() const {
   return impl_->le_maximum_data_length_;
 }
 
-uint16_t Controller::GetControllerLeMaximumAdvertisingDataLength() {
+uint16_t Controller::GetControllerLeMaximumAdvertisingDataLength() const {
   return impl_->le_maximum_advertising_data_length_;
 }
 
-uint16_t Controller::GetControllerLeNumberOfSupportedAdverisingSets() {
+uint16_t Controller::GetControllerLeNumberOfSupportedAdverisingSets() const {
   return impl_->le_number_supported_advertising_sets_;
 }
 
-VendorCapabilities Controller::GetControllerVendorCapabilities() {
+VendorCapabilities Controller::GetControllerVendorCapabilities() const {
   return impl_->vendor_capabilities_;
 }
 
-bool Controller::IsSupported(bluetooth::hci::OpCode op_code) {
+bool Controller::IsSupported(bluetooth::hci::OpCode op_code) const {
   return impl_->is_supported(op_code);
 }
 
index 3a4ee1c..3f2d2cd 100644 (file)
@@ -34,27 +34,27 @@ class Controller : public Module {
   virtual void RegisterCompletedAclPacketsCallback(
       common::Callback<void(uint16_t /* handle */, uint16_t /* num_packets */)> cb, os::Handler* handler);
 
-  virtual std::string GetControllerLocalName();
+  virtual std::string GetControllerLocalName() const;
 
-  virtual LocalVersionInformation GetControllerLocalVersionInformation();
+  virtual LocalVersionInformation GetControllerLocalVersionInformation() const;
 
-  virtual std::array<uint8_t, 64> GetControllerLocalSupportedCommands();
+  virtual std::array<uint8_t, 64> GetControllerLocalSupportedCommands() const;
 
-  virtual uint64_t GetControllerLocalSupportedFeatures();
+  virtual uint64_t GetControllerLocalSupportedFeatures() const;
 
-  virtual uint8_t GetControllerLocalExtendedFeaturesMaxPageNumber();
+  virtual uint8_t GetControllerLocalExtendedFeaturesMaxPageNumber() const;
 
-  virtual uint64_t GetControllerLocalExtendedFeatures(uint8_t page_number);
+  virtual uint64_t GetControllerLocalExtendedFeatures(uint8_t page_number) const;
 
-  virtual uint16_t GetControllerAclPacketLength();
+  virtual uint16_t GetControllerAclPacketLength() const;
 
-  virtual uint16_t GetControllerNumAclPacketBuffers();
+  virtual uint16_t GetControllerNumAclPacketBuffers() const;
 
-  virtual uint8_t GetControllerScoPacketLength();
+  virtual uint8_t GetControllerScoPacketLength() const;
 
-  virtual uint16_t GetControllerNumScoPacketBuffers();
+  virtual uint16_t GetControllerNumScoPacketBuffers() const;
 
-  virtual Address GetControllerMacAddress();
+  virtual Address GetControllerMacAddress() const;
 
   virtual void SetEventMask(uint64_t event_mask);
 
@@ -86,21 +86,21 @@ class Controller : public Module {
   // LE controller commands
   virtual void LeSetEventMask(uint64_t le_event_mask);
 
-  LeBufferSize GetControllerLeBufferSize();
+  virtual LeBufferSize GetControllerLeBufferSize() const;
 
-  uint64_t GetControllerLeLocalSupportedFeatures();
+  virtual uint64_t GetControllerLeLocalSupportedFeatures() const;
 
-  uint64_t GetControllerLeSupportedStates();
+  virtual uint64_t GetControllerLeSupportedStates() const;
 
-  LeMaximumDataLength GetControllerLeMaximumDataLength();
+  virtual LeMaximumDataLength GetControllerLeMaximumDataLength() const;
 
-  uint16_t GetControllerLeMaximumAdvertisingDataLength();
+  virtual uint16_t GetControllerLeMaximumAdvertisingDataLength() const;
 
-  uint16_t GetControllerLeNumberOfSupportedAdverisingSets();
+  virtual uint16_t GetControllerLeNumberOfSupportedAdverisingSets() const;
 
-  VendorCapabilities GetControllerVendorCapabilities();
+  virtual VendorCapabilities GetControllerVendorCapabilities() const;
 
-  bool IsSupported(OpCode op_code);
+  virtual bool IsSupported(OpCode op_code) const;
 
   static const ModuleFactory Factory;