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
Merged-In: Ida8d25d57504864f046e3403f593cc606fbfe982
This commit is contained in:
Chiachang Wang
2021-05-13 10:17:16 +08:00
parent 59d89299c9
commit cf6e5210ba
2 changed files with 16 additions and 12 deletions

View File

@@ -2401,6 +2401,11 @@ public final class NetworkCapabilities implements Parcelable {
return mTransportInfo.getApplicableRedactions();
}
private NetworkCapabilities removeDefaultCapabilites() {
mNetworkCapabilities &= ~DEFAULT_CAPABILITIES;
return this;
}
/**
* Builder class for NetworkCapabilities.
*
@@ -2436,6 +2441,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.
*
@@ -2495,17 +2510,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.
*