New System APIs for Passpoint r2 app.

Change-Id: I09428e9a393999f43aefe5efd77cffe4b1b17da5
diff --git a/Android.mk b/Android.mk
index 9192e96..7164778 100644
--- a/Android.mk
+++ b/Android.mk
@@ -493,7 +493,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/PasspointManagementObjectDefinition.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 3691270..f7608b0 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -19078,22 +19078,6 @@
 
 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();
@@ -19254,6 +19238,7 @@
     field public static final int SIM = 4; // 0x4
     field public static final int TLS = 1; // 0x1
     field public static final int TTLS = 2; // 0x2
+    field public static final int UNAUTH_TLS = 7; // 0x7
   }
 
   public static final class WifiEnterpriseConfig.Phase2 {
@@ -19296,7 +19281,6 @@
     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();
@@ -19312,7 +19296,6 @@
     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 b09a4a2..a8671d4 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -20832,22 +20832,6 @@
     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();
@@ -21030,6 +21014,7 @@
     field public static final int SIM = 4; // 0x4
     field public static final int TLS = 1; // 0x1
     field public static final int TTLS = 2; // 0x2
+    field public static final int UNAUTH_TLS = 7; // 0x7
   }
 
   public static final class WifiEnterpriseConfig.Phase2 {
@@ -21075,7 +21060,6 @@
     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();
@@ -21095,7 +21079,6 @@
     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/wifi/java/android/net/wifi/AnqpInformationElement.java b/wifi/java/android/net/wifi/AnqpInformationElement.java
new file mode 100644
index 0000000..47b7129
--- /dev/null
+++ b/wifi/java/android/net/wifi/AnqpInformationElement.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2016 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;
+
+/**
+ * This object contains the payload of an ANQP element.
+ * Vendor id is the vendor ID for the element, or 0 if it is an 802.11(u) element.
+ * Hotspot 2.0 uses the WFA Vendor ID which is 0x506f9a
+ * The payload contains the bytes of the payload, starting after the length octet(s).
+ * @hide
+ */
+public class AnqpInformationElement {
+    public static final int HOTSPOT20_VENDOR_ID = 0x506f9a;
+
+    public static final int ANQP_QUERY_LIST = 256;
+    public static final int ANQP_CAPABILITY_LIST = 257;
+    public static final int ANQP_VENUE_NAME = 258;
+    public static final int ANQP_EMERGENCY_NUMBER = 259;
+    public static final int ANQP_NWK_AUTH_TYPE = 260;
+    public static final int ANQP_ROAMING_CONSORTIUM = 261;
+    public static final int ANQP_IP_ADDR_AVAILABILITY = 262;
+    public static final int ANQP_NAI_REALM = 263;
+    public static final int ANQP_3GPP_NETWORK = 264;
+    public static final int ANQP_GEO_LOC = 265;
+    public static final int ANQP_CIVIC_LOC = 266;
+    public static final int ANQP_LOC_URI = 267;
+    public static final int ANQP_DOM_NAME = 268;
+    public static final int ANQP_EMERGENCY_ALERT = 269;
+    public static final int ANQP_TDLS_CAP = 270;
+    public static final int ANQP_EMERGENCY_NAI = 271;
+    public static final int ANQP_NEIGHBOR_REPORT = 272;
+    public static final int ANQP_VENDOR_SPEC = 56797;
+
+    public static final int HS_QUERY_LIST = 1;
+    public static final int HS_CAPABILITY_LIST = 2;
+    public static final int HS_FRIENDLY_NAME = 3;
+    public static final int HS_WAN_METRICS = 4;
+    public static final int HS_CONN_CAPABILITY = 5;
+    public static final int HS_NAI_HOME_REALM_QUERY = 6;
+    public static final int HS_OPERATING_CLASS = 7;
+    public static final int HS_OSU_PROVIDERS = 8;
+    public static final int HS_ICON_REQUEST = 10;
+    public static final int HS_ICON_FILE = 11;
+
+    private final int mVendorId;
+    private final int mElementId;
+    private final byte[] mPayload;
+
+    public AnqpInformationElement(int vendorId, int elementId, byte[] payload) {
+        mVendorId = vendorId;
+        mElementId = elementId;
+        mPayload = payload;
+    }
+
+    public int getVendorId() {
+        return mVendorId;
+    }
+
+    public int getElementId() {
+        return mElementId;
+    }
+
+    public byte[] getPayload() {
+        return mPayload;
+    }
+}
diff --git a/wifi/java/android/net/wifi/IWifiManager.aidl b/wifi/java/android/net/wifi/IWifiManager.aidl
index bad4e9c..1c7a308 100644
--- a/wifi/java/android/net/wifi/IWifiManager.aidl
+++ b/wifi/java/android/net/wifi/IWifiManager.aidl
@@ -20,7 +20,7 @@
 import android.net.wifi.WifiInfo;
 import android.net.wifi.ScanSettings;
 import android.net.wifi.ScanResult;
-import android.net.wifi.ScanInfo;
+import android.net.wifi.PasspointManagementObjectDefinition;
 import android.net.wifi.WifiConnectionStatistics;
 import android.net.wifi.WifiActivityEnergyInfo;
 import android.net.Network;
@@ -50,6 +50,17 @@
 
     int addOrUpdateNetwork(in WifiConfiguration config);
 
+    int addPasspointManagementObject(String mo);
+
+    int modifyPasspointManagementObject(String fqdn,
+                                        in List<PasspointManagementObjectDefinition> mos);
+
+    void queryPasspointIcon(long bssid, String fileName);
+
+    int matchProviderWithCurrentNetwork(String fqdn);
+
+    void deauthenticateNetwork(long holdoff, boolean ess);
+
     boolean removeNetwork(int netId);
 
     boolean enableNetwork(int netId, boolean disableOthers);
@@ -64,10 +75,6 @@
 
     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/PasspointManagementObjectDefinition.aidl
similarity index 84%
rename from wifi/java/android/net/wifi/ScanInfo.aidl
rename to wifi/java/android/net/wifi/PasspointManagementObjectDefinition.aidl
index 18ae508..eb7cc39 100644
--- a/wifi/java/android/net/wifi/ScanInfo.aidl
+++ b/wifi/java/android/net/wifi/PasspointManagementObjectDefinition.aidl
@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2015, The Android Open Source Project
+ * Copyright (c) 2008, 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.
@@ -16,4 +16,4 @@
 
 package android.net.wifi;
 
-parcelable ScanInfo;
+parcelable PasspointManagementObjectDefinition;
diff --git a/wifi/java/android/net/wifi/PasspointManagementObjectDefinition.java b/wifi/java/android/net/wifi/PasspointManagementObjectDefinition.java
new file mode 100644
index 0000000..611ed15
--- /dev/null
+++ b/wifi/java/android/net/wifi/PasspointManagementObjectDefinition.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2016 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;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * This object describes a partial tree structure in the Hotspot 2.0 release 2 management object.
+ * The object is used during subscription remediation to modify parts of an existing PPS MO
+ * tree (Hotspot 2.0 specification section 9.1).
+ * @hide
+ */
+public class PasspointManagementObjectDefinition implements Parcelable {
+    private final String mBaseUri;
+    private final String mUrn;
+    private final String mMoTree;
+
+    public PasspointManagementObjectDefinition(String baseUri, String urn, String moTree) {
+        mBaseUri = baseUri;
+        mUrn = urn;
+        mMoTree = moTree;
+    }
+
+    public String getmBaseUri() {
+        return mBaseUri;
+    }
+
+    public String getmUrn() {
+        return mUrn;
+    }
+
+    public String getmMoTree() {
+        return mMoTree;
+    }
+
+    @Override
+    public int describeContents() {
+        return 0;
+    }
+
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+        dest.writeString(mBaseUri);
+        dest.writeString(mUrn);
+        dest.writeString(mMoTree);
+    }
+
+    /**
+     * Implement the Parcelable interface {@hide}
+     */
+    public static final Creator<PasspointManagementObjectDefinition> CREATOR =
+            new Creator<PasspointManagementObjectDefinition>() {
+                public PasspointManagementObjectDefinition createFromParcel(Parcel in) {
+                    return new PasspointManagementObjectDefinition(
+                            in.readString(),    /* base URI */
+                            in.readString(),    /* URN */
+                            in.readString()     /* Tree XML */
+                    );
+                }
+
+                public PasspointManagementObjectDefinition[] newArray(int size) {
+                    return new PasspointManagementObjectDefinition[size];
+                }
+            };
+}
+
diff --git a/wifi/java/android/net/wifi/ScanInfo.java b/wifi/java/android/net/wifi/ScanInfo.java
deleted file mode 100644
index 39186fa..0000000
--- a/wifi/java/android/net/wifi/ScanInfo.java
+++ /dev/null
@@ -1,189 +0,0 @@
-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/ScanResult.java b/wifi/java/android/net/wifi/ScanResult.java
index 1f05339..22a84eb 100644
--- a/wifi/java/android/net/wifi/ScanResult.java
+++ b/wifi/java/android/net/wifi/ScanResult.java
@@ -43,6 +43,19 @@
      * The address of the access point.
      */
     public String BSSID;
