diff options
author | Jimmy Chen <jimmycmchen@google.com> | 2020-11-05 17:14:01 +0800 |
---|---|---|
committer | Jimmy Chen <jimmycmchen@google.com> | 2020-12-11 09:28:00 +0800 |
commit | 132aecc71aac50e2314dc9f60b16c07da3743df1 (patch) | |
tree | 5ef689ee6ef42fe27d62ad78a9ae243061f7d98e | |
parent | 063c3424a45f86338f8470860a427616e20d8aad (diff) | |
download | wifi-132aecc71aac50e2314dc9f60b16c07da3743df1.tar.gz |
softap: add support for SoftAP on the 60GHz band
Support starting SoftAP on the 60GHz band by setting
the apBand field in WifiConfiguration to AP_BAND_60G.
Extend the WifiNative.setupInterfaceForSoftApMode with
band argument. When band is AP_BAND_60G, locate a WIFI
chip which supports the 60GHz band by checking for the
new WIGIG chip capability. If a chip was found, create
the AP interface on this chip.
Extend the channel and band selection methods in
ApConfigUtil to support selecting 60GHz channels.
Implement WifiManager is60GHzBandSupported for detecting
whether 60GHz band is supported in the system. Note,
this method uses a configuration parameter and does not
check for capable WIFI chip. This is because the API
may need to be called when WIFI is disabled, before
the WIFI HAL is loaded. This can be switched to querying
the HAL in the future, when it is loaded earlier.
Add support for configurable 802.11ax (WIFI6) setting,
and disable it by default when using the 60GHz band since
it causes issues with hostapd.
Bug: 155421131
Test: Manual
Test: atest com.android.server.wifi
Change-Id: I82d700de0df1632d55169102372c189b72fc763b
13 files changed, 182 insertions, 56 deletions
diff --git a/service/java/com/android/server/wifi/HostapdHal.java b/service/java/com/android/server/wifi/HostapdHal.java index 1a161a57b..bffd2c260 100644 --- a/service/java/com/android/server/wifi/HostapdHal.java +++ b/service/java/com/android/server/wifi/HostapdHal.java @@ -851,6 +851,7 @@ public class HostapdHal { && channelParam13.channel == 0; // Prepare the bandMask channelParam13.V1_2.bandMask = getHalBandMask(config.getChannels().keyAt(i)); + channelParam13.bandMask = channelParam13.V1_2.bandMask; // Prepare AcsChannelFreqRangesMhz if (channelParam13.enableAcs && ApConfigUtil.isSendFreqRangesNeeded( config.getChannels().keyAt(i), mContext)) { @@ -933,6 +934,9 @@ public class HostapdHal { if (ApConfigUtil.containsBand(apBand, SoftApConfiguration.BAND_6GHZ)) { bandMask |= android.hardware.wifi.hostapd.V1_2.IHostapd.BandMask.BAND_6_GHZ; } + if (ApConfigUtil.containsBand(apBand, SoftApConfiguration.BAND_60GHZ)) { + bandMask |= android.hardware.wifi.hostapd.V1_3.IHostapd.BandMask.BAND_60_GHZ; + } return bandMask; } @@ -1179,6 +1183,14 @@ public class HostapdHal { return SoftApInfo.CHANNEL_WIDTH_80MHZ_PLUS_MHZ; case Bandwidth.WIFI_BANDWIDTH_160: return SoftApInfo.CHANNEL_WIDTH_160MHZ; + case Bandwidth.WIFI_BANDWIDTH_2160: + return SoftApInfo.CHANNEL_WIDTH_2160MHZ; + case Bandwidth.WIFI_BANDWIDTH_4320: + return SoftApInfo.CHANNEL_WIDTH_4320MHZ; + case Bandwidth.WIFI_BANDWIDTH_6480: + return SoftApInfo.CHANNEL_WIDTH_6480MHZ; + case Bandwidth.WIFI_BANDWIDTH_8640: + return SoftApInfo.CHANNEL_WIDTH_8640MHZ; default: return SoftApInfo.CHANNEL_WIDTH_INVALID; } @@ -1201,6 +1213,8 @@ public class HostapdHal { return ScanResult.WIFI_STANDARD_11AC; case Generation.WIFI_STANDARD_11AX: return ScanResult.WIFI_STANDARD_11AX; + case Generation.WIFI_STANDARD_11AD: + return ScanResult.WIFI_STANDARD_11AD; default: return ScanResult.WIFI_STANDARD_UNKNOWN; } diff --git a/service/java/com/android/server/wifi/SoftApManager.java b/service/java/com/android/server/wifi/SoftApManager.java index cb008a6f2..d02d1379a 100644 --- a/service/java/com/android/server/wifi/SoftApManager.java +++ b/service/java/com/android/server/wifi/SoftApManager.java @@ -664,6 +664,7 @@ public class SoftApManager implements ActiveModeManager { } mApInterfaceName = mWifiNative.setupInterfaceForSoftApMode( mWifiNativeInterfaceCallback, mRequestorWs, + mApConfig.getSoftApConfiguration().getBand(), (SdkLevel.isAtLeastS() && mApConfig.getSoftApConfiguration().getBands().length > 1)); if (TextUtils.isEmpty(mApInterfaceName)) { diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index 2d21642eb..0854dae79 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -899,11 +899,12 @@ public class WifiNative { * teardown any existing iface. */ private String createApIface(@NonNull Iface iface, @NonNull WorkSource requestorWs, - boolean isBridged) { + @SoftApConfiguration.BandType int band, boolean isBridged) { synchronized (mLock) { if (mWifiVendorHal.isVendorHalSupported()) { return mWifiVendorHal.createApIface( - new InterfaceDestoyedListenerInternal(iface.id), requestorWs, isBridged); + new InterfaceDestoyedListenerInternal(iface.id), requestorWs, + band, isBridged); } else { Log.i(TAG, "Vendor Hal not supported, ignoring createApIface."); return handleIfaceCreationWhenVendorHalNotSupported(iface); @@ -1181,7 +1182,7 @@ public class WifiNative { */ public String setupInterfaceForSoftApMode( @NonNull InterfaceCallback interfaceCallback, @NonNull WorkSource requestorWs, - boolean isBridged) { + @SoftApConfiguration.BandType int band, boolean isBridged) { synchronized (mLock) { if (!startHal()) { Log.e(TAG, "Failed to start Hal"); @@ -1199,7 +1200,7 @@ public class WifiNative { return null; } iface.externalListener = interfaceCallback; - iface.name = createApIface(iface, requestorWs, isBridged); + iface.name = createApIface(iface, requestorWs, band, isBridged); if (TextUtils.isEmpty(iface.name)) { Log.e(TAG, "Failed to create AP iface in vendor HAL"); mIfaceMgr.removeIface(iface.id); diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index daf8d7b74..3a27369b9 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -1258,6 +1258,16 @@ public class WifiServiceImpl extends BaseWifiService { supportedChannelList.stream().mapToInt(Integer::intValue).toArray()); } } + if (is60GHzBandSupportedInternal()) { + supportedChannelList = ApConfigUtil.getAvailableChannelFreqsForBand( + SoftApConfiguration.BAND_60GHZ, mWifiNative, mContext.getResources(), + false); + if (supportedChannelList != null) { + newSoftApCapability.setSupportedChannelList( + SoftApConfiguration.BAND_60GHZ, + supportedChannelList.stream().mapToInt(Integer::intValue).toArray()); + } + } return newSoftApCapability; } diff --git a/service/java/com/android/server/wifi/WifiShellCommand.java b/service/java/com/android/server/wifi/WifiShellCommand.java index ca920ba94..2068bca87 100644 --- a/service/java/com/android/server/wifi/WifiShellCommand.java +++ b/service/java/com/android/server/wifi/WifiShellCommand.java @@ -369,7 +369,9 @@ public class WifiShellCommand extends BasicShellCommandHandler { || (band == SoftApConfiguration.BAND_5GHZ && !mWifiService.is5GHzBandSupported()) || (band == SoftApConfiguration.BAND_6GHZ - && !mWifiService.is6GHzBandSupported())) { + && !mWifiService.is6GHzBandSupported()) + || (band == SoftApConfiguration.BAND_60GHZ + && !mWifiService.is60GHzBandSupported())) { pw.println("Invalid argument to 'force-softap-channel enabled' " + "- must be a valid WLAN channel" + " in a band supported by the device"); @@ -1120,6 +1122,7 @@ public class WifiShellCommand extends BasicShellCommandHandler { int[] allowed5gDfsFreq = mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ_DFS_ONLY); int[] allowed6gFreq = mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_6_GHZ); + int[] allowed60gFreq = mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_60_GHZ); if (allowed2gFreq == null) { allowed2gFreq = new int[0]; } @@ -1132,14 +1135,19 @@ public class WifiShellCommand extends BasicShellCommandHandler { if (allowed6gFreq == null) { allowed6gFreq = new int[0]; } + if (allowed60gFreq == null) { + allowed60gFreq = new int[0]; + } pw.println("2G freq: " + Arrays.toString(allowed2gFreq)); pw.println("5G freq: " + Arrays.toString(allowed5gFreq)); pw.println("5G DFS: " + Arrays.toString(allowed5gDfsFreq)); pw.println("6G freq: " + Arrays.toString(allowed6gFreq)); + pw.println("60G freq: " + Arrays.toString(allowed60gFreq)); return (Arrays.binarySearch(allowed2gFreq, apChannelMHz) >= 0 || Arrays.binarySearch(allowed5gFreq, apChannelMHz) >= 0 || Arrays.binarySearch(allowed5gDfsFreq, apChannelMHz) >= 0) - || Arrays.binarySearch(allowed6gFreq, apChannelMHz) >= 0; + || Arrays.binarySearch(allowed6gFreq, apChannelMHz) >= 0 + || Arrays.binarySearch(allowed60gFreq, apChannelMHz) >= 0; } private void waitForWifiEnabled(boolean enabled) throws InterruptedException { diff --git a/service/java/com/android/server/wifi/WifiVendorHal.java b/service/java/com/android/server/wifi/WifiVendorHal.java index 47eb3619d..f657c2e24 100644 --- a/service/java/com/android/server/wifi/WifiVendorHal.java +++ b/service/java/com/android/server/wifi/WifiVendorHal.java @@ -52,6 +52,7 @@ import android.hardware.wifi.V1_5.WifiBand; import android.net.MacAddress; import android.net.apf.ApfCapabilities; import android.net.wifi.ScanResult; +import android.net.wifi.SoftApConfiguration; import android.net.wifi.WifiManager; import android.net.wifi.WifiScanner; import android.net.wifi.WifiSsid; @@ -349,7 +350,8 @@ public class WifiVendorHal { if (!startVendorHal()) { return false; } - if (TextUtils.isEmpty(createApIface(null, null, false))) { + if (TextUtils.isEmpty(createApIface(null, null, + SoftApConfiguration.BAND_2GHZ, false))) { stopVendorHal(); return false; } @@ -518,18 +520,30 @@ public class WifiVendorHal { } } + private long getNecessaryCapabilitiesForSoftApMode(@SoftApConfiguration.BandType int band) { + long caps = HalDeviceManager.CHIP_CAPABILITY_ANY; + if ((band & SoftApConfiguration.BAND_60GHZ) != 0) { + caps |= android.hardware.wifi.V1_5.IWifiChip.ChipCapabilityMask.WIGIG; + } + return caps; + } + /** * Create a AP iface using {@link HalDeviceManager}. * * @param destroyedListener Listener to be invoked when the interface is destroyed. * @param requestorWs Requestor worksource. + * @param band The requesting band for this AP interface. * @param isBridged Whether or not AP interface is a bridge interface. * @return iface name on success, null otherwise. */ public String createApIface(@Nullable InterfaceDestroyedListener destroyedListener, - @NonNull WorkSource requestorWs, boolean isBridged) { + @NonNull WorkSource requestorWs, + @SoftApConfiguration.BandType int band, + boolean isBridged) { synchronized (sLock) { IWifiApIface iface = mHalDeviceManager.createApIface( + getNecessaryCapabilitiesForSoftApMode(band), new ApInterfaceDestroyedListenerInternal(destroyedListener), null, requestorWs, isBridged); if (iface == null) { diff --git a/service/java/com/android/server/wifi/util/ApConfigUtil.java b/service/java/com/android/server/wifi/util/ApConfigUtil.java index 7710d7e5f..8c9d82fb0 100644 --- a/service/java/com/android/server/wifi/util/ApConfigUtil.java +++ b/service/java/com/android/server/wifi/util/ApConfigUtil.java @@ -106,6 +106,8 @@ public class ApConfigUtil { return WifiScanner.WIFI_BAND_5_GHZ; case SoftApConfiguration.BAND_6GHZ: return WifiScanner.WIFI_BAND_6_GHZ; + case SoftApConfiguration.BAND_60GHZ: + return WifiScanner.WIFI_BAND_60_GHZ; default: return WifiScanner.WIFI_BAND_UNSPECIFIED; } @@ -136,6 +138,8 @@ public class ApConfigUtil { return SoftApConfiguration.BAND_5GHZ; } else if (ScanResult.is6GHz(frequency)) { return SoftApConfiguration.BAND_6GHZ; + } else if (ScanResult.is60GHz(frequency)) { + return SoftApConfiguration.BAND_60GHZ; } return -1; @@ -164,7 +168,9 @@ public class ApConfigUtil { * Checks if band is a valid combination of {link SoftApConfiguration#BandType} values */ public static boolean isBandValid(@BandType int band) { - return ((band != 0) && ((band & ~SoftApConfiguration.BAND_ANY) == 0)); + int bandAny = SoftApConfiguration.BAND_2GHZ | SoftApConfiguration.BAND_5GHZ + | SoftApConfiguration.BAND_6GHZ | SoftApConfiguration.BAND_60GHZ; + return ((band != 0) && ((band & ~bandAny) == 0)); } /** @@ -267,6 +273,11 @@ public class ApConfigUtil { R.string.config_wifiSoftap6gChannelList)); scannerBand = WifiScanner.WIFI_BAND_6_GHZ; break; + case SoftApConfiguration.BAND_60GHZ: + configuredList = convertStringToChannelList(resources.getString( + R.string.config_wifiSoftap60gChannelList)); + scannerBand = WifiScanner.WIFI_BAND_60_GHZ; + break; default: return null; } @@ -315,6 +326,14 @@ public class ApConfigUtil { List<Integer> allowedFreqList = null; + if ((apBand & SoftApConfiguration.BAND_60GHZ) != 0) { + allowedFreqList = getAvailableChannelFreqsForBand(SoftApConfiguration.BAND_60GHZ, + wifiNative, resources, true); + if (allowedFreqList != null && allowedFreqList.size() > 0) { + return allowedFreqList.get(sRandom.nextInt(allowedFreqList.size())).intValue(); + } + } + if ((apBand & SoftApConfiguration.BAND_6GHZ) != 0) { allowedFreqList = getAvailableChannelFreqsForBand(SoftApConfiguration.BAND_6GHZ, wifiNative, resources, true); @@ -424,6 +443,9 @@ public class ApConfigUtil { case WifiConfiguration.AP_BAND_5GHZ: band = SoftApConfiguration.BAND_5GHZ; break; + case WifiConfiguration.AP_BAND_60GHZ: + band = SoftApConfiguration.BAND_60GHZ; + break; default: // WifiConfiguration.AP_BAND_ANY means only 2GHz and 5GHz bands band = SoftApConfiguration.BAND_2GHZ | SoftApConfiguration.BAND_5GHZ; diff --git a/service/res/values/config.xml b/service/res/values/config.xml index 835dc7733..ad58208d4 100644 --- a/service/res/values/config.xml +++ b/service/res/values/config.xml @@ -169,6 +169,11 @@ range string like '36-48,149'. --> <string translatable="false" name="config_wifiSoftap6gChannelList"></string> + <!-- List of allowed channels in 60GHz band for softap. If the device doesn't want to restrict + channels this should be empty. Values is a comma separated channel string and/or channel + range string like '1-2,4'. --> + <string translatable="false" name="config_wifiSoftap60gChannelList"></string> + <!-- Integer indicating associated full scan max num active channels --> <integer translatable="false" name="config_wifi_framework_associated_partial_scan_max_num_active_channels">6</integer> diff --git a/service/res/values/overlayable.xml b/service/res/values/overlayable.xml index 7df1d81ed..ba5b589ba 100644 --- a/service/res/values/overlayable.xml +++ b/service/res/values/overlayable.xml @@ -66,6 +66,7 @@ <item type="string" name="config_wifiSoftap2gChannelList" /> <item type="string" name="config_wifiSoftap5gChannelList" /> <item type="string" name="config_wifiSoftap6gChannelList" /> + <item type="string" name="config_wifiSoftap60gChannelList" /> <item type="integer" name="config_wifi_framework_associated_partial_scan_max_num_active_channels" /> <item type="integer" name="config_wifi_framework_recovery_timeout_delay" /> <item type="bool" name="config_wifi_framework_enable_associated_network_selection" /> diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java index 8724c7318..4a0b1c7a8 100644 --- a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java @@ -179,7 +179,7 @@ public class SoftApManagerTest extends WifiBaseTest { when(mWifiNative.setApMacAddress(any(), any())).thenReturn(true); when(mWifiNative.startSoftAp(eq(TEST_INTERFACE_NAME), any(), anyBoolean(), any(WifiNative.SoftApListener.class))).thenReturn(true); - when(mWifiNative.setupInterfaceForSoftApMode(any(), any(), anyBoolean())) + when(mWifiNative.setupInterfaceForSoftApMode(any(), any(), anyInt(), anyBoolean())) .thenReturn(TEST_INTERFACE_NAME); when(mFrameworkFacade.getIntegerSetting( mContext, Settings.Global.SOFT_AP_TIMEOUT_ENABLED, 1)).thenReturn(1); @@ -329,7 +329,8 @@ public class SoftApManagerTest extends WifiBaseTest { @Test public void testSetupForSoftApModeNullApInterfaceNameFailureIncrementsMetrics() throws Exception { - when(mWifiNative.setupInterfaceForSoftApMode(any(), any(), anyBoolean())).thenReturn(null); + when(mWifiNative.setupInterfaceForSoftApMode( + any(), any(), anyInt(), anyBoolean())).thenReturn(null); when(mWifiApConfigStore.getApConfiguration()).thenReturn(null); SoftApModeConfiguration nullApConfig = new SoftApModeConfiguration(WifiManager.IFACE_IP_MODE_TETHERED, null, @@ -357,7 +358,8 @@ public class SoftApManagerTest extends WifiBaseTest { @Test public void testSetupForSoftApModeEmptyInterfaceNameFailureIncrementsMetrics() throws Exception { - when(mWifiNative.setupInterfaceForSoftApMode(any(), any(), anyBoolean())).thenReturn(""); + when(mWifiNative.setupInterfaceForSoftApMode( + any(), any(), anyInt(), anyBoolean())).thenReturn(""); SoftApModeConfiguration nullApConfig = new SoftApModeConfiguration(WifiManager.IFACE_IP_MODE_TETHERED, null, mTestSoftApCapability); @@ -1762,6 +1764,8 @@ public class SoftApManagerTest extends WifiBaseTest { /** Starts soft AP and verifies that it is enabled successfully. */ protected void startSoftApAndVerifyEnabled( SoftApModeConfiguration softApConfig, String countryCode) throws Exception { + // The expected band to setup the interface + int expectedBandMask = SoftApConfiguration.BAND_2GHZ; // The expected config to pass to Native SoftApConfiguration expectedConfig = null; // The config which base on mDefaultApConfig and generate ramdonized mac address @@ -1780,6 +1784,7 @@ public class SoftApManagerTest extends WifiBaseTest { .setChannel(DEFAULT_AP_CHANNEL, SoftApConfiguration.BAND_2GHZ) .build(); } else { + expectedBandMask = config.getBand(); expectedConfig = new SoftApConfiguration.Builder(config) .setChannel(DEFAULT_AP_CHANNEL, SoftApConfiguration.BAND_2GHZ) .build(); @@ -1792,7 +1797,8 @@ public class SoftApManagerTest extends WifiBaseTest { ArgumentCaptor<Intent> intentCaptor = ArgumentCaptor.forClass(Intent.class); verify(mFakeSoftApNotifier).dismissSoftApShutDownTimeoutExpiredNotification(); order.verify(mWifiNative).setupInterfaceForSoftApMode( - mWifiNativeInterfaceCallbackCaptor.capture(), eq(TEST_WORKSOURCE), eq(false)); + mWifiNativeInterfaceCallbackCaptor.capture(), eq(TEST_WORKSOURCE), + eq(expectedBandMask), eq(false)); ArgumentCaptor<SoftApConfiguration> configCaptor = ArgumentCaptor.forClass(SoftApConfiguration.class); order.verify(mCallback).onStateChanged(WifiManager.WIFI_AP_STATE_ENABLING, 0); @@ -2250,7 +2256,8 @@ public class SoftApManagerTest extends WifiBaseTest { mTestSoftApCapability); mSoftApManager = createSoftApManager(dualBandConfig, TEST_COUNTRY_CODE, ROLE_SOFTAP_TETHERED); - verify(mWifiNative).setupInterfaceForSoftApMode(any(), any(), eq(true)); + verify(mWifiNative).setupInterfaceForSoftApMode( + any(), any(), eq(SoftApConfiguration.BAND_2GHZ), eq(true)); } @Test diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java index 4a8951bf8..97b0c62e1 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiNativeInterfaceManagementTest.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.anyBoolean; +import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doNothing; @@ -125,7 +126,8 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { when(mWifiVendorHal.isVendorHalReady()).thenReturn(true); when(mWifiVendorHal.startVendorHal()).thenReturn(true); when(mWifiVendorHal.createStaIface(any(), any())).thenReturn(IFACE_NAME_0); - when(mWifiVendorHal.createApIface(any(), any(), anyBoolean())).thenReturn(IFACE_NAME_0); + when(mWifiVendorHal.createApIface(any(), any(), anyInt(), + anyBoolean())).thenReturn(IFACE_NAME_0); when(mWifiVendorHal.removeStaIface(any())).thenReturn(true); when(mWifiVendorHal.removeApIface(any())).thenReturn(true); when(mWifiVendorHal.replaceStaIfaceRequestorWs(any(), any())).thenReturn(true); @@ -215,7 +217,8 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { @Test public void testSetupSoftApInterface() throws Exception { executeAndValidateSetupSoftApInterface( - false, false, IFACE_NAME_0, mIfaceCallback0, mIfaceDestroyedListenerCaptor0, + false, false, IFACE_NAME_0, + mIfaceCallback0, mIfaceDestroyedListenerCaptor0, mNetworkObserverCaptor0); assertNull(mWifiNative.getClientInterfaceName()); } @@ -428,13 +431,13 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { // The iface name will remain the same. doAnswer(new MockAnswerUtil.AnswerWithArguments() { public String answer(InterfaceDestroyedListener destroyedListener, WorkSource ws, - boolean isBridged) { + int band, boolean isBridged) { mIfaceDestroyedListenerCaptor0.getValue().onDestroyed(IFACE_NAME_0); return IFACE_NAME_0; } - }).when(mWifiVendorHal).createApIface(any(), any(), eq(false)); + }).when(mWifiVendorHal).createApIface(any(), any(), anyInt(), eq(false)); assertEquals(IFACE_NAME_0, mWifiNative.setupInterfaceForSoftApMode( - mIfaceCallback1, TEST_WORKSOURCE, false)); + mIfaceCallback1, TEST_WORKSOURCE, SoftApConfiguration.BAND_2GHZ, false)); mInOrder.verify(mHostapdHal).isInitializationStarted(); mInOrder.verify(mHostapdHal).initialize(); @@ -443,7 +446,7 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { mInOrder.verify(mHostapdHal).registerDeathHandler(any()); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).createApIface( - mIfaceDestroyedListenerCaptor1.capture(), eq(TEST_WORKSOURCE), eq(false)); + mIfaceDestroyedListenerCaptor1.capture(), eq(TEST_WORKSOURCE), anyInt(), eq(false)); // Creation of AP interface should trigger the STA interface destroy validateOnDestroyedClientInterface( false, true, IFACE_NAME_0, mIfaceCallback0, mNetworkObserverCaptor0.getValue()); @@ -696,14 +699,14 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { // The iface name will remain the same. doAnswer(new MockAnswerUtil.AnswerWithArguments() { public String answer(InterfaceDestroyedListener destroyedListener, WorkSource ws, - boolean isBriger) { + int band, boolean isBriger) { mIfaceDestroyedListenerCaptor0.getValue().onDestroyed(IFACE_NAME_0); return IFACE_NAME_0; } - }).when(mWifiVendorHal).createApIface(any(), any(), eq(false)); + }).when(mWifiVendorHal).createApIface(any(), any(), anyInt(), eq(false)); assertEquals(IFACE_NAME_0, mWifiNative.setupInterfaceForSoftApMode( - mIfaceCallback1, TEST_WORKSOURCE, false)); + mIfaceCallback1, TEST_WORKSOURCE, SoftApConfiguration.BAND_2GHZ, false)); mInOrder.verify(mHostapdHal).isInitializationStarted(); mInOrder.verify(mHostapdHal).initialize(); @@ -712,7 +715,7 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { mInOrder.verify(mHostapdHal).registerDeathHandler(any()); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).createApIface( - mIfaceDestroyedListenerCaptor1.capture(), eq(TEST_WORKSOURCE), eq(false)); + mIfaceDestroyedListenerCaptor1.capture(), eq(TEST_WORKSOURCE), anyInt(), eq(false)); // Creation of AP interface should trigger the STA interface destroy validateOnDestroyedClientInterface( false, true, IFACE_NAME_0, mIfaceCallback0, mNetworkObserverCaptor0.getValue()); @@ -992,7 +995,7 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { public void testSetupSoftApInterfaceFailureInStartHal() throws Exception { when(mWifiVendorHal.startVendorHal()).thenReturn(false); assertNull(mWifiNative.setupInterfaceForSoftApMode(mIfaceCallback0, TEST_WORKSOURCE, - false)); + SoftApConfiguration.BAND_2GHZ, false)); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).startVendorHal(); @@ -1011,7 +1014,7 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { public void testSetupSoftApInterfaceFailureInStartHostapd() throws Exception { when(mHostapdHal.startDaemon()).thenReturn(false); assertNull(mWifiNative.setupInterfaceForSoftApMode(mIfaceCallback0, TEST_WORKSOURCE, - false)); + SoftApConfiguration.BAND_2GHZ, false)); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).startVendorHal(); @@ -1031,9 +1034,9 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { */ @Test public void testSetupSoftApInterfaceFailureInHalCreateApIface() throws Exception { - when(mWifiVendorHal.createApIface(any(), any(), anyBoolean())).thenReturn(null); + when(mWifiVendorHal.createApIface(any(), any(), anyInt(), anyBoolean())).thenReturn(null); assertNull(mWifiNative.setupInterfaceForSoftApMode( - mIfaceCallback0, TEST_WORKSOURCE, false)); + mIfaceCallback0, TEST_WORKSOURCE, SoftApConfiguration.BAND_2GHZ, false)); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).startVendorHal(); @@ -1043,7 +1046,7 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { mInOrder.verify(mHostapdHal).isInitializationComplete(); mInOrder.verify(mHostapdHal).registerDeathHandler(any()); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); - mInOrder.verify(mWifiVendorHal).createApIface(any(), any(), anyBoolean()); + mInOrder.verify(mWifiVendorHal).createApIface(any(), any(), anyInt(), anyBoolean()); mInOrder.verify(mWifiMetrics).incrementNumSetupSoftApInterfaceFailureDueToHal(); // To test if the failure is handled cleanly, invoke teardown and ensure that @@ -1060,7 +1063,7 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { throws Exception { when(mWificondControl.setupInterfaceForSoftApMode(any())).thenReturn(false); assertNull(mWifiNative.setupInterfaceForSoftApMode( - mIfaceCallback0, TEST_WORKSOURCE, false)); + mIfaceCallback0, TEST_WORKSOURCE, SoftApConfiguration.BAND_2GHZ, false)); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).startVendorHal(); @@ -1071,7 +1074,7 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { mInOrder.verify(mHostapdHal).registerDeathHandler(any()); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).createApIface( - mIfaceDestroyedListenerCaptor0.capture(), eq(TEST_WORKSOURCE), eq(false)); + mIfaceDestroyedListenerCaptor0.capture(), eq(TEST_WORKSOURCE), anyInt(), eq(false)); mInOrder.verify(mWificondControl).setupInterfaceForSoftApMode(any()); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).removeApIface(any()); @@ -1191,7 +1194,7 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { // Now setup an AP interface. assertEquals(IFACE_NAME_0, mWifiNative.setupInterfaceForSoftApMode( - mIfaceCallback1, TEST_WORKSOURCE, false)); + mIfaceCallback1, TEST_WORKSOURCE, SoftApConfiguration.BAND_2GHZ, false)); mInOrder.verify(mHostapdHal).isInitializationStarted(); mInOrder.verify(mHostapdHal).initialize(); @@ -1231,7 +1234,7 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { // First setup an AP interface and verify. assertEquals(IFACE_NAME_0, mWifiNative.setupInterfaceForSoftApMode( - mIfaceCallback0, TEST_WORKSOURCE, false)); + mIfaceCallback0, TEST_WORKSOURCE, SoftApConfiguration.BAND_2GHZ, false)); mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mHostapdHal).isInitializationStarted(); @@ -1552,9 +1555,9 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { String ifaceName, @Mock WifiNative.InterfaceCallback callback, ArgumentCaptor<InterfaceDestroyedListener> destroyedListenerCaptor, ArgumentCaptor<NetdEventObserver> networkObserverCaptor) throws Exception { - when(mWifiVendorHal.createApIface(any(), any(), eq(false))).thenReturn(ifaceName); + when(mWifiVendorHal.createApIface(any(), any(), anyInt(), eq(false))).thenReturn(ifaceName); assertEquals(ifaceName, mWifiNative.setupInterfaceForSoftApMode( - callback, TEST_WORKSOURCE, false)); + callback, TEST_WORKSOURCE, SoftApConfiguration.BAND_2GHZ, false)); validateSetupSoftApInterface( existingStaIface, existingApIface, ifaceName, destroyedListenerCaptor, @@ -1578,7 +1581,8 @@ public class WifiNativeInterfaceManagementTest extends WifiBaseTest { } mInOrder.verify(mWifiVendorHal).isVendorHalSupported(); mInOrder.verify(mWifiVendorHal).createApIface( - destroyedListenerCaptor.capture(), eq(TEST_WORKSOURCE), eq(false)); + destroyedListenerCaptor.capture(), eq(TEST_WORKSOURCE), + eq(SoftApConfiguration.BAND_2GHZ), eq(false)); mInOrder.verify(mWificondControl).setupInterfaceForSoftApMode(ifaceName); mInOrder.verify(mNetdWrapper).registerObserver(networkObserverCaptor.capture()); mInOrder.verify(mNetdWrapper).isInterfaceUp(ifaceName); diff --git a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java index 72d037d45..92b211320 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiVendorHalTest.java @@ -28,6 +28,7 @@ import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyBoolean; import static org.mockito.Mockito.anyByte; import static org.mockito.Mockito.anyInt; +import static org.mockito.Mockito.anyLong; import static org.mockito.Mockito.anyObject; import static org.mockito.Mockito.anyShort; import static org.mockito.Mockito.doAnswer; @@ -85,6 +86,7 @@ import android.net.MacAddress; import android.net.NattKeepalivePacketData; import android.net.apf.ApfCapabilities; import android.net.wifi.ScanResult; +import android.net.wifi.SoftApConfiguration; import android.net.wifi.WifiManager; import android.net.wifi.WifiScanner; import android.net.wifi.WifiSsid; @@ -353,7 +355,7 @@ public class WifiVendorHalTest extends WifiBaseTest { }).when(mHalDeviceManager).stop(); when(mHalDeviceManager.createStaIface(any(), eq(null), any())) .thenReturn(mIWifiStaIface); - when(mHalDeviceManager.createApIface(any(), eq(null), any(), anyBoolean())) + when(mHalDeviceManager.createApIface(anyLong(), any(), eq(null), any(), anyBoolean())) .thenReturn(mIWifiApIface); when(mHalDeviceManager.removeIface(any())).thenReturn(true); when(mHalDeviceManager.getChip(any(IWifiIface.class))) @@ -434,7 +436,8 @@ public class WifiVendorHalTest extends WifiBaseTest { verify(mIWifiStaIface).registerEventCallback(any(IWifiStaIfaceEventCallback.class)); verify(mIWifiChip).registerEventCallback(any(IWifiChipEventCallback.class)); - verify(mHalDeviceManager, never()).createApIface(any(), eq(null), any(), anyBoolean()); + verify(mHalDeviceManager, never()).createApIface( + anyLong(), any(), eq(null), any(), anyBoolean()); } /** @@ -447,7 +450,8 @@ public class WifiVendorHalTest extends WifiBaseTest { assertTrue(mWifiVendorHal.isHalStarted()); verify(mHalDeviceManager).start(); - verify(mHalDeviceManager).createApIface(any(), eq(null), any(), anyBoolean()); + verify(mHalDeviceManager).createApIface( + anyLong(), any(), eq(null), any(), anyBoolean()); verify(mHalDeviceManager).getChip(eq(mIWifiApIface)); verify(mHalDeviceManager).isReady(); verify(mHalDeviceManager).isStarted(); @@ -474,7 +478,8 @@ public class WifiVendorHalTest extends WifiBaseTest { verify(mHalDeviceManager).start(); verify(mHalDeviceManager, never()).createStaIface(any(), eq(null), any()); - verify(mHalDeviceManager, never()).createApIface(any(), eq(null), any(), anyBoolean()); + verify(mHalDeviceManager, never()).createApIface( + anyLong(), any(), eq(null), any(), anyBoolean()); verify(mHalDeviceManager, never()).getChip(any(IWifiIface.class)); verify(mIWifiStaIface, never()) .registerEventCallback(any(IWifiStaIfaceEventCallback.class)); @@ -494,7 +499,8 @@ public class WifiVendorHalTest extends WifiBaseTest { verify(mHalDeviceManager).createStaIface(any(), eq(null), any()); verify(mHalDeviceManager).stop(); - verify(mHalDeviceManager, never()).createApIface(any(), eq(null), any(), anyBoolean()); + verify(mHalDeviceManager, never()).createApIface( + anyLong(), any(), eq(null), any(), anyBoolean()); verify(mHalDeviceManager, never()).getChip(any(IWifiIface.class)); verify(mIWifiStaIface, never()) .registerEventCallback(any(IWifiStaIfaceEventCallback.class)); @@ -516,7 +522,8 @@ public class WifiVendorHalTest extends WifiBaseTest { verify(mHalDeviceManager).stop(); verify(mIWifiStaIface).registerEventCallback(any(IWifiStaIfaceEventCallback.class)); - verify(mHalDeviceManager, never()).createApIface(any(), eq(null), any(), anyBoolean()); + verify(mHalDeviceManager, never()).createApIface( + anyLong(), any(), eq(null), any(), anyBoolean()); } /** @@ -536,7 +543,8 @@ public class WifiVendorHalTest extends WifiBaseTest { verify(mIWifiStaIface).registerEventCallback(any(IWifiStaIfaceEventCallback.class)); verify(mHalDeviceManager, never()).getChip(any(IWifiIface.class)); - verify(mHalDeviceManager, never()).createApIface(any(), eq(null), any(), anyBoolean()); + verify(mHalDeviceManager, never()).createApIface( + anyLong(), any(), eq(null), any(), anyBoolean()); } /** @@ -557,7 +565,8 @@ public class WifiVendorHalTest extends WifiBaseTest { verify(mIWifiStaIface).registerEventCallback(any(IWifiStaIfaceEventCallback.class)); verify(mIWifiChip).registerEventCallback(any(IWifiChipEventCallback.class)); - verify(mHalDeviceManager, never()).createApIface(any(), eq(null), any(), anyBoolean()); + verify(mHalDeviceManager, never()).createApIface( + anyLong(), any(), eq(null), any(), anyBoolean()); } /** @@ -566,13 +575,13 @@ public class WifiVendorHalTest extends WifiBaseTest { */ @Test public void testStartHalFailureInApMode() throws Exception { - when(mHalDeviceManager.createApIface(any(), eq(null), any(), anyBoolean())) + when(mHalDeviceManager.createApIface(anyLong(), any(), eq(null), any(), anyBoolean())) .thenReturn(null); assertFalse(mWifiVendorHal.startVendorHalAp()); assertFalse(mWifiVendorHal.isHalStarted()); verify(mHalDeviceManager).start(); - verify(mHalDeviceManager).createApIface(any(), eq(null), any(), anyBoolean()); + verify(mHalDeviceManager).createApIface(anyLong(), any(), eq(null), any(), anyBoolean()); verify(mHalDeviceManager).stop(); verify(mHalDeviceManager, never()).createStaIface(any(), eq(null), any()); @@ -598,7 +607,8 @@ public class WifiVendorHalTest extends WifiBaseTest { verify(mHalDeviceManager, times(2)).isReady(); verify(mHalDeviceManager, times(2)).isStarted(); - verify(mHalDeviceManager, never()).createApIface(any(), eq(null), any(), anyBoolean()); + verify(mHalDeviceManager, never()).createApIface( + anyLong(), any(), eq(null), any(), anyBoolean()); } /** @@ -615,7 +625,8 @@ public class WifiVendorHalTest extends WifiBaseTest { verify(mHalDeviceManager).start(); verify(mHalDeviceManager).stop(); - verify(mHalDeviceManager).createApIface(any(), eq(null), any(), anyBoolean()); + verify(mHalDeviceManager).createApIface( + anyLong(), any(), eq(null), any(), anyBoolean()); verify(mHalDeviceManager).getChip(eq(mIWifiApIface)); verify(mHalDeviceManager, times(2)).isReady(); verify(mHalDeviceManager, times(2)).isStarted(); @@ -665,11 +676,12 @@ public class WifiVendorHalTest extends WifiBaseTest { InterfaceDestroyedListener externalLister = mock(InterfaceDestroyedListener.class); assertTrue(mWifiVendorHal.startVendorHal()); - assertNotNull(mWifiVendorHal.createApIface(externalLister, TEST_WORKSOURCE, false)); + assertNotNull(mWifiVendorHal.createApIface( + externalLister, TEST_WORKSOURCE, SoftApConfiguration.BAND_2GHZ, false)); assertTrue(mWifiVendorHal.isHalStarted()); verify(mHalDeviceManager).start(); - verify(mHalDeviceManager).createApIface( + verify(mHalDeviceManager).createApIface(anyLong(), internalListenerCaptor.capture(), eq(null), eq(TEST_WORKSOURCE), eq(false)); verify(mHalDeviceManager).getChip(eq(mIWifiApIface)); verify(mHalDeviceManager).isReady(); @@ -2559,8 +2571,10 @@ public class WifiVendorHalTest extends WifiBaseTest { }).when(mIWifiApIface).getName(any(IWifiIface.getNameCallback.class)); assertTrue(mWifiVendorHal.startVendorHal()); - assertNull(mWifiVendorHal.createApIface(null, TEST_WORKSOURCE, false)); - verify(mHalDeviceManager).createApIface(any(), eq(null), eq(TEST_WORKSOURCE), eq(false)); + assertNull(mWifiVendorHal.createApIface( + null, TEST_WORKSOURCE, SoftApConfiguration.BAND_2GHZ, false)); + verify(mHalDeviceManager).createApIface( + anyLong(), any(), eq(null), eq(TEST_WORKSOURCE), eq(false)); } /** @@ -2582,8 +2596,10 @@ public class WifiVendorHalTest extends WifiBaseTest { @Test public void testCreateRemoveApIface() throws RemoteException { assertTrue(mWifiVendorHal.startVendorHal()); - String ifaceName = mWifiVendorHal.createApIface(null, TEST_WORKSOURCE, false); - verify(mHalDeviceManager).createApIface(any(), eq(null), eq(TEST_WORKSOURCE), eq(false)); + String ifaceName = mWifiVendorHal.createApIface( + null, TEST_WORKSOURCE, SoftApConfiguration.BAND_2GHZ, false); + verify(mHalDeviceManager).createApIface( + anyLong(), any(), eq(null), eq(TEST_WORKSOURCE), eq(false)); assertEquals(TEST_IFACE_NAME, ifaceName); assertTrue(mWifiVendorHal.removeApIface(ifaceName)); verify(mHalDeviceManager).removeIface(eq(mIWifiApIface)); diff --git a/tests/wifitests/src/com/android/server/wifi/util/ApConfigUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/ApConfigUtilTest.java index e6fa2c256..17edffa41 100644 --- a/tests/wifitests/src/com/android/server/wifi/util/ApConfigUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/util/ApConfigUtilTest.java @@ -115,13 +115,21 @@ public class ApConfigUtilTest extends WifiBaseTest { /* Now some 6GHz channels */ 5955, SoftApConfiguration.BAND_6GHZ, 1, 5970, SoftApConfiguration.BAND_6GHZ, 4, - 6110, SoftApConfiguration.BAND_6GHZ, 32 + 6110, SoftApConfiguration.BAND_6GHZ, 32, + /* some 60GHz channels */ + 58320, SoftApConfiguration.BAND_60GHZ, 1, + 60480, SoftApConfiguration.BAND_60GHZ, 2, + 62640, SoftApConfiguration.BAND_60GHZ, 3, + 64800, SoftApConfiguration.BAND_60GHZ, 4, + 66960, SoftApConfiguration.BAND_60GHZ, 5, + 69120, SoftApConfiguration.BAND_60GHZ, 6, }; private static final int[] EMPTY_CHANNEL_LIST = {}; private static final int[] ALLOWED_2G_FREQS = {2462}; //ch# 11 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 @Mock Context mContext; @Mock Resources mResources; @@ -219,7 +227,7 @@ public class ApConfigUtilTest extends WifiBaseTest { public void isBandValidFailure() throws Exception { assertFalse(ApConfigUtil.isBandValid(0)); assertFalse(ApConfigUtil.isBandValid(SoftApConfiguration.BAND_2GHZ - | SoftApConfiguration.BAND_6GHZ | 0x0F)); + | SoftApConfiguration.BAND_6GHZ | 0x1F)); } /** @@ -313,6 +321,21 @@ public class ApConfigUtilTest extends WifiBaseTest { } /** + * Verify a 60G channel is selected from the list of allowed channels. + */ + @Test + public void chooseApChannel60GBandWithAllowedChannels() throws Exception { + when(mResources.getString(R.string.config_wifiSoftap60gChannelList)) + .thenReturn("1-2"); + when(mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_60_GHZ)) + .thenReturn(ALLOWED_60G_FREQS); //ch# 1, 2 + + int freq = ApConfigUtil.chooseApChannel( + SoftApConfiguration.BAND_60GHZ, mWifiNative, mResources); + assertTrue(ArrayUtils.contains(ALLOWED_60G_FREQS, freq)); + } + + /** * Verify chooseApChannel failed when selecting a channel in 5GHz band * with no channels allowed. */ |