Snap for 10453938 from 49a242811007889d591c9f7322d914d46e9ae669 to mainline-odp-release

Change-Id: I0cc4c480e29205f84f7df023bf5149eb2c577b17
diff --git a/Android.bp b/Android.bp
index 01fe22a..0dc42b0 100644
--- a/Android.bp
+++ b/Android.bp
@@ -120,6 +120,7 @@
     shared_libs: [
         "android.hardware.net.nlinterceptor-V1-ndk",
         "libbase",
+        "libbinder",
         "libutils",
         "libwifi-system-iface",
     ],
@@ -180,6 +181,7 @@
         local_include_dirs: ["aidl"],
         export_aidl_headers: true,
     },
+    export_shared_lib_headers: ["libbinder"],
     srcs: [
         "ipc_constants.cpp",
         ":libwificond_ipc_aidl",
diff --git a/OWNERS b/OWNERS
index 351212a..bed29cb 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,2 +1,3 @@
 etancohen@google.com
 arabawy@google.com
+kumachang@google.com
diff --git a/aidl/android/net/wifi/nl80211/IScanEvent.aidl b/aidl/android/net/wifi/nl80211/IScanEvent.aidl
index 3ee8195..0434f24 100644
--- a/aidl/android/net/wifi/nl80211/IScanEvent.aidl
+++ b/aidl/android/net/wifi/nl80211/IScanEvent.aidl
@@ -22,5 +22,8 @@
  */
 interface IScanEvent {
   oneway void OnScanResultReady();
+  // This callback is deprecated in Android 14.
+  // Newer wificond implementation should call OnScanRequestFailed().
   oneway void OnScanFailed();
+  oneway void OnScanRequestFailed(int errorCode);
 }
diff --git a/aidl/android/net/wifi/nl80211/IWifiScannerImpl.aidl b/aidl/android/net/wifi/nl80211/IWifiScannerImpl.aidl
index 02c714c..e619739 100644
--- a/aidl/android/net/wifi/nl80211/IWifiScannerImpl.aidl
+++ b/aidl/android/net/wifi/nl80211/IWifiScannerImpl.aidl
@@ -30,6 +30,20 @@
   const int SCAN_TYPE_LOW_SPAN = 0;
   const int SCAN_TYPE_LOW_POWER = 1;
   const int SCAN_TYPE_HIGH_ACCURACY = 2;
+
+  // Scan request status
+  // Request succeeded
+  const int SCAN_STATUS_SUCCESS = 0;
+  // All other standard error codes are mapped to this
+  const int SCAN_STATUS_FAILED_GENERIC = 1;
+  //Device or resource busy - Due to connection in progress, processing another scan request etc.
+  const int SCAN_STATUS_FAILED_BUSY = 2;
+  // Aborted - Due to another high priority operation like roaming, offload scan etc
+  const int SCAN_STATUS_FAILED_ABORT = 3;
+  // No such device - Due to wrong interface or interface doesn't exist
+  const int SCAN_STATUS_FAILED_NODEV = 4;
+  // Invalid argument - Due to wrong/unsupported argument passed in scan params
+  const int SCAN_STATUS_FAILED_INVALID_ARGS = 5;
   // Scan type used internally if the device does not support
   // the type specified in |SingleScanSettings.scan_type|.
   // Scan requests from framework with this type will be rejected.
@@ -46,8 +60,13 @@
   int getMaxSsidsPerScan();
 
   // Request a single scan using a SingleScanSettings parcelable object.
+  // This interface is deprecated from Android 14, newer wificond implementation should call
+  // scanRequest() which can return the scan request status.
   boolean scan(in SingleScanSettings scanSettings);
 
+  // Request a single scan using a SingleScanSettings parcelable object.
+  int scanRequest(in SingleScanSettings scanSettings);
+
   // Subscribe single scanning events.
   // Scanner assumes there is only one subscriber.
   // This call will replace any existing |handler|.
@@ -75,5 +94,5 @@
   // Abort ongoing scan.
   void abortScan();
 
-  // TODO(nywang) add more interfaces.
+  // add more interfaces.
 }
diff --git a/client_interface_impl.cpp b/client_interface_impl.cpp
index 26bcba3..cd50e22 100644
--- a/client_interface_impl.cpp
+++ b/client_interface_impl.cpp
@@ -242,6 +242,16 @@
   return interface_mac_addr_;
 }
 
+void ClientInterfaceImpl::UpdateBandInfo() {
+  LOG(INFO) << "UpdateBandInfo";
+  if (!netlink_utils_->GetWiphyInfo(wiphy_index_,
+                               &band_info_,
+                               &scan_capabilities_,
+                               &wiphy_features_)) {
+    LOG(ERROR) << "Failed to get wiphy info from kernel";
+  }
+}
+
 const BandInfo& ClientInterfaceImpl::GetBandInfo() const {
   return band_info_;
 }
diff --git a/client_interface_impl.h b/client_interface_impl.h
index c52c2b0..9711a8c 100644
--- a/client_interface_impl.h
+++ b/client_interface_impl.h
@@ -78,6 +78,7 @@
   bool SignalPoll(std::vector<int32_t>* out_signal_poll_results);
   const std::array<uint8_t, ETH_ALEN>& GetMacAddress();
   const std::string& GetInterfaceName() const { return interface_name_; }
+  void UpdateBandInfo();
   const BandInfo& GetBandInfo() const;
   const android::sp<ScannerImpl> GetScanner() { return scanner_; };
   virtual bool IsAssociated() const;
diff --git a/looper_backed_event_loop.cpp b/looper_backed_event_loop.cpp
index f759948..e97d1d9 100644
--- a/looper_backed_event_loop.cpp
+++ b/looper_backed_event_loop.cpp
@@ -30,7 +30,7 @@
 
   ~EventLoopCallback() override = default;
 
