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

Commit 518d9478 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Get rid of Discoverability shim

Bug: 149757450
Change-Id: Ibe6cccc0971d4a723ba5489332ca7933e7609a34
parent d4e47054
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -29,13 +29,13 @@
#include "hci/facade/le_advertising_manager_facade.h"
#include "hci/facade/le_scanning_manager_facade.h"
#include "l2cap/classic/facade.h"
#include "neighbor/discoverability.h"
#include "neighbor/facade/facade.h"
#include "os/log.h"
#include "os/thread.h"
#include "security/facade.h"
#include "shim/advertising.h"
#include "shim/connectability.h"
#include "shim/discoverability.h"
#include "shim/dumpsys.h"
#include "shim/hci_layer.h"
#include "shim/inquiry.h"
@@ -107,7 +107,7 @@ class RootFacadeService : public ::bluetooth::facade::RootFacade::Service {
      case BluetoothModule::SHIM:
        modules.add<::bluetooth::shim::Advertising>();
        modules.add<::bluetooth::shim::Connectability>();
        modules.add<::bluetooth::shim::Discoverability>();
        modules.add<::bluetooth::neighbor::DiscoverabilityModule>();
        modules.add<::bluetooth::shim::Dumpsys>();
        modules.add<::bluetooth::shim::HciLayer>();
        modules.add<::bluetooth::shim::Inquiry>();
+0 −1
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@ filegroup {
    srcs: [
            "advertising.cc",
            "connectability.cc",
            "discoverability.cc",
            "dumpsys.cc",
            "hci_layer.cc",
            "inquiry.cc",

system/gd/shim/discoverability.cc

deleted100644 → 0
+0 −104
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 <memory>
#include <string>

#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 {

namespace {
constexpr char kModuleName[] = "shim::Discoverability";
}  // namespace

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

  neighbor::DiscoverabilityModule* module_{nullptr};

  bool general_discoverability_enabled_{false};
  bool limited_discoverability_enabled_{false};
};

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

void Discoverability::StopDiscoverability() {
  if (pimpl_->general_discoverability_enabled_ || pimpl_->limited_discoverability_enabled_) {
    pimpl_->module_->StopDiscoverability();
    LOG_DEBUG("%s Stopped discoverability", __func__);
  } else {
    LOG_WARN("%s Discoverability not enabled", __func__);
  }
}

void Discoverability::StartLimitedDiscoverability() {
  if (pimpl_->general_discoverability_enabled_ || pimpl_->limited_discoverability_enabled_) {
    LOG_WARN("%s Please stop discoverability before re-enabling", __func__);
    return;
  }
  pimpl_->module_->StartLimitedDiscoverability();
  LOG_DEBUG("%s Started limited discoverability", __func__);
}

void Discoverability::StartGeneralDiscoverability() {
  if (pimpl_->general_discoverability_enabled_ || pimpl_->limited_discoverability_enabled_) {
    LOG_WARN("%s Please stop discoverability before re-enabling", __func__);
    return;
  }
  pimpl_->module_->StartGeneralDiscoverability();
  LOG_DEBUG("%s Started general discoverability", __func__);
}

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

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

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

std::string Discoverability::ToString() const {
  return kModuleName;
}

}  // namespace shim
}  // namespace bluetooth

system/gd/shim/discoverability.h

deleted100644 → 0
+0 −53
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"

namespace bluetooth {
namespace shim {

class Discoverability : public bluetooth::Module {
 public:
  void StartGeneralDiscoverability();
  void StartLimitedDiscoverability();
  void StopDiscoverability();

  bool IsGeneralDiscoverabilityEnabled() const;
  bool IsLimitedDiscoverabilityEnabled() const;

  Discoverability() = default;
  ~Discoverability() = default;

  static const ModuleFactory Factory;

 protected:
  void ListDependencies(ModuleList* list) override;  // Module
  void Start() override;                             // Module
  void Stop() override;                              // Module
  std::string ToString() const override;             // Module

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

}  // namespace shim
}  // namespace bluetooth
+0 −2
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@
#include "security/security_module.h"
#include "shim/advertising.h"
#include "shim/connectability.h"
#include "shim/discoverability.h"
#include "shim/dumpsys.h"
#include "shim/hci_layer.h"
#include "shim/inquiry.h"
@@ -81,7 +80,6 @@ struct bluetooth::shim::Stack::impl {
    modules.add<::bluetooth::storage::LegacyModule>();
    modules.add<::bluetooth::shim::Advertising>();
    modules.add<::bluetooth::shim::Connectability>();
    modules.add<::bluetooth::shim::Discoverability>();
    modules.add<::bluetooth::shim::Dumpsys>();
    modules.add<::bluetooth::shim::Inquiry>();
    modules.add<::bluetooth::shim::Name>();
Loading