diff options
author | Ricardo Cerqueira <ricardo@cyngn.com> | 2016-05-09 19:54:32 +0100 |
---|---|---|
committer | Ricardo Cerqueira <ricardo@cyngn.com> | 2016-05-09 20:03:20 +0100 |
commit | 901aac2ba8c64c35811424425bbeb01c895484e3 (patch) | |
tree | f9b5d8aa2f2b265299bfc7bdff30174638ece655 | |
parent | eb9c90d1c8f48f2620804b79444674c8f35f1dda (diff) | |
download | frameworks_opt_net_wifi-901aac2ba8c64c35811424425bbeb01c895484e3.tar.gz frameworks_opt_net_wifi-901aac2ba8c64c35811424425bbeb01c895484e3.tar.bz2 frameworks_opt_net_wifi-901aac2ba8c64c35811424425bbeb01c895484e3.zip |
Fix EAP-SIM fallback identity generation outside of North America
There are only a few MCCs in which the MNC is expected to be 3-digit long.
However, the fallback path for REQ-IDENTITY was assuming that length
all the time, which resulted in us getting the wrong realm for the
fallback path (which is kicked in when, for example, wifi starts up
faster than mobile)
Also, SIM states are indexed by slot, not subId
Ref CYNGNOS-2768
Change-Id: I3ea01d45e62689075b62df7a169f8734d0c9f5e6
-rw-r--r-- | service/java/com/android/server/wifi/WifiStateMachine.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index 0ce8dd4..1c06e71 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -7730,19 +7730,21 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno mContext.getSystemService(Context.TELEPHONY_SERVICE); if (tm != null) { int subId = SubscriptionManager.getDefaultSubId(); + int slotId = tm.getDefaultSim(); if (targetWificonfiguration != null && targetWificonfiguration.SIMNum > 0 && tm.getDefault().getPhoneCount() >= 2) { int[] subIds = SubscriptionManager.getSubId(targetWificonfiguration.SIMNum - 1); if (subIds != null) { subId = subIds[0]; + slotId = SubscriptionManager.getSlotId(subId); } } String imsi = tm.getSubscriberId(subId); String mccMnc = ""; - if (tm.getSimState(subId) == TelephonyManager.SIM_STATE_READY) + if (tm.getSimState(slotId) == TelephonyManager.SIM_STATE_READY) mccMnc = tm.getSimOperator(subId); String identity = buildIdentity(eapMethod, imsi, mccMnc); @@ -8413,9 +8415,17 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno if (mnc.length() == 2) mnc = "0" + mnc; } else { - // extract mcc & mnc from IMSI, assume mnc size is 3 + // extract mcc & mnc from IMSI, assume mnc size is 3 if in this list, 2 otherwise + String ThreeDigitMnc[] = {"302", "310", "311", "312", "313", "314", "315", "316", "334", "348"}; + mcc = imsi.substring(0, 3); mnc = imsi.substring(3, 6); + + if (!Arrays.asList(ThreeDigitMnc).contains(mcc)) + mnc = mnc.substring(0, 2); + + if (mnc.length() == 2) + mnc = "0" + mnc; } return prefix + imsi + "@wlan.mnc" + mnc + ".mcc" + mcc + ".3gppnetwork.org"; |