wifi: Duplicate getValidChannelsForBand in AP iface

This functionality is needed even for AP iface. So, duplicate this
method.

Changes in the CL:
1. Add getValidChannelsForBand() in IWifiApIface.
2. Rename StaBackgroundScanBan to WifiBand to make it a more generic
name.
3. Change the existing method name in IWifiStaIface to match with the
one in IWifiApIface.

While there,
Fix indentation in hidl_callback_util.h

Bug: 35663149
Test: Compiles
Change-Id: Iaeb6c323e13eedf2f98de92fea77e327c76ffa5b
diff --git a/wifi/1.0/default/hidl_callback_util.h b/wifi/1.0/default/hidl_callback_util.h
index a1c6819..7136279 100644
--- a/wifi/1.0/default/hidl_callback_util.h
+++ b/wifi/1.0/default/hidl_callback_util.h
@@ -82,14 +82,12 @@
     return true;
   }
 
-  const std::set<android::sp<CallbackType>> getCallbacks() {
-    return cb_set_;
-  }
+  const std::set<android::sp<CallbackType>> getCallbacks() { return cb_set_; }
 
   // Death notification for callbacks.
   void onObjectDeath(uint64_t cookie) {
-    CallbackType *cb = reinterpret_cast<CallbackType*>(cookie);
-    const auto& iter =  cb_set_.find(cb);
+    CallbackType* cb = reinterpret_cast<CallbackType*>(cookie);
+    const auto& iter = cb_set_.find(cb);
     if (iter == cb_set_.end()) {
       LOG(ERROR) << "Unknown callback death notification received";
       return;
diff --git a/wifi/1.0/default/hidl_struct_util.cpp b/wifi/1.0/default/hidl_struct_util.cpp
index 7dbc8eb..c7b8c41 100644
--- a/wifi/1.0/default/hidl_struct_util.cpp
+++ b/wifi/1.0/default/hidl_struct_util.cpp
@@ -306,21 +306,21 @@
   return true;
 }
 
-legacy_hal::wifi_band convertHidlGscanBandToLegacy(StaBackgroundScanBand band) {
+legacy_hal::wifi_band convertHidlWifiBandToLegacy(WifiBand band) {
   switch (band) {
-    case StaBackgroundScanBand::BAND_UNSPECIFIED:
+    case WifiBand::BAND_UNSPECIFIED:
       return legacy_hal::WIFI_BAND_UNSPECIFIED;
-    case StaBackgroundScanBand::BAND_24GHZ:
+    case WifiBand::BAND_24GHZ:
       return legacy_hal::WIFI_BAND_BG;
-    case StaBackgroundScanBand::BAND_5GHZ:
+    case WifiBand::BAND_5GHZ:
       return legacy_hal::WIFI_BAND_A;
-    case StaBackgroundScanBand::BAND_5GHZ_DFS:
+    case WifiBand::BAND_5GHZ_DFS:
       return legacy_hal::WIFI_BAND_A_DFS;
-    case StaBackgroundScanBand::BAND_5GHZ_WITH_DFS:
+    case WifiBand::BAND_5GHZ_WITH_DFS:
       return legacy_hal::WIFI_BAND_A_WITH_DFS;
-    case StaBackgroundScanBand::BAND_24GHZ_5GHZ:
+    case WifiBand::BAND_24GHZ_5GHZ:
       return legacy_hal::WIFI_BAND_ABG;
-    case StaBackgroundScanBand::BAND_24GHZ_5GHZ_WITH_DFS:
+    case WifiBand::BAND_24GHZ_5GHZ_WITH_DFS:
       return legacy_hal::WIFI_BAND_ABG_WITH_DFS;
   };
   CHECK(false);
diff --git a/wifi/1.0/default/hidl_struct_util.h b/wifi/1.0/default/hidl_struct_util.h
index 490dcae..41e97b3 100644
--- a/wifi/1.0/default/hidl_struct_util.h
+++ b/wifi/1.0/default/hidl_struct_util.h
@@ -60,7 +60,7 @@
 bool convertLegacyGscanCapabilitiesToHidl(
     const legacy_hal::wifi_gscan_capabilities& legacy_caps,
     StaBackgroundScanCapabilities* hidl_caps);
-legacy_hal::wifi_band convertHidlGscanBandToLegacy(StaBackgroundScanBand band);
+legacy_hal::wifi_band convertHidlWifiBandToLegacy(WifiBand band);
 bool convertHidlGscanParamsToLegacy(
     const StaBackgroundScanParameters& hidl_scan_params,
     legacy_hal::wifi_scan_cmd_params* legacy_scan_params);
diff --git a/wifi/1.0/default/wifi_ap_iface.cpp b/wifi/1.0/default/wifi_ap_iface.cpp
index 1a8b31d..e2beec2 100644
--- a/wifi/1.0/default/wifi_ap_iface.cpp
+++ b/wifi/1.0/default/wifi_ap_iface.cpp
@@ -17,6 +17,7 @@
 #include <android-base/logging.h>
 
 #include "hidl_return_util.h"
+#include "hidl_struct_util.h"
 #include "wifi_ap_iface.h"
 #include "wifi_status_util.h"
 
@@ -64,6 +65,15 @@
                          code);
 }
 
+Return<void> WifiApIface::getValidFrequenciesForBand(
+    WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) {
+  return validateAndCall(this,
+                         WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+                         &WifiApIface::getValidFrequenciesForBandInternal,
+                         hidl_status_cb,
+                         band);
+}
+
 std::pair<WifiStatus, std::string> WifiApIface::getNameInternal() {
   return {createWifiStatus(WifiStatusCode::SUCCESS), ifname_};
 }
@@ -79,6 +89,16 @@
   return createWifiStatusFromLegacyError(legacy_status);
 }
 
