diff options
author | Peter Qiu <zqiu@google.com> | 2017-04-10 20:35:50 +0900 |
---|---|---|
committer | Peter Qiu <zqiu@google.com> | 2017-05-23 09:50:17 -0700 |
commit | e7dfd69fbe21902b89124b99d914ed3c90ba8baf (patch) | |
tree | 018055837d786362456c1e0428178e875d535c3e /service | |
parent | a37ddaead71747d1efe44504efd4ebaebe3a825c (diff) |
Avoid selecting EAP-SIM/AKA/AKA' networks when SIM is not ready
Avoid continuous authentication failure caused by selecting
EAP-SIM/AKA/AKA' networks when SIM card is not ready.
Should check SIM card status before selecting EAP networks.
Bug: 38357575
Test: Manual
Change-Id: I2358ce89dabdad8d3fc8eb363fb0ff653739bdc9
Diffstat (limited to 'service')
5 files changed, 36 insertions, 3 deletions
diff --git a/service/java/com/android/server/wifi/SavedNetworkEvaluator.java b/service/java/com/android/server/wifi/SavedNetworkEvaluator.java index bf79edaf8..b37e9a168 100644 --- a/service/java/com/android/server/wifi/SavedNetworkEvaluator.java +++ b/service/java/com/android/server/wifi/SavedNetworkEvaluator.java @@ -23,6 +23,7 @@ import android.util.LocalLog; import android.util.Pair; import com.android.internal.R; +import com.android.server.wifi.util.TelephonyUtil; import java.util.ArrayList; import java.util.Arrays; @@ -286,6 +287,10 @@ public class SavedNetworkEvaluator implements WifiNetworkSelector.NetworkEvaluat + " has specified BSSID " + network.BSSID + ". Skip " + scanResult.BSSID); continue; + } else if (TelephonyUtil.isSimConfig(network) + && !mWifiConfigManager.isSimPresent()) { + // Don't select if security type is EAP SIM/AKA/AKA' when SIM is not present. + continue; } int score = calculateBssidScore(scanResult, network, currentNetwork, currentBssid, diff --git a/service/java/com/android/server/wifi/WifiConfigManager.java b/service/java/com/android/server/wifi/WifiConfigManager.java index 87d7a100b..e4f5d472e 100644 --- a/service/java/com/android/server/wifi/WifiConfigManager.java +++ b/service/java/com/android/server/wifi/WifiConfigManager.java @@ -285,6 +285,10 @@ public class WifiConfigManager { */ private boolean mDeferredUserUnlockRead = false; /** + * Flag to indicate if SIM is present. + */ + private boolean mSimPresent = false; + /** * This is keeping track of the next network ID to be assigned. Any new networks will be * assigned |mNextNetworkId| as network ID. */ @@ -2336,11 +2340,14 @@ public class WifiConfigManager { /** * Resets all sim networks state. */ - public void resetSimNetworks() { + public void resetSimNetworks(boolean simPresent) { if (mVerboseLoggingEnabled) localLog("resetSimNetworks"); for (WifiConfiguration config : getInternalConfiguredNetworks()) { if (TelephonyUtil.isSimConfig(config)) { - String currentIdentity = TelephonyUtil.getSimIdentity(mTelephonyManager, config); + String currentIdentity = null; + if (simPresent) { + currentIdentity = TelephonyUtil.getSimIdentity(mTelephonyManager, config); + } // Update the loaded config config.enterpriseConfig.setIdentity(currentIdentity); if (config.enterpriseConfig.getEapMethod() != WifiEnterpriseConfig.Eap.PEAP) { @@ -2348,6 +2355,16 @@ public class WifiConfigManager { } } } + mSimPresent = simPresent; + } + + /** + * Check if SIM is present. + * + * @return True if SIM is present, otherwise false. + */ + public boolean isSimPresent() { + return mSimPresent; } /** diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 079b24e51..fa1f60dd2 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -4302,7 +4302,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiRss break; case CMD_RESET_SIM_NETWORKS: log("resetting EAP-SIM/AKA/AKA' networks since SIM was changed"); - mWifiConfigManager.resetSimNetworks(); + mWifiConfigManager.resetSimNetworks(message.arg1 == 1); break; case CMD_BLUETOOTH_ADAPTER_STATE_CHANGE: mBluetoothConnectionActive = (message.arg1 != diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java b/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java index 132a2f22c..6ff5ee945 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointNetworkEvaluator.java @@ -92,6 +92,10 @@ public class PasspointNetworkEvaluator implements WifiNetworkSelector.NetworkEva Pair<PasspointProvider, PasspointMatch> bestProvider = mPasspointManager.matchProvider(scanDetail.getScanResult()); if (bestProvider != null) { + if (bestProvider.first.isSimCredential() && !mWifiConfigManager.isSimPresent()) { + // Skip providers backed by SIM credential when SIM is not present. + continue; + } candidateList.add(new PasspointNetworkCandidate( bestProvider.first, bestProvider.second, scanDetail)); } diff --git a/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java b/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java index 33867bbdd..c38098dac 100644 --- a/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java +++ b/service/java/com/android/server/wifi/hotspot2/PasspointProvider.java @@ -303,6 +303,13 @@ public class PasspointProvider { } /** + * @return true if provider is backed by a SIM credential. + */ + public boolean isSimCredential() { + return mConfig.getCredential().getSimCredential() != null; + } + + /** * Convert a legacy {@link WifiConfiguration} representation of a Passpoint configuration to * a {@link PasspointConfiguration}. This is used for migrating legacy Passpoint * configuration (release N and older). |