Merge "wifi: Check multicast mac address when setting SAP bssid"
This commit is contained in:
@@ -724,14 +724,17 @@ public final class SoftApConfiguration implements Parcelable {
|
||||
* @param bssid BSSID, or null to have the BSSID chosen by the framework. The caller is
|
||||
* responsible for avoiding collisions.
|
||||
* @return Builder for chaining.
|
||||
* @throws IllegalArgumentException when the given BSSID is the all-zero or broadcast MAC
|
||||
* address.
|
||||
* @throws IllegalArgumentException when the given BSSID is the all-zero
|
||||
* , multicast or broadcast MAC address.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setBssid(@Nullable MacAddress bssid) {
|
||||
if (bssid != null) {
|
||||
Preconditions.checkArgument(!bssid.equals(WifiManager.ALL_ZEROS_MAC_ADDRESS));
|
||||
Preconditions.checkArgument(!bssid.equals(MacAddress.BROADCAST_ADDRESS));
|
||||
if (bssid.getAddressType() != MacAddress.TYPE_UNICAST) {
|
||||
throw new IllegalArgumentException("bssid doesn't support "
|
||||
+ "multicast or broadcast mac address");
|
||||
}
|
||||
}
|
||||
mBssid = bssid;
|
||||
return this;
|
||||
|
||||
@@ -35,6 +35,7 @@ import java.util.Random;
|
||||
@SmallTest
|
||||
public class SoftApConfigurationTest {
|
||||
private static final String TEST_CHAR_SET_AS_STRING = "abcdefghijklmnopqrstuvwxyz0123456789";
|
||||
private static final String TEST_BSSID = "aa:22:33:aa:bb:cc";
|
||||
|
||||
private SoftApConfiguration parcelUnparcel(SoftApConfiguration configIn) {
|
||||
Parcel parcel = Parcel.obtain();
|
||||
@@ -67,12 +68,13 @@ public class SoftApConfigurationTest {
|
||||
|
||||
@Test
|
||||
public void testBasicSettings() {
|
||||
MacAddress testBssid = MacAddress.fromString(TEST_BSSID);
|
||||
SoftApConfiguration original = new SoftApConfiguration.Builder()
|
||||
.setSsid("ssid")
|
||||
.setBssid(MacAddress.fromString("11:22:33:44:55:66"))
|
||||
.setBssid(testBssid)
|
||||
.build();
|
||||
assertThat(original.getSsid()).isEqualTo("ssid");
|
||||
assertThat(original.getBssid()).isEqualTo(MacAddress.fromString("11:22:33:44:55:66"));
|
||||
assertThat(original.getBssid()).isEqualTo(testBssid);
|
||||
assertThat(original.getPassphrase()).isNull();
|
||||
assertThat(original.getSecurityType()).isEqualTo(SoftApConfiguration.SECURITY_TYPE_OPEN);
|
||||
assertThat(original.getBand()).isEqualTo(SoftApConfiguration.BAND_2GHZ);
|
||||
@@ -220,6 +222,20 @@ public class SoftApConfigurationTest {
|
||||
assertThat(copy.hashCode()).isEqualTo(original.hashCode());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidBroadcastBssid() {
|
||||
SoftApConfiguration original = new SoftApConfiguration.Builder()
|
||||
.setBssid(MacAddress.BROADCAST_ADDRESS)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidMulticastBssid() {
|
||||
SoftApConfiguration original = new SoftApConfiguration.Builder()
|
||||
.setBssid(MacAddress.fromString("01:aa:bb:cc:dd:ee"))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testInvalidShortPasswordLengthForWpa2() {
|
||||
SoftApConfiguration original = new SoftApConfiguration.Builder()
|
||||
|
||||
Reference in New Issue
Block a user