-  virtual void handleMessage(const android::Message& message) {
+  void handleMessage(const android::Message& message) override {
     callback_();
   }
 
@@ -77,16 +77,13 @@
 }
 
 void LooperBackedEventLoop::PostTask(const std::function<void()>& callback) {
-  sp<android::MessageHandler> event_loop_callback =
-      new EventLoopCallback(callback);
-  looper_->sendMessage(event_loop_callback, Message());
+  looper_->sendMessage(sp<EventLoopCallback>::make(callback), Message());
 }
 
 void LooperBackedEventLoop::PostDelayedTask(
     const std::function<void()>& callback,
     int64_t delay_ms) {
-  sp<android::MessageHandler> looper_callback = new EventLoopCallback(callback);
-  looper_->sendMessageDelayed(ms2ns(delay_ms), looper_callback, Message());
+  looper_->sendMessageDelayed(ms2ns(delay_ms), sp<EventLoopCallback>::make(callback), Message());
 }
 
 bool LooperBackedEventLoop::WatchFileDescriptor(
diff --git a/net/netlink_manager.cpp b/net/netlink_manager.cpp
index 64db5d8..95d8a46 100644
--- a/net/netlink_manager.cpp
+++ b/net/netlink_manager.cpp
@@ -48,7 +48,7 @@
 // netlink.h suggests NLMSG_GOODSIZE to be at most 8192 bytes.
 constexpr int kReceiveBufferSize = 8 * 1024;
 constexpr uint32_t kBroadcastSequenceNumber = 0;
-constexpr int kMaximumNetlinkMessageWaitMilliSeconds = 1000;
+constexpr int kMaximumNetlinkMessageWaitMilliSeconds = 4000;
 uint8_t ReceiveBuffer[kReceiveBufferSize];
 
 void AppendPacket(vector<unique_ptr<const NL80211Packet>>* vec,
@@ -99,7 +99,8 @@
 void NetlinkManager::ReceivePacketAndRunHandler(int fd) {
   ssize_t len = read(fd, ReceiveBuffer, kReceiveBufferSize);
   if (len == -1) {
-    LOG(ERROR) << "Failed to read packet from buffer on fd: " << fd;
+    LOG(ERROR) << "Failed to read packet from buffer on fd: " << fd
+               << ", error is " << strerror(errno);
     perror(" netlink error ");
     return;
   }
@@ -136,7 +137,8 @@
     auto itr = message_handlers_.find(sequence_number);
     // There is no handler for this sequence number.
     if (itr == message_handlers_.end()) {
-      LOG(WARNING) << "No handler for message: " << sequence_number;
+      LOG(WARNING) << "No handler for message: " << sequence_number
+                   << ", packet len = " << len;
       return;
     }
     // A multipart message is terminated by NLMSG_DONE.
@@ -308,11 +310,13 @@
                            time_remaining);
 
     if (poll_return == 0) {
-      LOG(ERROR) << "Failed to poll netlink fd:" << sync_netlink_fd_.get() << "time out ";
+      LOG(ERROR) << "Failed to poll netlink fd:" << sync_netlink_fd_.get()
+                 << "time out, sequence is " << sequence ;
       message_handlers_.erase(sequence);
       return false;
     } else if (poll_return == -1) {
-      PLOG(ERROR) << "Failed to poll netlink fd";
+      LOG(ERROR) << "Failed to poll netlink fd:" << sync_netlink_fd_.get()
+                 << ", sequence is " << sequence;
       message_handlers_.erase(sequence);
       return false;
     }
@@ -321,7 +325,7 @@
     time_remaining -= static_cast<int>(ns2ms(interval));
   }
   if (time_remaining <= 0) {
-    LOG(ERROR) << "Timeout waiting for netlink reply messages";
+    LOG(ERROR) << "Timeout waiting for netlink reply messages, sequence is " << sequence;
     message_handlers_.erase(sequence);
     return false;
   }
diff --git a/net/netlink_utils.cpp b/net/netlink_utils.cpp
index dc2e4be..fc705d6 100644
--- a/net/netlink_utils.cpp
+++ b/net/netlink_utils.cpp
@@ -73,6 +73,7 @@
 
 constexpr uint8_t kEhtCapPhyNumByte = 8;
 constexpr uint8_t kEht320MhzBitMask = 0x2;
+constexpr int kNl80211CmdRetryCount = 1;
 
 bool IsExtFeatureFlagSet(
     const std::vector<uint8_t>& ext_feature_flags_bytes,
@@ -135,7 +136,7 @@
       netlink_manager_->GetSequenceNumber(),
       getpid());
   get_wiphy.AddFlag(NLM_F_DUMP);
-  int ifindex;
+  int ifindex = 0;
   if (!iface_name.empty()) {
     ifindex = if_nametoindex(iface_name.c_str());
     if (ifindex == 0) {
@@ -145,11 +146,20 @@
     get_wiphy.AddAttribute(NL80211Attr<uint32_t>(NL80211_ATTR_IFINDEX, ifindex));
   }
   vector<unique_ptr<const NL80211Packet>> response;
-  if (!netlink_manager_->SendMessageAndGetResponses(get_wiphy, &response))  {
-    LOG(ERROR) << "NL80211_CMD_GET_WIPHY dump failed, ifindex: "
-               << ifindex << " and name: " << iface_name.c_str();
-    return false;
+  for (int i = kNl80211CmdRetryCount; i >= 0; i--) {
+      if (netlink_manager_->SendMessageAndGetResponses(get_wiphy, &response))  {
+          break;
+      } else {
+        if (i == 0) {
+            LOG(ERROR) << "NL80211_CMD_GET_WIPHY dump failed, ifindex: "
+                       << ifindex << " and name: " << iface_name.c_str();
+            return false;
+        } else {
+            LOG(INFO) << "Failed to get wiphy index, retry again";
+        }
+      }
   }
+
   if (response.empty()) {
     LOG(INFO) << "No wiphy is found";
     return false;
@@ -320,9 +330,17 @@
     get_wiphy.AddFlag(NLM_F_DUMP);
   }
   vector<unique_ptr<const NL80211Packet>> response;
-  if (!netlink_manager_->SendMessageAndGetResponses(get_wiphy, &response))  {
-    LOG(ERROR) << "NL80211_CMD_GET_WIPHY dump failed";
-    return false;
+  for (int i = kNl80211CmdRetryCount; i >= 0; i--) {
+      if (netlink_manager_->SendMessageAndGetResponses(get_wiphy, &response))  {
+          break;
+      } else {
+        if (i == 0) {
+            LOG(ERROR) << "NL80211_CMD_GET_WIPHY dump failed";
+            return false;
+        } else {
+            LOG(INFO) << "Failed to get wiphy info, retry again";
+        }
+      }
   }
 
   vector<NL80211Packet> packet_per_wiphy;
@@ -332,7 +350,7 @@
     }
   } else {
     for (auto& packet : response) {
-      packet_per_wiphy.push_back(move(*(packet.release())));
+      packet_per_wiphy.push_back(std::move(*(packet.release())));
     }
   }
 
@@ -808,7 +826,7 @@
               attr_by_wiphy_and_id[wiphy_index].find(attr_id);
           if (attr_id_and_attr == attr_by_wiphy_and_id[wiphy_index].end()) {
             attr_by_wiphy_and_id[wiphy_index].
-                insert(make_pair(attr_id, move(attr)));
+                insert(make_pair(attr_id, std::move(attr)));
           } else {
             attr_id_and_attr->second.Merge(attr);
           }
@@ -824,7 +842,7 @@
     for (const auto& attr : wiphy_and_attributes.second) {
       new_wiphy.AddAttribute(attr.second);
     }
-    packet_per_wiphy->emplace_back(move(new_wiphy));
+    packet_per_wiphy->emplace_back(std::move(new_wiphy));
   }
   return true;
 }
