summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Cerqueira <ricardo@cyngn.com>2016-04-05 11:41:06 +0100
committerRicardo Cerqueira <ricardo@cyngn.com>2016-04-05 12:17:23 +0100
commitb3d44b3be6e0e952880319caaea0e458a7aa3871 (patch)
tree88d2a50a48720e78bc92fe70b90e1897db426bd3
parente857544b876a28a4895f20b495a9c0484c1bbcde (diff)
downloadandroid_frameworks_opt_net_wifi-b3d44b3be6e0e952880319caaea0e458a7aa3871.tar.gz
android_frameworks_opt_net_wifi-b3d44b3be6e0e952880319caaea0e458a7aa3871.tar.bz2
android_frameworks_opt_net_wifi-b3d44b3be6e0e952880319caaea0e458a7aa3871.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
-rw-r--r--service/java/com/android/server/wifi/WifiStateMachine.java48
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 4f3d432a5..f6a7e69d2 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;
@@ -7725,11 +7727,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);
@@ -10489,13 +10501,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);
@@ -10560,7 +10572,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");
@@ -10608,6 +10620,30 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno
}
}
+ 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