+
+    /**
+     * The HESSID from the beacon.
+     * @hide
+     */
+    public long hessid;
+
+    /**
+     * The ANQP Domain ID from the Hotspot 2.0 Indication element, if present.
+     * @hide
+     */
+    public int anqpDomainId;
+
     /**
      * Describes the authentication, key management, and encryption schemes
      * supported by the access point.
@@ -341,14 +354,27 @@
     /** information elements found in the beacon
      * @hide
      */
-    public InformationElement informationElements[];
+    public InformationElement[] informationElements;
+
+    /** ANQP response elements.
+     * @hide
+     */
+    public AnqpInformationElement[] anqpElements;
 
     /** {@hide} */
-    public ScanResult(WifiSsid wifiSsid, String BSSID, String caps, int level, int frequency,
-            long tsf) {
+    public ScanResult(WifiSsid wifiSsid, String BSSID, long hessid, int anqpDomainId,
+            byte[] osuProviders, String caps, int level, int frequency, long tsf) {
         this.wifiSsid = wifiSsid;
         this.SSID = (wifiSsid != null) ? wifiSsid.toString() : WifiSsid.NONE;
         this.BSSID = BSSID;
+        this.hessid = hessid;
+        this.anqpDomainId = anqpDomainId;
+        if (osuProviders != null) {
+            this.anqpElements = new AnqpInformationElement[1];
+            this.anqpElements[0] =
+                    new AnqpInformationElement(AnqpInformationElement.HOTSPOT20_VENDOR_ID,
+                            AnqpInformationElement.HS_OSU_PROVIDERS, osuProviders);
+        }
         this.capabilities = caps;
         this.level = level;
         this.frequency = frequency;
@@ -380,11 +406,14 @@
     }
 
     /** {@hide} */
-    public ScanResult(String Ssid, String BSSID, String caps, int level, int frequency,
+    public ScanResult(String Ssid, String BSSID, long hessid, int anqpDomainId, String caps,
+            int level, int frequency,
             long tsf, int distCm, int distSdCm, int channelWidth, int centerFreq0, int centerFreq1,
             boolean is80211McRTTResponder) {
         this.SSID = Ssid;
         this.BSSID = BSSID;
+        this.hessid = hessid;
+        this.anqpDomainId = anqpDomainId;
         this.capabilities = caps;
         this.level = level;
         this.frequency = frequency;
@@ -402,11 +431,12 @@
     }
 
     /** {@hide} */
-    public ScanResult(WifiSsid wifiSsid, String Ssid, String BSSID, String caps, int level,
+    public ScanResult(WifiSsid wifiSsid, String Ssid, String BSSID, long hessid, int anqpDomainId,
+                  String caps, int level,
                   int frequency, long tsf, int distCm, int distSdCm, int channelWidth,
                   int centerFreq0, int centerFreq1, boolean is80211McRTTResponder) {
-        this(Ssid, BSSID, caps,level, frequency, tsf, distCm, distSdCm, channelWidth, centerFreq0,
-                centerFreq1, is80211McRTTResponder);
+        this(Ssid, BSSID, hessid, anqpDomainId, caps, level, frequency, tsf, distCm,
+                distSdCm, channelWidth, centerFreq0, centerFreq1, is80211McRTTResponder);
         this.wifiSsid = wifiSsid;
     }
 
@@ -416,6 +446,10 @@
             wifiSsid = source.wifiSsid;
             SSID = source.SSID;
             BSSID = source.BSSID;
+            hessid = source.hessid;
+            anqpDomainId = source.anqpDomainId;
+            informationElements = source.informationElements;
+            anqpElements = source.anqpElements;
             capabilities = source.capabilities;
             level = source.level;
             frequency = source.frequency;
@@ -496,6 +530,8 @@
         }
         dest.writeString(SSID);
         dest.writeString(BSSID);
+        dest.writeLong(hessid);
+        dest.writeInt(anqpDomainId);
         dest.writeString(capabilities);
         dest.writeInt(level);
         dest.writeInt(frequency);
@@ -532,6 +568,15 @@
             for (int i = 0; i < anqpLines.size(); i++) {
                 dest.writeString(anqpLines.get(i));
             }
+        }
+        if (anqpElements != null) {
+            dest.writeInt(anqpElements.length);
+            for (AnqpInformationElement element : anqpElements) {
+                dest.writeInt(element.getVendorId());
+                dest.writeInt(element.getElementId());
+                dest.writeInt(element.getPayload().length);
+                dest.writeByteArray(element.getPayload());
+            }
         } else {
             dest.writeInt(0);
         }
@@ -546,19 +591,22 @@
                     wifiSsid = WifiSsid.CREATOR.createFromParcel(in);
                 }
                 ScanResult sr = new ScanResult(
-                    wifiSsid,
-                    in.readString(),                    /* SSID  */
-                    in.readString(),                    /* BSSID */
-                    in.readString(),                    /* capabilities */
-                    in.readInt(),                       /* level */
-                    in.readInt(),                       /* frequency */
-                    in.readLong(),                      /* timestamp */
-                    in.readInt(),                       /* distanceCm */
-                    in.readInt(),                       /* distanceSdCm */
-                    in.readInt(),                       /* channelWidth */
-                    in.readInt(),                       /* centerFreq0 */
-                    in.readInt(),                       /* centerFreq1 */
-                    false                               /* rtt responder, fixed with flags below */
+                        wifiSsid,
+                        in.readString(),                    /* SSID  */
+                        in.readString(),                    /* BSSID */
+                        in.readLong(),                      /* HESSID */
+                        in.readInt(),                       /* ANQP Domain ID */
+                        in.readString(),                    /* capabilities */
+                        in.readInt(),                       /* level */
+                        in.readInt(),                       /* frequency */
+                        in.readLong(),                      /* timestamp */
+                        in.readInt(),                       /* distanceCm */
+                        in.readInt(),                       /* distanceSdCm */
+                        in.readInt(),                       /* channelWidth */
+                        in.readInt(),                       /* centerFreq0 */
+                        in.readInt(),                       /* centerFreq1 */
+                        false                               /* rtt responder,
+                                                               fixed with flags below */
                 );
 
                 sr.seen = in.readLong();
