Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d4060bd7 authored by Ajay Panicker's avatar Ajay Panicker
Browse files

Add default implementations for observer callbacks

Added defaults functions that do nothing for the bluetooth observers. Also
removed empty definition of the discovery callback in adapter. A little cleanup
was done too.

Change-Id: I93b6134f25e30e30cc2072cb4c99ce06aa781849
parent 6a6d917b
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -244,10 +244,6 @@ void Adapter::AdapterPropertiesCallback(bt_status_t status,
  }
}

void Adapter::DiscoveryStateChangedCallback(bt_discovery_state_t state) {
  // This does nothing
}

bool Adapter::SetAdapterProperty(bt_property_type_t type,
                                 void* value, int length) {
  CHECK(length > 0);
+0 −1
Original line number Diff line number Diff line
@@ -110,7 +110,6 @@ class Adapter : public hal::BluetoothInterface::Observer {
  void AdapterPropertiesCallback(bt_status_t status,
                                 int num_properties,
                                 bt_property_t* properties) override;
  void DiscoveryStateChangedCallback(bt_discovery_state_t state) override;

  // Sends a request to set the given HAL adapter property type and value.
  bool SetAdapterProperty(bt_property_type_t type, void* value, int length);
+20 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ void AdapterPropertiesCallback(bt_status_t status,
void DiscoveryStateChangedCallback(bt_discovery_state_t state) {
  lock_guard<mutex> lock(g_instance_lock);
  if (!g_bluetooth_interface) {
    LOG(WARNING) << "Callback recieved after global instance was destroyed";
    LOG(WARNING) << "Callback received after global instance was destroyed";
    return;
  }

@@ -256,6 +256,25 @@ base::ObserverList<BluetoothInterface::Observer>* GetObservers() {

}  // namespace

// Default observer implementations. These are provided so that the methods
// themselves are optional.
void BluetoothInterface::Observer::AdapterStateChangedCallback(
    bt_state_t /* state*/) {
  // Do nothing.
}

void BluetoothInterface::Observer::AdapterPropertiesCallback(
    bt_status_t /* status */,
    int /* num_properties */,
    bt_property_t* /* properties */) {
  // Do nothing.
}

void BluetoothInterface::Observer::DiscoveryStateChangedCallback(
    bt_discovery_state_t /* state */) {
  // Do nothing.
}

// static
bool BluetoothInterface::Initialize() {
  lock_guard<mutex> lock(g_instance_lock);
+3 −3
Original line number Diff line number Diff line
@@ -49,11 +49,11 @@ class BluetoothInterface {
    // All of the events below correspond to callbacks defined in
    // "bt_callbacks_t" in the HAL API definitions.

    virtual void AdapterStateChangedCallback(bt_state_t state) = 0;
    virtual void AdapterStateChangedCallback(bt_state_t state);
    virtual void AdapterPropertiesCallback(bt_status_t status,
                                           int num_properties,
                                           bt_property_t* properties) = 0;
    virtual void DiscoveryStateChangedCallback(bt_discovery_state_t state) = 0;
                                           bt_property_t* properties);
    virtual void DiscoveryStateChangedCallback(bt_discovery_state_t state);

    // TODO(armansito): Complete the list of callbacks.
  };
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ LOCAL_MODULE := net_test_bluetooth

# These tests use the bluetoothtbd HAL wrappers in order to easily interact
# with the interface using C++
# TODO: Make the bluetoothtbd HAL a static library
bluetoothHalSrc := \
  ../../service/hal/bluetooth_interface.cpp \
  ../../service/logging_helpers.cpp