diff --git a/scanning/pno_settings.cpp b/scanning/pno_settings.cpp
index 6307ea7..222c4ea 100644
--- a/scanning/pno_settings.cpp
+++ b/scanning/pno_settings.cpp
@@ -27,14 +27,13 @@
 namespace wifi {
 namespace nl80211 {
 
-const uint32_t PnoSettings::kFastScanIterations = 3;
-const uint32_t PnoSettings::kSlowScanIntervalMultiplier = 3;
-
 status_t PnoSettings::writeToParcel(::android::Parcel* parcel) const {
   RETURN_IF_FAILED(parcel->writeInt64(interval_ms_));
   RETURN_IF_FAILED(parcel->writeInt32(min_2g_rssi_));
   RETURN_IF_FAILED(parcel->writeInt32(min_5g_rssi_));
   RETURN_IF_FAILED(parcel->writeInt32(min_6g_rssi_));
+  RETURN_IF_FAILED(parcel->writeUint32(scan_iterations_));
+  RETURN_IF_FAILED(parcel->writeUint32(scan_interval_multiplier_));
   RETURN_IF_FAILED(parcel->writeInt32(pno_networks_.size()));
   for (const auto& network : pno_networks_) {
     // For Java readTypedList():
@@ -50,6 +49,8 @@
   RETURN_IF_FAILED(parcel->readInt32(&min_2g_rssi_));
   RETURN_IF_FAILED(parcel->readInt32(&min_5g_rssi_));
   RETURN_IF_FAILED(parcel->readInt32(&min_6g_rssi_));
+  RETURN_IF_FAILED(parcel->readUint32(&scan_iterations_));
+  RETURN_IF_FAILED(parcel->readUint32(&scan_interval_multiplier_));
   int32_t num_pno_networks = 0;
   RETURN_IF_FAILED(parcel->readInt32(&num_pno_networks));
   for (int i = 0; i < num_pno_networks; i++) {
diff --git a/scanning/pno_settings.h b/scanning/pno_settings.h
index f0e0826..7ee7402 100644
--- a/scanning/pno_settings.h
+++ b/scanning/pno_settings.h
@@ -31,14 +31,14 @@
 
 class PnoSettings : public ::android::Parcelable {
  public:
-  static const uint32_t kFastScanIterations;
-  static const uint32_t kSlowScanIntervalMultiplier;
 
   PnoSettings()
       : interval_ms_(0),
         min_2g_rssi_(0),
         min_5g_rssi_(0),
-        min_6g_rssi_(0) {}
+        min_6g_rssi_(0),
+        scan_iterations_(0),
+        scan_interval_multiplier_(0) {}
   bool operator==(const PnoSettings& rhs) const {
     return (pno_networks_ == rhs.pno_networks_ &&
             min_2g_rssi_ == rhs.min_2g_rssi_ &&
@@ -52,6 +52,8 @@
   int32_t min_2g_rssi_;
   int32_t min_5g_rssi_;
   int32_t min_6g_rssi_;
+  uint32_t scan_iterations_;
+  uint32_t scan_interval_multiplier_;
   std::vector<PnoNetwork> pno_networks_;
 };
 
diff --git a/scanning/scan_utils.cpp b/scanning/scan_utils.cpp
index 6c2cb22..8c79b20 100644
--- a/scanning/scan_utils.cpp
+++ b/scanning/scan_utils.cpp
@@ -281,6 +281,7 @@
                      bool enable_6ghz_rnr,
                      const vector<vector<uint8_t>>& ssids,
                      const vector<uint32_t>& freqs,
+                     const vector<uint8_t>& vendor_ies,
                      int* error_code) {
   NL80211Packet trigger_scan(
       netlink_manager_->GetFamilyId(),
@@ -341,6 +342,12 @@
                               scan_flags));
     LOG(DEBUG) << "Triggering scan with scan_flag=" << scan_flags;
   }
+
+  if (!vendor_ies.empty()) {
+    NL80211Attr<vector<uint8_t>> vendor_ie_attr(NL80211_ATTR_IE, vendor_ies);
+    trigger_scan.AddAttribute(vendor_ie_attr);
+  }
+
   // We are receiving an ERROR/ACK message instead of the actual
   // scan results here, so it is OK to expect a timely response because
   // kernel is supposed to send the ERROR/ACK back before the scan starts.
diff --git a/scanning/scan_utils.h b/scanning/scan_utils.h
index 3ac7f4a..2d4cfe3 100644
--- a/scanning/scan_utils.h
+++ b/scanning/scan_utils.h
@@ -94,6 +94,7 @@
   // If |ssids| contains an empty string, it will a scan for all ssids.
   // - |freqs| is a vector of frequencies we request to scan.
   // If |freqs| is an empty vector, it will scan all supported frequencies.
+  // - |vendor_ies| is a vector of vendor ies we add it in probe req.
   // - |error_code| contains the errno kernel replied when this returns false.
   // Returns true on success.
   virtual bool Scan(uint32_t interface_index,
@@ -102,6 +103,7 @@
                     bool enable_6ghz_rnr,
                     const std::vector<std::vector<uint8_t>>& ssids,
                     const std::vector<uint32_t>& freqs,
+                    const std::vector<uint8_t>& vendor_ies,
                     int* error_code);
 
   // Send scan request to kernel for interface with index |interface_index|.
diff --git a/scanning/scanner_impl.cpp b/scanning/scanner_impl.cpp
index c7857df..e89fff4 100644
--- a/scanning/scanner_impl.cpp
+++ b/scanning/scanner_impl.cpp
@@ -57,6 +57,20 @@
   return {};
 }
 
+int convertStdErrNumToScanStatus(int errNum) {
+    switch(errNum) {
+    case EINVAL:
+      return IWifiScannerImpl::SCAN_STATUS_FAILED_INVALID_ARGS;
+    case EBUSY:
+      return IWifiScannerImpl::SCAN_STATUS_FAILED_BUSY;
+    case ENODEV:
+      return IWifiScannerImpl::SCAN_STATUS_FAILED_NODEV;
+    default:
+      return IWifiScannerImpl::SCAN_STATUS_FAILED_GENERIC;
+  }
+  return {};
+}
+
 constexpr const int kPercentNetworksWithFreq = 30;
 constexpr const int32_t kPnoScanDefaultFreqs2G[] = {2412, 2417, 2422, 2427, 2432, 2437, 2447, 2452,
     2457, 2462};
@@ -143,10 +157,10 @@
   return Status::ok();
 }
 
-Status ScannerImpl::scan(const SingleScanSettings& scan_settings,
-                         bool* out_success) {
+Status ScannerImpl::scanRequest(const SingleScanSettings& scan_settings,
+                         int* status) {
   if (!CheckIsValid()) {
-    *out_success = false;
+    *status = IWifiScannerImpl::SCAN_STATUS_FAILED_GENERIC;
     return Status::ok();
   }
 
@@ -190,19 +204,33 @@
 
   int error_code = 0;
   if (!scan_utils_->Scan(interface_index_, request_random_mac, scan_type,
-                         scan_settings.enable_6ghz_rnr_, ssids, freqs, &error_code)) {
+                         scan_settings.enable_6ghz_rnr_, ssids, freqs,
+                         scan_settings.vendor_ies_, &error_code)) {
     if (error_code == ENODEV) {
         nodev_counter_ ++;
         LOG(WARNING) << "Scan failed with error=nodev. counter=" << nodev_counter_;
     }
     CHECK(error_code != ENODEV || nodev_counter_ <= 3)
         << "Driver is in a bad state, restarting wificond";
-    *out_success = false;
+    *status = convertStdErrNumToScanStatus(error_code);
     return Status::ok();
   }
   nodev_counter_ = 0;
   scan_started_ = true;
-  *out_success = true;
+  *status = IWifiScannerImpl::SCAN_STATUS_SUCCESS;
+  return Status::ok();
+
+}
+Status ScannerImpl::scan(const SingleScanSettings& scan_settings,
+                         bool* out_success) {
+
+  int status = 0;
+  scanRequest(scan_settings, &status);
+  if (status == IWifiScannerImpl::SCAN_STATUS_SUCCESS) {
+    *out_success = true;
+  } else {
+    *out_success = false;
+  }
   return Status::ok();
 }
 
@@ -437,7 +465,7 @@
     // TODO: Pass other parameters back once we find framework needs them.
     if (aborted) {
       LOG(WARNING) << "Scan aborted";
-      scan_event_handler_->OnScanFailed();
+      scan_event_handler_->OnScanRequestFailed(IWifiScannerImpl::SCAN_STATUS_FAILED_ABORT);
     } else {
       scan_event_handler_->OnScanResultReady();
     }
@@ -471,18 +499,18 @@
   bool support_num_scan_plans = scan_capabilities_.max_num_scan_plans >= 2;
   bool support_scan_plan_interval =
       scan_capabilities_.max_scan_plan_interval * 1000 >=
-          pno_settings.interval_ms_ * PnoSettings::kSlowScanIntervalMultiplier;
+          pno_settings.interval_ms_ * pno_settings.scan_interval_multiplier_;
   bool support_scan_plan_iterations =
       scan_capabilities_.max_scan_plan_iterations >=
-                  PnoSettings::kFastScanIterations;
+                  pno_settings.scan_iterations_;
 
   uint32_t fast_scan_interval =
       static_cast<uint32_t>(pno_settings.interval_ms_);
   if (support_num_scan_plans && support_scan_plan_interval &&
       support_scan_plan_iterations) {
     return SchedScanIntervalSetting{
-        {{fast_scan_interval, PnoSettings::kFastScanIterations}},
-        fast_scan_interval * PnoSettings::kSlowScanIntervalMultiplier};
+        {{fast_scan_interval, pno_settings.scan_iterations_}},
+        fast_scan_interval * pno_settings.scan_interval_multiplier_};
   } else {
     // Device doesn't support the provided scan plans.
     // Specify single interval instead.
diff --git a/scanning/scanner_impl.h b/scanning/scanner_impl.h
index 449f454..2e34c01 100644
--- a/scanning/scanner_impl.h
+++ b/scanning/scanner_impl.h
@@ -55,6 +55,10 @@
       const android::net::wifi::nl80211::SingleScanSettings&
           scan_settings,
       bool* out_success) override;
+  ::android::binder::Status scanRequest(
+      const android::net::wifi::nl80211::SingleScanSettings&
+          scan_settings,
+      int* status) override;
   ::android::binder::Status startPnoScan(
       const android::net::wifi::nl80211::PnoSettings& pno_settings,
       bool* out_success) override;
diff --git a/scanning/single_scan_settings.cpp b/scanning/single_scan_settings.cpp
index 47809fb..28dad53 100644
--- a/scanning/single_scan_settings.cpp
+++ b/scanning/single_scan_settings.cpp
@@ -55,6 +55,7 @@
     RETURN_IF_FAILED(parcel->writeInt32(1));
     RETURN_IF_FAILED(network.writeToParcel(parcel));
   }
+  RETURN_IF_FAILED(parcel->writeByteVector(vendor_ies_));
   return ::android::OK;
 }
 