@@ -590,6 +638,19 @@
                         sr.anqpLines.add(in.readString());
                     }
                 }
+                n = in.readInt();
+                if (n != 0) {
+                    sr.anqpElements = new AnqpInformationElement[n];
+                    for (int i = 0; i < n; i++) {
+                        int vendorId = in.readInt();
+                        int elementId = in.readInt();
+                        int len = in.readInt();
+                        byte[] payload = new byte[len];
+                        in.readByteArray(payload);
+                        sr.anqpElements[n] =
+                                new AnqpInformationElement(vendorId, elementId, payload);
+                    }
+                }
                 return sr;
             }
 
diff --git a/wifi/java/android/net/wifi/WifiConfiguration.java b/wifi/java/android/net/wifi/WifiConfiguration.java
index c6354bd..c8065f9 100644
--- a/wifi/java/android/net/wifi/WifiConfiguration.java
+++ b/wifi/java/android/net/wifi/WifiConfiguration.java
@@ -58,6 +58,9 @@
     /** {@hide} */
     public static final int INVALID_NETWORK_ID = -1;
 
+    /** {@hide} */
+    private String mPasspointManagementObjectTree;
+
     /**
      * Recognized key management schemes.
      */
@@ -79,11 +82,16 @@
           * @hide
           */
         public static final int WPA2_PSK = 4;
