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
diff --git a/system/blueberry/facade/hci/le_initiator_address_facade.proto b/system/blueberry/facade/hci/le_initiator_address_facade.proto
index 354e464..8a0361c 100644
--- a/system/blueberry/facade/hci/le_initiator_address_facade.proto
+++ b/system/blueberry/facade/hci/le_initiator_address_facade.proto
@@ -8,7 +8,7 @@
 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 {
diff --git a/system/gd/hci/acl_manager/le_impl.h b/system/gd/hci/acl_manager/le_impl.h
index baa38c2..6377037 100644
--- a/system/gd/hci/acl_manager/le_impl.h
+++ b/system/gd/hci/acl_manager/le_impl.h
@@ -293,7 +293,7 @@
     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 @@
 
     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 @@
     }
     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;
diff --git a/system/gd/hci/facade/le_initiator_address_facade.cc b/system/gd/hci/facade/le_initiator_address_facade.cc
index 1ce1f19..725ee62 100644
--- a/system/gd/hci/facade/le_initiator_address_facade.cc
+++ b/system/gd/hci/facade/le_initiator_address_facade.cc
@@ -79,7 +79,7 @@
       ::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 @@
     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()));
diff --git a/system/gd/hci/le_address_manager.cc b/system/gd/hci/le_address_manager.cc
index c9f51a6..5550bdf 100644
--- a/system/gd/hci/le_address_manager.cc
+++ b/system/gd/hci/le_address_manager.cc
@@ -214,12 +214,12 @@
   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);
diff --git a/system/gd/hci/le_address_manager.h b/system/gd/hci/le_address_manager.h
index f5d6aec..776fe99 100644
--- a/system/gd/hci/le_address_manager.h
+++ b/system/gd/hci/le_address_manager.h
@@ -80,9 +80,9 @@
   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();
diff --git a/system/gd/hci/le_advertising_manager.cc b/system/gd/hci/le_advertising_manager.cc
index a45d486..b030468 100644
--- a/system/gd/hci/le_advertising_manager.cc
+++ b/system/gd/hci/le_advertising_manager.cc
@@ -313,10 +313,10 @@
           AdvertiserAddressType::NONRESOLVABLE_RANDOM) {
         return le_address_manager_->NewNonResolvableAddress();
       } else {
-        return le_address_manager_->GetAnotherAddress();
+        return le_address_manager_->NewResolvableAddress();
       }
     } else {
-      return le_address_manager_->GetCurrentAddress();
+      return le_address_manager_->GetInitiatorAddress();
     }
   }
 
@@ -461,7 +461,7 @@
               common::BindOnce(&impl::set_advertising_set_random_address_on_timer, common::Unretained(this), id),
               le_address_manager_->GetNextPrivateAddressIntervalMs());
         } else {
-          advertising_sets_[id].current_address = le_address_manager_->GetCurrentAddress();
+          advertising_sets_[id].current_address = le_address_manager_->GetInitiatorAddress();
           le_advertising_interface_->EnqueueCommand(
               hci::LeSetAdvertisingSetRandomAddressBuilder::Create(
                   id, advertising_sets_[id].current_address.GetAddress()),