diff options
author | Yuhao Zheng <yuhaozheng@google.com> | 2014-05-13 09:40:27 -0700 |
---|---|---|
committer | Vinit Deshpande <vinitd@google.com> | 2014-05-18 09:41:35 -0700 |
commit | 0c78205e664e679c4bf9543e17372879d5010611 (patch) | |
tree | 6041627444b28051aefbb578bd67c5b5c2e9d508 /wifi/java/android/net | |
parent | a4864472313208e4f1de02f45d3eadad237c54af (diff) | |
download | frameworks_base-0c78205e664e679c4bf9543e17372879d5010611.zip frameworks_base-0c78205e664e679c4bf9543e17372879d5010611.tar.gz frameworks_base-0c78205e664e679c4bf9543e17372879d5010611.tar.bz2 |
Hotspot 2.0 framework API -- more functionalities
- Added resolution parameter for requestOsuIcons()
- Added ANQP parser (OSU provider list only)
Bug: 5485670
Change-Id: I69f6fd2ce6f80980ad786c2a3833cca8279771b3
Diffstat (limited to 'wifi/java/android/net')
4 files changed, 147 insertions, 25 deletions
diff --git a/wifi/java/android/net/wifi/ScanResult.java b/wifi/java/android/net/wifi/ScanResult.java index 6d66b4c..49d565c 100644 --- a/wifi/java/android/net/wifi/ScanResult.java +++ b/wifi/java/android/net/wifi/ScanResult.java @@ -165,7 +165,8 @@ public class ScanResult implements Parcelable { sb.append(", distanceSd: ").append((distanceSdCm != UNSPECIFIED ? distanceSdCm : "?")). append("(cm)"); - if (passpoint != null) sb.append(passpoint.toString()); + if (passpoint != null) + sb.append(", passpoint: [").append(passpoint.toString()).append("]"); return sb.toString(); } diff --git a/wifi/java/android/net/wifi/passpoint/PasspointInfo.java b/wifi/java/android/net/wifi/passpoint/PasspointInfo.java index 4997aa9..d57b0aa 100644 --- a/wifi/java/android/net/wifi/passpoint/PasspointInfo.java +++ b/wifi/java/android/net/wifi/passpoint/PasspointInfo.java @@ -182,16 +182,54 @@ public class PasspointInfo implements Parcelable { @Override public String toString() { - // TODO - return "PasspointInfo"; + StringBuffer sb = new StringBuffer(); + sb.append("BSSID: ").append(bssid); + 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); + if (operatorFriendlyName != null) + sb.append(" operatorFriendlyName: ").append(operatorFriendlyName); + 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() + ")"); + return sb.toString(); } /** Implement the Parcelable interface {@hide} */ @Override public void writeToParcel(Parcel out, int flags) { - // TODO 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); + if (osuProviderList == null) { + out.writeInt(0); + } else { + out.writeInt(osuProviderList.size()); + for (PasspointOsuProvider osu : osuProviderList) + osu.writeToParcel(out, flags); + } } /** Implement the Parcelable interface {@hide} */ @@ -205,11 +243,27 @@ public class PasspointInfo implements Parcelable { new Parcelable.Creator<PasspointInfo>() { @Override public PasspointInfo createFromParcel(Parcel in) { - PasspointInfo pi = new PasspointInfo(); - pi.bssid = (String) in.readValue(String.class.getClassLoader()); - pi.venueName = (String) in.readValue(String.class.getClassLoader()); - // TODO - return pi; + PasspointInfo p = new PasspointInfo(); + 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(); + if (n > 0) { + p.osuProviderList = new ArrayList<PasspointOsuProvider>(); + for (int i = 0; i < n; i++) { + PasspointOsuProvider osu = PasspointOsuProvider.CREATOR.createFromParcel(in); + p.osuProviderList.add(osu); + } + } + return p; } @Override diff --git a/wifi/java/android/net/wifi/passpoint/PasspointManager.java b/wifi/java/android/net/wifi/passpoint/PasspointManager.java index f32536f..d6a2000 100644 --- a/wifi/java/android/net/wifi/passpoint/PasspointManager.java +++ b/wifi/java/android/net/wifi/passpoint/PasspointManager.java @@ -226,13 +226,13 @@ public class PasspointManager { synchronized(mAnqpRequestLock) { mAnqpRequest.add(sr); } } - private void anqpRequestFinish(PasspointInfo pi) { - Log.d(TAG, "anqpRequestFinish pi.bssid=" + pi.bssid); + private void anqpRequestFinish(PasspointInfo result) { + Log.d(TAG, "anqpRequestFinish pi.bssid=" + result.bssid); synchronized(mAnqpRequestLock) { for (ScanResult sr : mAnqpRequest) - if (sr.BSSID.equals(pi.bssid)) { - Log.d(TAG, "find hit " + pi.bssid); - sr.passpoint = pi; + if (sr.BSSID.equals(result.bssid)) { + Log.d(TAG, "find hit " + result.bssid); + sr.passpoint = result; mAnqpRequest.remove(sr); Log.d(TAG, "mAnqpRequest.len=" + mAnqpRequest.size()); break; @@ -268,8 +268,8 @@ public class PasspointManager { break; case REQUEST_ANQP_INFO_SUCCEEDED: - PasspointInfo pi = (PasspointInfo) message.obj; - anqpRequestFinish(pi); + PasspointInfo result = (PasspointInfo) message.obj; + anqpRequestFinish(result); if (listener != null) { ((ActionListener) listener).onSuccess(); } @@ -396,13 +396,17 @@ public class PasspointManager { */ public void requestAnqpInfo(Channel c, List<ScanResult> requested, int mask, ActionListener listener) { + Log.d(TAG, "requestAnqpInfo start"); + Log.d(TAG, "requested.size=" + requested.size()); checkChannel(c); List<ScanResult> list = new ArrayList<ScanResult>(); for (ScanResult sr : requested) if (sr.capabilities.contains("[HS20]")) { list.add(sr); c.anqpRequestStart(sr); + Log.d(TAG, "adding " + sr.BSSID); } int count = list.size(); + Log.d(TAG, "after filter, count=" + count); if (count == 0) { if (DBG) Log.d(TAG, "ANQP info request contains no HS20 APs, skipped"); listener.onSuccess(); @@ -411,6 +415,7 @@ public class PasspointManager { int key = c.putListener(listener, count); for (ScanResult sr : list) c.mAsyncChannel.sendMessage(REQUEST_ANQP_INFO, mask, key, sr); + Log.d(TAG, "requestAnqpInfo end"); } /** @@ -418,10 +423,21 @@ public class PasspointManager { * * @param c * @param requested + * @param resolution * @param listener */ public void requestOsuIcons(Channel c, List<PasspointOsuProvider> requested, - ActionListener listener) { + int resolution, ActionListener listener) { + } + + /** + * TODO: doc + * + * @param requested + * @return + */ + public List<PasspointPolicy> requestCredentialMatch(List<ScanResult> requested) { + return null; } /* TODO: add credential APIs */ @@ -478,10 +494,8 @@ public class PasspointManager { * Select and connect to a Passpoint network. * * @param policy Selected Passpoint network, see {@link PasspointPolicy} - * @return {@code true} if the operation succeeds, {@code false} otherwise */ - public boolean connect(PasspointPolicy policy) { - return true; + public void connect(PasspointPolicy selected) { } private static void checkChannel(Channel c) { diff --git a/wifi/java/android/net/wifi/passpoint/PasspointOsuProvider.java b/wifi/java/android/net/wifi/passpoint/PasspointOsuProvider.java index b896307..80d5315 100644 --- a/wifi/java/android/net/wifi/passpoint/PasspointOsuProvider.java +++ b/wifi/java/android/net/wifi/passpoint/PasspointOsuProvider.java @@ -25,13 +25,16 @@ import android.os.Parcelable; public class PasspointOsuProvider implements Parcelable { /** TODO: doc */ + public static final int OSU_METHOD_UNKNOWN = -1; + + /** TODO: doc */ public static final int OSU_METHOD_OMADM = 0; /** TODO: doc */ public static final int OSU_METHOD_SOAP = 1; /** TODO: doc */ - public String SSID; + public String ssid; /** TODO: doc */ public String friendlyName; @@ -40,7 +43,16 @@ public class PasspointOsuProvider implements Parcelable { public String serverUri; /** TODO: doc */ - public int osuMethod; + public int osuMethod = OSU_METHOD_UNKNOWN; + + /** TODO: doc */ + public int iconWidth; + + /** TODO: doc */ + public int iconHeight; + + /** TODO: doc */ + public String iconType; /** TODO: doc */ public String iconFileName; @@ -66,13 +78,45 @@ public class PasspointOsuProvider implements Parcelable { } @Override + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append("SSID: ").append(ssid); + if (friendlyName != null) + sb.append(" friendlyName: ").append(friendlyName); + if (serverUri != null) + sb.append(" serverUri: ").append(serverUri); + sb.append(" osuMethod: ").append(osuMethod); + if (iconFileName != null) { + sb.append(" icon: [").append(iconWidth).append("x") + .append(iconHeight).append(" ") + .append(iconType).append(" ") + .append(iconFileName); + } + if (osuNai != null) + sb.append(" osuNai: ").append(osuNai); + if (osuService != null) + sb.append(" osuService: ").append(osuService); + return sb.toString(); + } + + @Override public int describeContents() { return 0; } @Override - public void writeToParcel(Parcel dest, int flags) { - // TODO + public void writeToParcel(Parcel out, int flags) { + out.writeValue(ssid); + out.writeValue(friendlyName); + out.writeValue(serverUri); + out.writeInt(osuMethod); + out.writeInt(iconWidth); + out.writeInt(iconHeight); + out.writeValue(iconType); + out.writeValue(iconFileName); + out.writeValue(osuNai); + out.writeValue(osuService); + // TODO: icon image? } public static final Parcelable.Creator<PasspointOsuProvider> CREATOR = @@ -80,7 +124,16 @@ public class PasspointOsuProvider implements Parcelable { @Override public PasspointOsuProvider createFromParcel(Parcel in) { PasspointOsuProvider osu = new PasspointOsuProvider(); - // TODO + 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.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()); return osu; } |