+        /**
+         * Hotspot 2.0 r2 OSEN:
+         * @hide
+         */
+        public static final int OSEN = 5;
 
         public static final String varName = "key_mgmt";
 
         public static final String[] strings = { "NONE", "WPA_PSK", "WPA_EAP", "IEEE8021X",
-                "WPA2_PSK" };
+                "WPA2_PSK", "OSEN" };
     }
 
     /**
@@ -96,10 +104,14 @@
         public static final int WPA = 0;
         /** WPA2/IEEE 802.11i */
         public static final int RSN = 1;
+        /** HS2.0 r2 OSEN
+         * @hide
+         */
+        public static final int OSEN = 2;
 
         public static final String varName = "proto";
 
-        public static final String[] strings = { "WPA", "RSN" };
+        public static final String[] strings = { "WPA", "RSN", "OSEN" };
     }
 
     /**
@@ -158,10 +170,15 @@
         public static final int TKIP = 2;
         /** AES in Counter mode with CBC-MAC [RFC 3610, IEEE 802.11i/D7.0] */
         public static final int CCMP = 3;
+        /** Hotspot 2.0 r2 OSEN
+         * @hide
+         */
+        public static final int GTK_NOT_USED = 4;
 
         public static final String varName = "group";
 
-        public static final String[] strings = { "WEP40", "WEP104", "TKIP", "CCMP" };
+        public static final String[] strings =
+                { "WEP40", "WEP104", "TKIP", "CCMP", "GTK_NOT_USED" };
     }
 
     /** Possible status of a network configuration. */
