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

Commit 66d57833 authored by Myles Watson's avatar Myles Watson
Browse files

Remove AdapterConfig

Bug: 260006855
Test: atest bluetooth_unit_test_gd
Change-Id: Ifbc7bc4eadfd2eda8ad7d501895d76043466eb73
parent 9753bc22
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -273,10 +273,14 @@ void AclManager::SetPrivacyPolicyForInitiatorAddress(
    std::chrono::milliseconds minimum_rotation_time,
    std::chrono::milliseconds maximum_rotation_time) {
  crypto_toolbox::Octet16 rotation_irk{};
  auto irk = GetDependency<storage::StorageModule>()->GetAdapterConfig().GetLeIdentityResolvingKey();
  auto irk_prop =
      GetDependency<storage::StorageModule>()->GetProperty("Adapter", "LE_LOCAL_KEY_IRK");
  if (irk_prop.has_value()) {
    auto irk = common::ByteArray<16>::FromString(irk_prop.value());
    if (irk.has_value()) {
      rotation_irk = irk->bytes;
    }
  }
  CallOn(
      pimpl_->le_impl_,
      &le_impl::set_privacy_policy_for_initiator_address,
+14 −11
Original line number Diff line number Diff line
@@ -80,23 +80,26 @@ void SecurityManagerImpl::Init() {
  ASSERT_LOG(storage_module_ != nullptr, "Storage module must not be null!");
  security_database_.LoadRecordsFromStorage();

  storage::AdapterConfig adapter_config = storage_module_->GetAdapterConfig();
  if (!adapter_config.GetLeIdentityResolvingKey()) {
    auto mutation = storage_module_->Modify();
    mutation.Add(adapter_config.SetLeIdentityResolvingKey(bluetooth::os::GenerateRandom<16>()));
    mutation.Commit();
  auto irk_prop = storage_module_->GetBin("Adapter", "LE_LOCAL_KEY_IRK");
  if (!irk_prop.has_value()) {
    auto rand16 = bluetooth::os::GenerateRandom<16>();
    std::vector<uint8_t> new_irk{rand16.begin(), rand16.end()};
    storage_module_->SetBin("Adapter", "LE_LOCAL_KEY_IRK", new_irk);
    irk_prop = storage_module_->GetBin("Adapter", "LE_LOCAL_KEY_IRK");
  }

  Address controllerAddress = controller_->GetMacAddress();
  if (!adapter_config.GetAddress() || adapter_config.GetAddress().value() != controllerAddress) {
    auto mutation = storage_module_->Modify();
    mutation.Add(adapter_config.SetAddress(controllerAddress));
    mutation.Commit();
  auto address_prop = storage_module_->GetProperty("Adapter", "Address");
  if (!address_prop || address_prop.value() != controllerAddress.ToString()) {
    storage_module_->SetProperty("Adapter", "Address", controllerAddress.ToString());
  }

  local_identity_address_ =
      hci::AddressWithType(adapter_config.GetAddress().value(), hci::AddressType::PUBLIC_DEVICE_ADDRESS);
  local_identity_resolving_key_ = adapter_config.GetLeIdentityResolvingKey().value().bytes;
      hci::AddressWithType(controllerAddress, hci::AddressType::PUBLIC_DEVICE_ADDRESS);
  irk_prop = storage_module_->GetBin("Adapter", "LE_LOCAL_KEY_IRK");
  ASSERT_LOG(irk_prop.has_value(), "Irk not found in storage");
  ASSERT_LOG(irk_prop->size() == 16, "Irk corrupted in storage");
  std::copy(irk_prop->begin(), irk_prop->end(), local_identity_resolving_key_.data());

  hci::LeAddressManager::AddressPolicy address_policy = hci::LeAddressManager::AddressPolicy::USE_RESOLVABLE_ADDRESS;
  hci::AddressWithType address_with_type(hci::Address{}, hci::AddressType::RANDOM_DEVICE_ADDRESS);
+0 −2
Original line number Diff line number Diff line
@@ -10,7 +10,6 @@ package {
filegroup {
    name: "BluetoothStorageSources",
    srcs: [
        "adapter_config.cc",
        "classic_device.cc",
        "config_cache.cc",
        "config_cache_helper.cc",
@@ -26,7 +25,6 @@ filegroup {
filegroup {
    name: "BluetoothStorageUnitTestSources",
    srcs: [
        "adapter_config_test.cc",
        "classic_device_test.cc",
        "config_cache_helper_test.cc",
        "config_cache_test.cc",
+0 −1
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@

source_set("BluetoothStorageSources") {
  sources = [
    "adapter_config.cc",
    "classic_device.cc",
    "config_cache.cc",
    "config_cache_helper.cc",
+0 −26
Original line number Diff line number Diff line
/*
 * Copyright 2020 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.
 */

#include "storage/adapter_config.h"

namespace bluetooth {
namespace storage {

AdapterConfig::AdapterConfig(ConfigCache* config, ConfigCache* memory_only_config, std::string section)
    : config_(config), memory_only_config_(memory_only_config), section_(std::move(section)) {}

}  // namespace storage
}  // namespace bluetooth
 No newline at end of file
Loading