Java 类android.net.wifi.WifiConfiguration.PairwiseCipher 实例源码
项目:TumCampusApp
文件:EduroamManager.java
/**
* Configures eduroam wifi connection
*
* @param lrzId User's LRZ-ID
* @param networkPass User's lrz password
* @return Returns true if configuration was successful, false otherwise
*/
public boolean configureEduroam(String lrzId, String networkPass) {
// Configure Wifi
boolean update = true;
WifiConfiguration conf = getEduroamConfig(mContext);
if (conf == null) {
update = false;
conf = new WifiConfiguration();
}
conf.SSID = "\"" + NETWORK_SSID + "\"";
conf.allowedKeyManagement.set(KeyMgmt.WPA_EAP);
conf.allowedKeyManagement.set(KeyMgmt.IEEE8021X);
conf.allowedGroupCiphers.set(GroupCipher.TKIP);
conf.allowedGroupCiphers.set(GroupCipher.CCMP);
conf.allowedGroupCiphers.set(GroupCipher.WEP40);
conf.allowedGroupCiphers.set(GroupCipher.WEP104);
conf.allowedPairwiseCiphers.set(PairwiseCipher.CCMP);
conf.allowedPairwiseCiphers.set(PairwiseCipher.TKIP);
conf.allowedProtocols.set(Protocol.RSN);
conf.status = WifiConfiguration.Status.ENABLED;
if (Build.VERSION.SDK_INT >= 18) {
setupEnterpriseConfigAPI18(conf, lrzId, networkPass);
} else {
if (!setupEnterpriseConfigOld(conf, lrzId, networkPass)) {
return false;
}
}
// Add eduroam to wifi networks
WifiManager wifiManager = (WifiManager) mContext.getApplicationContext()
.getSystemService(Context.WIFI_SERVICE);
int networkId;
if (update) {
networkId = wifiManager.updateNetwork(conf);
Utils.log("deleted " + conf.networkId);
} else {
networkId = wifiManager.addNetwork(conf);
}
Utils.log("added " + networkId);
//Check if update successful
if (networkId == -1) {
return false;
}
//Enable and exit
wifiManager.enableNetwork(networkId, true);
return true;
}