Merge changes from topic "network_request_match_callback"

* changes:
  WifiManager: Network request match callback registration
  wifi(API): NetworkSpecifier for Wifi NetworkAgent
  wifi(API): Mark old API's deprecated
  wifi(API): New API surface for network suggestion
  wifi(API): New API surface for connection via NetworkRequest
This commit is contained in:
Roshan Pius
2018-11-06 17:42:58 +00:00
committed by Android (Google) Code Review
2 changed files with 49 additions and 1 deletions

View File

@@ -17,8 +17,8 @@
package android.net;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import android.support.test.filters.SmallTest;
@@ -252,6 +252,39 @@ public class MacAddressTest {
}
}
@Test
public void testMatches() {
// match 4 bytes prefix
assertTrue(MacAddress.fromString("aa:bb:cc:dd:ee:11").matches(
MacAddress.fromString("aa:bb:cc:dd:00:00"),
MacAddress.fromString("ff:ff:ff:ff:00:00")));
// match bytes 0,1,2 and 5
assertTrue(MacAddress.fromString("aa:bb:cc:dd:ee:11").matches(
MacAddress.fromString("aa:bb:cc:00:00:11"),
MacAddress.fromString("ff:ff:ff:00:00:ff")));
// match 34 bit prefix
assertTrue(MacAddress.fromString("aa:bb:cc:dd:ee:11").matches(
MacAddress.fromString("aa:bb:cc:dd:c0:00"),
MacAddress.fromString("ff:ff:ff:ff:c0:00")));
// fail to match 36 bit prefix
assertFalse(MacAddress.fromString("aa:bb:cc:dd:ee:11").matches(
MacAddress.fromString("aa:bb:cc:dd:40:00"),
MacAddress.fromString("ff:ff:ff:ff:f0:00")));
// match all 6 bytes
assertTrue(MacAddress.fromString("aa:bb:cc:dd:ee:11").matches(
MacAddress.fromString("aa:bb:cc:dd:ee:11"),
MacAddress.fromString("ff:ff:ff:ff:ff:ff")));
// match none of 6 bytes
assertTrue(MacAddress.fromString("aa:bb:cc:dd:ee:11").matches(
MacAddress.fromString("00:00:00:00:00:00"),
MacAddress.fromString("00:00:00:00:00:00")));
}
static byte[] toByteArray(int... in) {
byte[] out = new byte[in.length];
for (int i = 0; i < in.length; i++) {