DO NOT MERGE Hotspot 2.0 relase 2 first cut.
CP mods to take a URL as a parameter, and new ScanInfo object.
Cherry-picked from 52eb29f0822f129f2b14bacec23dd492f2260ac0
Change-Id: Idbb2d4751c575ba07a56942771e2b2955b624635
diff --git a/Android.mk b/Android.mk
index ce01c20..f2bd387 100644
--- a/Android.mk
+++ b/Android.mk
@@ -482,6 +482,7 @@
frameworks/base/wifi/java/android/net/wifi/p2p/nsd/WifiP2pServiceInfo.aidl \
frameworks/base/wifi/java/android/net/wifi/WpsInfo.aidl \
frameworks/base/wifi/java/android/net/wifi/ScanResult.aidl \
+ frameworks/base/wifi/java/android/net/wifi/ScanInfo.aidl \
frameworks/base/wifi/java/android/net/wifi/WifiEnterpriseConfig.aidl \
frameworks/base/wifi/java/android/net/wifi/WifiConfiguration.aidl \
frameworks/base/wifi/java/android/net/wifi/WifiInfo.aidl \
diff --git a/api/current.txt b/api/current.txt
index c45cc3d..7a4cd9b 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -18163,6 +18163,7 @@
field public static final java.lang.String CONNECTIVITY_ACTION = "android.net.conn.CONNECTIVITY_CHANGE";
field public static final deprecated int DEFAULT_NETWORK_PREFERENCE = 1; // 0x1
field public static final java.lang.String EXTRA_CAPTIVE_PORTAL = "android.net.extra.CAPTIVE_PORTAL";
+ field public static final java.lang.String EXTRA_CAPTIVE_PORTAL_URL = "android.net.extra.CAPTIVE_PORTAL_URL";
field public static final java.lang.String EXTRA_EXTRA_INFO = "extraInfo";
field public static final java.lang.String EXTRA_IS_FAILOVER = "isFailover";
field public static final java.lang.String EXTRA_NETWORK = "android.net.extra.NETWORK";
@@ -19069,6 +19070,22 @@
package android.net.wifi {
+ public class ScanInfo implements android.os.Parcelable {
+ ctor public ScanInfo(android.net.wifi.ScanResult);
+ ctor public ScanInfo(long, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String, byte[], int);
+ method public int describeContents();
+ method public long getBssid();
+ method public byte[] getIconData();
+ method public java.lang.String getIconType();
+ method public java.lang.String getName();
+ method public int getOsuIdentity();
+ method public int getRssi();
+ method public android.net.wifi.ScanResult getScanResult();
+ method public java.lang.String getServiceDescription();
+ method public java.lang.String getSsid();
+ method public void writeToParcel(android.os.Parcel, int);
+ }
+
public class ScanResult implements android.os.Parcelable {
method public int describeContents();
method public boolean is80211mcResponder();
@@ -19269,6 +19286,7 @@
method public java.util.List<android.net.wifi.WifiConfiguration> getConfiguredNetworks();
method public android.net.wifi.WifiInfo getConnectionInfo();
method public android.net.DhcpInfo getDhcpInfo();
+ method public java.util.List<android.net.wifi.ScanInfo> getScanInfos();
method public java.util.List<android.net.wifi.ScanResult> getScanResults();
method public int getWifiState();
method public boolean is5GHzBandSupported();
@@ -19284,6 +19302,7 @@
method public boolean reconnect();
method public boolean removeNetwork(int);
method public boolean saveConfiguration();
+ method public void setOsuSelection(int);
method public void setTdlsEnabled(java.net.InetAddress, boolean);
method public void setTdlsEnabledWithMacAddress(java.lang.String, boolean);
method public boolean setWifiEnabled(boolean);
diff --git a/api/system-current.txt b/api/system-current.txt
index 1e7b94e..5b5c34d 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -19676,6 +19676,7 @@
field public static final java.lang.String CONNECTIVITY_ACTION = "android.net.conn.CONNECTIVITY_CHANGE";
field public static final deprecated int DEFAULT_NETWORK_PREFERENCE = 1; // 0x1
field public static final java.lang.String EXTRA_CAPTIVE_PORTAL = "android.net.extra.CAPTIVE_PORTAL";
+ field public static final java.lang.String EXTRA_CAPTIVE_PORTAL_URL = "android.net.extra.CAPTIVE_PORTAL_URL";
field public static final java.lang.String EXTRA_EXTRA_INFO = "extraInfo";
field public static final java.lang.String EXTRA_IS_FAILOVER = "isFailover";
field public static final java.lang.String EXTRA_NETWORK = "android.net.extra.NETWORK";
@@ -20823,6 +20824,22 @@
field public byte id;
}
+ public class ScanInfo implements android.os.Parcelable {
+ ctor public ScanInfo(android.net.wifi.ScanResult);
+ ctor public ScanInfo(long, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String, byte[], int);
+ method public int describeContents();
+ method public long getBssid();
+ method public byte[] getIconData();
+ method public java.lang.String getIconType();
+ method public java.lang.String getName();
+ method public int getOsuIdentity();
+ method public int getRssi();
+ method public android.net.wifi.ScanResult getScanResult();
+ method public java.lang.String getServiceDescription();
+ method public java.lang.String getSsid();
+ method public void writeToParcel(android.os.Parcel, int);
+ }
+
public class ScanResult implements android.os.Parcelable {
method public int describeContents();
method public boolean is80211mcResponder();
@@ -21048,6 +21065,7 @@
method public android.net.wifi.WifiConnectionStatistics getConnectionStatistics();
method public android.net.DhcpInfo getDhcpInfo();
method public java.util.List<android.net.wifi.WifiConfiguration> getPrivilegedConfiguredNetworks();
+ method public java.util.List<android.net.wifi.ScanInfo> getScanInfos();
method public java.util.List<android.net.wifi.ScanResult> getScanResults();
method public int getWifiState();
method public boolean is5GHzBandSupported();
@@ -21067,6 +21085,7 @@
method public boolean reconnect();
method public boolean removeNetwork(int);
method public boolean saveConfiguration();
+ method public void setOsuSelection(int);
method public void setTdlsEnabled(java.net.InetAddress, boolean);
method public void setTdlsEnabledWithMacAddress(java.lang.String, boolean);
method public boolean setWifiEnabled(boolean);
@@ -25581,8 +25600,8 @@
ctor public UserHandle(android.os.Parcel);
method public int describeContents();
method public int getIdentifier();
- method public final boolean isOwner();
- method public static final int myUserId();
+ method public boolean isOwner();
+ method public static int myUserId();
method public static android.os.UserHandle readFromParcel(android.os.Parcel);
method public void writeToParcel(android.os.Parcel, int);
method public static void writeToParcel(android.os.UserHandle, android.os.Parcel);
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 4d9b759..ad9058f 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -208,6 +208,12 @@
* {@link android.content.Intent#getParcelableExtra(String)}.
*/
public static final String EXTRA_CAPTIVE_PORTAL = "android.net.extra.CAPTIVE_PORTAL";
+
+ /**
+ * Key for passing a URL to the captive portal login activity.
+ */
+ public static final String EXTRA_CAPTIVE_PORTAL_URL = "android.net.extra.CAPTIVE_PORTAL_URL";
+
/**
* Broadcast action to indicate the change of data activity status
* (idle or active) on a network in a recent period.
diff --git a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
index 0fe5509..abb464e 100644
--- a/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
+++ b/packages/CaptivePortalLogin/src/com/android/captiveportallogin/CaptivePortalLoginActivity.java
@@ -76,8 +76,9 @@
String server = Settings.Global.getString(getContentResolver(), "captive_portal_server");
if (server == null) server = DEFAULT_SERVER;
mCm = ConnectivityManager.from(this);
+ String url = getIntent().getStringExtra(ConnectivityManager.EXTRA_CAPTIVE_PORTAL_URL);
try {
- mURL = new URL("http", server, "/generate_204");
+ mURL = url != null ? new URL(url) : new URL("http", server, "/generate_204");
} catch (MalformedURLException e) {
// System misconfigured, bail out in a way that at least provides network access.
Log.e(TAG, "Invalid captive portal URL, server=" + server);
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl
index 0d95b38..23be8e0 100644
--- a/wifi/java/android/net/wifi/IWifiManager.aidl
+++ b/wifi/java/android/net/wifi/IWifiManager.aidl
@@ -23,6 +23,7 @@
import android.net.wifi.ScanSettings;
import android.net.wifi.WifiChannel;
import android.net.wifi.ScanResult;
+import android.net.wifi.ScanInfo;
import android.net.wifi.WifiConnectionStatistics;
import android.net.wifi.WifiActivityEnergyInfo;
import android.net.Network;
@@ -70,6 +71,10 @@
void disconnect();
+ List<ScanInfo> getScanInfos(String callingPackage);
+
+ void setOsuSelection(int osuID);
+
void reconnect();
void reassociate();
diff --git a/wifi/java/android/net/wifi/ScanInfo.aidl b/wifi/java/android/net/wifi/ScanInfo.aidl
new file mode 100644
index 0000000..18ae508
--- /dev/null
+++ b/wifi/java/android/net/wifi/ScanInfo.aidl
@@ -0,0 +1,19 @@
+/**
+ * Copyright (c) 2015, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.wifi;
+
+parcelable ScanInfo;
diff --git a/wifi/java/android/net/wifi/ScanInfo.java b/wifi/java/android/net/wifi/ScanInfo.java
new file mode 100644
index 0000000..39186fa
--- /dev/null
+++ b/wifi/java/android/net/wifi/ScanInfo.java
@@ -0,0 +1,189 @@
+package android.net.wifi;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+public class ScanInfo implements Parcelable {
+ private final ScanResult mScanResult;
+
+ private final long mBSSID; // The BSSID of the best AP with an SSID matching the OSU
+ private final int mRSSI; // RSSI of the AP with BSSID
+ private final String mSSID; // The SSID to connect to for an OSU connection.
+ private final String mName;
+ private final String mServiceDescription;
+ private final String mIconType;
+ private final byte[] mIconData;
+ private final int mOSUIdentity;
+
+ public ScanInfo(ScanResult scanResult) {
+ mScanResult = scanResult;
+
+ mBSSID = -1;
+ mRSSI = -1;
+ mSSID = null;
+ mName = null;
+ mServiceDescription = null;
+ mIconType = null;
+ mIconData = null;
+ mOSUIdentity = -1;
+ }
+
+ public ScanInfo(long BSSID, int rssi, String SSID, String name, String serviceDescription,
+ String iconType, byte[] iconData, int OSUIdentity) {
+ mBSSID = BSSID;
+ mRSSI = rssi;
+ mSSID = SSID;
+ mName = name;
+ mServiceDescription = serviceDescription;
+ mIconType = iconType;
+ mIconData = iconData;
+ mOSUIdentity = OSUIdentity;
+
+ mScanResult = null;
+ }
+
+ /**
+ * Get the scan result of this ScanInfo.
+ * @return The ScanResult, if this ScanInfo contains a one. If the ScanInfo contains
+ * OSU information getScanResult will return null.
+ */
+ public ScanResult getScanResult() {
+ return mScanResult;
+ }
+
+ /**
+ * OSU only: The BSSID of the AP who advertises the OSU SSID. This value is not guaranteed to
+ * be correct; In the somewhat unlikely case that multiple APs advertise OSU SSIDs that matches
+ * an OSU information element returned through ANQP and one of those is not related to an OSU
+ * there is a (slight) risk that the BSSID is for a "spoof" OSU.
+ * The matching algorithm that produces the ScanInfo objects makes a best effort to get the
+ * matching right though and since it is (a) fair to assume that the OSU SSID resides on the
+ * same AP as the one advertising the OSU information, and (b) BSSIDs for multi-SSID APs are
+ * typically adjacent to each other, matching will prefer the BSSID closest to the advertising
+ * APs BSSID if multiple SSIDs match.
+ * @return The BSSID.
+ */
+ public long getBssid() {
+ return mBSSID;
+ }
+
+ /**
+ * OSU only.
+ * @return The signal level of the AP associated with the BSSID from getBSSID.
+ */
+ public int getRssi() {
+ return mRSSI;
+ }
+
+ /**
+ * OSU only.
+ * @return The SSID of the AP to which to associate to establish an OSU connection.
+ */
+ public String getSsid() {
+ return mSSID;
+ }
+
+ /**
+ * OSU only.
+ * @return The name of the Service Provider of the OSU.
+ */
+ public String getName() {
+ return mName;
+ }
+
+ /**
+ * OSU only.
+ * @return The service description of the OSU.
+ */
+ public String getServiceDescription() {
+ return mServiceDescription;
+ }
+
+ /**
+ * OSU only.
+ * Get the type of icon that icon data represents, e.g. JPG, PNG etc. This field is formatted
+ * using standard MIME encodings per RFC-4288 and IANA MIME media types.
+ * @return The icon type in icon data.
+ */
+ public String getIconType() {
+ return mIconType;
+ }
+
+ /**
+ * OSU only.
+ * @return The binary data of the icon.
+ */
+ public byte[] getIconData() {
+ return mIconData;
+ }
+
+ /**
+ * OSU only.
+ * @return a unique identity for the OSU. This value is generated by the framework and should
+ * be used to uniquely identify a specific OSU. Please note that values may be reused after
+ * a very long time-span (in any normal scenario, likely years) and implementations should make
+ * sure to not rely on any long term persisted values.
+ */
+ public int getOsuIdentity() {
+ return mOSUIdentity;
+ }
+
+ private static final int ScanResultMarker = 0;
+ private static final int OSUMarker = 1;
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** Implement the Parcelable interface {@hide} */
+ public static final Creator<ScanInfo> CREATOR =
+ new Creator<ScanInfo>() {
+ @Override
+ public ScanInfo createFromParcel(Parcel source) {
+ int marker = source.readInt();
+ if (marker == ScanResultMarker) {
+ return new ScanInfo(ScanResult.CREATOR.createFromParcel(source));
+ }
+ else if (marker == OSUMarker) {
+ return new ScanInfo(
+ source.readLong(),
+ source.readInt(),
+ source.readString(),
+ source.readString(),
+ source.readString(),
+ source.readString(),
+ source.createByteArray(),
+ source.readInt()
+ );
+ }
+ else {
+ throw new RuntimeException("Bad ScanInfo data");
+ }
+ }
+
+ @Override
+ public ScanInfo[] newArray(int size) {
+ return new ScanInfo[0];
+ }
+ };
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ if (mScanResult != null) {
+ dest.writeInt(ScanResultMarker);
+ mScanResult.writeToParcel(dest, flags);
+ return;
+ }
+
+ dest.writeInt(OSUMarker);
+ dest.writeLong(mBSSID);
+ dest.writeInt(mRSSI);
+ dest.writeString(mSSID);
+ dest.writeString(mName);
+ dest.writeString(mServiceDescription);
+ dest.writeString(mIconType);
+ dest.writeByteArray(mIconData);
+ dest.writeInt(mOSUIdentity);
+ }
+}
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index cf88df4..ff8d6d4d 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -1315,6 +1315,30 @@
}
/**
+ * An augmented version of getScanResults that returns ScanResults as well as OSU information
+ * wrapped in ScanInfo objects.
+ * @return
+ */
+ public List<ScanInfo> getScanInfos() {
+ try {
+ return mService.getScanInfos(mContext.getOpPackageName());
+ } catch (RemoteException e) {
+ return null;
+ }
+ }
+
+ /**
+ * Notify the OSU framework about the currently selected OSU.
+ * @param osuID The OSU ID from ScanInfo.getOsuIdentity()
+ */
+ public void setOsuSelection(int osuID) {
+ try {
+ mService.setOsuSelection(osuID);
+ } catch (RemoteException e) {
+ }
+ }
+
+ /**
* Check if scanning is always available.
*
* If this return {@code true}, apps can issue {@link #startScan} and fetch scan results