@@ -1734,6 +1751,16 @@
         return shared || (UserHandle.getUserId(creatorUid) == userId);
     }
 
+    /** @hide */
+    public void setPasspointManagementObjectTree(String passpointManagementObjectTree) {
+        mPasspointManagementObjectTree = passpointManagementObjectTree;
+    }
+
+    /** @hide */
+    public String getMoTree() {
+        return mPasspointManagementObjectTree;
+    }
+
     /** copy constructor {@hide} */
     public WifiConfiguration(WifiConfiguration source) {
         if (source != null) {
@@ -1885,6 +1912,7 @@
         dest.writeInt(numNoInternetAccessReports);
         dest.writeInt(noInternetAccessExpected ? 1 : 0);
         dest.writeInt(shared ? 1 : 0);
+        dest.writeString(mPasspointManagementObjectTree);
     }
 
     /** Implement the Parcelable interface {@hide} */
@@ -1953,6 +1981,7 @@
                 config.numNoInternetAccessReports = in.readInt();
                 config.noInternetAccessExpected = in.readInt() != 0;
                 config.shared = in.readInt() != 0;
+                config.mPasspointManagementObjectTree = in.readString();
                 return config;
             }
 
diff --git a/wifi/java/android/net/wifi/WifiEnterpriseConfig.java b/wifi/java/android/net/wifi/WifiEnterpriseConfig.java
index 53efe6c..d77f2bb 100644
--- a/wifi/java/android/net/wifi/WifiEnterpriseConfig.java
+++ b/wifi/java/android/net/wifi/WifiEnterpriseConfig.java
@@ -284,8 +284,11 @@
         public static final int AKA     = 5;
         /** EAP-Authentication and Key Agreement Prime */
         public static final int AKA_PRIME = 6;
+        /** Hotspot 2.0 r2 OSEN */
+        public static final int UNAUTH_TLS = 7;
         /** @hide */
-        public static final String[] strings = { "PEAP", "TLS", "TTLS", "PWD", "SIM", "AKA", "AKA'" };
+        public static final String[] strings =
+                { "PEAP", "TLS", "TTLS", "PWD", "SIM", "AKA", "AKA'", "WFA-UNAUTH-TLS" };
 
         /** Prevent initialization */
         private Eap() {}
diff --git a/wifi/java/android/net/wifi/WifiManager.java b/wifi/java/android/net/wifi/WifiManager.java
index 50f2cf0..4133cda 100644
--- a/wifi/java/android/net/wifi/WifiManager.java
+++ b/wifi/java/android/net/wifi/WifiManager.java
@@ -26,28 +26,26 @@
 import android.net.Network;
 import android.net.NetworkCapabilities;
 import android.net.NetworkRequest;
-import android.net.wifi.ScanSettings;
 import android.os.Binder;
 import android.os.Build;
-import android.os.IBinder;
 import android.os.Handler;
 import android.os.HandlerThread;
+import android.os.IBinder;
 import android.os.Looper;
 import android.os.Message;
+import android.os.Messenger;
 import android.os.RemoteException;
 import android.os.WorkSource;
-import android.os.Messenger;
 import android.util.Log;
 import android.util.SparseArray;
 
-import java.net.InetAddress;
-import java.util.concurrent.CountDownLatch;
-
 import com.android.internal.annotations.GuardedBy;
 import com.android.internal.util.AsyncChannel;
 import com.android.internal.util.Protocol;
 
+import java.net.InetAddress;
 import java.util.List;
