summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-05-02 02:24:40 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-05-02 02:24:40 +0000
commit2eeb28d2fe35854db0ca672443314712cb65cfd1 (patch)
treedcb9d2f3c64873b8a176ac854ab7bade80fdbc10
parent207079994b7e0ba2183161194a9d4edda41cc62c (diff)
parent564f3f8861c44011f73de533cc6c4372fed49e90 (diff)
Merge "Remove auto-join check PasspointNetworkNominateHelper" into rvc-dev
-rw-r--r--service/java/com/android/server/wifi/SavedNetworkNominator.java3
-rw-r--r--service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java3
-rw-r--r--tests/wifitests/src/com/android/server/wifi/SavedNetworkNominatorTest.java25
-rw-r--r--tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelperTest.java68
4 files changed, 18 insertions, 81 deletions
diff --git a/service/java/com/android/server/wifi/SavedNetworkNominator.java b/service/java/com/android/server/wifi/SavedNetworkNominator.java
index 6480237ef..3c94bed9d 100644
--- a/service/java/com/android/server/wifi/SavedNetworkNominator.java
+++ b/service/java/com/android/server/wifi/SavedNetworkNominator.java
@@ -177,6 +177,9 @@ public class SavedNetworkNominator implements WifiNetworkSelector.NetworkNominat
mPasspointNetworkNominateHelper.getPasspointNetworkCandidates(scanDetails, false);
for (Pair<ScanDetail, WifiConfiguration> candidate : candidates) {
WifiConfiguration config = candidate.second;
+ if (!config.allowAutojoin) {
+ continue;
+ }
if (isNetworkSimBasedCredential(config) && !isSimBasedNetworkAbleToAutoJoin(config)) {
continue;
}
diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java b/service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java
index 0a5da1f7c..e1491aa7a 100644
--- a/service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java
+++ b/service/java/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelper.java
@@ -146,9 +146,6 @@ public class PasspointNetworkNominateHelper {
if (matchedProvider.first.isFromSuggestion() != isFromSuggestion) {
continue;
}
- if (!matchedProvider.first.isAutojoinEnabled()) {
- continue;
- }
List<PasspointNetworkCandidate> candidates = candidatesPerProvider
.computeIfAbsent(matchedProvider.first, k -> new ArrayList<>());
candidates.add(new PasspointNetworkCandidate(matchedProvider.first,
diff --git a/tests/wifitests/src/com/android/server/wifi/SavedNetworkNominatorTest.java b/tests/wifitests/src/com/android/server/wifi/SavedNetworkNominatorTest.java
index 2a42c77e5..33e61a44f 100644
--- a/tests/wifitests/src/com/android/server/wifi/SavedNetworkNominatorTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/SavedNetworkNominatorTest.java
@@ -38,7 +38,7 @@ import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
/**
@@ -229,21 +229,26 @@ public class SavedNetworkNominatorTest extends WifiBaseTest {
}
/**
- * Ensure that we do nominate the only matching saved passponit network .
+ * Ensure that we do nominate the only matching saved passponit network with auto-join enabled .
*/
@Test
- public void returnCandidatesIfPasspointNetworksAvailable() {
- ScanDetail scanDetail = mock(ScanDetail.class);
- List<ScanDetail> scanDetails = new ArrayList<>();
- scanDetails.add(scanDetail);
- WifiConfiguration configuration = mock(WifiConfiguration.class);
- List<Pair<ScanDetail, WifiConfiguration>> passpointCandidates = new ArrayList<>();
- passpointCandidates.add(Pair.create(scanDetail, configuration));
+ public void returnCandidatesIfPasspointNetworksAvailableWithAutojoinEnabled() {
+ ScanDetail scanDetail1 = mock(ScanDetail.class);
+ ScanDetail scanDetail2 = mock(ScanDetail.class);
+ List<ScanDetail> scanDetails = Arrays.asList(scanDetail1, scanDetail2);
+ WifiConfiguration configuration1 = mock(WifiConfiguration.class);
+ configuration1.allowAutojoin = true;
+ WifiConfiguration configuration2 = mock(WifiConfiguration.class);
+ configuration2.allowAutojoin = false;
+ List<Pair<ScanDetail, WifiConfiguration>> passpointCandidates =
+ Arrays.asList(Pair.create(scanDetail1, configuration1), Pair.create(scanDetail2,
+ configuration2));
when(mPasspointNetworkNominateHelper.getPasspointNetworkCandidates(scanDetails, false))
.thenReturn(passpointCandidates);
mSavedNetworkNominator.nominateNetworks(scanDetails, null, null,
false, false, mOnConnectableListener);
- verify(mOnConnectableListener).onConnectable(scanDetail, configuration);
+ verify(mOnConnectableListener).onConnectable(scanDetail1, configuration1);
+ verify(mOnConnectableListener, never()).onConnectable(scanDetail2, configuration2);
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelperTest.java b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelperTest.java
index 32fcb7093..a361a19bc 100644
--- a/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelperTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/hotspot2/PasspointNetworkNominateHelperTest.java
@@ -320,74 +320,6 @@ public class PasspointNetworkNominateHelperTest {
}
/**
- * Verify that when a network matches a roaming provider is found for different scanDetails,
- * will nominate only the candidate with auto-join enabled.
- */
- @Test
- public void evaluateScansWithHomeProviderNetworkAndRoamingProviderNetworkAutoJoinSomeoff() {
- List<ScanDetail> scanDetails = Arrays.asList(generateScanDetail(TEST_SSID1, TEST_BSSID1),
- generateScanDetail(TEST_SSID2, TEST_BSSID2));
-
- // Setup matching providers for ScanDetail with TEST_SSID1.
- when(sTestProvider1.isAutojoinEnabled()).thenReturn(false); // disable auto-join on provider
- List<Pair<PasspointProvider, PasspointMatch>> homeProvider = new ArrayList<>();
- homeProvider.add(Pair.create(sTestProvider1, PasspointMatch.HomeProvider));
- List<Pair<PasspointProvider, PasspointMatch>> roamingProvider = new ArrayList<>();
- roamingProvider.add(Pair.create(sTestProvider2, PasspointMatch.RoamingProvider));
-
- // Return homeProvider for the first ScanDetail (TEST_SSID1) and
- // roamingProvider for the second (TEST_SSID2);
- when(mPasspointManager.matchProvider(any(ScanResult.class)))
- .thenReturn(homeProvider).thenReturn(roamingProvider);
- when(mWifiConfigManager.addOrUpdateNetwork(any(WifiConfiguration.class), anyInt(),
- any())).thenReturn(new NetworkUpdateResult(TEST_NETWORK_ID + 1));
- when(mWifiConfigManager.getConfiguredNetwork(TEST_NETWORK_ID)).thenReturn(TEST_CONFIG1);
- when(mWifiConfigManager.getConfiguredNetwork(TEST_NETWORK_ID + 1))
- .thenReturn(TEST_CONFIG2);
- List<Pair<ScanDetail, WifiConfiguration>> candidates = mNominateHelper
- .getPasspointNetworkCandidates(scanDetails, false);
- assertEquals(1, candidates.size());
- assertEquals(TEST_FQDN2, candidates.get(0).second.FQDN);
-
- verify(mWifiConfigManager).addOrUpdateNetwork(any(), anyInt(), any());
- }
-
- /**
- * Verify that when a network matches a roaming provider is found for different scanDetails,
- * and if all have auto-join disabled - will nominate no candidates.
- */
- @Test
- public void evaluateScansWithHomeProviderNetworkAndRoamingProviderNetworkAutoJoinAllOff() {
- List<ScanDetail> scanDetails = Arrays.asList(generateScanDetail(TEST_SSID1, TEST_BSSID1),
- generateScanDetail(TEST_SSID2, TEST_BSSID2));
-
- // Setup matching providers for ScanDetail with TEST_SSID1.
- when(sTestProvider1.isAutojoinEnabled()).thenReturn(false); // disable auto-join on provider
- when(sTestProvider2.isAutojoinEnabled()).thenReturn(false); // disable auto-join on provider
- List<Pair<PasspointProvider, PasspointMatch>> homeProvider = new ArrayList<>();
- homeProvider.add(Pair.create(sTestProvider1, PasspointMatch.HomeProvider));
- List<Pair<PasspointProvider, PasspointMatch>> roamingProvider = new ArrayList<>();
- roamingProvider.add(Pair.create(sTestProvider2, PasspointMatch.RoamingProvider));
-
- // Return homeProvider for the first ScanDetail (TEST_SSID1) and
- // roamingProvider for the second (TEST_SSID2);
- when(mPasspointManager.matchProvider(any(ScanResult.class)))
- .thenReturn(homeProvider).thenReturn(roamingProvider);
- when(mWifiConfigManager.addOrUpdateNetwork(any(WifiConfiguration.class), anyInt(),
- any())).thenReturn(new NetworkUpdateResult(TEST_NETWORK_ID))
- .thenReturn(new NetworkUpdateResult(TEST_NETWORK_ID + 1));
- when(mWifiConfigManager.getConfiguredNetwork(TEST_NETWORK_ID)).thenReturn(TEST_CONFIG1);
- when(mWifiConfigManager.getConfiguredNetwork(TEST_NETWORK_ID + 1))
- .thenReturn(TEST_CONFIG2);
- List<Pair<ScanDetail, WifiConfiguration>> candidates = mNominateHelper
- .getPasspointNetworkCandidates(scanDetails, false);
- assertEquals(0, candidates.size());
-
- verify(mWifiConfigManager, never()).addOrUpdateNetwork(any(), anyInt(), any());
- }
-
-
- /**
* Verify that anonymous identity is empty when matching a SIM credential provider with a
* network that supports encrypted IMSI and anonymous identity. The anonymous identity will be
* populated with {@code anonymous@<realm>} by ClientModeImpl's handling of the