Make change and version bump to aml_wif_311313030 for mainline module file: apex/apex_manifest.json

Change-Id: I11ecd54ce13348288c7a00a9b5e67ab135588cef
diff --git a/apex/apex_manifest.json b/apex/apex_manifest.json
index 54ce8b0..56ced08 100644
--- a/apex/apex_manifest.json
+++ b/apex/apex_manifest.json
@@ -1,5 +1,5 @@
 {
   "name": "com.android.wifi",
-  "version": 311313020
+  "version": 311313030
 }
 
diff --git a/service/java/com/android/server/wifi/util/ApConfigUtil.java b/service/java/com/android/server/wifi/util/ApConfigUtil.java
index 4f881e1..5846a74 100644
--- a/service/java/com/android/server/wifi/util/ApConfigUtil.java
+++ b/service/java/com/android/server/wifi/util/ApConfigUtil.java
@@ -367,10 +367,18 @@
         int[] regulatoryArray = wifiNative.getChannelsForBand(scannerBand);
         List<Integer> regulatoryList = new ArrayList<Integer>();
         for (int freq : regulatoryArray) {
-            if (inFrequencyMHz) {
-                regulatoryList.add(freq);
-            } else {
-                regulatoryList.add(ScanResult.convertFrequencyMhzToChannelIfSupported(freq));
+            regulatoryList.add(inFrequencyMHz
+                    ? freq : ScanResult.convertFrequencyMhzToChannelIfSupported(freq));
+        }
+
+        // Add DFS channels to the supported channel list if the device supports SoftAp operation
+        // in the DFS channel.
+        if (resources.getBoolean(R.bool.config_wifiSoftapAcsIncludeDfs)
+                && scannerBand == WifiScanner.WIFI_BAND_5_GHZ) {
+            regulatoryArray = wifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY);
+            for (int freq : regulatoryArray) {
+                regulatoryList.add(inFrequencyMHz
+                        ? freq : ScanResult.convertFrequencyMhzToChannelIfSupported(freq));
             }
         }
 
diff --git a/service/tests/wifitests/src/com/android/server/wifi/util/ApConfigUtilTest.java b/service/tests/wifitests/src/com/android/server/wifi/util/ApConfigUtilTest.java
index 6d75580..51c6ca6 100644
--- a/service/tests/wifitests/src/com/android/server/wifi/util/ApConfigUtilTest.java
+++ b/service/tests/wifitests/src/com/android/server/wifi/util/ApConfigUtilTest.java
@@ -23,6 +23,7 @@
 import static org.junit.Assume.assumeTrue;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import android.content.Context;
@@ -53,6 +54,7 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 
 /**
  * Unit tests for {@link com.android.server.wifi.util.ApConfigUtil}.
@@ -137,6 +139,7 @@
     private static final int[] ALLOWED_5G_FREQS = {5745, 5765}; //ch# 149, 153
     private static final int[] ALLOWED_6G_FREQS = {5945, 5965};
     private static final int[] ALLOWED_60G_FREQS = {58320, 60480}; // ch# 1, 2
+    private static final int[] TEST_5G_DFS_FREQS = {5280, 5520}; // ch#56, 104
 
     @Mock Context mContext;
     @Mock Resources mResources;
@@ -842,4 +845,21 @@
                     mockSoftApCapability));
         }
     }
+
+    @Test
+    public void testGetAvailableChannelFreqsForBandWithDfsChannelWhenDeviceSupported()
+            throws Exception {
+        when(mResources.getBoolean(R.bool.config_wifiSoftapAcsIncludeDfs))
+                .thenReturn(true);
+        when(mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY))
+                .thenReturn(TEST_5G_DFS_FREQS);
+        when(mWifiNative.getChannelsForBand(anyInt())).thenReturn(new int[0]);
+        List<Integer> result = ApConfigUtil.getAvailableChannelFreqsForBand(
+                SoftApConfiguration.BAND_5GHZ, mWifiNative, mResources, true);
+        // make sure we try to get dfs channel.
+        verify(mWifiNative).getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY);
+        for (int freq : result) {
+            assertTrue(Arrays.stream(TEST_5G_DFS_FREQS).anyMatch(n -> n == freq));
+        }
+    }
 }