diff options
author | Prerepa Viswanadham <dham@google.com> | 2015-04-10 15:58:10 -0700 |
---|---|---|
committer | Prerepa Viswanadham <dham@google.com> | 2015-04-10 15:58:10 -0700 |
commit | 57bf2a8a38e929f00f3323cf97a8ea7a9af900ce (patch) | |
tree | 16549920278bc3572f80037303d63991705a53e7 /wifi/java/android/net | |
parent | 3932bb41535f91b03610147e24a244cf7e4152cb (diff) | |
parent | e593d0aec6430d98731d9751facd0414a1c9c6a2 (diff) | |
download | frameworks_base-57bf2a8a38e929f00f3323cf97a8ea7a9af900ce.zip frameworks_base-57bf2a8a38e929f00f3323cf97a8ea7a9af900ce.tar.gz frameworks_base-57bf2a8a38e929f00f3323cf97a8ea7a9af900ce.tar.bz2 |
Merge commit 'e593d0a' into merge_work
Change-Id: I4f8ae40fc446cd9cda4d5c6ec99469a98dda595b
Diffstat (limited to 'wifi/java/android/net')
-rw-r--r-- | wifi/java/android/net/wifi/IWifiManager.aidl | 4 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/RttManager.java | 329 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiConfiguration.java | 38 | ||||
-rw-r--r-- | wifi/java/android/net/wifi/WifiManager.java | 28 |
4 files changed, 290 insertions, 109 deletions
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl index 5342494..6e6d6f6 100644 --- a/wifi/java/android/net/wifi/IWifiManager.aidl +++ b/wifi/java/android/net/wifi/IWifiManager.aidl @@ -47,6 +47,8 @@ interface IWifiManager List<WifiConfiguration> getPrivilegedConfiguredNetworks(); + WifiConfiguration getMatchingWifiConfig(in ScanResult scanResult); + int addOrUpdateNetwork(in WifiConfiguration config); boolean removeNetwork(int netId); @@ -113,6 +115,8 @@ interface IWifiManager WifiConfiguration getWifiApConfiguration(); + WifiConfiguration buildWifiConfig(String uriString, String mimeType, in byte[] data); + void setWifiApConfiguration(in WifiConfiguration wifiConfig); void startWifi(); diff --git a/wifi/java/android/net/wifi/RttManager.java b/wifi/java/android/net/wifi/RttManager.java index 65ecf5d..b156d0c 100644 --- a/wifi/java/android/net/wifi/RttManager.java +++ b/wifi/java/android/net/wifi/RttManager.java @@ -26,51 +26,109 @@ public class RttManager { private static final boolean DBG = true; private static final String TAG = "RttManager"; - /** @deprecated Type must be specified*/ + /** @deprecated It is Not supported anymore. */ @Deprecated public static final int RTT_TYPE_UNSPECIFIED = 0; + public static final int RTT_TYPE_ONE_SIDED = 1; + public static final int RTT_TYPE_TWO_SIDED = 2; - /** @deprecated It is not supported*/ + /** @deprecated It is not supported anymore. */ @Deprecated public static final int RTT_TYPE_11_V = 2; - public static final int RTT_TYPE_TWO_SIDED = 4; - /** @deprecated It is not supported*/ + /** @deprecated It is not supported anymore. */ @Deprecated public static final int RTT_TYPE_11_MC = 4; + /** @deprecated It is not supported anymore. */ + @Deprecated public static final int RTT_PEER_TYPE_UNSPECIFIED = 0; + public static final int RTT_PEER_TYPE_AP = 1; public static final int RTT_PEER_TYPE_STA = 2; /* requires NAN */ + public static final int RTT_PEER_P2P_GO = 3; + public static final int RTT_PEER_P2P_CLIENT = 4; + public static final int RTT_PEER_NAN = 5; + /** + * @deprecated It is not supported anymore. + * Use {@link android.net.wifi.RttManager#RTT_BW_20_SUPPORT} API. + */ + @Deprecated public static final int RTT_CHANNEL_WIDTH_20 = 0; + + /** + * @deprecated It is not supported anymore. + * Use {@link android.net.wifi.RttManager#RTT_BW_40_SUPPORT} API. + */ + @Deprecated public static final int RTT_CHANNEL_WIDTH_40 = 1; + + /** + * @deprecated It is not supported anymore. + * Use {@link android.net.wifi.RttManager#RTT_BW_80_SUPPORT} API. + */ + @Deprecated public static final int RTT_CHANNEL_WIDTH_80 = 2; + + /**@deprecated It is not supported anymore. + * Use {@link android.net.wifi.RttManager#RTT_BW_160_SUPPORT} API. + */ + @Deprecated public static final int RTT_CHANNEL_WIDTH_160 = 3; + + /**@deprecated not supported anymore*/ + @Deprecated public static final int RTT_CHANNEL_WIDTH_80P80 = 4; + + /**@deprecated It is not supported anymore. + * Use {@link android.net.wifi.RttManager#RTT_BW_5_SUPPORT} API. + */ + @Deprecated public static final int RTT_CHANNEL_WIDTH_5 = 5; + + /**@deprecated It is not supported anymore. + * Use {@link android.net.wifi.RttManager#RTT_BW_10_SUPPORT} API. + */ + @Deprecated public static final int RTT_CHANNEL_WIDTH_10 = 6; - /** @deprecated channel info must be specified*/ + /** @deprecated channel info must be specified. */ @Deprecated public static final int RTT_CHANNEL_WIDTH_UNSPECIFIED = -1; public static final int RTT_STATUS_SUCCESS = 0; + /** General failure*/ public static final int RTT_STATUS_FAILURE = 1; + /** Destination does not respond to RTT request*/ public static final int RTT_STATUS_FAIL_NO_RSP = 2; + /** RTT request is rejected by the destination. Double side RTT only*/ public static final int RTT_STATUS_FAIL_REJECTED = 3; + /** */ public static final int RTT_STATUS_FAIL_NOT_SCHEDULED_YET = 4; + /** Timing measurement timeout*/ public static final int RTT_STATUS_FAIL_TM_TIMEOUT = 5; + /** Destination is on a different channel from the RTT Request*/ public static final int RTT_STATUS_FAIL_AP_ON_DIFF_CHANNEL = 6; + /** This type of Ranging is not support by Hardware*/ public static final int RTT_STATUS_FAIL_NO_CAPABILITY = 7; + /** Request abort fro uncertain reason*/ public static final int RTT_STATUS_ABORTED = 8; - //if the T1-T4 or TOD/TOA Timestamp is illegal + /** The T1-T4 or TOD/TOA Timestamp is illegal*/ public static final int RTT_STATUS_FAIL_INVALID_TS = 9; - //11mc protocol failed, eg, unrecognized FTMR/FTM + /** 11mc protocol level failed, eg, unrecognized FTMR/FTM frame*/ public static final int RTT_STATUS_FAIL_PROTOCOL = 10; + /** Request can not be scheduled by hardware*/ public static final int RTT_STATUS_FAIL_SCHEDULE = 11; + /** destination is busy now, you can try after a specified time from destination*/ public static final int RTT_STATUS_FAIL_BUSY_TRY_LATER = 12; + /** Bad Request argument*/ + public static final int RTT_STATUS_INVALID_REQ = 13; + /** Wifi is not enabled*/ + public static final int RTT_STATUS_NO_WIFI = 14; + /** Responder overrides param info, cannot range with new params 2-side RTT only*/ + public static final int RTT_STATUS_FAIL_FTM_PARAM_OVERRIDE = 15; public static final int REASON_UNSPECIFIED = -1; public static final int REASON_NOT_AVAILABLE = -2; @@ -80,30 +138,30 @@ public class RttManager { public static final String DESCRIPTION_KEY = "android.net.wifi.RttManager.Description"; /** - * RTT BW supported bit mask + * RTT BW supported bit mask, used as RTT param bandWidth too */ - public static final int RTT_BW_5_SUPPORT = 0x1; - public static final int RTT_BW_10_SUPPORT = 0x2; - public static final int RTT_BW_20_SUPPORT = 0x4; - public static final int RTT_BW_40_SUPPORT = 0x8; + public static final int RTT_BW_5_SUPPORT = 0x01; + public static final int RTT_BW_10_SUPPORT = 0x02; + public static final int RTT_BW_20_SUPPORT = 0x04; + public static final int RTT_BW_40_SUPPORT = 0x08; public static final int RTT_BW_80_SUPPORT = 0x10; public static final int RTT_BW_160_SUPPORT = 0x20; /** * RTT Preamble Support bit mask */ - public static final int PREAMBLE_LEGACY = 0x1; - public static final int PREAMBLE_HT = 0x2; - public static final int PREAMBLE_VHT = 0x4; + public static final int PREAMBLE_LEGACY = 0x01; + public static final int PREAMBLE_HT = 0x02; + public static final int PREAMBLE_VHT = 0x04; - /** @deprecated It has been replaced by RttCapabilities*/ + /** @deprecated Use the new {@link android.net.wifi.RttManager.RttCapabilities} API */ @Deprecated public class Capabilities { public int supportedType; public int supportedPeerType; } - /** @deprecated It has been replaced by getRttCapabilities*/ + /** @deprecated Use the new {@link android.net.wifi.RttManager#getRttCapabilities()} API.*/ @Deprecated public Capabilities getCapabilities() { return new Capabilities(); @@ -241,28 +299,35 @@ public class RttManager { /** specifies parameters for RTT request */ public static class RttParams { /** - * type of destination device being ranged; one of RTT_PEER_TYPE_AP or RTT_PEER_TYPE_STA + * type of destination device being ranged + * currently only support RTT_PEER_TYPE_AP + * Range:RTT_PEER_TYPE_xxxx Default value:RTT_PEER_TYPE_AP */ public int deviceType; /** - * type of RTT measurement method; one of RTT_TYPE_ONE_SIDED or RTT_TYPE_TWO_SIDED. + * type of RTT measurement method. Need check scan result and RttCapabilities first + * Range: RTT_TYPE_ONE_SIDED or RTT_TYPE_TWO_SIDED + * Default value: RTT_TYPE_ONE_SIDED */ public int requestType; - /** mac address of the device being ranged */ + /** + * mac address of the device being ranged + * Default value: null + */ public String bssid; /** - * The primary 20 MHz frequency (in MHz) of the channel over which the client is - * communicating with the access point.Similar as ScanResult.frequency + * The primary control channel over which the client is + * communicating with the AP.Same as ScanResult.frequency + * Default value: 0 */ public int frequency; /** - * channel width used for RTT measurement. User need verify the highest BW the destination - * support (from scan result etc) before set this value. Wider channels result usually give - * better accuracy. However, the frame loss can increase. Similar as ScanResult.channelWidth + * channel width of the destination AP. Same as ScanResult.channelWidth + * Default value: 0 */ public int channelWidth; @@ -270,77 +335,113 @@ public class RttManager { * Not used if the AP bandwidth is 20 MHz * If the AP use 40, 80 or 160 MHz, this is the center frequency * if the AP use 80 + 80 MHz, this is the center frequency of the first segment - * similar as ScanResult.centerFreq0 + * same as ScanResult.centerFreq0 + * Default value: 0 */ public int centerFreq0; /** * Only used if the AP bandwidth is 80 + 80 MHz * if the AP use 80 + 80 MHz, this is the center frequency of the second segment - * similar as ScanResult.centerFreq1 + * same as ScanResult.centerFreq1 + * Default value: 0 */ public int centerFreq1; + /** * number of samples to be taken - * @deprecated It has been replaced by numSamplesPerBurst + * @deprecated Use the new {@link android.net.wifi.RttManager.RttParams#numSamplesPerBurst} */ @Deprecated public int num_samples; /** * number of retries if a sample fails - * @deprecated It has been replaced by numRetriesPerMeasurementFrame + * @deprecated + * Use {@link android.net.wifi.RttManager.RttParams#numRetriesPerMeasurementFrame} API. */ @Deprecated public int num_retries; - /** Number of burst. fixed to 1 for single side RTT*/ + /** Number of burst in exp , 2^x. 0 means single shot measurement, range 0-15 + * Currently only single shot is supported + * Default value: 0 + */ public int numberBurst; - /** valid only if numberBurst > 1, interval between burst(ms). Not used by singe side RTT */ + /** + * valid only if numberBurst > 1, interval between burst(100ms). + * Range : 0-31, 0--means no specific + * Default value: 0 + */ public int interval; - /** number of samples to be taken in one burst*/ + /** + * number of samples to be taken in one burst + * Range: 1-31 + * Default value: 8 + */ public int numSamplesPerBurst; /** number of retries for each measurement frame if a sample fails - * Only used by single side RTT + * Only used by single side RTT, + * Range 0 - 3 Default value: 0 */ public int numRetriesPerMeasurementFrame; - /** number of retries for FTMR frame if fails Only used by 80211MC double side RTT */ + /** + * number of retries for FTMR frame (control frame) if it fails. + * Only used by 80211MC double side RTT + * Range: 0-3 Default Value : 0 + */ public int numRetriesPerFTMR; - /** Request LCI information */ + /** + * Request LCI information, only available when choose double side RTT measurement + * need check RttCapabilties first. + * Default value: false + * */ public boolean LCIRequest; - /** Request LCR information */ + /** + * Request LCR information, only available when choose double side RTT measurement + * need check RttCapabilties first. + * Default value: false + * */ public boolean LCRRequest; - /** Timeout for each burst, unit of 250 us*/ + /** + * Timeout for each burst, (250 * 2^x) us, + * Range 1-11 and 15. 15 means no control Default value: 15 + * */ public int burstTimeout; /** preamble used for RTT measurement - * should be one of PREAMBLE_LEGACY, PREAMBLE_HT, PREAMBLE_VHT + * Range: PREAMBLE_LEGACY, PREAMBLE_HT, PREAMBLE_VHT + * Default value: PREAMBLE_HT */ public int preamble; /** bandWidth used for RTT measurement.User need verify the highest BW the destination * support (from scan result etc) before set this value. Wider channels result usually give * better accuracy. However, the frame loss can increase too. - * should be one of RTT_CHANNEL_WIDTH_20 to RTT_CHANNEL_WIDTH_80 + * should be one of RTT_BW_5_SUPPORT to RTT_BW_160_SUPPORT. However, need check + * RttCapabilities firstto verify HW support this bandwidth. + * Default value:RTT_BW_20_SUPPORT */ public int bandwidth; public RttParams() { //provide initial value for RttParams deviceType = RTT_PEER_TYPE_AP; - numberBurst = 1; + requestType = RTT_TYPE_ONE_SIDED; + numberBurst = 0; numSamplesPerBurst = 8; numRetriesPerMeasurementFrame = 0; - burstTimeout = 40 + numSamplesPerBurst *4; - preamble = PREAMBLE_LEGACY; - bandwidth = RTT_CHANNEL_WIDTH_20; + numRetriesPerFTMR = 0; + burstTimeout = 15; + preamble = PREAMBLE_HT; + bandwidth = RTT_BW_20_SUPPORT; } } @@ -430,26 +531,29 @@ public class RttManager { }; } - public class wifiInformationElement { - /** Information Element ID*/ - public int id; - public String data; + public static class WifiInformationElement { + /** Information Element ID 0xFF means element is invalid. */ + public byte id; + public byte[] data; } /** specifies RTT results */ public static class RttResult { - /** mac address of the device being ranged */ + /** mac address of the device being ranged. */ public String bssid; - /** # of burst for this measurement*/ + /** # of burst for this measurement. */ public int burstNumber; - /** total number of measurement frames in this measurement*/ + /** total number of measurement frames attempted in this measurement. */ public int measurementFrameNumber; - /** total successful number of measurement frames in this measurement*/ + /** total successful number of measurement frames in this measurement. */ public int successMeasurementFrameNumber; - /** Maximum number of frames per burst supported by peer */ + /** + * Maximum number of frames per burst supported by peer. Two side RTT only + * Valid only if less than request + */ public int frameNumberPerBurstPeer; /** status of the request */ @@ -457,120 +561,128 @@ public class RttManager { /** * type of the request used - * @deprecated It has been replaced by measurementType + * @deprecated Use {@link android.net.wifi.RttManager.RttResult#measurementType} */ @Deprecated public int requestType; - /** RTT measurement method type used, shoudl be one of RTT_TYPE_ONE_SIDED or + /** RTT measurement method type used, should be one of RTT_TYPE_ONE_SIDED or * RTT_TYPE_TWO_SIDED. */ public int measurementType; - /** please retry RTT measurement after this S since peer indicate busy at ths moment*/ + /** + * only valid when status == RTT_STATUS_FAIL_BUSY_TRY_LATER + * please retry RTT measurement after this duration since peer indicate busy at ths moment + * Unit S Range:1-31 + */ public int retryAfterDuration; - /** timestamp of completion, in microsecond since boot */ + /** timestamp of completion, in microsecond since boot. */ public long ts; - /** average RSSI observed, unit of 0.5 dB */ + /** average RSSI observed, unit of 0.5 dB. */ public int rssi; /** * RSSI spread (i.e. max - min) - * @deprecated It has been replaced by rssi_spread + * @deprecated Use {@link android.net.wifi.RttManager.RttResult#rssiSpread} API. */ @Deprecated public int rssi_spread; - /**RSSI spread (i.e. max - min), unit of 0.5 dB */ + /**RSSI spread (i.e. max - min), unit of 0.5 dB. */ public int rssiSpread; /** * average transmit rate - * @deprecated It has been replaced by txRate + * @deprecated Use {@link android.net.wifi.RttManager.RttResult#txRate} API. */ @Deprecated public int tx_rate; - /** average transmit rate */ + /** average transmit rate. Unit (100kbps). */ public int txRate; - /** average receiving rate */ + /** average receiving rate Unit (100kbps). */ public int rxRate; /** * average round trip time in nano second - * @deprecated It has been replaced by rtt + * @deprecated Use {@link android.net.wifi.RttManager.RttResult#rtt} API. */ @Deprecated public long rtt_ns; - /** average round trip time in 0.1 nano second */ + /** average round trip time in 0.1 nano second. */ public long rtt; /** * standard deviation observed in round trip time - * @deprecated It has been replaced by rttStandardDeviation + * @deprecated Use {@link android.net.wifi.RttManager.RttResult#rttStandardDeviation} API. */ @Deprecated public long rtt_sd_ns; - /** standard deviation of RTT in 0.1 ns */ + /** standard deviation of RTT in 0.1 ns. */ public long rttStandardDeviation; /** * spread (i.e. max - min) round trip time - * @deprecated It has been replaced by rttSpread + * @deprecated Use {@link android.net.wifi.RttManager.RttResult#rttSpread} API. */ @Deprecated public long rtt_spread_ns; - /** spread (i.e. max - min) RTT in 0.1 ns */ + /** spread (i.e. max - min) RTT in 0.1 ns. */ public long rttSpread; /** * average distance in centimeter, computed based on rtt_ns - * @deprecated It has been replaced by distance + * @deprecated use {@link android.net.wifi.RttManager.RttResult#distance} API. */ @Deprecated public int distance_cm; - /** average distance in cm, computed based on rtt */ + /** average distance in cm, computed based on rtt. */ public int distance; /** * standard deviation observed in distance - * @deprecated It has been replaced with distanceStandardDeviation + * @deprecated + * Use {@link .android.net.wifi.RttManager.RttResult#distanceStandardDeviation} API. */ @Deprecated public int distance_sd_cm; - /** standard deviation observed in distance in cm*/ + /** standard deviation observed in distance in cm. */ public int distanceStandardDeviation; /** * spread (i.e. max - min) distance - * @deprecated It has been replaced by distanceSpread + * @deprecate Use {@link android.net.wifi.RttManager.RttResult#distanceSpread} API. */ @Deprecated public int distance_spread_cm; - /** spread (i.e. max - min) distance in cm */ + /** spread (i.e. max - min) distance in cm. */ public int distanceSpread; - /** the duration of this measurement burst*/ + /** the duration of this measurement burst, unit ms. */ public int burstDuration; - /** LCI information Element*/ - wifiInformationElement LCI; + /** Burst number supported by peer after negotiation, 2side RTT only*/ + public int negotiatedBurstNum; + + /** LCI information Element, only available for double side RTT. */ + public WifiInformationElement LCI; - /** LCR information Element*/ - wifiInformationElement LCR; + /** LCR information Element, only available to double side RTT. */ + public WifiInformationElement LCR; } - /** pseudo-private class used to parcel results */ + /** pseudo-private class used to parcel results. */ public static class ParcelableRttResults implements Parcelable { public RttResult mResults[]; @@ -608,10 +720,17 @@ public class RttManager { dest.writeInt(result.distanceStandardDeviation); dest.writeInt(result.distanceSpread); dest.writeInt(result.burstDuration); - //dest.writeInt(result.LCI.id); - //dest.writeString(result.LCI.data); - //dest.writeInt(result.LCR.id); - //dest.writeString(result.LCR.data); + dest.writeInt(result.negotiatedBurstNum); + dest.writeByte(result.LCI.id); + if (result.LCI.id != (byte) 0xFF) { + dest.writeByte((byte)result.LCI.data.length); + dest.writeByteArray(result.LCI.data); + } + dest.writeByte(result.LCR.id); + if (result.LCR.id != (byte) 0xFF) { + dest.writeInt((byte) result.LCR.data.length); + dest.writeByte(result.LCR.id); + } } } else { dest.writeInt(0); @@ -651,10 +770,21 @@ public class RttManager { results[i].distanceStandardDeviation = in.readInt(); results[i].distanceSpread = in.readInt(); results[i].burstDuration = in.readInt(); - //results[i].LCI.id = in.readInt(); - //results[i].LCI.data = in.readString(); - //results[i].LCR.id = in.readInt(); - //results[i].LCR.data = in.readString(); + results[i].negotiatedBurstNum = in.readInt(); + results[i].LCI = new WifiInformationElement(); + results[i].LCI.id = in.readByte(); + if (results[i].LCI.id != (byte) 0xFF) { + byte length = in.readByte(); + results[i].LCI.data = new byte[length]; + in.readByteArray(results[i].LCI.data); + } + results[i].LCR = new WifiInformationElement(); + results[i].LCR.id = in.readByte(); + if (results[i].LCR.id != (byte) 0xFF) { + byte length = in.readByte(); + results[i].LCR.data = new byte[length]; + in.readByteArray(results[i].LCR.data); + } } ParcelableRttResults parcelableResults = new ParcelableRttResults(results); @@ -696,18 +826,24 @@ public class RttManager { !mRttCapabilities.twoSided11McRttSupported) { Log.e(TAG, "Request " + index + ": two side RTT is not supported"); return false; - } else if ( params.numberBurst <= 0 ) { + } else if(params.bssid == null || params.bssid.isEmpty()) { + Log.e(TAG,"No BSSID is input"); + } else if ( params.numberBurst != 0 ) { Log.e(TAG, "Request " + index + ": Illegal number of burst: " + params.numberBurst); return false; - } else if (params.numberBurst > 1 && params.interval <= 0) { - Log.e(TAG, "Request " + index + ": Illegal interval value: " + params.interval); - return false; - } else if (params.numSamplesPerBurst <= 0) { + } else if (params.numSamplesPerBurst <= 0 || params.numSamplesPerBurst > 31) { Log.e(TAG, "Request " + index + ": Illegal sample number per burst: " + params.numSamplesPerBurst); return false; - } else if (params.numRetriesPerMeasurementFrame < 0 || params.numRetriesPerFTMR < 0) { - Log.e(TAG, "Request " + index + ": Illegal retry number"); + } else if (params.numRetriesPerMeasurementFrame < 0 || + params.numRetriesPerMeasurementFrame > 3) { + Log.e(TAG, "Request " + index + ": Illegal measurement frame retry number:" + + params.numRetriesPerMeasurementFrame); + return false; + } else if(params.numRetriesPerFTMR < 0 || + params.numRetriesPerFTMR > 3) { + Log.e(TAG, "Request " + index + ": Illegal FTMR frame retry number:" + + params.numRetriesPerFTMR); return false; } else if (params.LCIRequest && !mRttCapabilities.lciSupported) { Log.e(TAG, "Request " + index + ": LCI is not supported"); @@ -715,7 +851,8 @@ public class RttManager { } else if (params.LCRRequest && !mRttCapabilities.lcrSupported) { Log.e(TAG, "Request " + index + ": LCR is not supported"); return false; - } else if (params.burstTimeout <= 0){ + } else if (params.burstTimeout < 1 || + (params.burstTimeout > 11 && params.burstTimeout != 15)){ Log.e(TAG, "Request " + index + ": Illegal burst timeout: " + params.burstTimeout); return false; } else if ((params.preamble & mRttCapabilities.preambleSupported) == 0) { diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java index 9cb6f2e..6ea0db2 100644 --- a/wifi/java/android/net/wifi/WifiConfiguration.java +++ b/wifi/java/android/net/wifi/WifiConfiguration.java @@ -25,6 +25,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; @@ -910,41 +911,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; } /** diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index 275c7d1..4e4f9b2 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -645,6 +645,20 @@ public class WifiManager { } /** + * Returns a WifiConfiguration matching this ScanResult + * @param scanResult scanResult that represents the BSSID + * @return {@link WifiConfiguration} that matches this BSSID or null + * @hide + */ + public WifiConfiguration getMatchingWifiConfig(ScanResult scanResult) { + try { + return mService.getMatchingWifiConfig(scanResult); + } catch (RemoteException e) { + return null; + } + } + + /** * Add a new network description to the set of configured networks. * The {@code networkId} field of the supplied configuration object * is ignored. @@ -1488,6 +1502,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 * |