+std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
+WifiApIface::getValidFrequenciesForBandInternal(WifiBand band) {
+  static_assert(sizeof(WifiChannelInMhz) == sizeof(uint32_t), "Size mismatch");
+  legacy_hal::wifi_error legacy_status;
+  std::vector<uint32_t> valid_frequencies;
+  std::tie(legacy_status, valid_frequencies) =
+      legacy_hal_.lock()->getValidFrequenciesForBand(
+          hidl_struct_util::convertHidlWifiBandToLegacy(band));
+  return {createWifiStatusFromLegacyError(legacy_status), valid_frequencies};
+}
 }  // namespace implementation
 }  // namespace V1_0
 }  // namespace wifi
diff --git a/wifi/1.0/default/wifi_ap_iface.h b/wifi/1.0/default/wifi_ap_iface.h
index 23d6435..efc168a 100644
--- a/wifi/1.0/default/wifi_ap_iface.h
+++ b/wifi/1.0/default/wifi_ap_iface.h
@@ -44,12 +44,16 @@
   Return<void> getType(getType_cb hidl_status_cb) override;
   Return<void> setCountryCode(const hidl_array<int8_t, 2>& code,
                               setCountryCode_cb hidl_status_cb) override;
+  Return<void> getValidFrequenciesForBand(
+      WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override;
 
  private:
   // Corresponding worker functions for the HIDL methods.
   std::pair<WifiStatus, std::string> getNameInternal();
   std::pair<WifiStatus, IfaceType> getTypeInternal();
   WifiStatus setCountryCodeInternal(const std::array<int8_t, 2>& code);
+  std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
+  getValidFrequenciesForBandInternal(WifiBand band);
 
   std::string ifname_;
   std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal_;
diff --git a/wifi/1.0/default/wifi_legacy_hal.cpp b/wifi/1.0/default/wifi_legacy_hal.cpp
index 7d58254..7390b65 100644
--- a/wifi/1.0/default/wifi_legacy_hal.cpp
+++ b/wifi/1.0/default/wifi_legacy_hal.cpp
@@ -562,7 +562,7 @@
 }
 
 std::pair<wifi_error, std::vector<uint32_t>>
