diff options
Diffstat (limited to 'wifi/java/android')
17 files changed, 1422 insertions, 561 deletions
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl index 00e1cd8..e83eed7 100644 --- a/wifi/java/android/net/wifi/IWifiManager.aidl +++ b/wifi/java/android/net/wifi/IWifiManager.aidl @@ -132,5 +132,13 @@ interface IWifiManager void enableVerboseLogging(int verbose); int getVerboseLoggingLevel(); + + int getAggressiveHandover(); + + void enableAggressiveHandover(int enabled); + + int getAllowScansWithTraffic(); + + void setAllowScansWithTraffic(int enabled); } diff --git a/wifi/java/android/net/wifi/RssiPacketCountInfo.java b/wifi/java/android/net/wifi/RssiPacketCountInfo.java index f549e1d..0de2033 100644 --- a/wifi/java/android/net/wifi/RssiPacketCountInfo.java +++ b/wifi/java/android/net/wifi/RssiPacketCountInfo.java @@ -34,14 +34,17 @@ public class RssiPacketCountInfo implements Parcelable { public int txbad; + public int rxgood; + public RssiPacketCountInfo() { - rssi = txgood = txbad = 0; + rssi = txgood = txbad = rxgood = 0; } private RssiPacketCountInfo(Parcel in) { rssi = in.readInt(); txgood = in.readInt(); txbad = in.readInt(); + rxgood = in.readInt(); } @Override @@ -49,6 +52,7 @@ public class RssiPacketCountInfo implements Parcelable { out.writeInt(rssi); out.writeInt(txgood); out.writeInt(txbad); + out.writeInt(rxgood); } @Override diff --git a/wifi/java/android/net/wifi/ScanResult.java b/wifi/java/android/net/wifi/ScanResult.java index f6d7f55..8191edd 100644 --- a/wifi/java/android/net/wifi/ScanResult.java +++ b/wifi/java/android/net/wifi/ScanResult.java @@ -89,6 +89,21 @@ public class ScanResult implements Parcelable { * {@hide} */ public final static int UNSPECIFIED = -1; + /** + * @hide + * TODO: makes real freq boundaries + */ + public boolean is24GHz() { + return frequency > 2400 && frequency < 2500; + } + + /** + * @hide + * TODO: makes real freq boundaries + */ + public boolean is5GHz() { + return frequency > 4900 && frequency < 5900; + } /** information element from beacon * @hide @@ -144,8 +159,7 @@ public class ScanResult implements Parcelable { distanceCm = source.distanceCm; distanceSdCm = source.distanceSdCm; seen = source.seen; - if (source.passpoint != null) - passpoint = new WifiPasspointInfo(source.passpoint); + passpoint = source.passpoint; } } @@ -179,8 +193,7 @@ public class ScanResult implements Parcelable { sb.append(", distanceSd: ").append((distanceSdCm != UNSPECIFIED ? distanceSdCm : "?")). append("(cm)"); - if (passpoint != null) - sb.append(", passpoint: [").append(passpoint.toString()).append("]"); + sb.append(", passpoint: ").append(passpoint != null ? "yes" : "no"); return sb.toString(); } diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java index 5dfc318..59b48e4 100644 --- a/wifi/java/android/net/wifi/WifiConfiguration.java +++ b/wifi/java/android/net/wifi/WifiConfiguration.java @@ -342,14 +342,92 @@ public class WifiConfiguration implements Parcelable { /** * @hide + * Uid of app owning the BSSID + */ + public int bssidOwnerUid; + + /** + * @hide * BSSID list on which this configuration was seen. * TODO: prevent this list to grow infinitely, age-out the results */ public HashMap<String, ScanResult> scanResultCache; + /** The Below RSSI thresholds are used to configure AutoJoin + * - GOOD/LOW/BAD thresholds are used so as to calculate link score + * - UNWANTED_SOFT are used by the blacklisting logic so as to handle the unwanted network message coming from CS + * - UNBLACKLIST thresholds are used so as to tweak the speed at which the network is unblacklisted (i.e. if + * it is seen with good RSSI, it is blacklisted faster) + * - INITIAL_AUTOJOIN_ATTEMPT, used to determine how close from the network we need to be before autojoin kicks in + */ /** @hide **/ public static int INVALID_RSSI = -127; + /** @hide **/ + public static int UNWANTED_BLACKLIST_SOFT_RSSI_24 = -80; + + /** @hide **/ + public static int UNWANTED_BLACKLIST_SOFT_RSSI_5 = -70; + + /** @hide **/ + public static int GOOD_RSSI_24 = -65; + + /** @hide **/ + public static int LOW_RSSI_24 = -77; + + /** @hide **/ + public static int BAD_RSSI_24 = -87; + + /** @hide **/ + public static int GOOD_RSSI_5 = -60; + + /** @hide **/ + public static int LOW_RSSI_5 = -72; + + /** @hide **/ + public static int BAD_RSSI_5 = -82; + + /** @hide **/ + public static int UNWANTED_BLACKLIST_SOFT_BUMP = 4; + + /** @hide **/ + public static int UNWANTED_BLACKLIST_HARD_BUMP = 8; + + /** @hide **/ + public static int UNBLACKLIST_THRESHOLD_24_SOFT = -77; + + /** @hide **/ + public static int UNBLACKLIST_THRESHOLD_24_HARD = -68; + + /** @hide **/ + public static int UNBLACKLIST_THRESHOLD_5_SOFT = -63; + + /** @hide **/ + public static int UNBLACKLIST_THRESHOLD_5_HARD = -56; + + /** @hide **/ + public static int INITIAL_AUTO_JOIN_ATTEMPT_MIN_24 = -80; + + /** @hide **/ + public static int INITIAL_AUTO_JOIN_ATTEMPT_MIN_5 = -70; + + /** @hide + * 5GHz band is prefered over 2.4 if the 5GHz RSSI is higher than this threshold **/ + public static int A_BAND_PREFERENCE_RSSI_THRESHOLD = -65; + + /** @hide + * 5GHz band is penalized if the 5GHz RSSI is lower than this threshold **/ + public static int G_BAND_PREFERENCE_RSSI_THRESHOLD = -75; + + /** @hide + * Boost given to RSSI on a home network for the purpose of calculating the score + * This adds stickiness to home networks, as defined by: + * - less than 4 known BSSIDs + * - PSK only + * - TODO: add a test to verify that all BSSIDs are behind same gateway + ***/ + public static int HOME_NETWORK_RSSI_BOOST = 5; + /** * @hide * A summary of the RSSI and Band status for that configuration @@ -426,11 +504,11 @@ public class WifiConfiguration implements Parcelable { if (result.seen == 0) continue; - if ((result.frequency > 4900) && (result.frequency < 5900)) { + if (result.is5GHz()) { //strictly speaking: [4915, 5825] //number of known BSSID on 5GHz band status.num5 = status.num5 + 1; - } else if ((result.frequency > 2400) && (result.frequency < 2500)) { + } else if (result.is24GHz()) { //strictly speaking: [2412, 2482] //number of known BSSID on 2.4Ghz band status.num24 = status.num24 + 1; @@ -438,12 +516,12 @@ public class WifiConfiguration implements Parcelable { if ((now_ms - result.seen) > age) continue; - if ((result.frequency > 4900) && (result.frequency < 5900)) { + if (result.is5GHz()) { if (result.level > status.rssi5) { status.rssi5 = result.level; status.age5 = result.seen; } - } else if ((result.frequency > 2400) && (result.frequency < 2500)) { + } else if (result.is24GHz()) { if (result.level > status.rssi24) { status.rssi24 = result.level; status.age24 = result.seen; @@ -456,7 +534,7 @@ public class WifiConfiguration implements Parcelable { /** @hide */ public static final int AUTO_JOIN_ENABLED = 0; - /** @hide + /** * if this is set, the WifiConfiguration cannot use linkages so as to bump * it's relative priority. * - status between and 128 indicate various level of blacklisting depending @@ -465,7 +543,17 @@ public class WifiConfiguration implements Parcelable { * although it may have been self added we will not re-self-add it, ignore it, * not return it to applications, and not connect to it * */ + + /** @hide + * network was temporary disabled due to bad connection, most likely due + * to weak RSSI */ public static final int AUTO_JOIN_TEMPORARY_DISABLED = 1; + /** @hide + * network was temporary disabled due to bad connection, which cant be attributed + * to weak RSSI */ + public static final int AUTO_JOIN_TEMPORARY_DISABLED_LINK_ERRORS = 32; + /** @hide */ + public static final int AUTO_JOIN_TEMPORARY_DISABLED_AT_SUPPLICANT = 64; /** @hide */ public static final int AUTO_JOIN_DISABLED_ON_AUTH_FAILURE = 128; /** @hide */ @@ -476,6 +564,24 @@ public class WifiConfiguration implements Parcelable { */ public int autoJoinStatus; + + /** + * @hide + */ + public long blackListTimestamp; + + /** + * @hide + * last time the system was connected to this configuration. + */ + public long lastConnected; + + /** + * @hide + * last time the system was disconnected to this configuration. + */ + public long lastDisconnected; + /** * Set if the configuration was self added by the framework * This boolean is cleared if we get a connect/save/ update or @@ -586,7 +692,20 @@ public class WifiConfiguration implements Parcelable { // TODO: Add more checks return true; + } + /** + * Helper function, identify if a configuration is linked + * @hide + */ + public boolean isLinked(WifiConfiguration config) { + if (config.linkedConfigurations != null && linkedConfigurations != null) { + if (config.linkedConfigurations.get(configKey()) != null + && linkedConfigurations.get(config.configKey()) != null) { + return true; + } + } + return false; } /** @@ -614,6 +733,17 @@ public class WifiConfiguration implements Parcelable { return mostRecent; } + /** @hide **/ + public void setAutoJoinStatus(int status) { + if (status < 0) status = 0; + if (status == 0) { + blackListTimestamp = 0; + } else if (status > autoJoinStatus) { + blackListTimestamp = System.currentTimeMillis(); + } + autoJoinStatus = status; + } + @Override public String toString() { StringBuilder sbuf = new StringBuilder(); @@ -697,6 +827,15 @@ public class WifiConfiguration implements Parcelable { if (selfAdded) sbuf.append("selfAdded"); if (creatorUid != 0) sbuf.append("uid=" + Integer.toString(creatorUid)); + if (blackListTimestamp != 0) { + long now_ms = System.currentTimeMillis(); + long diff = now_ms - blackListTimestamp; + if (diff <= 0) { + sbuf.append("blackListed since <incorrect>"); + } else { + sbuf.append("blackListed since ").append(Long.toString(diff/1000)).append( "sec"); + } + } return sbuf.toString(); } @@ -985,8 +1124,12 @@ public class WifiConfiguration implements Parcelable { didSelfAdd = source.didSelfAdd; lastConnectUid = source.lastConnectUid; lastUpdateUid = source.lastUpdateUid; + bssidOwnerUid = source.bssidOwnerUid; creatorUid = source.creatorUid; peerWifiConfiguration = source.peerWifiConfiguration; + blackListTimestamp = source.blackListTimestamp; + lastConnected = source.lastConnected; + lastDisconnected = source.lastDisconnected; } } @@ -1030,17 +1173,8 @@ public class WifiConfiguration implements Parcelable { dest.writeInt(creatorUid); dest.writeInt(lastConnectUid); dest.writeInt(lastUpdateUid); - /* - TODO: should we write the cache results to the parcel? - if (scanResultCache != null) { - dest.writeInt(WifiConfiguration.SCAN_CACHE_TAG); - dest.writeInt(scanResultCache.size()); - for (ScanResult result : scanResultCache.values()) { - result.writeToParcel(dest, flags); - } - } else { - dest.writeInt(WifiConfiguration.NOTHING_TAG); - }*/ + dest.writeInt(bssidOwnerUid); + dest.writeLong(blackListTimestamp); } /** Implement the Parcelable interface {@hide} */ @@ -1079,26 +1213,8 @@ public class WifiConfiguration implements Parcelable { config.creatorUid = in.readInt(); config.lastConnectUid = in.readInt(); config.lastUpdateUid = in.readInt(); - /* - TODO: should we write the cache results to the parcel? - boolean done = false; - do { - int tag = in.readInt(); - switch (tag) { - case WifiConfiguration.SCAN_CACHE_TAG: - int size = in.readInt(); - config.scanResultCache = new HashMap<String, ScanResult>(); - while (size > 0) { - ScanResult result = ScanResult.CREATOR.createFromParcel(in); - config.scanResultCache.put(result.BSSID, result); - size--; - } - break; - case WifiConfiguration.NOTHING_TAG: - done = true; - break; - } - } while (!done);*/ + config.bssidOwnerUid = in.readInt(); + config.blackListTimestamp = in.readLong(); return config; } diff --git a/wifi/java/android/net/wifi/WifiEnterpriseConfig.java b/wifi/java/android/net/wifi/WifiEnterpriseConfig.java index 1484d49..7debb93 100644 --- a/wifi/java/android/net/wifi/WifiEnterpriseConfig.java +++ b/wifi/java/android/net/wifi/WifiEnterpriseConfig.java @@ -224,9 +224,9 @@ public class WifiEnterpriseConfig implements Parcelable { public static final int TTLS = 2; /** EAP-Password */ public static final int PWD = 3; - /** EAP-Subscriber Identity Module */ + /** EAP-Subscriber Identity Module {@hide} */ public static final int SIM = 4; - /** EAP-Authentication and Key Agreement */ + /** EAP-Authentication and Key Agreement {@hide} */ public static final int AKA = 5; /** @hide */ public static final String[] strings = { "PEAP", "TLS", "TTLS", "PWD", "SIM", "AKA" }; diff --git a/wifi/java/android/net/wifi/WifiInfo.java b/wifi/java/android/net/wifi/WifiInfo.java index f44cb0a..e46f916 100644 --- a/wifi/java/android/net/wifi/WifiInfo.java +++ b/wifi/java/android/net/wifi/WifiInfo.java @@ -40,7 +40,7 @@ public class WifiInfo implements Parcelable { * of <code>DetailedState</code>. */ private static final EnumMap<SupplicantState, DetailedState> stateMap = - new EnumMap<SupplicantState, DetailedState>(SupplicantState.class); + new EnumMap<SupplicantState, DetailedState>(SupplicantState.class); static { stateMap.put(SupplicantState.DISCONNECTED, DetailedState.DISCONNECTED); @@ -62,14 +62,31 @@ public class WifiInfo implements Parcelable { private String mBSSID; private WifiSsid mWifiSsid; private int mNetworkId; - /** Received Signal Strength Indicator */ + + /** @hide **/ + public static final int INVALID_RSSI = -127; + + /** @hide **/ + public static final int MIN_RSSI = -126; + + /** @hide **/ + public static final int MAX_RSSI = 200; + + + /** + * Received Signal Strength Indicator + */ private int mRssi; - /** Link speed in Mbps */ + /** + * Link speed in Mbps + */ public static final String LINK_SPEED_UNITS = "Mbps"; private int mLinkSpeed; - /** Frequency in MHz */ + /** + * Frequency in MHz + */ public static final String FREQUENCY_UNITS = "MHz"; private int mFrequency; @@ -77,9 +94,121 @@ public class WifiInfo implements Parcelable { private String mMacAddress; /** - * Flag indicating that AP has hinted that upstream connection is metered, - * and sensitive to heavy data transfers. + * @hide + */ + public long txBad; + /** + * @hide + */ + public long txRetries; + /** + * @hide + */ + public long txSuccess; + /** + * @hide + */ + public long rxSuccess; + /** + * @hide + */ + public double txBadRate; + /** + * @hide + */ + public double txRetriesRate; + /** + * @hide + */ + public double txSuccessRate; + /** + * @hide + */ + public double rxSuccessRate; + + /** + * @hide */ + public int badRssiCount; + + /** + * @hide + */ + public int linkStuckCount; + + /** + * @hide + */ + public int lowRssiCount; + + /** + * @hide + */ + public int score; + + /** + * TODO: get actual timestamp and calculate true rates + * @hide + */ + public void updatePacketRates(WifiLinkLayerStats stats) { + if (stats != null) { + long txgood = stats.txmpdu_be + stats.txmpdu_bk + stats.txmpdu_vi + stats.txmpdu_vo; + long txretries = stats.retries_be + stats.retries_bk + + stats.retries_vi + stats.retries_vo; + long rxgood = stats.rxmpdu_be + stats.rxmpdu_bk + stats.rxmpdu_vi + stats.rxmpdu_vo; + long txbad = stats.lostmpdu_be + stats.lostmpdu_bk + + stats.lostmpdu_vi + stats.lostmpdu_vo; + + txBadRate = (txBadRate * 0.5) + + ((double) (txbad - txBad) * 0.5); + txSuccessRate = (txSuccessRate * 0.5) + + ((double) (txgood - txSuccess) * 0.5); + rxSuccessRate = (rxSuccessRate * 0.5) + + ((double) (rxgood - rxSuccess) * 0.5); + txRetriesRate = (txRetriesRate * 0.5) + + ((double) (txretries - txRetries) * 0.5); + + txBad = txbad; + txSuccess = txgood; + rxSuccess = rxgood; + txRetries = txretries; + } else { + txBad = 0; + txSuccess = 0; + rxSuccess = 0; + txRetries = 0; + txBadRate = 0; + txSuccessRate = 0; + rxSuccessRate = 0; + txRetriesRate = 0; + } + } + + + /** + * This function is less powerful and used if the WifiLinkLayerStats API is not implemented + * at the Wifi HAL + * @hide + */ + public void updatePacketRates(long txPackets, long rxPackets) { + //paranoia + txBad = 0; + txRetries = 0; + txBadRate = 0; + txRetriesRate = 0; + + txSuccessRate = (txSuccessRate * 0.5) + + ((double) (txPackets - txSuccess) * 0.5); + rxSuccessRate = (rxSuccessRate * 0.5) + + ((double) (rxPackets - rxSuccess) * 0.5); + txSuccess = txPackets; + rxSuccess = rxPackets; + } + + /** + * Flag indicating that AP has hinted that upstream connection is metered, + * and sensitive to heavy data transfers. + */ private boolean mMeteredHint; /** @hide */ @@ -88,11 +217,35 @@ public class WifiInfo implements Parcelable { mBSSID = null; mNetworkId = -1; mSupplicantState = SupplicantState.UNINITIALIZED; - mRssi = -9999; + mRssi = INVALID_RSSI; mLinkSpeed = -1; mFrequency = -1; } + /** @hide */ + public void reset() { + setInetAddress(null); + setBSSID(null); + setSSID(null); + setNetworkId(-1); + setRssi(INVALID_RSSI); + setLinkSpeed(-1); + setFrequency(-1); + setMeteredHint(false); + txBad = 0; + txSuccess = 0; + rxSuccess = 0; + txRetries = 0; + txBadRate = 0; + txSuccessRate = 0; + rxSuccessRate = 0; + txRetriesRate = 0; + lowRssiCount = 0; + badRssiCount = 0; + linkStuckCount = 0; + score = 0; + } + /** * Copy constructor * @hide @@ -109,6 +262,18 @@ public class WifiInfo implements Parcelable { mIpAddress = source.mIpAddress; mMacAddress = source.mMacAddress; mMeteredHint = source.mMeteredHint; + txBad = source.txBad; + txRetries = source.txRetries; + txSuccess = source.txSuccess; + rxSuccess = source.rxSuccess; + txBadRate = source.txBadRate; + txRetriesRate = source.txRetriesRate; + txSuccessRate = source.txSuccessRate; + rxSuccessRate = source.rxSuccessRate; + score = source.score; + badRssiCount = source.badRssiCount; + lowRssiCount = source.lowRssiCount; + linkStuckCount = source.linkStuckCount; } } @@ -158,7 +323,7 @@ public class WifiInfo implements Parcelable { /** * Returns the received signal strength indicator of the current 802.11 * network, in dBm. - * @return the RSSI, in the range -110 to 10 + * @return the RSSI, in the range -127 to 200 */ public int getRssi() { return mRssi; @@ -166,6 +331,10 @@ public class WifiInfo implements Parcelable { /** @hide */ public void setRssi(int rssi) { + if (rssi < INVALID_RSSI) + rssi = INVALID_RSSI; + if (rssi > MAX_RSSI) + rssi = MAX_RSSI; mRssi = rssi; } @@ -198,6 +367,22 @@ public class WifiInfo implements Parcelable { } /** + * @hide + * TODO: makes real freq boundaries + */ + public boolean is24GHz() { + return mFrequency < 4000; + } + + /** + * @hide + * TODO: makes real freq boundaries + */ + public boolean is5GHz() { + return mFrequency > 4000; + } + + /** * Record the MAC address of the WLAN interface * @param macAddress the MAC address in {@code XX:XX:XX:XX:XX:XX} form * @hide @@ -325,8 +510,8 @@ public class WifiInfo implements Parcelable { append(", Link speed: ").append(mLinkSpeed).append(LINK_SPEED_UNITS). append(", Frequency: ").append(mFrequency).append(FREQUENCY_UNITS). append(", Net ID: ").append(mNetworkId). - append(", Metered hint: ").append(mMeteredHint); - + append(", Metered hint: ").append(mMeteredHint). + append(", score: ").append(Integer.toString(score)); return sb.toString(); } @@ -356,6 +541,13 @@ public class WifiInfo implements Parcelable { dest.writeString(mBSSID); dest.writeString(mMacAddress); dest.writeInt(mMeteredHint ? 1 : 0); + dest.writeInt(score); + dest.writeDouble(txSuccessRate); + dest.writeDouble(txRetriesRate); + dest.writeDouble(txBadRate); + dest.writeDouble(rxSuccessRate); + dest.writeInt(badRssiCount); + dest.writeInt(lowRssiCount); mSupplicantState.writeToParcel(dest, flags); } @@ -379,6 +571,13 @@ public class WifiInfo implements Parcelable { info.mBSSID = in.readString(); info.mMacAddress = in.readString(); info.mMeteredHint = in.readInt() != 0; + info.score = in.readInt(); + info.txSuccessRate = in.readDouble(); + info.txRetriesRate = in.readDouble(); + info.txBadRate = in.readDouble(); + info.rxSuccessRate = in.readDouble(); + info.badRssiCount = in.readInt(); + info.lowRssiCount = in.readInt(); info.mSupplicantState = SupplicantState.CREATOR.createFromParcel(in); return info; } diff --git a/wifi/java/android/net/wifi/WifiLinkLayerStats.java b/wifi/java/android/net/wifi/WifiLinkLayerStats.java index 922eddd..ae2fa98 100644 --- a/wifi/java/android/net/wifi/WifiLinkLayerStats.java +++ b/wifi/java/android/net/wifi/WifiLinkLayerStats.java @@ -111,6 +111,8 @@ public class WifiLinkLayerStats implements Parcelable { /** {@hide} */ public String toString() { StringBuilder sbuf = new StringBuilder(); + sbuf.append(" WifiLinkLayerStats: ").append('\n'); + if (this.SSID != null) { sbuf.append(" SSID: ").append(this.SSID).append('\n'); } diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java index bf46745..a30fb79 100644 --- a/wifi/java/android/net/wifi/WifiManager.java +++ b/wifi/java/android/net/wifi/WifiManager.java @@ -1413,14 +1413,12 @@ public class WifiManager { /** * Passed with {@link ActionListener#onFailure}. * Indicates that the operation failed due to an internal error. - * @hide */ public static final int ERROR = 0; /** * Passed with {@link ActionListener#onFailure}. * Indicates that the operation is already in progress - * @hide */ public static final int IN_PROGRESS = 1; @@ -1428,30 +1426,28 @@ public class WifiManager { * Passed with {@link ActionListener#onFailure}. * Indicates that the operation failed because the framework is busy and * unable to service the request - * @hide */ public static final int BUSY = 2; /* WPS specific errors */ - /** WPS overlap detected {@hide} */ + /** WPS overlap detected */ public static final int WPS_OVERLAP_ERROR = 3; - /** WEP on WPS is prohibited {@hide} */ + /** WEP on WPS is prohibited */ public static final int WPS_WEP_PROHIBITED = 4; - /** TKIP only prohibited {@hide} */ + /** TKIP only prohibited */ public static final int WPS_TKIP_ONLY_PROHIBITED = 5; - /** Authentication failure on WPS {@hide} */ + /** Authentication failure on WPS */ public static final int WPS_AUTH_FAILURE = 6; - /** WPS timed out {@hide} */ + /** WPS timed out */ public static final int WPS_TIMED_OUT = 7; /** * Passed with {@link ActionListener#onFailure}. * Indicates that the operation failed due to invalid inputs - * @hide */ public static final int INVALID_ARGS = 8; - /** Interface for callback invocation on an application action {@hide} */ + /** Interface for callback invocation on an application action */ public interface ActionListener { /** The operation succeeded */ public void onSuccess(); @@ -1463,7 +1459,7 @@ public class WifiManager { public void onFailure(int reason); } - /** Interface for callback invocation on a start WPS action {@hide} */ + /** Interface for callback invocation on a start WPS action */ public interface WpsListener { /** WPS start succeeded */ public void onStartSuccess(String pin); @@ -1745,7 +1741,6 @@ public class WifiManager { * @param listener for callbacks on success or failure. Can be null. * @throws IllegalStateException if the WifiManager instance needs to be * initialized again - * @hide */ public void startWps(WpsInfo config, WpsListener listener) { if (config == null) throw new IllegalArgumentException("config cannot be null"); @@ -1759,7 +1754,6 @@ public class WifiManager { * @param listener for callbacks on success or failure. Can be null. * @throws IllegalStateException if the WifiManager instance needs to be * initialized again - * @hide */ public void cancelWps(ActionListener listener) { validateChannel(); @@ -2232,7 +2226,6 @@ public class WifiManager { } } - /** * Set wifi verbose log. Called from developer settings. * @hide @@ -2257,4 +2250,53 @@ public class WifiManager { return 0; } } + + /** + * Set wifi Aggressive Handover. Called from developer settings. + * @hide + */ + public void enableAggressiveHandover(int enabled) { + try { + mService.enableAggressiveHandover(enabled); + } catch (RemoteException e) { + + } + } + + /** + * Get the WiFi Handover aggressiveness.This is used by settings + * to decide what to show within the picker. + * @hide + */ + public int getAggressiveHandover() { + try { + return mService.getAggressiveHandover(); + } catch (RemoteException e) { + return 0; + } + } + + /** + * Set setting for allowing Scans when traffic is ongoing. + * @hide + */ + public void setAllowScansWithTraffic(int enabled) { + try { + mService.setAllowScansWithTraffic(enabled); + } catch (RemoteException e) { + + } + } + + /** + * Get setting for allowing Scans when traffic is ongoing. + * @hide + */ + public int getAllowScansWithTraffic() { + try { + return mService.getAllowScansWithTraffic(); + } catch (RemoteException e) { + return 0; + } + } } diff --git a/wifi/java/android/net/wifi/WifiScanner.java b/wifi/java/android/net/wifi/WifiScanner.java index 3b65ca8..21b700d 100644 --- a/wifi/java/android/net/wifi/WifiScanner.java +++ b/wifi/java/android/net/wifi/WifiScanner.java @@ -153,12 +153,17 @@ public class WifiScanner { dest.writeInt(band); dest.writeInt(periodInMs); dest.writeInt(reportEvents); - dest.writeInt(channels.length); - for (int i = 0; i < channels.length; i++) { - dest.writeInt(channels[i].frequency); - dest.writeInt(channels[i].dwellTimeMS); - dest.writeInt(channels[i].passive ? 1 : 0); + if (channels != null) { + dest.writeInt(channels.length); + + for (int i = 0; i < channels.length; i++) { + dest.writeInt(channels[i].frequency); + dest.writeInt(channels[i].dwellTimeMS); + dest.writeInt(channels[i].passive ? 1 : 0); + } + } else { + dest.writeInt(0); } } @@ -211,10 +216,14 @@ public class WifiScanner { /** Implement the Parcelable interface {@hide} */ public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(mResults.length); - for (int i = 0; i < mResults.length; i++) { - ScanResult result = mResults[i]; - result.writeToParcel(dest, flags); + if (mResults != null) { + dest.writeInt(mResults.length); + for (int i = 0; i < mResults.length; i++) { + ScanResult result = mResults[i]; + result.writeToParcel(dest, flags); + } + } else { + dest.writeInt(0); } } @@ -324,13 +333,17 @@ public class WifiScanner { dest.writeInt(unchangedSampleSize); dest.writeInt(minApsBreachingThreshold); dest.writeInt(periodInMs); - dest.writeInt(hotspotInfos.length); - for (int i = 0; i < hotspotInfos.length; i++) { - HotspotInfo info = hotspotInfos[i]; - dest.writeString(info.bssid); - dest.writeInt(info.low); - dest.writeInt(info.high); - dest.writeInt(info.frequencyHint); + if (hotspotInfos != null) { + dest.writeInt(hotspotInfos.length); + for (int i = 0; i < hotspotInfos.length; i++) { + HotspotInfo info = hotspotInfos[i]; + dest.writeString(info.bssid); + dest.writeInt(info.low); + dest.writeInt(info.high); + dest.writeInt(info.frequencyHint); + } + } else { + dest.writeInt(0); } } @@ -456,13 +469,18 @@ public class WifiScanner { /** Implement the Parcelable interface {@hide} */ public void writeToParcel(Parcel dest, int flags) { dest.writeInt(apLostThreshold); - dest.writeInt(hotspotInfos.length); - for (int i = 0; i < hotspotInfos.length; i++) { - HotspotInfo info = hotspotInfos[i]; - dest.writeString(info.bssid); - dest.writeInt(info.low); - dest.writeInt(info.high); - dest.writeInt(info.frequencyHint); + + if (hotspotInfos != null) { + dest.writeInt(hotspotInfos.length); + for (int i = 0; i < hotspotInfos.length; i++) { + HotspotInfo info = hotspotInfos[i]; + dest.writeString(info.bssid); + dest.writeInt(info.low); + dest.writeInt(info.high); + dest.writeInt(info.frequencyHint); + } + } else { + dest.writeInt(0); } } @@ -680,6 +698,42 @@ public class WifiScanner { } } + /** @hide */ + public static class OperationResult implements Parcelable { + public int reason; + public String description; + + public OperationResult(int reason, String description) { + this.reason = reason; + this.description = description; + } + + /** Implement the Parcelable interface {@hide} */ + public int describeContents() { + return 0; + } + + /** Implement the Parcelable interface {@hide} */ + public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(reason); + dest.writeString(description); + } + + /** Implement the Parcelable interface {@hide} */ + public static final Creator<OperationResult> CREATOR = + new Creator<OperationResult>() { + public OperationResult createFromParcel(Parcel in) { + int reason = in.readInt(); + String description = in.readString(); + return new OperationResult(reason, description); + } + + public OperationResult[] newArray(int size) { + return new OperationResult[size]; + } + }; + } + private static class ServiceHandler extends Handler { ServiceHandler(Looper looper) { super(looper); @@ -717,9 +771,11 @@ public class WifiScanner { case CMD_OP_SUCCEEDED : ((ActionListener) listener).onSuccess(); break; - case CMD_OP_FAILED : - ((ActionListener) listener).onFailure(msg.arg1, (String)msg.obj); - removeListener(msg.arg2); + case CMD_OP_FAILED : { + OperationResult result = (OperationResult)msg.obj; + ((ActionListener) listener).onFailure(result.reason, result.description); + removeListener(msg.arg2); + } break; case CMD_SCAN_RESULT : ((ScanListener) listener).onResults( diff --git a/wifi/java/android/net/wifi/WpsInfo.java b/wifi/java/android/net/wifi/WpsInfo.java index 2ad4ad0..ae2e771 100644 --- a/wifi/java/android/net/wifi/WpsInfo.java +++ b/wifi/java/android/net/wifi/WpsInfo.java @@ -40,7 +40,7 @@ public class WpsInfo implements Parcelable { /** Wi-Fi Protected Setup. www.wi-fi.org/wifi-protected-setup has details */ public int setup; - /** @hide */ + /** Passed with pin method KEYPAD */ public String BSSID; /** Passed with pin method configuration */ diff --git a/wifi/java/android/net/wifi/passpoint/IWifiPasspointManager.aidl b/wifi/java/android/net/wifi/passpoint/IWifiPasspointManager.aidl index 8375d09..61c2b8a 100644 --- a/wifi/java/android/net/wifi/passpoint/IWifiPasspointManager.aidl +++ b/wifi/java/android/net/wifi/passpoint/IWifiPasspointManager.aidl @@ -16,6 +16,8 @@ package android.net.wifi.passpoint; +import android.net.wifi.ScanResult; +import android.net.wifi.passpoint.WifiPasspointPolicy; import android.os.Messenger; /** @@ -27,5 +29,6 @@ interface IWifiPasspointManager { Messenger getMessenger(); int getPasspointState(); + List<WifiPasspointPolicy> requestCredentialMatch(in List<ScanResult> requested); } diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointCredential.java b/wifi/java/android/net/wifi/passpoint/WifiPasspointCredential.java index 0769a64..33ccad5 100644 --- a/wifi/java/android/net/wifi/passpoint/WifiPasspointCredential.java +++ b/wifi/java/android/net/wifi/passpoint/WifiPasspointCredential.java @@ -20,10 +20,13 @@ import android.net.wifi.WifiEnterpriseConfig; import android.os.Parcelable; import android.os.Parcel; +import java.util.ArrayList; import java.util.Collection; -import java.util.Set; +import java.util.List; import java.util.Iterator; import java.util.Map; +import java.util.Set; + /** * A class representing a Wi-Fi Passpoint credential. @@ -32,77 +35,90 @@ import java.util.Map; public class WifiPasspointCredential implements Parcelable { private final static String TAG = "PasspointCredential"; - private String mWifiSPFQDN; + private final static boolean DBG = true; + + /** Wi-Fi nodes**/ + private String mWifiSpFqdn; + + /** PerProviderSubscription nodes **/ private String mCredentialName; - private String mUpdateIdentifier; + + /** SubscriptionUpdate nodes **/ + private String mSubscriptionUpdateInterval; private String mSubscriptionUpdateMethod; + private String mSubscriptionUpdateRestriction; + private String mSubscriptionUpdateURI; + private String mSubscriptionUpdateUsername; + private String mSubscriptionUpdatePassword; + + /** HomeSP nodes **/ + private String mHomeSpFqdn; + private String mFriendlyName; + private Collection<WifiPasspointDmTree.HomeOIList> mHomeOIList; + private Collection<WifiPasspointDmTree.OtherHomePartners> mOtherHomePartnerList; + + /** SubscriptionParameters nodes**/ + private String mCreationDate; + private String mExpirationDate; + + /** Credential nodes **/ private String mType; private String mInnerMethod; private String mCertType; private String mCertSha256Fingerprint; + private String mUpdateIdentifier; private String mUsername; private String mPasswd; + private String mRealm; private String mImsi; private String mMcc; private String mMnc; private String mCaRootCert; - private String mRealm; - private int mPriority; //User preferred priority; The smaller, the higher - private boolean mUserPreferred = false; - private String mHomeSpFqdn; - private String mFriendlyName; - private String mOtherhomepartnerFqdn; private String mClientCert; - private String mCreationDate; - private String mExpirationDate; - - private String mSubscriptionDMAccUsername; - private String mSubscriptionDMAccPassword; - private String mSubscriptionUpdateInterval; + private boolean mCheckAaaServerCertStatus; - private String mPolicyUpdateURI; + /** Policy nodes **/ + private String mPolicyUpdateUri; private String mPolicyUpdateInterval; - private String mPolicyDMAccUsername; - private String mPolicyDMAccPassword; + private String mPolicyUpdateUsername; + private String mPolicyUpdatePassword; private String mPolicyUpdateRestriction; private String mPolicyUpdateMethod; - private Collection<WifiPasspointDmTree.PreferredRoamingPartnerList> mPreferredRoamingPartnerList; - private Collection<WifiPasspointDmTree.HomeOIList> mHomeOIList; private Collection<WifiPasspointDmTree.MinBackhaulThresholdNetwork> mMinBackhaulThresholdNetwork; - private Collection<WifiPasspointDmTree.RequiredProtoPortTuple> mRequiredProtoPortTuple; private Collection<WifiPasspointDmTree.SPExclusionList> mSpExclusionList; + private Collection<WifiPasspointDmTree.RequiredProtoPortTuple> mRequiredProtoPortTuple; private String mMaxBssLoad; - private boolean mIsMachineRemediation; - - private String mAAACertURL; - private String mAAASha256Fingerprint; + /** CrednetialPriority node **/ + private int mCrednetialPriority; - private String mSubscriptionUpdateRestriction; - private String mSubscriptionUpdateURI; + /** AAAServerTrustRoot nodes **/ + private String mAaaCertUrl; + private String mAaaSha256Fingerprint; - private boolean mCheckAaaServerCertStatus; + /** Others **/ + private boolean mIsMachineRemediation; + private boolean mUserPreferred = false; + private String mWifiTreePath; + private WifiEnterpriseConfig mEnterpriseConfig; /** @hide */ - public WifiPasspointCredential() { - - } + public WifiPasspointCredential() {} /** * Constructor * @param realm Realm of the passpoint credential - * @param config Credential information, must be either EAP-TLS or EAP-TTLS. + * @param fqdn Fully qualified domain name (FQDN) of the credential + * @param config Enterprise config, must be either EAP-TLS or EAP-TTLS * @see WifiEnterpriseConfig */ - public WifiPasspointCredential(String realm, WifiEnterpriseConfig config) { + public WifiPasspointCredential(String realm, String fqdn, WifiEnterpriseConfig config) { mRealm = realm; switch (config.getEapMethod()) { case WifiEnterpriseConfig.Eap.TLS: - // TODO; - break; case WifiEnterpriseConfig.Eap.TTLS: - // TODO; + mEnterpriseConfig = new WifiEnterpriseConfig(config); break; default: // ignore @@ -113,84 +129,6 @@ public class WifiPasspointCredential implements Parcelable { public WifiPasspointCredential(String type, String caroot, String clientcert, - WifiPasspointDmTree.SpFqdn sp, - WifiPasspointDmTree.CredentialInfo credinfo) { - - if (credinfo == null) { - return; - } - - mType = type; - mCaRootCert = caroot; - mClientCert = clientcert; - - mWifiSPFQDN = sp.nodeName; - mUpdateIdentifier = sp.perProviderSubscription.UpdateIdentifier; - - mCredentialName = credinfo.nodeName; - Set set = credinfo.homeSP.otherHomePartners.entrySet(); - Iterator i = set.iterator(); - if (i.hasNext()) { - Map.Entry entry3 = (Map.Entry) i.next(); - WifiPasspointDmTree.OtherHomePartners ohp = (WifiPasspointDmTree.OtherHomePartners) entry3.getValue(); - mOtherhomepartnerFqdn = ohp.FQDN; - } - - set = credinfo.aAAServerTrustRoot.entrySet(); - i = set.iterator(); - if (i.hasNext()) { - Map.Entry entry3 = (Map.Entry) i.next(); - WifiPasspointDmTree.AAAServerTrustRoot aaa = (WifiPasspointDmTree.AAAServerTrustRoot) entry3.getValue(); - mAAACertURL = aaa.CertURL; - mAAASha256Fingerprint = aaa.CertSHA256Fingerprint; - } - - mCertType = credinfo.credential.digitalCertificate.CertificateType; - mCertSha256Fingerprint = credinfo.credential.digitalCertificate.CertSHA256Fingerprint; - mUsername = credinfo.credential.usernamePassword.Username; - mPasswd = credinfo.credential.usernamePassword.Password; - mIsMachineRemediation = credinfo.credential.usernamePassword.MachineManaged; - mInnerMethod = credinfo.credential.usernamePassword.eAPMethod.InnerMethod; - mImsi = credinfo.credential.sim.IMSI; - mCreationDate = credinfo.credential.CreationDate; - mExpirationDate = credinfo.credential.ExpirationDate; - mRealm = credinfo.credential.Realm; - - if (credinfo.credentialPriority == null) { - credinfo.credentialPriority = "128"; - } - mPriority = Integer.parseInt(credinfo.credentialPriority); - - mHomeSpFqdn = credinfo.homeSP.FQDN; - - mSubscriptionUpdateInterval = credinfo.subscriptionUpdate.UpdateInterval; - mSubscriptionUpdateMethod = credinfo.subscriptionUpdate.UpdateMethod; - mSubscriptionUpdateRestriction = credinfo.subscriptionUpdate.Restriction; - mSubscriptionUpdateURI = credinfo.subscriptionUpdate.URI; - mSubscriptionDMAccUsername = credinfo.subscriptionUpdate.usernamePassword.Username; - mSubscriptionDMAccPassword = credinfo.subscriptionUpdate.usernamePassword.Password; - - mPolicyUpdateURI = credinfo.policy.policyUpdate.URI; - mPolicyUpdateInterval = credinfo.policy.policyUpdate.UpdateInterval; - mPolicyDMAccUsername = credinfo.policy.policyUpdate.usernamePassword.Username; - mPolicyDMAccPassword = credinfo.policy.policyUpdate.usernamePassword.Password; - mPolicyUpdateRestriction = credinfo.policy.policyUpdate.Restriction; - mPolicyUpdateMethod = credinfo.policy.policyUpdate.UpdateMethod; - mPreferredRoamingPartnerList = credinfo.policy.preferredRoamingPartnerList.values(); - mMinBackhaulThresholdNetwork = credinfo.policy.minBackhaulThreshold.values(); - mRequiredProtoPortTuple = credinfo.policy.requiredProtoPortTuple.values(); - mMaxBssLoad = credinfo.policy.maximumBSSLoadValue; - mSpExclusionList = credinfo.policy.sPExclusionList.values(); - - mHomeOIList = credinfo.homeSP.homeOIList.values(); - mFriendlyName = credinfo.homeSP.FriendlyName; - mCheckAaaServerCertStatus = credinfo.credential.CheckAAAServerCertStatus; - } - - /** @hide */ - public WifiPasspointCredential(String type, - String caroot, - String clientcert, String mcc, String mnc, WifiPasspointDmTree.SpFqdn sp, @@ -204,25 +142,19 @@ public class WifiPasspointCredential implements Parcelable { mCaRootCert = caroot; mClientCert = clientcert; - mWifiSPFQDN = sp.nodeName; + mWifiSpFqdn = sp.nodeName; mUpdateIdentifier = sp.perProviderSubscription.UpdateIdentifier; mCredentialName = credinfo.nodeName; - Set set = credinfo.homeSP.otherHomePartners.entrySet(); - Iterator i = set.iterator(); - if (i.hasNext()) { - Map.Entry entry3 = (Map.Entry) i.next(); - WifiPasspointDmTree.OtherHomePartners ohp = (WifiPasspointDmTree.OtherHomePartners) entry3.getValue(); - mOtherhomepartnerFqdn = ohp.FQDN; - } + mOtherHomePartnerList = credinfo.homeSP.otherHomePartners.values(); - set = credinfo.aAAServerTrustRoot.entrySet(); - i = set.iterator(); + Set set = credinfo.aAAServerTrustRoot.entrySet(); + Iterator i = set.iterator(); if (i.hasNext()) { Map.Entry entry3 = (Map.Entry) i.next(); WifiPasspointDmTree.AAAServerTrustRoot aaa = (WifiPasspointDmTree.AAAServerTrustRoot) entry3.getValue(); - mAAACertURL = aaa.CertURL; - mAAASha256Fingerprint = aaa.CertSHA256Fingerprint; + mAaaCertUrl = aaa.CertURL; + mAaaSha256Fingerprint = aaa.CertSHA256Fingerprint; } mCertType = credinfo.credential.digitalCertificate.CertificateType; @@ -239,22 +171,24 @@ public class WifiPasspointCredential implements Parcelable { mRealm = credinfo.credential.Realm; if (credinfo.credentialPriority == null) { - credinfo.credentialPriority = "128"; + mCrednetialPriority = 128; + } else { + mCrednetialPriority = Integer.parseInt(credinfo.credentialPriority); } - mPriority = Integer.parseInt(credinfo.credentialPriority); mHomeSpFqdn = credinfo.homeSP.FQDN; + mSubscriptionUpdateInterval = credinfo.subscriptionUpdate.UpdateInterval; mSubscriptionUpdateMethod = credinfo.subscriptionUpdate.UpdateMethod; mSubscriptionUpdateRestriction = credinfo.subscriptionUpdate.Restriction; mSubscriptionUpdateURI = credinfo.subscriptionUpdate.URI; - mSubscriptionDMAccUsername = credinfo.subscriptionUpdate.usernamePassword.Username; - mSubscriptionDMAccPassword = credinfo.subscriptionUpdate.usernamePassword.Password; + mSubscriptionUpdateUsername = credinfo.subscriptionUpdate.usernamePassword.Username; + mSubscriptionUpdatePassword = credinfo.subscriptionUpdate.usernamePassword.Password; - mPolicyUpdateURI = credinfo.policy.policyUpdate.URI; + mPolicyUpdateUri = credinfo.policy.policyUpdate.URI; mPolicyUpdateInterval = credinfo.policy.policyUpdate.UpdateInterval; - mPolicyDMAccUsername = credinfo.policy.policyUpdate.usernamePassword.Username; - mPolicyDMAccPassword = credinfo.policy.policyUpdate.usernamePassword.Password; + mPolicyUpdateUsername = credinfo.policy.policyUpdate.usernamePassword.Username; + mPolicyUpdatePassword = credinfo.policy.policyUpdate.usernamePassword.Password; mPolicyUpdateRestriction = credinfo.policy.policyUpdate.Restriction; mPolicyUpdateMethod = credinfo.policy.policyUpdate.UpdateMethod; mPreferredRoamingPartnerList = credinfo.policy.preferredRoamingPartnerList.values(); @@ -265,6 +199,7 @@ public class WifiPasspointCredential implements Parcelable { mHomeOIList = credinfo.homeSP.homeOIList.values(); mFriendlyName = credinfo.homeSP.FriendlyName; + mCheckAaaServerCertStatus = credinfo.credential.CheckAAAServerCertStatus; } /** @hide */ @@ -283,8 +218,8 @@ public class WifiPasspointCredential implements Parcelable { } /** @hide */ - public String getWifiSPFQDN() { - return mWifiSPFQDN; + public String getWifiSpFqdn() { + return mWifiSpFqdn; } /** @hide */ @@ -293,16 +228,26 @@ public class WifiPasspointCredential implements Parcelable { } /** @hide */ - public String getEapMethodStr() { + public String getType() { return mType; } /** - * Get EAP method of this Passpoint credential. - * @return EAP method, refer to {@link WifiEnterpriseConfig.Eap} for possible return values + * Get enterprise config of this Passpoint credential. + * @return Enterprise config + * @see WifiEnterpriseConfig */ - public int getEapMethod() { - return 0; + public WifiEnterpriseConfig getEnterpriseConfig() { + return new WifiEnterpriseConfig(mEnterpriseConfig); + } + + /** + * Set enterprise config of this Passpoint credential. + * @param config Enterprise config, must be either EAP-TLS or EAP-TTLS + * @see WifiEnterpriseConfig + */ + public void setEnterpriseConfig(WifiEnterpriseConfig config) { + // TODO } /** @hide */ @@ -315,10 +260,7 @@ public class WifiPasspointCredential implements Parcelable { return mCertSha256Fingerprint; } - /** - * Get the user name of this Passpoint credential, for EAP-TTLS only. - * @return user name - */ + /** @hide */ public String getUserName() { return mUsername; } @@ -329,10 +271,7 @@ public class WifiPasspointCredential implements Parcelable { return mPasswd; } - /** - * Get the IMSI of this Passpoint credential, for EAP-SIM / EAP-AKA only. - * @return IMSI - */ + /** @hide */ public String getImsi() { return mImsi; } @@ -348,62 +287,75 @@ public class WifiPasspointCredential implements Parcelable { } /** @hide */ - public String getCaRootCert() { + public String getCaRootCertPath() { return mCaRootCert; } - /** - * Get the client certificate path of this Passpoint credential, for EAP-TLS only. - * @return client certificate path - */ + /** @hide */ public String getClientCertPath() { return mClientCert; } /** - * Get the realm of this Passpoint credential, for all EAP methods. + * Get the realm of this Passpoint credential. * @return Realm */ public String getRealm() { return mRealm; } + /** + * Set the ream of this Passpoint credential. + * @param realm Realm + */ + public void setRealm(String realm) { + mRealm = realm; + } + /** @hide */ public int getPriority() { if (mUserPreferred) { return 0; } - return mPriority; + return mCrednetialPriority; } /** - * Get the fully qualified domain name (FQDN) of this Passpoint credential, - * for all EAP methods. + * Get the fully qualified domain name (FQDN) of this Passpoint credential. * @return FQDN */ - public String getFqdn() { + public String getHomeSpFqdn() { return mHomeSpFqdn; } + /** + * Set the fully qualified domain name (FQDN) of this Passpoint credential. + * @param fqdn FQDN + */ + public void setFqdn(String fqdn) { + mHomeSpFqdn = fqdn; + } + + /** @hide */ - public String getOtherhomepartners() { - return mOtherhomepartnerFqdn; + public Collection<WifiPasspointDmTree.OtherHomePartners> getOtherHomePartnerList() { + return mOtherHomePartnerList; } /** @hide */ - public String getSubscriptionDMAccUsername() { - return mSubscriptionDMAccUsername; + public String getSubscriptionUpdateUsername() { + return mSubscriptionUpdateUsername; } /** @hide */ - public String getSubscriptionDMAccPassword() { - return mSubscriptionDMAccPassword; + public String getSubscriptionUpdatePassword() { + return mSubscriptionUpdatePassword; } /** @hide */ - public String getPolicyUpdateURI() { - return mPolicyUpdateURI; + public String getPolicyUpdateUri() { + return mPolicyUpdateUri; } /** @hide */ @@ -412,13 +364,13 @@ public class WifiPasspointCredential implements Parcelable { } /** @hide */ - public String getPolicyDMAccUsername() { - return mPolicyDMAccUsername; + public String getPolicyUpdateUsername() { + return mPolicyUpdateUsername; } /** @hide */ - public String getPolicyDMAccPassword() { - return mPolicyDMAccPassword; + public String getPolicyUpdatePassword() { + return mPolicyUpdatePassword; } /** @hide */ @@ -447,12 +399,12 @@ public class WifiPasspointCredential implements Parcelable { } /** @hide */ - public Collection<WifiPasspointDmTree.PreferredRoamingPartnerList> getPrpList() { + public Collection<WifiPasspointDmTree.PreferredRoamingPartnerList> getPreferredRoamingPartnerList() { return mPreferredRoamingPartnerList; } /** @hide */ - public Collection<WifiPasspointDmTree.HomeOIList> getHomeOIList() { + public Collection<WifiPasspointDmTree.HomeOIList> getHomeOiList() { return mHomeOIList; } @@ -477,13 +429,13 @@ public class WifiPasspointCredential implements Parcelable { } /** @hide */ - public String getAAACertURL() { - return mAAACertURL; + public String getAaaCertUrl() { + return mAaaCertUrl; } /** @hide */ - public String getAAASha256Fingerprint() { - return mAAASha256Fingerprint; + public String getAaaSha256Fingerprint() { + return mAaaSha256Fingerprint; } /** @hide */ @@ -541,7 +493,8 @@ public class WifiPasspointCredential implements Parcelable { } if (this.mType.equals("TLS")) { result = this.mRealm.equals(other.mRealm) && - this.mHomeSpFqdn.equals(other.mHomeSpFqdn); + this.mHomeSpFqdn.equals(other.mHomeSpFqdn) && + this.mClientCert.equals(other.mClientCert); } if (this.mType.equals("SIM")) { result = this.mMcc.equals(other.mMcc) && @@ -560,72 +513,75 @@ public class WifiPasspointCredential implements Parcelable { StringBuffer sb = new StringBuffer(); String none = "<none>"; - sb.append(", UpdateIdentifier: ") - .append(mUpdateIdentifier == null ? none : mUpdateIdentifier). - append(", SubscriptionUpdateMethod: ") - .append(mSubscriptionUpdateMethod == null ? none : mSubscriptionUpdateMethod). - append(", Type: ").append(mType == null ? none : mType). - append(", Username: ").append(mUsername == null ? none : mUsername). - append(", Passwd: ").append(mPasswd == null ? none : mPasswd). - append(", SubDMAccUsername: ") - .append(mSubscriptionDMAccUsername == null ? none : mSubscriptionDMAccUsername). - append(", SubDMAccPassword: ") - .append(mSubscriptionDMAccPassword == null ? none : mSubscriptionDMAccPassword). - append(", PolDMAccUsername: ") - .append(mPolicyDMAccUsername == null ? none : mPolicyDMAccUsername). - append(", PolDMAccPassword: ") - .append(mPolicyDMAccPassword == null ? none : mPolicyDMAccPassword). - append(", Imsi: ").append(mImsi == null ? none : mImsi). - append(", Mcc: ").append(mMcc == null ? none : mMcc). - append(", Mnc: ").append(mMnc == null ? none : mMnc). - append(", CaRootCert: ").append(mCaRootCert == null ? none : mCaRootCert). - append(", Realm: ").append(mRealm == null ? none : mRealm). - append(", Priority: ").append(mPriority). - append(", Fqdn: ").append(mHomeSpFqdn == null ? none : mHomeSpFqdn). - append(", Otherhomepartners: ") - .append(mOtherhomepartnerFqdn == null ? none : mOtherhomepartnerFqdn). - append(", ExpirationDate: ") - .append(mExpirationDate == null ? none : mExpirationDate). - append(", MaxBssLoad: ").append(mMaxBssLoad == null ? none : mMaxBssLoad). - append(", SPExclusionList: ").append(mSpExclusionList); - - if (mPreferredRoamingPartnerList != null) { - sb.append("PreferredRoamingPartnerList:"); - for (WifiPasspointDmTree.PreferredRoamingPartnerList prpListItem : mPreferredRoamingPartnerList) { - sb.append("[fqdnmatch:").append(prpListItem.FQDN_Match). - append(", priority:").append(prpListItem.Priority). - append(", country:").append(prpListItem.Country).append("]"); + if (!DBG) { + sb.append(none); + } else { + sb.append(", UpdateIdentifier: ") + .append(mUpdateIdentifier == null ? none : mUpdateIdentifier) + .append(", SubscriptionUpdateMethod: ") + .append(mSubscriptionUpdateMethod == null ? none : mSubscriptionUpdateMethod) + .append(", Type: ").append(mType == null ? none : mType) + .append(", Username: ").append(mUsername == null ? none : mUsername) + .append(", Passwd: ").append(mPasswd == null ? none : mPasswd) + .append(", SubDMAccUsername: ") + .append(mSubscriptionUpdateUsername == null ? none : mSubscriptionUpdateUsername) + .append(", SubDMAccPassword: ") + .append(mSubscriptionUpdatePassword == null ? none : mSubscriptionUpdatePassword) + .append(", PolDMAccUsername: ") + .append(mPolicyUpdateUsername == null ? none : mPolicyUpdateUsername) + .append(", PolDMAccPassword: ") + .append(mPolicyUpdatePassword == null ? none : mPolicyUpdatePassword) + .append(", Imsi: ").append(mImsi == null ? none : mImsi) + .append(", Mcc: ").append(mMcc == null ? none : mMcc) + .append(", Mnc: ").append(mMnc == null ? none : mMnc) + .append(", CaRootCert: ").append(mCaRootCert == null ? none : mCaRootCert) + .append(", Realm: ").append(mRealm == null ? none : mRealm) + .append(", Priority: ").append(mCrednetialPriority) + .append(", Fqdn: ").append(mHomeSpFqdn == null ? none : mHomeSpFqdn) + .append(", Otherhomepartners: ") + .append(mOtherHomePartnerList == null ? none : mOtherHomePartnerList) + .append(", ExpirationDate: ") + .append(mExpirationDate == null ? none : mExpirationDate) + .append(", MaxBssLoad: ").append(mMaxBssLoad == null ? none : mMaxBssLoad) + .append(", SPExclusionList: ").append(mSpExclusionList); + + if (mPreferredRoamingPartnerList != null) { + sb.append("PreferredRoamingPartnerList:"); + for (WifiPasspointDmTree.PreferredRoamingPartnerList prpListItem : mPreferredRoamingPartnerList) { + sb.append("[fqdnmatch:").append(prpListItem.FQDN_Match). + append(", priority:").append(prpListItem.Priority). + append(", country:").append(prpListItem.Country).append("]"); + } } - } - if (mHomeOIList != null) { - sb.append("HomeOIList:"); - for (WifiPasspointDmTree.HomeOIList HomeOIListItem : mHomeOIList) { - sb.append("[HomeOI:").append(HomeOIListItem.HomeOI). - append(", HomeOIRequired:").append(HomeOIListItem.HomeOIRequired). - append("]"); + if (mHomeOIList != null) { + sb.append("HomeOIList:"); + for (WifiPasspointDmTree.HomeOIList HomeOIListItem : mHomeOIList) { + sb.append("[HomeOI:").append(HomeOIListItem.HomeOI). + append(", HomeOIRequired:").append(HomeOIListItem.HomeOIRequired). + append("]"); + } } - } - if (mMinBackhaulThresholdNetwork != null) { - sb.append("BackHaulThreshold:"); - for (WifiPasspointDmTree.MinBackhaulThresholdNetwork BhtListItem : mMinBackhaulThresholdNetwork) { - sb.append("[networkType:").append(BhtListItem.NetworkType). - append(", dlBandwidth:").append(BhtListItem.DLBandwidth). - append(", ulBandwidth:").append(BhtListItem.ULBandwidth). - append("]"); + if (mMinBackhaulThresholdNetwork != null) { + sb.append("BackHaulThreshold:"); + for (WifiPasspointDmTree.MinBackhaulThresholdNetwork BhtListItem : mMinBackhaulThresholdNetwork) { + sb.append("[networkType:").append(BhtListItem.NetworkType). + append(", dlBandwidth:").append(BhtListItem.DLBandwidth). + append(", ulBandwidth:").append(BhtListItem.ULBandwidth). + append("]"); + } } - } - if (mRequiredProtoPortTuple != null) { - sb.append("WifiMORequiredProtoPortTupleList:"); - for (WifiPasspointDmTree.RequiredProtoPortTuple RpptListItem : mRequiredProtoPortTuple) { - sb.append("[IPProtocol:").append(RpptListItem.IPProtocol). - append(", PortNumber:").append(RpptListItem.PortNumber). - append("]"); + if (mRequiredProtoPortTuple != null) { + sb.append("WifiMORequiredProtoPortTupleList:"); + for (WifiPasspointDmTree.RequiredProtoPortTuple RpptListItem : mRequiredProtoPortTuple) { + sb.append("[IPProtocol:").append(RpptListItem.IPProtocol). + append(", PortNumber:").append(RpptListItem.PortNumber). + append("]"); + } } } - return sb.toString(); } @@ -636,19 +592,22 @@ public class WifiPasspointCredential implements Parcelable { /** Implement the Parcelable interface {@hide} */ public void writeToParcel(Parcel dest, int flags) { + dest.writeString(mWifiSpFqdn); + dest.writeString(mCredentialName); dest.writeString(mType); - dest.writeString(mUsername); - dest.writeString(mPasswd); - dest.writeString(mImsi); - dest.writeString(mMcc); - dest.writeString(mMnc); - dest.writeString(mCaRootCert); - dest.writeString(mRealm); - dest.writeInt(mPriority); + dest.writeInt(mCrednetialPriority); dest.writeString(mHomeSpFqdn); - dest.writeString(mOtherhomepartnerFqdn); - dest.writeString(mClientCert); - dest.writeString(mExpirationDate); + dest.writeString(mRealm); + } + + /** Implement the Parcelable interface {@hide} */ + public void readFromParcel(Parcel in) { + mWifiSpFqdn = in.readString(); + mCredentialName = in.readString(); + mType = in.readString(); + mCrednetialPriority = in.readInt(); + mHomeSpFqdn = in.readString(); + mRealm = in.readString(); } /** Implement the Parcelable interface {@hide} */ @@ -656,19 +615,12 @@ public class WifiPasspointCredential implements Parcelable { new Creator<WifiPasspointCredential>() { public WifiPasspointCredential createFromParcel(Parcel in) { WifiPasspointCredential pc = new WifiPasspointCredential(); + pc.mWifiSpFqdn = in.readString(); + pc.mCredentialName = in.readString(); pc.mType = in.readString(); - pc.mUsername = in.readString(); - pc.mPasswd = in.readString(); - pc.mImsi = in.readString(); - pc.mMcc = in.readString(); - pc.mMnc = in.readString(); - pc.mCaRootCert = in.readString(); - pc.mRealm = in.readString(); - pc.mPriority = in.readInt(); + pc.mCrednetialPriority = in.readInt(); pc.mHomeSpFqdn = in.readString(); - pc.mOtherhomepartnerFqdn = in.readString(); - pc.mClientCert = in.readString(); - pc.mExpirationDate = in.readString(); + pc.mRealm = in.readString(); return pc; } @@ -681,9 +633,9 @@ public class WifiPasspointCredential implements Parcelable { public int compareTo(WifiPasspointCredential another) { //The smaller the higher - if (mPriority < another.mPriority) { + if (mCrednetialPriority < another.mCrednetialPriority) { return -1; - } else if (mPriority == another.mPriority) { + } else if (mCrednetialPriority == another.mCrednetialPriority) { return this.mType.compareTo(another.mType); } else { return 1; diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointDmTree.java b/wifi/java/android/net/wifi/passpoint/WifiPasspointDmTree.java index 9ff1973..bbf5fc6 100644 --- a/wifi/java/android/net/wifi/passpoint/WifiPasspointDmTree.java +++ b/wifi/java/android/net/wifi/passpoint/WifiPasspointDmTree.java @@ -25,19 +25,17 @@ import java.util.HashMap; /** * Required Mobile Device Management Tree Structure * - * +----------+ - * | ./(Root) | - * +----+-----+ - * | - * +---------+ | +---------+ +---------+ - * | DevInfo |-----------+---------| Wi-Fi |---|SP FQDN* | - * +---------+ | +---------+ +---------+ - * +---------+ | - * |DevDetail|-----------+ - * +---------+ - * - * For example, - * ./Wi-Fi/wi-fi.org/PerproviderSubscription/Cred01/Policy/PreferredRoamingPartnerList/Roa01/FQDN_Math + * +----------+ + * | ./(Root) | + * +----+-----+ + * | + * +---------+ | +---------+ +---------+ + * | DevInfo |-----------+---------| Wi-Fi |--|SP FQDN* | + * +---------+ | +---------+ +---------+ + * +---------+ | | + * |DevDetail|-----------+ +-----------------------+ + * +---------+ |PerproviderSubscription|--<X>+ + * +-----------------------+ * * This class contains all nodes start from Wi-Fi * @hide diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.java b/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.java index 99bea2f..33db3f5 100644 --- a/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.java +++ b/wifi/java/android/net/wifi/passpoint/WifiPasspointInfo.java @@ -88,68 +88,160 @@ public class WifiPasspointInfo implements Parcelable { CONNECTION_CAPABILITY | OSU_PROVIDER; - /** TODO doc */ - public String bssid; - /** TODO doc */ - public String venueName; + public static class WanMetrics { + public static final int STATUS_RESERVED = 0; + public static final int STATUS_UP = 1; + public static final int STATUS_DOWN = 2; + public static final int STATUS_TEST = 3; + + public int wanInfo; + public long downlinkSpeed; + public long uplinkSpeed; + public int downlinkLoad; + public int uplinkLoad; + public int lmd; + + public int getLinkStatus() { + return wanInfo & 0x3; + } - /** TODO doc */ - public String networkAuthType; + public boolean getSymmetricLink() { + return (wanInfo & (1 << 2)) != 0; + } - /** TODO doc */ - public String roamingConsortium; + public boolean getAtCapacity() { + return (wanInfo & (1 << 3)) != 0; + } - /** TODO doc */ - public String ipAddrTypeAvaibility; + @Override + public String toString() { + return wanInfo + "," + downlinkSpeed + "," + uplinkSpeed + "," + + downlinkLoad + "," + uplinkLoad + "," + lmd; + } + } - /** TODO doc */ - public String naiRealm; + public static class IpProtoPort { + public static final int STATUS_CLOSED = 0; + public static final int STATUS_OPEN = 1; + public static final int STATUS_UNKNOWN = 2; - /** TODO doc */ - public String cellularNetwork; + public int proto; + public int port; + public int status; - /** TODO doc */ - public String domainName; + @Override + public String toString() { + return proto + "," + port + "," + status; + } + } - /** TODO doc */ - public String operatorFriendlyName; + public static class NetworkAuthType { + public static final int TYPE_TERMS_AND_CONDITION = 0; + public static final int TYPE_ONLINE_ENROLLMENT = 1; + public static final int TYPE_HTTP_REDIRECTION = 2; + public static final int TYPE_DNS_REDIRECTION = 3; - /** TODO doc */ - public String wanMetrics; + public int type; + public String redirectUrl; - /** TODO doc */ - public String connectionCapability; + @Override + public String toString() { + return type + "," + redirectUrl; + } + } - /** TODO doc */ - public List<WifiPasspointOsuProvider> osuProviderList; + public static class IpAddressType { + public static final int IPV6_NOT_AVAILABLE = 0; + public static final int IPV6_AVAILABLE = 1; + public static final int IPV6_UNKNOWN = 2; + + public static final int IPV4_NOT_AVAILABLE = 0; + public static final int IPV4_PUBLIC = 1; + public static final int IPV4_PORT_RESTRICTED = 2; + public static final int IPV4_SINGLE_NAT = 3; + public static final int IPV4_DOUBLE_NAT = 4; + public static final int IPV4_PORT_RESTRICTED_SINGLE_NAT = 5; + public static final int IPV4_PORT_RESTRICTED_DOUBLE_NAT = 6; + public static final int IPV4_PORT_UNKNOWN = 7; + + private static final int NULL_VALUE = -1; + + public int availability; - /** default constructor @hide */ - public WifiPasspointInfo() { - // osuProviderList = new ArrayList<OsuProvider>(); + public int getIpv6Availability() { + return availability & 0x3; + } + + public int getIpv4Availability() { + return (availability & 0xFF) >> 2; + } + + @Override + public String toString() { + return getIpv6Availability() + "," + getIpv4Availability(); + } } - /** copy constructor @hide */ - public WifiPasspointInfo(WifiPasspointInfo source) { - // TODO - bssid = source.bssid; - venueName = source.venueName; - networkAuthType = source.networkAuthType; - roamingConsortium = source.roamingConsortium; - ipAddrTypeAvaibility = source.ipAddrTypeAvaibility; - naiRealm = source.naiRealm; - cellularNetwork = source.cellularNetwork; - domainName = source.domainName; - operatorFriendlyName = source.operatorFriendlyName; - wanMetrics = source.wanMetrics; - connectionCapability = source.connectionCapability; - if (source.osuProviderList != null) { - osuProviderList = new ArrayList<WifiPasspointOsuProvider>(); - for (WifiPasspointOsuProvider osu : source.osuProviderList) - osuProviderList.add(new WifiPasspointOsuProvider(osu)); + public static class NaiRealm { + public static final int ENCODING_RFC4282 = 0; + public static final int ENCODING_UTF8 = 1; + + public int encoding; + public String realm; + + @Override + public String toString() { + return encoding + "," + realm; } } + public static class CellularNetwork { + public String mcc; + public String mnc; + + @Override + public String toString() { + return mcc + "," + mnc; + } + } + + /** BSSID */ + public String bssid; + + /** venue name */ + public String venueName; + + /** list of network authentication types */ + public List<NetworkAuthType> networkAuthTypeList; + + /** list of roaming consortium OIs */ + public List<String> roamingConsortiumList; + + /** IP address availability */ + public IpAddressType ipAddrTypeAvailability; + + /** list of NAI realm */ + public List<NaiRealm> naiRealmList; + + /** list of 3GPP cellular network */ + public List<CellularNetwork> cellularNetworkList; + + /** list of fully qualified domain name (FQDN) */ + public List<String> domainNameList; + + /** HS 2.0 operator friendly name */ + public String operatorFriendlyName; + + /** HS 2.0 wan metrics */ + public WanMetrics wanMetrics; + + /** list of HS 2.0 IP proto port */ + public List<IpProtoPort> connectionCapabilityList; + + /** list of HS 2.0 OSU providers */ + public List<WifiPasspointOsuProvider> osuProviderList; + /** * Convert mask to ANQP subtypes, for supplicant command use. * @@ -193,46 +285,155 @@ public class WifiPasspointInfo implements Parcelable { @Override public String toString() { StringBuffer sb = new StringBuffer(); - sb.append("BSSID: ").append(bssid); + + sb.append("BSSID: ").append("(").append(bssid).append(")"); + if (venueName != null) - sb.append(" venueName: ").append(venueName); - if (networkAuthType != null) - sb.append(" networkAuthType: ").append(networkAuthType); - if (roamingConsortium != null) - sb.append(" roamingConsortium: ").append(roamingConsortium); - if (ipAddrTypeAvaibility != null) - sb.append(" ipAddrTypeAvaibility: ").append(ipAddrTypeAvaibility); - if (naiRealm != null) - sb.append(" naiRealm: ").append(naiRealm); - if (cellularNetwork != null) - sb.append(" cellularNetwork: ").append(cellularNetwork); - if (domainName != null) - sb.append(" domainName: ").append(domainName); + sb.append(" venueName: ").append("(") + .append(venueName.replace("\n", "\\n")).append(")"); + + if (networkAuthTypeList != null) { + sb.append(" networkAuthType: "); + for (NetworkAuthType auth : networkAuthTypeList) + sb.append("(").append(auth.toString()).append(")"); + } + + if (roamingConsortiumList != null) { + sb.append(" roamingConsortium: "); + for (String oi : roamingConsortiumList) + sb.append("(").append(oi).append(")"); + } + + if (ipAddrTypeAvailability != null) { + sb.append(" ipAddrTypeAvaibility: ").append("(") + .append(ipAddrTypeAvailability.toString()).append(")"); + } + + if (naiRealmList != null) { + sb.append(" naiRealm: "); + for (NaiRealm realm : naiRealmList) + sb.append("(").append(realm.toString()).append(")"); + } + + if (cellularNetworkList != null) { + sb.append(" cellularNetwork: "); + for (CellularNetwork plmn : cellularNetworkList) + sb.append("(").append(plmn.toString()).append(")"); + } + + if (domainNameList != null) { + sb.append(" domainName: "); + for (String fqdn : domainNameList) + sb.append("(").append(fqdn).append(")"); + } + if (operatorFriendlyName != null) - sb.append(" operatorFriendlyName: ").append(operatorFriendlyName); + sb.append(" operatorFriendlyName: ").append("(") + .append(operatorFriendlyName).append(")"); + if (wanMetrics != null) - sb.append(" wanMetrics: ").append(wanMetrics); - if (connectionCapability != null) - sb.append(" connectionCapability: ").append(connectionCapability); - if (osuProviderList != null) - sb.append(" osuProviderList: (size=" + osuProviderList.size() + ")"); + sb.append(" wanMetrics: ").append("(") + .append(wanMetrics.toString()).append(")"); + + if (connectionCapabilityList != null) { + sb.append(" connectionCapability: "); + for (IpProtoPort ip : connectionCapabilityList) + sb.append("(").append(ip.toString()).append(")"); + } + + if (osuProviderList != null) { + sb.append(" osuProviderList: "); + for (WifiPasspointOsuProvider osu : osuProviderList) + sb.append("(").append(osu.toString()).append(")"); + } + return sb.toString(); } /** Implement the Parcelable interface {@hide} */ @Override public void writeToParcel(Parcel out, int flags) { - out.writeValue(bssid); - out.writeValue(venueName); - out.writeValue(networkAuthType); - out.writeValue(roamingConsortium); - out.writeValue(ipAddrTypeAvaibility); - out.writeValue(naiRealm); - out.writeValue(cellularNetwork); - out.writeValue(domainName); - out.writeValue(operatorFriendlyName); - out.writeValue(wanMetrics); - out.writeValue(connectionCapability); + out.writeString(bssid); + out.writeString(venueName); + + if (networkAuthTypeList == null) { + out.writeInt(0); + } else { + out.writeInt(networkAuthTypeList.size()); + for (NetworkAuthType auth : networkAuthTypeList) { + out.writeInt(auth.type); + out.writeString(auth.redirectUrl); + } + } + + if (roamingConsortiumList == null) { + out.writeInt(0); + } else { + out.writeInt(roamingConsortiumList.size()); + for (String oi : roamingConsortiumList) + out.writeString(oi); + } + + if (ipAddrTypeAvailability == null) { + out.writeInt(IpAddressType.NULL_VALUE); + } else { + out.writeInt(ipAddrTypeAvailability.availability); + } + + if (naiRealmList == null) { + out.writeInt(0); + } else { + out.writeInt(naiRealmList.size()); + for (NaiRealm realm : naiRealmList) { + out.writeInt(realm.encoding); + out.writeString(realm.realm); + } + } + + if (cellularNetworkList == null) { + out.writeInt(0); + } else { + out.writeInt(cellularNetworkList.size()); + for (CellularNetwork plmn : cellularNetworkList) { + out.writeString(plmn.mcc); + out.writeString(plmn.mnc); + } + } + + + if (domainNameList == null) { + out.writeInt(0); + } else { + out.writeInt(domainNameList.size()); + for (String fqdn : domainNameList) + out.writeString(fqdn); + } + + out.writeString(operatorFriendlyName); + + if (wanMetrics == null) { + out.writeInt(0); + } else { + out.writeInt(1); + out.writeInt(wanMetrics.wanInfo); + out.writeLong(wanMetrics.downlinkSpeed); + out.writeLong(wanMetrics.uplinkSpeed); + out.writeInt(wanMetrics.downlinkLoad); + out.writeInt(wanMetrics.uplinkLoad); + out.writeInt(wanMetrics.lmd); + } + + if (connectionCapabilityList == null) { + out.writeInt(0); + } else { + out.writeInt(connectionCapabilityList.size()); + for (IpProtoPort ip : connectionCapabilityList) { + out.writeInt(ip.proto); + out.writeInt(ip.port); + out.writeInt(ip.status); + } + } + if (osuProviderList == null) { out.writeInt(0); } else { @@ -254,18 +455,90 @@ public class WifiPasspointInfo implements Parcelable { @Override public WifiPasspointInfo createFromParcel(Parcel in) { WifiPasspointInfo p = new WifiPasspointInfo(); - p.bssid = (String) in.readValue(String.class.getClassLoader()); - p.venueName = (String) in.readValue(String.class.getClassLoader()); - p.networkAuthType = (String) in.readValue(String.class.getClassLoader()); - p.roamingConsortium = (String) in.readValue(String.class.getClassLoader()); - p.ipAddrTypeAvaibility = (String) in.readValue(String.class.getClassLoader()); - p.naiRealm = (String) in.readValue(String.class.getClassLoader()); - p.cellularNetwork = (String) in.readValue(String.class.getClassLoader()); - p.domainName = (String) in.readValue(String.class.getClassLoader()); - p.operatorFriendlyName = (String) in.readValue(String.class.getClassLoader()); - p.wanMetrics = (String) in.readValue(String.class.getClassLoader()); - p.connectionCapability = (String) in.readValue(String.class.getClassLoader()); - int n = in.readInt(); + int n; + + p.bssid = in.readString(); + p.venueName = in.readString(); + + n = in.readInt(); + if (n > 0) { + p.networkAuthTypeList = new ArrayList<NetworkAuthType>(); + for (int i = 0; i < n; i++) { + NetworkAuthType auth = new NetworkAuthType(); + auth.type = in.readInt(); + auth.redirectUrl = in.readString(); + p.networkAuthTypeList.add(auth); + } + } + + n = in.readInt(); + if (n > 0) { + p.roamingConsortiumList = new ArrayList<String>(); + for (int i = 0; i < n; i++) + p.roamingConsortiumList.add(in.readString()); + } + + n = in.readInt(); + if (n != IpAddressType.NULL_VALUE) { + p.ipAddrTypeAvailability = new IpAddressType(); + p.ipAddrTypeAvailability.availability = n; + } + + n = in.readInt(); + if (n > 0) { + p.naiRealmList = new ArrayList<NaiRealm>(); + for (int i = 0; i < n; i++) { + NaiRealm realm = new NaiRealm(); + realm.encoding = in.readInt(); + realm.realm = in.readString(); + p.naiRealmList.add(realm); + } + } + + n = in.readInt(); + if (n > 0) { + p.cellularNetworkList = new ArrayList<CellularNetwork>(); + for (int i = 0; i < n; i++) { + CellularNetwork plmn = new CellularNetwork(); + plmn.mcc = in.readString(); + plmn.mnc = in.readString(); + p.cellularNetworkList.add(plmn); + } + } + + n = in.readInt(); + if (n > 0) { + p.domainNameList = new ArrayList<String>(); + for (int i = 0; i < n; i++) + p.domainNameList.add(in.readString()); + } + + p.operatorFriendlyName = in.readString(); + + n = in.readInt(); + if (n > 0) { + p.wanMetrics = new WanMetrics(); + p.wanMetrics.wanInfo = in.readInt(); + p.wanMetrics.downlinkSpeed = in.readLong(); + p.wanMetrics.uplinkSpeed = in.readLong(); + p.wanMetrics.downlinkLoad = in.readInt(); + p.wanMetrics.uplinkLoad = in.readInt(); + p.wanMetrics.lmd = in.readInt(); + } + + n = in.readInt(); + if (n > 0) { + p.connectionCapabilityList = new ArrayList<IpProtoPort>(); + for (int i = 0; i < n; i++) { + IpProtoPort ip = new IpProtoPort(); + ip.proto = in.readInt(); + ip.port = in.readInt(); + ip.status = in.readInt(); + p.connectionCapabilityList.add(ip); + } + } + + n = in.readInt(); if (n > 0) { p.osuProviderList = new ArrayList<WifiPasspointOsuProvider>(); for (int i = 0; i < n; i++) { @@ -274,6 +547,7 @@ public class WifiPasspointInfo implements Parcelable { p.osuProviderList.add(osu); } } + return p; } diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointManager.java b/wifi/java/android/net/wifi/passpoint/WifiPasspointManager.java index e140c13..e7e6767 100644 --- a/wifi/java/android/net/wifi/passpoint/WifiPasspointManager.java +++ b/wifi/java/android/net/wifi/passpoint/WifiPasspointManager.java @@ -22,6 +22,8 @@ import android.os.Handler; import android.os.Looper; import android.os.Message; import android.os.Messenger; +import android.os.Parcel; +import android.os.Parcelable; import android.os.RemoteException; import android.util.Log; @@ -45,58 +47,53 @@ public class WifiPasspointManager { /* Passpoint states values */ - /** Passpoint is in an known state. This should only occur in boot time @hide */ + /** Passpoint is in an unknown state. This should only occur in boot time */ public static final int PASSPOINT_STATE_UNKNOWN = 0; - /** Passpoint is disabled. This occurs when wifi is disabled. @hide */ + /** Passpoint is disabled. This occurs when wifi is disabled */ public static final int PASSPOINT_STATE_DISABLED = 1; - /** Passpoint is enabled and in discovery state. @hide */ + /** Passpoint is enabled and in discovery state */ public static final int PASSPOINT_STATE_DISCOVERY = 2; - /** Passpoint is enabled and in access state. @hide */ + /** Passpoint is enabled and in access state */ public static final int PASSPOINT_STATE_ACCESS = 3; - /** Passpoint is enabled and in provisioning state. @hide */ + /** Passpoint is enabled and in provisioning state */ public static final int PASSPOINT_STATE_PROVISION = 4; /* Passpoint callback error codes */ - /** Indicates that the operation failed due to an internal error @hide */ - public static final int ERROR = 0; + /** Indicates that the operation failed due to an internal error */ + public static final int REASON_ERROR = 0; - /** Indicates that the operation failed because wifi is disabled @hide */ - public static final int WIFI_DISABLED = 1; + /** Indicates that the operation failed because wifi is disabled */ + public static final int REASON_WIFI_DISABLED = 1; - /** Indicates that the operation failed because the framework is busy @hide */ - public static final int BUSY = 2; + /** Indicates that the operation failed because the framework is busy */ + public static final int REASON_BUSY = 2; + + /** Indicates that the operation failed because parameter is invalid */ + public static final int REASON_INVALID_PARAMETER = 3; + + /** Indicates that the operation failed because the server is not trusted */ + public static final int REASON_NOT_TRUSTED = 4; /** * protocol supported for Passpoint - * @hide */ public static final String PROTOCOL_DM = "OMA-DM-ClientInitiated"; /** * protocol supported for Passpoint - * @hide */ public static final String PROTOCOL_SOAP = "SPP-ClientInitiated"; /* Passpoint broadcasts */ /** - * Broadcast intent action indicating that Passpoint online sign up is - * avaiable. - * @hide - */ - public static final String PASSPOINT_OSU_AVAILABLE = - "android.net.wifi.passpoint.OSU_AVAILABLE"; - - /** * Broadcast intent action indicating that the state of Passpoint * connectivity has changed - * @hide */ public static final String PASSPOINT_STATE_CHANGED_ACTION = "android.net.wifi.passpoint.STATE_CHANGE"; @@ -104,7 +101,6 @@ public class WifiPasspointManager { /** * Broadcast intent action indicating that the saved Passpoint credential * list has changed - * @hide */ public static final String PASSPOINT_CRED_CHANGED_ACTION = "android.net.wifi.passpoint.CRED_CHANGE"; @@ -112,21 +108,18 @@ public class WifiPasspointManager { /** * Broadcast intent action indicating that Passpoint online sign up is * avaiable. - * @hide */ public static final String PASSPOINT_OSU_AVAILABLE_ACTION = "android.net.wifi.passpoint.OSU_AVAILABLE"; /** * Broadcast intent action indicating that user remediation is required - * @hide */ public static final String PASSPOINT_USER_REM_REQ_ACTION = "android.net.wifi.passpoint.USER_REM_REQ"; /** * Interface for callback invocation when framework channel is lost - * @hide */ public interface ChannelListener { /** @@ -138,14 +131,13 @@ public class WifiPasspointManager { /** * Interface for callback invocation on an application action - * @hide */ public interface ActionListener { /** The operation succeeded */ public void onSuccess(); /** - * * The operation failed + * The operation failed * * @param reason The reason for failure could be one of * {@link #WIFI_DISABLED}, {@link #ERROR} or {@link #BUSY} @@ -155,7 +147,6 @@ public class WifiPasspointManager { /** * Interface for callback invocation when doing OSU or user remediation - * @hide */ public interface OsuRemListener { /** The operation succeeded */ @@ -171,11 +162,11 @@ public class WifiPasspointManager { /** * Browser launch is requried for user interaction. When this callback - * is called, app should launch browser / webview to the given URL. + * is called, app should launch browser / webview to the given URI. * - * @param url URL for browser launch + * @param uri URI for browser launch */ - public void onBrowserLaunch(String url); + public void onBrowserLaunch(String uri); /** * When this is called, app should dismiss the previously lanched browser. @@ -187,7 +178,6 @@ public class WifiPasspointManager { * A channel that connects the application to the wifi passpoint framework. * Most passpoint operations require a Channel as an argument. * An instance of Channel is obtained by doing a call on {@link #initialize} - * @hide */ public static class Channel { private final static int INVALID_LISTENER_KEY = 0; @@ -288,7 +278,8 @@ public class WifiPasspointManager { @Override public void handleMessage(Message message) { - Object listener = getListener(message.arg2, false); + Object listener = null; + switch (message.what) { case AsyncChannel.CMD_CHANNEL_DISCONNECTED: if (mChannelListener != null) { @@ -300,6 +291,7 @@ public class WifiPasspointManager { case REQUEST_ANQP_INFO_SUCCEEDED: WifiPasspointInfo result = (WifiPasspointInfo) message.obj; anqpRequestFinish(result); + listener = getListener(message.arg2, false); if (listener != null) { ((ActionListener) listener).onSuccess(); } @@ -307,6 +299,7 @@ public class WifiPasspointManager { case REQUEST_ANQP_INFO_FAILED: anqpRequestFinish((ScanResult) message.obj); + listener = getListener(message.arg2, false); if (listener == null) getListener(message.arg2, true); if (listener != null) { @@ -314,6 +307,31 @@ public class WifiPasspointManager { } break; + case START_OSU_SUCCEEDED: + listener = getListener(message.arg2, true); + if (listener != null) { + ((OsuRemListener) listener).onSuccess(); + } + break; + + case START_OSU_FAILED: + listener = getListener(message.arg2, true); + if (listener != null) { + ((OsuRemListener) listener).onFailure(message.arg1); + } + break; + + case START_OSU_BROWSER: + listener = getListener(message.arg2, true); + if (listener != null) { + ParcelableString str = (ParcelableString) message.obj; + if (str == null || str.string == null) + ((OsuRemListener) listener).onBrowserDismiss(); + else + ((OsuRemListener) listener).onBrowserLaunch(str.string); + } + break; + default: Log.d(TAG, "Ignored " + message); break; @@ -323,25 +341,46 @@ public class WifiPasspointManager { } - private static final int BASE = Protocol.BASE_WIFI_PASSPOINT_MANAGER; + public static class ParcelableString implements Parcelable { + public String string; - /** @hide */ - public static final int REQUEST_ANQP_INFO = BASE + 1; - - /** @hide */ - public static final int REQUEST_ANQP_INFO_FAILED = BASE + 2; + @Override + public int describeContents() { + return 0; + } - /** @hide */ - public static final int REQUEST_ANQP_INFO_SUCCEEDED = BASE + 3; + @Override + public void writeToParcel(Parcel out, int flags) { + out.writeString(string); + } - /** @hide */ - public static final int REQUEST_OSU_INFO = BASE + 4; + public static final Parcelable.Creator<ParcelableString> CREATOR = + new Parcelable.Creator<ParcelableString>() { + @Override + public ParcelableString createFromParcel(Parcel in) { + ParcelableString ret = new ParcelableString(); + ret.string = in.readString(); + return ret; + } + @Override + public ParcelableString[] newArray(int size) { + return new ParcelableString[size]; + } + }; + } - /** @hide */ - public static final int REQUEST_OSU_INFO_FAILED = BASE + 5; + private static final int BASE = Protocol.BASE_WIFI_PASSPOINT_MANAGER; - /** @hide */ - public static final int REQUEST_OSU_INFO_SUCCEEDED = BASE + 6; + public static final int REQUEST_ANQP_INFO = BASE + 1; + public static final int REQUEST_ANQP_INFO_FAILED = BASE + 2; + public static final int REQUEST_ANQP_INFO_SUCCEEDED = BASE + 3; + public static final int REQUEST_OSU_ICON = BASE + 4; + public static final int REQUEST_OSU_ICON_FAILED = BASE + 5; + public static final int REQUEST_OSU_ICON_SUCCEEDED = BASE + 6; + public static final int START_OSU = BASE + 7; + public static final int START_OSU_BROWSER = BASE + 8; + public static final int START_OSU_FAILED = BASE + 9; + public static final int START_OSU_SUCCEEDED = BASE + 10; private Context mContext; IWifiPasspointManager mService; @@ -350,7 +389,6 @@ public class WifiPasspointManager { * TODO: doc * @param context * @param service - * @hide */ public WifiPasspointManager(Context context, IWifiPasspointManager service) { mContext = context; @@ -368,7 +406,6 @@ public class WifiPasspointManager { * @return Channel instance that is necessary for performing any further * passpoint operations * - * @hide */ public Channel initialize(Context srcContext, Looper srcLooper, ChannelListener listener) { Messenger messenger = getMessenger(); @@ -387,8 +424,6 @@ public class WifiPasspointManager { /** * STOPSHIP: temp solution, should use supplicant manager instead, check * with b/13931972 - * - * @hide */ public Messenger getMessenger() { try { @@ -398,7 +433,6 @@ public class WifiPasspointManager { } } - /** @hide */ public int getPasspointState() { try { return mService.getPasspointState(); @@ -407,7 +441,6 @@ public class WifiPasspointManager { } } - /** @hide */ public void requestAnqpInfo(Channel c, List<ScanResult> requested, int mask, ActionListener listener) { Log.d(TAG, "requestAnqpInfo start"); @@ -434,24 +467,25 @@ public class WifiPasspointManager { Log.d(TAG, "requestAnqpInfo end"); } - /** @hide */ public void requestOsuIcons(Channel c, List<WifiPasspointOsuProvider> requested, int resolution, ActionListener listener) { } - /** @hide */ public List<WifiPasspointPolicy> requestCredentialMatch(List<ScanResult> requested) { - return null; + try { + return mService.requestCredentialMatch(requested); + } catch (RemoteException e) { + return null; + } } - /* TODO: add credential APIs */ - /** - * Give a list of all saved Passpoint credentials. + * Get a list of saved Passpoint credentials. Only those credentials owned + * by the caller will be returned. * * @return The list of credentials */ - public List<WifiPasspointCredential> getSavedCredentials() { + public List<WifiPasspointCredential> getCredentials() { return null; } @@ -487,21 +521,21 @@ public class WifiPasspointManager { return true; } - /** @hide */ - public void startOsu(Channel c, WifiPasspointOsuProvider selected, OsuRemListener listener) { - + public void startOsu(Channel c, WifiPasspointOsuProvider osu, OsuRemListener listener) { + Log.d(TAG, "startOsu start"); + checkChannel(c); + int key = c.putListener(listener); + c.mAsyncChannel.sendMessage(START_OSU, 0, key, osu); + Log.d(TAG, "startOsu end"); } - /** @hide */ - public void startUserRemediation(Channel c, OsuRemListener listener) { + public void startRemediation(Channel c, OsuRemListener listener) { } - /** @hide */ - public void connect(WifiPasspointPolicy selected) { + public void connect(WifiPasspointPolicy policy) { } private static void checkChannel(Channel c) { - if (c == null) - throw new IllegalArgumentException("Channel needs to be initialized"); + if (c == null) throw new IllegalArgumentException("Channel needs to be initialized"); } } diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointOsuProvider.java b/wifi/java/android/net/wifi/passpoint/WifiPasspointOsuProvider.java index 18a8f1e..b54b70c 100644 --- a/wifi/java/android/net/wifi/passpoint/WifiPasspointOsuProvider.java +++ b/wifi/java/android/net/wifi/passpoint/WifiPasspointOsuProvider.java @@ -87,22 +87,22 @@ public class WifiPasspointOsuProvider implements Parcelable { @Override public String toString() { StringBuffer sb = new StringBuffer(); - sb.append("SSID: ").append(ssid); + sb.append("SSID: ").append("<").append(ssid).append(">"); if (friendlyName != null) - sb.append(" friendlyName: ").append(friendlyName); + sb.append(" friendlyName: ").append("<").append(friendlyName).append(">"); if (serverUri != null) - sb.append(" serverUri: ").append(serverUri); - sb.append(" osuMethod: ").append(osuMethod); + sb.append(" serverUri: ").append("<").append(serverUri).append(">"); + sb.append(" osuMethod: ").append("<").append(osuMethod).append(">"); if (iconFileName != null) { - sb.append(" icon: [").append(iconWidth).append("x") + sb.append(" icon: <").append(iconWidth).append("x") .append(iconHeight).append(" ") .append(iconType).append(" ") - .append(iconFileName); + .append(iconFileName).append(">"); } if (osuNai != null) - sb.append(" osuNai: ").append(osuNai); + sb.append(" osuNai: ").append("<").append(osuNai).append(">"); if (osuService != null) - sb.append(" osuService: ").append(osuService); + sb.append(" osuService: ").append("<").append(osuService).append(">"); return sb.toString(); } @@ -113,16 +113,16 @@ public class WifiPasspointOsuProvider implements Parcelable { @Override public void writeToParcel(Parcel out, int flags) { - out.writeValue(ssid); - out.writeValue(friendlyName); - out.writeValue(serverUri); + out.writeString(ssid); + out.writeString(friendlyName); + out.writeString(serverUri); out.writeInt(osuMethod); out.writeInt(iconWidth); out.writeInt(iconHeight); - out.writeValue(iconType); - out.writeValue(iconFileName); - out.writeValue(osuNai); - out.writeValue(osuService); + out.writeString(iconType); + out.writeString(iconFileName); + out.writeString(osuNai); + out.writeString(osuService); // TODO: icon image? } @@ -131,16 +131,16 @@ public class WifiPasspointOsuProvider implements Parcelable { @Override public WifiPasspointOsuProvider createFromParcel(Parcel in) { WifiPasspointOsuProvider osu = new WifiPasspointOsuProvider(); - osu.ssid = (String) in.readValue(String.class.getClassLoader()); - osu.friendlyName = (String) in.readValue(String.class.getClassLoader()); - osu.serverUri = (String) in.readValue(String.class.getClassLoader()); + osu.ssid = in.readString(); + osu.friendlyName = in.readString(); + osu.serverUri = in.readString(); osu.osuMethod = in.readInt(); osu.iconWidth = in.readInt(); osu.iconHeight = in.readInt(); - osu.iconType = (String) in.readValue(String.class.getClassLoader()); - osu.iconFileName = (String) in.readValue(String.class.getClassLoader()); - osu.osuNai = (String) in.readValue(String.class.getClassLoader()); - osu.osuService = (String) in.readValue(String.class.getClassLoader()); + osu.iconType = in.readString(); + osu.iconFileName = in.readString(); + osu.osuNai = in.readString(); + osu.osuService = in.readString(); return osu; } diff --git a/wifi/java/android/net/wifi/passpoint/WifiPasspointPolicy.java b/wifi/java/android/net/wifi/passpoint/WifiPasspointPolicy.java index 5f76562..f84ac88 100644 --- a/wifi/java/android/net/wifi/passpoint/WifiPasspointPolicy.java +++ b/wifi/java/android/net/wifi/passpoint/WifiPasspointPolicy.java @@ -16,10 +16,18 @@ package android.net.wifi.passpoint; +import android.net.wifi.WifiConfiguration; +import android.net.wifi.ScanResult; import android.os.Parcelable; import android.os.Parcel; +import android.security.Credentials; import android.util.Log; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.List; + + /** @hide */ public class WifiPasspointPolicy implements Parcelable { @@ -35,7 +43,7 @@ public class WifiPasspointPolicy implements Parcelable { public static final int UNRESTRICTED = 2; private String mName; - private int mSubscriptionPriority; + private int mCredentialPriority; private int mRoamingPriority; private String mBssid; private String mSsid; @@ -43,12 +51,28 @@ public class WifiPasspointPolicy implements Parcelable { private int mRestriction;// Permitted values are "HomeSP", "RoamingPartner", or "Unrestricted" private boolean mIsHomeSp; + private final String INT_PRIVATE_KEY = "private_key"; + private final String INT_PHASE2 = "phase2"; + private final String INT_PASSWORD = "password"; + private final String INT_IDENTITY = "identity"; + private final String INT_EAP = "eap"; + private final String INT_CLIENT_CERT = "client_cert"; + private final String INT_CA_CERT = "ca_cert"; + private final String INT_ANONYMOUS_IDENTITY = "anonymous_identity"; + private final String INT_SIM_SLOT = "sim_slot"; + private final String INT_ENTERPRISEFIELD_NAME ="android.net.wifi.WifiConfiguration$EnterpriseField"; + private final String ISO8601DATEFORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; + private final String ENTERPRISE_PHASE2_MSCHAPV2 = "auth=MSCHAPV2"; + private final String ENTERPRISE_PHASE2_MSCHAP = "auth=MSCHAP"; + /** @hide */ - public WifiPasspointPolicy(String name, int priority, String ssid, + public WifiPasspointPolicy(String name, String ssid, String bssid, WifiPasspointCredential pc, int restriction, boolean ishomesp) { mName = name; - mSubscriptionPriority = priority; + if (pc != null) { + mCredentialPriority = pc.getPriority(); + } //PerProviderSubscription/<X+>/Policy/PreferredRoamingPartnerList/<X+>/Priority mRoamingPriority = 128; //default priority value of 128 mSsid = ssid; @@ -87,7 +111,7 @@ public class WifiPasspointPolicy implements Parcelable { } /** @hide */ - public boolean getHomeSp() { + public boolean isHomeSp() { return mIsHomeSp; } @@ -102,8 +126,8 @@ public class WifiPasspointPolicy implements Parcelable { } /** @hide */ - public void setSubscriptionPriority(int priority) { - mSubscriptionPriority = priority; + public void setCredentialPriority(int priority) { + mCredentialPriority = priority; } /** @hide */ @@ -111,14 +135,150 @@ public class WifiPasspointPolicy implements Parcelable { mRoamingPriority = priority; } - public int getSubscriptionPriority() { - return mSubscriptionPriority; + public int getCredentialPriority() { + return mCredentialPriority; } public int getRoamingPriority() { return mRoamingPriority; } + public WifiConfiguration createWifiConfiguration() { + WifiConfiguration wfg = new WifiConfiguration(); + if (mBssid != null) { + Log.d(TAG, "create bssid:" + mBssid); + wfg.BSSID = mBssid; + } + + if (mSsid != null) { + Log.d(TAG, "create ssid:" + mSsid); + wfg.SSID = mSsid; + } + //TODO: 1. add pmf configuration + // 2. add ocsp configuration + // 3. add eap-sim configuration + /*Key management*/ + wfg.status = WifiConfiguration.Status.ENABLED; + wfg.allowedKeyManagement.clear(); + wfg.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP); + wfg.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X); + + /*Group Ciphers*/ + wfg.allowedGroupCiphers.clear(); + wfg.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); + wfg.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); + + /*Protocols*/ + wfg.allowedProtocols.clear(); + wfg.allowedProtocols.set(WifiConfiguration.Protocol.RSN); + wfg.allowedProtocols.set(WifiConfiguration.Protocol.WPA); + + Class[] enterpriseFieldArray = WifiConfiguration.class.getClasses(); + Class<?> enterpriseFieldClass = null; + + + for(Class<?> myClass : enterpriseFieldArray) { + if(myClass.getName().equals(INT_ENTERPRISEFIELD_NAME)) { + enterpriseFieldClass = myClass; + break; + } + } + Log.d(TAG, "class chosen " + enterpriseFieldClass.getName() ); + + + Field anonymousId = null, caCert = null, clientCert = null, + eap = null, identity = null, password = null, + phase2 = null, privateKey = null; + + Field[] fields = WifiConfiguration.class.getFields(); + + + for (Field tempField : fields) { + if (tempField.getName().trim().equals(INT_ANONYMOUS_IDENTITY)) { + anonymousId = tempField; + Log.d(TAG, "field " + anonymousId.getName() ); + } else if (tempField.getName().trim().equals(INT_CA_CERT)) { + caCert = tempField; + } else if (tempField.getName().trim().equals(INT_CLIENT_CERT)) { + clientCert = tempField; + Log.d(TAG, "field " + clientCert.getName() ); + } else if (tempField.getName().trim().equals(INT_EAP)) { + eap = tempField; + Log.d(TAG, "field " + eap.getName() ); + } else if (tempField.getName().trim().equals(INT_IDENTITY)) { + identity = tempField; + Log.d(TAG, "field " + identity.getName() ); + } else if (tempField.getName().trim().equals(INT_PASSWORD)) { + password = tempField; + Log.d(TAG, "field " + password.getName() ); + } else if (tempField.getName().trim().equals(INT_PHASE2)) { + phase2 = tempField; + Log.d(TAG, "field " + phase2.getName() ); + + } else if (tempField.getName().trim().equals(INT_PRIVATE_KEY)) { + privateKey = tempField; + } + } + + + Method setValue = null; + + for(Method m: enterpriseFieldClass.getMethods()) { + if(m.getName().trim().equals("setValue")) { + Log.d(TAG, "method " + m.getName() ); + setValue = m; + break; + } + } + + try { + // EAP + String eapmethod = mCredential.getType(); + Log.d(TAG, "eapmethod:" + eapmethod); + setValue.invoke(eap.get(wfg), eapmethod); + + // Username, password, EAP Phase 2 + if ("TTLS".equals(eapmethod)) { + setValue.invoke(phase2.get(wfg), ENTERPRISE_PHASE2_MSCHAPV2); + setValue.invoke(identity.get(wfg), mCredential.getUserName()); + setValue.invoke(password.get(wfg), mCredential.getPassword()); + setValue.invoke(anonymousId.get(wfg), "anonymous@" + mCredential.getRealm()); + } + + // EAP CA Certificate + String cacertificate = null; + String rootCA = mCredential.getCaRootCertPath(); + if (rootCA == null){ + cacertificate = null; + } else { + cacertificate = "keystore://" + Credentials.WIFI + "HS20" + Credentials.CA_CERTIFICATE + rootCA; + } + Log.d(TAG, "cacertificate:" + cacertificate); + setValue.invoke(caCert.get(wfg), cacertificate); + + //User certificate + if ("TLS".equals(eapmethod)) { + String usercertificate = null; + String privatekey = null; + String clientCertPath = mCredential.getClientCertPath(); + if (clientCertPath != null){ + privatekey = "keystore://" + Credentials.WIFI + "HS20" + Credentials.USER_PRIVATE_KEY + clientCertPath; + usercertificate = "keystore://" + Credentials.WIFI + "HS20" + Credentials.USER_CERTIFICATE + clientCertPath; + } + Log.d(TAG, "privatekey:" + privatekey); + Log.d(TAG, "usercertificate:" + usercertificate); + if (privatekey != null && usercertificate != null) { + setValue.invoke(privateKey.get(wfg), privatekey); + setValue.invoke(clientCert.get(wfg), usercertificate); + } + } + } catch (Exception e) { + Log.d(TAG, "createWifiConfiguration err:" + e); + } + + return wfg; + } + /** {@inheritDoc} @hide */ public int compareTo(WifiPasspointPolicy another) { Log.d(TAG, "this:" + this); @@ -126,17 +286,17 @@ public class WifiPasspointPolicy implements Parcelable { if (another == null) { return -1; - } else if (this.mIsHomeSp == true && another.getHomeSp() == false) { + } else if (this.mIsHomeSp == true && another.isHomeSp() == false) { //home sp priority is higher then roaming Log.d(TAG, "compare HomeSP first, this is HomeSP, another isn't"); return -1; - } else if ((this.mIsHomeSp == true && another.getHomeSp() == true)) { + } else if ((this.mIsHomeSp == true && another.isHomeSp() == true)) { Log.d(TAG, "both HomeSP"); - //if both home sp, compare subscription priority - if (this.mSubscriptionPriority < another.getSubscriptionPriority()) { + //if both home sp, compare credential priority + if (this.mCredentialPriority < another.getCredentialPriority()) { Log.d(TAG, "this priority is higher"); return -1; - } else if (this.mSubscriptionPriority == another.getSubscriptionPriority()) { + } else if (this.mCredentialPriority == another.getCredentialPriority()) { Log.d(TAG, "both priorities equal"); //if priority still the same, compare name(ssid) if (this.mName.compareTo(another.mName) != 0) { @@ -158,7 +318,7 @@ public class WifiPasspointPolicy implements Parcelable { } else { return 1; } - } else if ((this.mIsHomeSp == false && another.getHomeSp() == false)) { + } else if ((this.mIsHomeSp == false && another.isHomeSp() == false)) { Log.d(TAG, "both RoamingSp"); //if both roaming sp, compare roaming priority(preferredRoamingPartnerList/<X+>/priority) if (this.mRoamingPriority < another.getRoamingPriority()) { @@ -192,7 +352,7 @@ public class WifiPasspointPolicy implements Parcelable { @Override /** @hide */ public String toString() { - return "PasspointPolicy: name=" + mName + " SubscriptionPriority=" + mSubscriptionPriority + + return "PasspointPolicy: name=" + mName + " CredentialPriority=" + mCredentialPriority + " mRoamingPriority" + mRoamingPriority + " ssid=" + mSsid + " restriction=" + mRestriction + " ishomesp=" + mIsHomeSp + " Credential=" + mCredential; |