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

Commit 09706a44 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Initial Entry for le advertising shim"

parents 5c099829 dbcbc123
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
filegroup {
    name: "BluetoothShimSources",
    srcs: [
            "advertising.cc",
            "controller.cc",
            "connectability.cc",
            "discoverability.cc",
+61 −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 "bt_gd_shim"

#include <functional>
#include <memory>

#include "hci/address.h"
#include "hci/hci_packets.h"
#include "hci/le_advertising_manager.h"
#include "module.h"
#include "os/handler.h"
#include "os/log.h"
#include "shim/advertising.h"

namespace bluetooth {
namespace shim {

struct Advertising::impl {
  hci::LeAdvertisingManager* module_{nullptr};

  impl(hci::LeAdvertisingManager* module);
  ~impl();
};

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

Advertising::impl::impl(hci::LeAdvertisingManager* advertising_manager) : module_(advertising_manager) {}

Advertising::impl::~impl() {}

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

void Advertising::Start() {
  pimpl_ = std::make_unique<impl>(GetDependency<hci::LeAdvertisingManager>());
}

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

}  // namespace shim
}  // namespace bluetooth
+46 −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/iadvertising.h"

namespace bluetooth {
namespace shim {

class Advertising : public bluetooth::Module, public bluetooth::shim::IAdvertising {
 public:
  Advertising() = default;
  ~Advertising() = default;

  static const ModuleFactory Factory;

 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(Advertising);
};

}  // namespace shim
}  // namespace bluetooth
+29 −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

/**
 * The gd API exported to the legacy api
 */
namespace bluetooth {
namespace shim {

struct IAdvertising {
  virtual ~IAdvertising() {}
};

}  // namespace shim
}  // namespace bluetooth
+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@
namespace bluetooth {
namespace shim {

struct IAdvertising;
struct IController;
struct IConnectability;
struct IDiscoverability;
@@ -35,6 +36,7 @@ struct IStack {
  virtual void Start() = 0;
  virtual void Stop() = 0;

  virtual IAdvertising* GetAdvertising() = 0;
  virtual IController* GetController() = 0;
  virtual IConnectability* GetConnectability() = 0;
  virtual IDiscoverability* GetDiscoverability() = 0;
Loading