-WifiLegacyHal::getValidFrequenciesForGscan(wifi_band band) {
+WifiLegacyHal::getValidFrequenciesForBand(wifi_band band) {
   static_assert(sizeof(uint32_t) >= sizeof(wifi_channel),
                 "Wifi Channel cannot be represented in output");
   std::vector<uint32_t> freqs;
diff --git a/wifi/1.0/default/wifi_legacy_hal.h b/wifi/1.0/default/wifi_legacy_hal.h
index ed020b0..c8fd5bd 100644
--- a/wifi/1.0/default/wifi_legacy_hal.h
+++ b/wifi/1.0/default/wifi_legacy_hal.h
@@ -175,7 +175,7 @@
       const on_gscan_results_callback& on_results_callback,
       const on_gscan_full_result_callback& on_full_result_callback);
   wifi_error stopGscan(wifi_request_id id);
-  std::pair<wifi_error, std::vector<uint32_t>> getValidFrequenciesForGscan(
+  std::pair<wifi_error, std::vector<uint32_t>> getValidFrequenciesForBand(
       wifi_band band);
   // Link layer stats functions.
   wifi_error enableLinkLayerStats(bool debug);
diff --git a/wifi/1.0/default/wifi_sta_iface.cpp b/wifi/1.0/default/wifi_sta_iface.cpp
index 55c9cf7..0c84102 100644
--- a/wifi/1.0/default/wifi_sta_iface.cpp
+++ b/wifi/1.0/default/wifi_sta_iface.cpp
@@ -106,15 +106,13 @@
                          hidl_status_cb);
 }
 
-Return<void> WifiStaIface::getValidFrequenciesForBackgroundScan(
-    StaBackgroundScanBand band,
-    getValidFrequenciesForBackgroundScan_cb hidl_status_cb) {
-  return validateAndCall(
-      this,
-      WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
-      &WifiStaIface::getValidFrequenciesForBackgroundScanInternal,
-      hidl_status_cb,
-      band);
+Return<void> WifiStaIface::getValidFrequenciesForBand(
+    WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) {
+  return validateAndCall(this,
+                         WifiStatusCode::ERROR_WIFI_IFACE_INVALID,
+                         &WifiStaIface::getValidFrequenciesForBandInternal,
+                         hidl_status_cb,
+                         band);
 }
 
 Return<void> WifiStaIface::startBackgroundScan(
@@ -363,14 +361,13 @@
 }
 
 std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
-WifiStaIface::getValidFrequenciesForBackgroundScanInternal(
-    StaBackgroundScanBand band) {
+WifiStaIface::getValidFrequenciesForBandInternal(WifiBand band) {
   static_assert(sizeof(WifiChannelInMhz) == sizeof(uint32_t), "Size mismatch");
   legacy_hal::wifi_error legacy_status;
   std::vector<uint32_t> valid_frequencies;
   std::tie(legacy_status, valid_frequencies) =
-      legacy_hal_.lock()->getValidFrequenciesForGscan(
-          hidl_struct_util::convertHidlGscanBandToLegacy(band));
+      legacy_hal_.lock()->getValidFrequenciesForBand(
+          hidl_struct_util::convertHidlWifiBandToLegacy(band));
   return {createWifiStatusFromLegacyError(legacy_status), valid_frequencies};
 }
 
diff --git a/wifi/1.0/default/wifi_sta_iface.h b/wifi/1.0/default/wifi_sta_iface.h
index 5f0ffe9..08faa2f 100644
--- a/wifi/1.0/default/wifi_sta_iface.h
+++ b/wifi/1.0/default/wifi_sta_iface.h
@@ -57,9 +57,8 @@
       installApfPacketFilter_cb hidl_status_cb) override;
   Return<void> getBackgroundScanCapabilities(
       getBackgroundScanCapabilities_cb hidl_status_cb) override;
-  Return<void> getValidFrequenciesForBackgroundScan(
-      StaBackgroundScanBand band,
-      getValidFrequenciesForBackgroundScan_cb hidl_status_cb) override;
+  Return<void> getValidFrequenciesForBand(
+      WifiBand band, getValidFrequenciesForBand_cb hidl_status_cb) override;
   Return<void> startBackgroundScan(
       uint32_t cmd_id,
       const StaBackgroundScanParameters& params,
@@ -119,7 +118,7 @@
   std::pair<WifiStatus, StaBackgroundScanCapabilities>
   getBackgroundScanCapabilitiesInternal();
   std::pair<WifiStatus, std::vector<WifiChannelInMhz>>
-  getValidFrequenciesForBackgroundScanInternal(StaBackgroundScanBand band);
+  getValidFrequenciesForBandInternal(WifiBand band);
   WifiStatus startBackgroundScanInternal(
       uint32_t cmd_id, const StaBackgroundScanParameters& params);
   WifiStatus stopBackgroundScanInternal(uint32_t cmd_id);