Source:
private NetworkCapabilities getCapabilities(WifiConfiguration currentWifiConfiguration) { final NetworkCapabilities result = new NetworkCapabilities(mNetworkCapabilitiesFilter); result.setNetworkSpecifier(null); if (currentWifiConfiguration == null) { return result; } if (!mWifiInfo.isTrusted()) { result.removeCapability(NetworkCapabilities.NET_CAPABILITY_TRUSTED); } else { result.addCapability(NetworkCapabilities.NET_CAPABILITY_TRUSTED); } result.setAdministratorUids(Arrays.asList(currentWifiConfiguration.creatorUid)); if (!WifiConfiguration.isMetered(currentWifiConfiguration, mWifiInfo)) { result.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED); } else { result.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED); } if (mWifiInfo.getRssi() != WifiInfo.INVALID_RSSI) { result.setSignalStrength(mWifiInfo.getRssi()); } else { result.setSignalStrength(NetworkCapabilities.SIGNAL_STRENGTH_UNSPECIFIED); } if (currentWifiConfiguration.osu) { result.removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); } if (!mWifiInfo.getSSID().equals(WifiSsid.NONE)) { result.setSSID(mWifiInfo.getSSID()); } else { result.setSSID(null); } Pair<Integer, String> specificRequestUidAndPackageName = mNetworkFactory.getSpecificNetworkRequestUidAndPackageName( currentWifiConfiguration); if (specificRequestUidAndPackageName.first != Process.INVALID_UID) { result.removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); } result.setNetworkSpecifier( createNetworkAgentSpecifier( currentWifiConfiguration, getCurrentBSSID(), specificRequestUidAndPackageName.first, specificRequestUidAndPackageName.second)); return result; }

Target:
private NetworkCapabilities getCapabilities(WifiConfiguration currentWifiConfiguration) { final NetworkCapabilities result = new NetworkCapabilities(mNetworkCapabilitiesFilter); result.setNetworkSpecifier(null); if (currentWifiConfiguration == null) { return result; } if (!mWifiInfo.isTrusted()) { result.removeCapability(NetworkCapabilities.NET_CAPABILITY_TRUSTED); } else { result.addCapability(NetworkCapabilities.NET_CAPABILITY_TRUSTED); } result.setOwnerUid(currentWifiConfiguration.creatorUid); result.setAdministratorUids(Arrays.asList(currentWifiConfiguration.creatorUid)); if (!WifiConfiguration.isMetered(currentWifiConfiguration, mWifiInfo)) { result.addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED); } else { result.removeCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED); } if (mWifiInfo.getRssi() != WifiInfo.INVALID_RSSI) { result.setSignalStrength(mWifiInfo.getRssi()); } else { result.setSignalStrength(NetworkCapabilities.SIGNAL_STRENGTH_UNSPECIFIED); } if (currentWifiConfiguration.osu) { result.removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); } if (!mWifiInfo.getSSID().equals(WifiSsid.NONE)) { result.setSSID(mWifiInfo.getSSID()); } else { result.setSSID(null); } Pair<Integer, String> specificRequestUidAndPackageName = mNetworkFactory.getSpecificNetworkRequestUidAndPackageName( currentWifiConfiguration); if (specificRequestUidAndPackageName.first != Process.INVALID_UID) { result.removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET); } result.setNetworkSpecifier( createNetworkAgentSpecifier( currentWifiConfiguration, getCurrentBSSID(), specificRequestUidAndPackageName.first, specificRequestUidAndPackageName.second)); return result; }