Snap for 11397440 from 368607b9070dc9567b694b7312c8f0a1952f0580 to mainline-ipsec-release

Change-Id: Ifed38873887177a1587a1498c77bfa90314cfe83
diff --git a/service/java/com/android/server/wifi/ScanRequestProxy.java b/service/java/com/android/server/wifi/ScanRequestProxy.java
index 651f487..c5af30e 100644
--- a/service/java/com/android/server/wifi/ScanRequestProxy.java
+++ b/service/java/com/android/server/wifi/ScanRequestProxy.java
@@ -579,7 +579,8 @@
      * @param bssid BSSID as string {@link ScanResult#BSSID}.
      * @return ScanResult for the corresponding bssid if found, null otherwise.
      */
-    public @Nullable ScanResult getScanResult(@NonNull String bssid) {
+    public @Nullable ScanResult getScanResult(@Nullable String bssid) {
+        if (bssid == null) return null;
         ScanResult scanResult = mFullScanCache.get(bssid);
         if (scanResult == null) {
             scanResult = mPartialScanCache.get(bssid);
diff --git a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
index 8671ecb..986431b 100644
--- a/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
+++ b/service/java/com/android/server/wifi/SupplicantStaIfaceHal.java
@@ -842,16 +842,22 @@
     }
 
     /**
+     * Check whether the HAL service is using AIDL.
+     *
+     * @return true if the AIDL service is being used, false otherwise.
+     */
+    public boolean isAidlService() {
+        return mStaIfaceHal != null && mStaIfaceHal instanceof SupplicantStaIfaceHalAidlImpl;
+    }
+
+    /**
      * Check whether the AIDL service is running at least the expected version.
      *
      * @param expectedVersion Version number to check.
      * @return true if the AIDL service is available and >= the expected version, false otherwise.
      */
     public boolean isAidlServiceVersionAtLeast(int expectedVersion) {
-        if (mStaIfaceHal == null || mStaIfaceHal instanceof SupplicantStaIfaceHalHidlImpl) {
-            return false;
-        }
-        return ((SupplicantStaIfaceHalAidlImpl) mStaIfaceHal)
+        return isAidlService() && ((SupplicantStaIfaceHalAidlImpl) mStaIfaceHal)
                 .isServiceVersionAtLeast(expectedVersion);
     }
 
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index 1b91aed..8274bf7 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -1597,7 +1597,8 @@
                 return false;
             }
             if (mContext.getResources().getBoolean(
-                    R.bool.config_wifiNetworkCentricQosPolicyFeatureEnabled)) {
+                    R.bool.config_wifiNetworkCentricQosPolicyFeatureEnabled)
+                    && isSupplicantUsingAidlService()) {
                 mQosPolicyFeatureEnabled = mSupplicantStaIfaceHal
                         .setNetworkCentricQosPolicyFeatureEnabled(iface.name, true);
                 if (!mQosPolicyFeatureEnabled) {
@@ -3165,6 +3166,15 @@
     }
 
     /**
+     * Check whether Supplicant is using the AIDL HAL service.
+     *
+     * @return true if the Supplicant is using the AIDL service, false otherwise.
+     */
+    public boolean isSupplicantUsingAidlService() {
+        return mSupplicantStaIfaceHal.isAidlService();
+    }
+
+    /**
      * Check whether the Supplicant AIDL service is running at least the expected version.
      *
      * @param expectedVersion Version number to check.
diff --git a/service/java/com/android/server/wifi/WifiScoreCard.java b/service/java/com/android/server/wifi/WifiScoreCard.java
index 0603549..e94e337 100644
--- a/service/java/com/android/server/wifi/WifiScoreCard.java
+++ b/service/java/com/android/server/wifi/WifiScoreCard.java
@@ -119,7 +119,7 @@
     static final int SUFFICIENT_RECENT_STATS_ONLY = 1;
     static final int SUFFICIENT_RECENT_PREV_STATS = 2;
 
-    private static final int MAX_FREQUENCIES_PER_SSID = 10;
+    private static final int MAX_FREQUENCIES_PER_SSID = 30;
     private static final int MAX_TRAFFIC_STATS_POLL_TIME_DELTA_MS = 6_000;
 
     private final Clock mClock;
diff --git a/service/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java b/service/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java
index 244c386..8907e67 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java
@@ -267,6 +267,7 @@
     @Test
     public void testSetupClientInterfaceWithQosPolicyFeatureEnabled() throws Exception {
         mResources.setBoolean(R.bool.config_wifiNetworkCentricQosPolicyFeatureEnabled, true);
+        when(mSupplicantStaIfaceHal.isAidlService()).thenReturn(true);
         when(mSupplicantStaIfaceHal
                 .setNetworkCentricQosPolicyFeatureEnabled(anyString(), anyBoolean()))
                 .thenReturn(true);
@@ -274,6 +275,7 @@
                 false, false, IFACE_NAME_0, mIfaceCallback0, mIfaceDestroyedListenerCaptor0,
                 mNetworkObserverCaptor0);
         assertEquals(Set.of(IFACE_NAME_0), mWifiNative.getClientInterfaceNames());
+        verify(mSupplicantStaIfaceHal).isAidlService();
         verify(mSupplicantStaIfaceHal)
                 .setNetworkCentricQosPolicyFeatureEnabled(IFACE_NAME_0, true);
     }