diff options
| author | 2020-01-17 14:33:52 +0900 | |
|---|---|---|
| committer | 2020-01-28 06:23:36 +0000 | |
| commit | ac16b8ae3ed2481d16b7649455f2b23edd51824f (patch) | |
| tree | 94d22d65674c18d71a3b3b5a8e978b2ee47a1fd7 | |
| parent | 48f7f07d525138a54f57fbc7fdb4c81d511a0aa4 (diff) | |
Make Information Elements (IE) of a scan result available as a public API.
Bug: 137835398
Test: atest FrameworksWifiTests
Test: attach to upstream hotspot device by selecting the sanned
ssid from wifi settings, then check the OUI, vendor specific
type fileds of IEs from the logcat.
Merged-In: If3b9906c75033f51bd35fcf054154125719ea958
Change-Id: If3b9906c75033f51bd35fcf054154125719ea958
| -rw-r--r-- | api/current.txt | 9 | ||||
| -rw-r--r-- | wifi/java/android/net/wifi/ScanResult.aidl | 2 | ||||
| -rw-r--r-- | wifi/java/android/net/wifi/ScanResult.java | 62 |
3 files changed, 63 insertions, 10 deletions
diff --git a/api/current.txt b/api/current.txt index be36bca6c720..2bcd09788b16 100644 --- a/api/current.txt +++ b/api/current.txt @@ -29914,7 +29914,9 @@ package android.net.ssl { package android.net.wifi { public class ScanResult implements android.os.Parcelable { + ctor public ScanResult(@NonNull android.net.wifi.ScanResult); method public int describeContents(); + method @NonNull public java.util.List<android.net.wifi.ScanResult.InformationElement> getInformationElements(); method public boolean is80211mcResponder(); method public boolean isPasspointNetwork(); method public void writeToParcel(android.os.Parcel, int); @@ -29924,6 +29926,7 @@ package android.net.wifi { field public static final int CHANNEL_WIDTH_40MHZ = 1; // 0x1 field public static final int CHANNEL_WIDTH_80MHZ = 2; // 0x2 field public static final int CHANNEL_WIDTH_80MHZ_PLUS_MHZ = 4; // 0x4 + field @NonNull public static final android.os.Parcelable.Creator<android.net.wifi.ScanResult> CREATOR; field public String SSID; field public String capabilities; field public int centerFreq0; @@ -29936,6 +29939,12 @@ package android.net.wifi { field public CharSequence venueName; } + public static class ScanResult.InformationElement { + ctor public ScanResult.InformationElement(@NonNull android.net.wifi.ScanResult.InformationElement); + method @NonNull public java.nio.ByteBuffer getBytes(); + method public int getId(); + } + public enum SupplicantState implements android.os.Parcelable { method public int describeContents(); method public static boolean isValidState(android.net.wifi.SupplicantState); diff --git a/wifi/java/android/net/wifi/ScanResult.aidl b/wifi/java/android/net/wifi/ScanResult.aidl index bb66722e4a13..b30689ca5d16 100644 --- a/wifi/java/android/net/wifi/ScanResult.aidl +++ b/wifi/java/android/net/wifi/ScanResult.aidl @@ -16,4 +16,4 @@ package android.net.wifi; -parcelable ScanResult; +@JavaOnlyStableParcelable parcelable ScanResult; diff --git a/wifi/java/android/net/wifi/ScanResult.java b/wifi/java/android/net/wifi/ScanResult.java index 2901bd8cbb48..2d0942d3ffa7 100644 --- a/wifi/java/android/net/wifi/ScanResult.java +++ b/wifi/java/android/net/wifi/ScanResult.java @@ -16,13 +16,16 @@ package android.net.wifi; +import android.annotation.NonNull; import android.annotation.SystemApi; import android.compat.annotation.UnsupportedAppUsage; import android.os.Parcel; import android.os.Parcelable; +import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Objects; @@ -433,58 +436,100 @@ public class ScanResult implements Parcelable { @UnsupportedAppUsage public List<String> anqpLines; - /** information elements from beacon - * @hide + /** + * information elements from beacon. */ public static class InformationElement { + /** @hide */ @UnsupportedAppUsage public static final int EID_SSID = 0; + /** @hide */ @UnsupportedAppUsage public static final int EID_SUPPORTED_RATES = 1; + /** @hide */ @UnsupportedAppUsage public static final int EID_TIM = 5; + /** @hide */ @UnsupportedAppUsage public static final int EID_BSS_LOAD = 11; + /** @hide */ @UnsupportedAppUsage public static final int EID_ERP = 42; + /** @hide */ public static final int EID_HT_CAPABILITIES = 45; + /** @hide */ @UnsupportedAppUsage public static final int EID_RSN = 48; + /** @hide */ @UnsupportedAppUsage public static final int EID_EXTENDED_SUPPORTED_RATES = 50; + /** @hide */ @UnsupportedAppUsage public static final int EID_HT_OPERATION = 61; + /** @hide */ @UnsupportedAppUsage public static final int EID_INTERWORKING = 107; + /** @hide */ @UnsupportedAppUsage public static final int EID_ROAMING_CONSORTIUM = 111; + /** @hide */ @UnsupportedAppUsage public static final int EID_EXTENDED_CAPS = 127; + /** @hide */ public static final int EID_VHT_CAPABILITIES = 191; + /** @hide */ @UnsupportedAppUsage public static final int EID_VHT_OPERATION = 192; + /** @hide */ @UnsupportedAppUsage public static final int EID_VSA = 221; + /** @hide */ @UnsupportedAppUsage public int id; + /** @hide */ @UnsupportedAppUsage public byte[] bytes; + /** @hide */ public InformationElement() { } - public InformationElement(InformationElement rhs) { + public InformationElement(@NonNull InformationElement rhs) { this.id = rhs.id; this.bytes = rhs.bytes.clone(); } + + /** + * The element ID of the information element. Defined in the IEEE 802.11-2016 spec + * Table 9-77. + */ + public int getId() { + return id; + } + + /** + * Get the specific content of the information element. + */ + @NonNull + public ByteBuffer getBytes() { + return ByteBuffer.wrap(bytes).asReadOnlyBuffer(); + } } - /** information elements found in the beacon + /** + * information elements found in the beacon. * @hide */ @UnsupportedAppUsage public InformationElement[] informationElements; + /** + * Get all information elements found in the beacon. + */ + @NonNull + public List<InformationElement> getInformationElements() { + return Collections.unmodifiableList(Arrays.asList(informationElements)); + } /** ANQP response elements. * @hide @@ -604,8 +649,8 @@ public class ScanResult implements Parcelable { this.wifiSsid = wifiSsid; } - /** copy constructor {@hide} */ - public ScanResult(ScanResult source) { + /** copy constructor */ + public ScanResult(@NonNull ScanResult source) { if (source != null) { wifiSsid = source.wifiSsid; SSID = source.SSID; @@ -759,9 +804,8 @@ public class ScanResult implements Parcelable { } } - /** Implement the Parcelable interface {@hide} */ - @UnsupportedAppUsage - public static final @android.annotation.NonNull Creator<ScanResult> CREATOR = + /** Implement the Parcelable interface */ + public static final @NonNull Creator<ScanResult> CREATOR = new Creator<ScanResult>() { public ScanResult createFromParcel(Parcel in) { WifiSsid wifiSsid = null; |