summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorRoshan Pius <rpius@google.com>2017-07-17 16:29:47 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-07-17 16:29:47 +0000
commitc9f254bcdf9a1f2b535626a85b416de56a615610 (patch)
tree6d7c779120c6f9639138914231bc7d7d68ea0c55 /service
parent77315558f37f2ddc71ed029e262deffe0de52b70 (diff)
parente9d6e6722d8e4724b42f4c1dffa02bed05ee8b0a (diff)
Merge "WifiConfigManager: Method to remove all transient networks" into oc-dr1-dev
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/WifiConfigManager.java27
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java12
2 files changed, 29 insertions, 10 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java
index 8a6ef4647..8aaebb2df 100644
--- a/service/java/com/android/server/wifi/WifiConfigManager.java
+++ b/service/java/com/android/server/wifi/WifiConfigManager.java
@@ -1207,6 +1207,33 @@ public class WifiConfigManager {
}
/**
+ * Iterates through the internal list of configured networks and removes any ephemeral or
+ * passpoint network configurations which are transient in nature.
+ *
+ * @return true if a network was removed, false otherwise.
+ */
+ public boolean removeAllEphemeralOrPasspointConfiguredNetworks() {
+ if (mVerboseLoggingEnabled) {
+ Log.v(TAG, "Removing all passpoint or ephemeral configured networks");
+ }
+ boolean didRemove = false;
+ WifiConfiguration[] copiedConfigs =
+ mConfiguredNetworks.valuesForAllUsers().toArray(new WifiConfiguration[0]);
+ for (WifiConfiguration config : copiedConfigs) {
+ if (config.isPasspoint()) {
+ Log.d(TAG, "Removing passpoint network config " + config.configKey());
+ removeNetwork(config.networkId, mSystemUiUid);
+ didRemove = true;
+ } else if (config.ephemeral) {
+ Log.d(TAG, "Removing ephemeral network config " + config.configKey());
+ removeNetwork(config.networkId, mSystemUiUid);
+ didRemove = true;
+ }
+ }
+ return didRemove;
+ }
+
+ /**
* Helper method to mark a network enabled for network selection.
*/
private void setNetworkSelectionEnabled(WifiConfiguration config) {
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 183f32ff0..b347ea322 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -4810,16 +4810,8 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss
void registerDisconnected() {
if (mLastNetworkId != WifiConfiguration.INVALID_NETWORK_ID) {
mWifiConfigManager.updateNetworkAfterDisconnect(mLastNetworkId);
- // We are switching away from this configuration,
- // hence record the time we were connected last
- WifiConfiguration config = mWifiConfigManager.getConfiguredNetwork(mLastNetworkId);
- if (config != null) {
- // Remove WifiConfiguration for ephemeral or Passpoint networks, since they're
- // temporary networks.
- if (config.ephemeral || config.isPasspoint()) {
- mWifiConfigManager.removeNetwork(mLastNetworkId, Process.WIFI_UID);
- }
- }
+ // Let's remove any ephemeral or passpoint networks on every disconnect.
+ mWifiConfigManager.removeAllEphemeralOrPasspointConfiguredNetworks();
}
}