summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/ThroughputPredictor.java15
-rw-r--r--service/java/com/android/server/wifi/WifiInjector.java2
-rw-r--r--service/res/values/config.xml7
-rw-r--r--service/res/values/overlayable.xml2
-rw-r--r--tests/wifitests/src/com/android/server/wifi/ThroughputPredictorTest.java55
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 23bb75ad0..b56d37a2c 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 be59e5dd1..0c88a258b 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 80d805176..06ae35b8c 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,