diff options
author | Kai Shi <kaishi@google.com> | 2020-04-10 17:07:25 -0700 |
---|---|---|
committer | Kai Shi <kaishi@google.com> | 2020-04-10 17:07:25 -0700 |
commit | c68b442944045d2ba496d862402361d3886a3c10 (patch) | |
tree | 39c390e21a99807d89753fdd53f2185ccc782687 | |
parent | 82298418fe24c1d0d8f62ba1b79e55d168bf6351 (diff) |
Mitigation of incorrect maxNumSpatialStreamDevice.
Many android devices will set maxNumSpatialStreamDevice incorrectly to 8
due to a WLAN driver bug. The bug fix is being ported but not expected
to be applied to all affected products on time. As a mitigation method,
add overriding enable flag and value in config overlay file to override
maxNumSpatialStreamDevice to a correct value before the bug fix is
completely populated. The enable flag is set by default with a default
overriding value of 2. Final settings can be configured per device.
Bug: 148982542
Test: atest com.android.server.wifi
Change-Id: I7b95a0b7f5685ab8b841113ff7136723d8b04250
5 files changed, 78 insertions, 3 deletions
diff --git a/service/java/com/android/server/wifi/ThroughputPredictor.java b/service/java/com/android/server/wifi/ThroughputPredictor.java index e381b2b14..9a33863e4 100644 --- a/service/java/com/android/server/wifi/ThroughputPredictor.java +++ b/service/java/com/android/server/wifi/ThroughputPredictor.java @@ -20,12 +20,15 @@ import static com.android.server.wifi.util.InformationElementUtil.BssLoad.MAX_CH import static com.android.server.wifi.util.InformationElementUtil.BssLoad.MIN_CHANNEL_UTILIZATION; import android.annotation.NonNull; +import android.content.Context; import android.net.wifi.ScanResult; import android.net.wifi.WifiAnnotations.WifiStandard; import android.net.wifi.WifiInfo; import android.net.wifi.nl80211.DeviceWiphyCapabilities; import android.util.Log; +import com.android.wifi.resources.R; + /** * A class that predicts network throughput based on RSSI, channel utilization, channel width, * WiFi standard (PHY/MAC mode), Nss and other radio information. @@ -97,6 +100,12 @@ public class ThroughputPredictor { private static final int MAX_NUM_SPATIAL_STREAM_11N = 4; private static final int MAX_NUM_SPATIAL_STREAM_LEGACY = 1; + private final Context mContext; + + ThroughputPredictor(Context context) { + mContext = context; + } + /** * Enable/Disable verbose logging. * @@ -177,6 +186,12 @@ public class ThroughputPredictor { int maxNumSpatialStreamDevice = Math.min(deviceCapabilities.getMaxNumberTxSpatialStreams(), deviceCapabilities.getMaxNumberRxSpatialStreams()); + if (mContext.getResources().getBoolean( + R.bool.config_wifiFrameworkMaxNumSpatialStreamDeviceOverrideEnable)) { + maxNumSpatialStreamDevice = mContext.getResources().getInteger( + R.integer.config_wifiFrameworkMaxNumSpatialStreamDeviceOverrideValue); + } + int maxNumSpatialStream = Math.min(maxNumSpatialStreamDevice, maxNumSpatialStreamAp); // Get minimum standard support between device and AP diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java index 594008975..c6692d2fc 100644 --- a/service/java/com/android/server/wifi/WifiInjector.java +++ b/service/java/com/android/server/wifi/WifiInjector.java @@ -286,7 +286,7 @@ public class WifiInjector { mContext.getSystemService(ActivityManager.class).isLowRamDevice() ? 256 : 512); mScoringParams = new ScoringParams(mContext); mWifiMetrics.setScoringParams(mScoringParams); - mThroughputPredictor = new ThroughputPredictor(); + mThroughputPredictor = new ThroughputPredictor(mContext); mWifiNetworkSelector = new WifiNetworkSelector(mContext, mWifiScoreCard, mScoringParams, mWifiConfigManager, mClock, mConnectivityLocalLog, mWifiMetrics, mWifiNative, mThroughputPredictor); diff --git a/service/res/values/config.xml b/service/res/values/config.xml index 4d351b105..dd5b75f71 100644 --- a/service/res/values/config.xml +++ b/service/res/values/config.xml @@ -36,6 +36,13 @@ be checked via NL80211 interface --> <bool translatable="false" name="config_wifi11axSupportOverride">false</bool> + <!-- Indicates whether to enable overriding the max number of spatial stream supported by the device + If true, config_wifiFrameworkMaxNumSpatialStreamDeviceOverrideValue + will be used to override the max number of spatial stream supported by the device. + If false, it will be left to WifiCond to derive the value from NL80211 interface --> + <bool translatable="false" name="config_wifiFrameworkMaxNumSpatialStreamDeviceOverrideEnable">true</bool> + <integer translatable="false" name="config_wifiFrameworkMaxNumSpatialStreamDeviceOverrideValue">2</integer> + <!-- Boolean indicating whether 802.11r Fast BSS Transition is enabled on this platform --> <bool translatable="false" name="config_wifi_fast_bss_transition_enabled">false</bool> diff --git a/service/res/values/overlayable.xml b/service/res/values/overlayable.xml index 7244911af..bc2c06cc3 100644 --- a/service/res/values/overlayable.xml +++ b/service/res/values/overlayable.xml @@ -23,6 +23,8 @@ <item type="bool" name="config_wifi5ghzSupport" /> <item type="bool" name="config_wifi6ghzSupport" /> <item type="bool" name="config_wifi11axSupportOverride" /> + <item type="bool" name="config_wifiFrameworkMaxNumSpatialStreamDeviceOverrideEnable" /> + <item type="integer" name="config_wifiFrameworkMaxNumSpatialStreamDeviceOverrideValue" /> <item type="bool" name="config_wifi_fast_bss_transition_enabled" /> <item type="string" name="config_wifi_p2p_device_type" /> <item type="bool" name="config_wifi_background_scan_support" /> diff --git a/tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java b/tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java index aa3010a33..f8b0586ee 100644 --- a/tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java +++ b/tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java @@ -24,16 +24,20 @@ import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.validateMockitoUsage; import static org.mockito.Mockito.when; +import android.content.Context; import android.net.wifi.ScanResult; import android.net.wifi.nl80211.DeviceWiphyCapabilities; import androidx.test.filters.SmallTest; +import com.android.wifi.resources.R; + import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.mockito.Spy; /** * Unit tests for {@link com.android.server.wifi.ThroughputPredictor}. @@ -41,7 +45,12 @@ import org.mockito.MockitoAnnotations; @SmallTest public class ThroughputPredictorTest extends WifiBaseTest { @Mock private DeviceWiphyCapabilities mDeviceCapabilities; - + @Mock private Context mContext; + // For simulating the resources, we use a Spy on a MockResource + // (which is really more of a stub than a mock, in spite if its name). + // This is so that we get errors on any calls that we have not explicitly set up. + @Spy + private MockResources mResource = new MockResources(); ThroughputPredictor mThroughputPredictor; WifiNative.ConnectionCapabilities mConnectionCap = new WifiNative.ConnectionCapabilities(); @@ -67,7 +76,14 @@ public class ThroughputPredictorTest extends WifiBaseTest { when(mDeviceCapabilities.getMaxNumberTxSpatialStreams()).thenReturn(2); when(mDeviceCapabilities.getMaxNumberRxSpatialStreams()).thenReturn(2); - mThroughputPredictor = new ThroughputPredictor(); + when(mResource.getBoolean( + R.bool.config_wifiFrameworkMaxNumSpatialStreamDeviceOverrideEnable)) + .thenReturn(false); + when(mResource.getInteger( + R.integer.config_wifiFrameworkMaxNumSpatialStreamDeviceOverrideValue)) + .thenReturn(2); + when(mContext.getResources()).thenReturn(mResource); + mThroughputPredictor = new ThroughputPredictor(mContext); } /** Cleans up test. */ @@ -113,6 +129,21 @@ public class ThroughputPredictorTest extends WifiBaseTest { } @Test + public void verifyHighRssiMinChannelUtilizationAc5g80Mhz2ssOverriddenTo1ss() { + when(mResource.getBoolean( + R.bool.config_wifiFrameworkMaxNumSpatialStreamDeviceOverrideEnable)) + .thenReturn(true); + when(mResource.getInteger( + R.integer.config_wifiFrameworkMaxNumSpatialStreamDeviceOverrideValue)) + .thenReturn(1); + int predictedThroughputMbps = mThroughputPredictor.predictThroughput(mDeviceCapabilities, + ScanResult.WIFI_STANDARD_11AC, ScanResult.CHANNEL_WIDTH_80MHZ, 0, 5180, 2, + MIN_CHANNEL_UTILIZATION, 50, false); + + assertEquals(433, predictedThroughputMbps); + } + + @Test public void verifyHighRssiMinChannelUtilizationAx5g160Mhz4ss() { when(mDeviceCapabilities.isWifiStandardSupported(ScanResult.WIFI_STANDARD_11AX)) .thenReturn(true); @@ -129,6 +160,26 @@ public class ThroughputPredictorTest extends WifiBaseTest { } @Test + public void verifyHighRssiMinChannelUtilizationAx5g160Mhz4ssOverriddenTo2ss() { + when(mResource.getBoolean( + R.bool.config_wifiFrameworkMaxNumSpatialStreamDeviceOverrideEnable)) + .thenReturn(true); + when(mDeviceCapabilities.isWifiStandardSupported(ScanResult.WIFI_STANDARD_11AX)) + .thenReturn(true); + when(mDeviceCapabilities.isChannelWidthSupported(ScanResult.CHANNEL_WIDTH_160MHZ)) + .thenReturn(true); + when(mDeviceCapabilities.getMaxNumberTxSpatialStreams()).thenReturn(4); + when(mDeviceCapabilities.getMaxNumberRxSpatialStreams()).thenReturn(4); + + int predictedThroughputMbps = mThroughputPredictor.predictThroughput(mDeviceCapabilities, + ScanResult.WIFI_STANDARD_11AX, ScanResult.CHANNEL_WIDTH_160MHZ, 0, 5180, 4, + MIN_CHANNEL_UTILIZATION, INVALID, false); + + assertEquals(2401, predictedThroughputMbps); + } + + + @Test public void verifyMidRssiMinChannelUtilizationAc5g80Mhz2ss() { int predictedThroughputMbps = mThroughputPredictor.predictThroughput(mDeviceCapabilities, ScanResult.WIFI_STANDARD_11AC, ScanResult.CHANNEL_WIDTH_80MHZ, -50, 5180, 2, |