Fix setCapabilities.
P introduced setSSID, UIDs and unwanted capabilities. None of these exhibit commutative behavior through combineCapabilities because their semantics don't allow it. Therefore NetworkRequest.setCapabilities() is badly broken around any of these. Look at the comments in the new tests to realize the extent of the damage. Clean cherry-pick of ag/4083952 Bug: 79748782 Test: new tests written, old tests pass Change-Id: Iafe074126132a82af37f4bf056c4a7b8d56bdc83 Merged-In: Ia5bebf8a233775367bbf1b788870528934ecbcfb Merged-In: I13d7782a6c0c7b1f94137995bbb0d257a58d89c1
This commit is contained in:
parent
d082c6c128
commit
52a6d547b7
2 changed files with 78 additions and 14 deletions
|
|
@ -61,16 +61,7 @@ public final class NetworkCapabilities implements Parcelable {
|
|||
|
||||
public NetworkCapabilities(NetworkCapabilities nc) {
|
||||
if (nc != null) {
|
||||
mNetworkCapabilities = nc.mNetworkCapabilities;
|
||||
mTransportTypes = nc.mTransportTypes;
|
||||
mLinkUpBandwidthKbps = nc.mLinkUpBandwidthKbps;
|
||||
mLinkDownBandwidthKbps = nc.mLinkDownBandwidthKbps;
|
||||
mNetworkSpecifier = nc.mNetworkSpecifier;
|
||||
mSignalStrength = nc.mSignalStrength;
|
||||
mUids = nc.mUids;
|
||||
mEstablishingVpnAppUid = nc.mEstablishingVpnAppUid;
|
||||
mUnwantedNetworkCapabilities = nc.mUnwantedNetworkCapabilities;
|
||||
mSSID = nc.mSSID;
|
||||
set(nc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -89,6 +80,23 @@ public final class NetworkCapabilities implements Parcelable {
|
|||
mSSID = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set all contents of this object to the contents of a NetworkCapabilities.
|
||||
* @hide
|
||||
*/
|
||||
public void set(NetworkCapabilities nc) {
|
||||
mNetworkCapabilities = nc.mNetworkCapabilities;
|
||||
mTransportTypes = nc.mTransportTypes;
|
||||
mLinkUpBandwidthKbps = nc.mLinkUpBandwidthKbps;
|
||||
mLinkDownBandwidthKbps = nc.mLinkDownBandwidthKbps;
|
||||
mNetworkSpecifier = nc.mNetworkSpecifier;
|
||||
mSignalStrength = nc.mSignalStrength;
|
||||
setUids(nc.mUids); // Will make the defensive copy
|
||||
mEstablishingVpnAppUid = nc.mEstablishingVpnAppUid;
|
||||
mUnwantedNetworkCapabilities = nc.mUnwantedNetworkCapabilities;
|
||||
mSSID = nc.mSSID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents the network's capabilities. If any are specified they will be satisfied
|
||||
* by any Network that matches all of them.
|
||||
|
|
|
|||
|
|
@ -197,8 +197,7 @@ public class NetworkRequest implements Parcelable {
|
|||
* @hide
|
||||
*/
|
||||
public Builder setCapabilities(NetworkCapabilities nc) {
|
||||
mNetworkCapabilities.clearAll();
|
||||
mNetworkCapabilities.combineCapabilities(nc);
|
||||
mNetworkCapabilities.set(nc);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue