diff options
author | Sravanthi Palakonda <srapal@codeaurora.org> | 2015-09-10 17:22:21 +0530 |
---|---|---|
committer | Linux Build Service Account <lnxbuild@localhost> | 2015-10-06 03:21:21 -0600 |
commit | 43f908faf7f46349061c80ea9e50377d719c855e (patch) | |
tree | 2892df7515b68a8d597432fad80ab36a1e814219 /src/com/android/settings/wifi | |
parent | 2407f2d8843eff1445ea18e38228e9782210cc81 (diff) | |
download | packages_apps_Settings-43f908faf7f46349061c80ea9e50377d719c855e.zip packages_apps_Settings-43f908faf7f46349061c80ea9e50377d719c855e.tar.gz packages_apps_Settings-43f908faf7f46349061c80ea9e50377d719c855e.tar.bz2 |
Wifi: Enhance EAP SIM/AKA/AKA` configuration for multi(dual ) sim
This commit enhances the user interface by having the provision to
perform EAP authentication on a specific SIM , when the DUT is enabled
with multi (dual) SIM.
Change-Id: I4095d235750c2a46ab33a99f5f4f3937b6d5e314
CRs-Fixed: 905749
Diffstat (limited to 'src/com/android/settings/wifi')
-rw-r--r-- | src/com/android/settings/wifi/WifiConfigController.java | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/com/android/settings/wifi/WifiConfigController.java b/src/com/android/settings/wifi/WifiConfigController.java index 1a4b1dd..9ff39bf 100644 --- a/src/com/android/settings/wifi/WifiConfigController.java +++ b/src/com/android/settings/wifi/WifiConfigController.java @@ -35,8 +35,10 @@ import android.net.wifi.WifiEnterpriseConfig.Eap; import android.net.wifi.WifiEnterpriseConfig.Phase2; import android.net.wifi.WifiInfo; import android.os.Handler; +import android.provider.Settings; import android.security.Credentials; import android.security.KeyStore; +import android.telephony.TelephonyManager; import android.text.Editable; import android.text.InputType; import android.text.TextWatcher; @@ -54,11 +56,16 @@ import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; +import android.telephony.SubscriptionInfo; +import android.telephony.SubscriptionManager; import com.android.settings.ProxySelector; import com.android.settings.R; import com.android.settingslib.wifi.AccessPoint; import com.android.settings.Utils; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collections; import java.net.InetAddress; import java.net.Inet4Address; import java.util.Iterator; @@ -116,6 +123,8 @@ public class WifiConfigController implements TextWatcher, private Spinner mEapMethodSpinner; private Spinner mEapCaCertSpinner; private Spinner mPhase2Spinner; + private Spinner mSimCardSpinner; + private ArrayList<String> mSimDisplayNames; // Associated with mPhase2Spinner, one of PHASE2_FULL_ADAPTER or PHASE2_PEAP_ADAPTER private ArrayAdapter<String> mPhase2Adapter; private Spinner mEapUserCertSpinner; @@ -146,6 +155,11 @@ public class WifiConfigController implements TextWatcher, private TextView mSsidView; private Context mContext; + private TelephonyManager mTelephonyManager; + private SubscriptionManager mSubscriptionManager = null; + private String selectedSimCardName; + private int selectedSimCardNumber; + public WifiConfigController( WifiConfigUiBase parent, View view, AccessPoint accessPoint, boolean edit, @@ -163,6 +177,8 @@ public class WifiConfigController implements TextWatcher, mContext = mConfigUi.getContext(); final Resources res = mContext.getResources(); + mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); + mSimDisplayNames = new ArrayList<String>(); mLevels = res.getStringArray(R.array.wifi_signal); PHASE2_PEAP_ADAPTER = new ArrayAdapter<String>( mContext, android.R.layout.simple_spinner_item, @@ -447,6 +463,14 @@ public class WifiConfigController implements TextWatcher, break; } break; + case Eap.SIM: + case Eap.AKA: + case Eap.AKA_PRIME: + selectedSimCardName = (String)mSimCardSpinner.getSelectedItem(); + selectedSimCardNumber = mSimDisplayNames. + indexOf(selectedSimCardName) + 1; + config.SIMNum = selectedSimCardNumber; + break; default: // The default index from PHASE2_FULL_ADAPTER maps to the API config.enterpriseConfig.setPhase2Method(phase2Method); @@ -634,6 +658,7 @@ public class WifiConfigController implements TextWatcher, mView.findViewById(R.id.eap).setVisibility(View.VISIBLE); if (mEapMethodSpinner == null) { + getSIMInfo(); mEapMethodSpinner = (Spinner) mView.findViewById(R.id.method); mEapMethodSpinner.setOnItemSelectedListener(this); if (Utils.isWifiOnly(mContext) || !mContext.getResources().getBoolean( @@ -649,6 +674,7 @@ public class WifiConfigController implements TextWatcher, mPhase2Spinner = (Spinner) mView.findViewById(R.id.phase2); mEapCaCertSpinner = (Spinner) mView.findViewById(R.id.ca_cert); mEapUserCertSpinner = (Spinner) mView.findViewById(R.id.user_cert); + mSimCardSpinner = (Spinner) mView.findViewById(R.id.sim_card); mEapIdentityView = (TextView) mView.findViewById(R.id.identity); mEapAnonymousView = (TextView) mView.findViewById(R.id.anonymous); @@ -679,6 +705,12 @@ public class WifiConfigController implements TextWatcher, break; } break; + case Eap.SIM: + case Eap.AKA: + case Eap.AKA_PRIME: + WifiConfiguration config = mAccessPoint.getConfig(); + mSimCardSpinner.setSelection(config.SIMNum-1); + break; default: mPhase2Spinner.setSelection(phase2Method); break; @@ -734,12 +766,14 @@ public class WifiConfigController implements TextWatcher, setCaCertInvisible(); setAnonymousIdentInvisible(); setUserCertInvisible(); + setSimCardInvisible(); break; case WIFI_EAP_METHOD_TLS: mView.findViewById(R.id.l_user_cert).setVisibility(View.VISIBLE); setPhase2Invisible(); setAnonymousIdentInvisible(); setPasswordInvisible(); + setSimCardInvisible(); break; case WIFI_EAP_METHOD_PEAP: // Reset adapter if needed @@ -750,6 +784,7 @@ public class WifiConfigController implements TextWatcher, mView.findViewById(R.id.l_phase2).setVisibility(View.VISIBLE); mView.findViewById(R.id.l_anonymous).setVisibility(View.VISIBLE); setUserCertInvisible(); + setSimCardInvisible(); break; case WIFI_EAP_METHOD_TTLS: // Reset adapter if needed @@ -760,10 +795,23 @@ public class WifiConfigController implements TextWatcher, mView.findViewById(R.id.l_phase2).setVisibility(View.VISIBLE); mView.findViewById(R.id.l_anonymous).setVisibility(View.VISIBLE); setUserCertInvisible(); + setSimCardInvisible(); break; case WIFI_EAP_METHOD_SIM: case WIFI_EAP_METHOD_AKA: case WIFI_EAP_METHOD_AKA_PRIME: + WifiConfiguration config = mAccessPoint.getConfig(); + ArrayAdapter<String> eapSimAdapter = new ArrayAdapter<String>( + mContext, android.R.layout.simple_spinner_item, + mSimDisplayNames.toArray(new String[mSimDisplayNames.size()]) + ); + eapSimAdapter.setDropDownViewResource( + android.R.layout.simple_spinner_dropdown_item); + mSimCardSpinner.setAdapter(eapSimAdapter); + mView.findViewById(R.id.l_sim_card).setVisibility(View.VISIBLE); + if(config != null){ + mSimCardSpinner.setSelection(config.SIMNum-1); + } setPhase2Invisible(); setAnonymousIdentInvisible(); setCaCertInvisible(); @@ -774,6 +822,10 @@ public class WifiConfigController implements TextWatcher, } } + private void setSimCardInvisible() { + mView.findViewById(R.id.l_sim_card).setVisibility(View.GONE); + } + private void setIdentityInvisible() { mView.findViewById(R.id.l_identity).setVisibility(View.GONE); mPhase2Spinner.setSelection(Phase2.NONE); @@ -1025,4 +1077,20 @@ public class WifiConfigController implements TextWatcher, InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD : InputType.TYPE_TEXT_VARIATION_PASSWORD)); } + + private void getSIMInfo() { + int numOfSims; + String displayname; + mSubscriptionManager = SubscriptionManager.from(mContext); + for(int i = 0; i < mTelephonyManager.getSimCount(); i++) { + final SubscriptionInfo sir = mSubscriptionManager. + getActiveSubscriptionInfoForSimSlotIndex(i); + if (sir != null) { + displayname = String.valueOf(sir.getDisplayName()); + } else { + displayname = mContext.getString(R.string.sim_editor_title, i + 1); + } + mSimDisplayNames.add(displayname); + } + } } |