summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorOscar Shu <xshu@google.com>2019-11-20 19:17:51 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-11-20 19:17:51 +0000
commit174cd54dd6f84414dcc8d4b354dd679f450b1c80 (patch)
tree8d3431ff9a5f40d21d6eb7364555a230a14a06d4 /tests
parent7be5a9d761365d4654565837fc51e207396fdc54 (diff)
parenta522b345fa15716a21fd9edcf523cf3c1331dd94 (diff)
Merge changes from topic "macRandNotification"
* changes: Detect networks in SSID hotlist Add SSID hotlist in DeviceConfig
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java19
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java27
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java b/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java
index e23d402aa..900d3a7f3 100644
--- a/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/DeviceConfigFacadeTest.java
@@ -28,6 +28,7 @@ import android.os.Handler;
import android.os.test.TestLooper;
import android.provider.DeviceConfig;
import android.provider.DeviceConfig.OnPropertiesChangedListener;
+import android.util.ArraySet;
import androidx.test.filters.SmallTest;
@@ -42,6 +43,9 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.MockitoSession;
+import java.util.Collections;
+import java.util.Set;
+
/**
* Unit tests for {@link com.android.server.wifi.DeviceConfigFacade}.
@@ -88,6 +92,12 @@ public class DeviceConfigFacadeTest extends WifiBaseTest {
return def;
}
});
+ when(DeviceConfig.getString(anyString(), anyString(), anyString()))
+ .then(new AnswerWithArguments() {
+ public String answer(String namespace, String field, String def) {
+ return def;
+ }
+ });
mDeviceConfigFacade = new DeviceConfigFacade(mContext, new Handler(mLooper.getLooper()),
mWifiMetrics);
@@ -125,6 +135,8 @@ public class DeviceConfigFacadeTest extends WifiBaseTest {
mDeviceConfigFacade.getDataStallTxPerThr());
assertEquals(DeviceConfigFacade.DEFAULT_DATA_STALL_CCA_LEVEL_THR,
mDeviceConfigFacade.getDataStallCcaLevelThr());
+ assertEquals(Collections.emptySet(),
+ mDeviceConfigFacade.getRandomizationFlakySsidHotlist());
// Simulate updating the fields
when(DeviceConfig.getBoolean(anyString(), eq("abnormal_connection_bugreport_enabled"),
@@ -144,9 +156,14 @@ public class DeviceConfigFacadeTest extends WifiBaseTest {
anyInt())).thenReturn(95);
when(DeviceConfig.getInt(anyString(), eq("data_stall_cca_level_thr"),
anyInt())).thenReturn(80);
+ when(DeviceConfig.getString(anyString(), eq("randomization_flaky_ssid_hotlist"),
+ anyString())).thenReturn("ssid_1,ssid_2");
mOnPropertiesChangedListenerCaptor.getValue().onPropertiesChanged(null);
// Verifying fields are updated to the new values
+ Set<String> randomizationFlakySsidSet = new ArraySet<>();
+ randomizationFlakySsidSet.add("\"ssid_1\"");
+ randomizationFlakySsidSet.add("\"ssid_2\"");
assertEquals(true, mDeviceConfigFacade.isAbnormalConnectionBugreportEnabled());
assertEquals(100, mDeviceConfigFacade.getAbnormalConnectionDurationMs());
assertEquals(true, mDeviceConfigFacade.isAggressiveMacRandomizationSsidWhitelistEnabled());
@@ -155,5 +172,7 @@ public class DeviceConfigFacadeTest extends WifiBaseTest {
assertEquals(1500, mDeviceConfigFacade.getDataStallRxTputThrKbps());
assertEquals(95, mDeviceConfigFacade.getDataStallTxPerThr());
assertEquals(80, mDeviceConfigFacade.getDataStallCcaLevelThr());
+ assertEquals(randomizationFlakySsidSet,
+ mDeviceConfigFacade.getRandomizationFlakySsidHotlist());
}
}
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
index 4ad2a251e..203250e9f 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigManagerTest.java
@@ -5592,6 +5592,33 @@ public class WifiConfigManagerTest extends WifiBaseTest {
}
/**
+ * Verifies that isInFlakyRandomizationSsidHotlist returns true if the network's SSID is in
+ * the hotlist and the network is using randomized MAC.
+ */
+ @Test
+ public void testFlakyRandomizationSsidHotlist() {
+ WifiConfiguration openNetwork = WifiConfigurationTestUtil.createOpenNetwork();
+ NetworkUpdateResult result = verifyAddNetworkToWifiConfigManager(openNetwork);
+ int networkId = result.getNetworkId();
+
+ // should return false when there is nothing in the hotlist
+ assertFalse(mWifiConfigManager.isInFlakyRandomizationSsidHotlist(networkId));
+
+ // add the network's SSID to the hotlist and verify the method returns true
+ Set<String> ssidHotlist = new HashSet<>();
+ ssidHotlist.add(openNetwork.SSID);
+ when(mDeviceConfigFacade.getRandomizationFlakySsidHotlist()).thenReturn(ssidHotlist);
+ assertTrue(mWifiConfigManager.isInFlakyRandomizationSsidHotlist(networkId));
+
+ // Now change the macRandomizationSetting to "trusted" and then verify
+ // isInFlakyRandomizationSsidHotlist returns false
+ openNetwork.macRandomizationSetting = WifiConfiguration.RANDOMIZATION_NONE;
+ NetworkUpdateResult networkUpdateResult = updateNetworkToWifiConfigManager(openNetwork);
+ assertNotEquals(WifiConfiguration.INVALID_NETWORK_ID, networkUpdateResult.getNetworkId());
+ assertFalse(mWifiConfigManager.isInFlakyRandomizationSsidHotlist(networkId));
+ }
+
+ /**
* Verifies that when scanning a WPA3 in transition mode AP, and there is a matching WPA2 saved
* network, {@link WifiConfigManager#getConfiguredNetworkForScanDetailAndCache(ScanDetail)}
* clones a new WPA3 saved network that will be used to connect to it.