summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNate Jiang <qiangjiang@google.com>2019-07-15 19:00:05 -0700
committerNate Jiang <qiangjiang@google.com>2019-07-16 16:43:41 +0000
commit7c9b249046dc4bb393a592085fdb394699f31411 (patch)
tree3623217874e9e652044257abb897b7421e4eb3d6 /tests
parent227fefbd539e3e0b8f183e3b6fac1b3aea4409a2 (diff)
[NetworkSuggestion] remove all suggestion should trigger disconnect
When App with "NETWORK_CARRIER_PROVISIONING" permission removes all suggestions, framework should disconnect connected network if suggested by this APP. Bug: 137597179 Test: atest android.net.wifi Test: atest com.android.server.wifi Test: acts WifiNetworkSuggestionTest Change-Id: I2e1193cdc6013028788b447e4da05d61cfa16e6d
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
index 8d33fae36..97a183370 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
@@ -1387,6 +1387,39 @@ public class WifiNetworkSuggestionsManagerTest {
verify(mClientModeImpl).disconnectCommand();
}
+ /**
+ * Verify that we will disconnect from network when App has NetworkCarrierProvisioningPermission
+ * and removed all its suggestions by remove empty list.
+ */
+ @Test
+ public void
+ testRemoveAllNetworkSuggestionsMatchingConnectionSuccessWithOneMatchCarrierProvision() {
+ WifiNetworkSuggestion networkSuggestion = new WifiNetworkSuggestion(
+ WifiConfigurationTestUtil.createOpenNetwork(), false, false, TEST_UID_1,
+ TEST_PACKAGE_1);
+ List<WifiNetworkSuggestion> networkSuggestionList =
+ new ArrayList<WifiNetworkSuggestion>() {{
+ add(networkSuggestion);
+ }};
+ when(mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(TEST_UID_1))
+ .thenReturn(true);
+ assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
+ mWifiNetworkSuggestionsManager.add(networkSuggestionList, TEST_UID_1,
+ TEST_PACKAGE_1));
+ mWifiNetworkSuggestionsManager.setHasUserApprovedForApp(true, TEST_PACKAGE_1);
+
+ // Simulate connecting to the network.
+ mWifiNetworkSuggestionsManager.handleConnectionAttemptEnded(
+ WifiMetrics.ConnectionEvent.FAILURE_NONE, networkSuggestion.wifiConfiguration,
+ TEST_BSSID);
+
+ // Now remove all network suggestion and ensure we did trigger a disconnect.
+ assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
+ mWifiNetworkSuggestionsManager.remove(new ArrayList<>(), TEST_UID_1,
+ TEST_PACKAGE_1));
+ verify(mClientModeImpl).disconnectCommand();
+ }
+
/**
* Verify that we do not disconnect from the network if there are network suggestion from