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

Commit 9c5f5a91 authored by Rahul Arya's avatar Rahul Arya Committed by William Escande
Browse files

Rename LeAddressManager#GetCurrentAddress()

There is misuse of this function since it's not clear whether it is the
initiator address, or the identity address. Renaming it should prevent
future misuse. The followup CL fixes the incorrect usage when possible.

We also rename GetAnotherAddress for similar reasons.

Bug: 268112598
Test: unit
(cherry picked from https://android-review.googlesource.com/q/commit:39d32583924b13763820eccd567a3736751363e0)
Merged-In: Ia5640c02a452670f7dae85e9c8c0c8099da8159f
Change-Id: Ia5640c02a452670f7dae85e9c8c0c8099da8159f
Bug:279962122
parent 5d810081
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ import "blueberry/facade/common.proto";
service LeInitiatorAddressFacade {
  rpc SetPrivacyPolicyForInitiatorAddress(PrivacyPolicy) returns (google.protobuf.Empty) {}
  rpc GetCurrentInitiatorAddress(google.protobuf.Empty) returns (blueberry.facade.BluetoothAddressWithType) {}
  rpc GetAnotherAddress(google.protobuf.Empty) returns (blueberry.facade.BluetoothAddressWithType) {}
  rpc NewResolvableAddress(google.protobuf.Empty) returns (blueberry.facade.BluetoothAddressWithType) {}
}

enum AddressPolicy {
+3 −3
Original line number Diff line number Diff line
@@ -293,7 +293,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
    auto peer_address_type = connection_complete.GetPeerAddressType();
    auto role = connection_complete.GetRole();
    AddressWithType remote_address(address, peer_address_type);
    AddressWithType local_address = le_address_manager_->GetCurrentAddress();
    AddressWithType local_address = le_address_manager_->GetInitiatorAddress();
    const bool in_filter_accept_list = is_device_in_connect_list(remote_address);
    auto argument_list = std::vector<std::pair<bluetooth::os::ArgumentType, int>>();
    argument_list.push_back(
@@ -492,7 +492,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {

    AddressWithType local_address;
    if (role == hci::Role::CENTRAL) {
      local_address = le_address_manager_->GetCurrentAddress();
      local_address = le_address_manager_->GetInitiatorAddress();
    } else {
      // when accepting connection, we must obtain the address from the advertiser.
      // When we receive "set terminated event", we associate connection handle with advertiser address
@@ -757,7 +757,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
    }
    InitiatorFilterPolicy initiator_filter_policy = InitiatorFilterPolicy::USE_FILTER_ACCEPT_LIST;
    OwnAddressType own_address_type =
        static_cast<OwnAddressType>(le_address_manager_->GetCurrentAddress().GetAddressType());
        static_cast<OwnAddressType>(le_address_manager_->GetInitiatorAddress().GetAddressType());
    uint16_t conn_interval_min = 0x0018;
    uint16_t conn_interval_max = 0x0028;
    uint16_t conn_latency = 0x0000;
+3 −3
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ class LeInitiatorAddressFacadeService : public LeInitiatorAddressFacade::Service
      ::grpc::ServerContext* context,
      const ::google::protobuf::Empty* request,
      ::blueberry::facade::BluetoothAddressWithType* response) override {
    AddressWithType current = address_manager_->GetCurrentAddress();
    AddressWithType current = address_manager_->GetInitiatorAddress();
    auto bluetooth_address = new ::blueberry::facade::BluetoothAddress();
    bluetooth_address->set_address(current.GetAddress().ToString());
    response->set_type(static_cast<::blueberry::facade::BluetoothAddressTypeEnum>(current.GetAddressType()));
@@ -87,11 +87,11 @@ class LeInitiatorAddressFacadeService : public LeInitiatorAddressFacade::Service
    return ::grpc::Status::OK;
  }

  ::grpc::Status GetAnotherAddress(
  ::grpc::Status NewResolvableAddress(
      ::grpc::ServerContext* context,
      const ::google::protobuf::Empty* request,
      ::blueberry::facade::BluetoothAddressWithType* response) override {
    AddressWithType another = address_manager_->GetAnotherAddress();
    AddressWithType another = address_manager_->NewResolvableAddress();
    auto bluetooth_address = new ::blueberry::facade::BluetoothAddress();
    bluetooth_address->set_address(another.GetAddress().ToString());
    response->set_type(static_cast<::blueberry::facade::BluetoothAddressTypeEnum>(another.GetAddressType()));
+2 −2
Original line number Diff line number Diff line
@@ -214,12 +214,12 @@ void LeAddressManager::AckResume(LeAddressManagerCallback* callback) {
  handler_->BindOnceOn(this, &LeAddressManager::ack_resume, callback).Invoke();
}

AddressWithType LeAddressManager::GetCurrentAddress() {
AddressWithType LeAddressManager::GetInitiatorAddress() {
  ASSERT(address_policy_ != AddressPolicy::POLICY_NOT_SET);
  return le_address_;
}

AddressWithType LeAddressManager::GetAnotherAddress() {
AddressWithType LeAddressManager::NewResolvableAddress() {
  ASSERT(RotatingAddress());
  hci::Address address = generate_rpa();
  auto random_address = AddressWithType(address, AddressType::RANDOM_DEVICE_ADDRESS);
+3 −3
Original line number Diff line number Diff line
@@ -80,9 +80,9 @@ class LeAddressManager {
  virtual bool UnregisterSync(
      LeAddressManagerCallback* callback,
      std::chrono::milliseconds timeout = kUnregisterSyncTimeoutInMs);
  AddressWithType GetCurrentAddress();        // What was set in SetRandomAddress()
  AddressWithType GetAnotherAddress();        // A new random address without rotating.
  AddressWithType NewNonResolvableAddress();  // A new non-resolvable address
  virtual AddressWithType GetInitiatorAddress();      // What was set in SetRandomAddress()
  virtual AddressWithType NewResolvableAddress();     // A new random address without rotating.
  virtual AddressWithType NewNonResolvableAddress();  // A new non-resolvable address

  uint8_t GetFilterAcceptListSize();
  uint8_t GetResolvingListSize();
Loading