@@ -107,6 +108,7 @@
     RETURN_IF_FAILED(network.readFromParcel(parcel));
     hidden_networks_.push_back(network);
   }
+  RETURN_IF_FAILED(parcel->readByteVector(&vendor_ies_));
   return ::android::OK;
 }
 
diff --git a/scanning/single_scan_settings.h b/scanning/single_scan_settings.h
index a7d99dd..27bf774 100644
--- a/scanning/single_scan_settings.h
+++ b/scanning/single_scan_settings.h
@@ -36,7 +36,8 @@
   bool operator==(const SingleScanSettings& rhs) const {
     return (scan_type_ == rhs.scan_type_ &&
             channel_settings_ == rhs.channel_settings_ &&
-            hidden_networks_ == rhs.hidden_networks_);
+            hidden_networks_ == rhs.hidden_networks_ &&
+            vendor_ies_ == rhs.vendor_ies_);
   }
   ::android::status_t writeToParcel(::android::Parcel* parcel) const override;
   ::android::status_t readFromParcel(const ::android::Parcel* parcel) override;
@@ -45,6 +46,7 @@
   bool enable_6ghz_rnr_;
   std::vector<ChannelSettings> channel_settings_;
   std::vector<HiddenNetwork> hidden_networks_;
+  std::vector<uint8_t> vendor_ies_;
 
  private:
   bool isValidScanType() const;
