Merge "cts: unregister softap callback after finish the test" into rvc-dev
diff --git a/tests/cts/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java b/tests/cts/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java
index 5eb3e36..29f091b 100644
--- a/tests/cts/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java
+++ b/tests/cts/net/src/android/net/wifi/aware/cts/SingleDeviceTest.java
@@ -64,6 +64,9 @@
// wait for Wi-Fi Aware state changes & network requests callbacks
static private final int WAIT_FOR_AWARE_CHANGE_SECS = 10; // 10 seconds
+ private static final int MIN_DISTANCE_MM = 1 * 1000;
+ private static final int MAX_DISTANCE_MM = 3 * 1000;
+ private static final byte[] PMK_VALID = "01234567890123456789012345678901".getBytes();
private final Object mLock = new Object();
private final HandlerThread mHandlerThread = new HandlerThread("SingleDeviceTest");
@@ -615,7 +618,8 @@
// 2. update-subscribe
subscribeConfig = new SubscribeConfig.Builder().setServiceName(
- serviceName).setServiceSpecificInfo("extras".getBytes()).build();
+ serviceName).setServiceSpecificInfo("extras".getBytes())
+ .setMinDistanceMm(MIN_DISTANCE_MM).build();
discoverySession.updateSubscribe(subscribeConfig);
assertTrue("Subscribe update", discoveryCb.waitForCallback(
DiscoverySessionCallbackTest.ON_SESSION_CONFIG_UPDATED));
@@ -741,7 +745,8 @@
}
/**
- * Request an Aware data-path (encrypted) as a Responder with an arbitrary peer MAC address.
+ * Request an Aware data-path (encrypted with Passphrase) as a Responder with an arbitrary peer
+ * MAC address.
* Validate that receive an onUnavailable() callback.
*/
public void testDataPathPassphraseOutOfBandFail() {
@@ -773,6 +778,40 @@
session.close();
}
+ /**
+ * Request an Aware data-path (encrypted with PMK) as a Responder with an arbitrary peer MAC
+ * address.
+ * Validate that receive an onUnavailable() callback.
+ */
+ public void testDataPathPmkOutOfBandFail() {
+ if (!TestUtils.shouldTestWifiAware(getContext())) {
+ return;
+ }
+ MacAddress mac = MacAddress.fromString("00:01:02:03:04:05");
+
+ // 1. initialize Aware: only purpose is to make sure it is available for OOB data-path
+ WifiAwareSession session = attachAndGetSession();
+
+ PublishConfig publishConfig = new PublishConfig.Builder().setServiceName(
+ "ValidName").build();
+ DiscoverySessionCallbackTest discoveryCb = new DiscoverySessionCallbackTest();
+ session.publish(publishConfig, discoveryCb, mHandler);
+ assertTrue("Publish started",
+ discoveryCb.waitForCallback(DiscoverySessionCallbackTest.ON_PUBLISH_STARTED));
+
+ // 2. request an AWARE network
+ NetworkCallbackTest networkCb = new NetworkCallbackTest();
+ NetworkRequest nr = new NetworkRequest.Builder().addTransportType(
+ NetworkCapabilities.TRANSPORT_WIFI_AWARE).setNetworkSpecifier(
+ session.createNetworkSpecifierPmk(
+ WifiAwareManager.WIFI_AWARE_DATA_PATH_ROLE_INITIATOR, mac.toByteArray(),
+ PMK_VALID)).build();
+ mConnectivityManager.requestNetwork(nr, networkCb);
+ assertTrue("OnUnavailable not received", networkCb.waitForOnUnavailable());
+
+ session.close();
+ }
+
// local utilities
private WifiAwareSession attachAndGetSession() {