summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNate(Qiang) Jiang <qiangjiang@google.com>2020-03-06 16:05:17 -0800
committerNate Jiang <qiangjiang@google.com>2020-03-09 21:00:08 +0000
commit924050178386e73cc459ec19e47afd7c304c4068 (patch)
treef18bc46e01d317c619afeca9b33e0a9b7e0e47de
parente6813a5870911b10561db2c259c072123c1c513a (diff)
Fix removing enterprise suggestion certificate
Make when remove a enterprise suggestion, use the internal config object to remove ketStore. Which has certificate alias. Bug: 150500247 Test: atest com.android.server.wifi Merged-In: Id020e16fb6c26f38eb217248f7296b9ae4b0e781 Change-Id: I8015d87599d843e022805ce69fd5a4eae4d7b066
-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));