Merge "API to get network visible network capability name" into sc-dev

This commit is contained in:
Sarah Chin
2021-03-24 05:27:45 +00:00
committed by Android (Google) Code Review
2 changed files with 18 additions and 0 deletions

View File

@@ -270,6 +270,7 @@ package android.net {
public final class NetworkCapabilities implements android.os.Parcelable {
method @NonNull public int[] getAdministratorUids();
method @Nullable public static String getCapabilityCarrierName(int);
method @Nullable public String getSsid();
method @NonNull public int[] getTransportTypes();
method public boolean isPrivateDnsBroken();

View File

@@ -711,6 +711,23 @@ public final class NetworkCapabilities implements Parcelable {
return ((mNetworkCapabilities & CONNECTIVITY_MANAGED_CAPABILITIES) != 0);
}
/**
* Get the name of the given capability that carriers use.
* If the capability does not have a carrier-name, returns null.
*
* @param capability The capability to get the carrier-name of.
* @return The carrier-name of the capability, or null if it doesn't exist.
* @hide
*/
@SystemApi
public static @Nullable String getCapabilityCarrierName(@NetCapability int capability) {
if (capability == NET_CAPABILITY_ENTERPRISE) {
return capabilityNameOf(capability);
} else {
return null;
}
}
private void combineNetCapabilities(@NonNull NetworkCapabilities nc) {
final long wantedCaps = this.mNetworkCapabilities | nc.mNetworkCapabilities;
final long unwantedCaps =