summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorNate(Qiang) Jiang <qiangjiang@google.com>2020-03-02 17:56:31 -0800
committerNate Jiang <qiangjiang@google.com>2020-03-18 03:21:08 +0000
commit6853a19f2da130483fbe4082b457f1cf6a21e542 (patch)
treebeef7242624bd9169f847c2255b95da487666e2a /service
parentb4486b2a1bce042384b6da156aced9c8ff76b5ec (diff)
Enterprise suggestion's catificate share same lifecycle as suggestion
Enterprise network suggestion's catificate will add to keystore immediately after add the suggestion, and will only remove after suggestion is removed. Bug: 150500247 Test: atest com.android.server.wifi Merged-In: Icbe49911d7ca93b03dfdf728ad88057c31aa5974 Change-Id: Icbe49911d7ca93b03dfdf728ad88057c31aa5974 (cherry picked from commit e6813a5870911b10561db2c259c072123c1c513a)
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java18
-rw-r--r--service/java/com/android/server/wifi/WifiInjector.java4
-rw-r--r--service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java37
3 files changed, 46 insertions, 13 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index fb84cf0b1..59785fd87 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -1211,12 +1211,11 @@ public class WifiConfigManager {
return new NetworkUpdateResult(WifiConfiguration.INVALID_NETWORK_ID);
}
- // Update the keys for non-Passpoint enterprise networks. For Passpoint, the certificates
- // and keys are installed at the time the provider is installed.
- if (config.enterpriseConfig != null
- && config.enterpriseConfig.getEapMethod() != WifiEnterpriseConfig.Eap.NONE
- && !config.isPasspoint()) {
- if (!(mWifiKeyStore.updateNetworkKeys(newInternalConfig, existingInternalConfig))) {
+ // Update the keys for saved enterprise networks. For Passpoint, the certificates
+ // and keys are installed at the time the provider is installed. For suggestion enterprise
+ // network the certificates and keys are installed at the time the suggestion is added
+ if (!config.isPasspoint() && !config.fromWifiNetworkSuggestion && config.isEnterprise()) {
+ if (!mWifiKeyStore.updateNetworkKeys(newInternalConfig, existingInternalConfig)) {
return new NetworkUpdateResult(WifiConfiguration.INVALID_NETWORK_ID);
}
}
@@ -1353,9 +1352,10 @@ public class WifiConfigManager {
if (mVerboseLoggingEnabled) {
Log.v(TAG, "Removing network " + config.getPrintableSsid());
}
- // Remove any associated enterprise keys for non-Passpoint networks.
- if (!config.isPasspoint() && config.enterpriseConfig != null
- && config.enterpriseConfig.getEapMethod() != WifiEnterpriseConfig.Eap.NONE) {
+ // Remove any associated enterprise keys for saved enterprise networks. Passpoint network
+ // will remove the enterprise keys when provider is uninstalled. Suggestion enterprise
+ // networks will remove the enterprise keys when suggestion is removed.
+ if (!config.isPasspoint() && !config.fromWifiNetworkSuggestion && config.isEnterprise()) {
mWifiKeyStore.removeKeys(config.enterpriseConfig);
}
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java
index 474f27cdd..9ffca1326 100644
--- a/service/java/com/android/server/wifi/WifiInjector.java
+++ b/service/java/com/android/server/wifi/WifiInjector.java
@@ -269,8 +269,8 @@ public class WifiInjector {
mWifiConfigManager, mClock, mConnectivityLocalLog, mWifiConnectivityHelper,
subscriptionManager);
mWifiNetworkSuggestionsManager = new WifiNetworkSuggestionsManager(mContext,
- new Handler(mWifiCoreHandlerThread.getLooper()), this,
- mWifiPermissionsUtil, mWifiConfigManager, mWifiConfigStore, mWifiMetrics);
+ new Handler(mWifiCoreHandlerThread.getLooper()), this, mWifiPermissionsUtil,
+ mWifiConfigManager, mWifiConfigStore, mWifiMetrics, mWifiKeyStore);
mNetworkSuggestionEvaluator = new NetworkSuggestionEvaluator(mWifiNetworkSuggestionsManager,
mWifiConfigManager, mConnectivityLocalLog);
mScoredNetworkEvaluator = new ScoredNetworkEvaluator(context, clientModeImplLooper,
diff --git a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
index 6a5db5d23..8feb3711e 100644
--- a/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
+++ b/service/java/com/android/server/wifi/WifiNetworkSuggestionsManager.java
@@ -102,6 +102,7 @@ public class WifiNetworkSuggestionsManager {
private final WifiMetrics mWifiMetrics;
private final WifiInjector mWifiInjector;
private final FrameworkFacade mFrameworkFacade;
+ private final WifiKeyStore mWifiKeyStore;
/**
* Per app meta data to store network suggestions, status, etc for each app providing network
@@ -160,6 +161,10 @@ public class WifiNetworkSuggestionsManager {
@NonNull PerAppInfo perAppInfo) {
this.wns = wns;
this.perAppInfo = perAppInfo;
+ this.wns.wifiConfiguration.fromWifiNetworkSuggestion = true;
+ this.wns.wifiConfiguration.ephemeral = true;
+ this.wns.wifiConfiguration.creatorName = perAppInfo.packageName;
+ this.wns.wifiConfiguration.creatorUid = wns.suggestorUid;
}
@Override
@@ -378,7 +383,8 @@ public class WifiNetworkSuggestionsManager {
WifiPermissionsUtil wifiPermissionsUtil,
WifiConfigManager wifiConfigManager,
WifiConfigStore wifiConfigStore,
- WifiMetrics wifiMetrics) {
+ WifiMetrics wifiMetrics,
+ WifiKeyStore keyStore) {
mContext = context;
mResources = context.getResources();
mHandler = handler;
@@ -391,6 +397,7 @@ public class WifiNetworkSuggestionsManager {
mWifiPermissionsUtil = wifiPermissionsUtil;
mWifiConfigManager = wifiConfigManager;
mWifiMetrics = wifiMetrics;
+ mWifiKeyStore = keyStore;
// register the data store for serializing/deserializing data.
wifiConfigStore.registerStoreData(
@@ -587,6 +594,19 @@ public class WifiNetworkSuggestionsManager {
// Start tracking app-op changes from the app if they have active suggestions.
startTrackingAppOpsChange(packageName, uid);
}
+ Iterator<ExtendedWifiNetworkSuggestion> iterator = extNetworkSuggestions.iterator();
+ // Install enterprise network suggestion catificate.
+ while (iterator.hasNext()) {
+ WifiConfiguration config = iterator.next().wns.wifiConfiguration;
+ if (!config.isEnterprise()) {
+ continue;
+ }
+ if (!mWifiKeyStore.updateNetworkKeys(config, null)) {
+ Log.e(TAG, "Enterprise network install failure for SSID: "
+ + config.SSID);
+ iterator.remove();
+ }
+ }
perAppInfo.extNetworkSuggestions.addAll(extNetworkSuggestions);
// Update the max size for this app.
perAppInfo.maxSize = Math.max(perAppInfo.extNetworkSuggestions.size(), perAppInfo.maxSize);
@@ -611,7 +631,12 @@ 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.
@@ -626,8 +651,16 @@ public class WifiNetworkSuggestionsManager {
// Stop tracking app-op changes from the app if they don't have active suggestions.
stopTrackingAppOpsChange(packageName);
}
+ // Clean the enterprise certifiacte.
+ for (ExtendedWifiNetworkSuggestion ewns : removingSuggestions) {
+ WifiConfiguration config = ewns.wns.wifiConfiguration;
+ if (!config.isEnterprise()) {
+ continue;
+ }
+ mWifiKeyStore.removeKeys(config.enterpriseConfig);
+ }
// Clear the scan cache.
- removeFromScanResultMatchInfoMap(extNetworkSuggestions);
+ removeFromScanResultMatchInfoMap(removingSuggestions);
}
/**