diff options
author | Lorenzo Colitti <lorenzo@google.com> | 2017-04-12 22:58:45 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-04-12 22:58:45 +0000 |
commit | 6ac4be51565b2c0de7ee4928104692b19111910c (patch) | |
tree | 91eb6207eedfdd3eb093d3b73381b3e95a964342 /service | |
parent | fd04dc2ac414fe830299b23dfcdcabc25430baf6 (diff) | |
parent | 6055a6d756f131a052395b851129e174e412fb80 (diff) |
Merge "Make the NetworkSpecifier a class instead of a string." am: 8c8188a1e8 am: adc933f525
am: 6055a6d756
Change-Id: I9a52ccc70177a86d70cb8f24246109672837875c
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/aware/WifiAwareDataPathStateManager.java | 36 |
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)); |