summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2018-05-14 15:55:26 -0700
committerRoshan Pius <rpius@google.com>2018-05-17 14:53:08 -0700
commitb4846aff56ffd388ff02400a144da80ff73b87bd (patch)
treec94a93c37f5c5f0311fea7747ef828ce82dcc0b2 /tests
parent8964a106164d84089c1ee52b62973c346115822b (diff)
WifiMetrics: Add metrics when softap band preference unsatisfied
Bug: 79701630 Test: Unit tests Test: Validated that the metric is updated when STA + AP forces the AP to not satisfy the band preference. (act.py -c softap_cross_onhub.config -tb dut-name -tc WifiStaApConcurrencyTest:test_wifi_connection_5G_DFS_softap_5G) Change-Id: Ib3131d25969a9d89f8b46f6dc788fb2a16324909
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java108
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java6
2 files changed, 108 insertions, 6 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
index 7534f78ce..0b937849d 100644
--- a/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SoftApManagerTest.java
@@ -42,6 +42,7 @@ import android.net.Uri;
import android.net.wifi.IApInterfaceEventCallback;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
+import android.net.wifi.WifiScanner;
import android.os.UserHandle;
import android.os.test.TestLooper;
import android.provider.Settings;
@@ -57,8 +58,6 @@ import org.mockito.InOrder;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.Locale;
@@ -72,13 +71,11 @@ public class SoftApManagerTest {
private static final String TEST_SSID = "TestSSID";
private static final String TEST_PASSWORD = "TestPassword";
private static final String TEST_COUNTRY_CODE = "TestCountry";
- private static final Integer[] ALLOWED_2G_CHANNELS = {1, 2, 3, 4};
private static final String TEST_INTERFACE_NAME = "testif0";
private static final String OTHER_INTERFACE_NAME = "otherif";
private static final int TEST_NUM_CONNECTED_CLIENTS = 4;
-
- private final ArrayList<Integer> mAllowed2GChannels =
- new ArrayList<>(Arrays.asList(ALLOWED_2G_CHANNELS));
+ private static final int[] ALLOWED_2G_CHANNELS = {2412, 2417, 2437};
+ private static final int[] ALLOWED_5G_CHANNELS = {5180, 5190, 5240};
private final WifiConfiguration mDefaultApConfig = createDefaultApConfig();
@@ -600,6 +597,105 @@ public class SoftApManagerTest {
}
@Test
+ public void updatesMetricsOnChannelSwitchedEventDetectsBandUnsatisfiedOnBand2Ghz()
+ throws Exception {
+ WifiConfiguration config = createDefaultApConfig();
+ config.apBand = WifiConfiguration.AP_BAND_2GHZ;
+
+ SoftApModeConfiguration apConfig =
+ new SoftApModeConfiguration(WifiManager.IFACE_IP_MODE_TETHERED, config);
+ startSoftApAndVerifyEnabled(apConfig);
+
+ final int channelFrequency = 2437;
+ final int channelBandwidth = IApInterfaceEventCallback.BANDWIDTH_20;
+ when(mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_24_GHZ))
+ .thenReturn(ALLOWED_5G_CHANNELS);
+ mSoftApListenerCaptor.getValue().onSoftApChannelSwitched(channelFrequency,
+ channelBandwidth);
+ mLooper.dispatchAll();
+
+ verify(mWifiNative).getChannelsForBand(WifiScanner.WIFI_BAND_24_GHZ);
+ verify(mWifiMetrics).addSoftApChannelSwitchedEvent(channelFrequency, channelBandwidth,
+ apConfig.getTargetMode());
+ verify(mWifiMetrics).incrementNumSoftApUserBandPreferenceUnsatisfied();
+ }
+
+ @Test
+ public void updatesMetricsOnChannelSwitchedEventDetectsBandUnsatisfiedOnBand5Ghz()
+ throws Exception {
+ WifiConfiguration config = createDefaultApConfig();
+ config.apBand = WifiConfiguration.AP_BAND_5GHZ;
+
+ SoftApModeConfiguration apConfig =
+ new SoftApModeConfiguration(WifiManager.IFACE_IP_MODE_TETHERED, config);
+ startSoftApAndVerifyEnabled(apConfig);
+
+ final int channelFrequency = 5180;
+ final int channelBandwidth = IApInterfaceEventCallback.BANDWIDTH_20;
+ when(mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ))
+ .thenReturn(ALLOWED_2G_CHANNELS);
+ mSoftApListenerCaptor.getValue().onSoftApChannelSwitched(channelFrequency,
+ channelBandwidth);
+ mLooper.dispatchAll();
+
+ verify(mWifiNative).getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ);
+ verify(mWifiMetrics).addSoftApChannelSwitchedEvent(channelFrequency, channelBandwidth,
+ apConfig.getTargetMode());
+ verify(mWifiMetrics).incrementNumSoftApUserBandPreferenceUnsatisfied();
+ }
+
+ @Test
+ public void updatesMetricsOnChannelSwitchedEventDetectsBandUnsatisfiedOnBandAny()
+ throws Exception {
+ WifiConfiguration config = createDefaultApConfig();
+ config.apBand = WifiConfiguration.AP_BAND_ANY;
+
+ SoftApModeConfiguration apConfig =
+ new SoftApModeConfiguration(WifiManager.IFACE_IP_MODE_TETHERED, config);
+ startSoftApAndVerifyEnabled(apConfig);
+
+ final int channelFrequency = 2437;
+ final int channelBandwidth = IApInterfaceEventCallback.BANDWIDTH_20;
+ when(mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_24_GHZ))
+ .thenReturn(new int[0]);
+ when(mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ))
+ .thenReturn(new int[0]);
+ mSoftApListenerCaptor.getValue().onSoftApChannelSwitched(channelFrequency,
+ channelBandwidth);
+ mLooper.dispatchAll();
+
+ verify(mWifiNative).getChannelsForBand(WifiScanner.WIFI_BAND_24_GHZ);
+ verify(mWifiNative).getChannelsForBand(WifiScanner.WIFI_BAND_5_GHZ);
+ verify(mWifiMetrics).addSoftApChannelSwitchedEvent(channelFrequency, channelBandwidth,
+ apConfig.getTargetMode());
+ verify(mWifiMetrics).incrementNumSoftApUserBandPreferenceUnsatisfied();
+ }
+
+ @Test
+ public void updatesMetricsOnChannelSwitchedEventDetectsBandUnsatisfiedOnlyWhenRequired()
+ throws Exception {
+ WifiConfiguration config = createDefaultApConfig();
+ config.apBand = WifiConfiguration.AP_BAND_2GHZ;
+
+ SoftApModeConfiguration apConfig =
+ new SoftApModeConfiguration(WifiManager.IFACE_IP_MODE_TETHERED, config);
+ startSoftApAndVerifyEnabled(apConfig);
+
+ final int channelFrequency = 2437;
+ final int channelBandwidth = IApInterfaceEventCallback.BANDWIDTH_20;
+ when(mWifiNative.getChannelsForBand(WifiScanner.WIFI_BAND_24_GHZ))
+ .thenReturn(ALLOWED_2G_CHANNELS);
+ mSoftApListenerCaptor.getValue().onSoftApChannelSwitched(channelFrequency,
+ channelBandwidth);
+ mLooper.dispatchAll();
+
+ verify(mWifiNative).getChannelsForBand(WifiScanner.WIFI_BAND_24_GHZ);
+ verify(mWifiMetrics).addSoftApChannelSwitchedEvent(channelFrequency, channelBandwidth,
+ apConfig.getTargetMode());
+ verify(mWifiMetrics, never()).incrementNumSoftApUserBandPreferenceUnsatisfied();
+ }
+
+ @Test
public void updatesNumAssociatedStations() throws Exception {
SoftApModeConfiguration apConfig =
new SoftApModeConfiguration(WifiManager.IFACE_IP_MODE_TETHERED, null);
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
index 9b9bce33d..3e267196e 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiMetricsTest.java
@@ -290,6 +290,7 @@ public class WifiMetricsTest {
private static final int NUM_RADIO_MODE_CHANGE_TO_SCC = 13;
private static final int NUM_RADIO_MODE_CHANGE_TO_SBS = 19;
private static final int NUM_RADIO_MODE_CHANGE_TO_DBS = 34;
+ private static final int NUM_SOFTAP_USER_BAND_PREFERENCE_UNSATISFIED = 14;
private static final long NUM_WATCHDOG_SUCCESS_DURATION_MS = 65;
/** Number of notifications per "Connect to Network" notification type. */
@@ -604,6 +605,9 @@ public class WifiMetricsTest {
for (int i = 0; i < NUM_RADIO_MODE_CHANGE_TO_DBS; i++) {
mWifiMetrics.incrementNumRadioModeChangeToDbs();
}
+ for (int i = 0; i < NUM_SOFTAP_USER_BAND_PREFERENCE_UNSATISFIED; i++) {
+ mWifiMetrics.incrementNumSoftApUserBandPreferenceUnsatisfied();
+ }
// increment pno scan metrics
for (int i = 0; i < NUM_PNO_SCAN_ATTEMPTS; i++) {
@@ -902,6 +906,8 @@ public class WifiMetricsTest {
assertEquals(NUM_RADIO_MODE_CHANGE_TO_SCC, mDecodedProto.numRadioModeChangeToScc);
assertEquals(NUM_RADIO_MODE_CHANGE_TO_SBS, mDecodedProto.numRadioModeChangeToSbs);
assertEquals(NUM_RADIO_MODE_CHANGE_TO_DBS, mDecodedProto.numRadioModeChangeToDbs);
+ assertEquals(NUM_SOFTAP_USER_BAND_PREFERENCE_UNSATISFIED,
+ mDecodedProto.numSoftApUserBandPreferenceUnsatisfied);
PnoScanMetrics pno_metrics = mDecodedProto.pnoScanMetrics;
assertNotNull(pno_metrics);