Merge "Fixing comments in Network Capabilities" am: b6477d22ca
am: 2c36870f3d
Change-Id: If3c0d76f9598d931d801271c4d0634e15f4b9ed4
This commit is contained in:
@@ -382,7 +382,7 @@ public final class NetworkCapabilities implements Parcelable {
|
|||||||
/**
|
/**
|
||||||
* Removes (if found) the given capability from this {@code NetworkCapability} instance.
|
* Removes (if found) the given capability from this {@code NetworkCapability} instance.
|
||||||
* <p>
|
* <p>
|
||||||
* Note that this method removes capabilities that was added via {@link #addCapability(int)},
|
* Note that this method removes capabilities that were added via {@link #addCapability(int)},
|
||||||
* {@link #addUnwantedCapability(int)} or {@link #setCapabilities(int[], int[])} .
|
* {@link #addUnwantedCapability(int)} or {@link #setCapabilities(int[], int[])} .
|
||||||
*
|
*
|
||||||
* @param capability the capability to be removed.
|
* @param capability the capability to be removed.
|
||||||
@@ -471,6 +471,7 @@ public final class NetworkCapabilities implements Parcelable {
|
|||||||
&& ((mUnwantedNetworkCapabilities & (1 << capability)) != 0);
|
&& ((mUnwantedNetworkCapabilities & (1 << capability)) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Note this method may result in having the same capability in wanted and unwanted lists. */
|
||||||
private void combineNetCapabilities(NetworkCapabilities nc) {
|
private void combineNetCapabilities(NetworkCapabilities nc) {
|
||||||
this.mNetworkCapabilities |= nc.mNetworkCapabilities;
|
this.mNetworkCapabilities |= nc.mNetworkCapabilities;
|
||||||
this.mUnwantedNetworkCapabilities |= nc.mUnwantedNetworkCapabilities;
|
this.mUnwantedNetworkCapabilities |= nc.mUnwantedNetworkCapabilities;
|
||||||
@@ -1132,7 +1133,11 @@ public final class NetworkCapabilities implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Combine a set of Capabilities to this one. Useful for coming up with the complete set
|
* Combine a set of Capabilities to this one. Useful for coming up with the complete set.
|
||||||
|
* <p>
|
||||||
|
* Note that this method may break an invariant of having a particular capability in either
|
||||||
|
* wanted or unwanted lists but never in both. Requests that have the same capability in
|
||||||
|
* both lists will never be satisfied.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public void combineCapabilities(NetworkCapabilities nc) {
|
public void combineCapabilities(NetworkCapabilities nc) {
|
||||||
|
|||||||
@@ -282,7 +282,7 @@ public class NetworkCapabilitiesTest {
|
|||||||
assertTrue("Request: " + request + ", Network:" + network,
|
assertTrue("Request: " + request + ", Network:" + network,
|
||||||
request.satisfiedByNetworkCapabilities(network));
|
request.satisfiedByNetworkCapabilities(network));
|
||||||
|
|
||||||
// Adding capabilities that doesn't exist in the network anyway
|
// Requesting absence of capabilities that network doesn't have. Request should satisfy.
|
||||||
request.addUnwantedCapability(NET_CAPABILITY_WIFI_P2P);
|
request.addUnwantedCapability(NET_CAPABILITY_WIFI_P2P);
|
||||||
request.addUnwantedCapability(NET_CAPABILITY_NOT_METERED);
|
request.addUnwantedCapability(NET_CAPABILITY_NOT_METERED);
|
||||||
assertTrue(request.satisfiedByNetworkCapabilities(network));
|
assertTrue(request.satisfiedByNetworkCapabilities(network));
|
||||||
@@ -297,7 +297,6 @@ public class NetworkCapabilitiesTest {
|
|||||||
assertTrue(request.hasUnwantedCapability(NET_CAPABILITY_NOT_RESTRICTED));
|
assertTrue(request.hasUnwantedCapability(NET_CAPABILITY_NOT_RESTRICTED));
|
||||||
assertFalse(request.hasCapability(NET_CAPABILITY_NOT_RESTRICTED));
|
assertFalse(request.hasCapability(NET_CAPABILITY_NOT_RESTRICTED));
|
||||||
|
|
||||||
|
|
||||||
// Now this request won't be satisfied because network contains NOT_RESTRICTED.
|
// Now this request won't be satisfied because network contains NOT_RESTRICTED.
|
||||||
assertFalse(request.satisfiedByNetworkCapabilities(network));
|
assertFalse(request.satisfiedByNetworkCapabilities(network));
|
||||||
network.removeCapability(NET_CAPABILITY_NOT_RESTRICTED);
|
network.removeCapability(NET_CAPABILITY_NOT_RESTRICTED);
|
||||||
|
|||||||
Reference in New Issue
Block a user