diff --git a/server.cpp b/server.cpp
index 1fd10dd..9b6bc38 100644
--- a/server.cpp
+++ b/server.cpp
@@ -18,6 +18,7 @@
 
 #include <algorithm> // for std::find_if
 #include <sstream>
+#include <set>
 
 #include <android-base/file.h>
 #include <android-base/logging.h>
@@ -44,6 +45,7 @@
 using std::optional;
 using std::placeholders::_1;
 using std::placeholders::_2;
+using std::set;
 using std::string;
 using std::stringstream;
 using std::unique_ptr;
@@ -487,6 +489,30 @@
   return false;
 }
 
+void Server::handleCountryCodeChanged() {
+  uint32_t wiphy_index;
+  set<uint32_t> handled_wiphy_index;
+  for (auto& it : client_interfaces_) {
+    it.second->UpdateBandInfo();
+    if (netlink_utils_->GetWiphyIndex(&wiphy_index, it.first)) {
+      if (handled_wiphy_index.find(wiphy_index) == handled_wiphy_index.end()) {
+        UpdateBandWiphyIndexMap(wiphy_index);
+        LogSupportedBands(wiphy_index);
+        handled_wiphy_index.insert(wiphy_index);
+      }
+    }
+  }
+  for (auto& it : ap_interfaces_) {
+    if (netlink_utils_->GetWiphyIndex(&wiphy_index, it.first)) {
+      if (handled_wiphy_index.find(wiphy_index) == handled_wiphy_index.end()) {
+        UpdateBandWiphyIndexMap(wiphy_index);
+        LogSupportedBands(wiphy_index);
+        handled_wiphy_index.insert(wiphy_index);
+      }
+    }
+  }
+}
+
 void Server::OnRegDomainChanged(uint32_t wiphy_index, std::string& country_code) {
   string current_country_code;
   if (country_code.empty()) {
@@ -506,26 +532,13 @@
   // interfaces. So update band - wiphy index mapping only if an
   // interface exists
   if (!hasNoIfaceForWiphyIndex(wiphy_index)) {
-    UpdateBandWiphyIndexMap(wiphy_index);
+    handleCountryCodeChanged();
   }
-  LogSupportedBands(wiphy_index);
 }
 
 android::binder::Status Server::notifyCountryCodeChanged() {
   LOG(INFO) << "Receive notifyCountryCodeChanged";
-  uint32_t wiphy_index;
-  for (auto& it : client_interfaces_) {
-    if (netlink_utils_->GetWiphyIndex(&wiphy_index, it.first)) {
-      UpdateBandWiphyIndexMap(wiphy_index);
-      LogSupportedBands(wiphy_index);
-    }
-  }
-  for (auto& it : ap_interfaces_) {
-    if (netlink_utils_->GetWiphyIndex(&wiphy_index, it.first)) {
-      UpdateBandWiphyIndexMap(wiphy_index);
-      LogSupportedBands(wiphy_index);
-    }
-  }
+  handleCountryCodeChanged();
   return Status::ok();
 }
 
diff --git a/server.h b/server.h
index b43ae0a..df0968c 100644
--- a/server.h
+++ b/server.h
@@ -121,6 +121,7 @@
       uint32_t *wiphy_index);
   void LogSupportedBands(uint32_t wiphy_index);
   void OnRegDomainChanged(uint32_t wiphy_index, std::string& country_code);
