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

Commit 39d32583 authored by Rahul Arya's avatar Rahul Arya
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
Change-Id: Ia5640c02a452670f7dae85e9c8c0c8099da8159f
parent 5c715054
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 {
+4 −4
Original line number Diff line number Diff line
@@ -338,7 +338,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);

    if (role == hci::Role::CENTRAL) {
@@ -612,7 +612,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {

  RoleSpecificData initialize_role_specific_data(Role role) {
    if (role == hci::Role::CENTRAL) {
      return DataAsCentral{le_address_manager_->GetCurrentAddress()};
      return DataAsCentral{le_address_manager_->GetInitiatorAddress()};
    } else if (
        controller_->SupportsBleExtendedAdvertising() ||
        controller_->IsSupported(hci::OpCode::LE_MULTI_ADVT)) {
@@ -624,7 +624,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
      // the exception is if we only support legacy advertising - here, our current address is also
      // our advertised address
      return DataAsPeripheral{
          le_address_manager_->GetCurrentAddress(),
          le_address_manager_->GetInitiatorAddress(),
          {},
          true /* For now, ignore non-discoverable legacy advertising TODO(b/254314964) */};
    }
@@ -889,7 +889,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 = os::GetSystemPropertyUint32(kPropertyMinConnInterval, kConnIntervalMin);
    uint16_t conn_interval_max = os::GetSystemPropertyUint32(kPropertyMaxConnInterval, kConnIntervalMax);
    uint16_t conn_latency = os::GetSystemPropertyUint32(kPropertyConnLatency, kConnLatency);
+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