Replace clearAll with withoutDefaultCapabilities

As the feedback from API review, the clearAll method in Builder
does not match the actual usage. Thus, remove it and replace
with withoutDefaultCapabilities to provide clearer usage.

Bug: 184735772
Test: make update-api ; m
Change-Id: Ida8d25d57504864f046e3403f593cc606fbfe982
CTS-Coverage-Bug: 186061922
This commit is contained in:
Chiachang Wang
2021-05-13 10:17:16 +08:00
parent 81370d77c3
commit c5c3bfb20e
2 changed files with 16 additions and 12 deletions

View File

@@ -2418,6 +2418,11 @@ public final class NetworkCapabilities implements Parcelable {
return mTransportInfo.getApplicableRedactions();
}
private NetworkCapabilities removeDefaultCapabilites() {
mNetworkCapabilities &= ~DEFAULT_CAPABILITIES;
return this;
}
/**
* Builder class for NetworkCapabilities.
*
@@ -2453,6 +2458,16 @@ public final class NetworkCapabilities implements Parcelable {
mCaps = new NetworkCapabilities(nc);
}
/**
* Creates a new Builder without the default capabilities.
*/
@NonNull
public static Builder withoutDefaultCapabilities() {
final NetworkCapabilities nc = new NetworkCapabilities();
nc.removeDefaultCapabilites();
return new Builder(nc);
}
/**
* Adds the given transport type.
*
@@ -2512,17 +2527,6 @@ public final class NetworkCapabilities implements Parcelable {
return this;
}
/**
* Completely clears the contents of this object, removing even the capabilities that are
* set by default when the object is constructed.
* @return this builder
*/
@NonNull
public Builder clearAll() {
mCaps.clearAll();
return this;
}
/**
* Sets the owner UID.
*