+import java.util.concurrent.CountDownLatch;
 
 /**
  * This class provides the primary API for managing all aspects of Wi-Fi
@@ -114,6 +112,51 @@
     public static final int WIFI_CREDENTIAL_FORGOT = 1;
 
     /**
+     * Broadcast intent action indicating that the a Passpoint release 2 icon has been received.
+     * @hide
+     */
+    public static final String PASSPOINT_ICON_RECEIVED_ACTION =
+            "android.net.wifi.PASSPOINT_ICON_RECEIVED";
+    /** @hide */
+    public static final String EXTRA_PASSPOINT_ICON_BSSID = "bssid";
+    /** @hide */
+    public static final String EXTRA_PASSPOINT_ICON_FILE = "file";
+    /** @hide */
+    public static final String EXTRA_PASSPOINT_ICON_DATA = "icon";
+
+    /**
+     * Broadcast intent action indicating that the a Passpoint release
+     * 2 WNM frame has been received.
+     * @hide
+     */
+    public static final String PASSPOINT_WNM_FRAME_RECEIVED_ACTION =
+            "android.net.wifi.PASSPOINT_WNM_FRAME_RECEIVED";
+    /**
+     * Originating BSS
+     * @hide */
+    public static final String EXTRA_PASSPOINT_WNM_BSSID = "bssid";
+    /**
+     * SOAP-XML or OMA-DM
+     * @hide */
+    public static final String EXTRA_PASSPOINT_WNM_METHOD = "method";
+    /**
+     * Type of Passpoint match
+     * @hide */
+    public static final String EXTRA_PASSPOINT_WNM_PPOINT_MATCH = "match";
+    /**
+     * String
+     * @hide */
+    public static final String EXTRA_PASSPOINT_WNM_URL = "url";
+    /**
+     * Boolean true=ess, false=bss
+     * @hide */
+    public static final String EXTRA_PASSPOINT_WNM_ESS = "ess";
+    /**
+     * Delay in seconds
+     * @hide */
+    public static final String EXTRA_PASSPOINT_WNM_DELAY = "delay";
+
+    /**
      * Broadcast intent action indicating that Wi-Fi has been enabled, disabled,
      * enabling, disabling, or unknown. One extra provides this state as an int.
      * Another extra provides the previous state, if available.
@@ -771,6 +814,76 @@
     }
 
     /**
+     * Add a Hotspot 2.0 release 2 Management Object
+     * @param mo The MO in XML form
+     * @return -1 for failure
+     * @hide
+     */
+    public int addPasspointManagementObject(String mo) {
+        try {
+            return mService.addPasspointManagementObject(mo);
+        } catch (RemoteException e) {
+            return -1;
+        }
+    }
+
+    /**
+     * Modify a Hotspot 2.0 release 2 Management Object
+     * @param fqdn The FQDN of the service provider
+     * @param mos A List of MO definitions to be updated
+     * @return the number of nodes updated, or -1 for failure
+     * @hide
+     */
+    public int modifyPasspointManagementObject(String fqdn,
+                                               List<PasspointManagementObjectDefinition> mos) {
+        try {
+            return mService.modifyPasspointManagementObject(fqdn, mos);
+        } catch (RemoteException e) {
+            return -1;
+        }
+    }
+
+    /**
+     * Query for a Hotspot 2.0 release 2 OSU icon
+     * @param bssid The BSSID of the AP
+     * @param fileName Icon file name
+     * @hide
+     */
+    public void queryPasspointIcon(long bssid, String fileName) {
+        try {
+            mService.queryPasspointIcon(bssid, fileName);
+        } catch (RemoteException e) {
+        }
+    }
+
+    /**
+     * Match the currently associated network against the SP matching the given FQDN
+     * @param fqdn FQDN of the SP
+     * @return ordinal [HomeProvider, RoamingProvider, Incomplete, None, Declined]
+     * @hide
+     */
+    public int matchProviderWithCurrentNetwork(String fqdn) {
+        try {
+            return mService.matchProviderWithCurrentNetwork(fqdn);
+        } catch (RemoteException e) {
+            return -1;
+        }
+    }
+
+    /**
+     * Deauthenticate and set the re-authentication hold off time for the current network
+     * @param holdoff hold off time in milliseconds
+     * @param ess set if the hold off pertains to an ESS rather than a BSS
+     * @hide
+     */
+    public void deauthenticateNetwork(long holdoff, boolean ess) {
+        try {
+            mService.deauthenticateNetwork(holdoff, ess);
+        } catch (RemoteException e) {
+        }
+    }
+
+    /**
      * Remove the specified network from the list of configured networks.
      * This may result in the asynchronous delivery of state change
      * events.
@@ -1191,30 +1304,6 @@
     }
 
     /**
-     * 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