summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2017-04-18 08:22:51 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-04-18 08:22:52 +0000
commit8ab4881b5771ddd8ab3fa475362ac42efccff9c4 (patch)
tree24e4c1960262043c3f7fc7b0a3520acf605f4c26 /tests
parentb7c333ba6d7480d7531a2db3e84ad934187204a5 (diff)
parentfed87ea776ae79754b001a0a8cf5cd7d6a312139 (diff)
Merge "[AWARE] Implement custom network specifier"
Diffstat (limited to 'tests')
-rw-r--r--tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java31
1 files changed, 19 insertions, 12 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java
index 912dce2f3..e7a383c5e 100644
--- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java
@@ -37,7 +37,7 @@ import android.net.ConnectivityManager;
import android.net.NetworkCapabilities;
import android.net.NetworkFactory;
import android.net.NetworkRequest;
-import android.net.StringNetworkSpecifier;
+import android.net.NetworkSpecifier;
import android.net.wifi.aware.AttachCallback;
import android.net.wifi.aware.ConfigRequest;
import android.net.wifi.aware.DiscoverySession;
@@ -51,6 +51,7 @@ import android.net.wifi.aware.PublishDiscoverySession;
import android.net.wifi.aware.SubscribeConfig;
import android.net.wifi.aware.SubscribeDiscoverySession;
import android.net.wifi.aware.WifiAwareManager;
+import android.net.wifi.aware.WifiAwareNetworkSpecifier;
import android.net.wifi.aware.WifiAwareSession;
import android.os.Handler;
import android.os.INetworkManagementService;
@@ -64,7 +65,6 @@ import com.android.internal.util.AsyncChannel;
import libcore.util.HexEncoding;
-import org.json.JSONObject;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -418,12 +418,19 @@ public class WifiAwareDataPathStateManagerTest {
doPublish);
// corrupt the network specifier: reverse the role (so it's mis-matched)
- JSONObject jsonObject = new JSONObject(
- ((StringNetworkSpecifier) nr.networkCapabilities.getNetworkSpecifier()).specifier);
- jsonObject.put(WifiAwareManager.NETWORK_SPECIFIER_KEY_ROLE,
- 1 - jsonObject.getInt(WifiAwareManager.NETWORK_SPECIFIER_KEY_ROLE));
- nr.networkCapabilities.setNetworkSpecifier(
- new StringNetworkSpecifier(jsonObject.toString()));
+ WifiAwareNetworkSpecifier ns =
+ (WifiAwareNetworkSpecifier) nr.networkCapabilities.getNetworkSpecifier();
+ ns = new WifiAwareNetworkSpecifier(
+ ns.type,
+ 1 - ns.role, // corruption hack
+ ns.clientId,
+ ns.sessionId,
+ ns.peerId,
+ ns.peerMac,
+ ns.pmk,
+ ns.passphrase
+ );
+ nr.networkCapabilities.setNetworkSpecifier(ns);
Message reqNetworkMsg = Message.obtain();
reqNetworkMsg.what = NetworkFactory.CMD_REQUEST_NETWORK;
@@ -682,7 +689,7 @@ public class WifiAwareDataPathStateManagerTest {
(SubscribeDiscoverySession) discoverySession.capture());
}
- String ns;
+ NetworkSpecifier ns;
if (pmk == null) {
ns = discoverySession.getValue().createNetworkSpecifierOpen(peerHandle);
} else {
@@ -694,7 +701,7 @@ public class WifiAwareDataPathStateManagerTest {
nc.addTransportType(NetworkCapabilities.TRANSPORT_WIFI_AWARE);
nc.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN).addCapability(
NetworkCapabilities.NET_CAPABILITY_NOT_METERED);
- nc.setNetworkSpecifier(new StringNetworkSpecifier(ns));
+ nc.setNetworkSpecifier(ns);
nc.setLinkUpstreamBandwidthKbps(1);
nc.setLinkDownstreamBandwidthKbps(1);
nc.setSignalStrength(1);
@@ -721,7 +728,7 @@ public class WifiAwareDataPathStateManagerTest {
mMockLooper.dispatchAll();
verify(mockCallback).onAttached(sessionCaptor.capture());
- String ns;
+ NetworkSpecifier ns;
if (pmk == null) {
ns = sessionCaptor.getValue().createNetworkSpecifierOpen(role, peer);
} else {
@@ -732,7 +739,7 @@ public class WifiAwareDataPathStateManagerTest {
nc.addTransportType(NetworkCapabilities.TRANSPORT_WIFI_AWARE);
nc.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN).addCapability(
NetworkCapabilities.NET_CAPABILITY_NOT_METERED);
- nc.setNetworkSpecifier(new StringNetworkSpecifier(ns));
+ nc.setNetworkSpecifier(ns);
nc.setLinkUpstreamBandwidthKbps(1);
nc.setLinkDownstreamBandwidthKbps(1);
nc.setSignalStrength(1);