Android的:如何以编程方式创建EAP无线网络配置? [英] Android: How to create EAP wifi configuration programmatically?

查看:214
本文介绍了Android的:如何以编程方式创建EAP无线网络配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何编程创建开放/ WEP / PSK / PSK2配置。

I know how to create Open/WEP/PSK/PSK2 configuration programmatically.

恩。

WifiConfiguration conf = new WifiConfiguration();
conf.SSID = "ssid";
conf.preSharedKey = "\"password\"";
conf.status = WifiConfiguration.Status.ENABLED;        

conf.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);

conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); 
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
conf.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);

conf.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);

conf.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
conf.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);

conf.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
conf.allowedProtocols.set(WifiConfiguration.Protocol.RSN);

int res = wifi.addNetwork(conf);
boolean b = wifi.enableNetwork(res, true);

但我怎么创建一个用于802.1X EAP? 展望源$ C ​​$ C处: .. \包\ APPS \设置\ SRC \ COM \机器人\设置\无线\ WifiDialog.java

But how do I create one for '802.1x EAP'? Looking into the source code at: ..\packages\apps\Settings\src\com\android\settings\wifi\WifiDialog.java

case AccessPoint.SECURITY_EAP:
                config.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
                config.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
                config.eap.setValue((String) mEapMethod.getSelectedItem());

                config.phase2.setValue((mPhase2.getSelectedItemPosition() == 0) ? "" :
                        "auth=" + mPhase2.getSelectedItem());
                config.ca_cert.setValue((mEapCaCert.getSelectedItemPosition() == 0) ? "" :
                        KEYSTORE_SPACE + Credentials.CA_CERTIFICATE +
                        (String) mEapCaCert.getSelectedItem());
                config.client_cert.setValue((mEapUserCert.getSelectedItemPosition() == 0) ? "" :
                        KEYSTORE_SPACE + Credentials.USER_CERTIFICATE +
                        (String) mEapUserCert.getSelectedItem());
                config.private_key.setValue((mEapUserCert.getSelectedItemPosition() == 0) ? "" :
                        KEYSTORE_SPACE + Credentials.USER_PRIVATE_KEY +
                        (String) mEapUserCert.getSelectedItem());
                config.identity.setValue((mEapIdentity.length() == 0) ? "" :
                        mEapIdentity.getText().toString());
                config.anonymous_identity.setValue((mEapAnonymous.length() == 0) ? "" :
                        mEapAnonymous.getText().toString());
                if (mPassword.length() != 0) {
                    config.password.setValue(mPassword.getText().toString());
                }

似乎做的工作,但config.eap不是从我的应用程序accessable。

Seems to do the work but 'config.eap' is not accessable from my application.

有没有一种方法来配置EAP类​​型的或者是不可能的?

Is there a way to configure EAP types or is it not possible?

推荐答案

我回答了这个在这里: <一href="http://stackoverflow.com/questions/4374862/how-to-programatically-create-and-read-wep-eap-wifi-configurations-in-android">How以编程方式创建和读​​取WEP / EAP无线网络配置,Android的?

I answered this here: How to programatically create and read WEP/EAP WiFi configurations in Android?

HTH :)

这篇关于Android的:如何以编程方式创建EAP无线网络配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