+  void handleCountryCodeChanged();
   void BroadcastClientInterfaceReady(
       android::sp<android::net::wifi::nl80211::IClientInterface> network_interface);
   void BroadcastApInterfaceReady(
diff --git a/tests/mock_scan_utils.h b/tests/mock_scan_utils.h
index 3f43bb2..1c6ccc3 100644
--- a/tests/mock_scan_utils.h
+++ b/tests/mock_scan_utils.h
@@ -41,13 +41,14 @@
       uint32_t interface_index,
       std::vector<android::net::wifi::nl80211::NativeScanResult>* out_scan_results));
 
-  MOCK_METHOD7(Scan, bool(
+  MOCK_METHOD8(Scan, bool(
       uint32_t interface_index,
       bool request_random_mac,
       int scan_type,
       bool enable_6ghz_rnr,
       const std::vector<std::vector<uint8_t>>& ssids,
       const std::vector<uint32_t>& freqs,
+      const std::vector<uint8_t>& vendor_ies,
       int* error_code));
 
   MOCK_METHOD10(StartScheduledScan, bool(
diff --git a/tests/scan_utils_unittest.cpp b/tests/scan_utils_unittest.cpp
index d2f3631..e2eb414 100644
--- a/tests/scan_utils_unittest.cpp
+++ b/tests/scan_utils_unittest.cpp
@@ -155,7 +155,7 @@
                   AppendMessageAndReturn, response, true, _1, _2)));
   int errno_ignored;
   EXPECT_TRUE(scan_utils_.Scan(kFakeInterfaceIndex, kFakeUseRandomMAC,
-                               kFakeScanType, false, {}, {}, &errno_ignored));
+                               kFakeScanType, false, {}, {}, {}, &errno_ignored));
   // TODO(b/34231420): Add validation of requested scan ssids, threshold,
   // and frequencies.
 }
@@ -175,7 +175,7 @@
   int errno_ignored;
   EXPECT_TRUE(scan_utils_.Scan(kFakeInterfaceIndex, true,
                                IWifiScannerImpl::SCAN_TYPE_DEFAULT,
-                               false, {}, {}, &errno_ignored));
+                               false, {}, {}, {}, &errno_ignored));
 }
 
 TEST_F(ScanUtilsTest, CanSendScanRequestForLowSpanScan) {
@@ -195,7 +195,7 @@
   int errno_ignored;
   EXPECT_TRUE(scan_utils_.Scan(kFakeInterfaceIndex, false,
                                IWifiScannerImpl::SCAN_TYPE_LOW_SPAN,
-                               true, {}, {}, &errno_ignored));
+                               true, {}, {}, {}, &errno_ignored));
 }
 
 TEST_F(ScanUtilsTest, CanSendScanRequestForLowPowerScan) {
@@ -213,7 +213,7 @@
   int errno_ignored;
   EXPECT_TRUE(scan_utils_.Scan(kFakeInterfaceIndex, false,
                                IWifiScannerImpl::SCAN_TYPE_LOW_POWER,
-                               false, {}, {}, &errno_ignored));
+                               false, {}, {}, {}, &errno_ignored));
 }
 
 TEST_F(ScanUtilsTest, CanSendScanRequestForHighAccuracyScan) {
@@ -231,7 +231,7 @@
   int errno_ignored;
   EXPECT_TRUE(scan_utils_.Scan(kFakeInterfaceIndex, false,
                                IWifiScannerImpl::SCAN_TYPE_HIGH_ACCURACY,
-                               false, {}, {}, &errno_ignored));
+                               false, {}, {}, {}, &errno_ignored));
 }
 
 TEST_F(ScanUtilsTest, CanSendScanRequestForHighAccuracyScanWithRandomAddr) {
@@ -251,7 +251,7 @@
   int errno_ignored;
   EXPECT_TRUE(scan_utils_.Scan(kFakeInterfaceIndex, true,
                                IWifiScannerImpl::SCAN_TYPE_HIGH_ACCURACY,
-                               false, {}, {}, &errno_ignored));
+                               false, {}, {}, {}, &errno_ignored));
 }
 
 TEST_F(ScanUtilsTest, CanHandleScanRequestFailure) {
@@ -264,7 +264,7 @@
                   AppendMessageAndReturn, response, true, _1, _2)));
   int error_code;
   EXPECT_FALSE(scan_utils_.Scan(kFakeInterfaceIndex, kFakeUseRandomMAC,
-                               kFakeScanType, false, {}, {}, &error_code));
+                               kFakeScanType, false, {}, {}, {}, &error_code));
   EXPECT_EQ(kFakeErrorCode, error_code);
 }
 
diff --git a/tests/scanner_unittest.cpp b/tests/scanner_unittest.cpp
index 869a21b..9ceff9f 100644
--- a/tests/scanner_unittest.cpp
+++ b/tests/scanner_unittest.cpp
@@ -51,6 +51,8 @@
 
 constexpr uint32_t kFakeInterfaceIndex = 12;
 constexpr uint32_t kFakeScanIntervalMs = 10000;
