From ae78221ce2fb27dd978ec1f8714389adb9605414 Mon Sep 17 00:00:00 2001 From: Sravanthi Palakonda Date: Thu, 4 Dec 2014 19:16:52 +0530 Subject: wifi:Provide UI with SIM info for EAP-SIM authentication User Interface requires the SIM information (viz. number / type of SIM's supported on the device), using which the respective authentication option is provisioned to the user. This commit queries the same by invoking a command exposed by the wpa_supplicant. It is the wpa_supplicant that gets this information. CRs-Fixed: 775942 Change-Id: I93c6a5450c806d8fade0103ef96eca986c925eba --- .../com/android/server/wifi/WifiConfigStore.java | 18 ++++++++++++++++ .../java/com/android/server/wifi/WifiNative.java | 4 ++++ .../com/android/server/wifi/WifiServiceImpl.java | 13 +++++++++++ .../com/android/server/wifi/WifiStateMachine.java | 25 ++++++++++++++++++++++ 4 files changed, 60 insertions(+) diff --git a/service/java/com/android/server/wifi/WifiConfigStore.java b/service/java/com/android/server/wifi/WifiConfigStore.java index 76255d46e..ffcb5c4a0 100755 --- a/service/java/com/android/server/wifi/WifiConfigStore.java +++ b/service/java/com/android/server/wifi/WifiConfigStore.java @@ -2653,6 +2653,15 @@ public class WifiConfigStore extends IpConfigStore { } } + if (!mWifiNative.setNetworkVariable( + netId, + WifiConfiguration.SIMNumVarName, + Integer.toString(config.SIMNum))) { + loge(config.SIMNum + ": failed to set sim no: " + +config.SIMNum); + break setVariables; + } + String allowedKeyManagementString = makeString(config.allowedKeyManagement, WifiConfiguration.KeyMgmt.strings); if (config.allowedKeyManagement.cardinality() != 0 && @@ -3483,6 +3492,15 @@ public class WifiConfigStore extends IpConfigStore { } } + value = mWifiNative.getNetworkVariable(netId, WifiConfiguration.SIMNumVarName); + if (!TextUtils.isEmpty(value)) { + try { + config.SIMNum = Integer.parseInt(value); + } catch (NumberFormatException ignore) { + Log.e(TAG,"error in parsing Selected Sim number " + config.SIMNum); + } + } + value = mWifiNative.getNetworkVariable(netId, WifiConfiguration.hiddenSSIDVarName); config.hiddenSSID = false; if (!TextUtils.isEmpty(value)) { diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java index 0e01e27f7..6b813639d 100644 --- a/service/java/com/android/server/wifi/WifiNative.java +++ b/service/java/com/android/server/wifi/WifiNative.java @@ -631,6 +631,10 @@ public class WifiNative { return doStringCommand("PKTCNT_POLL"); } + public String getSimInfoNative() { + return doStringCommand("GET_SIM_INFO"); + } + public void bssFlush() { doBooleanCommand("BSS_FLUSH 0"); } diff --git a/service/java/com/android/server/wifi/WifiServiceImpl.java b/service/java/com/android/server/wifi/WifiServiceImpl.java index 8de6c0fb6..7589673d0 100644 --- a/service/java/com/android/server/wifi/WifiServiceImpl.java +++ b/service/java/com/android/server/wifi/WifiServiceImpl.java @@ -797,6 +797,19 @@ public final class WifiServiceImpl extends IWifiManager.Stub { } } + /** + * see {@link android.net.wifi.WifiManager#getSimInfo} + */ + public WifiEapSimInfo getSimInfo() { + enforceAccessPermission(); + if (mWifiStateMachineChannel != null) { + return mWifiStateMachine.syncGetSimInfo(mWifiStateMachineChannel); + } else { + Slog.e(TAG, "mWifiStateMachineChannel is not initialized"); + return null; + } + } + /** * see {@link android.net.wifi.WifiAdapter#reportActivityInfo} */ diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java index d2f8f29d7..3ac209487 100644 --- a/service/java/com/android/server/wifi/WifiStateMachine.java +++ b/service/java/com/android/server/wifi/WifiStateMachine.java @@ -629,6 +629,8 @@ public class WifiStateMachine extends StateMachine { /* Supplicant is trying to associate to a given SSID */ static final int CMD_TARGET_SSID = BASE + 148; + static final int CMD_GET_SIM_INFO = BASE + 149; + /* Wifi state machine modes of operation */ /* CONNECT_MODE - connect to any 'known' AP when it becomes available */ public static final int CONNECT_MODE = 1; @@ -2141,6 +2143,17 @@ public class WifiStateMachine extends StateMachine { return supportedFeatureSet; } + /** + * Get sim info synchronously + */ + + public WifiEapSimInfo syncGetSimInfo(AsyncChannel channel) { + Message resultMsg = channel.sendMessageSynchronously(CMD_GET_SIM_INFO); + WifiEapSimInfo mWifiEapSimInfo = (WifiEapSimInfo) resultMsg.obj; + resultMsg.recycle(); + return mWifiEapSimInfo; + } + /** * Get link layers stats for adapter synchronously */ @@ -4805,6 +4818,9 @@ public class WifiStateMachine extends StateMachine { replyToMessage(message, message.what, 0); } break; + case CMD_GET_SIM_INFO: + replyToMessage(message,message.what, (WifiEapSimInfo) null); + break; case CMD_GET_LINK_LAYER_STATS: // Not supported hence reply with error message replyToMessage(message, message.what, null); @@ -5420,6 +5436,15 @@ public class WifiStateMachine extends StateMachine { loge("Failed to set frequency band " + band); } break; + case CMD_GET_SIM_INFO: + String mSimInfo = mWifiNative.getSimInfoNative(); + WifiEapSimInfo mWifiEapSimInfo = new WifiEapSimInfo(mSimInfo); + if (mWifiEapSimInfo != null) { + replyToMessage(message, message.what ,(WifiEapSimInfo) mWifiEapSimInfo); + } else { + replyToMessage(message, message.what ,(WifiEapSimInfo) null); + } + break; case CMD_BLUETOOTH_ADAPTER_STATE_CHANGE: mBluetoothConnectionActive = (message.arg1 != BluetoothAdapter.STATE_DISCONNECTED); -- cgit v1.2.3