summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2020-04-22 16:52:46 -0700
committerRoshan Pius <rpius@google.com>2020-04-23 14:36:38 -0700
commite0e4592a0efe0170ad5a5e162253306f7d0f21fc (patch)
tree97798c26eacc73f13059eb30cdbee775916d25bc /tests
parent19df2d0dfa75acecef66737dee97e605bd2b00a3 (diff)
WifiNetworkFactory: Don't use WifiConfig from UI for matching
The WifiConfiguration passed in from the UI in the NetworkRequestUserSelectionCallback.select() only has the SSID field set (in hindsight the select() API should just have accepted a string param instead of WifiConfiguration). The rest of params including security params are constructed from the original app's request. Ensure that we use the merged WifiConfiguration to find matching scan results to set bssid for connection. Also, fixed the unit tests to reflect the correct behavior from UI (only set the SSID field in WifiConfiguration). The unit tests were incorrectly setting the securiy params and masking the problem. Bug: 154764757 Test: act.py -c wifi_manager_cross.config -tb dut-name -tc WifiNetworkRequestTest Test: atest com.android.server.wifi Change-Id: I611e05f15a0e1fff3cdbc1f6d0e2347653446678
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java28
1 files changed, 18 insertions, 10 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
index b495b49c7..ff31eb223 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkFactoryTest.java
@@ -1036,7 +1036,7 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Now trigger user selection to some network.
WifiConfiguration selectedNetwork = WifiConfigurationTestUtil.createOpenNetwork();
- networkRequestUserSelectionCallback.select(selectedNetwork);
+ sendUserSelectionSelect(networkRequestUserSelectionCallback, selectedNetwork);
mLooper.dispatchAll();
// Verify we did not attempt to trigger a connection or disable connectivity manager.
@@ -1060,7 +1060,7 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Now trigger user selection to some network.
WifiConfiguration selectedNetwork = WifiConfigurationTestUtil.createOpenNetwork();
- networkRequestUserSelectionCallback.select(selectedNetwork);
+ sendUserSelectionSelect(networkRequestUserSelectionCallback, selectedNetwork);
mLooper.dispatchAll();
// Verify we did not attempt to trigger a connection or disable connectivity manager.
@@ -1082,7 +1082,7 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
ScanResult matchingScanResult = mTestScanDatas[0].getResults()[0];
mSelectedNetwork = WifiConfigurationTestUtil.createPskNetwork();
mSelectedNetwork.SSID = "\"" + mTestScanDatas[0].getResults()[0].SSID + "\"";
- networkRequestUserSelectionCallback.select(mSelectedNetwork);
+ sendUserSelectionSelect(networkRequestUserSelectionCallback, mSelectedNetwork);
mLooper.dispatchAll();
// Cancel periodic scans.
@@ -1140,7 +1140,7 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Now trigger user selection to one of the network.
mSelectedNetwork = WifiConfigurationTestUtil.createPskNetwork();
mSelectedNetwork.SSID = "\"" + mTestScanDatas[0].getResults()[0].SSID + "\"";
- networkRequestUserSelectionCallback.select(mSelectedNetwork);
+ sendUserSelectionSelect(networkRequestUserSelectionCallback, mSelectedNetwork);
mLooper.dispatchAll();
// Verifier num of Approved access points.
@@ -1150,7 +1150,7 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Now trigger user selection to another network with different SSID.
mSelectedNetwork = WifiConfigurationTestUtil.createPskNetwork();
mSelectedNetwork.SSID = "\"" + mTestScanDatas[0].getResults()[numOfApPerSsid].SSID + "\"";
- networkRequestUserSelectionCallback.select(mSelectedNetwork);
+ sendUserSelectionSelect(networkRequestUserSelectionCallback, mSelectedNetwork);
mLooper.dispatchAll();
// Verify triggered trim when user Approved Access Points exceed capacity.
@@ -1187,7 +1187,7 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
.thenReturn(matchingSavedNetwork);
// Now trigger user selection to one of the network.
- networkRequestUserSelectionCallback.select(mSelectedNetwork);
+ sendUserSelectionSelect(networkRequestUserSelectionCallback, mSelectedNetwork);
mLooper.dispatchAll();
// Cancel periodic scans.
@@ -1240,7 +1240,7 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
INetworkRequestUserSelectionCallback networkRequestUserSelectionCallback =
mNetworkRequestUserSelectionCallback.getValue();
assertNotNull(networkRequestUserSelectionCallback);
- networkRequestUserSelectionCallback.select(mSelectedNetwork);
+ sendUserSelectionSelect(networkRequestUserSelectionCallback, mSelectedNetwork);
mLooper.dispatchAll();
// Verify WifiConfiguration params.
@@ -1291,7 +1291,7 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
INetworkRequestUserSelectionCallback networkRequestUserSelectionCallback =
mNetworkRequestUserSelectionCallback.getValue();
assertNotNull(networkRequestUserSelectionCallback);
- networkRequestUserSelectionCallback.select(mSelectedNetwork);
+ sendUserSelectionSelect(networkRequestUserSelectionCallback, mSelectedNetwork);
mLooper.dispatchAll();
// Verify WifiConfiguration params.
@@ -1734,7 +1734,7 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Ignore stale callbacks.
WifiConfiguration selectedNetwork = WifiConfigurationTestUtil.createOpenNetwork();
- networkRequestUserSelectionCallback.select(selectedNetwork);
+ sendUserSelectionSelect(networkRequestUserSelectionCallback, selectedNetwork);
mLooper.dispatchAll();
verify(mNetworkRequestMatchCallback).onAbort();
@@ -2713,7 +2713,7 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
// Now trigger user selection to one of the network.
mSelectedNetwork = WifiConfigurationTestUtil.createPskNetwork();
mSelectedNetwork.SSID = "\"" + targetSsid + "\"";
- networkRequestUserSelectionCallback.select(mSelectedNetwork);
+ sendUserSelectionSelect(networkRequestUserSelectionCallback, mSelectedNetwork);
mLooper.dispatchAll();
// Cancel the periodic scan timer.
@@ -3055,4 +3055,12 @@ public class WifiNetworkFactoryTest extends WifiBaseTest {
WifiConfigStore.ENCRYPT_CREDENTIALS_CONFIG_STORE_DATA_VERSION,
mock(WifiConfigStoreEncryptionUtil.class));
}
+
+ private void sendUserSelectionSelect(INetworkRequestUserSelectionCallback callback,
+ WifiConfiguration selectedNetwork) throws RemoteException {
+ WifiConfiguration selectedNetworkinCb = new WifiConfiguration();
+ // only copy over the ssid
+ selectedNetworkinCb.SSID = selectedNetwork.SSID;
+ callback.select(selectedNetworkinCb);
+ }
}