Expose uids related APIs in NetworkRequest and NetworkCapabilities
NetworkRequest is moving into the incoming connectivity mainline module. The hidden setUids becomes inaccessible outside the module. Shims for support cts in different API levels will need to use it to verify the behavior of NetworkRequest. Thus, expose it to the API surface. Also, VPN uses getUids and setUids to control network capabilities. Networkcapabilities is a part of incoming connectivity mainline module but VPN is not. Thus, exposing these two methods are needed to allow VPN to continue using it. Test: make update-api Bug: 172183305 Merged-In: I107c329d4d7130d488772166eae8b5e7aaa2ff04 Change-Id: If76877e6bde7abe3b5ddde078f87eefd027e675c
This commit is contained in:
committed by
Lorenzo Colitti
parent
545aafdd16
commit
32996ff68f
@@ -38,6 +38,7 @@ package android.net {
|
|||||||
|
|
||||||
public final class NetworkCapabilities implements android.os.Parcelable {
|
public final class NetworkCapabilities implements android.os.Parcelable {
|
||||||
ctor public NetworkCapabilities(@Nullable android.net.NetworkCapabilities, long);
|
ctor public NetworkCapabilities(@Nullable android.net.NetworkCapabilities, long);
|
||||||
|
method @Nullable public java.util.Set<android.util.Range<java.lang.Integer>> getUids();
|
||||||
field public static final long REDACT_ALL = -1L; // 0xffffffffffffffffL
|
field public static final long REDACT_ALL = -1L; // 0xffffffffffffffffL
|
||||||
field public static final long REDACT_FOR_ACCESS_FINE_LOCATION = 1L; // 0x1L
|
field public static final long REDACT_FOR_ACCESS_FINE_LOCATION = 1L; // 0x1L
|
||||||
field public static final long REDACT_FOR_LOCAL_MAC_ADDRESS = 2L; // 0x2L
|
field public static final long REDACT_FOR_LOCAL_MAC_ADDRESS = 2L; // 0x2L
|
||||||
@@ -46,6 +47,14 @@ package android.net {
|
|||||||
field public static final int TRANSPORT_TEST = 7; // 0x7
|
field public static final int TRANSPORT_TEST = 7; // 0x7
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final class NetworkCapabilities.Builder {
|
||||||
|
method @NonNull public android.net.NetworkCapabilities.Builder setUids(@Nullable java.util.Set<android.util.Range<java.lang.Integer>>);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class NetworkRequest.Builder {
|
||||||
|
method @NonNull public android.net.NetworkRequest.Builder setUids(@Nullable java.util.Set<android.util.Range<java.lang.Integer>>);
|
||||||
|
}
|
||||||
|
|
||||||
public class ParseException extends java.lang.RuntimeException {
|
public class ParseException extends java.lang.RuntimeException {
|
||||||
ctor public ParseException(@NonNull String);
|
ctor public ParseException(@NonNull String);
|
||||||
ctor public ParseException(@NonNull String, @NonNull Throwable);
|
ctor public ParseException(@NonNull String, @NonNull Throwable);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import android.annotation.LongDef;
|
|||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.RequiresPermission;
|
import android.annotation.RequiresPermission;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
import android.compat.annotation.UnsupportedAppUsage;
|
import android.compat.annotation.UnsupportedAppUsage;
|
||||||
import android.net.ConnectivityManager.NetworkCallback;
|
import android.net.ConnectivityManager.NetworkCallback;
|
||||||
@@ -1538,8 +1539,13 @@ public final class NetworkCapabilities implements Parcelable {
|
|||||||
/**
|
/**
|
||||||
* Get the list of UIDs this network applies to.
|
* Get the list of UIDs this network applies to.
|
||||||
* This returns a copy of the set so that callers can't modify the original object.
|
* This returns a copy of the set so that callers can't modify the original object.
|
||||||
|
*
|
||||||
|
* @return the list of UIDs this network applies to. If {@code null}, then the network applies
|
||||||
|
* to all UIDs.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
|
||||||
|
@SuppressLint("NullableCollection")
|
||||||
public @Nullable Set<Range<Integer>> getUids() {
|
public @Nullable Set<Range<Integer>> getUids() {
|
||||||
return UidRange.toIntRanges(mUids);
|
return UidRange.toIntRanges(mUids);
|
||||||
}
|
}
|
||||||
@@ -2741,6 +2747,21 @@ public final class NetworkCapabilities implements Parcelable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the list of UIDs this network applies to.
|
||||||
|
*
|
||||||
|
* @param uids the list of UIDs this network applies to, or {@code null} if this network
|
||||||
|
* applies to all UIDs.
|
||||||
|
* @return this builder
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
|
||||||
|
public Builder setUids(@Nullable Set<Range<Integer>> uids) {
|
||||||
|
mCaps.setUids(uids);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the instance of the capabilities.
|
* Builds the instance of the capabilities.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import static android.net.NetworkCapabilities.TRANSPORT_TEST;
|
|||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.RequiresPermission;
|
import android.annotation.RequiresPermission;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.annotation.SystemApi;
|
import android.annotation.SystemApi;
|
||||||
import android.compat.annotation.UnsupportedAppUsage;
|
import android.compat.annotation.UnsupportedAppUsage;
|
||||||
import android.net.NetworkCapabilities.NetCapability;
|
import android.net.NetworkCapabilities.NetCapability;
|
||||||
@@ -282,6 +283,9 @@ public class NetworkRequest implements Parcelable {
|
|||||||
* @return The builder to facilitate chaining.
|
* @return The builder to facilitate chaining.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
@NonNull
|
||||||
|
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
|
||||||
|
@SuppressLint("MissingGetterMatchingBuilder")
|
||||||
public Builder setUids(@Nullable Set<Range<Integer>> uids) {
|
public Builder setUids(@Nullable Set<Range<Integer>> uids) {
|
||||||
mNetworkCapabilities.setUids(uids);
|
mNetworkCapabilities.setUids(uids);
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
Reference in New Issue
Block a user