summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java6
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java47
3 files changed, 53 insertions, 6 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java b/tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java
index 9824c5b23..3ac4adc3b 100644
--- a/tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WakeupControllerTest.java
@@ -390,7 +390,7 @@ public class WakeupControllerTest extends WifiBaseTest {
WifiConfiguration wepNetwork = WifiConfigurationTestUtil.createWepNetwork();
WifiNetworkSuggestion wepNetworkSuggestion =
new WifiNetworkSuggestion(wepNetwork, null, false, false, true, true);
- when(mWifiNetworkSuggestionsManager.getAllNetworkSuggestions())
+ when(mWifiNetworkSuggestionsManager.getAllApprovedNetworkSuggestions())
.thenReturn(new HashSet<>(Arrays.asList(
openNetworkSuggestion, wepNetworkSuggestion)));
@@ -432,7 +432,7 @@ public class WakeupControllerTest extends WifiBaseTest {
WifiConfiguration oweNetwork = WifiConfigurationTestUtil.createOweNetwork(quotedSsid2);
WifiNetworkSuggestion oweNetworkSuggestion =
new WifiNetworkSuggestion(oweNetwork, null, false, false, true, true);
- when(mWifiNetworkSuggestionsManager.getAllNetworkSuggestions())
+ when(mWifiNetworkSuggestionsManager.getAllApprovedNetworkSuggestions())
.thenReturn(new HashSet<>(Arrays.asList(oweNetworkSuggestion)));
// scan results from most recent scan
@@ -530,7 +530,7 @@ public class WakeupControllerTest extends WifiBaseTest {
.createOpenNetwork(ScanResultUtil.createQuotedSSID(SAVED_SSID));
WifiNetworkSuggestion openNetworkSuggestion =
new WifiNetworkSuggestion(openNetwork, null, false, false, true, true);
- when(mWifiNetworkSuggestionsManager.getAllNetworkSuggestions())
+ when(mWifiNetworkSuggestionsManager.getAllApprovedNetworkSuggestions())
.thenReturn(new HashSet<>(Collections.singletonList(openNetworkSuggestion)));
initializeWakeupController(true /* enabled */);
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
index b01f2beb1..fe16b2833 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConnectivityManagerTest.java
@@ -109,7 +109,7 @@ public class WifiConnectivityManagerTest extends WifiBaseTest {
when(mWifiInjector.getWifiScanner()).thenReturn(mWifiScanner);
when(mWifiNetworkSuggestionsManager.retrieveHiddenNetworkList())
.thenReturn(new ArrayList<>());
- when(mWifiNetworkSuggestionsManager.getAllNetworkSuggestions())
+ when(mWifiNetworkSuggestionsManager.getAllApprovedNetworkSuggestions())
.thenReturn(new HashSet<>());
when(mWifiInjector.getBssidBlocklistMonitor()).thenReturn(mBssidBlocklistMonitor);
when(mWifiInjector.getWifiChannelUtilizationScan()).thenReturn(mWifiChannelUtilization);
@@ -1497,7 +1497,7 @@ public class WifiConnectivityManagerTest extends WifiBaseTest {
when(mWifiNetworkSuggestion.getWifiConfiguration()).thenReturn(mSuggestionConfig);
Set<WifiNetworkSuggestion> suggestionNetworks = new HashSet<WifiNetworkSuggestion>();
suggestionNetworks.add(mWifiNetworkSuggestion);
- when(mWifiNetworkSuggestionsManager.getAllNetworkSuggestions())
+ when(mWifiNetworkSuggestionsManager.getAllApprovedNetworkSuggestions())
.thenReturn(suggestionNetworks);
// Prepare for no saved networks
@@ -1548,7 +1548,7 @@ public class WifiConnectivityManagerTest extends WifiBaseTest {
when(mWifiNetworkSuggestion.getWifiConfiguration()).thenReturn(mSuggestionConfig);
Set<WifiNetworkSuggestion> suggestionNetworks = new HashSet<WifiNetworkSuggestion>();
suggestionNetworks.add(mWifiNetworkSuggestion);
- when(mWifiNetworkSuggestionsManager.getAllNetworkSuggestions())
+ when(mWifiNetworkSuggestionsManager.getAllApprovedNetworkSuggestions())
.thenReturn(suggestionNetworks);
// Prepare for a single passpoint network
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
index 897dca341..e7e866084 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
@@ -4018,6 +4018,53 @@ public class WifiNetworkSuggestionsManagerTest extends WifiBaseTest {
}
/**
+ * Verify that we only return user approved suggestions.
+ */
+ @Test
+ public void testGetApprovedNetworkSuggestions() {
+ WifiConfiguration wifiConfiguration = WifiConfigurationTestUtil.createOpenNetwork();
+ WifiNetworkSuggestion networkSuggestion1 = new WifiNetworkSuggestion(
+ wifiConfiguration, null, false, false, true, true);
+ // Reuse the same network credentials to ensure they both match.
+ WifiNetworkSuggestion networkSuggestion2 = new WifiNetworkSuggestion(
+ wifiConfiguration, null, false, false, true, true);
+
+ List<WifiNetworkSuggestion> networkSuggestionList1 =
+ new ArrayList<WifiNetworkSuggestion>() {{
+ add(networkSuggestion1);
+ }};
+ List<WifiNetworkSuggestion> networkSuggestionList2 =
+ new ArrayList<WifiNetworkSuggestion>() {{
+ add(networkSuggestion2);
+ }};
+
+ assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
+ mWifiNetworkSuggestionsManager.add(networkSuggestionList1, TEST_UID_1,
+ TEST_PACKAGE_1, TEST_FEATURE));
+ assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
+ mWifiNetworkSuggestionsManager.add(networkSuggestionList2, TEST_UID_2,
+ TEST_PACKAGE_2, TEST_FEATURE));
+
+ // nothing approved, return empty.
+ assertTrue(mWifiNetworkSuggestionsManager.getAllApprovedNetworkSuggestions().isEmpty());
+
+ mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
+ // only app 1 approved.
+ assertEquals(new HashSet<WifiNetworkSuggestion>() {{
+ add(networkSuggestion1);
+ }},
+ mWifiNetworkSuggestionsManager.getAllApprovedNetworkSuggestions());
+
+ mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_2);
+ // both app 1 & 2 approved.
+ assertEquals(new HashSet<WifiNetworkSuggestion>() {{
+ add(networkSuggestion1);
+ add(networkSuggestion2);
+ }},
+ mWifiNetworkSuggestionsManager.getAllApprovedNetworkSuggestions());
+ }
+
+ /**
* Helper function for creating a test configuration with user credential.
*
* @return {@link PasspointConfiguration}