+constexpr uint32_t kFastScanIterations = 3;
+constexpr uint32_t kSlowScanIntervalMultiplier = 3;
 vector<uint32_t> kDefaultFrequencies = {2412, 2417, 2422, 2427, 2432, 2437, 2447, 2452, 2457,
                                         2462, 5180, 5200, 5220, 5240, 5745, 5765, 5785, 5805};
 
@@ -67,6 +69,7 @@
     bool enable_6ghz_rnr,
     const std::vector<std::vector<uint8_t>>& ssids_ignored,
     const std::vector<uint32_t>& freqs_ignored,
+    const std::vector<uint8_t>& vendor_ies,
     int* error_code) {
   *error_code = mock_error_code;
   // Returing false because this helper function is used for failure case.
@@ -121,7 +124,7 @@
 
 TEST_F(ScannerTest, TestSingleScan) {
   EXPECT_CALL(scan_utils_,
-              Scan(_, _, IWifiScannerImpl::SCAN_TYPE_DEFAULT, false, _, _, _)).
+              Scan(_, _, IWifiScannerImpl::SCAN_TYPE_DEFAULT, false, _, _, _, _)).
       WillOnce(Return(true));
   bool success = false;
   scanner_impl_.reset(new ScannerImpl(kFakeInterfaceIndex,
@@ -134,7 +137,7 @@
 
 TEST_F(ScannerTest, TestSingleScanForLowSpanScan) {
   EXPECT_CALL(scan_utils_,
-              Scan(_, _, IWifiScannerImpl::SCAN_TYPE_LOW_SPAN, true, _, _, _)).
+              Scan(_, _, IWifiScannerImpl::SCAN_TYPE_LOW_SPAN, true, _, _, _, _)).
       WillOnce(Return(true));
   wiphy_features_.supports_low_span_oneshot_scan = true;
   ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_,
@@ -150,7 +153,7 @@
 
 TEST_F(ScannerTest, TestSingleScanForLowPowerScan) {
   EXPECT_CALL(scan_utils_,
-              Scan(_, _, IWifiScannerImpl::SCAN_TYPE_LOW_POWER, _, _, _, _)).
+              Scan(_, _, IWifiScannerImpl::SCAN_TYPE_LOW_POWER, _, _, _, _, _)).
       WillOnce(Return(true));
   wiphy_features_.supports_low_power_oneshot_scan = true;
   ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_,
@@ -165,7 +168,7 @@
 
 TEST_F(ScannerTest, TestSingleScanForHighAccuracyScan) {
   EXPECT_CALL(scan_utils_,
-              Scan(_, _, IWifiScannerImpl::SCAN_TYPE_HIGH_ACCURACY, _, _, _, _)).
+              Scan(_, _, IWifiScannerImpl::SCAN_TYPE_HIGH_ACCURACY, _, _, _, _, _)).
       WillOnce(Return(true));
   wiphy_features_.supports_high_accuracy_oneshot_scan = true;
   ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_,
@@ -180,7 +183,7 @@
 
 TEST_F(ScannerTest, TestSingleScanForLowSpanScanWithNoWiphySupport) {
   EXPECT_CALL(scan_utils_,
-              Scan(_, _, IWifiScannerImpl::SCAN_TYPE_DEFAULT, _, _, _, _)).
+              Scan(_, _, IWifiScannerImpl::SCAN_TYPE_DEFAULT, _, _, _, _, _)).
       WillOnce(Return(true));
   ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_,
                            wiphy_features_, &client_interface_impl_,
@@ -194,7 +197,7 @@
 
 TEST_F(ScannerTest, TestSingleScanForLowPowerScanWithNoWiphySupport) {
   EXPECT_CALL(scan_utils_,
-              Scan(_, _, IWifiScannerImpl::SCAN_TYPE_DEFAULT, _, _, _, _)).
+              Scan(_, _, IWifiScannerImpl::SCAN_TYPE_DEFAULT, _, _, _, _, _)).
       WillOnce(Return(true));
   ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_,
                            wiphy_features_, &client_interface_impl_,
@@ -208,7 +211,7 @@
 
 TEST_F(ScannerTest, TestSingleScanForHighAccuracyScanWithNoWiphySupport) {
   EXPECT_CALL(scan_utils_,
-              Scan(_, _, IWifiScannerImpl::SCAN_TYPE_DEFAULT, _, _, _, _)).
+              Scan(_, _, IWifiScannerImpl::SCAN_TYPE_DEFAULT, _, _, _, _, _)).
       WillOnce(Return(true));
   ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_,
                            wiphy_features_, &client_interface_impl_,
@@ -227,10 +230,10 @@
                                       &scan_utils_));
   EXPECT_CALL(
       scan_utils_,
-      Scan(_, _, _, _, _, _, _)).
+      Scan(_, _, _, _, _, _, _, _)).
           WillOnce(Invoke(bind(
               ReturnErrorCodeForScanRequest, EBUSY,
-              _1, _2, _3, _4, _5, _6, _7)));
+              _1, _2, _3, _4, _5, _6, _7, _8)));
 
   bool success = false;
   EXPECT_TRUE(scanner_impl_->scan(SingleScanSettings(), &success).isOk());
@@ -244,10 +247,10 @@
                                       &scan_utils_));
   ON_CALL(
       scan_utils_,
-      Scan(_, _, _, _, _, _, _)).
+      Scan(_, _, _, _, _, _, _, _)).
           WillByDefault(Invoke(bind(
               ReturnErrorCodeForScanRequest, ENODEV,
-              _1, _2, _3, _4, _5, _6, _7)));
+              _1, _2, _3, _4, _5, _6, _7, _8)));
 
   bool single_scan_failure;
   EXPECT_TRUE(scanner_impl_->scan(SingleScanSettings(), &single_scan_failure).isOk());
