Hotspot 2.0 relase 2 first cut.

CP mods to take a URL as a parameter, and new ScanInfo object.

Change-Id: Idbb2d4751c575ba07a56942771e2b2955b624635
This commit is contained in:
Jan Nordqvist
2015-09-22 15:54:32 -07:00
parent 7794c359c7
commit 52eb29f082
9 changed files with 286 additions and 3 deletions

View File

@@ -483,6 +483,7 @@ aidl_files := \
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 \

View File

@@ -18250,6 +18250,7 @@ package android.net {
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";
@@ -19156,6 +19157,22 @@ package android.net.sip {
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();
@@ -19356,6 +19373,7 @@ package android.net.wifi {
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();
@@ -19371,6 +19389,7 @@ package android.net.wifi {
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);

View File

@@ -19762,6 +19762,7 @@ package android.net {
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";
@@ -20909,6 +20910,22 @@ package android.net.wifi {
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();
@@ -21134,6 +21151,7 @@ package android.net.wifi {
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();
@@ -21153,6 +21171,7 @@ package android.net.wifi {
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);
@@ -25667,8 +25686,8 @@ package android.os {
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);

View File

@@ -208,6 +208,12 @@ public class ConnectivityManager {
* {@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.

View File

@@ -76,8 +76,9 @@ public class CaptivePortalLoginActivity extends Activity {
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);

View File

@@ -23,6 +23,7 @@ import android.net.wifi.WifiInfo;
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 @@ interface IWifiManager
void disconnect();
List<ScanInfo> getScanInfos(String callingPackage);
void setOsuSelection(int osuID);
void reconnect();
void reassociate();

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -1314,6 +1314,30 @@ public class WifiManager {
}
}
/**
* 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.
*