From b81eb91076f713e800415d26d57a8109d4f35037 Mon Sep 17 00:00:00 2001 From: Etan Cohen Date: Mon, 27 Mar 2017 15:55:10 -0700 Subject: Make the NetworkSpecifier a class instead of a string. Bug: 27533960 Bug: 36053921 Bug: 36275276 Test: unit tests (wifi), integration (aware) tests Change-Id: I6524e678a2f116ec8799c4c029bb3823dd889b2b --- .../server/wifi/aware/WifiAwareDataPathStateManagerTest.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tests') 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 29d0d12a6..912dce2f3 100644 --- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java @@ -37,6 +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.wifi.aware.AttachCallback; import android.net.wifi.aware.ConfigRequest; import android.net.wifi.aware.DiscoverySession; @@ -417,10 +418,12 @@ public class WifiAwareDataPathStateManagerTest { doPublish); // corrupt the network specifier: reverse the role (so it's mis-matched) - JSONObject jsonObject = new JSONObject(nr.networkCapabilities.getNetworkSpecifier()); + 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(jsonObject.toString()); + nr.networkCapabilities.setNetworkSpecifier( + new StringNetworkSpecifier(jsonObject.toString())); Message reqNetworkMsg = Message.obtain(); reqNetworkMsg.what = NetworkFactory.CMD_REQUEST_NETWORK; @@ -691,7 +694,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(ns); + nc.setNetworkSpecifier(new StringNetworkSpecifier(ns)); nc.setLinkUpstreamBandwidthKbps(1); nc.setLinkDownstreamBandwidthKbps(1); nc.setSignalStrength(1); @@ -729,7 +732,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(ns); + nc.setNetworkSpecifier(new StringNetworkSpecifier(ns)); nc.setLinkUpstreamBandwidthKbps(1); nc.setLinkDownstreamBandwidthKbps(1); nc.setSignalStrength(1); -- cgit v1.2.3