summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorEtan Cohen <etancohen@google.com>2017-03-27 15:55:10 -0700
committerEtan Cohen <etancohen@google.com>2017-04-06 08:06:35 -0700
commitb81eb91076f713e800415d26d57a8109d4f35037 (patch)
tree076404f1b54bac8ab478a585e9ca9fe881f63752 /service
parent398b7247f7c0928a0320809b5b4efb9cba2d9d51 (diff)
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
Diffstat (limited to 'service')
-rw-r--r--service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java36
1 files changed, 28 insertions, 8 deletions
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java
index 5842a3bf8..b0a3f027a 100644
--- a/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java
+++ b/service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java
@@ -22,12 +22,15 @@ import android.net.ConnectivityManager;
import android.net.IpPrefix;
import android.net.LinkAddress;
import android.net.LinkProperties;
+import android.net.MatchAllNetworkSpecifier;
import android.net.NetworkAgent;
import android.net.NetworkCapabilities;
import android.net.NetworkFactory;
import android.net.NetworkInfo;
import android.net.NetworkRequest;
+import android.net.NetworkSpecifier;
import android.net.RouteInfo;
+import android.net.StringNetworkSpecifier;
import android.net.wifi.aware.WifiAwareManager;
import android.os.IBinder;
import android.os.INetworkManagementService;
@@ -113,8 +116,7 @@ public class WifiAwareDataPathStateManager {
.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED)
.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_RESTRICTED)
.addCapability(NetworkCapabilities.NET_CAPABILITY_TRUSTED);
- mNetworkCapabilitiesFilter
- .setNetworkSpecifier(NetworkCapabilities.MATCH_ALL_REQUESTS_NETWORK_SPECIFIER);
+ mNetworkCapabilitiesFilter.setNetworkSpecifier(new MatchAllNetworkSpecifier());
mNetworkCapabilitiesFilter.setLinkUpstreamBandwidthKbps(NETWORK_FACTORY_BANDWIDTH_AVAIL);
mNetworkCapabilitiesFilter.setLinkDownstreamBandwidthKbps(NETWORK_FACTORY_BANDWIDTH_AVAIL);
mNetworkCapabilitiesFilter.setSignalStrength(NETWORK_FACTORY_SIGNAL_STRENGTH_AVAIL);
@@ -568,12 +570,17 @@ public class WifiAwareDataPathStateManager {
return false;
}
- String networkSpecifier = request.networkCapabilities.getNetworkSpecifier();
- if (TextUtils.isEmpty(networkSpecifier)) {
+ NetworkSpecifier networkSpecifierObj =
+ request.networkCapabilities.getNetworkSpecifier();
+ if (networkSpecifierObj == null
+ || !(networkSpecifierObj instanceof StringNetworkSpecifier)
+ || TextUtils.isEmpty(
+ ((StringNetworkSpecifier) networkSpecifierObj).specifier)) {
Log.w(TAG, "WifiAwareNetworkFactory.acceptRequest: request=" + request
- + " - empty (or null) NetworkSpecifier");
+ + " - null, empty, or not a StringNetworkSpecifier");
return false;
}
+ String networkSpecifier = ((StringNetworkSpecifier) networkSpecifierObj).specifier;
// look up specifier - are we being called again?
AwareNetworkRequestInformation nnri = mNetworkRequestsCache.get(networkSpecifier);
@@ -609,7 +616,13 @@ public class WifiAwareDataPathStateManager {
+ networkRequest + ", score=" + score);
}
- String networkSpecifier = networkRequest.networkCapabilities.getNetworkSpecifier();
+ NetworkSpecifier networkSpecifierObj =
+ networkRequest.networkCapabilities.getNetworkSpecifier();
+ String networkSpecifier = "";
+ if (networkSpecifierObj != null
+ && networkSpecifierObj instanceof StringNetworkSpecifier) {
+ networkSpecifier = ((StringNetworkSpecifier) networkSpecifierObj).specifier;
+ }
AwareNetworkRequestInformation nnri = mNetworkRequestsCache.get(networkSpecifier);
if (nnri == null) {
Log.e(TAG, "WifiAwareNetworkFactory.needNetworkFor: networkRequest="
@@ -656,7 +669,14 @@ public class WifiAwareDataPathStateManager {
+ networkRequest);
}
- String networkSpecifier = networkRequest.networkCapabilities.getNetworkSpecifier();
+ NetworkSpecifier networkSpecifierObj =
+ networkRequest.networkCapabilities.getNetworkSpecifier();
+ String networkSpecifier = "";
+ if (networkSpecifierObj != null
+ && networkSpecifierObj instanceof StringNetworkSpecifier) {
+ networkSpecifier = ((StringNetworkSpecifier) networkSpecifierObj).specifier;
+ }
+
AwareNetworkRequestInformation nnri = mNetworkRequestsCache.get(networkSpecifier);
if (nnri == null) {
Log.e(TAG, "WifiAwareNetworkFactory.releaseNetworkFor: networkRequest="
@@ -1034,7 +1054,7 @@ public class WifiAwareDataPathStateManager {
networkInfo.setIsAvailable(true);
networkInfo.setDetailedState(NetworkInfo.DetailedState.CONNECTED, null, null);
- networkCapabilities.setNetworkSpecifier(networkSpecifier);
+ networkCapabilities.setNetworkSpecifier(new StringNetworkSpecifier(networkSpecifier));
linkProperties.setInterfaceName(nnri.interfaceName);
linkProperties.addLinkAddress(new LinkAddress(linkLocal, 64));