Loading common/moduleutils/src/android/net/shared/ProvisioningConfiguration.java +28 −5 Original line number Diff line number Diff line Loading @@ -231,7 +231,11 @@ public class ProvisioningConfiguration { * InformationElements fields of ScanResult. */ public static class ScanResultInfo { @NonNull private final String mSsid; @NonNull private final String mBssid; @NonNull private final List<InformationElement> mInformationElements; /** Loading @@ -240,6 +244,7 @@ public class ProvisioningConfiguration { */ public static class InformationElement { private final int mId; @NonNull private final byte[] mPayload; public InformationElement(int id, @NonNull ByteBuffer payload) { Loading @@ -257,6 +262,7 @@ public class ProvisioningConfiguration { /** * Get the specific content of the information element. */ @NonNull public ByteBuffer getPayload() { return ByteBuffer.wrap(mPayload).asReadOnlyBuffer(); } Loading Loading @@ -293,6 +299,7 @@ public class ProvisioningConfiguration { * Create an instance of {@link InformationElement} based on the contents of the * specified {@link InformationElementParcelable}. */ @Nullable public static InformationElement fromStableParcelable(InformationElementParcelable p) { if (p == null) return null; return new InformationElement(p.id, Loading @@ -300,8 +307,12 @@ public class ProvisioningConfiguration { } } public ScanResultInfo(String ssid, @NonNull List<InformationElement> informationElements) { public ScanResultInfo(@NonNull String ssid, @NonNull String bssid, @NonNull List<InformationElement> informationElements) { Objects.requireNonNull(ssid, "ssid must not be null."); Objects.requireNonNull(bssid, "bssid must not be null."); mSsid = ssid; mBssid = bssid; mInformationElements = Collections.unmodifiableList(new ArrayList<>(informationElements)); } Loading @@ -309,13 +320,23 @@ public class ProvisioningConfiguration { /** * Get the scanned network name. */ @NonNull public String getSsid() { return mSsid; } /** * Get the address of the access point. */ @NonNull public String getBssid() { return mBssid; } /** * Get all information elements found in the beacon. */ @NonNull public List<InformationElement> getInformationElements() { return mInformationElements; } Loading @@ -324,6 +345,7 @@ public class ProvisioningConfiguration { public String toString() { StringBuffer str = new StringBuffer(); str.append("SSID: ").append(mSsid); str.append(", BSSID: ").append(mBssid); str.append(", Information Elements: {"); for (InformationElement ie : mInformationElements) { str.append("[").append(ie.toString()).append("]"); Loading @@ -338,12 +360,13 @@ public class ProvisioningConfiguration { if (!(o instanceof ScanResultInfo)) return false; ScanResultInfo other = (ScanResultInfo) o; return Objects.equals(mSsid, other.mSsid) && Objects.equals(mBssid, other.mBssid) && mInformationElements.equals(other.mInformationElements); } @Override public int hashCode() { return Objects.hash(mSsid, mInformationElements); return Objects.hash(mSsid, mBssid, mInformationElements); } /** Loading @@ -352,6 +375,7 @@ public class ProvisioningConfiguration { public ScanResultInfoParcelable toStableParcelable() { final ScanResultInfoParcelable p = new ScanResultInfoParcelable(); p.ssid = mSsid; p.bssid = mBssid; p.informationElements = toParcelableArray(mInformationElements, InformationElement::toStableParcelable, InformationElementParcelable.class); return p; Loading @@ -366,11 +390,10 @@ public class ProvisioningConfiguration { final List<InformationElement> ies = new ArrayList<InformationElement>(); ies.addAll(fromParcelableArray(p.informationElements, InformationElement::fromStableParcelable)); return new ScanResultInfo(p.ssid, ies); return new ScanResultInfo(p.ssid, p.bssid, ies); } private static byte[] convertToByteArray(final ByteBuffer buffer) { if (buffer == null) return null; private static byte[] convertToByteArray(@NonNull final ByteBuffer buffer) { final byte[] bytes = new byte[buffer.limit()]; final ByteBuffer copy = buffer.asReadOnlyBuffer(); try { Loading common/networkstackclient/aidl_api/networkstack-aidl-interfaces/current/android/net/ScanResultInfoParcelable.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -18,5 +18,6 @@ package android.net; parcelable ScanResultInfoParcelable { String ssid; String bssid; android.net.InformationElementParcelable[] informationElements; } common/networkstackclient/src/android/net/ScanResultInfoParcelable.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -20,5 +20,6 @@ import android.net.InformationElementParcelable; parcelable ScanResultInfoParcelable { String ssid; String bssid; InformationElementParcelable[] informationElements; } tests/integration/src/android/net/ip/IpClientIntegrationTest.java +5 −3 Original line number Diff line number Diff line Loading @@ -234,6 +234,7 @@ public class IpClientIntegrationTest { (byte) 0x00, (byte) 0x17, (byte) 0xF2 }; private static final byte TEST_VENDOR_SPECIFIC_TYPE = 0x06; private static final String TEST_DEFAULT_BSSID = "00:11:22:33:44:55"; private class Dependencies extends IpClient.Dependencies { private boolean mIsDhcpLeaseCacheEnabled; Loading Loading @@ -1578,7 +1579,7 @@ public class IpClientIntegrationTest { } private ScanResultInfo makeScanResultInfo(final int id, final String ssid, final byte[] oui, final byte type, final byte[] data) { final String bssid, final byte[] oui, final byte type, final byte[] data) { final ByteBuffer payload = ByteBuffer.allocate(4 + data.length); payload.put(oui); payload.put(type); Loading @@ -1586,13 +1587,14 @@ public class IpClientIntegrationTest { payload.flip(); final ScanResultInfo.InformationElement ie = new ScanResultInfo.InformationElement(id /* IE id */, payload); return new ScanResultInfo(ssid, Collections.singletonList(ie)); return new ScanResultInfo(ssid, bssid, Collections.singletonList(ie)); } private void doUpstreamHotspotDetectionTest(final int id, final String displayName, final String ssid, final byte[] oui, final byte type, final byte[] data) throws Exception { final ScanResultInfo info = makeScanResultInfo(id, ssid, oui, type, data); final ScanResultInfo info = makeScanResultInfo(id, ssid, TEST_DEFAULT_BSSID, oui, type, data); final long currentTime = System.currentTimeMillis(); final List<DhcpPacket> sentPackets = performDhcpHandshake(true /* isSuccessLease */, TEST_LEASE_DURATION_S, true /* isDhcpLeaseCacheEnabled */, Loading tests/unit/src/android/net/shared/ProvisioningConfigurationTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -57,7 +57,8 @@ public class ProvisioningConfigurationTest { final ScanResultInfo.InformationElement ie = new ScanResultInfo.InformationElement(0xdd /* vendor specific IE id */, ByteBuffer.wrap(payload)); return new ScanResultInfo(ssid, Collections.singletonList(ie)); return new ScanResultInfo(ssid, "01:02:03:04:05:06" /* bssid string */, Collections.singletonList(ie)); } @Before Loading Loading
common/moduleutils/src/android/net/shared/ProvisioningConfiguration.java +28 −5 Original line number Diff line number Diff line Loading @@ -231,7 +231,11 @@ public class ProvisioningConfiguration { * InformationElements fields of ScanResult. */ public static class ScanResultInfo { @NonNull private final String mSsid; @NonNull private final String mBssid; @NonNull private final List<InformationElement> mInformationElements; /** Loading @@ -240,6 +244,7 @@ public class ProvisioningConfiguration { */ public static class InformationElement { private final int mId; @NonNull private final byte[] mPayload; public InformationElement(int id, @NonNull ByteBuffer payload) { Loading @@ -257,6 +262,7 @@ public class ProvisioningConfiguration { /** * Get the specific content of the information element. */ @NonNull public ByteBuffer getPayload() { return ByteBuffer.wrap(mPayload).asReadOnlyBuffer(); } Loading Loading @@ -293,6 +299,7 @@ public class ProvisioningConfiguration { * Create an instance of {@link InformationElement} based on the contents of the * specified {@link InformationElementParcelable}. */ @Nullable public static InformationElement fromStableParcelable(InformationElementParcelable p) { if (p == null) return null; return new InformationElement(p.id, Loading @@ -300,8 +307,12 @@ public class ProvisioningConfiguration { } } public ScanResultInfo(String ssid, @NonNull List<InformationElement> informationElements) { public ScanResultInfo(@NonNull String ssid, @NonNull String bssid, @NonNull List<InformationElement> informationElements) { Objects.requireNonNull(ssid, "ssid must not be null."); Objects.requireNonNull(bssid, "bssid must not be null."); mSsid = ssid; mBssid = bssid; mInformationElements = Collections.unmodifiableList(new ArrayList<>(informationElements)); } Loading @@ -309,13 +320,23 @@ public class ProvisioningConfiguration { /** * Get the scanned network name. */ @NonNull public String getSsid() { return mSsid; } /** * Get the address of the access point. */ @NonNull public String getBssid() { return mBssid; } /** * Get all information elements found in the beacon. */ @NonNull public List<InformationElement> getInformationElements() { return mInformationElements; } Loading @@ -324,6 +345,7 @@ public class ProvisioningConfiguration { public String toString() { StringBuffer str = new StringBuffer(); str.append("SSID: ").append(mSsid); str.append(", BSSID: ").append(mBssid); str.append(", Information Elements: {"); for (InformationElement ie : mInformationElements) { str.append("[").append(ie.toString()).append("]"); Loading @@ -338,12 +360,13 @@ public class ProvisioningConfiguration { if (!(o instanceof ScanResultInfo)) return false; ScanResultInfo other = (ScanResultInfo) o; return Objects.equals(mSsid, other.mSsid) && Objects.equals(mBssid, other.mBssid) && mInformationElements.equals(other.mInformationElements); } @Override public int hashCode() { return Objects.hash(mSsid, mInformationElements); return Objects.hash(mSsid, mBssid, mInformationElements); } /** Loading @@ -352,6 +375,7 @@ public class ProvisioningConfiguration { public ScanResultInfoParcelable toStableParcelable() { final ScanResultInfoParcelable p = new ScanResultInfoParcelable(); p.ssid = mSsid; p.bssid = mBssid; p.informationElements = toParcelableArray(mInformationElements, InformationElement::toStableParcelable, InformationElementParcelable.class); return p; Loading @@ -366,11 +390,10 @@ public class ProvisioningConfiguration { final List<InformationElement> ies = new ArrayList<InformationElement>(); ies.addAll(fromParcelableArray(p.informationElements, InformationElement::fromStableParcelable)); return new ScanResultInfo(p.ssid, ies); return new ScanResultInfo(p.ssid, p.bssid, ies); } private static byte[] convertToByteArray(final ByteBuffer buffer) { if (buffer == null) return null; private static byte[] convertToByteArray(@NonNull final ByteBuffer buffer) { final byte[] bytes = new byte[buffer.limit()]; final ByteBuffer copy = buffer.asReadOnlyBuffer(); try { Loading
common/networkstackclient/aidl_api/networkstack-aidl-interfaces/current/android/net/ScanResultInfoParcelable.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -18,5 +18,6 @@ package android.net; parcelable ScanResultInfoParcelable { String ssid; String bssid; android.net.InformationElementParcelable[] informationElements; }
common/networkstackclient/src/android/net/ScanResultInfoParcelable.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -20,5 +20,6 @@ import android.net.InformationElementParcelable; parcelable ScanResultInfoParcelable { String ssid; String bssid; InformationElementParcelable[] informationElements; }
tests/integration/src/android/net/ip/IpClientIntegrationTest.java +5 −3 Original line number Diff line number Diff line Loading @@ -234,6 +234,7 @@ public class IpClientIntegrationTest { (byte) 0x00, (byte) 0x17, (byte) 0xF2 }; private static final byte TEST_VENDOR_SPECIFIC_TYPE = 0x06; private static final String TEST_DEFAULT_BSSID = "00:11:22:33:44:55"; private class Dependencies extends IpClient.Dependencies { private boolean mIsDhcpLeaseCacheEnabled; Loading Loading @@ -1578,7 +1579,7 @@ public class IpClientIntegrationTest { } private ScanResultInfo makeScanResultInfo(final int id, final String ssid, final byte[] oui, final byte type, final byte[] data) { final String bssid, final byte[] oui, final byte type, final byte[] data) { final ByteBuffer payload = ByteBuffer.allocate(4 + data.length); payload.put(oui); payload.put(type); Loading @@ -1586,13 +1587,14 @@ public class IpClientIntegrationTest { payload.flip(); final ScanResultInfo.InformationElement ie = new ScanResultInfo.InformationElement(id /* IE id */, payload); return new ScanResultInfo(ssid, Collections.singletonList(ie)); return new ScanResultInfo(ssid, bssid, Collections.singletonList(ie)); } private void doUpstreamHotspotDetectionTest(final int id, final String displayName, final String ssid, final byte[] oui, final byte type, final byte[] data) throws Exception { final ScanResultInfo info = makeScanResultInfo(id, ssid, oui, type, data); final ScanResultInfo info = makeScanResultInfo(id, ssid, TEST_DEFAULT_BSSID, oui, type, data); final long currentTime = System.currentTimeMillis(); final List<DhcpPacket> sentPackets = performDhcpHandshake(true /* isSuccessLease */, TEST_LEASE_DURATION_S, true /* isDhcpLeaseCacheEnabled */, Loading
tests/unit/src/android/net/shared/ProvisioningConfigurationTest.java +2 −1 Original line number Diff line number Diff line Loading @@ -57,7 +57,8 @@ public class ProvisioningConfigurationTest { final ScanResultInfo.InformationElement ie = new ScanResultInfo.InformationElement(0xdd /* vendor specific IE id */, ByteBuffer.wrap(payload)); return new ScanResultInfo(ssid, Collections.singletonList(ie)); return new ScanResultInfo(ssid, "01:02:03:04:05:06" /* bssid string */, Collections.singletonList(ie)); } @Before Loading