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

Commit 9ff9b575 authored by Chris Manton's avatar Chris Manton Committed by android-build-merger
Browse files

Add legacy/gd shim controller module am: 2ee4a784 am: 6010caa3

am: d945649c

Change-Id: I142f107f7dfe22c867afb1941806fde216e897c0
parents 29a26f07 d945649c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
filegroup {
    name: "BluetoothShimSources",
    srcs: [
            "controller.cc",
            "stack.cc",
    ],
}
+109 −0
Original line number Diff line number Diff line
/*
 * Copyright 2019 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.
 */
#define LOG_TAG "gd_shim"

#include <memory>

#include "common/bidi_queue.h"
#include "hci/address.h"
#include "hci/controller.h"
#include "hci/hci_packets.h"
#include "module.h"
#include "os/handler.h"
#include "os/log.h"
#include "shim/controller.h"

namespace bluetooth {
namespace shim {

const ModuleFactory Controller::Factory = ModuleFactory([]() { return new Controller(); });

struct Controller::impl {
  impl(hci::Controller* hci_controller) : hci_controller_(hci_controller) {}

  hci::Controller* hci_controller_{nullptr};
};

bool Controller::IsCommandSupported(int op_code) const {
  return pimpl_->hci_controller_->IsSupported((bluetooth::hci::OpCode)op_code);
}

uint16_t Controller::GetControllerAclPacketLength() const {
  return pimpl_->hci_controller_->GetControllerAclPacketLength();
}

LeBufferSize Controller::GetControllerLeBufferSize() const {
  LeBufferSize le_buffer_size;
  hci::LeBufferSize hci_le_buffer_size = pimpl_->hci_controller_->GetControllerLeBufferSize();

  le_buffer_size.le_data_packet_length = hci_le_buffer_size.le_data_packet_length_;
  le_buffer_size.total_num_le_packets = hci_le_buffer_size.total_num_le_packets_;
  return le_buffer_size;
}

LeMaximumDataLength Controller::GetControllerLeMaximumDataLength() const {
  LeMaximumDataLength maximum_data_length;
  hci::LeMaximumDataLength hci_maximum_data_length = pimpl_->hci_controller_->GetControllerLeMaximumDataLength();

  maximum_data_length.supported_max_tx_octets = hci_maximum_data_length.supported_max_tx_octets_;
  maximum_data_length.supported_max_tx_time = hci_maximum_data_length.supported_max_tx_time_;
  maximum_data_length.supported_max_rx_octets = hci_maximum_data_length.supported_max_rx_octets_;
  maximum_data_length.supported_max_rx_time = hci_maximum_data_length.supported_max_rx_time_;
  return maximum_data_length;
}

uint16_t Controller::GetControllerNumAclPacketBuffers() const {
  return pimpl_->hci_controller_->GetControllerNumAclPacketBuffers();
}

uint64_t Controller::GetControllerLeLocalSupportedFeatures() const {
  return pimpl_->hci_controller_->GetControllerLeLocalSupportedFeatures();
}

uint64_t Controller::GetControllerLocalExtendedFeatures(uint8_t page_number) const {
  return pimpl_->hci_controller_->GetControllerLocalExtendedFeatures(page_number);
}

std::string Controller::GetControllerMacAddress() const {
  return pimpl_->hci_controller_->GetControllerMacAddress().ToString();
}

uint64_t Controller::GetControllerLeSupportedStates() const {
  return pimpl_->hci_controller_->GetControllerLeSupportedStates();
}

uint8_t Controller::GetControllerLocalExtendedFeaturesMaxPageNumber() const {
  return pimpl_->hci_controller_->GetControllerLocalExtendedFeaturesMaxPageNumber();
}

/**
 * Module methods
 */
void Controller::ListDependencies(ModuleList* list) {
  list->add<hci::Controller>();
}

void Controller::Start() {
  LOG_INFO("%s Starting controller shim layer", __func__);
  pimpl_ = std::make_unique<impl>(GetDependency<hci::Controller>());
}

void Controller::Stop() {
  pimpl_.reset();
}

}  // namespace shim
}  // namespace bluetooth
+65 −0
Original line number Diff line number Diff line
/*
 * Copyright 2019 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.
 */
#pragma once

#include <memory>
#include <string>

#include "module.h"
#include "shim/icontroller.h"

/**
 * Gd shim controller module that depends upon the Gd controller module.
 *
 * Wraps the Gd controller module to expose a sufficient API to allow
 * proper operation of the legacy shim controller interface.
 *
 */
namespace bluetooth {
namespace shim {

class Controller : public bluetooth::Module, public bluetooth::shim::IController {
 public:
  Controller() = default;
  ~Controller() = default;

  static const ModuleFactory Factory;

  // Exported controller methods from IController for shim layer
  bool IsCommandSupported(int op_code) const override;
  LeBufferSize GetControllerLeBufferSize() const override;
  LeMaximumDataLength GetControllerLeMaximumDataLength() const override;
  std::string GetControllerMacAddress() const override;
  uint16_t GetControllerAclPacketLength() const override;
  uint16_t GetControllerNumAclPacketBuffers() const override;
  uint64_t GetControllerLeLocalSupportedFeatures() const override;
  uint64_t GetControllerLeSupportedStates() const override;
  uint64_t GetControllerLocalExtendedFeatures(uint8_t page_number) const override;
  uint8_t GetControllerLocalExtendedFeaturesMaxPageNumber() const override;

 protected:
  void ListDependencies(ModuleList* list) override;  // Module
  void Start() override;                             // Module
  void Stop() override;                              // Module

 private:
  struct impl;
  std::unique_ptr<impl> pimpl_;
  DISALLOW_COPY_AND_ASSIGN(Controller);
};

}  // namespace shim
}  // namespace bluetooth
+55 −0
Original line number Diff line number Diff line
/*
 * Copyright 2019 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.
 */
#pragma once

#include <cstdint>
#include <string>

/**
 * The shim controller module that depends on the Gd controller module
 */
namespace bluetooth {
namespace shim {

typedef struct {
  uint16_t le_data_packet_length;
  uint8_t total_num_le_packets;
} LeBufferSize;

typedef struct {
  uint16_t supported_max_tx_octets;
  uint16_t supported_max_tx_time;
  uint16_t supported_max_rx_octets;
  uint16_t supported_max_rx_time;
} LeMaximumDataLength;

struct IController {
  virtual bool IsCommandSupported(int op_code) const = 0;
  virtual LeBufferSize GetControllerLeBufferSize() const = 0;
  virtual LeMaximumDataLength GetControllerLeMaximumDataLength() const = 0;
  virtual std::string GetControllerMacAddress() const = 0;
  virtual uint16_t GetControllerAclPacketLength() const = 0;
  virtual uint16_t GetControllerNumAclPacketBuffers() const = 0;
  virtual uint64_t GetControllerLeLocalSupportedFeatures() const = 0;
  virtual uint64_t GetControllerLeSupportedStates() const = 0;
  virtual uint64_t GetControllerLocalExtendedFeatures(uint8_t page_number) const = 0;
  virtual uint8_t GetControllerLocalExtendedFeaturesMaxPageNumber() const = 0;

  virtual ~IController() {}
};

}  // namespace shim
}  // namespace bluetooth
+4 −0
Original line number Diff line number Diff line
@@ -22,10 +22,14 @@
namespace bluetooth {
namespace shim {

struct IController;

struct IStack {
  virtual void Start() = 0;
  virtual void Stop() = 0;

  virtual IController* GetController() = 0;

  virtual ~IStack() {}
};

Loading