Merge "API for config app." into m-wireless-dev
This commit is contained in:
committed by
Android Partner Code Review
commit
0326f585e1
@ -115,6 +115,8 @@ interface IWifiManager
|
||||
|
||||
WifiConfiguration getWifiApConfiguration();
|
||||
|
||||
WifiConfiguration buildWifiConfig(String uriString, String mimeType, in byte[] data);
|
||||
|
||||
void setWifiApConfiguration(in WifiConfiguration wifiConfig);
|
||||
|
||||
void startWifi();
|
||||
|
@ -24,6 +24,7 @@ import android.net.StaticIpConfiguration;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.BitSet;
|
||||
@ -863,41 +864,52 @@ public class WifiConfiguration implements Parcelable {
|
||||
* @hide
|
||||
*/
|
||||
public boolean isValid() {
|
||||
String reason = strIsValid();
|
||||
if (reason != null) {
|
||||
Log.e("WFII", "WiFi Config not valid: " + reason);
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private String strIsValid() {
|
||||
|
||||
if (allowedKeyManagement == null)
|
||||
return false;
|
||||
return "allowed kmgmt";
|
||||
|
||||
if (allowedKeyManagement.cardinality() > 1) {
|
||||
if (allowedKeyManagement.cardinality() != 2) {
|
||||
return false;
|
||||
return "cardinality != 2";
|
||||
}
|
||||
if (allowedKeyManagement.get(KeyMgmt.WPA_EAP) == false) {
|
||||
return false;
|
||||
if (!allowedKeyManagement.get(KeyMgmt.WPA_EAP)) {
|
||||
return "not WPA_EAP";
|
||||
}
|
||||
if ((allowedKeyManagement.get(KeyMgmt.IEEE8021X) == false)
|
||||
&& (allowedKeyManagement.get(KeyMgmt.WPA_PSK) == false)) {
|
||||
return false;
|
||||
if ((!allowedKeyManagement.get(KeyMgmt.IEEE8021X))
|
||||
&& (!allowedKeyManagement.get(KeyMgmt.WPA_PSK))) {
|
||||
return "not PSK or 8021X";
|
||||
}
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(FQDN) == false) {
|
||||
if (!TextUtils.isEmpty(FQDN)) {
|
||||
/* this is passpoint configuration; it must not have an SSID */
|
||||
if (TextUtils.isEmpty(SSID) == false) {
|
||||
return false;
|
||||
if (!TextUtils.isEmpty(SSID)) {
|
||||
return "no SSID";
|
||||
}
|
||||
/* this is passpoint configuration; it must have a providerFriendlyName */
|
||||
if (TextUtils.isEmpty(providerFriendlyName)) {
|
||||
return false;
|
||||
return "no provider friendly name";
|
||||
}
|
||||
/* this is passpoint configuration; it must have enterprise config */
|
||||
if (enterpriseConfig == null
|
||||
|| enterpriseConfig.getEapMethod() == WifiEnterpriseConfig.Eap.NONE ) {
|
||||
return false;
|
||||
return "no enterprise config";
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add more checks
|
||||
return true;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1479,6 +1479,20 @@ public class WifiManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a WifiConfiguration from Hotspot 2.0 MIME file.
|
||||
* @return AP details in WifiConfiguration
|
||||
*
|
||||
* @hide Dont open yet
|
||||
*/
|
||||
public WifiConfiguration buildWifiConfig(String uriString, String mimeType, byte[] data) {
|
||||
try {
|
||||
return mService.buildWifiConfig(uriString, mimeType, data);
|
||||
} catch (RemoteException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Wi-Fi AP Configuration.
|
||||
* @return {@code true} if the operation succeeded, {@code false} otherwise
|
||||
|
Reference in New Issue
Block a user