summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2017-04-18 09:02:02 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-04-18 09:02:02 +0000
commitfe30628f67c1398ee3bbcac2acafe843515ad3b0 (patch)
treea2821b64a848e1f2267313e879387da8518d033b /tests
parent313c6fb670de1a37772822ebf25b14e80301ecc1 (diff)
parent7f40dc9ed31156257e6a8b45a6694b042cc256cc (diff)
Merge "[AWARE] Implement custom network specifier" am: 8ab4881b57 am: 79327970e5 am: bd41467855
am: 7f40dc9ed3 Change-Id: I57bd375325a10bc1efe4c09b3285afc976aaeceb
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);