@@ -266,7 +269,7 @@
                                       scan_capabilities_, wiphy_features_,
                                       &client_interface_impl_,
                                       &scan_utils_));
-  EXPECT_CALL(scan_utils_, Scan(_, _, _, _, _, _, _)).WillOnce(Return(true));
+  EXPECT_CALL(scan_utils_, Scan(_, _, _, _, _, _, _, _)).WillOnce(Return(true));
   EXPECT_TRUE(
       scanner_impl_->scan(SingleScanSettings(), &single_scan_success).isOk());
   EXPECT_TRUE(single_scan_success);
@@ -345,8 +348,8 @@
       0 /* max_match_sets */,
       // Parameters above are not related to this test.
       2 /* 1 plan for finite repeated scan and 1 plan for ininfite scan loop */,
-      kFakeScanIntervalMs * PnoSettings::kSlowScanIntervalMultiplier / 1000,
-      PnoSettings::kFastScanIterations);
+      kFakeScanIntervalMs * kSlowScanIntervalMultiplier / 1000,
+      kFastScanIterations);
   ScannerImpl scanner(
       kFakeInterfaceIndex,
       scan_capabilities_scan_plan_supported, wiphy_features_,
@@ -355,6 +358,8 @@
 
   PnoSettings pno_settings;
   pno_settings.interval_ms_ = kFakeScanIntervalMs;
+  pno_settings.scan_iterations_ = kFastScanIterations;
+  pno_settings.scan_interval_multiplier_ = kSlowScanIntervalMultiplier;
 
   SchedScanIntervalSetting interval_setting;
   EXPECT_CALL(
@@ -368,7 +373,7 @@
   EXPECT_TRUE(scanner.startPnoScan(pno_settings, &success_ignored).isOk());
   /* 1 plan for finite repeated scan */
   EXPECT_EQ(1U, interval_setting.plans.size());
-  EXPECT_EQ(kFakeScanIntervalMs * PnoSettings::kSlowScanIntervalMultiplier,
+  EXPECT_EQ(kFakeScanIntervalMs * kSlowScanIntervalMultiplier,
             interval_setting.final_interval_ms);
 }
 
@@ -388,6 +393,8 @@
       &scan_utils_);
   PnoSettings pno_settings;
   pno_settings.interval_ms_ = kFakeScanIntervalMs;
+  pno_settings.scan_iterations_ = kFastScanIterations;
+  pno_settings.scan_interval_multiplier_ = kSlowScanIntervalMultiplier;
 
   SchedScanIntervalSetting interval_setting;
   EXPECT_CALL(
@@ -426,8 +433,8 @@
       1 /* max_num_sched_scan_ssids */,
       1 /* max_match_sets */,
       0,
-      kFakeScanIntervalMs * PnoSettings::kSlowScanIntervalMultiplier / 1000,
-      PnoSettings::kFastScanIterations);
+      kFakeScanIntervalMs * kSlowScanIntervalMultiplier / 1000,
+      kFastScanIterations);
   ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_test_frequencies,
                            wiphy_features_, &client_interface_impl_,
                            &scan_utils_);
@@ -457,8 +464,8 @@
       1 /* max_num_sched_scan_ssids */,
       2 /* max_match_sets */,
       0,
-      kFakeScanIntervalMs * PnoSettings::kSlowScanIntervalMultiplier / 1000,
-      PnoSettings::kFastScanIterations);
+      kFakeScanIntervalMs * kSlowScanIntervalMultiplier / 1000,
+      kFastScanIterations);
   ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_test_frequencies,
                            wiphy_features_, &client_interface_impl_,
                            &scan_utils_);
@@ -496,8 +503,8 @@
       1 /* max_num_sched_scan_ssids */,
       2 /* max_match_sets */,
       0,
-      kFakeScanIntervalMs * PnoSettings::kSlowScanIntervalMultiplier / 1000,
-      PnoSettings::kFastScanIterations);
+      kFakeScanIntervalMs * kSlowScanIntervalMultiplier / 1000,
+      kFastScanIterations);
   ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_test_frequencies,
                            wiphy_features_, &client_interface_impl_,
                            &scan_utils_);
@@ -539,8 +546,8 @@
       1 /* max_num_sched_scan_ssids */,
       2 /* max_match_sets */,
       0,
-      kFakeScanIntervalMs * PnoSettings::kSlowScanIntervalMultiplier / 1000,
-      PnoSettings::kFastScanIterations);
+      kFakeScanIntervalMs * kSlowScanIntervalMultiplier / 1000,
+      kFastScanIterations);
   ScannerImpl scanner_impl(kFakeInterfaceIndex, scan_capabilities_test_frequencies,
                            wiphy_features_, &client_interface_impl_,
                            &scan_utils_);
diff --git a/wifi_keystore_hal_connector.cpp b/wifi_keystore_hal_connector.cpp
index 271e444..4884f77 100644
--- a/wifi_keystore_hal_connector.cpp
+++ b/wifi_keystore_hal_connector.cpp
@@ -43,7 +43,9 @@
   configureRpcThreadpool(1, false /* callerWillJoin */);
   android::sp<IKeystore> wifiKeystoreHalService = new Keystore();
   android::status_t err = wifiKeystoreHalService->registerAsService();
-  CHECK(err == android::OK) << "Cannot register wifi keystore HAL service: " << err;
+  if (err != android::OK) {
+      LOG(INFO) << "Did not register wifi keystore HIDL HAL service: " << err;
+  }
 }
 }  // namespace wificond
 }  // namespace android