summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinit Deshpande <vinitd@google.com>2016-01-07 11:22:06 -0800
committerVinit Deshpande <vinitd@google.com>2016-01-12 13:02:47 -0800
commitfdce524fd05844c996cf1c5c0c102a87fde8e32c (patch)
treef362d9ebb1bbca43702f900879ede71682484d79
parent5ebc35f19feab2755a13cf7d5acaeff4bbc78994 (diff)
downloadandroid_frameworks_opt_net_wifi-fdce524fd05844c996cf1c5c0c102a87fde8e32c.tar.gz
android_frameworks_opt_net_wifi-fdce524fd05844c996cf1c5c0c102a87fde8e32c.tar.bz2
android_frameworks_opt_net_wifi-fdce524fd05844c996cf1c5c0c102a87fde8e32c.zip
Reset idenitities for EAP-SIM networks when SIM is pulled
This change resets identity and anonymous_identity for all networks that use SIM based auth. This ensures that all cached data is destroyed when SIM is removed; and newly added SIM must be authorized on the network to connect again. Bug: 23703716 Change-Id: I83d80336b2089c73d99214651b64b79443faf7f7
-rw-r--r--service/java/com/android/server/wifi/WifiConfigStore.java25
-rw-r--r--service/java/com/android/server/wifi/WifiServiceImpl.java2
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java26
3 files changed, 53 insertions, 0 deletions
diff --git a/service/java/com/android/server/wifi/WifiConfigStore.java b/service/java/com/android/server/wifi/WifiConfigStore.java
index d40b8756c..25d8ece33 100644
--- a/service/java/com/android/server/wifi/WifiConfigStore.java
+++ b/service/java/com/android/server/wifi/WifiConfigStore.java
@@ -3991,6 +3991,31 @@ public class WifiConfigStore extends IpConfigStore {
return false;
}
+ static boolean isSimConfig(WifiConfiguration config) {
+ if (config == null) {
+ return false;
+ }
+
+ if (config.enterpriseConfig == null) {
+ return false;
+ }
+
+ int method = config.enterpriseConfig.getEapMethod();
+ return (method == WifiEnterpriseConfig.Eap.SIM
+ || method == WifiEnterpriseConfig.Eap.AKA
+ || method == WifiEnterpriseConfig.Eap.AKA_PRIME);
+ }
+
+ void resetSimNetworks() {
+ for(WifiConfiguration config : mConfiguredNetworks.values()) {
+ if (isSimConfig(config)) {
+ /* This configuration may have cached Pseudonym IDs; lets remove them */
+ mWifiNative.setNetworkVariable(config.networkId, "identity", "NULL");
+ mWifiNative.setNetworkVariable(config.networkId, "anonymous_identity", "NULL");
+ }
+ }
+ }
+
boolean isNetworkConfigured(WifiConfiguration config) {
// Check if either we have a network Id or a WifiConfiguration
// matching the one we are trying to add.
diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java
index 33ce852e2..5ab035c65 100644
--- a/service/java/com/android/server/wifi/WifiServiceImpl.java
+++ b/service/java/com/android/server/wifi/WifiServiceImpl.java
@@ -373,6 +373,8 @@ public final class WifiServiceImpl extends IWifiManager.Stub {
public void onReceive(Context context, Intent intent) {
String state = intent.getStringExtra(IccCardConstants.INTENT_KEY_ICC_STATE);
if (state.equals(IccCardConstants.INTENT_VALUE_ICC_ABSENT)) {
+ Log.d(TAG, "resetting networks because SIM was removed");
+ mWifiStateMachine.resetSimAuthNetworks();
Log.d(TAG, "resetting country code because SIM is removed");
mWifiStateMachine.resetCountryCode();
}
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index ced5babb0..7773cb9e4 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -743,6 +743,9 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno
/* alert from firmware */
static final int CMD_FIRMWARE_ALERT = BASE + 100;
+ /* SIM is removed; reset any cached data for it */
+ static final int CMD_RESET_SIM_NETWORKS = BASE + 101;
+
/**
* Make this timer 40 seconds, which is about the normal DHCP timeout.
* In no valid case, the WiFiStateMachine should remain stuck in ObtainingIpAddress
@@ -2472,6 +2475,14 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno
}
/**
+ * reset cached SIM credential data
+ */
+ public synchronized void resetSimAuthNetworks() {
+ sendMessage(CMD_RESET_SIM_NETWORKS);
+ }
+
+
+ /**
* Get Network object of current wifi network
* @return Network object of current wifi network
*/
@@ -6095,6 +6106,10 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno
mWifiP2pChannel.sendMessage(WifiP2pServiceImpl.SET_COUNTRY_CODE, country);
break;
+ case CMD_RESET_SIM_NETWORKS:
+ log("resetting EAP-SIM/AKA/AKA' networks since SIM was removed");
+ mWifiConfigStore.resetSimNetworks();
+ break;
default:
return NOT_HANDLED;
}
@@ -8569,6 +8584,17 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno
case CMD_STOP_RSSI_MONITORING_OFFLOAD:
stopRssiMonitoringOffload();
break;
+ case CMD_RESET_SIM_NETWORKS:
+ if (mLastNetworkId != WifiConfiguration.INVALID_NETWORK_ID) {
+ WifiConfiguration config =
+ mWifiConfigStore.getWifiConfiguration(mLastNetworkId);
+ if (mWifiConfigStore.isSimConfig(config)) {
+ mWifiNative.disconnect();
+ transitionTo(mDisconnectingState);
+ }
+ }
+ /* allow parent state to reset data for other networks */
+ return NOT_HANDLED;
default:
return NOT_HANDLED;
}