summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java10
-rw-r--r--tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java4
2 files changed, 11 insertions, 3 deletions
diff --git a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
index 19603d8c6..426dddb8e 100644
--- a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
+++ b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
@@ -639,11 +639,15 @@ public class WifiNetworkSuggestionsManager {
@NonNull Collection<ExtendedWifiNetworkSuggestion> extNetworkSuggestions,
@NonNull String packageName,
@NonNull PerAppInfo perAppInfo) {
+ // Get internal suggestions
+ Set<ExtendedWifiNetworkSuggestion> removingSuggestions =
+ new HashSet<>(perAppInfo.extNetworkSuggestions);
if (!extNetworkSuggestions.isEmpty()) {
+ // Keep the internal suggestions need to remove.
+ removingSuggestions.retainAll(extNetworkSuggestions);
perAppInfo.extNetworkSuggestions.removeAll(extNetworkSuggestions);
} else {
// empty list is used to clear everything for the app. Store a copy for use below.
- extNetworkSuggestions = new HashSet<>(perAppInfo.extNetworkSuggestions);
perAppInfo.extNetworkSuggestions.clear();
}
if (perAppInfo.extNetworkSuggestions.isEmpty()) {
@@ -655,7 +659,7 @@ public class WifiNetworkSuggestionsManager {
stopTrackingAppOpsChange(packageName);
}
// Clean the enterprise certifiacte.
- for (ExtendedWifiNetworkSuggestion ewns : extNetworkSuggestions) {
+ for (ExtendedWifiNetworkSuggestion ewns : removingSuggestions) {
WifiConfiguration config = ewns.wns.wifiConfiguration;
if (!config.isEnterprise()) {
continue;
@@ -663,7 +667,7 @@ public class WifiNetworkSuggestionsManager {
mWifiKeyStore.removeKeys(config.enterpriseConfig);
}
// Clear the scan cache.
- removeFromScanResultMatchInfoMap(extNetworkSuggestions);
+ removeFromScanResultMatchInfoMap(removingSuggestions);
}
/**
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
index 9e183e729..dabdfd569 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiNetworkSuggestionsManagerTest.java
@@ -334,6 +334,10 @@ public class WifiNetworkSuggestionsManagerTest {
Set<WifiNetworkSuggestion> allNetworkSuggestions =
mWifiNetworkSuggestionsManager.getAllNetworkSuggestions();
assertEquals(1, allNetworkSuggestions.size());
+ WifiNetworkSuggestion removingSuggestion = new WifiNetworkSuggestion(
+ WifiConfigurationTestUtil.createEapNetwork(), false, false, TEST_UID_1,
+ TEST_PACKAGE_1);
+ removingSuggestion.wifiConfiguration.SSID = networkSuggestion1.wifiConfiguration.SSID;
assertEquals(WifiManager.STATUS_NETWORK_SUGGESTIONS_SUCCESS,
mWifiNetworkSuggestionsManager.remove(new ArrayList<>(),
TEST_UID_1, TEST_PACKAGE_1));