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:04:05 +0100 |
commit | ad44dae8d11543439509c6606d288f2c492b30dc (patch) | |
tree | 197430603bf6b64b6173d6637bdb57ebf7d6b9d8 /service/java | |
parent | ec38bfb5c7fefc0f973758d99d4580afa98fb5e7 (diff) | |
download | android_frameworks_opt_net_wifi-ad44dae8d11543439509c6606d288f2c492b30dc.tar.gz android_frameworks_opt_net_wifi-ad44dae8d11543439509c6606d288f2c492b30dc.tar.bz2 android_frameworks_opt_net_wifi-ad44dae8d11543439509c6606d288f2c492b30dc.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
(cherry picked from commit b354a61d44d2ff79c922ac96bbf662825f909dcd)
Diffstat (limited to 'service/java')
-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 46081e5d4..351f878c7 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -7715,19 +7715,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); @@ -8398,9 +8400,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"; |