From b21d2489c1bd330e39f4489c7f221ebb4dffc283 Mon Sep 17 00:00:00 2001 From: Vinit Deshpande Date: Mon, 2 Feb 2015 10:50:36 -0800 Subject: [PATCH] Passpoint API - Take 1 Added some common fields to WifiConfigurations; which should be used with WifiEnterpriseConfig. The network information is saved in a file. Change-Id: Ica2069900dfc373e14792cbe81a185586e2954cc --- api/current.txt | 12 +++- wifi/java/android/net/wifi/WifiConfiguration.java | 70 +++++++++++++++------- .../android/net/wifi/WifiEnterpriseConfig.java | 65 +++++++++++++++++++- 3 files changed, 120 insertions(+), 27 deletions(-) diff --git a/api/current.txt b/api/current.txt index 753c940e4d60..e44002e250e5 100644 --- a/api/current.txt +++ b/api/current.txt @@ -17916,6 +17916,8 @@ package android.net.wifi { field public int networkId; field public java.lang.String preSharedKey; field public int priority; + field public java.lang.String providerFriendlyName; + field public java.util.HashSet roamingConsortiumIds; field public int status; field public java.lang.String[] wepKeys; field public int wepTxKeyIndex; @@ -17973,6 +17975,7 @@ package android.net.wifi { ctor public WifiEnterpriseConfig(); ctor public WifiEnterpriseConfig(android.net.wifi.WifiEnterpriseConfig); method public int describeContents(); + method public java.lang.String getAltSubjectMatch(); method public java.lang.String getAnonymousIdentity(); method public java.security.cert.X509Certificate getCaCertificate(); method public java.security.cert.X509Certificate getClientCertificate(); @@ -17980,7 +17983,10 @@ package android.net.wifi { method public java.lang.String getIdentity(); method public java.lang.String getPassword(); method public int getPhase2Method(); - method public java.lang.String getSubjectMatch(); + method public java.lang.String getPlmn(); + method public java.lang.String getRealm(); + method public deprecated java.lang.String getSubjectMatch(); + method public void setAltSubjectMatch(java.lang.String); method public void setAnonymousIdentity(java.lang.String); method public void setCaCertificate(java.security.cert.X509Certificate); method public void setClientKeyEntry(java.security.PrivateKey, java.security.cert.X509Certificate); @@ -17988,7 +17994,9 @@ package android.net.wifi { method public void setIdentity(java.lang.String); method public void setPassword(java.lang.String); method public void setPhase2Method(int); - method public void setSubjectMatch(java.lang.String); + method public void setPlmn(java.lang.String); + method public void setRealm(java.lang.String); + method public deprecated void setSubjectMatch(java.lang.String); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; } diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java index 22c236ebdf20..65346c05a474 100644 --- a/wifi/java/android/net/wifi/WifiConfiguration.java +++ b/wifi/java/android/net/wifi/WifiConfiguration.java @@ -19,22 +19,18 @@ package android.net.wifi; import android.annotation.SystemApi; import android.net.IpConfiguration; import android.net.IpConfiguration.ProxySettings; -import android.net.IpConfiguration.IpAssignment; import android.net.ProxyInfo; import android.net.StaticIpConfiguration; import android.os.Parcel; import android.os.Parcelable; import android.text.TextUtils; -import android.util.Log; -import android.annotation.SystemApi; -import java.util.Random; -import java.util.Calendar; import java.util.HashMap; import java.util.BitSet; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.HashSet; /** * A class representing a configured Wi-Fi network, including the @@ -254,18 +250,6 @@ public class WifiConfiguration implements Parcelable { public int apChannel = 0; /** - * Fully qualified domain name (FQDN) of AAA server or RADIUS server - * e.g. {@code "mail.example.com"}. - */ - public String FQDN; - /** - * Network access identifier (NAI) realm, for Passpoint credential. - * e.g. {@code "myhost.example.com"}. - * @hide - */ - public String naiRealm; - - /** * Pre-shared key for use with WPA-PSK. *

* When the value of this key is read, the actual key is @@ -348,6 +332,21 @@ public class WifiConfiguration implements Parcelable { public WifiEnterpriseConfig enterpriseConfig; /** + * Fully qualified domain name of a passpoint configuration + */ + public String FQDN; + + /** + * Service provider name, for Passpoint credential. + */ + public String providerFriendlyName; + + /** + * Roaming Consortium Id, for Passpoint credential. + */ + public HashSet roamingConsortiumIds; + + /** * @hide */ private IpConfiguration mIpConfiguration; @@ -857,7 +856,7 @@ public class WifiConfiguration implements Parcelable { SSID = null; BSSID = null; FQDN = null; - naiRealm = null; + roamingConsortiumIds = new HashSet(); priority = 0; hiddenSSID = false; disableReason = DISABLED_UNKNOWN_REASON; @@ -902,6 +901,17 @@ public class WifiConfiguration implements Parcelable { } } + if (FQDN != null) { + /* must have a providerFriendlyName */ + if (providerFriendlyName == null) { + return false; + } + /* this is passpoint configuration; it must have enterprise config */ + if (enterpriseConfig == null) { + return false; + } + } + // TODO: Add more checks return true; } @@ -1037,8 +1047,9 @@ public class WifiConfiguration implements Parcelable { sbuf.append("- DSBLE "); } sbuf.append("ID: ").append(this.networkId).append(" SSID: ").append(this.SSID). + append(" PROVIDER-NAME: ").append(this.providerFriendlyName). append(" BSSID: ").append(this.BSSID).append(" FQDN: ").append(this.FQDN). - append(" REALM: ").append(this.naiRealm).append(" PRIO: ").append(this.priority). + append(" PRIO: ").append(this.priority). append('\n'); if (this.numConnectionFailures > 0) { sbuf.append(" numConnectFailures ").append(this.numConnectionFailures).append("\n"); @@ -1366,6 +1377,8 @@ public class WifiConfiguration implements Parcelable { String key; if (allowCached && mCachedConfigKey != null) { key = mCachedConfigKey; + } else if (providerFriendlyName != null) { + key = FQDN + KeyMgmt.strings[KeyMgmt.WPA_EAP]; } else { if (allowedKeyManagement.get(KeyMgmt.WPA_PSK)) { key = SSID + KeyMgmt.strings[KeyMgmt.WPA_PSK]; @@ -1481,7 +1494,12 @@ public class WifiConfiguration implements Parcelable { SSID = source.SSID; BSSID = source.BSSID; FQDN = source.FQDN; - naiRealm = source.naiRealm; + roamingConsortiumIds = new HashSet(); + for (Long roamingConsortiumId : source.roamingConsortiumIds) { + roamingConsortiumIds.add(roamingConsortiumId); + } + + providerFriendlyName = source.providerFriendlyName; preSharedKey = source.preSharedKey; apBand = source.apBand; @@ -1580,7 +1598,11 @@ public class WifiConfiguration implements Parcelable { dest.writeInt(apChannel); dest.writeString(autoJoinBSSID); dest.writeString(FQDN); - dest.writeString(naiRealm); + dest.writeString(providerFriendlyName); + dest.writeInt(roamingConsortiumIds.size()); + for (Long roamingConsortiumId : roamingConsortiumIds) { + dest.writeLong(roamingConsortiumId); + } dest.writeString(preSharedKey); for (String wepKey : wepKeys) { dest.writeString(wepKey); @@ -1644,7 +1666,11 @@ public class WifiConfiguration implements Parcelable { config.apChannel = in.readInt(); config.autoJoinBSSID = in.readString(); config.FQDN = in.readString(); - config.naiRealm = in.readString(); + config.providerFriendlyName = in.readString(); + int numRoamingConsortiumIds = in.readInt(); + for (int i = 0; i < numRoamingConsortiumIds; i++) { + config.roamingConsortiumIds.add(in.readLong()); + } config.preSharedKey = in.readString(); for (int i = 0; i < config.wepKeys.length; i++) { config.wepKeys[i] = in.readString(); diff --git a/wifi/java/android/net/wifi/WifiEnterpriseConfig.java b/wifi/java/android/net/wifi/WifiEnterpriseConfig.java index cf3cba3ec0da..36fc96b81feb 100644 --- a/wifi/java/android/net/wifi/WifiEnterpriseConfig.java +++ b/wifi/java/android/net/wifi/WifiEnterpriseConfig.java @@ -54,6 +54,8 @@ public class WifiEnterpriseConfig implements Parcelable { /** @hide */ public static final String SUBJECT_MATCH_KEY = "subject_match"; /** @hide */ + public static final String ALTSUBJECT_MATCH_KEY = "altsubject_match"; + /** @hide */ public static final String OPP_KEY_CACHING = "proactive_key_caching"; /** * String representing the keystore OpenSSL ENGINE's ID. @@ -93,6 +95,11 @@ public class WifiEnterpriseConfig implements Parcelable { public static final String ENGINE_ID_KEY = "engine_id"; /** @hide */ public static final String PRIVATE_KEY_ID_KEY = "key_id"; + /** @hide */ + public static final String REALM_KEY = "realm"; + /** @hide */ + public static final String PLMN_KEY = "plmn"; + private HashMap mFields = new HashMap(); private X509Certificate mCaCert; @@ -530,22 +537,74 @@ public class WifiEnterpriseConfig implements Parcelable { } /** - * Set subject match. This is the substring to be matched against the subject of the - * authentication server certificate. + * Set subject match (deprecated). This is the substring to be matched against the subject of + * the authentication server certificate. * @param subjectMatch substring to be matched + * @deprecated in favor of altSubjectMatch */ public void setSubjectMatch(String subjectMatch) { setFieldValue(SUBJECT_MATCH_KEY, subjectMatch, ""); } /** - * Get subject match + * Get subject match (deprecated) * @return the subject match string + * @deprecated in favor of altSubjectMatch */ public String getSubjectMatch() { return getFieldValue(SUBJECT_MATCH_KEY, ""); } + /** + * Set alternate subject match. This is the substring to be matched against the + * alternate subject of the authentication server certificate. + * @param altSubjectMatch substring to be matched, for example + * DNS:server.example.com;EMAIL:server@example.com + */ + public void setAltSubjectMatch(String altSubjectMatch) { + setFieldValue(ALTSUBJECT_MATCH_KEY, altSubjectMatch, ""); + } + + /** + * Get alternate subject match + * @return the alternate subject match string + */ + public String getAltSubjectMatch() { + return getFieldValue(ALTSUBJECT_MATCH_KEY, ""); + } + + /** + * Set realm for passpoint credential + * @param realm the realm + */ + public void setRealm(String realm) { + setFieldValue(REALM_KEY, realm, ""); + } + + /** + * Get realm for passpoint credential + * @return the realm + */ + public String getRealm() { + return getFieldValue(REALM_KEY, ""); + } + + /** + * Set plmn for passpoint credential + * @param plmn the plmn value derived from mcc & mnc + */ + public void setPlmn(String plmn) { + setFieldValue(PLMN_KEY, plmn, ""); + } + + /** + * Set plmn for passpoint credential + * @return the plmn + */ + public String getPlmn() { + return getFieldValue(PLMN_KEY, ""); + } + /** See {@link WifiConfiguration#getKeyIdForCredentials} @hide */ String getKeyId(WifiEnterpriseConfig current) { String eap = mFields.get(EAP_KEY); -- 2.11.0