diff options
author | Ricardo Cerqueira <ricardo@cyngn.com> | 2016-04-05 11:41:06 +0100 |
---|---|---|
committer | Ricardo Cerqueira <ricardo@cyngn.com> | 2016-04-05 12:18:28 +0100 |
commit | ec38bfb5c7fefc0f973758d99d4580afa98fb5e7 (patch) | |
tree | 06083bcb7a1c1bad593338f269f64025726741ce /service/java | |
parent | 53cbe974863cee30372a098d7b873652e40a778b (diff) | |
download | android_frameworks_opt_net_wifi-ec38bfb5c7fefc0f973758d99d4580afa98fb5e7.tar.gz android_frameworks_opt_net_wifi-ec38bfb5c7fefc0f973758d99d4580afa98fb5e7.tar.bz2 android_frameworks_opt_net_wifi-ec38bfb5c7fefc0f973758d99d4580afa98fb5e7.zip |
EAP: Make the state-machine MSIM-aware
We already get and store the SIM slot to which we want to bind an
access point in Settings and the base framework. Close the loop
here, and make sure the calls into Telephony refer to the correct
subscription.
Change-Id: I7f45b2948df08d0e158cea4e51144e5efc02dffc
Diffstat (limited to 'service/java')
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index da7a395a9..46081e5d4 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -25,6 +25,7 @@ import static android.net.wifi.WifiManager.WIFI_STATE_DISABLED; import static android.net.wifi.WifiManager.WIFI_STATE_DISABLING; import static android.net.wifi.WifiManager.WIFI_STATE_ENABLED; import static android.net.wifi.WifiManager.WIFI_STATE_ENABLING; + /** * TODO: * Deprecate WIFI_STATE_UNKNOWN @@ -99,6 +100,7 @@ import android.os.SystemProperties; import android.os.UserHandle; import android.os.WorkSource; import android.provider.Settings; +import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; @@ -7712,11 +7714,21 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); if (tm != null) { - String imsi = tm.getSubscriberId(); + int subId = SubscriptionManager.getDefaultSubId(); + + if (targetWificonfiguration != null && targetWificonfiguration.SIMNum > 0 && + tm.getDefault().getPhoneCount() >= 2) { + int[] subIds = SubscriptionManager.getSubId(targetWificonfiguration.SIMNum - 1); + if (subIds != null) { + subId = subIds[0]; + } + } + + String imsi = tm.getSubscriberId(subId); String mccMnc = ""; - if (tm.getSimState() == TelephonyManager.SIM_STATE_READY) - mccMnc = tm.getSimOperator(); + if (tm.getSimState(subId) == TelephonyManager.SIM_STATE_READY) + mccMnc = tm.getSimOperator(subId); String identity = buildIdentity(eapMethod, imsi, mccMnc); @@ -10465,13 +10477,13 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno * com.android.internal.telephony.PhoneConstants#APPTYPE_xxx */ int appType = 2; - String tmResponse = tm.getIccSimChallengeResponse(appType, base64Challenge); + String tmResponse = getIccSimChallengeResponse(appType, base64Challenge, tm); if (tmResponse == null) { /* Then, in case of failure, issue may be due to sim type, retry as a simple sim * appType = 1 => SIM */ appType = 1; - tmResponse = tm.getIccSimChallengeResponse(appType, base64Challenge); + tmResponse = getIccSimChallengeResponse(appType, base64Challenge, tm); } logv("Raw Response - " + tmResponse); @@ -10532,7 +10544,7 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno mContext.getSystemService(Context.TELEPHONY_SERVICE); if (tm != null) { int appType = 2; // 2 => USIM - tmResponse = tm.getIccSimChallengeResponse(appType, base64Challenge); + tmResponse = getIccSimChallengeResponse(appType, base64Challenge, tm); logv("Raw Response - " + tmResponse); } else { loge("could not get telephony manager"); @@ -10575,6 +10587,30 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno mWifiNative.simAuthResponse(requestData.networkId, res_type, response); } + private String getIccSimChallengeResponse( + int appType, String base64Challenge, TelephonyManager tm) { + String tmResponse = null; + int subId = SubscriptionManager.getDefaultSubId(); + + if (targetWificonfiguration != null && targetWificonfiguration.SIMNum > 0 && + tm.getDefault().getPhoneCount() >= 2) { + int[] subIds = SubscriptionManager.getSubId(targetWificonfiguration.SIMNum - 1); + if (subIds != null) { + subId = subIds[0]; + } + } + + + if (subId >= 0) { + log("Requesting SIM challenge response from sub " + subId); + tmResponse = tm.getIccSimChallengeResponse(subId, appType, base64Challenge); + } else { + log("Requesting SIM challenge response"); + tmResponse = tm.getIccSimChallengeResponse(appType, base64Challenge); + } + return tmResponse; + } + /** * @param reason reason code from supplicant on network disconnected event * @return true if this is a suspicious disconnect |