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

Commit 87ccf210 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes If88cfd69,Icea6e47b

* changes:
  Conditional entry between legacy Gd stack
  Gd shim layer neighbor modules
parents 39043c65 583d945e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -250,6 +250,7 @@ cc_test {
        ":BluetoothNeighborTestSources",
        ":BluetoothPacketTestSources",
        ":BluetoothSecurityTestSources",
        ":BluetoothShimTestSources",
    ],
    generated_headers: [
        "BluetoothGeneratedPackets_h",
+12 −0
Original line number Diff line number Diff line
@@ -2,7 +2,19 @@ filegroup {
    name: "BluetoothShimSources",
    srcs: [
            "controller.cc",
            "connectability.cc",
            "discoverability.cc",
            "hci_layer.cc",
            "inquiry.cc",
            "page.cc",
            "stack.cc",
    ],
}

filegroup {
    name: "BluetoothShimTestSources",
    srcs: [
    ],
}

+69 −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 "neighbor/connectability.h"
#include "os/handler.h"
#include "os/log.h"
#include "shim/connectability.h"

namespace bluetooth {
namespace shim {

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

struct Connectability::impl {
  impl(neighbor::ConnectabilityModule* module) : module_(module) {}

  neighbor::ConnectabilityModule* module_{nullptr};
};

void Connectability::StartConnectability() {
  pimpl_->module_->StartConnectability();
}

void Connectability::StopConnectability() {
  pimpl_->module_->StopConnectability();
}

bool Connectability::IsConnectable() const {
  return pimpl_->module_->IsConnectable();
}

/**
 * Module methods
 */
void Connectability::ListDependencies(ModuleList* list) {
  list->add<neighbor::ConnectabilityModule>();
}

void Connectability::Start() {
  pimpl_ = std::make_unique<impl>(GetDependency<neighbor::ConnectabilityModule>());
}

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

}  // namespace shim
}  // namespace bluetooth
+49 −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 "module.h"
#include "shim/iconnectability.h"

namespace bluetooth {
namespace shim {

class Connectability : public bluetooth::Module, public bluetooth::shim::IConnectability {
 public:
  void StartConnectability() override;
  void StopConnectability() override;
  bool IsConnectable() const override;

  Connectability() = default;
  ~Connectability() = 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(Connectability);
};

}  // namespace shim
}  // namespace bluetooth
+77 −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 "neighbor/discoverability.h"
#include "os/handler.h"
#include "os/log.h"
#include "shim/discoverability.h"

namespace bluetooth {
namespace shim {

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

struct Discoverability::impl {
  impl(neighbor::DiscoverabilityModule* module) : module_(module) {}

  neighbor::DiscoverabilityModule* module_{nullptr};
};

void Discoverability::StopDiscoverability() {
  return pimpl_->module_->StopDiscoverability();
}

void Discoverability::StartLimitedDiscoverability() {
  return pimpl_->module_->StartLimitedDiscoverability();
}

void Discoverability::StartGeneralDiscoverability() {
  return pimpl_->module_->StartGeneralDiscoverability();
}

bool Discoverability::IsGeneralDiscoverabilityEnabled() const {
  return pimpl_->module_->IsGeneralDiscoverabilityEnabled();
}

bool Discoverability::IsLimitedDiscoverabilityEnabled() const {
  return pimpl_->module_->IsLimitedDiscoverabilityEnabled();
}

/**
 * Module methods
 */
void Discoverability::ListDependencies(ModuleList* list) {
  list->add<neighbor::DiscoverabilityModule>();
}

void Discoverability::Start() {
  pimpl_ = std::make_unique<impl>(GetDependency<neighbor::DiscoverabilityModule>());
}

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

}  // namespace shim
}  // namespace bluetooth
Loading